function toggleReg($comp_id,$cat_id) { global $eventstable, $compstable, $regstable; $comp_id = (int)$comp_id; $cat_id = (int)$cat_id; $competitor = strict_query("SELECT cat? AS cat FROM $compstable WHERE id=?", array($cat_id,$comp_id)); if(!sql_num_rows($competitor)) return ""; $_X = "X"; // Do not change! $_w = "-"; // " $event = strict_query("SELECT r1_open, r2_open, r1_groupsize FROM $eventstable WHERE id=?", array($cat_id)); $groupsize = cased_mysql_result($event,0,"r1_groupsize"); if (sql_num_rows($event) && !cased_mysql_result($event,0,"r2_open")) { if (cased_mysql_result($event,0,"r1_open")) { $regs = strict_query("SELECT COUNT(*) as count FROM $regstable WHERE cat_id=? AND round=1", array($cat_id)); $nregs = cased_mysql_result($regs,0,"count"); } else $nregs = $groupsize; $hl = NULL; if (!cased_mysql_result($competitor,0,"cat")) { if ($nregs < $groupsize) { $newValue = $_X; strict_query("INSERT INTO $regstable VALUES (?,1,?)", array($cat_id,$comp_id)); } else $newValue = $_w; } elseif (compHasTimesR1($comp_id,$cat_id)) return $_X; else { $newValue = ""; if (cased_mysql_result($event,0,"r1_open") && cased_mysql_result($competitor,0,"cat")==$_X) { $waiting = strict_query("SELECT id FROM $compstable WHERE cat?='$_w' ORDER BY id LIMIT 1", array($cat_id)); if (!sql_num_rows($waiting)) strict_query("DELETE FROM $regstable WHERE cat_id=? AND round=1 AND comp_id=?", array($cat_id,$comp_id)); else { strict_query("UPDATE $compstable SET cat?='$_X' WHERE id=".cased_mysql_result($waiting,0,"id"), array($cat_id)); strict_query("UPDATE $regstable SET comp_id='" .cased_mysql_result($waiting,0,"id"). "' WHERE cat_id=? AND round=1 AND comp_id=?", array($cat_id,$comp_id)); $hl = "td".cased_mysql_result($waiting,0,"id")."_".$cat_id; } } } strict_query("UPDATE $compstable SET cat?='$newValue' WHERE id=?", array($cat_id,$comp_id)); if ($hl) $newValue .= "/".$hl; return $newValue; } }
function addEve($eve_id) { $eve_id = (int)$eve_id; global $eventstable, $compstable; // $result = strict_query("SELECT id FROM $eventstable WHERE id=?", array($eve_id)); if (sql_num_rows($result)) return; $result = strict_query("SELECT * FROM categories WHERE id=?", array($eve_id)); if (sql_num_rows($result)) { strict_query("INSERT INTO $eventstable SET id=?, r1=1, r1_format=" . substr(cased_mysql_result($result,0,"possible_formats"),0,1) . ", r1_groupsize=999", array($eve_id)); strict_query("ALTER TABLE $compstable ADD cat? VARCHAR( 1 ) NOT NULL", array($eve_id)); } }
function addCom($wcaid,$name,$birthday,$country,$gender,$importing=false,$id=0) { global $compstable; // $name = preg_replace("~[\\\\\"\;]~","",$name); $wcaid = strtoupper($wcaid); if ($wcaid && !preg_match("/^\d{4}[A-Z]{4}\d{2}$/",$wcaid)) return addCom_err("Invalid WCA id format",$wcaid,$name,$importing); if (!checkdate((int)substr($birthday,5,2),(int)substr($birthday,8,2),(int)substr($birthday,0,4))) return addCom_err("Invalid date [$birthday]",$wcaid,$name,$importing); $gender = strtolower($gender); if ($gender!="f" && $gender!="m") return addCom_err("Invalid gender",$wcaid,$name,$importing); // if ($wcaid && !$id) { $result = strict_query("SELECT * FROM $compstable WHERE WCAid=?", array($wcaid)); if (sql_num_rows($result)) return addCom_err("WCA id already exists",$wcaid,$name,$importing); } $result = strict_query("SELECT * FROM countries WHERE id=?", array($country)); if (!sql_num_rows($result)) return addCom_err("Invalid country: ".$country,$wcaid,$name,$importing); if (!$id) { $result = strict_query("SELECT * FROM $compstable WHERE name=? AND country_id=? AND birthday=?", array($name,$country,$birthday)); if (sql_num_rows($result)) return addCom_err("Competitor already inserted",$wcaid,$name,$importing); } // if ($id) strict_query("UPDATE $compstable SET WCAid=?, name=?, country_id=?, birthday=?, gender=? WHERE id=?", array($wcaid,$name,$country,$birthday,$gender,$id)); else strict_query("INSERT INTO $compstable SET WCAid=?, name=?, country_id=?, birthday=?, gender=?", array($wcaid,$name,$country,$birthday,$gender)); // return ($id?(int)$id:sql_insert_id()); }
require_once "lib_get.php"; $_GETid = _GET_num("id"); $_GETfld = _GET_fld("fld"); if ($_GETid && $_GETfld) { require_once "db.php"; // $result = strict_query("SELECT * FROM $eventstable WHERE id=?", array($_GETid)); if (sql_num_rows($result)==1) { $fld = substr($_GETfld,strpos($_GETfld,"_")); switch ($fld) { case "_format": $formats = strict_query("SELECT * FROM formats ORDER BY id"); while($row=cased_mysql_fetch_array($formats)) $fmts[] = $row["name"]; $category = strict_query("SELECT possible_formats FROM categories WHERE id=".cased_mysql_result($result,0,"id")); $possible_formats = cased_mysql_result($category,0,"possible_formats"); $value = cased_mysql_result($result,0,$_GETfld); $newValue = (int)substr ($possible_formats, (strpos($possible_formats,"".$value)+1) % strlen($possible_formats), 1); strict_query("UPDATE $eventstable SET $_GETfld=$newValue WHERE id=?", array($_GETid)); echo $fmts[$newValue-1]; break; } } sql_close(); } ?>
$pdf->Ln(10); } $result = strict_query("SELECT $compstable.name, countries.name AS country, $timestable.best FROM $timestable JOIN $compstable ON $compstable.id=$timestable.comp_id JOIN countries ON $compstable.country_id=countries.id WHERE $timestable.cat_id=1 ORDER BY $timestable.best LIMIT 1"); if (sql_num_rows($result)) { $pdf->SetFont("","B",12); $pdf->Write(5,"Fastest solve"); $pdf->Ln(); $pdf->SetFontSize(10); $pdf->Write(5,romance(cased_mysql_result($result,0,"name"))." - ".cased_mysql_result($result,0,"country")." - ".formatTime(cased_mysql_result($result,0,"best"),1)); $pdf->Ln(10); } $result = strict_query("SELECT $compstable.name, average, countries.name AS country FROM $compstable ". "JOIN (SELECT comp_id, MIN(average) AS average FROM $timestable WHERE cat_id=1 GROUP BY comp_id) avg ON avg.comp_id=$compstable.id ". "JOIN countries ON $compstable.country_id=countries.id ". "WHERE gender=\"f\" AND average!=\"\" ORDER BY average LIMIT 3"); if (sql_num_rows($result)) { $pdf->SetFont("","B",12); $pdf->Write(5,"Fastest females"); $pdf->Ln(); $pdf->SetFontSize(10); $count = 0; while ($row=cased_mysql_fetch_array($result)) { $pdf->Write(5,++$count.". ".romance($row["name"])." - ".$row["country"]." - ".formatTime($row["average"],1)); $pdf->Ln(); } }
function print_txt_sch($fn) { global $competition, $eventstable; // $r = strict_query("SELECT name, abbr FROM categories"); while ($row=cased_mysql_fetch_array($r)) $categories[$row["abbr"]] = $row["name"]; $r = strict_query("SELECT * FROM $eventstable JOIN categories ON $eventstable.id=categories.id"); while ($row=cased_mysql_fetch_array($r)) { $events[_RX][$row["abbr"]] = 0; $events[_ID][$row["abbr"]] = $row["id"]; $x = 1; while ($x <= 4 && $row["r$x"."_open"]) $x++; $events[_RTOP][$row["abbr"]] = $x-1; } // $fh = fopen($fn,'r'); $ver = trim(fgets($fh)); if ($ver != "00") { print_txt01_sch($fh,$categories,$events); return; } // echo "<h2>".cased_mysql_result($competition,0,"name")." Schedule</h2><p>"; $timezone = fgets($fh); $line = fgets($fh); while ($line) { echo date("l - F jS, Y",strtotime($line))."<p>"; echo "<table border=0 cellpadding=0 cellspacing=0 class=SCH><tr><th height=17 width=50>Start</th><th width=200>Event</th><th width=100>Round</th><th width=80>Format</th></tr>"; $line = fgets($fh); while ($line && !strtotime($line)) { $time = fetch($line); $abbr = fetch($line); echo "<tr".($categories[$abbr]?"":" class=rest").">"; echo "<td height=17 align=right>$time</td>"; if ($categories[$abbr]) { echo "<td>".$categories[$abbr]."</td>"; echo "<td>"; if (isset($events[_RX][$abbr])) { $events[_RX][$abbr] = $events[_RX][$abbr] + 1; if ($events[_RX][$abbr] <= $events[_RTOP][$abbr]) echo "<a href='live.php?cid=" .$_GET["cid"]. "&cat=" .$events[_ID][$abbr]. "&rnd=" .$events[_RX][$abbr]. "'>" .fetch($line). "</a>"; else echo fetch($line); } else echo fetch($line); echo "</td>"; echo "<td>".fetch($line)."</td>"; } else echo "<td colspan=3 align=center>$abbr</td>"; echo "<tr>"; // $line = fgets($fh); } echo "</table><p><br>"; } fclose($fh); // echo "All times are $timezone"; }
function createSheetEvtRnd($sheet,$cat_id,$round,$lround,$timelimit) { global $ssC,$ssB,$ssR,$ssTs,$ssTm,$ssBC,$ssBR,$ssBG1,$ssBG2, $compstable, $regstable, $timestable, $events,$evt, $f_header,$f_headerc,$f_time; // $category = strict_query("SELECT * FROM categories WHERE id=".$cat_id); $timetype = cased_mysql_result($category,0,"timetype"); $inseconds = cased_mysql_result($category,0,"inseconds"); $format = strict_query("SELECT * FROM formats WHERE id=".cased_mysql_result($events,$evt,"r".$round."_format")); $times = cased_mysql_result($format,0,"times"); $avgtype = cased_mysql_result($format,0,"avgtype"); $query = "SELECT $regstable.*, $compstable.name, $compstable.WCAid, $timestable.t1, $timestable.t2, $timestable.t3, $timestable.t4, $timestable.t5, $timestable.average, $timestable.best, countries.name AS country FROM $regstable ". "JOIN $timestable ON ($regstable.cat_id=$timestable.cat_id AND $regstable.round=$timestable.round AND $regstable.comp_id=$timestable.comp_id) ". "JOIN $compstable ON ($regstable.comp_id=$compstable.id) ". "JOIN countries ON ($compstable.country_id=countries.id) ". "WHERE $regstable.cat_id=" .$cat_id. " AND $regstable.round=" .$round." ORDER BY $timestable.t1 IS NULL, $timestable.average=\"\", $timestable.average, $timestable.best, $regstable.comp_id"; $result = strict_query($query); if (!sql_num_rows($result)) // trick to generate 32 empty lines with formulas $result = strict_query("SELECT NULL as name, NULL as country, NULL as WCAid, NULL as t1, NULL as t2, NULL as t3, NULL as t4, NULL as t5 FROM countries LIMIT 32"); // $sheet ->setTitle(cased_mysql_result($category,0,"abbr")."-".$round); $sheet //->setCellValue("A1", cased_mysql_result($category,0,"name")." - round $round") ->setCellValue("A1", cased_mysql_result($category,0,"name")." - ".roundString($round,$lround,$timelimit)) ->setCellValue("A2", "Format: ".cased_mysql_result($format,0,"name")) ->setCellValue("A3", ($timetype==2?"number of moves":($inseconds?"time in seconds (ss.hh)":"time in minutes (m:ss.hh)"))) ->setCellValue("A4", "Position") ->setCellValue("B4", "Name") ->setCellValue("C4", "Country") ->setCellValue("D4", "WCA id"); $sheet ->setSharedStyle($ssB, "A1:A3") ->setSharedStyle($ssB, "A4:D4"); if ($timetype!=3) { if ($times==1) { $sheet->setCellValue("E4", "Result"); $letterLT = "E"; $letterBest = "E"; } else { for ($x=1;$x<=$times;$x++) $sheet->setCellValue(chr(68+$x)."4", $x); $letterLT = chr(67+$x); $letterBest = chr(68+$x); } $sheet ->setSharedStyle($ssBC, "E4:".chr(68+$times)."4") ->setSharedStyle($ssBR, chr(69+$times)."4:Z4"); $x = 69+$times; } else { for ($x=1;$x<=$times;$x++) $sheet ->setCellValue(chr(69+($x-1)*4)."4", "tried") ->setCellValue(chr(69+($x-1)*4+1)."4", "solved") ->setCellValue(chr(69+($x-1)*4+2)."4", "seconds") ->setCellValue(chr(69+($x-1)*4+3)."4", "score $x"); $sheet ->setSharedStyle($ssBR, "E4:Z4"); $x = 69+($x-1)*4; } if ($times>1) $sheet->setCellValue(chr($x++)."4", "Best"); $sheet->setCellValue(chr($x++)."4", "WR"); if ($avgtype==0) { $letterAvg = chr($x+1); $sheet ->setCellValue(chr($x++)."4", "Worst") ->setCellValue(chr($x++)."4", "Average") ->setCellValue(chr($x++)."4", "WR"); } elseif ($avgtype==1) { $letterAvg = chr($x); $sheet ->setCellValue(chr($x++)."4", "Mean") ->setCellValue(chr($x++)."4", "WR"); } $line = 5; $lineb = 4; while ($row=cased_mysql_fetch_array($result)) { $sheet ->setCellValue("B$line", $row["name"]) ->setCellValue("C$line", $row["country"]) ->setCellValue("D$line", $row["WCAid"]); if ($timetype!=3) { for ($x=1;$x<=$times;$x++) $sheet->setCellValue(chr(68+$x).$line, formatTime($row["t$x"],$timetype,$inseconds)); $x = 69+$times; if ($times>1) $sheet ->setCellValue(chr($x++).$line, "=IF(MIN(E$line:$letterLT$line)>0,MIN(E$line:$letterLT$line),IF(COUNTBLANK(E$line:$letterLT$line)=$times,\"\",\"DNF\"))"); if ($avgtype==0) { $x++; $sheet ->setCellValue(chr($x++).$line, "=IF(COUNTBLANK(E$line:I$line)>0,\"\",IF(COUNTIF(E$line:I$line,\"DNF\")+COUNTIF(E$line:I$line,\"DNS\")>0,\"DNF\",MAX(E$line:I$line)))") ->setCellValue(chr($x++).$line, "=IF(COUNTBLANK(E$line:I$line)>0,\"\",IF(COUNTIF(E$line:I$line,\"DNF\")+COUNTIF(E$line:I$line,\"DNS\")>1,\"DNF\",IF(COUNTIF(E$line:I$line,\"DNF\")+COUNTIF(E$line:I$line,\"DNS\")>0,(SUM(E$line:I$line)-J$line)/".($times-2).",(SUM(E$line:I$line)-J$line-L$line)/".($times-2).")))"); } elseif ($avgtype==1) { $x++; $sheet ->setCellValue(chr($x++).$line, "=IF(COUNTBLANK(E$line:G$line)>0,\"\",IF(COUNTIF(E$line:G$line,\"DNF\")+COUNTIF(E$line:G$line,\"DNS\")>0,\"DNF\",AVERAGE(E$line:G$line)))"); } if (isset($letterAvg)) $sheet ->setCellValue("A$line", "=IF(AND($letterAvg$lineb=$letterAvg$line,$letterBest$lineb=$letterBest$line),A$lineb,ROW()-4)"); else $sheet ->setCellValue("A$line", "=IF($letterBest$lineb=$letterBest$line,A$lineb,ROW()-4)"); if ($timetype==2) $sheet->setSharedStyle($ssR, "E$line:Z$line"); elseif ($inseconds) $sheet->setSharedStyle($ssTs, "E$line:Z$line"); else $sheet->setSharedStyle($ssTm, "E$line:Z$line"); } else { $formula = ""; $formula_b = ""; for ($x=1;$x<=$times;$x++) { if (!$row["t$x"] || $row["t$x"]=="DNF" || $row["t$x"]=="DNS") $sheet->setCellValue(chr(69+($x-1)*4).$line, $row["t$x"]); else $sheet ->setCellValue(chr(69+($x-1)*4).$line, (int)substr($row["t$x"],2,2)) ->setCellValue(chr(69+($x-1)*4+1).$line, (int)substr($row["t$x"],0,2)) ->setCellValue(chr(69+($x-1)*4+2).$line, round(formatTime(substr($row["t$x"],4,9),1,true))); // Disagree with that "round" $lE = chr(69+($x-1)*4); $lF = chr(69+($x-1)*4+1); $lG = chr(69+($x-1)*4+2); $lH = chr(69+($x-1)*4+3); $sheet ->setCellValue(chr(69+($x-1)*4+3).$line, "=IF($lE$line=\"DNS\",-2,IF($lE$line=\"DNF\",-1,(99-$lF$line+$lE$line-$lF$line)*10000000+$lG$line*100+$lE$line-$lF$line))") // Changed formula to suit my records (DNFs were discarded before) ->setSharedStyle($ssBG1, chr(69+($x-1)*4+3).$line) ->getColumnDimension(chr(69+($x-1)*4+3))->setWidth(10); if ($formula) $formula .= ","; $formula .= "IF($lH$line<0,1000000000,$lH$line)"; if ($formula_b) $formula_b .= ","; $formula_b .= "$lH$line<0"; } if ($times==1) { $sheet ->setCellValue("A$line", "=IF(H$lineb=H$line,A$lineb,ROW()-4)"); } else { $letterBest = chr(69+($x-1)*4); $sheet ->setCellValue($letterBest.$line, "=IF(AND($formula_b),-1,MIN($formula))") ->setCellValue("A$line", "=IF($letterBest$lineb=$letterBest$line,A$lineb,ROW()-4)") ->setSharedStyle($ssBG2, $letterBest.$line) ->getColumnDimension(chr(69+($x-1)*4))->setWidth(10); } } $line++; $lineb++; } $sheet->getColumnDimension('B')->setWidth(20); $sheet->getColumnDimension('C')->setWidth(10); $sheet->getColumnDimension('D')->setWidth(15); }
elseif ($comp_id) die("This competitor is not registered to any event or these events are not yet open"); } elseif (array_key_exists("aofr",$_GET)) { $ts = new TS(); $ts->AddFont('DejaVu','','DejaVuSans.ttf',true); $ofr = strict_query("SELECT $eventstable.id, categories.name, times FROM $eventstable JOIN categories ON (categories.id=$eventstable.id) JOIN formats ON (formats.id=$eventstable.r1_format) WHERE r1_open=1 ORDER BY $eventstable.id"); while ($rowe=cased_mysql_fetch_array($ofr)) { $query = "SELECT id, name FROM $compstable WHERE cat".$rowe["id"]."=\"X\""; if ($_SESSION["c_id"]==$sebastien) $query .= " ORDER BY id"; else $query .= " ORDER BY name"; $comps = strict_query($query); $count = 0; while ($row=cased_mysql_fetch_array($comps)) { $compname = preg_replace("/\(.*\)/","",$row["name"]); $count++; $ts->Timesheet($row["id"], $compname, $rowe["name"], 1, $rowe["times"], $count); } } $ts->SetDisplayMode("fullpage","single"); $ts->Output(preg_replace("/\W/","",$_SESSION["c_name"])." - Scorecards.pdf", "I"); } else { $ts = new TS(); for ($x=1;$x<=4;$x++)
<? require_once "lib.php"; require_once "lib_ref_admin.php"; require_once "lib_get.php"; $cat_id = _GET_num("cat_id"); $round = _GET_num("round"); if ($cat_id && $round) { require_once "db.php"; // $event = strict_query("SELECT * FROM $eventstable WHERE id=?", array($cat_id)); if (sql_num_rows($event) && cased_mysql_result($event,0,"r".$round) && cased_mysql_result($event,0,"r".$round."_open") && ($round==4 || !cased_mysql_result($event,0,"r".($round+1)) || !cased_mysql_result($event,0,"r".($round+1)."_open"))) { if (sql_num_rows(strict_query("SELECT * FROM $timestable WHERE cat_id=? AND round=? LIMIT 1", array($cat_id,$round)))) die("Can't clear this round: it has times"); else { strict_query("DELETE FROM $regstable WHERE cat_id=? AND round=?", array($cat_id,$round)); if ($round==1) strict_query("UPDATE $compstable SET cat?=\"-\" WHERE cat?=\"X\"", array($cat_id,$cat_id)); strict_query("UPDATE $eventstable SET r?_open=0 WHERE id=?", array($round,$cat_id)); } } // sql_close(); } ?>
$_POSTid = NULL; if (array_key_exists('id', $_POST)) $_POSTid = _POST_num("id"); else $_POSTid = $_SESSION["c_id"]; if (array_key_exists("pw",$_POST)) $_POSTpw = _POST_key("pw"); else $_POSTpw = $_SESSION["c_pw"]; unset($_SESSION["c_pw"]); if (is_null($_POSTid)) _error("Invalid calling params"); if (!$_POSTpw) _error("Blank password"); $result = strict_query("SELECT * FROM competitions WHERE id=?",array($_POSTid)); if (!$result || sql_num_rows($result) != 1) _error("Competition not available"); if (cased_mysql_result($result,0,"admin_pw")==$_POSTpw) { $_SESSION["c_id"] = $_POSTid; $_SESSION["c_admin"] = true; $_SESSION["c_country"] = cased_mysql_result($result,0,"country"); $_SESSION["c_name"] = cased_mysql_result($result,0,"name"); } elseif (cased_mysql_result($result,0,"intro_pw")==$_POSTpw) { $_SESSION["c_id"] = $_POSTid; unset($_SESSION["c_admin"]); $_SESSION["c_country"] = cased_mysql_result($result,0,"country"); $_SESSION["c_name"] = cased_mysql_result($result,0,"name"); }
echo "<td><div class=col_ot><a href='timessheet.php?comp_id=" .$row["id"]. "' target=_blank>[cards]</a>".($candelete ? " <a style='cursor:pointer;' onclick='if (confirm(\"Remove " .htmlspecialchars($row["name"],ENT_QUOTES). " from the competitors list?\")) callPage(\"delcompetitor.php?id=" .$row["id"]. "\");'>[delete]</a>" : "")."</div></td></tr>\r\n"; } } ?> <tr style="background-color:white;"> <form name=frm onsubmit="return(submitForm());"> <td colspan=2><!-- width:118px=86+26+3+3px --> <input type=text id=WCAid name=WCAid maxlength=10 style="width:118px;text-transform:uppercase;" onblur='validateWCAid(this);'></td> <td><input type=text id=competitor name=competitor maxlength=50 style="width:200px;"></td> <td><input type=text id=birth name=birth maxlength=10 onkeypress='birthKeyPress(event);' style="width:72px;" onblur='validateBirth(this)'></td> <td><select id=country name=country style="width:100px;"> <option value=""></option> <? $result = strict_query("SELECT * FROM countries"); while ($row=cased_mysql_fetch_array($result)) { echo "<option value=\"" . $row["id"] . "\""; if ($row["id"]==$_SESSION["c_country"]) echo " selected"; echo ">" . $row["name"] . "</option>\r\n"; } ?> </select></td> <td><select id=gender name=gender style="width:40px;"> <option value=""></option> <option value="m">male</option> <option value="f">female</option> </select></td> <?
<? require_once "lib_ref_admin.php"; require_once "db.php"; require_once "lib_get.php"; $_GETid = _GET_num("id"); if ($_GETid) { strict_query ("DELETE FROM $eventstable WHERE id=?", array($_GETid)); strict_query ("ALTER TABLE $compstable DROP cat?", array($_GETid)); } sql_close(); ?>
if ($_GETid && $_GETfld && isset($_GET["value"])) { require_once "db.php"; // if ($_GETfld=="timelimit") { $value = _GET_key("value"); // still secure because of the following lines if ($value && !preg_match("/^([0-9]{1,2}\072[0-5][0-9]\056[0-9]{2}|[0-5]?[0-9]\056[0-9]{2}|[0-9]{1,2}\072[0-5][0-9])$/",$value)) $value = ""; if ($value) { $value = formatTimelimit00($value); if (!timelimitNum00($value)) $value = ""; } } else $value = _GET_num("value"); // strict_query("UPDATE $eventstable SET $_GETfld=? WHERE id=?", array($value,$_GETid)); // if ($_GETfld=="timelimit") if ($value) $value = "cutoff $value"; else $value = "no cutoff"; echo $value; // sql_close(); } ?>
for ($t=1;$t<=$scoresread;$t++) { $insertst .= ", t$t=?"; if ($timetype!=3) $array[count($array)] = numTime($scores[$t]); else $array[count($array)] = $scores[$t]; } $insertst .= ", average=?, best=?"; $array[count($array)] = $average; $array[count($array)] = $best; strict_query($insertst, $array); } $i++; } $i = $i - 5; $open = $i ? 1 : 0; strict_query("UPDATE $eventstable SET r?=1, r?_format=?, r?_groupsize=?, r?_open=? WHERE id=?", array($round,$round,$formatid,$round,$i,$round,$open,$evtid)); echo " Done! <b>$i scorecards</b> imported.<br>"; } echo "<script>opener.location.reload();</script>"; echo "<p><input type=button value=close onclick='window.close();' />"; sql_close(); ?> </BODY> </HTML>
<? require_once "lib.php"; require_once "lib_reg.php"; require_once "lib_ref_admin.php"; require_once "lib_get.php"; $_GETid = _GET_num("id"); if ($_GETid) { require_once "db.php"; // if (sql_num_rows(strict_query("SELECT * FROM $timestable WHERE comp_id=?", array($_GETid)))) die("Can't delete a competitor who already has results in the competition"); $competitor = strict_query("SELECT * FROM $compstable WHERE id=?", array($_GETid)); if (!sql_num_rows($competitor)) { sql_close(); die("Competitor id not found!"); } $categories = strict_query("SELECT id FROM $eventstable"); while ($rcat=cased_mysql_fetch_array($categories)) { if (cased_mysql_result($competitor,0,"cat".$rcat["id"])=="X") { toggleReg($_GETid,$rcat["id"]); } } strict_query ("DELETE FROM $compstable WHERE id=?", array($_GETid)); sql_close(); } ?>
{ echo "<a style='cursor:pointer;' onclick='callPage(\"addround.php?id=".$event["id"]."\");'>[add round]</a> "; $b = true; } if ($event["r2"] && !$event[$prevrnd."_open"]) { echo "<a style='cursor:pointer;' onclick='callPage(\"delround.php?id=".$event["id"]."\");'>[remove last round]</a>"; $b = true; } if ($b) echo "<br />"; echo "</DIV></td></tr></table></td>"; } if ($nevents) echo "</tr>"; echo "<tr valign=top>"; $result = strict_query("SELECT categories.* FROM categories LEFT OUTER JOIN $eventstable ON categories.id=$eventstable.id WHERE $eventstable.id IS NULL ORDER BY categories.id"); if (sql_num_rows($result)) { echo "<td><table cellspacing=0 border=0 class=nested><tr valign=top><td style='width:58px;'><img border=0 src='img/corneradd.jpg'></td><td style='width:100%;'><div class=header>Add event</div><DIV style='margin-left:75px;'><form method=get action=\"addevent.php\"><select name=id>"; while($row=cased_mysql_fetch_array($result)) echo "<option value=".$row["id"].">".$row["name"]."</option>"; echo "<input type=submit value=\"add\"></form></DIV></td></tr></table></td>"; } sql_close(); ?> <td><table cellspacing=0 border=0 class=nested><tr valign=top><td style='width:58px;'><img border=0 src='img/cornerimport.jpg'></td><td style='width:100%;'><div class=header>Import .CSV or .XLS registration file</div><DIV style='margin-left:75px;'><form action="importcsv.php" target="w_csvimport" onsubmit="w=window.open('', 'w_csvimport', 'width=600, height='+screen.availHeight+', top=0, left='+(screen.availWidth-600)+', location=0, scrollbars=1, resizable=1');w.focus();" method="post" enctype="multipart/form-data"> <label for="file">file:</label> <input type="file" name="file" id="file" /> <input type="submit" value="submit" style="float:right;"/> </form></DIV></td></tr></table></td></tr>
if (isset($headers[$value])) $headers[$value] = $col; elseif (isset($cats[$value])) { $cats[$col] = $cats[$value]; addEve($cats[$value]); } $col++; } } else { $ncomp++; // $country = strict_query("SELECT id FROM countries WHERE name=?", array($line[$headers["country"]])); if (!sql_num_rows($country)) $errors .= "Country name \"".$line[$headers["country"]]."\" not found in database<br>"; else { $birthday = $line[$headers["birth date"]]; $l = strlen($birthday); if ($l < 10 && $l > 7) { if (strpos($birthday,'-',5)==6) $birthday = substr_replace($birthday,"0",5,0); if (strlen($birthday)<10) $birthday = substr_replace($birthday,"0",8,0); } // $err = addCom( $line[$headers["wca id"]], $line[$headers["name"]],
{ if ($query) $query .= ", "; if ($x>$times || (!$cutpassed && $x>$tries)) $query .= "t".$x."=''"; else { $query .= "t".$x."=?"; $array[count($array)] = $_GET["t".$x]; } } $array[count($array)] = $_GETcat_id; $array[count($array)] = $_GETround; $array[count($array)] = $_GETcomp_id; strict_query( ( $alreadyhastimes ? "UPDATE $timestable SET $query, average='$average', best='$best' WHERE cat_id=? AND round=? AND comp_id=?" : "INSERT INTO $timestable SET $query, average='$average', best='$best', cat_id=?, round=?, comp_id=?" ) , $array ); // echo "OK"; } // sql_close(); } ?>
<? require_once "lib_ref.php"; require_once "lib_get.php"; $comp_id = _GET_num("comp_id"); $cat_id = _GET_num("cat_id"); $round = _GET_num("round"); if ($comp_id && $cat_id && $round) { require_once "db.php"; // strict_query("DELETE FROM $timestable WHERE cat_id=? AND round=? AND comp_id=?", array($cat_id,$round,$comp_id)); // sql_close(); } ?>
$comp_id = _POST_num("comp_id"); $ncmp_id = _POST_num("ncmp_id"); if (!$cat_id || !$round || $round<=1 || !$comp_id) error(0); $qualified = strict_query("SELECT * FROM $regstable WHERE cat_id=? AND round=? AND comp_id=?", array($cat_id,$round,$comp_id)); $qualified = (sql_num_rows($qualified)==1); if (!$qualified) error(1); $noscore = strict_query("SELECT * FROM $timestable WHERE cat_id=? AND round=? AND comp_id=?", array($cat_id,$round,$comp_id)); $noscore = (sql_num_rows($noscore)==0); if (!$noscore) error(2); if ($ncmp_id) { $qualified = strict_query("SELECT * FROM $regstable WHERE cat_id=? AND round=? AND comp_id=?", array($cat_id,$round,$ncmp_id)); $qualified = (!sql_num_rows($qualified)); if (!$qualified) error(3); strict_query("UPDATE $regstable SET comp_id=? WHERE cat_id=? AND round=? AND comp_id=? LIMIT 1", array($ncmp_id,$cat_id,$round,$comp_id)); } else strict_query("DELETE FROM $regstable WHERE cat_id=? AND round=? AND comp_id=? LIMIT 1", array($cat_id,$round,$comp_id)); sql_close(); ?> <!DOCTYPE HTML> <HTML> <BODY onload='opener.location.reload();window.close();'> </BODY> </HTML>
{ require_once "db.php"; // $result = strict_query("SELECT * FROM $eventstable WHERE id=?", array($_GETid)); if (sql_num_rows($result)==1) { $event = cased_mysql_fetch_array($result); $round = 0; do { $round += 1; } while($round < 4 && $event["r".$round]); $rnd = "r".$round; if (!$event[$rnd]) { $prnd = "r".($round-1); if ($event[$prnd."_open"]) $gs = sql_num_rows(strict_query("SELECT round FROM $regstable WHERE cat_id=? AND round=?", array($_GETid,$round-1))); else $gs = $event[$prnd."_groupsize"]; $gs = floor($gs*.75); if ($gs >= 2) { strict_query("UPDATE $eventstable SET ". $rnd."=1, ". $rnd."_format=". $prnd."_format, " .$rnd."_groupsize=". $gs.", " .$rnd."_open=0 WHERE id=?", array($_GETid)); } } } // sql_close(); } ?>
} else $DBH = new PDO(SQL_DSN, SQL_USER, SQL_PASSWORD); } // $count = 0; $result = strict_query("SELECT competitions.*, countries.name AS countryname FROM competitions JOIN countries ON countries.id=competitions.country WHERE CURDATE()>=date_b AND CURDATE()<=date_e ORDER BY date_b, competitions.id"); if (sql_num_rows($result)) listComps("Competitions in progress"); // $result = strict_query("SELECT competitions.*, countries.name AS countryname FROM competitions JOIN countries ON countries.id=competitions.country WHERE CURDATE()>date_e ORDER BY date_b DESC, competitions.id DESC"); if (sql_num_rows($result)) listComps("Past competitions"); // $result = strict_query("SELECT competitions.*, countries.name AS countryname FROM competitions JOIN countries ON countries.id=competitions.country WHERE CURDATE()<date_b ORDER BY date_b, competitions.id"); if (sql_num_rows($result)) listComps("Upcoming competitions"); $result = strict_query("SELECT CURDATE() AS now"); // sql_close(); echo "<div style='color:#444;'><br><br>"; if (!$live) echo "Looking for the <a href='http://".DOMAIN."'>live results</a> site?<br><br>"; echo "WCA delegates and competitions organizers, please <a href='http://www.facebook.com/cubecomps' target=_blank>contact here</a><br><br>"; if (!$live) echo "<iframe src='//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2Fcubecomps&send=false&layout=button_count&width=450&show_faces=false&action=like&colorscheme=light&font&height=21&appId=234783519900971' scrolling='no' frameborder='0' style='border:none; overflow:hidden; width:450px; height:21px;' allowTransparency='true'></iframe><br><br>"; echo "by <a href='http://www.binarema.es' target=_blank>Binarema</a>"; echo "</div></td></tr>"; echo "</td></tr><table>"; ?> </BODY> </HTML>
"uploadbg.php", array("image/jpeg","image/pjpeg"), $maxSize, "image/*", "window.location.reload();"); ?> <p>Only JPEG images of <?php echo $maxSize; ?> Kb maximum. Regardless of the dimension and resolution of the uploaded file, the image will be stretched 95 mm width and 138.5 mm height in order to cover all the scorecard's background. <p> <div class=header>Clear background</div> Click <input type=button value=clear onclick='clearBackground();'> to use a default white background.<p> <? $ofr = strict_query("SELECT id FROM $eventstable WHERE r1_open=1"); if (sql_num_rows($ofr)) { ?> <div class=header>All opened first round scorecards</div> <form action="timessheet.php" target=_blank method="get"><input type=hidden name=aofr value=1>Get <input type=submit value='all scorecards'> for opened first rounds. <span style='font-size:10px;'>(NOTE: You should open rounds as soon as you can.)</span></form> <br> <? } ?> <div class=header>Blank scorecards</div> <form action="timessheet.php" target=_blank method="get">Click to get a set of <input type=submit value='blank scorecards'></form> </td> </tr> </table>
require_once "inc_private.php"; if (preg_match("~^test\\.~i",$_SERVER["HTTP_HOST"])) { if (SQL_DBTYPE == DBTYPE_MYSQL) { mysql_connect(SQL_SERVER, SQL_TEST_USER, SQL_TEST_PASSWORD); mysql_select_db(SQL_TEST_DBNAME); } else $DBH = new PDO(SQL_TEST_DSN, SQL_TEST_USER, SQL_TEST_PASSWORD); } else { if (SQL_DBTYPE == DBTYPE_MYSQL) { mysql_connect(SQL_SERVER, SQL_USER, SQL_PASSWORD); mysql_select_db(SQL_DBNAME); } else $DBH = new PDO(SQL_DSN, SQL_USER, SQL_PASSWORD); } $result = strict_query("SELECT * FROM competitions WHERE id=".$_SESSION['c_id']); if (sql_num_rows($result) != 1) die ("You're not allowed to edit that competition any more (".$_SESSION['c_id'].")"); // $eventstable = "events".$_SESSION["c_id"]; $compstable = "competitors".$_SESSION["c_id"]; $regstable = "registrations".$_SESSION["c_id"]; $timestable = "times".$_SESSION["c_id"]; ?>
$maxrounds = 1; elseif ($gsr1 <= 15) $maxrounds = 2; elseif ($gsr1 <= 99) $maxrounds = 3; else $maxrounds = 4; for ($x=$round+1;$x<=4;$x++) { $registered = floor($registered*.75); if ($x>$maxrounds || $registered<2) { //if (cased_mysql_result($event,0,"r$round")) if (cased_mysql_result($event,0,"r$x")) $set .= ", r$x=0, r" .$x. "_format=0, r" .$x. "_groupsize=0, r" .$x. "_open=0"; else break; } else { if (cased_mysql_result($event,0,"r".$x."_groupsize")>$registered) $set .= ", r".$x."_groupsize=$registered"; } } strict_query("UPDATE $eventstable SET $set WHERE id=?", array($cat_id)); } // sql_close(); } ?>
<? require_once "lib.php"; require_once "lib_ref.php"; require_once "lib_get.php"; $comp_id = _GET_num("comp_id"); $cat_id = _GET_num("cat_id"); $round = _GET_num("round"); if ($comp_id && $cat_id && $round) { require_once "db.php"; // $qualified = sql_num_rows(strict_query("SELECT round FROM $regstable WHERE cat_id=? AND round=? AND comp_id=?", array($cat_id,$round,$comp_id))); if ($qualified) { $alreadyhastimes = sql_num_rows(strict_query("SELECT round FROM $timestable WHERE cat_id=? AND round=? AND comp_id=?", array($cat_id,$round,$comp_id))); $competitor = strict_query("SELECT name FROM $compstable WHERE id=?", array($comp_id)); echo ($alreadyhastimes?"1":"0").cased_mysql_result($competitor,0,"name"); } // sql_close(); } ?>
$result = strict_query($query.$charset); $query = <<<EOT CREATE TABLE IF NOT EXISTS $regstable ( `cat_id` tinyint(2) NOT NULL, `round` tinyint(1) NOT NULL, `comp_id` smallint(3) NOT NULL, PRIMARY KEY (`cat_id`,`round`,`comp_id`) ) EOT; $result = strict_query($query.$charset); $query = <<<EOT CREATE TABLE IF NOT EXISTS $timestable ( `cat_id` tinyint(2) NOT NULL, `round` tinyint(1) NOT NULL, `comp_id` smallint(3) NOT NULL, `t1` varchar(15) NOT NULL, `t2` varchar(15) default NULL, `t3` varchar(15) default NULL, `t4` varchar(15) default NULL, `t5` varchar(15) default NULL, `average` varchar(15) default NULL, `best` varchar(15) NOT NULL, PRIMARY KEY (`cat_id`,`round`,`comp_id`) ) EOT; $result = strict_query($query.$charset); ?>
<? if(!isset($_SESSION)) session_start(); require_once "lib_ref_admin.php"; require_once "db.php"; $result = strict_query("SELECT admin_pw FROM competitions WHERE id=".$_SESSION["c_id"]); if ($result && sql_num_rows($result)==1) { if (cased_mysql_result($result,0,"admin_pw")==$_POST["pw"]) { strict_query("DROP TABLE $eventstable, $compstable, $regstable, $timestable"); sql_close(); $_SESSION["c_pw"]=$_POST["pw"]; header("Location: identification.php\r\n"); } else { $color = "#6b7b71"; $light_color = "#b0c7b4"; $dark_color = "#0a1414"; ?> <!DOCTYPE HTML> <HTML> <HEAD> <TITLE>Erroneous password</TITLE> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <style type="text/css"> body {font-family:verdana,sans-serif;font-size:11px;margin:10px 10px;background-color:<?php echo $color; ?> ;color:#FFFFCC;}