Exemple #1
0
function optimize()
{
    $sock = new sockets();
    $unix = new unix();
    $q = new mysql();
    $basename = basename(__FILE__);
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".MAIN.pid";
    $pid = @file_get_contents($pidfile);
    if ($unix->process_exists($pid, $basename)) {
        mysql_admin_events("Already running pid {$pid}, aborting", __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    $t = 0;
    if ($GLOBALS["VERBOSE"]) {
        echo "Start ok ->CheckTables() \n";
    }
    $q->BuildTables();
    $EnableMysqlOptimize = $sock->GET_INFO("EnableMysqlOptimize");
    if (!is_numeric($EnableMysqlOptimize)) {
        $EnableMysqlOptimize = 0;
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "EnableMysqlOptimize= {$EnableMysqlOptimize} \n";
    }
    if ($EnableMysqlOptimize == 0) {
        return;
    }
    $t1 = time();
    $ARRAY = unserialize(base64_decode($sock->GET_INFO("MysqlOptimizeDBS")));
    if ($GLOBALS["VERBOSE"]) {
        echo "MysqlOptimizeDBS= " . count($ARRAY) . " \n";
    }
    mysql_admin_events("Starting optimize " . count($ARRAY) . " databases ", __FUNCTION__, __FILE__, __LINE__, "defrag");
    $c = 0;
    while (list($database, $enabled) = each($ARRAY)) {
        if (!is_numeric($enabled)) {
            continue;
        }
        if ($enabled == 1) {
            $c++;
            optimize_tables($database);
        }
    }
    $time = $unix->distanceOfTimeInWords($t1, time(), true);
    mysql_admin_events("{$c} Database(s) checked {$time}", __FUNCTION__, __FILE__, __LINE__, "defrag");
}
Exemple #2
0
        }
    } else {
        $percent = 0;
    }
    if ($percent >= 0) {
        displayProgressBar(400, $percent);
    }
    if ($offset != -1) {
        if (restoreMySqlDump($DB, $path . "/" . $_GET["file"], $duree)) {
            echo "<div class='center'><a href=\"backup.php?file=" . $_GET["file"] . "&amp;duree={$duree}&amp;offset=" . "{$offset}&amp;cpt={$cpt}&amp;donotcheckversion=1\">" . $LANG['backup'][24] . "</a>";
            echo "<script language='javascript' type='text/javascript'>window.location=\"backup.php?file=" . $_GET["file"] . "&duree={$duree}&offset={$offset}&cpt={$cpt}&donotcheckversion=1\";</script></div>";
            glpi_flush();
            exit;
        }
    } else {
        optimize_tables(NULL, true);
        // Compatiblity for old version for utf8 complete conversion
        $cnf = new Config();
        $input['id'] = 1;
        $input['utf8_conv'] = 1;
        $cnf->update($input);
    }
}
if (isset($_GET["delfile"]) && $_GET["delfile"] != "") {
    $filename = $_GET["delfile"];
    if (is_file($path . "/" . $_GET["delfile"])) {
        unlink($path . "/" . $_GET["delfile"]);
        echo "<div class ='center'>" . $filename . " " . $LANG['common'][28] . "</div>";
    }
}
if (haveRight("check_update", "r")) {
<input type="submit" name="cancel" value="No">&nbsp;&nbsp;&nbsp;<input type="submit" name="conf" value="Yes">
<?php 
    echo _hs;
    ?>
</form>
<?php 
    require $WWW_ROOT_DISK . 'adm/admclose.php';
    exit;
}
if ($FUD_OPT_1 & 1) {
    draw_stat('Disabling the forum for the duration of maintenance run');
    maintenance_status('Undergoing maintenance, please come back later.', 1);
}
if (isset($_GET['opt'])) {
    draw_stat('Optimizing forum\'s SQL tables');
    optimize_tables();
    draw_stat('Done: Optimizing forum\'s SQL tables');
    if ($FUD_OPT_1 & 1 || isset($_GET['enable_forum'])) {
        draw_stat('Re-enabling the forum.');
        maintenance_status($DISABLED_REASON, 0);
    } else {
        echo '<font size="+1" color="red">Your forum is currently disabled, to re-enable it go to the <a href="admglobal.php?' . _rsid . '">Global Settings Manager</a> and re-enable it.</font><br>';
    }
    require $WWW_ROOT_DISK . 'adm/admclose.php';
    exit;
}
?>
<script language="Javascript1.2">
	var intervalID;
	function scrolldown()
	{
 /**
  * Clean log cron function
  *
  * @param $task for log
  *
  **/
 static function cronOptimize($task)
 {
     $nb = optimize_tables(NULL, true);
     $task->setVolume($nb);
     return 1;
 }
Exemple #5
0
function updateDbUpTo031()
{
    global $DB, $LANG, $migration;
    $ret = array();
    // Before 0.31
    if (!TableExists("glpi_config") && !TableExists("glpi_configs")) {
        $query = "CREATE TABLE `glpi_config` (\n                  `ID` int(11) NOT NULL auto_increment,\n                  `num_of_events` varchar(200) NOT NULL default '',\n                  `jobs_at_login` varchar(200) NOT NULL default '',\n                  `sendexpire` varchar(200) NOT NULL default '',\n                  `cut` varchar(200) NOT NULL default '',\n                  `expire_events` varchar(200) NOT NULL default '',\n                  `list_limit` varchar(200) NOT NULL default '',\n                  `version` varchar(200) NOT NULL default '',\n                  `logotxt` varchar(200) NOT NULL default '',\n                  `root_doc` varchar(200) NOT NULL default '',\n                  `event_loglevel` varchar(200) NOT NULL default '',\n                  `mailing` varchar(200) NOT NULL default '',\n                  `imap_auth_server` varchar(200) NOT NULL default '',\n                  `imap_host` varchar(200) NOT NULL default '',\n                  `ldap_host` varchar(200) NOT NULL default '',\n                  `ldap_basedn` varchar(200) NOT NULL default '',\n                  `ldap_rootdn` varchar(200) NOT NULL default '',\n                  `ldap_pass` varchar(200) NOT NULL default '',\n                  `admin_email` varchar(200) NOT NULL default '',\n                  `mailing_signature` varchar(200) NOT NULL default '',\n                  `mailing_new_admin` varchar(200) NOT NULL default '',\n                  `mailing_followup_admin` varchar(200) NOT NULL default '',\n                  `mailing_finish_admin` varchar(200) NOT NULL default '',\n                  `mailing_new_all_admin` varchar(200) NOT NULL default '',\n                  `mailing_followup_all_admin` varchar(200) NOT NULL default '',\n                  `mailing_finish_all_admin` varchar(200) NOT NULL default '',\n                  `mailing_new_all_normal` varchar(200) NOT NULL default '',\n                  `mailing_followup_all_normal` varchar(200) NOT NULL default '',\n                  `mailing_finish_all_normal` varchar(200) NOT NULL default '',\n                  `mailing_new_attrib` varchar(200) NOT NULL default '',\n                  `mailing_followup_attrib` varchar(200) NOT NULL default '',\n                  `mailing_finish_attrib` varchar(200) NOT NULL default '',\n                  `mailing_new_user` varchar(200) NOT NULL default '',\n                  `mailing_followup_user` varchar(200) NOT NULL default '',\n                  `mailing_finish_user` varchar(200) NOT NULL default '',\n                  `ldap_field_name` varchar(200) NOT NULL default '',\n                  `ldap_field_email` varchar(200) NOT NULL default '',\n                  `ldap_field_location` varchar(200) NOT NULL default '',\n                  `ldap_field_realname` varchar(200) NOT NULL default '',\n                  `ldap_field_phone` varchar(200) NOT NULL default '',\n                PRIMARY KEY (`ID`)\n                ) TYPE=MyISAM AUTO_INCREMENT=2 ";
        $DB->query($query) or die($LANG['update'][90] . $DB->error());
        $query = "INSERT INTO `glpi_config`\n                VALUES (1, '10', '1', '1', '80', '30', '15', ' 0.31', 'GLPI powered by indepnet',\n                        '/glpi', '5', '0', '', '', '', '', '', '', '*****@*****.**', 'SIGNATURE',\n                        '1', '1', '1', '1', '0', '0', '0', '0', '0', '0', '0', '0','1', '1', '1',\n                        'uid', 'mail', 'physicaldeliveryofficename', 'cn', 'telephonenumber')";
        $DB->query($query) or die($LANG['update'][90] . $DB->error());
        echo "<p class='center'>Version > 0.31  </p>";
    }
    // < 0.78
    if (TableExists("glpi_config")) {
        // Get current version
        $query = "SELECT `version`\n                FROM `glpi_config`";
    } else {
        // >= 0.78
        // Get current version
        $query = "SELECT `version`\n                FROM `glpi_configs`";
    }
    $result = $DB->query($query) or die("get current version" . $DB->error());
    $current_version = trim($DB->result($result, 0, 0));
    // Save if problem with session during update
    $glpilanguage = $_SESSION["glpilanguage"];
    // To prevent problem of execution time
    ini_set("max_execution_time", "0");
    $migration = new Migration($current_version);
    switch ($current_version) {
        case "0.31":
            include "update_031_04.php";
            update031to04();
        case "0.4":
        case "0.41":
            include "update_04_042.php";
            update04to042();
        case "0.42":
            showLocationUpdateForm();
            include "update_042_05.php";
            update042to05();
        case "0.5":
            include "update_05_051.php";
            update05to051();
        case "0.51":
        case "0.51a":
            include "update_051_06.php";
            update051to06();
        case "0.6":
            include "update_06_065.php";
            update06to065();
        case "0.65":
            include "update_065_068.php";
            update065to068();
        case "0.68":
            include "update_068_0681.php";
            update068to0681();
        case "0.68.1":
        case "0.68.2":
        case "0.68.3":
            // Force update content
            if (showLocationUpdateForm()) {
                $query = "UPDATE `glpi_config`\n                      SET `version` = ' 0.68.3x'";
                $DB->query($query) or die("0.68.3 " . $LANG['update'][90] . $DB->error());
                showContentUpdateForm();
                exit;
            }
        case "0.68.3x":
            // Special version for replay upgrade process from here
            include "update_0681_07.php";
            update0681to07();
        case "0.7":
        case "0.70.1":
        case "0.70.2":
            include "update_07_071.php";
            update07to071();
        case "0.71":
        case "0.71.1":
            include "update_071_0712.php";
            update071to0712();
        case "0.71.2":
            include "update_0712_0713.php";
            update0712to0713();
        case "0.71.3":
        case "0.71.4":
        case "0.71.5":
        case "0.71.6":
            include "update_0713_072.php";
            update0713to072();
        case "0.72":
            include "update_072_0721.php";
            update072to0721();
        case "0.72.1":
            include "update_0721_0722.php";
            update0721to0722();
        case "0.72.2":
        case "0.72.21":
            include "update_0722_0723.php";
            update0722to0723();
        case "0.72.3":
        case "0.72.4":
            include "update_0723_078.php";
            update0723to078();
        case "0.78":
            include "update_078_0781.php";
            update078to0781();
        case "0.78.1":
            include "update_0781_0782.php";
            update0781to0782();
        case "0.78.2":
        case "0.78.3":
        case "0.78.4":
        case "0.78.5":
            include "update_0782_080.php";
            update0782to080();
        case "0.80":
            include "update_080_0801.php";
            update080to0801();
        case "0.80.1":
        case "0.80.2":
            break;
        default:
            include "update_031_04.php";
            update031to04();
            include "update_04_042.php";
            update04to042();
            showLocationUpdateForm();
            include "update_042_05.php";
            update042to05();
            include "update_05_051.php";
            update05to051();
            include "update_051_06.php";
            update051to06();
            include "update_06_065.php";
            update06to065();
            include "update_065_068.php";
            update065to068();
            include "update_068_0681.php";
            update068to0681();
            // Force update content
            $query = "UPDATE `glpi_config`\n                   SET `version` = ' 0.68.3x'";
            $DB->query($query) or die("0.68.3 " . $LANG['update'][90] . $DB->error());
            showContentUpdateForm();
            exit;
    }
    // Update version number and default langage and new version_founded ---- LEAVE AT THE END
    $query = "UPDATE `glpi_configs`\n             SET `version` = ' 0.80.2',\n                 `language` = '" . $glpilanguage . "',\n                 `founded_new_version` = '' ;";
    $DB->query($query) or die("0.80 " . $LANG['update'][90] . $DB->error());
    // Update process desactivate all plugins
    $plugin = new Plugin();
    $plugin->unactivateAll();
    echo "<h3>" . $LANG['update'][139] . "</h3>";
    optimize_tables($migration);
    return $ret;
}