Exemplo n.º 1
0
    if (!is_file(BACKUP_DIR . $get['sqlpath'] . '/' . $get['dumpfile'])) {
        if (is_file(BACKUP_DIR . $get['sqlpath'] . '/' . $next_dumpfile)) {
            api_msg('bak_file_lose', $get['dumpfile']);
        } else {
            api_msg('import_success', 'import_success');
        }
    }
    $sqldump = file_get_contents(BACKUP_DIR . $get['sqlpath'] . '/' . $get['dumpfile']);
    $sqlquery = splitsql($sqldump);
    unset($sqldump);
    foreach ($sqlquery as $sql) {
        //note 兼容SQL建表格式,調整為當前版本和字符集合適的建表語句
        $sql = syntablestruct(trim($sql), $db->version() > '4.1', $dbcharset);
        if ($sql != '') {
            $db->query($sql, 'SILENT');
            if (($sqlerror = $db->error()) && $db->errno() != 1062) {
                $db->halt('MySQL Query Error', $sql);
            }
        }
    }
    $cur_file = $get['dumpfile'];
    $get['dumpfile'] = $next_dumpfile;
    auto_next($get, BACKUP_DIR . $get['sqlpath'] . '/' . $cur_file);
} elseif ($get['method'] == 'ping') {
    //note 探測某個指定目錄下是否有備份數據
    if ($get['dir'] && is_dir(BACKUP_DIR . $get['dir'])) {
        echo "1";
        exit;
    } else {
        echo "-1";
        exit;