I’ve installed this newest version of the plugin, but seem to be dealing with a weird bug.
When the plugin is activated (if functioning properly) there is a link on the plugins menu below de-activate to configre your page name (pages or content or page for example). For some reason this doesn’t always appear (have tried on several installations old and new) and it dissapears after being configured.
My problem is I can’t get the sucker re-activated (menu option doesn’t display) after migrating my blog. Can anyone provide a path, database location, or fix so that I can get my EzStatic working again?
]]>Goal – To call external html files inside WordPress – maintaining in a manned that template is maintained. The HTML file has JavaScript code.
Problem – The problem is that the javascript functions do not get executed when external HTML files are called by EzStatic. EzStatic works well when calling plain html files which do not have javascript.
Question –
1) Is there another way to do what Im trying to do i.e. call external html files which are in the same webserver, Maintaining the template style. These HTML files have javascript.
Thank you once again. Your help is very much appreciated.
Regards
Mark
Thanks to Stephen, aka “gravity”, for help debugging the ob_ functions.
*/
/*
EzStatic – Allows easy display of static content within
the WP blog context.
Copyright (c) 2005 Owen Winkler
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated
documentation files (the “Software”), to deal in the
Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to
do so, subject to the following conditions:
The above copyright notice and this permission notice shall
be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
INSTRUCTIONS:
Detailed instructions at:
https://redalt.com/wiki/EzStatic
No edits to the WordPress source are required.
Just drop this into your WordPress plugins directory, and then
Activate it on the Plugins tab of the WordPress admin console.
If you are a user of high enough level and you check the new
option checkbox that appears below the post editing area, then
posts that contain PHP tags will be executed in the posts that
you write.
Also, you can include existing files into
your WordPress template:
Add a querystring to your URL that points to your static file.
Like this:
https://www.example.com/index.php?static=mystaticfile
EzStatic will try to open in order from your blog directory:
mystaticfile
mystaticfile.php
mystaticfile.htm
If the static file specified is PHP, it will execute the file
and display the results. This file may contain WordPress
template tags and functions.
For plugin developers:
You can use EzStatic in your own functions to create static-like
pages from your plugins!
Simply dump all of your output into a variable, then send it
with a new page title to the function EzStatic_force().
EzStatic will automatically insert your content in place of the
default post listing.
If you receive reports that EzStatic isn’t working, turn OFF
gzip support in your WordPress admin panel. (Options, Reading)
*/
if(!function_exists(‘EzStatic_include_up’)) :
function EzStatic_include_up($filename) {
$c=0;
while(!is_file($filename)) {
$filename = ‘../’ . $filename;
$c++;
if($c==30) {
echo ‘Could not find ‘ . basename($filename) . ‘.’;
return ”;
}
}
return $filename;
}
endif;
if(!defined(‘ABSPATH’)) {
// Things to do when the file is called solo
include(EzStatic_include_up(‘wp-config.php’));
$ezs_options = get_settings(‘ezstatic’);
if($ezs_options == ”) {
$ezs_options = array(
‘qs_key’ => ‘static’,
‘fileexts’ => array(‘.php’, ‘.htm’, ‘.html’, ‘.txt’, ‘.asp’),
‘block’ => array(‘htaccess’),
‘page_template’ => ”,
);
update_option(‘ezstatic’, $ezs_options);
}
if(isset($_POST[‘config’])) {
// Things to do when the Ajax gets ya
include_once(ABSPATH.’/wp-admin/admin-functions.php’);
auth_redirect();
?>
<div style=”padding:5px;”><!– margin:1px;border:1px solid #14568a;padding:5px;padding-top:10px; –>
<?php EzStatic_options_form(); ?>
</div>
<?php
} else {
// Things to do without Ajax
}
die();
};
// Things to do when the file is included as a plugin
add_filter(‘wp_head’, ‘EzStatic_head’);
//add_filter(‘admin_footer’, ‘EzStatic_admin_footer’);
add_filter(‘edit_form_advanced’, ‘EzStatic_edit_page_UI’);
add_filter(‘edit_page_form’, ‘EzStatic_edit_page_UI’);
//add_filter(‘edit_post’, ‘EzStatic_edit_post’);
//add_filter(‘publish_post’, ‘EzStatic_edit_post’);
add_action(‘save_post’, ‘EzStatic_edit_post’);
add_filter(‘capabilities_list’, ‘EzStatic_capabilities_list’);
add_filter(‘the_content’, ‘EzStatic_the_content’, 0);
add_filter(‘template_redirect’, ‘EzStatic_template_redirect’);
add_filter(‘admin_menu’, ‘EzStatic_admin_menu’);
$EzStatic_newcontent = ”;
$EzStatic_newhead = ”;
$EzStatic_newtitle = ”;
function EzStatic_relativeURL($attrib, $href, $rel)
{
if(($href{0} == “\\”) || (preg_match(“|https://[^ ]*|i”, $href))) {
return “{$attrib}=\”{$href}”;
}
else {
return “{$attrib}=\”{$rel}{$href}\””;
}
}
function EzStatic_basename($file) {
return preg_replace(‘/^.*wp-content[\\\\\/]plugins[\\\\\/]/’, ”, $file);
}
function EzStatic_template_redirect() {
global $wp_query, $post_cache, $EzStatic_newtitle, $EzStatic_newcontent, $EzStatic_page_template;
$ezs_options = get_settings(‘ezstatic’);
extract($ezs_options);
if(!isset($_REQUEST[$ezs_options[‘qs_key’]])) return;
global $wp_rewrite;
$wp_query->posts[0]->ID = -100;
$wp_query->posts[0]->post_author = 1;
$wp_query->posts[0]->post_date = date(‘Y-m-d h:i:s’);
$wp_query->posts[0]->post_date_gmt = get_gmt_from_date(date(‘Y-m-d h:i:s’));
$wp_query->posts[0]->post_content = $EzStatic_newcontent;
$wp_query->posts[0]->post_title = $EzStatic_newtitle;
$wp_query->posts[0]->post_category = 0;
$wp_query->posts[0]->post_excerpt = ”;
$wp_query->posts[0]->post_status = ‘static’;
$wp_query->posts[0]->comment_status = ‘closed’;
$wp_query->posts[0]->ping_status = ‘closed’;
$wp_query->posts[0]->post_password = ”;
$wp_query->posts[0]->post_name = ‘NAME’;
$wp_query->posts[0]->to_ping = ”;
$wp_query->posts[0]->pinged = ”;
$wp_query->posts[0]->post_modified = date(‘Y-m-d h:i:s’);
$wp_query->posts[0]->post_modified_gmt = get_gmt_from_date(date(‘Y-m-d h:i:s’));
$wp_query->posts[0]->post_content_filtered = ”;
$wp_query->posts[0]->post_parent = 0;
$wp_query->posts[0]->guid = ‘GUID’;
$wp_query->posts[0]->menu_order = ‘0’;
$wp_query->posts[0]->post_type = ”;
$wp_query->post = $wp_query->posts[0];
$wp_query->post_count = 1;
$wp_query->is_page = true;
$post_cache[-100] = $wp_query->post;
if ( ! empty($page_template) && file_exists(TEMPLATEPATH . “/$page_template”) ) {
include(TEMPLATEPATH . “/$page_template”);
exit;
} else if ( get_page_template() ) {
include(get_page_template());
exit;
} else if ( file_exists(TEMPLATEPATH . “/index.php”) ) {
include(TEMPLATEPATH . “/index.php”);
exit;
}
}
$ezs_options = get_settings(‘ezstatic’);
if(($ezs_options[‘qs_key’] != ”) && preg_match(‘!/’ . $ezs_options[‘qs_key’] . ‘/([^?]+)/?(\?.*)?$!i’, $_SERVER[‘REQUEST_URI’], $urimatch)) {
$_REQUEST[$ezs_options[‘qs_key’]] = trim($urimatch[1],’/’);
}
if(isset($_REQUEST[$ezs_options[‘qs_key’]]))
{
$sfile = $_REQUEST[$ezs_options[‘qs_key’]];
$sfile = str_replace(‘..’, ”, $sfile);
if($ezs_options[‘block’] != ”) {
if(preg_match(‘/’ . str_replace(‘/’, ‘\/’, implode(“|”,$ezs_options[‘block’])) . ‘/’, $sfile)) {
$sfile = ‘.blocked:’.$sfile;
}
}
if($sfile{0} != ‘.’) {
$contentfile = ABSPATH . $sfile;
if(is_dir($contentfile)) $sfile .= ‘/index’; // Get index page?
foreach($ezs_options[‘fileexts’] as $ext) {
if(is_file($contentfile)) break;
$contentfile = ABSPATH . $sfile . $ext;
}
if(is_file($contentfile)) {
if(stristr(substr($contentfile, -4), ‘.php’)) {
ob_start();
include $contentfile;
$newcontent = ob_get_contents();
ob_end_clean();
}
else {
$newcontent = implode(”, file($contentfile));
}
if(isset($_REQUEST[‘autop’])) $newcontent = wpautop($newcontent);
if(preg_match(‘|<head[^>]*>(.*)</head|ims’, $newcontent, $matches)) {
$newhead = $matches[1];
$statictitle = preg_match(‘|<title[^>]*>([^<]*)</title>|i’, $newhead, $titles);
$newhead = preg_replace(‘|<title[^>]*>[^<]*</title>|i’, ”, $newhead);
$EzStatic_newtitle = $titles[1];
$EzStatic_newhead = “<!– begin from static page –>\n<script type=\”text/javascript\”><!– \ndocument.title=document.title + ‘ – ” . preg_replace(“/\r|\n|\\n/i”, ”, $titles[1]) . “‘;\n//–></script>\n$newhead\n<!– end from static page –>”;
$EzStatic_newhead = “\n<!– begin head from static page –>\n$newhead\n<!– end head from static page –>\n”;
}
if(preg_match(‘|<body[^>]*>(.*)</body|ims’, $newcontent, $matches)) {
$newcontent = $matches[1];
$newcontent = preg_replace(‘|\$([0-9])|’, ‘$$1’, $newcontent);
$addpath = addslashes(dirname($sfile).’/’);
$newcontent = preg_replace(“|(src)=\”([^/][^\”:]*)\”|e”, “EzStatic_relativeURL(‘\$1’, ‘\$2’, ‘$addpath’)”, $newcontent);
$newcontent = preg_replace(“|(href)=\”([^/][^\”:]*)\”|e”, “EzStatic_relativeURL(‘\$1’, ‘\$2’, ‘$addpath’)”, $newcontent);
}
if(ob_get_level() > 0) {
$content = ob_get_contents();
ob_end_clean();
//foreach(ob_list_handlers() as $buf) echo “Using buffer callback: $buf<br/>”;
}
$_POST[‘author’] = -1;
$EzStatic_newcontent = $newcontent.”\n<!– EzStatic embedded: $contentfile –>”;
}
else {
$EzStatic_newhead = “\n<!– EzStatic could not embed: $contentfile –>”;
}
}
else {
$EzStatic_newhead = “\n<!– EzStatic could not embed dotted file: $sfile –>”;
}
}
function EzStatic_head($content)
{
global $EzStatic_newhead;
print $EzStatic_newhead;
}
/* The following functions handle the newfangled admin configuration system */
add_action(‘admin_head’, ‘EzStatic_admin_head’);
if(strstr($_SERVER[‘REQUEST_URI’], ‘/wp-admin/plugins.php’)) {
ob_start(‘EzStatic_capture’);
if(isset($_GET[‘pfile’]) && ($_GET[‘page’] == EzStatic_basename(__FILE__))) {
// Do something!
}
}
function EzStatic_capture($content) {
$content = preg_replace_callback(‘//’, ‘EzStatic_add_link’, $content);
return $content;
}
function EzStatic_add_link($c) {
$replacement = $c[0] . ‘<br/>‘ . __(‘Configure’) . ‘‘;
return $replacement;
}
function EzStatic_admin_head($unused) {
if(preg_match(‘/(plugins.php)/i’, $_SERVER[‘SCRIPT_NAME’])) {
?>
<script language=”JavaScript” type=”text/javascript”><!–
function ezs_pageWidth() {return window.innerWidth != null? window.innerWidth: document.body != null? document.body.clientWidth:null;}
function ezs_pageHeight() {return window.innerHeight != null? window.innerHeight: document.body != null? document.body.clientHeight:null;}
function ezs_posLeft() {return typeof window.pageXOffset != ‘undefined’ ? window.pageXOffset:document.documentElement.scrollLeft? document.documentElement.scrollLeft:document.body.scrollLeft? document.body.scrollLeft:0;}
function ezs_posTop() {return typeof window.pageYOffset != ‘undefined’ ? window.pageYOffset:document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop?document.body.scrollTop:0;}
addLoadEvent(function () {
ezbcpod = document.createElement(“div”);
ezbcpod.style.position = “absolute”;
ezbcpod.id = “ezbcpod”;
ezbcpod.style.backgroundColor = “#ffffff”;
ezbcpod.style.border = “1px solid #14568a”;
ezbcpod.style.width = “70%”;
//ezbcpod.style.height = “300px”;
ezbcpod.style.display = “none”;
document.getElementsByTagName(‘body’)[0].appendChild(ezbcpod);
});
function ezs_show_config() {
if(ezbcpod.style.display == ‘none’) {
ezbcpod.style.top = (ezs_posTop() + 50) + “px”;
ezbcpod.style.left = “15%”;
ezbcpod.style.display = “block”;
var ajax = new sack();
ajax.requestFile = “<?php echo get_settings(‘siteurl’); ?>/wp-content/plugins/<?php echo str_replace(‘\\’, ‘/’, EzStatic_basename(__FILE__)); ?>”;
ajax.element = ‘ezbcpod’;
ajax.setVar(‘config’, ‘1’);
ajax.runAJAX();
} else {
ezbcpod.style.display = ‘none’;
}
return true;
}
function ezs_config_update() {
var ajax = new sack();
ajax.requestFile = “<?php echo get_settings(‘siteurl’); ?>/wp-content/plugins/<?php echo str_replace(‘\\’, ‘/’, EzStatic_basename(__FILE__)); ?>”;
ajax.element = ‘ezbcpod’;
ajax.setVar(‘config’, ‘2’);
var inp = document.getElementById(‘ezsconfig’).getElementsByTagName(‘input’);
for(z=0;z<inp.length;z++) {
if((inp[z].type != ‘checkbox’) || inp[z].checked)
ajax.setVar(inp[z].name, inp[z].value);
}
ajax.setVar(‘page_template’, document.getElementById(‘page_template’).value);
ajax.onCompletion = function() {window.setTimeout(“Fat.fade_element(‘ezsupdatenotice’);”,10);}
ajax.runAJAX();
return true;
}
//–></script>
<?php
}
}
/* The following functions handle the execution of PHP code embedded in a post or page */
function EzStatic_edit_page_UI($unused) {
global $wpdb, $post_status, $post_ID;
$ezs_options = get_settings(‘ezstatic’);
if(current_user_can(‘ezstatic_execute’)) {
if($post_ID != 0) {
$static = get_post_meta($post_ID, ‘_ezstatic’, true);
$checked = (‘1′ == $static)?’ checked=”checked”‘:”;
}
?>
<div id=”EzStatic”><label style=”margin:3px 30px;” for=”EzStatic_exec”><input type=”checkbox” id=”EzStatic_exec” name=”EzStatic_exec” value=”true” <?php echo $checked; ?> /> Execute page content between <?php ?>
as PHP.</label></div>
<script language=”JavaScript” type=”text/javascript”><!–
var placement = document.getElementById(“postdiv”);
if(!placement) placement = document.getElementById(“postdivrich”);
var substitution = document.getElementById(“EzStatic”);
placement.appendChild(substitution);
//–></script>
<?php
}
}
function EzStatic_edit_post($id)
{
global $wpdb;
if(!isset($id)) $id= $_REQUEST[‘post_ID’];
add_post_meta($id, ‘_ezstatic’, 0, true);
if(current_user_can(‘ezstatic_execute’)) {
if(isset($_POST[‘EzStatic_exec’])) {
update_post_meta($id, ‘_ezstatic’, 1);
}
else {
update_post_meta($id, ‘_ezstatic’, 0);
}
}
else {
update_post_meta($id, ‘_ezstatic’, 0);
}
}
function EzStatic_the_content($content) {
global $post;
if(get_post_meta($post->ID, ‘_ezstatic’, true) == 1) {
$authordata = new WP_User($post->post_author);
if($authordata->has_cap(‘ezstatic_execute’)) {
//$content = “
" . print_r($post, 1) . "
“;
$content = preg_replace_callback(‘/(<[\\s]*\\?php)((\’.*?(?<!\\\)\’|”.*?(?<!\\\)”|[^\'”]+?)*?)(\\?’.’>)/si’, ‘EzStatic_exec_PHP’, $post->post_content);
$content .= “<!– Processed by EzStatic –>”;
}
}
return $content;
}
function EzStatic_exec_PHP($php) {
ob_start();
eval($php[2]);
$res = ob_get_contents();
ob_end_clean();
return $res;
}
function EzStatic_capabilities_list($caplist) {
$caplist[] = ‘ezstatic_execute’;
return $caplist;
}
function EzStatic_admin_menu() {
global $sack_js;
if(strstr($_SERVER[‘REQUEST_URI’], ‘plugins.php’)) $sack_js = true;
if(stripslashes($_GET[‘page’]) == EzStatic_basename(__FILE__)) {
add_submenu_page(‘plugins.php’, ‘Configure EzStatic’, ‘EzStatic’, ‘activate_plugins’, EzStatic_basename(__FILE__), ‘EzStatic_config’);
}
}
function EzStatic_config() {
?>
<script type=”text/javascript”>function ezs_config_update() {return false;}</script>
<div class=”wrap”>
<?php
EzStatic_options_form();
?>
</div>
<?php
}
function EzStatic_options_form() {
global $wp_roles;
$ezs_options = get_settings(‘ezstatic’);
?>
<h2>Configure EzStatic</h2>
<?php
if($_POST[‘config’] == 2) {
echo “<div class=\”updated fade\” id=\”ezsupdatenotice\”>Configuration updated.</div>”;
$ezs_options = array(
‘qs_key’ => $_POST[‘qs_key’],
‘fileexts’ => explode(‘,’, $_POST[‘fileexts’]),
‘block’ => explode(‘,’, $_POST[‘block’]),
‘page_template’ => $_POST[‘page_template’],
);
update_option(‘ezstatic’, $ezs_options);
if(!is_array($_POST[‘roles’])) $_POST[‘roles’] = array();
foreach($wp_roles->role_names as $role => $name) {
if(in_array($role, $_POST[‘roles’])) {
$wp_roles->role_objects[$role]->add_cap(‘ezstatic_execute’);
} else {
$wp_roles->role_objects[$role]->remove_cap(‘ezstatic_execute’);
}
}
}
?>
<form onsubmit=”return !ezs_config_update();” id=”ezsconfig” method=”post”>
<table style=”width:100%;”>
<tr>
<td style=”width:60%;padding-top:10px;text-align:right;”><label for=”qs_key” style=”margin-top:5px;”><?php _e(‘Querystring Trigger’); ?>:</label><div style=”font-size:xx-small;”>The querystring trigger for selecting static pages.</div></td>
<td><input type=”text” name=”qs_key” style=”width:90%;” value=”<?php echo $ezs_options[‘qs_key’]; ?>”/></td>
</tr>
<tr>
<td style=”padding-top:10px;text-align:right;”><label for=”filexts”><?php _e(‘File Extensions’); ?>:</label><div style=”font-size:xx-small;”>A comma-separated list of extensions in the order EzStatic will try them.</div></td>
<td><input type=”text” name=”fileexts” style=”width:90%;” value=”<?php echo implode(‘,’, $ezs_options[‘fileexts’]); ?>”/></td>
</tr>
<tr>
<td style=”padding-top:10px;text-align:right;”><label for=”block”><?php _e(‘Blocked Substrings’); ?>:</label><div style=”font-size:xx-small;”>A comma-separated list of terms that will cause EzStatic to fail if they are used in the static file.</div></td>
<td><input type=”text” name=”block” style=”width:90%;” value=”<?php echo implode(‘,’, $ezs_options[‘block’]); ?>”/></td>
</tr>
<tr>
<td style=”padding-top:10px;text-align:right;”><label for=”page_template”><?php _e(‘Page Template’); ?>:</label><div style=”font-size:xx-small;”>The page template to use when embedding static files</div></td>
<td><select name=”page_template” id=”page_template”>’;
<option value=’default’><?php _e(‘Default Template’); ?></option>
<?php page_template_dropdown($ezs_options[‘page_template’]); ?>
</select></td>
</tr>
<tr>
<td style=”padding-top:10px;text-align:right;”><?php _e(‘Roles with Execute Permissions’); ?>:<div style=”font-size:xx-small;”>The user roles that may embed PHP code directly into posts and pages.</div></td>
<td>
<?php
foreach($wp_roles->role_names as $role => $name) {
echo “<label style=\”display:block\”><input type=\”checkbox\” name=\”roles[]\” value=\”{$role}\””;
if($wp_roles->role_objects[$role]->has_cap(‘ezstatic_execute’)) echo ‘ checked=”checked”‘;
echo “/> {$name}</label>\n”;
}
?>
</td>
</tr>
<tr>
<td colspan=”2″ style=”text-align:right”>
<input type=”Submit” name=”Submit” value=”Update” />
<input type=”button” name=”Close” value=”Close” onclick=”ezbcpod.innerHTML=”;ezbcpod.style.display=’none’;” />
</td>
</tr>
</table>
<input type=”hidden” name=”config” value=”2″ />
</form>
<?php
}
?>`
]]>A link like…
www.thisisnotmysite.com/sc/index.php?static=vt&table=1
doesn’t apparently work, in the sense that the variable $table isn’t readable by the code in the vt.php file. (vt.php appears just nicely, though!)
Am I just expecting too much? Or is there a way of making the variable accessible?
Yes, you may have read this already – but the last time I posted this, the thread was then closed to new replies ….
… and also I had a serious search over his websites for a means of contacting the author directly, but couldn’t find one.
]]>In regards to Microshop, I see I need to edit index.php and there is a mysql database section; did you guys just use the wordpress database or create a new one?
Just trying to work out how best to put these three together; so could someone please point me towards a tutorial or just drop some knowledge in here.
Thanks in advance.
]]>EzStaticVersion: 1.7
Author: Owen Winkler
Anyone have this or know where I can get it?
]]>The URL string that I am using is:
https://leroychatfiled.us/index.php?static=leroyheader
Can’t get EZ to work? I have installed and activated EzStatic 3.0.
The question is where do I put the URL? What page do I put it on? And where in the page and with what php tags do I need to use. Is it possible to see an example of the URL in a page?
Jim
]]>I created my pages that I wanted to use the EZstatic plugin with, and created the index.php?static=filename.php URL for my link.
But any pages that I create to use with EZstatic, while the background, etc etc etc look appropriate, my bullets & things for lists, etc are not showing up like in the sidebars.
What special “coding” do I have to surround my information with to make it match the rest of my site?
Example: start of page file…
<h2> :: Our Charter ::</h2>
<p align="left">The Charter of the Ladies.....
Then my list is coded as normal:
<ul>
<li>Any "Lady" can be a member...
But the bullets don’t show up like they do in the sidebar with teh same coding.
Please help!
The page the above coding comes from can be found at https://ladies-of-the-heart.com/index.php?static=charter.php if I haven’t explained it right…
]]>