Exemple #1
0
    }
}
// prints out the data to repair the database from missing data
if (rt("repair")) {
    $rs = dbExec("select\n\t\t\t\t\t\tu.id,\n\t\t\t\t\t\tu.class as cls,\n\t\t\t\t\t\tu.first_name as fn,\n\t\t\t\t\t\tu.last_name as ln,\n\t\t\t\t\t\tu.gamedata,\n\t\t\t\t\t\tt.w1vendor as w1v,\n\t\t\t\t\t\tt.w2vendor as w2v,\n\t\t\t\t\t\tt.w3vendor as w3v,\n\t\t\t\t\t\tt.w1cost as w1c,\n\t\t\t\t\t\tt.w2cost as w2c,\n\t\t\t\t\t\tt.w3cost as w3c\n\t\t\t\t\tfrom\n\t\t\t\t\t\tusers as u\n\t\t\t\t\tleft outer join tracking as t on\n\t\t\t\t\t\tu.id = t.user_id\n\t\t\t\t\twhere\n\t\t\t\t\t\tu.active=1\n\t\t\t\t\t\tand\n\t\t\t\t\t\tu.auth_count>0\n\t\t\t\t\t\tand \n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t(t.w1vendor = '' and t.w1cost != 0)\n\t\t\t\t\t\t\tor\n\t\t\t\t\t\t\t(t.w2vendor = '' and t.w2cost != 0)\n\t\t\t\t\t\t\tor\n\t\t\t\t\t\t\t(t.w3vendor = '' and t.w3cost != 0)\n\t\t\t\t\t\t)\n\t\t\t\t\torder by last_name\n\t\t\t\t\t\t");
    p("Repairing " . $rs->RecordCount() . " student records with at least 1 missing vendor name ...");
    while (!$rs->EOF) {
        $o = $rs->FetchNextObj();
        $id = $o->id;
        $gd = gdDecodeAssoc($o->gamedata);
        p_red($o->fn . " " . $o->ln . "[" . $o->id . "]:\n");
        for ($w = 1; $w <= $game_weeks; $w++) {
            $wvs = "w" . $w . "v";
            $wvl = "w" . $w . "vendor";
            if ($o->{$wvs} == "" && $gd[$wvl] != "") {
                $vn = getvname($gd[$wvl], $w, $o->cls);
                $sql = "update tracking set {$wvl}='{$vn}' where user_id={$id}";
                p_red($sql);
                dbExec($sql);
            }
        }
        p_red("");
    }
    exit;
}
if (rt("reset")) {
    b("clearing raised money for teams and students");
    //dbExec("delete from vars");
    //p("cleared vars table");
    dbExec("update tracking set raisedmoney=0");
    p("cleared tracking.raisedmoney");
Exemple #2
0
$rs = dbExec("select\n\t\t\t\tu.id,\n\t\t\t\tu.class as cls,\n\t\t\t\tu.first_name as fn,\n\t\t\t\tu.last_name as ln,\n\t\t\t\tu.gamedata,\n\t\t\t\tt.w1vendor as w1v,\n\t\t\t\tt.w2vendor as w2v,\n\t\t\t\tt.w3vendor as w3v,\n\t\t\t\tt.w1cost as w1c,\n\t\t\t\tt.w2cost as w2c,\n\t\t\t\tt.w3cost as w3c\n\t\t\tfrom\n\t\t\t\tusers as u\n\t\t\tleft outer join tracking as t on\n\t\t\t\tu.id = t.user_id\n\t\t\twhere\n\t\t\t\tu.active=1\n\t\t\t\tand\n\t\t\t\tu.auth_count > 0\n\t\t\t\tand\n\t\t\t\tu.user_type = 's'\n\t\t\t\t");
$rc = $rs->RecordCount();
w("Relevant user records: {$rc}\n");
w("\n");
$num = 0;
$num_fixed = 0;
while (!$rs->EOF) {
    $o = $rs->FetchNextObj();
    $id = $o->id;
    $gd = gdDecodeAssoc($o->gamedata);
    $m = "";
    $m .= "[" . $o->id . "] " . $o->fn . " " . $o->ln . " cls={$o->cls} :\n";
    $flag = false;
    $fixed = false;
    for ($w = 1; $w <= $game_weeks; $w++) {
        $g_name = getvname($gd["w" . $w . "vendor"], $w, $o->cls);
        //$gd["tm_".$o->cls."_w".$w."vendor"];
        $g_cost = (int) $gd["tm_" . $o->cls . "_w" . $w . "cost"];
        $a = "w" . $w . "v";
        $t_name = $o->{$a};
        $a = "w" . $w . "c";
        $t_cost = (int) $o->{$a};
        if ($t_name == "Dewey,") {
            $t_name = "Dewey";
        }
        if (substr($t_name, 0, 7) == "Ramblin") {
            $t_name = "Ramblin";
        }
        if ($g_name != $t_name || $g_cost != $t_cost) {
            $m .= "  w{$w}: g_name={$g_name}\tt_name={$t_name}\tg_cost={$g_cost}\tt_cost={$t_cost}\n";
            $flag = true;