示例#1
0
文件: db.php 项目: renduples/alibtob
    }
}
if (isset($_GET['do'])) {
    $do = trim($_GET['do']);
    if ($do == "refresh" && !empty($_GET['id'])) {
        $datafile = DATA_PATH . "backup_" . $backupdir . DS . $_GET['id'];
        if (!file_exists($datafile)) {
            flash("file_not_exists");
        } else {
            if (@($fp = fopen($datafile, 'rb'))) {
                $sqldump = fread($fp, filesize($datafile));
                fclose($fp);
                $sqlquery = splitsql($sqldump);
                unset($sqldump);
                foreach ($sqlquery as $sql) {
                    $sql = syntablestruct(trim($sql), $db->version() > '4.1', $dbcharset);
                    if ($sql != '') {
                        $db->query($sql);
                        if (($sqlerror = $db->error()) && $db->errno() != 1062) {
                            $db->halt('MySQL Query Error', $sql);
                        }
                    }
                }
                flash("db_restored", "db.php?do=restore");
            } else {
                flash();
            }
        }
    }
    if ($do == "del" && !empty($_GET['id'])) {
        $datafile = DATA_PATH . "backup_" . $backupdir . DS . $_GET['id'];