Ejemplo n.º 1
0
 /**
  * Additional message in global message
  *
  * @param $msg text to display
  **/
 function displayMessage($msg)
 {
     global $LANG;
     $fin = time();
     $tps = timestampToString($fin - $this->deb);
     echo "<script type='text/javascript'>document.getElementById('migration_message_" . $this->version . "').innerHTML=\"<p class='center'>{$msg} ({$tps})</p>\";</script>\n";
     glpi_flush();
 }
Ejemplo n.º 2
0
/**
 * Change the Progress Bar Position
 *
 * @param $crt Current Value (less then $max)
 * @param $tot Maximum Value
 * @param $msg message inside the bar (defaut is %)
 *
 * @return nothing
 **/
function changeProgressBarPosition($crt, $tot, $msg = "")
{
    if (!$tot) {
        $pct = 0;
    } else {
        if ($crt > $tot) {
            $pct = 1;
        } else {
            $pct = $crt / $tot;
        }
    }
    echo "<script type='text/javascript'>glpi_progressbar.updateProgress(\"{$pct}\",\"{$msg}\");</script>\n";
    glpi_flush();
}
Ejemplo n.º 3
0
    $query = "SELECT `utf8_conv`\n             FROM `{$config_table}`\n             WHERE `id` = '1'";
    $result = $DB->query($query);
    $data = $DB->fetch_assoc($result);
    if ($data["utf8_conv"]) {
        $complete_utf8 = false;
    }
}
if ($offsettable >= 0 && $complete_utf8) {
    if ($percent >= 0) {
        displayProgressBar(400, $percent);
        echo "<div class='bas'></div></div></div></body></html>";
        glpi_flush();
    }
    if (UpdateContent($DB, $duree, $rowlimit, $conv_utf8, $complete_utf8)) {
        echo "<br><a href='update_content.php?dump=1&amp;duree={$duree}&amp;rowlimit=" . "{$rowlimit}&amp;offsetrow={$offsetrow}&amp;offsettable={$offsettable}&amp;cpt={$cpt}'>" . $LANG['backup'][24] . "</a>";
        echo "<script language='javascript' type='text/javascript'>\n             window.location=\"update_content.php?dump=1&duree={$duree}&rowlimit={$rowlimit}&offsetrow=" . "{$offsetrow}&offsettable={$offsettable}&cpt={$cpt}\";</script>";
        glpi_flush();
        exit;
    }
} else {
    echo "<p class='submit'><a href='../index.php'>\n         <span class='button'>" . $LANG['install'][64] . "</span></a></p>";
    echo "<div class='bas'></div></div></div></body></html>";
}
if ($conv_utf8) {
    $query = "ALTER TABLE `{$config_table}`\n             ADD `utf8_conv` INT( 11 ) DEFAULT '0' NOT NULL";
    $DB->query($query) or die(" 0.6 add utf8_conv to {$config_table} " . $LANG['update'][90] . $DB->error());
}
if ($complete_utf8) {
    $DB->query("ALTER DATABASE `" . $DB->dbdefault . "` DEFAULT\n               CHARACTER SET utf8 COLLATE utf8_unicode_ci");
    $DB->query("UPDATE `{$config_table}`\n               SET `utf8_conv` = '1'\n               WHERE `id` = '1'");
}
Ejemplo n.º 4
0
/**  Restore a mysql dump
 *
 * @param $DB DB object
 * @param $dumpFile dump file
 * @param $duree max delay before refresh
**/
function restoreMySqlDump($DB, $dumpFile, $duree)
{
    global $DB, $TPSCOUR, $offset, $cpt, $LANG;
    // $dumpFile, fichier source
    // $duree=timeout pour changement de page (-1 = aucun)
    // Desactivation pour empecher les addslashes au niveau de la creation des tables
    // En plus, au niveau du dump on considere qu'on est bon
    // set_magic_quotes_runtime(0);
    if (!file_exists($dumpFile)) {
        echo $LANG['document'][38] . "&nbsp;: {$dumpFile}<br>";
        return false;
    }
    $fileHandle = fopen($dumpFile, "rb");
    if (!$fileHandle) {
        echo $LANG['document'][45] . "&nbsp;: {$dumpFile}<br>";
        return false;
    }
    if ($offset != 0) {
        if (fseek($fileHandle, $offset, SEEK_SET) != 0) {
            //erreur
            echo $LANG['backup'][22] . " " . formatNumber($offset, false, 0) . "<br>";
            return false;
        }
        glpi_flush();
    }
    $formattedQuery = "";
    while (!feof($fileHandle)) {
        current_time();
        if ($duree > 0 && $TPSCOUR >= $duree) {
            //on atteint la fin du temps imparti
            return true;
        }
        // specify read length to be able to read long lines
        $buffer = fgets($fileHandle, 102400);
        // do not strip comments due to problems when # in begin of a data line
        $formattedQuery .= $buffer;
        if (get_magic_quotes_runtime()) {
            $formattedQuery = stripslashes($formattedQuery);
        }
        if (substr(rtrim($formattedQuery), -1) == ";") {
            // Do not use the $DB->query
            if ($DB->query($formattedQuery)) {
                //if no success continue to concatenate
                $offset = ftell($fileHandle);
                $formattedQuery = "";
                $cpt++;
            }
        }
    }
    if ($DB->error) {
        echo "<hr>" . $LANG['backup'][23] . " [{$formattedQuery}]<br>" . $DB->error() . "<hr>";
    }
    fclose($fileHandle);
    $offset = -1;
    return true;
}
Ejemplo n.º 5
0
/**
 * To be conserved to migrations before 0.80
 * since 0.80, migration is a new class
**/
function displayMigrationMessage($id, $msg = "")
{
    global $LANG;
    static $created = 0;
    static $deb;
    if ($created != $id) {
        if (empty($msg)) {
            $msg = $LANG['rulesengine'][90];
        }
        echo "<div id='migration_message_{$id}'><p class='center'>{$msg}</p></div>";
        $created = $id;
        $deb = time();
    } else {
        if (empty($msg)) {
            $msg = $LANG['rulesengine'][91];
        }
        $fin = time();
        $tps = timestampToString($fin - $deb);
        echo "<script type='text/javascript'>document.getElementById('migration_message_{$id}').innerHTML =\n             '<p class=\"center\">{$msg} ({$tps})</p>';</script>\n";
    }
    glpi_flush();
}