Beispiel #1
0
        /** ====================================================================================================================================================
         * 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>&nbsp;</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 Email when the backup ends
  *
  * @return void
  */
 function sendSummaryEmail()
 {
     if (preg_match('/(?:[a-z0-9!#$%&*+\\/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&*+\\/=?^_`{|}~-]+)*|"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])/', $this->get_param('ftp_mail'))) {
         $message = "";
         $message .= "<p>" . __("Dear sirs,", $this->pluginID) . "</p><p>&nbsp;</p>";
         $message .= "<p>" . __("Please find hereafter a summary of the backup process.", $this->pluginID) . "</p>";
         $info = $this->get_param('info_process');
         $seconds = ($info['end'] - $info['start']) % 60;
         $minutes = floor(($info['end'] - $info['start']) / 60);
         $message .= "<h3>" . __("Global synthesis", $this->pluginID) . "</h3>";
         $message .= "<p>" . sprintf(__("The backup process has started on %s and have lasted %s minutes and %s seconds", $this->pluginID), date_i18n("F j, Y H:i:s", $info['start']), $minutes, $seconds) . "</p>";
         if (isset($info['sql'])) {
             $message .= "<h3>" . __("SQL synthesis", $this->pluginID) . "</h3>";
             $seconds = ($info['sql']['end'] - $info['sql']['start']) % 60;
             $minutes = floor(($info['sql']['end'] - $info['sql']['start']) / 60);
             $message .= "<p>" . sprintf(__("The SQL extraction has started on %s and have lasted %s minutes and %s seconds", $this->pluginID), date_i18n("F j, Y H:i:s", $info['sql']['start']), $minutes, $seconds) . "</p>";
             $message .= "<p>" . sprintf(__("%s entries have been extracted and have been stored in %s files.", $this->pluginID), $info['sql']['total_entries'], count($info['sql']['files'])) . "</p>";
             foreach ($info['sql']['files'] as $f => $time) {
                 $message .= "<li>";
                 $message .= sprintf(__("%s created on %s", $this->pluginID), basename($f), date_i18n("F j, Y H:i:s", $time));
                 $message .= "</li>";
             }
             $message .= "</ul>";
         }
         if (isset($info['zip'])) {
             $message .= "<h3>" . __("ZIP synthesis", $this->pluginID) . "</h3>";
             $seconds = ($info['zip']['end'] - $info['zip']['start']) % 60;
             $minutes = floor(($info['zip']['end'] - $info['zip']['start']) / 60);
             $message .= "<p>" . sprintf(__("The ZIP creation phase has started on %s and have lasted %s minutes and %s seconds", $this->pluginID), date_i18n("F j, Y H:i:s", $info['zip']['start']), $minutes, $seconds) . "</p>";
             $message .= "<p>" . sprintf(__("%s files have been stored into %s split files (zip, z01, z02, etc.).", $this->pluginID), $info['zip']['total_entries'], count($info['zip']['files'])) . "</p>";
             if (count(count($info['zip']['excluded_entries'])) != 0) {
                 $message .= "<p>" . sprintf(__("Please note that %s files have been excluded from the backup process because their sizes exceed the chunk size (i.e. %s Mo).", $this->pluginID), count($info['zip']['excluded_entries']), $this->get_param('max_allocated')) . "</p>";
                 $message .= "<ul>";
                 foreach ($info['zip']['excluded_entries'] as $f) {
                     $message .= "<li>";
                     $message .= sprintf(__("%s (size %s)", $this->pluginID), str_replace(ABSPATH, "", $f), SLFramework_Utils::byteSize(filesize($f)));
                     $message .= "</li>";
                 }
                 $message .= "</ul>";
             }
             $message .= "<p>" . sprintf(__("These zip files are accessible for %s days at the following path:", $this->pluginID), $this->get_param('delete_after')) . "</p>";
             $message .= "<ul>";
             foreach ($info['zip']['files'] as $time => $f) {
                 $message .= "<li>";
                 $message .= sprintf(__("%s created on %s", $this->pluginID), "<a href='" . str_replace(WP_CONTENT_DIR, WP_CONTENT_URL, $f) . "'>" . basename($f) . "</a>", date_i18n("F j, Y H:i:s", $time));
                 $message .= "</li>";
             }
             $message .= "</ul>";
         }
         if (isset($info['ftp'])) {
             $message .= "<h3>" . __("FTP synthesis", $this->pluginID) . "</h3>";
             $message .= "<p>" . sprintf(__("The %s zip files have been stored on the specified FTP: %s", $this->pluginID), count($info['ftp']), $this->get_ftp_host()) . "</p>";
             $message .= "<ul>";
             foreach ($info['ftp'] as $fi) {
                 if (is_file($fi['file'])) {
                     if (!$fi['error']) {
                         $message .= "<li>";
                         $message .= sprintf(__("%s stored on %s", $this->pluginID), "<a href='" . $this->get_ftp_host() . "/" . basename($fi['file']) . "'>" . basename($fi['file']) . "</a>", date_i18n("F j, Y H:i:s", $fi['date']));
                         $message .= "</li>";
                     } else {
                         $message .= "<li>";
                         $message .= sprintf(__("ERROR: %s has not been stored. The error message was: %s", $this->pluginID), basename($fi['file']), "<code>" . $fi['error_msg'] . "</code>");
                         $message .= "</li>";
                     }
                 }
             }
             $message .= "</ul>";
         }
         $message .= "<p>" . __("Best regards,", $this->pluginID) . "</p><p>&nbsp;</p>";
         $headers = "MIME-Version: 1.0\n" . "Content-Type: text/html; charset=\"" . get_option('blog_charset') . "\"\n";
         $subject = sprintf(__("Backup of %s on %s", $this->pluginID), get_bloginfo('name'), date_i18n('Y-m-d'));
         // send the email
         $res = wp_mail($this->get_param('ftp_mail'), $subject, $message, $headers);
         if (!$res) {
             SLFramework_Debug::log(get_class(), "An error occurred sending the mail to " . $this->get_param('ftp_mail'), 2);
         } else {
             SLFramework_Debug::log(get_class(), "The email has been successfully sent  to " . $this->get_param('ftp_mail'), 4);
         }
     }
 }