Ejemplo n.º 1
0
function checkData()
{
    $res = PQuery('BEGIN WORK; LOCK "MapSettings";');
    if (isset($res['error'])) {
        return array('error' => $res['error']);
    }
    $query = 'SELECT * FROM "MapSettings"
                WHERE "LastChangedMap" >= "LastChangedTmpMap"';
    $res = PQuery($query);
    if (isset($res['error'])) {
        return array('error' => $res['error']);
    }
    if ($res['count'] == 1) {
        $res = dropTmpTables(true);
        $res = createTmpTables(true);
        setTmpMapLastEdit();
    } else {
        $res = createTmpTables(true);
    }
    $res = PQuery('COMMIT WORK');
    return array('error' => isset($res['error']) ? $res['error'] : false);
}
Ejemplo n.º 2
0
            $sql = "UPDATE pw_bbs_threads t LEFT JOIN pw_user u ON u.username = t.lastpost_username SET t.lastpost_userid = ifnull(u.uid,0)  WHERE t.tid BETWEEN %d AND %d";
            $targetDb->query(sprintf($sql, $lastId * $_pertime, ($lastId + 1) * $_pertime));
            $transfers = $limit;
        }
        $nextId = $lastId + 1;
        calculatePercent(intval($limit), intval($lastId));
        refreshTo('bbsinfo');
    } elseif ('bbsinfo' == $action) {
        $info = $srcDb->get_one('SELECT * FROM pw_bbsinfo');
        $_info = array('id' => 1, 'newmember' => $info['newmember'], 'totalmember' => $info['totalmember'], 'higholnum' => $info['higholnum'], 'higholtime' => $info['higholtime'], 'yposts' => $info['yposts'], 'hposts' => $info['hposts']);
        $sql = sprintf("REPLACE INTO pw_bbsinfo (`id`, `newmember`, `totalmember`, `higholnum`, `higholtime`, `yposts`, `hposts`) VALUES ('%s')", implode("','", $_info));
        $targetDb->query($sql);
    }
    refreshTo('', 'finish');
} elseif ($step == 'finish') {
    dropTmpTables();
    $databaseContent = <<<EOT
<?php 
defined('WEKIT_VERSION') or exit(403);
return array(
\t'dsn' => 'mysql:host={$host};dbname={$dbname};port={$port}',
\t'user' => '{$username}',
\t'pwd' => '{$password}',
\t'charset' => '{$charset}',
\t'tableprefix' => '{$dbpre}',
);
EOT;
    $dbConfigFile = NEXTWIND_DIR . DS . 'conf' . DS . 'database.php';
    file_put_contents($dbConfigFile, $databaseContent);
    $installLocked = NEXTWIND_DIR . DS . 'data' . DS . 'install.lock';
    file_put_contents($installLocked, sprintf('UPDATE FROM 8.7 %s. LOCKED.', date('Y-m-d H:i:s', $timestamp)));