/** ====================================================================================================================================================
  * 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);
 }
Exemple #2
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 
        }
        /** ====================================================================================================================================================
         * Print the form with parameters
         * 	
         * @return void
         */
        function flush()
        {
            global $_POST;
            global $_FILES;
            global $wpdb;
            $this->buffer[] = array('end', "");
            // We create the beginning of the form
            $this->output = "<h3>" . __("Parameters", 'SL_framework') . "</h3>";
            if ($this->obj->getPluginID() != "") {
                $this->output .= "<p>" . __("Here are the parameters of the plugin. Modify them at will to fit your needs.", "SL_framework") . "</p>";
            } else {
                $this->output .= "<p>" . __("Here are the parameters of the framework. Modify them at will to fit your needs.", "SL_framework") . "</p>";
            }
            $this->output .= "<div class='wrap parameters'><form enctype='multipart/form-data' method='post' action='" . $_SERVER["REQUEST_URI"] . "'>\n";
            // We compute the parameter output
            $hastobeclosed = false;
            $maj = false;
            $modified = false;
            $error = false;
            $warning = false;
            $toExecuteWhenLoaded = "";
            $macroisdisplayed_count = 0;
            $macroisdisplayed = false;
            $macroisdisplayed_avoidnext = false;
            for ($iii = 0; $iii < count($this->buffer); $iii++) {
                $ligne = $this->buffer[$iii];
                // Is it a title
                if ($ligne[0] == "end" || $ligne[0] == "title" || $ligne[0] == "title_macro") {
                    if ($hastobeclosed) {
                        $this->output .= $currentTable->flush() . "<br/>";
                        $hastobeclosed = false;
                    }
                    // On test si on doit recommencer
                    if ($macroisdisplayed && !$macroisdisplayed_avoidnext) {
                        $nnn = 1;
                        // We search for the next parameter
                        $found_param = false;
                        while (isset($this->buffer[$macro_lasttitle + $nnn])) {
                            $first_param_after = $this->buffer[$macro_lasttitle + $nnn];
                            if ($first_param_after[0] == 'param') {
                                $found_param = true;
                                $first_param_after = $first_param_after[1];
                                break;
                            } else {
                                if ($first_param_after[0] == 'comment') {
                                    $nnn++;
                                } else {
                                    break;
                                }
                            }
                        }
                        // if the param has been found
                        if ($found_param) {
                            $all_names = $this->obj->get_name_params();
                            if (in_array($first_param_after . "_macro" . ($macroisdisplayed_count + 1), $all_names)) {
                                $iii = $macro_lasttitle - 1;
                                $macroisdisplayed_count++;
                                $macroisdisplayed_avoidnext = true;
                                continue;
                            } else {
                                $macroisdisplayed_count = 0;
                                $macroisdisplayed = false;
                                $macroisdisplayed_avoidnext = false;
                            }
                        }
                    }
                    $macroisdisplayed_avoidnext = false;
                    // We create a new table
                    $currentTable = new SLFramework_Table();
                    $currentTable->removeFooter();
                    $hastobeclosed = true;
                    if ($ligne[0] == "title") {
                        $currentTable->title(array($ligne[1], ""));
                        $macroisdisplayed = false;
                        $macroisdisplayed_text = "";
                    } else {
                        if ($ligne[0] == "title_macro") {
                            // Add delete button
                            $params = "[";
                            $count_param_temp = 0;
                            $nnn = 1;
                            while (isset($this->buffer[$iii + $nnn])) {
                                $first_param_after = $this->buffer[$iii + $nnn];
                                if ($first_param_after[0] == 'param') {
                                    if ($count_param_temp != 0) {
                                        $params .= ",";
                                    }
                                    $params .= "\"" . $first_param_after[1] . "_macro" . $macroisdisplayed_count . "\"";
                                    $nnn++;
                                    $count_param_temp++;
                                } else {
                                    if ($first_param_after[0] == 'comment') {
                                        $nnn++;
                                    } else {
                                        break;
                                    }
                                }
                            }
                            $params .= "]";
                            $md5 = sha1($params);
                            $delete = " <a href='#' onclick='del_param(" . $params . ", \"" . $md5 . "\", \"" . $this->obj->pluginID . "\");return false ; ' style='font-size:80%'>" . __('(Delete)', 'SL_framework') . "</a>";
                            $x = plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__));
                            $delete .= "<img id='wait_" . $md5 . "' src='" . $x . "/img/ajax-loader.gif' style='display:none;'>";
                            // Add add button
                            $add = "";
                            $macroisdisplayed_text = $ligne[2];
                            if ($macroisdisplayed_count == 0) {
                                $params = "[";
                                $count_param_temp = 0;
                                $nnn = 1;
                                while (isset($this->buffer[$iii + $nnn])) {
                                    $first_param_after = $this->buffer[$iii + $nnn];
                                    if ($first_param_after[0] == 'param') {
                                        if ($count_param_temp != 0) {
                                            $params .= ",";
                                        }
                                        $params .= "\"" . $first_param_after[1] . "_macro\"";
                                        $nnn++;
                                        $count_param_temp++;
                                    } else {
                                        if ($first_param_after[0] == 'comment') {
                                            $nnn++;
                                        } else {
                                            break;
                                        }
                                    }
                                }
                                $params .= "]";
                                $md5 = sha1($params);
                                $add = " <a href='#' onclick='add_param(" . $params . ", \"" . $md5 . "\", \"" . $this->obj->pluginID . "\");return false ; ' style='font-size:80%'>(" . $macroisdisplayed_text . ")</a>";
                                $x = plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__));
                                $add .= "<img id='wait_" . $md5 . "' src='" . $x . "/img/ajax-loader.gif' style='display:none;'>";
                            }
                            if (strpos($ligne[1], "%s") !== false) {
                                $currentTable->title(array(sprintf($ligne[1], $macroisdisplayed_count + 1) . $delete . $add, ""));
                            } else {
                                $currentTable->title(array($ligne[1] . $delete, ""));
                            }
                            $macro_lasttitle = $iii;
                            $macroisdisplayed_count_elements = 0;
                            $macroisdisplayed = true;
                        }
                    }
                }
                // compte le nombre d element dans la macro
                if ($macroisdisplayed) {
                    $macroisdisplayed_count_elements++;
                } else {
                    $macroisdisplayed_count_elements = 0;
                }
                // Is it a comment
                if ($ligne[0] == "comment") {
                    if (!$hastobeclosed) {
                        // We create a default table as no title has been provided
                        $currentTable = new SLFramework_Table();
                        $currentTable->removeFooter();
                        $currentTable->title(array(__("Parameters", "SL_framework"), __("Values", "SL_framework")));
                        $hastobeclosed = true;
                    }
                    $cl = "<p class='paramComment' style='color: #a4a4a4;'>" . $ligne[1] . "</p>";
                    // We check if there is a comment just after it
                    while (isset($this->buffer[$iii + 1])) {
                        if ($this->buffer[$iii + 1][0] != "comment") {
                            break;
                        }
                        $cl .= "<p class='paramComment' style='color: #a4a4a4;'>" . $this->buffer[$iii + 1][1] . "</p>";
                        $iii++;
                    }
                    $cel_label = new adminCell($cl);
                    $cel_value = new adminCell("");
                    $currentTable->add_line(array($cel_label, $cel_value), '1');
                }
                // Is it a param
                if ($ligne[0] == "param") {
                    $param = $ligne[1];
                    $param_default = $ligne[1];
                    //macro
                    if ($macroisdisplayed) {
                        $param = $param . "_macro" . $macroisdisplayed_count;
                    }
                    $name = $ligne[2];
                    $forbid = $ligne[3];
                    $allow = $ligne[4];
                    $related = $ligne[5];
                    if (!$hastobeclosed) {
                        // We create a default table as no title has been provided
                        $currentTable = new SLFramework_Table();
                        $currentTable->removeFooter();
                        $currentTable->title(array(__("Parameters", "SL_framework"), __("Values", "SL_framework")));
                        $hastobeclosed = true;
                    }
                    // What is the type of the parameter ?
                    //---------------------------------------
                    $type = "string";
                    if (is_bool($this->obj->get_default_option($param_default))) {
                        $type = "boolean";
                    }
                    if (is_int($this->obj->get_default_option($param_default))) {
                        $type = "int";
                    }
                    if (is_array($this->obj->get_default_option($param_default))) {
                        $type = "list";
                    }
                    // C'est un text si dans le texte par defaut, il y a une etoile
                    if (is_string($this->obj->get_default_option($param_default))) {
                        if (strpos($this->obj->get_default_option($param_default), "*") === 0) {
                            $type = "text";
                        }
                    }
                    // C'est un file si dans le texte par defaut est egal a [file]
                    if (is_string($this->obj->get_default_option($param_default))) {
                        if (str_replace("[file]", "", $this->obj->get_default_option($param_default)) != $this->obj->get_default_option($param_default)) {
                            $type = "file";
                        }
                    }
                    // C'est un password si dans le texte par defaut est egal a [password]
                    if (is_string($this->obj->get_default_option($param_default))) {
                        if (str_replace("[password]", "", $this->obj->get_default_option($param_default)) != $this->obj->get_default_option($param_default)) {
                            $type = "password";
                        }
                    }
                    // C'est un media si dans le texte par defaut est egal a [media]
                    if (is_string($this->obj->get_default_option($param_default))) {
                        if (str_replace("[media]", "", $this->obj->get_default_option($param_default)) != $this->obj->get_default_option($param_default)) {
                            $type = "media";
                        }
                    }
                    // C'est un page si dans le texte par defaut est egal a [page]
                    if (is_string($this->obj->get_default_option($param_default))) {
                        if (str_replace("[page]", "", $this->obj->get_default_option($param_default)) != $this->obj->get_default_option($param_default)) {
                            $type = "page";
                        }
                    }
                    // We reset the param
                    //---------------------------------------
                    $problem_e = "";
                    $problem_w = "";
                    if (isset($_POST['resetOptions'])) {
                        $maj = true;
                        $new_param = $this->get_new_value($param_default);
                        $modified = true;
                        $this->obj->set_param($param, $new_param);
                    }
                    // We update the param
                    //---------------------------------------
                    $problem_e = "";
                    $problem_w = "";
                    if (isset($_POST['submitOptions'])) {
                        $maj = true;
                        $new_param = $this->get_new_value($param);
                        $old_param = $this->obj->get_param($param);
                        if (is_array($new_param) && isset($new_param[0]) && $new_param[0] == 'error') {
                            $problem_e .= $new_param[1];
                            $error = true;
                        } else {
                            // Warning management
                            if ($type == "string" || $type == "text" || $type == "password") {
                                if (isset($_POST[$param])) {
                                    if ($new_param != stripslashes($_POST[$param])) {
                                        $problem_w .= "<p>" . __('Warning: some characters have been removed because they are not allowed here', 'SL_framework') . " (" . $forbid . ")!</p>\n";
                                        $warning = true;
                                    }
                                }
                            }
                            // Update of the value
                            if ($new_param != $old_param) {
                                $modified = true;
                                $this->obj->set_param($param, $new_param);
                                SLFramework_Debug::log(get_class(), "The parameter " . $param . " of the plugin " . $this->obj->getPluginID() . " have been modified", 4);
                            }
                        }
                    }
                    // We built a new line for the table
                    //---------------------------------------
                    if ($type == "boolean") {
                        $cl = "<p class='paramLine'><label for='" . $param . "'>" . $name . "</label></p>";
                        // We check if there is a comment just after it
                        while (isset($this->buffer[$iii + 1])) {
                            if ($this->buffer[$iii + 1][0] != "comment") {
                                break;
                            }
                            $cl .= "<p class='paramComment' style='color: #a4a4a4;'>" . $this->buffer[$iii + 1][1] . "</p>";
                            $iii++;
                        }
                        $cel_label = new adminCell($cl);
                        $checked = "";
                        if ($this->obj->get_param($param)) {
                            $checked = "checked";
                        }
                        if (count($related) > 0) {
                            $onClick = "onClick='activateDeactivate_Params(\"" . $param . "\",new Array(\"" . implode("\",\"", $related) . "\"))'";
                            $toExecuteWhenLoaded .= "activateDeactivate_Params(\"" . $param . "\",new Array(\"" . implode("\",\"", $related) . "\"));\n";
                        } else {
                            $onClick = "";
                        }
                        $workaround = "<input type='hidden' value='0' name='" . $param . "_workaround' id='" . $param . "_workaround'>";
                        $cel_value = new adminCell("<p class='paramLine'>" . $workaround . "<input " . $onClick . " name='" . $param . "' id='" . $param . "' type='checkbox' " . $checked . " ></p>");
                        $currentTable->add_line(array($cel_label, $cel_value), '1');
                    }
                    if ($type == "int") {
                        $ew = "";
                        if ($problem_e != "") {
                            $ew .= "<div class='errorSedLex'>" . $problem_e . "</div>";
                        }
                        if ($problem_w != "") {
                            $ew .= "<div class='warningSedLex'>" . $problem_w . "</div>";
                        }
                        $cl = "<p class='paramLine'><label for='" . $param . "'>" . $name . "</label></p>" . $ew;
                        // We check if there is a comment just after it
                        while (isset($this->buffer[$iii + 1])) {
                            if ($this->buffer[$iii + 1][0] != "comment") {
                                break;
                            }
                            $cl .= "<p class='paramComment' style='color: #a4a4a4;'>" . $this->buffer[$iii + 1][1] . "</p>";
                            $iii++;
                        }
                        $cel_label = new adminCell($cl);
                        $cel_value = new adminCell("<p class='paramLine'><input name='" . $param . "' id='" . $param . "' type='text' value='" . $this->obj->get_param($param) . "' size='" . min(30, max(6, strlen($this->obj->get_param($param) . '') + 1)) . "'> " . __('(integer)', 'SL_framework') . "</p>");
                        $currentTable->add_line(array($cel_label, $cel_value), '1');
                    }
                    if ($type == "string") {
                        $ew = "";
                        if ($problem_e != "") {
                            $ew .= "<div class='errorSedLex'>" . $problem_e . "</div>";
                        }
                        if ($problem_w != "") {
                            $ew .= "<div class='warningSedLex'>" . $problem_w . "</div>";
                        }
                        $cl = "<p class='paramLine'><label for='" . $param . "'>" . $name . "</label></p>" . $ew;
                        // We check if there is a comment just after it
                        while (isset($this->buffer[$iii + 1])) {
                            if ($this->buffer[$iii + 1][0] != "comment") {
                                break;
                            }
                            $cl .= "<p class='paramComment' style='color: #a4a4a4;'>" . $this->buffer[$iii + 1][1] . "</p>";
                            $iii++;
                        }
                        $cel_label = new adminCell($cl);
                        $cel_value = new adminCell("<p class='paramLine'><input name='" . $param . "' id='" . $param . "' type='text' value='" . htmlentities($this->obj->get_param($param), ENT_QUOTES, "UTF-8") . "' size='" . min(30, max(6, strlen($this->obj->get_param($param) . '') + 1)) . "'></p>");
                        $currentTable->add_line(array($cel_label, $cel_value), '1');
                    }
                    if ($type == "password") {
                        $ew = "";
                        if ($problem_e != "") {
                            $ew .= "<div class='errorSedLex'>" . $problem_e . "</div>";
                        }
                        if ($problem_w != "") {
                            $ew .= "<div class='warningSedLex'>" . $problem_w . "</div>";
                        }
                        $cl = "<p class='paramLine'><label for='" . $param . "'>" . $name . "</label></p>" . $ew;
                        // We check if there is a comment just after it
                        while (isset($this->buffer[$iii + 1])) {
                            if ($this->buffer[$iii + 1][0] != "comment") {
                                break;
                            }
                            $cl .= "<p class='paramComment' style='color: #a4a4a4;'>" . $this->buffer[$iii + 1][1] . "</p>";
                            $iii++;
                        }
                        $cel_label = new adminCell($cl);
                        $cel_value = new adminCell("<p class='paramLine'><input name='" . $param . "' id='" . $param . "' type='password' value='" . htmlentities($this->obj->get_param($param), ENT_QUOTES, "UTF-8") . "' size='" . min(30, max(6, strlen($this->obj->get_param($param) . '') + 1)) . "'></p>");
                        $currentTable->add_line(array($cel_label, $cel_value), '1');
                    }
                    if ($type == "text") {
                        $num = min(22, count(explode("\n", $this->obj->get_param($param))) + 1);
                        $ew = "";
                        if ($problem_e != "") {
                            $ew .= "<div class='errorSedLex'>" . $problem_e . "</div>";
                        }
                        if ($problem_w != "") {
                            $ew .= "<div class='warningSedLex'>" . $problem_w . "</div>";
                        }
                        $cl = "<p class='paramLine'><label for='" . $param . "'>" . $name . "</label></p>" . $ew;
                        // We check if there is a comment just after it
                        while (isset($this->buffer[$iii + 1])) {
                            if ($this->buffer[$iii + 1][0] != "comment") {
                                break;
                            }
                            $cl .= "<p class='paramComment' style='color: #a4a4a4;'>" . $this->buffer[$iii + 1][1] . "</p>";
                            $iii++;
                        }
                        $cel_label = new adminCell($cl);
                        $cel_value = new adminCell("<p class='paramLine'><div style='width:100%'><textarea style='width:100%' name='" . $param . "' id='" . $param . "' rows='" . $num . "'>" . htmlentities($this->obj->get_param($param), ENT_QUOTES, "UTF-8") . "</textarea></div></p>");
                        $currentTable->add_line(array($cel_label, $cel_value), '1');
                    }
                    if ($type == "list") {
                        $cl = "<p class='paramLine'><label for='" . $param . "'>" . $name . "</label></p>";
                        // We check if there is a comment just after it
                        while (isset($this->buffer[$iii + 1])) {
                            if ($this->buffer[$iii + 1][0] != "comment") {
                                break;
                            }
                            $cl .= "<p class='paramComment' style='color: #a4a4a4;'>" . $this->buffer[$iii + 1][1] . "</p>";
                            $iii++;
                        }
                        $cel_label = new adminCell($cl);
                        $cc = "";
                        ob_start();
                        ?>
							<p class='paramLine'>
							<select name='<?php 
                        echo $param;
                        ?>
' id='<?php 
                        echo $param;
                        ?>
'>
							<?php 
                        $array = $this->obj->get_param($param);
                        echo "//";
                        print_r($array);
                        foreach ($array as $a) {
                            if (!is_array($a)) {
                                $selected = "";
                                if (is_string($a) && substr($a, 0, 1) == "*") {
                                    $selected = "selected";
                                    $a = substr($a, 1);
                                }
                                ?>
										<option value="<?php 
                                echo SLFramework_Utils::create_identifier($a);
                                ?>
" <?php 
                                echo $selected;
                                ?>
><?php 
                                echo $a;
                                ?>
</option>
									<?php 
                            } else {
                                $selected = "";
                                if (is_string($a[0]) && substr($a[0], 0, 1) == "*") {
                                    $selected = "selected";
                                    $a[0] = substr($a[0], 1);
                                }
                                ?>
										<option value="<?php 
                                echo $a[1];
                                ?>
" <?php 
                                echo $selected;
                                ?>
><?php 
                                echo $a[0];
                                ?>
</option>
									<?php 
                            }
                        }
                        ?>
							</select>
							</p>
						<?php 
                        $cc = ob_get_clean();
                        $cel_value = new adminCell($cc);
                        $currentTable->add_line(array($cel_label, $cel_value), '1');
                    }
                    if ($type == "media") {
                        $cl = "<p class='paramLine'><label for='" . $param . "'>" . $name . "</label></p>" . $ew;
                        // We check if there is a comment just after it
                        while (isset($this->buffer[$iii + 1])) {
                            if ($this->buffer[$iii + 1][0] != "comment") {
                                break;
                            }
                            $cl .= "<p class='paramComment' style='color: #a4a4a4;'>" . $this->buffer[$iii + 1][1] . "</p>";
                            $iii++;
                        }
                        $cel_label = new adminCell($cl);
                        // If this is the URL of an auto-generated thumbnail, get the URL of the original image
                        $attachment_url = preg_replace('/-\\d+x\\d+(?=\\.(jpg|jpeg|png|gif)$)/i', '', $this->obj->get_param($param));
                        $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE guid='%s';", $attachment_url));
                        if (isset($attachment[0])) {
                            $id_media = $attachment[0];
                            $msg_media = "<p class='paramComment' style='color: #a4a4a4;'>" . sprintf(__("The URL is correct and the ID of the media file is %s.", 'SL_framework'), '<code>' . $id_media . "</code>") . "</p>";
                            if (wp_attachment_is_image($id_media)) {
                                $msg_media .= '<p class="paramComment" style="color: #a4a4a4; text-align:center;"><a href="' . get_attachment_link($id_media) . '">' . wp_get_attachment_image($id_media, "thumbnail") . '</a></p>';
                            } else {
                                $msg_media .= '<p class="paramComment" style="color: #a4a4a4; text-align:center;>coucou</p>';
                            }
                        } else {
                            $msg_media = "<p class='paramComment' style='color: #a4a4a4;'>" . __("The URL is not a media file.", 'SL_framework') . "</p>";
                        }
                        $cel_value = new adminCell("<p class='paramLine'><div style='width:100%'><input id='" . $param . "' type='text' size='20' name='" . $param . "' value='" . htmlentities($this->obj->get_param($param), ENT_QUOTES, "UTF-8") . "' /><input id='media_" . $param . "' class='button' type='button' value='" . __('Choose a media', 'SL_framework') . "' onclick=\"paramMediaReturn = '" . $param . "'; formfield = jQuery('#" . $param . "').attr('name'); tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true'); return false;\"/></div></p>" . $msg_media);
                        $currentTable->add_line(array($cel_label, $cel_value), '1');
                    }
                    if ($type == "page") {
                        $cl = "<p class='paramLine'><label for='" . $param . "'>" . $name . "</label></p>" . $ew;
                        // We check if there is a comment just after it
                        while (isset($this->buffer[$iii + 1])) {
                            if ($this->buffer[$iii + 1][0] != "comment") {
                                break;
                            }
                            $cl .= "<p class='paramComment' style='color: #a4a4a4;'>" . $this->buffer[$iii + 1][1] . "</p>";
                            $iii++;
                        }
                        $cel_label = new adminCell($cl);
                        $selected = 0;
                        if ($this->obj->get_param($param) != "[page]") {
                            $selected = $this->obj->get_param($param);
                        }
                        $cel_value = new adminCell("<p class='paramLine'>" . wp_dropdown_pages(array('echo' => 0, 'name' => $param, 'selected' => $selected, "show_option_none" => __('(none)', "SLFramework"), "option_none_value" => '[page]')) . "</p>");
                        $currentTable->add_line(array($cel_label, $cel_value), '1');
                    }
                    if ($type == "file") {
                        $ew = "";
                        if ($problem_e != "") {
                            $ew .= "<div class='errorSedLex'>" . $problem_e . "</div>";
                        }
                        if ($problem_w != "") {
                            $ew .= "<div class='warningSedLex'>" . $problem_w . "</div>";
                        }
                        $cl = "<p class='paramLine'><label for='" . $param . "'>" . $name . "</label></p>" . $ew;
                        // We check if there is a comment just after it
                        while (isset($this->buffer[$iii + 1])) {
                            if ($this->buffer[$iii + 1][0] != "comment") {
                                break;
                            }
                            $cl .= "<p class='paramComment' style='color: #a4a4a4;'>" . $this->buffer[$iii + 1][1] . "</p>";
                            $iii++;
                        }
                        $cel_label = new adminCell($cl);
                        $cc = "";
                        ob_start();
                        $upload_dir = wp_upload_dir();
                        if (!file_exists($upload_dir["basedir"] . $this->obj->get_param($param))) {
                            $this->obj->set_param($param, $this->obj->get_default_option($param_default));
                        }
                        if ($this->obj->get_default_option($param_default) == $this->obj->get_param($param)) {
                            ?>
								<p class='paramLine'><input type='file' name='<?php 
                            echo $param;
                            ?>
' id='<?php 
                            echo $param;
                            ?>
'/></p>
								<?php 
                        } else {
                            $path = $upload_dir["baseurl"] . $this->obj->get_param($param);
                            $pathdir = $upload_dir["basedir"] . $this->obj->get_param($param);
                            $info = pathinfo($pathdir);
                            if (strtolower($info['extension']) == "png" || strtolower($info['extension']) == "gif" || strtolower($info['extension']) == "jpg" || strtolower($info['extension']) == "bmp") {
                                list($width, $height) = getimagesize($pathdir);
                                $max_width = 100;
                                $max_height = 100;
                                $ratioh = $max_height / $height;
                                $ratiow = $max_width / $width;
                                $ratio = min($ratioh, $ratiow);
                                // New dimensions
                                $width = min(intval($ratio * $width), $width);
                                $height = min(intval($ratio * $height), $height);
                                ?>
									<p class='paramLine'><img src='<?php 
                                echo $path;
                                ?>
' width="<?php 
                                echo $width;
                                ?>
px" height="<?php 
                                echo $height;
                                ?>
px" style="vertical-align:middle;"/> <a href="<?php 
                                echo $path;
                                ?>
"><?php 
                                echo $this->obj->get_param($param);
                                ?>
</a></p>
									<?php 
                            } else {
                                ?>
									<p class='paramLine'><img src='<?php 
                                echo plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "img/file.png";
                                ?>
' width="75px" style="vertical-align:middle;"/> <a href="<?php 
                                echo $path;
                                ?>
"><?php 
                                echo $this->obj->get_param($param);
                                ?>
</a></p>
									<?php 
                            }
                            ?>
								<p class='paramLine'><?php 
                            echo sprintf(__("(If you want to delete this file, please check this box %s)", "SL_framework"), "<input type='checkbox'  name='delete_" . $param . "' value='1' id='delete_" . $param . "'>");
                            ?>
</p>
								<?php 
                        }
                        $cc = ob_get_clean();
                        $cel_value = new adminCell($cc);
                        $currentTable->add_line(array($cel_label, $cel_value), '1');
                    }
                }
                // End is it a param?
            }
            // We finish the form output
            ob_start();
            ?>
					<div class="submit">
						<input type="submit" name="submitOptions" class='button-primary validButton' value="<?php 
            echo __('Update', 'SL_framework');
            ?>
