/** ==================================================================================================================================================== * Log function * * @param string $where the name of the plugin which call the log function * @param string $text the text to be logged * @param integer $error_level 1=critical ; 2=error ; 3=warning ; 4=information ; 5=verbose * @return void */ static function log($where, $text, $error_level = 5) { // Test if this message has to be loged $frmk = new coreSLframework(); $level = $frmk->get_param('debug_level'); if (!is_numeric($error_level)) { return; } $error_level = floor($error_level); if ($level < $error_level) { return; } $namelogfile = SLFramework_Debug::get_log_path(); // We get the old content $old_content = @array_slice(@file($namelogfile), 0, 1999); if (!is_array($old_content)) { $old_content = array(""); } // Once the file is identified, we stored the new logfile $error = "VERBOSE"; if ($error_level == 1) { $error = "CRITICAL"; } if ($error_level == 2) { $error = "ERROR"; } if ($error_level == 3) { $error = "WARNING"; } if ($error_level == 4) { $error = "INFO"; } if ($error_level == 5) { $error = "VERBOSE"; } $new_content = "[" . date("Ymd His") . "] [" . @getmypid() . "] [" . $where . "] [" . $error . "] - " . $text . "\r\n" . implode("", $old_content); // We store the content @file_put_contents($namelogfile, $new_content); }
/** ==================================================================================================================================================== * This function displays the configuration page of the core * * @access private * @return void */ function sedlex_information() { global $submenu; global $blog_id; global $SLpluginActivated; echo get_option('plugin_error_on_activation'); update_option('plugin_error_on_activation', ""); if (is_multisite() && $blog_id == 1 || !is_multisite()) { ob_start(); $params = new SLFramework_Parameters($this->frmk); $params->add_title(__('Log options', 'SL_framework')); $params->add_param("debug_level", __('What is the debug level:', 'SL_framework')); $params->add_comment("<a href='" . str_replace(WP_CONTENT_DIR, content_url(), SLFramework_Debug::get_log_path()) . "' target='_blank'>" . __('See the debug logs', 'SL_framework') . "</a>"); $params->add_comment(__('1=log only the critical errors;', 'SL_framework')); $params->add_comment(__('2=log only the critical errors and the standard errors;', 'SL_framework')); $params->add_comment(__('3=log only the critical errors, the standard errors and the warnings;', 'SL_framework')); $params->add_comment(__('4=log information;', 'SL_framework')); $params->add_comment(__('5=log verbose;', 'SL_framework')); if (is_multisite()) { $params->add_title(__('Multisite Management', 'SL_framework')); $params->add_param("global_allow_translation_by_blogs", __('Do you want to allow sub-blogs to modify the translations of the plugins:', 'SL_framework')); $params->add_comment(__("If this option is unchecked, the translation tab won't be displayed in the blog administration panel.", 'SL_framework')); } $params->add_title(__('Location of the SL plugins', 'SL_framework')); $params->add_param("global_location_plugin", __('Where do you want to display the SL plugins:', 'SL_framework')); echo $params->flush(); $paramSave = ob_get_clean(); echo "<a name='top'></a>"; } //Information about the SL plugins ?> <div class="wrap"> <div id="icon-themes" class="icon32"><br/></div> <h2><?php echo __('Summary page for the plugins developped with the SL framework', 'SL_framework'); ?> </h2> </div> <div style="padding:20px;"> <?php echo $this->signature; ?> <p> </p> <?php $plugins = get_plugins(); $all_nb = 0; foreach ($plugins as $url => $data) { if (is_plugin_active($url)) { $all_nb++; } } $sl_count = 0; foreach ($SLpluginActivated as $ov) { $sl_count++; } ?> <p><?php printf(__("For now, you have installed %s plugins including %s plugins developped with the SedLex's framework", 'SL_framework'), $all_nb, $sl_count - 1); ?> <p/> <p><?php printf(__("The core plugin is located at %s", 'SL_framework'), "<code>" . str_replace(ABSPATH, "", SL_FRAMEWORK_DIR) . "</code>"); ?> <p/> <?php //====================================================================================== //= Tab listing all the plugins //====================================================================================== $tabs = new SLFramework_Tabs(); ob_start(); $table = new SLFramework_Table(); $table->title(array(__("Plugin name", 'SL_framework'), __("Description", 'SL_framework'))); $ligne = 0; foreach ($SLpluginActivated as $i => $url) { $ligne++; $plugin_name = explode("/", $url); if (isset($plugin_name[count($plugin_name) - 2])) { $plugin_name = $plugin_name[count($plugin_name) - 2]; } else { $plugin_name = "?"; } if ($i != 0) { $info = pluginSedlex::get_plugins_data(WP_PLUGIN_DIR . "/" . $url); ob_start(); ?> <p><b><?php echo $info['Plugin_Name']; ?> </b></p> <p><a href='admin.php?page=<?php echo $url; ?> '><?php echo __('Settings', 'SL_framework'); ?> </a> | <?php echo SLFramework_Utils::byteSize(SLFramework_Utils::dirSize(dirname(WP_PLUGIN_DIR . '/' . $url))); ?> </p> <?php $cel1 = new adminCell(ob_get_clean()); ob_start(); $database = ""; if ($info['Database'] != "") { $database = "<img src='" . plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/database.png" . "' alt='" . __('There is a SQL database for this plugin', 'SL_framework') . "'/>"; } ?> <p><?php echo str_replace("<ul>", "<ul style='list-style-type:circle; padding-left:1cm;'>", $info['Description']); ?> </p> <p><?php echo sprintf(__('Version: %s by %s', 'SL_framework'), $info['Version'], $info['Author']); ?> (<a href='<?php echo $info['Author_URI']; ?> '><?php echo $info['Author_URI']; ?> </a>)<?php echo $database; ?> </p> <?php $cel2 = new adminCell(ob_get_clean()); $table->add_line(array($cel1, $cel2), '1'); } } echo $table->flush(); $tabs->add_tab(__('List of SL plugins', 'SL_framework'), ob_get_clean(), plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_list.png"); if (is_multisite() && $blog_id == 1 || !is_multisite()) { //====================================================================================== //= Tab for parameters //====================================================================================== $tabs->add_tab(__('Parameters of the framework', 'SL_framework'), $paramSave, plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_param.png"); } if (is_multisite() && $blog_id == 1 || !is_multisite() || $this->frmk->get_param('global_allow_translation_by_blogs')) { //====================================================================================== //= Tab for the translation //====================================================================================== ob_start(); $plugin = str_replace("/", "", str_replace(basename(__FILE__), "", plugin_basename(__FILE__))); $trans = new SLFramework_Translation("SL_framework", $plugin); $trans->enable_translation(); $tabs->add_tab(__('Manage translation of the framework', 'SL_framework'), ob_get_clean(), plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_trad.png"); } echo $tabs->flush(); echo $this->signature; ?> </div> <?php }
/** ==================================================================================================================================================== * Send the feedback form * * @access private * @return void */ public function send_feedback() { // We sanitize the entries $plugin = preg_replace("/[^a-zA-Z0-9_-]/", "", $_POST['plugin']); $pluginID = preg_replace("/[^a-zA-Z0-9_]/", "", $_POST['pluginID']); $name = strip_tags($_POST['name']); $mail = preg_replace("/[^:\\/a-z0-9@A-Z_.-]/", "", $_POST['mail']); $comment = strip_tags($_POST['comment']); // If applicable, we select the log file $logfile = SLFramework_Debug::get_log_path(); $info_file = pluginSedLex::get_plugins_data(WP_PLUGIN_DIR . "/" . $plugin . "/" . $plugin . ".php"); $to = $info_file['Email']; $subject = "[" . ucfirst($plugin) . "] Feedback of " . $name; $message = ""; $message .= "From {$name} (" . $mail . ")\n\n\n"; $message .= $comment . "\n\n\n"; $message .= "* Accounts \n"; $message .= "**************************************** \n"; $admin = get_userdata(1); $message .= "Admin User Name: " . $admin->display_name . "\n"; $message .= "Admin User Login: "******"\n"; $message .= "Admin User Mail: " . $admin->user_email . "\n"; $current_user = wp_get_current_user(); $message .= "Logged User Name: " . $current_user->display_name . "\n"; $message .= "Logged User Login: "******"\n"; $message .= "Logged User Mail: " . $current_user->user_email . "\n"; $message .= "\n\n\n"; $message .= "* Information \n"; $message .= "**************************************** \n"; $message .= "Plugin: " . $plugin . "\n"; $message .= "Plugin Version: " . $info_file['Version'] . "\n"; $message .= "Wordpress Version: " . get_bloginfo('version') . "\n"; $message .= "URL (home): " . home_url('/') . "\n"; $message .= "URL (site): " . site_url('/') . "\n"; $message .= "Language: " . get_bloginfo('language') . "\n"; $message .= "Charset: " . get_bloginfo('charset') . "\n"; $message .= "\n\n\n"; $message .= "* Configuration of the plugin \n"; $message .= "**************************************** \n"; $options = get_option($pluginID . '_options'); // mask the password $new_option = array(); $new_plugin_copy = call_user_func(array($pluginID, 'getInstance')); foreach ($options as $o => $v) { if ($new_plugin_copy->get_default_option($o) !== "[password]") { $new_option[$o] = $v; } else { $new_option[$o] = "********** (masked)"; } } ob_start(); print_r($new_option); $message .= ob_get_clean(); $message .= "\n\n\n"; $message .= "* Activated plugins \n"; $message .= "**************************************** \n"; $plugins = get_plugins(); $active = get_option('active_plugins'); foreach ($plugins as $file => $p) { if (array_search($file, $active) !== false) { $message .= $p['Name'] . "(" . $p['Version'] . ") => " . $p['PluginURI'] . "\n"; } } $headers = ""; if (preg_match("#^[a-z0-9-_.]+@[a-z0-9-_.]{2,}\\.[a-z]{2,4}\$#", $mail)) { $headers = "Reply-To: {$mail}\n" . "Return-Path: {$mail}"; } $attachments = array($logfile); // send the email if (wp_mail($to, $subject, $message, $headers, $attachments)) { echo "<div class='updated fade'>"; echo "<p>" . __("The feedback has been sent", 'SL_framework') . "</p>"; echo "</div>"; SLFramework_Debug::log(get_class(), "A feedback mail has been sent.", 4); } else { echo "<div class='error fade'>"; echo "<p>" . __("An error occured sending the email.", 'SL_framework') . "</p><p>" . __("Make sure that your wordpress is able to send email.", 'SL_framework') . "</p>"; echo "</div>"; SLFramework_Debug::log(get_class(), "A feedback mail has failed to be sent.", 2); } //Die in order to avoid the 0 character to be printed at the end die; }