diff --git a/admin/judges.inc.php b/admin/judges.inc.php
index ac6f79d0..6f46aee6 100644
--- a/admin/judges.inc.php
+++ b/admin/judges.inc.php
@@ -8,10 +8,10 @@ function getJudgingTeams()
FROM
judges_teams
WHERE
- judges_teams.year='" . $config['FAIRYEAR'] . "'
+ judges_teams.year=?
ORDER BY
num,name");
- $q->execute();
+ $q->execute([$config['FAIRYEAR']]);
$lastteamid = -1;
$lastteamnum = -1;
@@ -28,8 +28,8 @@ function getJudgingTeams()
$rounds = array();
$tq = $pdo->prepare("SELECT * FROM judges_teams_timeslots_link
LEFT JOIN judges_timeslots ON judges_timeslots.id=judges_teams_timeslots_link.judges_timeslots_id
- WHERE judges_teams_timeslots_link.judges_teams_id='{$r->id}'");
- $tq->execute();
+ WHERE judges_teams_timeslots_link.judges_teams_id=?");
+ $tq->execute([$r->id]);
$teams[$r->id]['timeslots'] = array();
$teams[$r->id]['rounds'] = array();
@@ -39,8 +39,8 @@ function getJudgingTeams()
}
foreach ($rounds as $round_id) {
- $tq = $pdo->prepare("SELECT * FROM judges_timeslots WHERE id='{$round_id}'");
- $tq->execute();
+ $tq = $pdo->prepare("SELECT * FROM judges_timeslots WHERE id=?");
+ $tq->execute([$round_id]);
$teams[$r->id]['rounds'][] = $tq->fetch(PDO::FETCH_ASSOC);
}
@@ -55,12 +55,12 @@ function getJudgingTeams()
judges_teams_link
WHERE
judges_teams_link.users_id=users.id AND
- judges_teams_link.judges_teams_id='$r->id'
+ judges_teams_link.judges_teams_id=?
ORDER BY
captain DESC,
lastname,
firstname");
- $mq->execute();
+ $mq->execute([$r->id]);
show_pdo_errors_if_any($pdo);
$teamlangs = array();
@@ -87,9 +87,9 @@ function getJudgingTeams()
$lq = $pdo->prepare("SELECT projects.language
FROM judges_teams_timeslots_projects_link
LEFT JOIN projects ON judges_teams_timeslots_projects_link.projects_id=projects.id
- WHERE judges_teams_timeslots_projects_link.year='{$config['FAIRYEAR']}' AND
- judges_teams_id='$r->id' AND language!='' ");
- $lq->execute();
+ WHERE judges_teams_timeslots_projects_link.year=? AND
+ judges_teams_id=? AND language!='' ");
+ $lq->execute([$config['FAIRYEAR'],$r->id]);
show_pdo_errors_if_any($pdo);
$projectlangs = array();
while ($lr = $lq->fetch(PDO::FETCH_OBJ)) {
@@ -113,13 +113,13 @@ function getJudgingTeams()
award_types
WHERE
judges_teams_awards_link.award_awards_id=award_awards.id
- AND judges_teams_awards_link.judges_teams_id='$r->id'
+ AND judges_teams_awards_link.judges_teams_id=?
AND award_awards.award_types_id=award_types.id
- AND award_types.year='{$config['FAIRYEAR']}'
+ AND award_types.year=?
ORDER BY
name
");
- $aq->execute();
+ $aq->execute([$r->id,$config['FAIRYEAR']]);
while ($ar = $aq->fetch(PDO::FETCH_OBJ)) {
$teams[$r->id]['awards'][] = array(
'id' => $ar->id,
@@ -144,13 +144,13 @@ function getJudgingTeam($teamid)
FROM
judges_teams
WHERE
- judges_teams.year='" . $config['FAIRYEAR'] . "' AND
- judges_teams.id='$teamid'
+ judges_teams.year=? AND
+ judges_teams.id=?
ORDER BY
num,
name
");
- $q->execute();
+ $q->execute([$config['FAIRYEAR'],$teamid]);
$team = array();
@@ -172,12 +172,12 @@ function getJudgingTeam($teamid)
judges_teams_link
WHERE
judges_teams_link.users_id=users.id AND
- judges_teams_link.judges_teams_id='$r->id'
+ judges_teams_link.judges_teams_id=?
ORDER BY
captain DESC,
lastname,
firstname");
- $mq->execute();
+ $mq->execute([$r->id]);
show_pdo_errors_if_any($pdo);
while ($mr = $mq->fetch(PDO::FETCH_OBJ)) {
@@ -200,13 +200,13 @@ function getJudgingTeam($teamid)
award_types
WHERE
judges_teams_awards_link.award_awards_id=award_awards.id
- AND judges_teams_awards_link.judges_teams_id='$r->id'
+ AND judges_teams_awards_link.judges_teams_id=?
AND award_awards.award_types_id=award_types.id
- AND award_types.year='{$config['FAIRYEAR']}'
+ AND award_types.year=?
ORDER BY
name
");
- $aq->execute();
+ $aq->execute([$r->id,$config['FAIRYEAR']]);
while ($ar = $aq->fetch(PDO::FETCH_OBJ)) {
$team['awards'][] = array(
'id' => $ar->id,
@@ -248,11 +248,11 @@ function judges_load_all()
$ret = array();
$query = "SELECT id FROM users WHERE types LIKE '%judge%'
- AND year='{$config['FAIRYEAR']}'
+ AND year=?
AND deleted='no'
ORDER BY lastname, firstname";
$r = $pdo->prepare($query);
- $r->execute();
+ $r->execute([$config['FAIRYEAR']]);
while ($i = $r->fetch(PDO::FETCH_ASSOC)) {
$u = user_load($i['id']);
if ($u['judge_complete'] == 'no')
diff --git a/admin/judges_teams.php b/admin/judges_teams.php
index 822a3df3..75e06575 100644
--- a/admin/judges_teams.php
+++ b/admin/judges_teams.php
@@ -40,16 +40,16 @@ if (get_value_from_array($_POST, 'action'))
if ($action == 'delete' && get_value_from_array($_GET, 'delete')) {
// ALSO DELETE: team members, timeslots, projects, awards
- $stmt = $pdo->prepare("DELETE FROM judges_teams_link WHERE judges_teams_id='" . $_GET['delete'] . "' AND year='" . $config['FAIRYEAR'] . "'");
- $stmt->execute();
- $stmt = $pdo->prepare("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='" . $_GET['delete'] . "' AND year='" . $config['FAIRYEAR'] . "'");
- $stmt->execute();
- $stmt = $pdo->prepare("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='" . $_GET['delete'] . "' AND year='" . $config['FAIRYEAR'] . "'");
- $stmt->execute();
- $stmt = $pdo->prepare("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='" . $_GET['delete'] . "' AND year='" . $config['FAIRYEAR'] . "'");
- $stmt->execute();
- $stmt = $pdo->prepare("DELETE FROM judges_teams WHERE id='" . $_GET['delete'] . "' AND year='" . $config['FAIRYEAR'] . "'");
- $stmt->execute();
+ $stmt = $pdo->prepare("DELETE FROM judges_teams_link WHERE judges_teams_id=? AND year=?");
+ $stmt->execute([$_GET['delete'],$config['FAIRYEAR']]);
+ $stmt = $pdo->prepare("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id=? AND year=?");
+ $stmt->execute([$_GET['delete'],$config['FAIRYEAR']]);
+ $stmt = $pdo->prepare("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id=? AND year=?");
+ $stmt->execute([$_GET['delete'],$config['FAIRYEAR']]);
+ $stmt = $pdo->prepare("DELETE FROM judges_teams_awards_link WHERE judges_teams_id=? AND year=?");
+ $stmt->execute([$_GET['delete'],$config['FAIRYEAR']]);
+ $stmt = $pdo->prepare("DELETE FROM judges_teams WHERE id=? AND year=?");
+ $stmt->execute([$_GET['delete'],$config['FAIRYEAR']]);
message_push(happy(i18n('Judge team successfully removed, and all of its corresponding members, timeslots, projects and awards unlinked from team')));
}
@@ -58,25 +58,26 @@ if (get_value_or_default($action) == 'deletealldivisional') {
FROM \t
judges_teams
WHERE
- year='" . $config['FAIRYEAR'] . "'
+ year=?
AND autocreate_type_id='1'
");
+ $q2->execute([$config['FAIRYEAR']]);
show_pdo_errors_if_any($pdo);
$numdeleted = 0;
while ($r2 = $q2->fetch(PDO::FETCH_OBJ)) {
// okay now we can start deleting things! whew!
// first delete any linkings to the team
- $stmt = $pdo->prepare("DELETE FROM judges_teams_link WHERE judges_teams_id='$r2->id' AND year='" . $config['FAIRYEAR'] . "'");
- $stmt->execute();
- $stmt = $pdo->prepare("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='$r2->id' AND year='" . $config['FAIRYEAR'] . "'");
- $stmt->execute();
- $stmt = $pdo->prepare("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='$r2->id' AND year='" . $config['FAIRYEAR'] . "'");
- $stmt->execute();
- $stmt = $pdo->prepare("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$r2->id' AND year='" . $config['FAIRYEAR'] . "'");
- $stmt->execute();
- $stmt = $pdo->prepare("DELETE FROM judges_teams WHERE id='$r2->id' AND year='" . $config['FAIRYEAR'] . "'");
- $stmt->execute();
+ $stmt = $pdo->prepare("DELETE FROM judges_teams_link WHERE judges_teams_id=? AND year=?");
+ $stmt->execute([$r2->id,$config['FAIRYEAR']]);
+ $stmt = $pdo->prepare("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id=? AND year=?");
+ $stmt->execute([$r2->id,$config['FAIRYEAR']]);
+ $stmt = $pdo->prepare("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id=? AND year=?");
+ $stmt->execute([$r2->id,$config['FAIRYEAR']]);
+ $stmt = $pdo->prepare("DELETE FROM judges_teams_awards_link WHERE judges_teams_id=? AND year=?");
+ $stmt->execute([$r2->id,$config['FAIRYEAR']]);
+ $stmt = $pdo->prepare("DELETE FROM judges_teams WHERE id=? AND year=?");
+ $stmt->execute([$r2->id,$config['FAIRYEAR']]);
$numdeleted++;
}
if ($numdeleted)
@@ -89,24 +90,24 @@ if (get_value_or_default($action) == 'deleteall') {
$q2 = $pdo->prepare("SELECT *
FROM \tjudges_teams
WHERE
- year='" . $config['FAIRYEAR'] . "'
+ year=?
");
- $q2->execute();
+ $q2->execute([$config['FAIRYEAR']]);
$numdeleted = 0;
while ($r2 = $q2->FETCH(PDO::FETCH_OBJ)) {
// okay now we can start deleting things! whew!
// first delete any linkings to the team
- $stmt = $pdo->prepare("DELETE FROM judges_teams_link WHERE judges_teams_id='$r2->id' AND year='" . $config['FAIRYEAR'] . "'");
- $stmt->execute();
- $stmt = $pdo->prepare("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='$r2->id' AND year='" . $config['FAIRYEAR'] . "'");
- $stmt->execute();
- $stmt = $pdo->prepare("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='$r2->id' AND year='" . $config['FAIRYEAR'] . "'");
- $stmt->execute();
- $stmt = $pdo->prepare("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$r2->id' AND year='" . $config['FAIRYEAR'] . "'");
- $stmt->execute();
- $stmt = $pdo->prepare("DELETE FROM judges_teams WHERE id='$r2->id' AND year='" . $config['FAIRYEAR'] . "'");
- $stmt->execute();
+ $stmt = $pdo->prepare("DELETE FROM judges_teams_link WHERE judges_teams_id=? AND year=?");
+ $stmt->execute([$r2->id,$config['FAIRYEAR']]);
+ $stmt = $pdo->prepare("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id=? AND year=?");
+ $stmt->execute([$r2->id,$config['FAIRYEAR']]);
+ $stmt = $pdo->prepare("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id=? AND year=?");
+ $stmt->execute([$r2->id,$config['FAIRYEAR']]);
+ $stmt = $pdo->prepare("DELETE FROM judges_teams_awards_link WHERE judges_teams_id=? AND year=?");
+ $stmt->execute([$r2->id,$config['FAIRYEAR']]);
+ $stmt = $pdo->prepare("DELETE FROM judges_teams WHERE id=? AND year=?");
+ $stmt->execute([$r2->id,$config['FAIRYEAR']]);
$numdeleted++;
}
if ($numdeleted)
@@ -120,8 +121,8 @@ if ((get_value_or_default($action) == 'save' || $action == 'assign') && $edit) {
// but when we're done, if we're "assign" then go back to edit that team
// if we're save, then go back to the team list
$err = false;
- $q = $pdo->prepare("UPDATE judges_teams SET num='" . $_POST['team_num'] . "', name='" . (stripslashes($_POST['team_name'])) . "' WHERE id='$edit'");
- $q->execute();
+ $q = $pdo->prepare("UPDATE judges_teams SET num=?, name=? WHERE id=?");
+ $q->execute([ $_POST['team_num'],(stripslashes($_POST['team_name'])),$edit]);
if ($pdo->errorInfo()) {
$err = true;
message_push(error($pdo->errorInfo()));
@@ -133,8 +134,8 @@ if ((get_value_or_default($action) == 'save' || $action == 'assign') && $edit) {
// the judges wouldnt know which projects to judge for which award. This doesnt apply for divisions
// because the category/division is obvious based on project numbesr. A divisional judge team could easily
// be assigned to do all of Comp Sci - Junior, Intermediate and Senior without any problems.
- $q = $pdo->prepare("SELECT award_types.type FROM award_awards, award_types WHERE award_awards.award_types_id=award_types.id AND award_awards.id='" . $_POST['award'] . "'");
- $q->execute();
+ $q = $pdo->prepare("SELECT award_types.type FROM award_awards, award_types WHERE award_awards.award_types_id=award_types.id AND award_awards.id=?");
+ $q->execute([$_POST['award']]);
$aw = $q->fetch(PDO::FETCHH_OBJ);
$addaward = true;
@@ -144,12 +145,12 @@ if ((get_value_or_default($action) == 'save' || $action == 'assign') && $edit) {
award_awards,
award_types
WHERE
- judges_teams_awards_link.judges_teams_id='$edit'
+ judges_teams_awards_link.judges_teams_id=?
AND judges_teams_awards_link.award_awards_id=award_awards.id
AND award_awards.award_types_id=award_types.id
AND award_types.type='Special'
");
- $q->exxecute();
+ $q->exxecute([$edit]);
$r = $q->fetch(PDO::FETCHH_OBJ);
echo "special awards: $r->num";
if ($r->num) {
@@ -162,8 +163,8 @@ if ((get_value_or_default($action) == 'save' || $action == 'assign') && $edit) {
if ($addaward) {
// link up the award
- $stmt = $pdo->prepare("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,year) VALUES ('" . $_POST['award'] . "','$edit','" . $config['FAIRYEAR'] . "')");
- $stmt->execute();
+ $stmt = $pdo->prepare("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,year) VALUES (?,?,?)");
+ $stmt->execute([$_POST['award'],$edit,$config['FAIRYEAR']]);
message_push(happy(i18n('Award assigned to team')));
}
}
@@ -182,8 +183,8 @@ if ((get_value_or_default($action) == 'save' || $action == 'assign') && $edit) {
}
if (get_value_or_default($action) == 'unassign') {
- $stmt = $pdo->prepare("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$edit' AND award_awards_id='" . $_GET['unassign'] . "' AND year='" . $config['FAIRYEAR'] . "'");
- $stmt->execute();
+ $stmt = $pdo->prepare("DELETE FROM judges_teams_awards_link WHERE judges_teams_id=? AND award_awards_id=? AND year=?");
+ $stmt->execute([$edit,$_GET['unassign'],$config['FAIRYEAR']]);
message_push(happy(i18n('Award unassigned from judge team')));
// keep editing the same team
$action = 'edit';
@@ -191,8 +192,8 @@ if (get_value_or_default($action) == 'unassign') {
if (get_value_or_default($action) == 'createall') {
// first make sure we dont have any non-divisional award teams (dont want people hitting refresh and adding all the teams twice
- $q = $pdo->prepare("SELECT COUNT(*) AS c FROM judges_teams WHERE autocreate_type_id!='1' AND year='" . $config['FAIRYEAR'] . "'");
- $q->execute();
+ $q = $pdo->prepare("SELECT COUNT(*) AS c FROM judges_teams WHERE autocreate_type_id!='1' AND year=?");
+ $q->execute([$config['FAIRYEAR']]);
$r = $q->fetch(PDO::FETCH_OBJ);
if ($r->c) {
message_push(error(i18n("Cannot 'Create All' teams when any divisional teams currently exist. Try deleting all existing non-divisional teams first.")));
@@ -207,18 +208,18 @@ if (get_value_or_default($action) == 'createall') {
award_types
WHERE \t
award_awards.award_types_id=award_types.id
- AND award_awards.year='" . $config['FAIRYEAR'] . "'
- AND award_types.year='" . $config['FAIRYEAR'] . "'
+ AND award_awards.year=?
+ AND award_types.year=?
AND award_types_id!='1'
ORDER BY
award_types_order,
award_awards.order,
name");
- $q->execute();
+ $q->execute([$config['FAIRYEAR'],$config['FAIRYEAR']]);
// startat
- $q2 = $pdo->prepare("SELECT MAX(num) AS lastnum FROM judges_teams WHERE year='{$config['FAIRYEAR']}'");
- $q2->execute();
+ $q2 = $pdo->prepare("SELECT MAX(num) AS lastnum FROM judges_teams WHERE year=?");
+ $q2->execute([$config['FAIRYEAR']]);
$r2 = $q2->fetch(PDO::FETCH_OBJ);
if ($r2->lastnum)
$num = $r2->lastnum + 1;
@@ -239,8 +240,8 @@ if (get_value_or_default($action) == 'createall') {
$team_id = $pdo->lastInsertId();
if ($team_id) {
// now link the new team to the award
- $stmt = $pdo->prepare("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,year) VALUES ('$r->id','$team_id','" . $config['FAIRYEAR'] . "')");
- $stmt->execute();
+ $stmt = $pdo->prepare("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,year) VALUES (?,?,?)");
+ $stmt->execute([$r->id,$team_id,$config['FAIRYEAR']]);
message_push(happy(i18n('Created team #%1: %2', array($num, $name))));
} else {
message_push(error(i18n('Error creating team #%1: %2', array($num, $name))));
@@ -251,8 +252,8 @@ if (get_value_or_default($action) == 'createall') {
}
if (get_value_or_default($action) == 'add' && $_GET['num']) {
- $stmt = $pdo->prepare("INSERT INTO judges_teams(num,year) VALUES ('" . $_GET['num'] . "','" . $config['FAIRYEAR'] . "')");
- $stmt->execute();
+ $stmt = $pdo->prepare("INSERT INTO judges_teams(num,year) VALUES (?,?)");
+ $stmt->execute([$_GET['num'],$config['FAIRYEAR']]);
show_pdo_errors_if_any($pdo);
$edit = $pdo->lastInsertId();
$action = 'edit';
@@ -342,10 +343,10 @@ function addclicked()
)
LEFT JOIN judges_teams_awards_link ON award_awards.id = judges_teams_awards_link.award_awards_id
WHERE
- award_awards.year='" . $config['FAIRYEAR'] . "' AND
+ award_awards.year=? AND
judges_teams_awards_link.award_awards_id IS NULL
AND award_types.id=award_awards.award_types_id
- AND award_types.year='{$config['FAIRYEAR']}'
+ AND award_types.year=?
ORDER BY
award_type_order,
name";
@@ -353,7 +354,7 @@ function addclicked()
echo '