Пример #1
0
if ($opt['db']['maintenance_password'] == '') {
    if (in_array('--flush', $argv)) {
        echo "\nenter DB " . $opt['db']['maintenance_user'] . " password:\n";
        flush();
    } else {
        echo "enter DB " . $opt['db']['maintenance_user'] . " password: "******"no DB password - aborting.\n");
    }
}
// connect to database
if (!sql_connect_maintenance()) {
    echo 'Unable to connect to database';
    exit;
}
// set variables used by old maintenance scripts
$lang = $opt['template']['locale'];
// include the requested maintain version file
$dbsv = in_array('--dbsv', $argv);
if ($dbsv) {
    $versionfile = 'maintain-' . $argv[$dbsv + 1] . '.inc.php';
    if (!file_exists(dirname(__FILE__) . '/' . $versionfile)) {
        die($versionfile . " not found\n");
    } else {
        require $versionfile;
    }
    @unlink($opt['rootpath'] . 'cache2/dbsv-running');
Пример #2
0
function resetIds()
{
    global $translang, $tpl;
    if (sql_connect_maintenance() == false) {
        $tpl->error(ERROR_DB_NO_ROOT);
    }
    // clean up dead refs
    sql_temp_table('transDeadIds');
    sql("CREATE TEMPORARY TABLE &transDeadIds (`trans_id` INT(11) PRIMARY KEY) SELECT DISTINCT `sys_trans_ref`.`trans_id` FROM `sys_trans_ref` LEFT JOIN `sys_trans` ON `sys_trans_ref`.`trans_id`=`sys_trans`.`id` WHERE ISNULL(`sys_trans`.`id`)");
    sql("DELETE `sys_trans_ref` FROM `sys_trans_ref`, &transDeadIds WHERE `sys_trans_ref`.`trans_id`=&transDeadIds.`trans_id`");
    sql_drop_temp_table('transDeadIds');
    sql_temp_table('transDeadIds');
    sql("CREATE TEMPORARY TABLE &transDeadIds (`trans_id` INT(11) PRIMARY KEY) SELECT DISTINCT `sys_trans_text`.`trans_id` FROM `sys_trans_text` LEFT JOIN `sys_trans` ON `sys_trans_text`.`trans_id`=`sys_trans`.`id` WHERE ISNULL(`sys_trans`.`id`)");
    sql("DELETE `sys_trans_text` FROM `sys_trans_text`, &transDeadIds WHERE `sys_trans_text`.`trans_id`=&transDeadIds.`trans_id`");
    sql_drop_temp_table('transDeadIds');
    // table sys_trans
    if (sql_value("SELECT COUNT(*) FROM `sys_trans` WHERE `id`=1", 0) == 0) {
        useId(1);
    }
    $lastId = sql_value("SELECT MAX(`id`) FROM `sys_trans`", 0);
    while ($id = sql_value("SELECT `s1`.`id`+1 FROM `sys_trans` AS `s1` LEFT JOIN `sys_trans` AS `s2` ON `s1`.`id`+1=`s2`.`id` WHERE ISNULL(`s2`.`id`) AND `s1`.`id`<'&1' ORDER BY `s1`.`id` LIMIT 1", 0, $lastId)) {
        if ($lastId + 1 == $id) {
            break;
        }
        setId($lastId, $id);
        $lastId = sql_value("SELECT MAX(`id`) FROM `sys_trans`", 0);
    }
    // need alter privileges
    $lastId = sql_value("SELECT MAX(`id`) FROM `sys_trans`", 0);
    sql("ALTER TABLE `sys_trans` AUTO_INCREMENT = &1", $lastId + 1);
    $tpl->redirect('translate.php?translang=' . $translang);
}