'; return $output; } /* WP 1.x not supported anymore function execphp_eval_php_1_x($content) { // for debugging also group unimportant components with () // to check them with a print_r($matches) $pattern = '/'. '(<[\s]*\?php)'. // the opening of the )'. // the closing ? > tag '/is'; $content = preg_replace_callback($pattern, 'execphp_fix_tag_1_x', $content); // to be compatible with older PHP4 installations // don't use fancy ob_XXX shortcut functions ob_start(); eval(" ?> $content post_author)) return $content; $poster = new WP_User($post->post_author); if (!$poster->has_cap(EXECPHP_CAPABILITY)) return $content; // to be compatible with older PHP4 installations // don't use fancy ob_XXX shortcut functions ob_start(); eval(" ?> $content posts}` "; $wpdb->query($query); $s = $wpdb->get_results($query); if (!is_array($s)) $s = array(); foreach ($s as $i) { $i->post_content = $wpdb->escape(preg_replace_callback( $g_execphp_old_style_pattern, 'execphp_fix_tag_1_x', $i->post_content)); $i->post_excerpt = $wpdb->escape(preg_replace_callback( $g_execphp_old_style_pattern, 'execphp_fix_tag_1_x', $i->post_excerpt)); $query = " UPDATE `{$wpdb->posts}` SET `post_content` = '{$i->post_content}', `post_excerpt` = '{$i->post_excerpt}' WHERE `ID` = {$i->ID} "; $wpdb->query($query); } } function execphp_scan_for_old_style() { global $g_execphp_old_style_pattern; global $wpdb; $query = " SELECT `post_title`, `post_content`, `post_excerpt` FROM `{$wpdb->posts}` "; $wpdb->query($query); $s = $wpdb->get_results($query); if (!is_array($s)) $s = array(); // don't start $has_old_style with 0 to make later checking easier $has_old_style = 1; $titles = array(); foreach ($s as $i) { $content_has_old_style = preg_match($g_execphp_old_style_pattern, $i->post_content); $excpert_has_old_style = preg_match($g_execphp_old_style_pattern, $i->post_excerpt); if ($content_has_old_style || $excerpt_has_old_style) { $has_old_style += $content_has_old_style + $excerpt_has_old_style; $titles[] = $i->post_title; break; } } update_option(EXECPHP_OPTION_HAS_OLD_STYLE, $has_old_style); return $titles; } function execphp_old_style_warning() { $path = plugin_basename(__FILE__); echo "

". __('Exec-PHP found malformed styled PHP tags.', EXECPHP_PLUGIN_ID). " ". sprintf(__('Convert them on the EXEC-PHP config page to let your PHP code work properly.', EXECPHP_PLUGIN_ID), "options-general.php?page=$path")."

"; } function execphp_print_old_style_warning() { $has_old_style = get_option(EXECPHP_OPTION_HAS_OLD_STYLE); $ignore_old_style_warning = get_option(EXECPHP_OPTION_IGNORE_OLD_STYLE_WARNING); if (!$ignore_old_style_warning && $has_old_style > 1) add_filter('admin_footer', 'execphp_old_style_warning'); else remove_filter('admin_footer', 'execphp_old_style_warning'); } function execphp_config_page() { $has_old_style = get_option(EXECPHP_OPTION_HAS_OLD_STYLE); $ignore_old_style_warning = get_option(EXECPHP_OPTION_IGNORE_OLD_STYLE_WARNING); if (!$ignore_old_style_warning) $ignore_old_style_warning = false; if (isset($_POST['migrate_execphp'])) { execphp_migrate_old_style(); $has_old_style = 1; update_option(EXECPHP_OPTION_HAS_OLD_STYLE, $has_old_style); echo '

' . __('Posts migrated', EXECPHP_PLUGIN_ID) . "

\n"; } if (isset($_POST['toggle_warning_execphp'])) { $ignore_old_style_warning = !$ignore_old_style_warning; update_option(EXECPHP_OPTION_IGNORE_OLD_STYLE_WARNING, $ignore_old_style_warning); echo '

' . __('Options updated', EXECPHP_PLUGIN_ID) . "

\n"; } execphp_print_old_style_warning(); ?>

Be sure to backup your database first before pressing the button.", EXECPHP_PLUGIN_ID); ?>

1) { ?>

role_objects as $role) { if ($role->has_cap(EXECPHP_CAPABILITY)) return; } // be sure standard roles are available, these may be deleted or // renamed by the blog administrator $role = get_role('administrator'); if ($role !== NULL) $role->add_cap(EXECPHP_CAPABILITY); $role = get_role('editor'); if ($role !== NULL) $role->add_cap(EXECPHP_CAPABILITY); } function execphp_install() { execphp_install_capability(); execphp_scan_for_old_style(); execphp_print_old_style_warning(); } function execphp_uninstall() { delete_option(EXECPHP_OPTION_HAS_OLD_STYLE); delete_option(EXECPHP_OPTION_IGNORE_OLD_STYLE_WARNING); } // -------------------------------------------------------------------------- // activate plugin // -------------------------------------------------------------------------- // for debugging also group unimportant components with () // to check them with a print_r($matches) global $g_execphp_old_style_pattern; $g_execphp_old_style_pattern = '/'. '(?:(?:<[\s]+)|(\[[\s]*))\?php'. // the opening of the )'. // the closing ? > or ?] tag '/is'; global $wp_version; if (substr($wp_version, 0, 2) == "1.") { /* WP 1.x not supported anymore add_filter('init', 'execphp_init_1_x'); */ _e("This version of Exec-PHP does not support Wordpress 1.x anymore", EXECPHP_PLUGIN_ID); } else { /* HACK: #3002 Does not work with WP 2.0.4 on Windows; see trac ticket #3002; so we have to implement some more logic to the has_old_style flag register_activation_hook(__FILE__, execphp_install); register_deactivation_hook(__FILE__, execphp_uninstall); */ add_filter('init', 'execphp_init'); } ?>