function DBDeleteLanguage($contestnumber, $param, $c = null) { $ac = array('number'); foreach ($ac as $key) { if (!isset($param[$key])) { MSGError("DBDeleteLanguage param error: {$key} not found"); return false; } ${$key} = sanitizeText($param[$key]); } $cw = false; if ($c == null) { $cw = true; $c = DBConnect(); DBExec($c, "begin work", "DBDeleteLanguage(transaction)"); } $sql = "select * from langtable where langnumber={$number} and contestnumber={$contestnumber}"; $r = DBExec($c, $sql . " for update", "DBDeleteLanguage(get lang for update)"); if (DBnlines($r) > 0) { $a = DBRow($r, 0); $r = DBExec($c, "update langtable set langname='" . $a["langname"] . "(DEL)', updatetime=" . time() . " where contestnumber={$contestnumber} and langnumber={$number} " . "", "DBDeleteLanguage(update)"); $r = DBExec($c, "select runnumber as number, runsitenumber as site from runtable where contestnumber={$contestnumber} and runlangnumber={$number} for update"); $n = DBnlines($r); for ($i = 0; $i < $n; $i++) { $a = DBRow($r, $i); DBRunDelete($a["number"], $a["site"], $contestnumber, $_SESSION["usertable"]["usernumber"], $_SESSION["usertable"]["usersitenumber"]); } } if ($cw) { DBExec($c, "commit", "DBDeleteLanguage(commit)"); } LOGLevel("Language {$number} deleted (user="******"usertable"]["username"] . "/" . $_SESSION["usertable"]["usersitenumber"] . ")", 2); return true; }
function DBDeleteAnswer($contest, $param, $c = null) { $ac = array('number'); foreach ($ac as $key) { if (!isset($param[$key])) { return false; } ${$key} = sanitizeText($param[$key]); } $cw = false; if ($c == null) { $cw = true; $c = DBConnect(); DBExec($c, "begin work", "DBDeleteAnswer(transaction)"); } $r = DBExec($c, "select * from answertable where contestnumber={$contest} and answernumber={$number} " . "and fake='f' for update", "DBDeleteAnswers(delete)"); if (DBnlines($r) > 0) { $a = DBRow($r, 0); $r = DBExec($c, "update answertable set runanswer='" . $a["runanswer"] . "(DEL)', updatetime=" . time() . " where contestnumber={$contest} and answernumber={$number} " . "and fake='f'", "DBDeleteAnswers(update)"); $r = DBExec($c, "select runnumber as number, runsitenumber as site from runtable where contestnumber={$contest} and runanswer={$number} for update"); $n = DBnlines($r); for ($i = 0; $i < $n; $i++) { $a = DBRow($r, $i); DBRunDelete($a["number"], $a["site"], $contest, $_SESSION["usertable"]["usernumber"], $_SESSION["usertable"]["usersitenumber"]); } } if ($cw) { DBExec($c, "commit", "DBDeleteAnswer(commit)"); } LOGLevel("Answer {$number} deleted from contest {$contest} (user="******"usertable"]["username"] . "/" . $_SESSION["usertable"]["usersitenumber"] . ")", 2); return true; }
if (isset($_POST["cancel"]) && $_POST["cancel"] == "Cancel editing") { ForceLoad($runphp); } if (isset($_POST["giveup"]) && $_POST["giveup"] == "Renew" && isset($_POST["sitenumber"]) && isset($_POST["number"]) && is_numeric($_POST["number"]) && is_numeric($_POST["sitenumber"])) { $sitenumber = myhtmlspecialchars($_POST["sitenumber"]); $number = myhtmlspecialchars($_POST["number"]); if (DBGiveUpRunAutojudging($_SESSION["usertable"]["contestnumber"], $sitenumber, $number)) { MSGError("Run renewed."); } ForceLoad($runphp); } if (isset($_POST["delete"]) && $_POST["delete"] == "Delete" && isset($_POST["sitenumber"]) && isset($_POST["number"]) && is_numeric($_POST["number"]) && is_numeric($_POST["sitenumber"])) { if ($_POST["confirmation"] == "confirm") { $sitenumber = myhtmlspecialchars($_POST["sitenumber"]); $number = myhtmlspecialchars($_POST["number"]); if (DBRunDelete($number, $sitenumber, $_SESSION["usertable"]["contestnumber"], $_SESSION["usertable"]["usernumber"], $_SESSION["usertable"]["usersitenumber"])) { MSGError("Run deleted."); } } ForceLoad($runphp); } if (isset($_POST["answer"]) && isset($_POST["open"]) && $_POST["open"] == "Open run for rejudging" && isset($_POST["sitenumber"]) && isset($_POST["number"]) && is_numeric($_POST["number"]) && is_numeric($_POST["sitenumber"])) { if ($_POST["confirmation"] == "confirm") { $sitenumber = myhtmlspecialchars($_POST["sitenumber"]); $number = myhtmlspecialchars($_POST["number"]); DBGiveUpRunAutojudging($_SESSION["usertable"]["contestnumber"], $sitenumber, $number); if (DBChiefRunGiveUp($_POST["number"], $_POST["sitenumber"], $_SESSION["usertable"]["contestnumber"])) { MSGError("Run returned."); } ForceLoad($runphp); }
function DBDeleteProblem($contestnumber, $param, $c = null) { $ac = array('number', 'inputfilename'); foreach ($ac as $key) { if (!isset($param[$key])) { return false; } ${$key} = sanitizeText($param[$key]); } $sql = "select * from problemtable where problemnumber={$number} and contestnumber={$contestnumber} and fake='f'"; if ($inputfilename != "") { $sql .= " and probleminputfilename='{$inputfilename}'"; } $cw = false; if ($c == null) { $cw = true; $c = DBConnect(); DBExec($c, "begin work", "DBDeleteProblem(transaction)"); } $r = DBExec($c, $sql . " for update", "DBDeleteProblem(get for update)"); if (DBnlines($r) > 0) { $a = DBRow($r, 0); if (($pos = strpos($a["problemfullname"], "(DEL)")) !== false) { $sql = "update problemtable set problemfullname='" . substr($a["problemfullname"], 0, $pos) . "', updatetime=" . time() . " where contestnumber={$contestnumber} and problemnumber={$number} "; } else { $sql = "update problemtable set problemfullname='" . $a["problemfullname"] . "(DEL)', updatetime=" . time() . " where contestnumber={$contestnumber} and problemnumber={$number} "; } if ($inputfilename != "") { $sql .= " and probleminputfilename='{$inputfilename}'"; } $r = DBExec($c, $sql, "DBDeleteLanguage(update)"); $r = DBExec($c, "select runnumber as number, runsitenumber as site from runtable where contestnumber={$contestnumber} and runproblem={$number} for update"); $n = DBnlines($r); for ($i = 0; $i < $n; $i++) { $a = DBRow($r, $i); DBRunDelete($a["number"], $a["site"], $contestnumber, $_SESSION["usertable"]["usernumber"], $_SESSION["usertable"]["usersitenumber"]); } } if ($cw) { DBExec($c, "commit", "DBDeleteProblem(commit)"); } $ds = DIRECTORY_SEPARATOR; if ($ds == "") { $ds = "/"; } $ptmp = $_SESSION["locr"] . $ds . "private" . $ds . "problemtmp" . $ds . "contest" . $contestnumber . "-problem" . $number; @unlink($ptmp . ".name"); @unlink($ptmp . ".hash"); LOGLevel("Problem {$number} (inputfile={$inputfilename}) deleted (user="******"usertable"]["username"] . "/" . $_SESSION["usertable"]["usersitenumber"] . ")", 2); return true; }