" />&nbsp;
						<input type="submit" name="resetOptions" class='button validButton' value="<?php 
            echo __('Reset to default values', 'SL_framework');
            ?>
" />
					</div>
				</form>
			</div>
			<script>
				if (window.attachEvent) {window.attachEvent('onload', toExecuteWhenLoadedParameter);}
				else if (window.addEventListener) {window.addEventListener('load', toExecuteWhenLoadedParameter, false);}
				else {document.addEventListener('load', toExecuteWhenLoadedParameter, false);} 
				
				function toExecuteWhenLoadedParameter() {
					<?php 
            echo $toExecuteWhenLoaded;
            ?>
				}
			</script>
			<?php 
            // If the parameter have been modified, we say it !
            if ($error && $maj) {
                ?>
				<div class="error fade">
					<p><?php 
                echo __('Some parameters have not been updated due to errors (see below)!', 'SL_framework');
                ?>
</p>
				</div>
				<?php 
            } else {
                if ($warning && $maj) {
                    ?>
				<div class="updated  fade">
					<p><?php 
                    echo __('Parameters have been updated (but with some warnings)!', 'SL_framework');
                    ?>
</p>
				</div>
				<?php 
                } else {
                    if ($modified && $maj) {
                        if (!isset($_POST['resetOptions'])) {
                            ?>
				<div class="updated  fade">
					<p><?php 
                            echo __('Parameters have been updated successfully!', 'SL_framework');
                            ?>
</p>
				</div>
				<?php 
                        } else {
                            ?>
				<div class="updated  fade">
					<p><?php 
                            echo __('Parameters have been reset to their default values!', 'SL_framework');
                            ?>
</p>
				</div>
				<?php 
                        }
                    }
                }
            }
            $this->output .= ob_get_clean();
            echo $this->output;
        }
 /** ====================================================================================================================================================
  * Send backup files to ftp host
  *
  * @param $attach the bachup file paths
  * @return void
  */
 function sendFTP($attach)
 {
     $pasv = false;
     if ($this->get_ftp_host() == '') {
         return array("transfer" => false, "error" => __('No host has been defined', $this->pluginID));
     }
     $conn = false;
     if (preg_match("/ftp:\\/\\/([^\\/]*)(\\/*.*)/i", $this->get_ftp_host(), $match)) {
         $conn = @ftp_connect($match[1], $this->get_param('ftp_port'), 50);
     } else {
         if (!function_exists('ftp_ssl_connect')) {
             SLFramework_Debug::log(get_class(), "The PHP installation does not support SSL features", 1);
             return array("transfer" => false, "error" => sprintf(__('Your PHP installation does not support SSL features... Thus, please use a standard FTP and not a FTPS!', $this->pluginID), "<code>" . $match[1] . "</code>"));
         }
         if (preg_match("/ftps:\\/\\/([^\\/]*)(\\/*.*)/i", $this->get_ftp_host(), $match)) {
             $conn = @ftp_ssl_connect($match[1], $this->get_param('ftp_port'), 50);
         }
     }
     if ($conn === false) {
         SLFramework_Debug::log(get_class(), sprintf("Problem with host %s", $match[1]), 2);
         return array("transfer" => false, "error" => sprintf(__('The host %s cannot be resolved!', $this->pluginID), "<code>" . $match[1] . "</code>"));
     } else {
         if (@ftp_login($conn, $this->get_param('ftp_login'), $this->get_param('ftp_pass'))) {
             if (@ftp_chdir($conn, $match[2])) {
                 // Si on doit creer un nouveau repertoire pour chaque backup
                 if ($this->get_param('ftp_create_folder')) {
                     if (@ftp_chdir($conn, str_replace("//", "/", $match[2] . "/" . $this->get_param('ftp_prefix_folder') . date('Ymd')))) {
                         // Nothing to do ...
                     } else {
                         if (@ftp_mkdir($conn, str_replace("//", "/", $match[2] . "/" . $this->get_param('ftp_prefix_folder') . date('Ymd')))) {
                             // nikel ... maintenant que c'est crée ...
                             if (@ftp_chdir($conn, str_replace("//", "/", $match[2] . "/" . $this->get_param('ftp_prefix_folder') . date('Ymd')))) {
                                 // Nothing to do ...
                             } else {
                                 SLFramework_Debug::log(get_class(), "Problem for going into subdir: " . $this->get_param('ftp_prefix_folder') . $str_replace("//", "/", $match[2] . "/" . date('Ymd')), 2);
                             }
                         } else {
                             SLFramework_Debug::log(get_class(), "Problem with creation of subdir: " . $this->get_param('ftp_prefix_folder') . $str_replace("//", "/", $match[2] . "/" . date('Ymd')), 2);
                             return array("transfer" => false, "error" => sprintf(__('The folder %s cannot be created on the FTP repository!', $this->pluginID), "<code>" . $this->get_param('ftp_prefix_folder') . str_replace("//", "/", $match[2] . "/" . date('Ymd')) . "</code>"));
                         }
                     }
                 }
                 for ($i = 0; $i < count($attach); $i++) {
                     ob_start();
                     $res = @ftp_put($conn, basename($attach[$i]), $attach[$i], FTP_BINARY);
                     if (!$res) {
                         $pasv = true;
                         if (@ftp_pasv($conn, true)) {
                             $res = @ftp_put($conn, basename($attach[$i]), $attach[$i], FTP_BINARY);
                             if (!$res) {
                                 $value = ob_get_clean();
                                 @ftp_close($conn);
                                 SLFramework_Debug::log(get_class(), "Problem with FTP transferring: " . $value, 2);
                                 return array("transfer" => false, "error" => sprintf(__('The file %s cannot be transfered to the FTP repository %s! The ftp_put function returns: %s', $this->pluginID), "<code>" . $attach[$i] . "</code>", "<code>" . ftp_pwd($conn) . "</code>", "<code>" . $value . "</code>"));
                             } else {
                                 SLFramework_Debug::log(get_class(), "FTP transfer OK of " . $attach[$i] . ' to ' . $this->get_ftp_host(), 4);
                             }
                         } else {
                             $value = ob_get_clean();
                             @ftp_close($conn);
                             SLFramework_Debug::log(get_class(), "Problem with PASV mode: " . $value, 2);
                             return array("transfer" => false, "error" => sprintf(__('The file %s cannot be transfered to the FTP repository and PASV mode cannot be entered : %s', $this->pluginID), "<code>" . $attach[$i] . "</code>", "<code>" . $value . "</code>"));
                         }
                     } else {
                         SLFramework_Debug::log(get_class(), "FTP transfer OK of " . $attach[$i] . ' to ' . $this->get_ftp_host(), 4);
                     }
                     $vide = ob_get_clean();
                 }
                 @ftp_close($conn);
                 return array("transfer" => true, 'pasv' => $pasv, 'file' => $attach, 'ftp_host' => $match[1], 'ftp_dir' => $match[2]);
             } else {
                 @ftp_close($conn);
                 SLFramework_Debug::log(get_class(), "Problem with FTP chdir to " . $match[2], 2);
                 return array("transfer" => false, "error" => sprintf(__('The specified folder %s does not exists. Please create it so that the transfer may start!', $this->pluginID), $match[2]));
             }
         } else {
             @ftp_close($conn);
             SLFramework_Debug::log(get_class(), "The login (i.e. " . $this->get_param('ftp_login') . ")  and the password (i.e. " . $this->get_param('ftp_pass') . ") do not seem to be valid!", 2);
             return array("transfer" => false, "error" => __('The login/password does not seems valid!', $this->pluginID));
         }
     }
     return array("transfer" => true, 'pasv' => $pasv, 'file' => $attach, 'ftp_host' => $match[1], 'ftp_dir' => $match[2]);
 }
 /** ====================================================================================================================================================
  * 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;
 }
 /** ====================================================================================================================================================
  * Update the language installed for this plugin
  * 
  * @access private
  * @return void
  */
 static function update_languages_plugin($domain, $plugin)
 {
     $path = WP_PLUGIN_DIR . "/" . $plugin;
     if ($domain == "SL_framework") {
         return;
     }
     // We create the lang dir
     if (!is_dir($path . "/lang/")) {
         mkdir($path . "/lang/", 0777, true);
     }
     // We check if the .pot file exist
     if (is_file($path . "/lang/" . $domain . ".pot")) {
         // We delete the file
         @unlink($path . "/lang/" . $domain . ".pot");
     }
     // We generate a new POT file
     $content = "Content-Transfer-Encoding: 8bit\n\n";
     $php = SLFramework_Translation::get_php_files($path);
     foreach ($php as $f) {
         $lines = file($path . "/" . $f);
         $i = 0;
         foreach ($lines as $l) {
             $i++;
             $match_array = array("@__[ ]*\\([ ]*\\\"([^\\\"]*)\\\"([^)]*)this->pluginID\\)@", "@__[ ]*\\([ ]*'([^']*)'([^)]*)this->pluginID\\)@");
             foreach ($match_array as $reg) {
                 if (preg_match_all($reg, $l, $match, PREG_SET_ORDER)) {
                     foreach ($match as $m) {
                         $val[0] = trim($m[1]);
                         $pos = strpos($content, 'msgid "' . $val[0] . '"');
                         if ($pos === false) {
                             // We translate only the text of the domain of the plugin
                             $content .= "#: " . $f . ":" . $i . "\n";
                             $content .= "#@ " . $domain . "\n";
                             // domain
                             $value = $val[0];
                             // If the string is between simple quote, we escape the double quote
                             if ($reg == $match_array[1]) {
                                 $value = str_replace("\"", "\\\"", $val[0]);
                             }
                             $content .= 'msgid "' . $value . '"' . "\n";
                             $content .= 'msgstr ""' . "\n\n";
                         } else {
                             // If the text is already in the POT file, we only add the line number and the file
                             $temp = explode("#@ " . $domain . "\n" . 'msgid "' . $val[0] . '"' . "\n", $content);
                             $content = $temp[0] . "#: " . $f . ":" . $i . "\n" . "#@ " . $domain . "\n" . 'msgid "' . $val[0] . '"' . "\n" . $temp[1];
                         }
                     }
                 }
             }
         }
     }
     SLFramework_Debug::log(get_class(), "The file " . $path . "/lang/" . $domain . ".pot has been downloaded", 4);
     @file_put_contents($path . "/lang/" . $domain . ".pot", $content);
 }
