예제 #1
0
function save()
{
    global $db;
    $flag = be("all", "flag");
    $num = be("all", "num");
    $c_id = be("all", "c_id");
    $c_money = be("all", "c_money");
    $c_point = be("all", "c_point");
    if ($flag == "edit") {
        $colarr = array("c_money", "c_point");
        $valarr = array($c_money, $c_point);
        $where = "c_id=" . $c_id;
        $db->Update("{pre}user_card", $colarr, $valarr, $where);
    } else {
        $num = intval($num);
        $colarr = array("c_number", "c_pass", "c_money", "c_point", "c_addtime");
        for ($i = 0; $i < $num; $i++) {
            $c_number = getRndStr(10);
            $c_pass = getRndStr(6);
            $c_addtime = date('Y-m-d H:i:s', time());
            $valarr = array($c_number, $c_pass, $c_money, $c_point, $c_addtime);
            $db->Add("{pre}user_card", $colarr, $valarr);
        }
    }
    echo "保存完毕";
}
예제 #2
0
function bak()
{
    global $db;
    $fpath = "bak/" . date('Ymd', time()) . "_" . getRndStr(10);
    $sql = "";
    $p = 1;
    $tables = "{pre}art_topic,{pre}art_type,{pre}comment,{pre}gbook,{pre}link,{pre}mood,{pre}user,{pre}user_card,{pre}user_group,{pre}user_visit,{pre}vod_topic,{pre}vod_type,{pre}art,{pre}vod";
    $tables = replaceStr($tables, "{pre}", app_tablepre);
    $tablearr = explode(",", $tables);
    foreach ($tablearr as $table) {
        $sql .= make_header($table);
        $rsfield = $db->getTableFields(app_dbname, $table);
        $i = 0;
        while ($rowfield = mysql_fetch_field($rsfield)) {
            $fs[$i] = trim($rowfield->name);
            $i++;
        }
        unset($rsfield);
        $fsd = $i - 1;
        $nums = $db->getOne("select count(*) from {$table}");
        $pagecount = 1;
        if ($nums > 1000) {
            $pagecount = ceil($nums / 1000);
        }
        for ($n = 1; $n <= $pagecount; $n++) {
            $rsdata = $db->getAll("select * from {$table} limit " . 1000 * ($n - 1) . ",1000");
            $rscount = count($rsdata);
            $intable = "INSERT INTO `{$table}` VALUES(";
            for ($j = 0; $j < $rscount; $j++) {
                $line = $intable;
                for ($k = 0; $k <= $fsd; $k++) {
                    if ($k < $fsd) {
                        $line .= "'" . mysql_escape_string($rsdata[$j][$fs[$k]]) . "',";
                    } else {
                        $line .= "'" . mysql_escape_string($rsdata[$j][$fs[$k]]) . "');\r\n";
                    }
                }
                $sql .= $line;
                if (strlen($sql) >= 2000000) {
                    $fname = $fpath . "-" . $p . ".sql";
                    fwrite(fopen($fname, "wb"), $sql);
                    $p++;
                    $sql = "";
                }
            }
            unset($rsdata);
        }
        unset($fs);
    }
    $sql .= make_manager(replaceStr("{pre}manager", "{pre}", app_tablepre));
    $fname = $fpath . "-" . $p . ".sql";
    fwrite(fopen($fname, "wb"), $sql);
    echo "备份成功";
}
예제 #3
0
파일: admin_data.php 프로젝트: klarclm/sgv
         $u_start = ip2long(be("all", "u_startip"));
         $u_end = ip2long(be("all", "u_endip"));
     }
     $valarr['u_start'] = $u_start;
     $valarr['u_end'] = $u_end;
     $where = "u_id=" . $id;
     break;
 case "user_card":
     $num = be('all', 'num');
     $c_money = be('all', 'c_money');
     $c_point = be('all', 'c_point');
     $num = intval($num);
     $colarr = array('c_number', 'c_pass', 'c_money', 'c_point', 'c_addtime');
     for ($i = 0; $i < $num; $i++) {
         $c_number = getRndStr(16);
         $c_pass = getRndStr(8);
         $c_addtime = time();
         $valarr = array($c_number, $c_pass, $c_money, $c_point, $c_addtime);
         $db->Add('{pre}user_card', $colarr, $valarr);
     }
     $flag = 'ok';
     break;
 case "art":
     $id = be("all", "a_id");
     $uptag = be("all", "uptag");
     $uptime = be("all", "uptime");
     $colarr = array('a_name', 'a_subname', 'a_enname', 'a_letter', 'a_color', 'a_from', 'a_author', 'a_tag', 'a_pic', 'a_type', 'a_level', 'a_hide', 'a_lock', 'a_up', 'a_down', 'a_hits', 'a_dayhits', 'a_weekhits', 'a_monthhits', 'a_addtime', 'a_time', 'a_hitstime', 'a_maketime', 'a_remarks', 'a_content');
     for ($i = 0; $i < count($colarr); $i++) {
         $n = $colarr[$i];
         $valarr[$n] = be("all", $n);
     }
예제 #4
0
파일: db.php 프로젝트: klarclm/sgv
                    $sql = str_replace(chr(10), '', $sql);
                    $sql = str_replace(chr(13), '', $sql);
                    if (!isN($sql)) {
                        $db->query(trim($sql));
                    }
                    unset($sql);
                }
                unset($sqls);
            }
        }
        ob_flush();
        flush();
        showMsg('共有' . $fcount . '个备份分卷文件需要还原,正在还原第' . $num . '个文件...', '?m=db-reduction-num-' . ($num + 1) . '-fcount-' . $fcount . '-file-' . $file);
    }
} elseif ($method == 'bak') {
    $fpath = 'bak/' . date('Ymd', time()) . '_' . getRndStr(10);
    $sql = '';
    $p = 1;
    $tables = ' `{pre}art_relation` , `{pre}art_topic` , `{pre}art_type` , `{pre}comment` , `{pre}gbook` , `{pre}link` , `{pre}user` , `{pre}user_card` , `{pre}user_group` , `{pre}user_pay` , `{pre}user_visit`  , `{pre}vod_relation` , `{pre}vod_topic` , `{pre}vod_type`, `{pre}vod_class` , `{pre}art`, `{pre}vod`';
    $tables = str_replace('{pre}', $GLOBALS['MAC']['db']['tablepre'], $tables);
    $tablearr = explode(',', $tables);
    $pagesize = 800;
    foreach ($tablearr as $table) {
        $table = trim($table);
        $sql .= make_header($table);
        $i = 0;
        $fs = array();
        $res = $db->query("SHOW COLUMNS FROM " . $table);
        while ($row = mysql_fetch_array($res)) {
            $fs[] = $row[0];
        }