Exemple #7
0
    /** ====================================================================================================================================================
     * The admin configuration page
     * This function will be called when you select the plugin in the admin backend 
     *
     * @return void
     */
    public function configuration_page()
    {
        global $wpdb;
        global $blog_id;
        SLFramework_Debug::log(get_class(), "Print the configuration page.", 4);
        ?>
		<div class="plugin-titleSL">
			<h2><?php 
        echo $this->pluginName;
        ?>
</h2>
		</div>
		<div class="plugin-contentSL">			
			<?php 
        //===============================================================================================
        // After this comment, you may modify whatever you want
        ?>
			<p><?php 
        echo __("This is the configuration page of the plugin", $this->pluginID);
        ?>
</p>
			<?php 
        // We check rights
        $this->check_folder_rights(array(array(WP_CONTENT_DIR . "/sedlex/test/", "rwx")));
        $tabs = new SLFramework_Tabs();
        ob_start();
        // Examples for creating tables
        //----------------------------------
        echo "<h5>" . __("Tables", $this->pluginID) . "</h5>";
        $table = new SLFramework_Table();
        $table->title(array(__("Col1", $this->pluginID), __("Col2", $this->pluginID), __("Col2", $this->pluginID)));
        ob_start();
        echo __("Cell 1-1", $this->pluginID);
        $cel1 = new adminCell(ob_get_clean());
        ob_start();
        echo __("Cell 1-2", $this->pluginID);
        $cel2 = new adminCell(ob_get_clean());
        ob_start();
        echo __("Cell 1-3", $this->pluginID);
        $cel3 = new adminCell(ob_get_clean());
        $table->add_line(array($cel1, $cel2, $cel3), '1');
        ob_start();
        echo __("Cell 2-1", $this->pluginID);
        $cel1 = new adminCell(ob_get_clean());
        ob_start();
        echo __("Cell 2-2", $this->pluginID);
        $cel2 = new adminCell(ob_get_clean());
        ob_start();
        echo __("Cell 2-3", $this->pluginID);
        $cel3 = new adminCell(ob_get_clean());
        $table->add_line(array($cel1, $cel2, $cel3), '2');
        echo $table->flush();
        $tabs->add_tab(__('Summary', $this->pluginID), ob_get_clean());
        ob_start();
        $params = new SLFramework_Parameters($this, "tab-parameters");
        $params->add_title(__('Title 1', $this->pluginID));
        $params->add_param('opt1', __('Modify arg 1:', $this->pluginID));
        $params->add_comment(__("This is a comment. The default value is:", $this->pluginID));
        $params->add_comment_default_value('opt1');
        $params->add_param('opt2', __('Modify arg 2:', $this->pluginID));
        $params->add_param('opt3', __('Modify arg 3:', $this->pluginID));
        $params->add_comment(__('This is another comment.', $this->pluginID));
        $params->add_comment(__('The default value is:', $this->pluginID));
        $params->add_comment_default_value('opt3');
        $params->add_title(__('Title 2', $this->pluginID));
        $params->add_param('opt4', __('Modify arg 4:', $this->pluginID));
        $params->add_comment(__("This is a comment. The default value is:", $this->pluginID));
        $params->add_comment_default_value('opt4');
        $params->flush();
        $tabs->add_tab(__('Parameters', $this->pluginID), ob_get_clean(), plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_param.png");
        $frmk = new coreSLframework();
        if (is_multisite() && $blog_id == 1 || !is_multisite() || $frmk->get_param('global_allow_translation_by_blogs')) {
            ob_start();
            $plugin = str_replace("/", "", str_replace(basename(__FILE__), "", plugin_basename(__FILE__)));
            $trans = new SLFramework_Translation($this->pluginID, $plugin);
            $trans->enable_translation();
            $tabs->add_tab(__('Manage translations', $this->pluginID), ob_get_clean(), plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_trad.png");
        }
        ob_start();
        $plugin = str_replace("/", "", str_replace(basename(__FILE__), "", plugin_basename(__FILE__)));
        $trans = new SLFramework_Feedback($plugin, $this->pluginID);
        $trans->enable_feedback();
        $tabs->add_tab(__('Give feedback', $this->pluginID), ob_get_clean(), plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_mail.png");
        ob_start();
        // A list of plugin slug to be excluded
        $exlude = array('wp-pirate-search');
        // Replace sedLex by your own author name
        $trans = new SLFramework_OtherPlugins("sedLex", $exlude);
        $trans->list_plugins();
        $tabs->add_tab(__('Other plugins', $this->pluginID), ob_get_clean(), plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_plug.png");
        echo $tabs->flush();
        // Before this comment, you may modify whatever you want
        //===============================================================================================
        ?>
			<?php 
        echo $this->signature;
        ?>
		</div>
		<?php 
    }
 /** ====================================================================================================================================================
  * Create the archive and split it if necessary
  * 
  * @param string $splitfilename the path of the zip file to create
  * @param integer $chunk_size the maximum size of the archive
  * @param integer $maxExecutionTime the maximum execution time in second (if this time is exceeded, the function will return false. You just have to relaunch this function to complete the zip from where it has stopped)
  * @param integer $maxExecutionTime the maximum memory allocated by the process (in bytes)
  * @return array with the name of the file (or 'finished' => false if an error occured see 'error' for the error message)
  */
 function createZip($splitfilename, $chunk_size = 1000000000000000, $maxExecutionTime = 150, $maxAllocatedMemory = 4000000)
 {
     // Init variables
     //---------------------
     $zipfile_comment = "Compressed/Splitted by the SL framework (SedLex)";
     $path = str_replace(basename($splitfilename), "", $splitfilename);
     $pathToReturn = array();
     $disk_number = 1;
     $split_signature = "PK";
     // Optionnal
     $nbentry = 0;
     $nbfolder = 0;
     $data_segments = "";
     $files_not_included_due_to_filesize = array();
     $this->allocatedSize = 0;
     //  We check whether a process is running
     //----------------------------------------------
     if (is_file(dirname($splitfilename) . "/zip_in_progress")) {
         $timestart = @file_get_contents(dirname($splitfilename) . "/zip_in_progress");
         // We cannot read the lock file
         if ($timestart === FALSE) {
             if (!SLFramework_Utils::rm_rec($path . "/zip_in_progress")) {
                 SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress cannot be deleted", 2);
                 return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . "/zip_in_progress</code>"));
             }
             SLFramework_Debug::log(get_class(), "The file " . dirname($splitfilename) . "/zip_in_progress cannot be deleted", 2);
             return array('finished' => false, "error" => sprintf(__('The file %s cannot be read. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . dirname($splitfilename) . "/zip_in_progress</code>"));
         }
         $timeprocess = time() - (int) $timestart;
         SLFramework_Debug::log(get_class(), "An other process is still running  for " . $timeprocess, 2);
         return array('finished' => false, 'error' => sprintf(__("An other process is still running (it runs for %s seconds)", "SL_framework"), $timeprocess));
     }
     //  We create a lock file
     //----------------------------------------------
     $r = @file_put_contents(dirname($splitfilename) . "/zip_in_progress", time());
     if ($r === FALSE) {
         SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress cannot be modified/created", 2);
         if (!SLFramework_Utils::rm_rec($path . "/zip_in_progress")) {
             SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress cannot be deleted", 2);
             return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . "/zip_in_progress</code>"));
         }
         return array('finished' => false, "error" => sprintf(__('The file %s cannot be modified/created. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . dirname($splitfilename) . "/zip_in_progress</code>"));
     } else {
         SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress has be created to ensure that a lock file exists", 5);
     }
     //  We retrieve old saved param
     //      if the .tmp file exists, it means that we have to restart the zip process where it stopped
     //----------------------------------------------
     if (is_file($splitfilename . ".tmp")) {
         // We retrieve the process
         $content = @file_get_contents($splitfilename . ".tmp");
         if ($content === FALSE) {
             SLFramework_Debug::log(get_class(), "The file " . $splitfilename . ".tmp cannot be read", 2);
             if (!SLFramework_Utils::rm_rec($path . "/zip_in_progress")) {
                 SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress cannot be deleted", 2);
                 return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . "/zip_in_progress</code>"));
             }
             return array('finished' => false, "error" => sprintf(__('The file %s cannot be read. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $splitfilename . ".tmp</code>"));
         }
         list($nbentry, $nbfolder, $pathToReturn, $disk_number, $this->filelist, $files_not_included_due_to_filesize) = unserialize($content);
         SLFramework_Debug::log(get_class(), "Get the unserialized content of  " . $splitfilename . ".tmp", 4);
         //  We start a new process if nothing have yet started
         //----------------------------------------------
     } else {
         // We add the signature in the zip file
         $r = @file_put_contents($path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), $split_signature);
         $pathToReturn[time() . " " . sprintf("%02d", $disk_number)] = $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number);
         if ($r === FALSE) {
             SLFramework_Debug::log(get_class(), "The signature of the zip file cannot be added to " . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), 2);
             if (!SLFramework_Utils::rm_rec($path . "/zip_in_progress")) {
                 SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress cannot be deleted", 2);
                 return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . "/zip_in_progress</code>"));
             }
             return array('finished' => false, "error" => sprintf(__('The file %s cannot be created. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number) . "</code>"));
         } else {
             SLFramework_Debug::log(get_class(), "The signature of the zip file has been added to " . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), 4);
         }
         // We create the list of folder
         SLFramework_Debug::log(get_class(), "Begin the list of folders", 4);
         foreach ($this->filelist as $k => $filename_array) {
             $add_t = $filename_array[2];
             $remove_t = $filename_array[1];
             $filename = $filename_array[0];
             $newfilename = str_replace("//", "/", $add_t . str_replace(str_replace("\\", "/", $remove_t), "", str_replace("\\", "/", $filename)));
             if (!is_file($filename)) {
                 continue;
             }
             $ch = explode("/", $newfilename);
             // We delete the last item because it is the filename of the file
             unset($ch[count($ch) - 1]);
             while (count($ch) > 0) {
                 $chemin = implode("/", $ch) . "/";
                 if (!isset($this->dirlist[md5($chemin)])) {
                     $this->dirlist[md5($chemin)] = $chemin;
                 }
                 unset($ch[count($ch) - 1]);
             }
         }
         usort($this->dirlist, array($this, 'sort_by_length_dir'));
         usort($this->filelist, array($this, 'sort_by_length_file'));
         // We add the folder
         foreach ($this->dirlist as $dir) {
             $relative_offset_in_disk = 0;
             if (is_file($path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number))) {
                 clearstatcache();
                 $relative_offset_in_disk = @filesize($path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number));
             }
             $dir = SLFramework_Utils::convertUTF8($dir);
             $local_file_header = "PK";
             // 4 bytes  (0x04034b50) local_file_header_signature
             $local_file_header .= "";
             // 2 bytes version_needed_to_extract
             $local_file_header .= "";
             // 2 bytes general_purpose_bit_flag (we say that the name should be encode in UTF8)
             $local_file_header .= pack('v', 0);
             // 2 bytes compression_method
             $local_file_header .= pack('v', 0);
             // 2 bytes last mod file time
             $local_file_header .= pack('v', 0);
             // 2 bytes last mod file time
             $local_file_header .= pack('V', 0);
             // 4 bytes crc_32
             $local_file_header .= pack('V', 0);
             // 4 bytes compressed_size
             $local_file_header .= pack('V', 0);
             // 4 bytes uncompressed_size
             $local_file_header .= pack('v', strlen($dir));
             // 2 bytes filename_length
             $local_file_header .= pack('v', 0);
             // 2 bytes extra_field_length
             $local_file_header .= $dir;
             // variable size filename
             $local_file_header .= "";
             // variable size extra fields
             $r = @file_put_contents($path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), $local_file_header, FILE_APPEND);
             if ($r === FALSE) {
                 SLFramework_Debug::log(get_class(), "The folder " . $dir . " can not be added to zip file " . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), 2);
                 if (!SLFramework_Utils::rm_rec($path . "/zip_in_progress")) {
                     SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress cannot be deleted", 2);
                     return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . "/zip_in_progress</code>"));
                 }
                 return array('finished' => false, "error" => sprintf(__('The file %s cannot be modified/created. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number) . "</code>"));
             } else {
                 SLFramework_Debug::log(get_class(), "The folder " . $dir . " has been added to zip file " . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), 5);
             }
             //Set central File Header
             $central_file_header = "PK";
             // 4 bytes (0x02014b50) central file header signature
             $central_file_header .= "";
             // 2 bytes version made by (0 = MS-DOS and OS/2 compatible)
             $central_file_header .= "";
             // 2 bytes version needed to extract
             $central_file_header .= "";
             // 2 bytes general_purpose_bit_flag (we say that the name should be encode in UTF8)
             $central_file_header .= pack('v', 0);
             // 2 bytes compression_method
             $central_file_header .= pack('v', 0);
             // 2 bytes last mod file time
             $central_file_header .= pack('v', 0);
             // 2 bytes last mod file time
             $central_file_header .= pack('V', 0);
             // 4 bytes crc_32
             $central_file_header .= pack('V', 0);
             // 4 bytes compressed_size
             $central_file_header .= pack('V', 0);
             // 4 bytes uncompressed_size
             $central_file_header .= pack('v', strlen($dir));
             // 2 bytes filename_length
             $central_file_header .= pack('v', 0);
             // 2 bytes extra_field_length
             $central_file_header .= pack('v', 0);
             // 2 bytes  comment length
             $central_file_header .= pack('v', $disk_number - 1);
             // 2 bytes disk number start
             $central_file_header .= pack('v', 0);
             // 2 bytes internal file attribute
             $central_file_header .= pack('V', 16);
             // 4 bytes external file attribute
             $central_file_header .= pack('V', $relative_offset_in_disk);
             // 4 bytes relative offset of local header
             $central_file_header .= $dir;
             // variable size filename
             $central_file_header .= "";
             // variable size extra fields
             $central_file_header .= "";
             // variable size file comment
             $nbfolder++;
             $r = @file_put_contents($splitfilename . ".centraldirectory.tmp", $central_file_header, FILE_APPEND);
             if ($r === FALSE) {
                 SLFramework_Debug::log(get_class(), "The folder " . $dir . " cannot be added to central header file " . $splitfilename . ".centraldirectory.tmp", 2);
                 if (!SLFramework_Utils::rm_rec($path . "/zip_in_progress")) {
                     SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress cannot be deleted", 2);
                     return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . "/zip_in_progress</code>"));
                 }
                 return array('finished' => false, "error" => sprintf(__('The file %s cannot be modified/created. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $splitfilename . ".centraldirectory.tmp</code>"));
             } else {
                 SLFramework_Debug::log(get_class(), "The folder " . $dir . " has been added to central header file " . $splitfilename . ".centraldirectory.tmp", 5);
             }
         }
         SLFramework_Debug::log(get_class(), "End the list of  folders", 4);
     }
     //  The creation of the zip begin
     //----------------------------------------------
     SLFramework_Debug::log(get_class(), "Begin the loop for " . count($this->filelist) . " files", 4);
     foreach ($this->filelist as $k => $filename_array) {
         $add_t = $filename_array[2];
         $remove_t = $filename_array[1];
         $filename = $filename_array[0];
         //  If the time limit exceed, we save into temp files
         //----------------------------------------------
         $nowtime = microtime(true);
         if ($maxExecutionTime != 0) {
             if ($nowtime - $this->starttime > $maxExecutionTime) {
                 // We remove the files already inserted in the zip
                 $this->filelist = array_slice($this->filelist, $k);
                 // We save the content on the disk
                 $r = @file_put_contents($splitfilename . ".tmp", serialize(array($nbentry, $nbfolder, $pathToReturn, $disk_number, $this->filelist, $files_not_included_due_to_filesize)));
                 if ($r === FALSE) {
                     SLFramework_Debug::log(get_class(), "The serialized information cannot be written in " . $splitfilename . ".tmp", 2);
                     if (!SLFramework_Utils::rm_rec($path . "/zip_in_progress")) {
                         SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress cannot be deleted", 2);
                         return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . "/zip_in_progress</code>"));
                     }
                     return array('finished' => false, "error" => sprintf(__('The file %s cannot be modified/created. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $splitfilename . ".tmp</code>"));
                 } else {
                     SLFramework_Debug::log(get_class(), "The serialized information has been written successfully in " . $splitfilename . ".tmp", 4);
                 }
                 // we inform that the process is finished
                 if (!SLFramework_Utils::rm_rec($path . "/zip_in_progress")) {
                     SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress cannot be deleted", 2);
                     return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . "/zip_in_progress</code>"));
                 }
                 SLFramework_Debug::log(get_class(), "The Zip process is delayed due to time execution limitation (" . $nbentry . "/" . (count($this->filelist) + $nbentry) . " files)", 4);
                 return array('finished' => false, 'nb_to_finished' => count($this->filelist), 'nb_finished' => $nbentry, 'not_included' => $files_not_included_due_to_filesize);
             }
         }
         //  If the memory limit exceed, we save into temp files
         //----------------------------------------------
         if ($maxAllocatedMemory != 0) {
             if ($this->allocatedSize > 2 * $maxAllocatedMemory) {
                 // We remove the files already inserted in the zip
                 $this->filelist = array_slice($this->filelist, $k);
                 // We save the content on the disk
                 $r = @file_put_contents($splitfilename . ".tmp", serialize(array($nbentry, $nbfolder, $pathToReturn, $disk_number, $this->filelist, $files_not_included_due_to_filesize)));
                 if ($r === FALSE) {
                     SLFramework_Debug::log(get_class(), "The serialized information cannot be written in " . $splitfilename . ".tmp", 2);
                     if (!SLFramework_Utils::rm_rec($path . "/zip_in_progress")) {
                         SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress cannot be deleted", 2);
                         return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . "/zip_in_progress</code>"));
                     }
                     return array('finished' => false, "error" => sprintf(__('The file %s cannot be modified/created. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $splitfilename . ".tmp</code>"));
                 } else {
                     SLFramework_Debug::log(get_class(), "The serialized information has been written successfully in " . $splitfilename . ".tmp", 4);
                 }
                 // we inform that the process is finished
                 if (!SLFramework_Utils::rm_rec($path . "/zip_in_progress")) {
                     SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress cannot be deleted", 2);
                     return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . "/zip_in_progress</code>"));
                 }
                 SLFramework_Debug::log(get_class(), "The Zip process is delayed due to memory allocation limitation (" . $nbentry . "/" . (count($this->filelist) + $nbentry) . " files)", 4);
                 return array('finished' => false, 'nb_to_finished' => count($this->filelist), 'nb_finished' => $nbentry, 'not_included' => $files_not_included_due_to_filesize);
             }
         }
         //  Check if the file to be inserted in the zip file still exists
         //----------------------------------------------
         if (!is_file($filename)) {
             SLFramework_Debug::log(get_class(), "The file " . $filename . " does not exists and is ignored", 3);
             continue;
         }
         // Check the length of the file
         clearstatcache();
         if (@filesize($filename) > $maxAllocatedMemory) {
             SLFramework_Debug::log(get_class(), "The file " . $filename . " is too big (i.e. " . @filesize($filename) . ") and is then ignored", 3);
             $files_not_included_due_to_filesize[] = $filename;
             continue;
         } else {
             $this->allocatedSize += @filesize($filename);
         }
         //  Compress
         //----------------------------------------------
         $nbentry++;
         //Get the data
         $filedata = @file_get_contents($filename);
         if ($filedata === FALSE) {
             SLFramework_Debug::log(get_class(), "The file " . $filename . " can not be read", 2);
             if (!SLFramework_Utils::rm_rec($path . "/zip_in_progress")) {
                 SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress can not be deleted", 2);
                 return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . "/zip_in_progress</code>"));
             }
             return array('finished' => false, "error" => sprintf(__('The file %s cannot be read. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $filename . "</code>"));
         } else {
             SLFramework_Debug::log(get_class(), "The content of the file " . $filename . " has been read", 5);
         }
         //Compressing data
         $c_data = @gzcompress($filedata);
         if ($c_data === FALSE) {
             SLFramework_Debug::log(get_class(), "The content of the file " . $filename . " can not be compressed", 2);
             if (!SLFramework_Utils::rm_rec($path . "/zip_in_progress")) {
                 SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress can not be deleted", 2);
                 return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . "/zip_in_progress</code>"));
             }
             return array('finished' => false, "error" => sprintf(__('The file %s cannot be compressed.', 'SL_framework'), "<code>" . $filename . "</code>"));
         } else {
             SLFramework_Debug::log(get_class(), "The content of the file " . $filename . " has been compressed", 5);
         }
         $compressed_filedata = substr(substr($c_data, 0, strlen($c_data) - 4), 2);
         // fix crc bug
         // Get the time
         clearstatcache();
         $filetime = @filectime($filename);
         if ($filetime == 0) {
             $timearray = getdate();
         } else {
             $timearray = getdate($filetime);
         }
         if ($timearray['year'] < 1980) {
             $timearray['year'] = 1980;
             $timearray['mon'] = 1;
             $timearray['mday'] = 1;
             $timearray['hours'] = 0;
             $timearray['minutes'] = 0;
             $timearray['seconds'] = 0;
         }
         $dostime = $timearray['year'] - 1980 << 25 | $timearray['mon'] << 21 | $timearray['mday'] << 16 | $timearray['hours'] << 11 | $timearray['minutes'] << 5 | $timearray['seconds'] >> 1;
         $dtime = dechex($dostime);
         $hexdtime = '\\x' . $dtime[6] . $dtime[7] . '\\x' . $dtime[4] . $dtime[5];
         $hexddate = '\\x' . $dtime[2] . $dtime[3] . '\\x' . $dtime[0] . $dtime[1];
         eval('$hexdtime = "' . $hexdtime . '";');
         eval('$hexddate = "' . $hexddate . '";');
         $last_mod_file_time = $hexdtime;
         $last_mod_file_date = $hexddate;
         //Set Local File Header
         $newfilename = str_replace("//", "/", $add_t . str_replace(str_replace("\\", "/", $remove_t), "", str_replace("\\", "/", $filename)));
         if (substr($newfilename, 0, 1) == "/") {
             $newfilename = substr($newfilename, 1);
         }
         /*
          A.  Local file header:
         	local file header signature     4 bytes  (0x04034b50)
         	version needed to extract       2 bytes
         	general purpose bit flag        2 bytes
         	compression method              2 bytes
         	last mod file time              2 bytes
         	last mod file date              2 bytes
         	crc-32                          4 bytes
         	compressed size                 4 bytes
         	uncompressed size               4 bytes
         	file name length                2 bytes
         	extra field length              2 bytes
         	file name 						(variable size)
         	extra field 					(variable size)
         */
         $newfilename = SLFramework_Utils::convertUTF8($newfilename);
         $local_file_header = "PK";
         // 4 bytes  (0x04034b50) local_file_header_signature
         $local_file_header .= "";
         // 2 bytes version_needed_to_extract
         $local_file_header .= "";
         // 2 bytes general_purpose_bit_flag (we say that the name should be encode in UTF8)
         $local_file_header .= "";
         // 2 bytes compression_method
         $local_file_header .= $last_mod_file_time;
         // 2 bytes last mod file time
         $local_file_header .= $last_mod_file_date;
         // 2 bytes last mod file time
         $local_file_header .= pack('V', crc32($filedata));
         // 4 bytes crc_32
         $local_file_header .= pack('V', strlen($compressed_filedata));
         // 4 bytes compressed_size
         $local_file_header .= pack('V', strlen($filedata));
         // 4 bytes uncompressed_size
         $local_file_header .= pack('v', strlen($newfilename));
         // 2 bytes filename_length
         $local_file_header .= pack('v', 0);
         // 2 bytes extra_field_length
         $local_file_header .= $newfilename;
         // variable size filename
         $local_file_header .= "";
         // variable size extra fields
         // We add the local header in the zip files
         clearstatcache();
         if (strlen($local_file_header) + @filesize($path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number)) <= $chunk_size) {
             // We get the index of the file
             $relative_offset_in_disk = @filesize($path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number));
             $r = @file_put_contents($path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), $local_file_header, FILE_APPEND);
             if ($r === FALSE) {
                 SLFramework_Debug::log(get_class(), "The local file header of the file cannot be been added to " . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), 2);
                 if (!SLFramework_Utils::rm_rec($path . "/zip_in_progress")) {
                     SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress can not be deleted", 2);
                     return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . "/zip_in_progress</code>"));
                 }
                 return array('finished' => false, "error" => sprintf(__('The file %s cannot be modified/created. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number) . "</code>"));
             } else {
                 SLFramework_Debug::log(get_class(), "The local file header of the file has been added to " . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), 5);
             }
             // If the local header will be split, we create a new disk
         } else {
             $disk_number++;
             // We get the index of the file
             $relative_offset_in_disk = 0;
             $pathToReturn[time() . " " . sprintf("%02d", $disk_number)] = $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number);
             $r = @file_put_contents($path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), $local_file_header);
             if ($r === FALSE) {
                 SLFramework_Debug::log(get_class(), "The local file header of the file cannot be been added to " . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), 2);
                 if (!SLFramework_Utils::rm_rec($path . "/zip_in_progress")) {
                     SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress can not be deleted", 2);
                     return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . "/zip_in_progress</code>"));
                 }
                 return array('finished' => false, "error" => sprintf(__('The file %s cannot be modified/created. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number) . "</code>"));
             } else {
                 SLFramework_Debug::log(get_class(), "The local file header of the file has been been added to " . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), 5);
             }
         }
         $disk_number_of_local_header = $disk_number;
         /* 
          B.  File data
         	  Immediately following the local header for a file
         	  is the compressed or stored data for the file. 
         	  The series of [local file header][file data]
         	  repeats for each file in the .ZIP archive. 
         */
         // We add the compressed file in the zip files
         clearstatcache();
         if (strlen($compressed_filedata) + @filesize($path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number)) <= $chunk_size) {
             $r = @file_put_contents($path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), $compressed_filedata, FILE_APPEND);
             if ($r === FALSE) {
                 SLFramework_Debug::log(get_class(), "The compressed content of the file cannot be been added to " . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), 2);
                 if (!SLFramework_Utils::rm_rec($path . "/zip_in_progress")) {
                     SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress can not be deleted", 2);
                     return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . "/zip_in_progress</code>"));
                 }
                 return array('finished' => false, "error" => sprintf(__('The file %s cannot be modified/created. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number) . "</code>"));
             } else {
                 SLFramework_Debug::log(get_class(), "The compressed content of the file has been been added to " . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), 5);
             }
             // If the compressed file will be split, we create a new disk
         } else {
             clearstatcache();
             $part1 = substr($compressed_filedata, 0, $chunk_size - @filesize($path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number)));
             $part2 = substr($compressed_filedata, $chunk_size - @filesize($path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number)));
             $r = @file_put_contents($path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), $part1, FILE_APPEND);
             if ($r === FALSE) {
                 SLFramework_Debug::log(get_class(), "The first part of the compressed content of the file cannot be added to " . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), 2);
                 if (!SLFramework_Utils::rm_rec($path . "/zip_in_progress")) {
                     SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress can not be deleted", 2);
                     return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . "/zip_in_progress</code>"));
                 }
                 return array('finished' => false, "error" => sprintf(__('The file %s cannot be modified/created. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number) . "</code>"));
             } else {
                 SLFramework_Debug::log(get_class(), "The first part of the compressed content of the file has been added to " . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), 5);
             }
             $disk_number++;
             $pathToReturn[time() . " " . sprintf("%02d", $disk_number)] = $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number);
             $r = @file_put_contents($path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), $part2);
             if ($r === FALSE) {
                 SLFramework_Debug::log(get_class(), "The second part of the compressed content of the file cannot be added to " . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), 2);
                 if (!SLFramework_Utils::rm_rec($path . "/zip_in_progress")) {
                     SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress can not be deleted", 2);
                     return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . "/zip_in_progress</code>"));
                 }
                 return array('finished' => false, "error" => sprintf(__('The file %s cannot be modified/created. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number) . "</code>"));
             } else {
                 SLFramework_Debug::log(get_class(), "The second part of the compressed content of the file has been added to " . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), 5);
             }
         }
         /*
         				  F.  Central directory structure:
         					  [file header 1]
         					  ...
         					  [file header n]
         				
         					 File header:
         						central file header signature   4 bytes  (0x02014b50)
         						version made by                 2 bytes
         						version needed to extract       2 bytes
         						general purpose bit flag        2 bytes
         						compression method              2 bytes
         						last mod file time              2 bytes
         						last mod file date              2 bytes
         						crc-32                          4 bytes
         						compressed size                 4 bytes
         						uncompressed size               4 bytes
         						file name length                2 bytes
         						extra field length              2 bytes
         						file comment length             2 bytes
         						disk number start               2 bytes
         						internal file attributes        2 bytes
         						external file attributes        4 bytes
         						relative offset of local header 4 bytes
         						file name 						(variable size)
         						extra field 					(variable size)
         						file comment 					(variable size)
         */
         //Set central File Header
         $central_file_header = "PK";
         // 4 bytes (0x02014b50) central file header signature
         $central_file_header .= "";
         // 2 bytes version made by (0 = MS-DOS and OS/2 compatible)
         $central_file_header .= "";
         // 2 bytes version needed to extract
         $central_file_header .= "";
         // 2 bytes general_purpose_bit_flag (we say that the name should be encode in UTF8)
         $central_file_header .= "";
         // 2 bytes compression_method
         $central_file_header .= $last_mod_file_time;
         // 2 bytes last mod file time
         $central_file_header .= $last_mod_file_date;
         // 2 bytes last mod file time
         $central_file_header .= pack('V', crc32($filedata));
         // 4 bytes crc_32
         $central_file_header .= pack('V', strlen($compressed_filedata));
         // 4 bytes compressed_size
         $central_file_header .= pack('V', strlen($filedata));
         // 4 bytes uncompressed_size
         $central_file_header .= pack('v', strlen($newfilename));
         // 2 bytes filename_length
         $central_file_header .= pack('v', 0);
         // 2 bytes extra_field_length
         $central_file_header .= pack('v', 0);
         // 2 bytes  comment length
         $central_file_header .= pack('v', $disk_number_of_local_header - 1);
         // 2 bytes disk number start
         $central_file_header .= pack('v', 0);
         // 2 bytes internal file attribute
         $central_file_header .= pack('V', 32);
         // 4 bytes external file attribute
         $central_file_header .= pack('V', $relative_offset_in_disk);
         // 4 bytes relative offset of local header
         $central_file_header .= $newfilename;
         // variable size filename
         $central_file_header .= "";
         // variable size extra fields
         $central_file_header .= "";
         // variable size file comment
         $r = @file_put_contents($splitfilename . ".centraldirectory.tmp", $central_file_header, FILE_APPEND);
         if ($r === FALSE) {
             SLFramework_Debug::log(get_class(), "The central header cannot been added to " . $splitfilename . ".centraldirectory.tmp", 2);
             if (!SLFramework_Utils::rm_rec($path . "/zip_in_progress")) {
                 SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress can not be deleted", 2);
                 return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . "/zip_in_progress</code>"));
             }
             return array('finished' => false, "error" => sprintf(__('The file %s cannot be modified/created. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $splitfilename . ".centraldirectory.tmp</code>"));
         } else {
             SLFramework_Debug::log(get_class(), "The central header  has been added to " . $splitfilename . ".centraldirectory.tmp", 5);
         }
     }
     //  Finalization
     //----------------------------------------------
     /*
      I.  End of central directory record:
     	end of central dir signature    												4 bytes  (0x06054b50)
     	number of this disk            		 											2 bytes
     	number of the disk with the start of the central directory  					2 bytes
     	total number of entries in the central directory on this disk  					2 bytes
     	total number of entries in the central directory           						2 bytes
     	size of the central directory  					 								4 bytes
     	offset of start of central directory with respect to the starting disk number   4 bytes
     	.ZIP file comment length        												2 bytes
     	.ZIP file comment       														(variable size)
     */
     // We finalize
     clearstatcache();
     $end_central_dir_record = "PK";
     // 4 bytes  (0x06054b50)
     $end_central_dir_record .= pack('v', $disk_number - 1);
     // 2 bytes number of this disk
     $end_central_dir_record .= pack('v', $disk_number - 1);
     // 2 bytes number of the disk with the start of the central directory
     $end_central_dir_record .= pack('v', $nbentry + $nbfolder);
     // 2 bytes total number of entries in the central directory on this disk
     $end_central_dir_record .= pack('v', $nbentry + $nbfolder);
     // 2 bytes total number of entries in the central directory
     $end_central_dir_record .= pack('V', @filesize($splitfilename . ".centraldirectory.tmp"));
     // 4 bytes size of the central directory
     $end_central_dir_record .= pack('V', @filesize($path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number)));
     // 4 bytes offset of start of central directory with respect to the starting disk number
     $end_central_dir_record .= pack('v', strlen($zipfile_comment));
     // 2 bytes .ZIP file comment length
     $end_central_dir_record .= $zipfile_comment;
     // variable size .ZIP file comment
     // We complete the data segments file
     $r = @file_put_contents($splitfilename . ".centraldirectory.tmp", $end_central_dir_record, FILE_APPEND);
     if ($r === FALSE) {
         SLFramework_Debug::log(get_class(), "The end of the central header cannot been added to " . $splitfilename . ".centraldirectory.tmp", 2);
         if (!SLFramework_Utils::rm_rec($path . "/zip_in_progress")) {
             SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress can not be deleted", 2);
             return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . "/zip_in_progress</code>"));
         }
         return array('finished' => false, "error" => sprintf(__('The file %s cannot be modified/created. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $splitfilename . ".centraldirectory.tmp" . "</code>"));
     } else {
         SLFramework_Debug::log(get_class(), "The end of the central header has been added to " . $splitfilename . ".centraldirectory.tmp", 4);
     }
     // We copy the content of the central directory into the last file
     // TODO boucler sur des petits morceaux pour eviter une saturation mémoire
     // TODO ne pas depasser la taille max (sans pour autant couper une entrée)
     $r = @file_put_contents($path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), @file_get_contents($splitfilename . ".centraldirectory.tmp"), FILE_APPEND);
     if ($r === FALSE) {
         SLFramework_Debug::log(get_class(), "The content of the file " . $splitfilename . ".centraldirectory.tmp cannot be copied into " . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), 2);
         if (!SLFramework_Utils::rm_rec($path . "/zip_in_progress")) {
             SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress can not be deleted", 2);
             return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . "/zip_in_progress</code>"));
         }
         return array('finished' => false, "error" => sprintf(__('The file %s cannot be modified/created. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $splitfilename . ".centraldirectory.tmp</code>"));
     } else {
         SLFramework_Debug::log(get_class(), "The content of the file " . $splitfilename . ".centraldirectory.tmp has been copied into " . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), 4);
     }
     // rename the last file
     $r = @rename($path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number), $splitfilename);
     if ($r === FALSE) {
         SLFramework_Debug::log(get_class(), "The file " . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number) . " cannot be renamed into " . $splitfilename, 2);
         if (!SLFramework_Utils::rm_rec($path . "/zip_in_progress")) {
             SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress can not be deleted", 2);
             return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . "/zip_in_progress</code>"));
         }
         return array('finished' => false, "error" => sprintf(__('The file %s cannot be renamed. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number) . "</code>"));
     } else {
         SLFramework_Debug::log(get_class(), "The file " . $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number) . " has been renamed into " . $splitfilename, 4);
     }
     $pathToReturn[time() . " " . sprintf("%02d", $disk_number)] = $splitfilename;
     $newpathToReturn = array();
     // Remove from the above list the last file (because it has just been renamed)
     foreach ($pathToReturn as $k => $f) {
         if ($f != $path . basename($splitfilename, ".zip") . ".z" . sprintf("%02d", $disk_number)) {
             $newpathToReturn[$k] = $f;
         }
     }
     $pathToReturn = $newpathToReturn;
     // delete the  temp file
     if (!SLFramework_Utils::rm_rec($splitfilename . ".centraldirectory.tmp")) {
         SLFramework_Debug::log(get_class(), "The file " . $splitfilename . ".centraldirectory.tmp cannot be deleted", 2);
         if (!SLFramework_Utils::rm_rec($path . "/zip_in_progress")) {
             SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress can not be deleted", 2);
             return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . "/zip_in_progress</code>"));
         }
         return array('finished' => false, "error" => sprintf(__('The file %s cannot be renamed. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $splitfilename . ".centraldirectory.tmp" . "</code>"));
     } else {
         SLFramework_Debug::log(get_class(), "The file " . $splitfilename . ".centraldirectory.tmp has been deleted", 4);
     }
     if (!SLFramework_Utils::rm_rec($splitfilename . ".tmp")) {
         SLFramework_Debug::log(get_class(), "The file " . $splitfilename . ".tmp cannot be deleted", 2);
         if (!SLFramework_Utils::rm_rec($path . "/zip_in_progress")) {
             SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress can not be deleted", 2);
             return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $path . "/zip_in_progress</code>"));
         }
         return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . $splitfilename . ".tmp</code>"));
     } else {
         SLFramework_Debug::log(get_class(), "The file " . $splitfilename . ".tmp has been deleted", 4);
     }
     // we inform that the process is finished
     if (!SLFramework_Utils::rm_rec(dirname($splitfilename) . "/zip_in_progress")) {
         SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress can not be deleted", 2);
         return array("step" => "error", "error" => sprintf(__('The file %s cannot be deleted. You should have a problem with file permissions or security restrictions.', 'SL_framework'), "<code>" . dirname($splitfilename) . "/zip_in_progress</code>"));
     } else {
         SLFramework_Debug::log(get_class(), "The file " . $path . "/zip_in_progress has been deleted", 2);
     }
     SLFramework_Debug::log(get_class(), "The ZIP process has ended by compressing " . $nbentry . " files and ignoring " . count($files_not_included_due_to_filesize) . " files due to filesize limitations", 4);
     return array('finished' => true, 'nb_finished' => $nbentry, 'nb_to_finished' => 0, 'not_included' => $files_not_included_due_to_filesize, 'nb_files' => $nbentry, 'path' => $pathToReturn);
 }
Exemple #9
0
    /** ====================================================================================================================================================
     * The admin configuration page
     * This function will be called when you select the plugin in the admin backend 
     *
     * @return void
     */
    public function configuration_page()
    {
        global $wpdb;
        global $blog_id;
        SLFramework_Debug::log(get_class(), "Print the configuration page.", 4);
        ?>
		<div class="plugin-titleSL">
			<h2><?php 
        echo $this->pluginName;
        ?>
</h2>
		</div>
		
		<div class="plugin-contentSL">		
			<?php 
        echo $this->signature;
        ?>

			<?php 
        //===============================================================================================
        // After this comment, you may modify whatever you want
        // We check rights
        $this->check_folder_rights(array(array(WP_CONTENT_DIR . "/sedlex/test/", "rwx")));
        $tabs = new SLFramework_Tabs();
        ob_start();
        echo "<p>" . __("In this tab, you could re-order the page hierarchy by 'drag-and-dropping' page entries.", $this->pluginID) . "</p>";
        $args = array('sort_order' => 'ASC', 'sort_column' => 'menu_order,post_title', 'parent' => 0, 'child_of' => 0, 'offset' => 0, 'post_type' => 'page', 'post_status' => 'publish,draft,pending,future');
        SLFramework_Treelist::render($this->create_hierarchy_pages(get_pages($args)), true, 'savePageHierarchy', 'page_hiera');
        $tabs->add_tab(__('Order Pages', $this->pluginID), ob_get_clean());
        // HOW To
        ob_start();
        echo "<p>" . __('With this plugin you may order your pages into hierarchical tree and display the tree in them.', $this->pluginID) . "</p>";
        echo "<p>" . sprintf(__("To display the tree please add %s in your page.", $this->pluginID), "<code>[page_tree]</code>") . "</p>";
        $howto1 = new SLFramework_Box(__("Purpose of that plugin", $this->pluginID), ob_get_clean());
        ob_start();
        echo "<p>" . __('Just drag and drop each entry.', $this->pluginID) . "</p>";
        $howto2 = new SLFramework_Box(__("How to order the page", $this->pluginID), ob_get_clean());
        ob_start();
        echo $howto1->flush();
        echo $howto2->flush();
        $tabs->add_tab(__('How To', $this->pluginID), ob_get_clean(), plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_how.png");
        ob_start();
        $params = new SLFramework_Parameters($this, "tab-parameters");
        $params->add_title(__("Tree view style (i.e. [page_tree] shortcode)", $this->pluginID));
        $params->add_param('current_style', __("Set the style of current page in tree:", $this->pluginID));
        $params->add_param('parent_style', __("Set the style of parent pages in tree:", $this->pluginID));
        $params->add_param('child_style', __("Set the style of child pages in tree:", $this->pluginID));
        $params->add_param('other_style', __("Set the style of other pages in tree:", $this->pluginID));
        $params->add_title(__("Breadcrumb style (i.e. [page_parents] shortcode)", $this->pluginID));
        $params->add_param('breadcrumb_all', __("Set the style of the breadcrumb:", $this->pluginID));
        $params->add_param('breadcrumb_item', __("Set the style of items of the breadcrumb:", $this->pluginID));
        $params->add_title(__("Order for editor", $this->pluginID));
        $params->add_param('show_order_in_page_edit', __("Show the order page for the editors users (menu under the page menu):", $this->pluginID));
        $params->flush();
        $tabs->add_tab(__('Parameters', $this->pluginID), ob_get_clean(), plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_param.png");
        $frmk = new coreSLframework();
        if (is_multisite() && $blog_id == 1 || !is_multisite() || $frmk->get_param('global_allow_translation_by_blogs')) {
            ob_start();
            $plugin = str_replace("/", "", str_replace(basename(__FILE__), "", plugin_basename(__FILE__)));
            $trans = new SLFramework_Translation($this->pluginID, $plugin);
            $trans->enable_translation();
            $tabs->add_tab(__('Manage translations', $this->pluginID), ob_get_clean(), plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_trad.png");
        }
        ob_start();
        $plugin = str_replace("/", "", str_replace(basename(__FILE__), "", plugin_basename(__FILE__)));
        $trans = new SLFramework_Feedback($plugin, $this->pluginID);
        $trans->enable_feedback();
        $tabs->add_tab(__('Give feedback', $this->pluginID), ob_get_clean(), plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_mail.png");
        ob_start();
        // A liste of plugin slug to be excluded
        $exlude = array('wp-pirate-search');
        // Replace sedLex by your own author name
        $trans = new SLFramework_OtherPlugins("sedLex", $exlude);
        $trans->list_plugins();
        $tabs->add_tab(__('Other plugins', $this->pluginID), ob_get_clean(), plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_plug.png");
        echo $tabs->flush();
        // Before this comment, you may modify whatever you want
        //===============================================================================================
        ?>
			<?php 
        echo $this->signature;
        ?>
		</div>
		<?php 
    }