diff --git a/admin/registration_receivedforms.php b/admin/registration_receivedforms.php index cc32bef8..d1cd724a 100644 --- a/admin/registration_receivedforms.php +++ b/admin/registration_receivedforms.php @@ -77,7 +77,7 @@ if (get_value_from_array($_POST, 'action') == 'received' && get_value_from_array FROM projects,projectcategories,projectdivisions WHERE - projects.registrations_id='$reg_id' + projects.registrations_id=? AND projects.projectcategories_id=projectcategories.id AND @@ -87,7 +87,7 @@ if (get_value_from_array($_POST, 'action') == 'received' && get_value_from_array AND projectdivisions.year=projects.year "); - $q->execute(); + $q->execute([$reg_id]); show_pdo_errors_if_any($pdo); $projectinfo = $q->fetch(PDO::FETCH_OBJ); @@ -116,11 +116,11 @@ if (get_value_from_array($_POST, 'action') == 'received' && get_value_from_array FROM students,schools WHERE - students.registrations_id='$reg_id' + students.registrations_id=? AND students.schools_id=schools.id "); - $q->execute(); + $q->execute([$reg_id]); $studnum = 1; while ($studentinfo = $q->fetch(PDO::FETCH_OBJ)) { @@ -193,14 +193,14 @@ if (get_value_from_array($_POST, 'action') == 'received' && get_value_from_array $checkNumQuery = $pdo->prepare("SELECT projectnumber FROM projects, registrations WHERE projects.registrations_id = registrations.id - AND num='$regnum' - AND registrations.year='{$config['FAIRYEAR']}'"); - $checkNumQuery->execute(); + AND num=? + AND registrations.year=?"); + $checkNumQuery->execute([$regnum,$config['FAIRYEAR']]); $checkNumResults = $checkNumQuery->fetch(PDO::FETCH_OBJ); $projectnum = $checkNumResults->projectnumber; - $q = $pdo->prepare("SELECT id FROM registrations WHERE num='$regnum' AND year='{$config['FAIRYEAR']}'"); - $q->execute(); + $q = $pdo->prepare("SELECT id FROM registrations WHERE num=? AND year=?"); + $q->execute([$regnum, $config['FAIRYEAR']]); $r = $q->fetch(PDO::FETCH_OBJ); $reg_id = $r->id; @@ -218,8 +218,8 @@ if (get_value_from_array($_POST, 'action') == 'received' && get_value_from_array if ($_POST['action'] == 'receivedyes') { // actually set it to 'complete' - $stmt = $pdo->prepare("UPDATE registrations SET status='complete' WHERE num='$regnum' AND year='{$config['FAIRYEAR']}'"); - $stmt->execute(); + $stmt = $pdo->prepare("UPDATE registrations SET status='complete' WHERE num=? AND year=?"); + $stmt->execute([$regnum,$config['FAIRYEAR']]); foreach ($recipients AS $recip) { $to = $recip['to']; $subsub = array(); @@ -238,8 +238,8 @@ if (get_value_from_array($_POST, 'action') == 'received' && get_value_from_array echo happy(i18n('Registration of form %1 successfully completed', array($regnum))); } else if ($_POST['action'] == 'receivedyesnocash') { // actually set it to 'paymentpending' - $stmt = $pdo->prepare("UPDATE registrations SET status='paymentpending' WHERE num='$regnum' AND year='{$config['FAIRYEAR']}'"); - $stmt->execute(); + $stmt = $pdo->prepare("UPDATE registrations SET status='paymentpending' WHERE num=? AND year=?"); + $stmt->execute([$regnum,$config['FAIRYEAR']]); foreach ($recipients AS $recip) { $to = $recip['to']; $subsub = array(); @@ -261,13 +261,13 @@ if (get_value_from_array($_POST, 'action') == 'received' && get_value_from_array echo notice(i18n('Registration of form %1 cancelled', array($_POST['registration_number']))); } else if (get_value_from_array($_GET, 'action') == 'unregister' && get_value_from_array($_GET, 'registration_number')) { $reg_num = intval(trim($_GET['registration_number'])); - $q = $pdo - prepare("SELECT registrations.id AS reg_id, projects.id AS proj_id FROM projects,registrations WHERE projects.registrations_id=registrations.id AND registrations.year='{$config['FAIRYEAR']}' AND registrations.num='$reg_num'"); - $q->execute(); + $q = $pdo->prepare("SELECT registrations.id AS reg_id, projects.id AS proj_id FROM projects,registrations WHERE projects.registrations_id=registrations.id AND registrations.year=? AND registrations.num=?"); + $q->execute([$config['FAIRYEAR'],$reg_num]); $r = $q->fetch(PDO::FETCH_OBJ); - $stmt = $pdo->prepare("UPDATE projects SET projectnumber=null, projectsort=null, projectnumber_seq=0, projectsort_seq=0 WHERE id='$r->proj_id' AND year='{$config['FAIRYEAR']}'"); - $stmt->execute(); - $stmt = $pdo->prepare("UPDATE registrations SET status='open' WHERE id='$r->reg_id' AND year='{$config['FAIRYEAR']}'"); - $stmt->execute(); + $stmt = $pdo->prepare("UPDATE projects SET projectnumber=null, projectsort=null, projectnumber_seq=0, projectsort_seq=0 WHERE id=? AND year=?"); + $stmt->execute([$r->proj_id,$config['FAIRYEAR']]); + $stmt = $pdo->prepare("UPDATE registrations SET status='open' WHERE id=? AND year=?"); + $stmt->execute([$r->reg_id,$config['FAIRYEAR']]); echo happy(i18n('Successfully unregistered project')); } @@ -305,9 +305,9 @@ if ($showformatbottom) { if (get_value_from_array($_POST, 'action') == 'receive_all') { // Grab all projects that don't have project numbers. Status should therefor be open or new but not complete - $query_noprojectnumber = $pdo->prepare('SELECT * FROM projects WHERE projectnumber IS NULL AND year =' . $config['FAIRYEAR'] . ''); + $query_noprojectnumber = $pdo->prepare('SELECT * FROM projects WHERE projectnumber IS NULL AND year =?'); // Define arrays to append to later - $query_noprojectnumber->execute(); + $query_noprojectnumber->execute([$config['FAIRYEAR']]); $completed_students = array(); $incomplete_students = array(); $newstatus_students = array(); @@ -315,8 +315,8 @@ if (get_value_from_array($_POST, 'action') == 'receive_all') { // loop through each project that doesn't have a project number while ($studentproject = $query_noprojectnumber->fetch(PDO::FETCH_ASSOC)) { // Grab registration information about the current project - $q = $pdo->prepare("SELECT * FROM registrations WHERE id='" . $studentproject['registrations_id'] . "' AND year='" . $config['FAIRYEAR'] . "'"); - $q->execute(); + $q = $pdo->prepare("SELECT * FROM registrations WHERE id=? AND year=?"); + $q->execute([$studentproject['registrations_id'],$config['FAIRYEAR']]); $r = $q->fetch(PDO::FETCH_OBJ); $reg_id = $r->id; $reg_num = $r->num; @@ -347,18 +347,18 @@ if (get_value_from_array($_POST, 'action') == 'receive_all') { ) { // Generate project number and update it in data base list($projectnumber, $ps, $pns, $pss) = generateProjectNumber($reg_id); - $stmt = $pdo->prepare("UPDATE projects SET projectnumber='$projectnumber', - projectsort='$ps',projectnumber_seq='$pns',projectsort_seq='$pss' - WHERE registrations_id='$reg_id' AND year='{$config['FAIRYEAR']}'"); - $stmt->execute(); + $stmt = $pdo->prepare("UPDATE projects SET projectnumber=?, + projectsort=?,projectnumber_seq=?,projectsort_seq=? + WHERE registrations_id=? AND year=?"); + $stmt->execute([$projectnumber,$ps,$pns,$pss,$reg_id,$config['FAIRYEAR']]); // email stuff // get all students with this registration number // $recipients=getEmailRecipientsForRegistration($reg_id); // Set status to 'complete' - $stmt = $pdo->prepare("UPDATE registrations SET status='complete' WHERE num='$reg_num' AND year='{$config['FAIRYEAR']}'"); - $stmt->execute(); + $stmt = $pdo->prepare("UPDATE registrations SET status='complete' WHERE num=? AND year=?"); + $stmt->execute([$reg_num,$config['FAIRYEAR']]); /*foreach($recipients AS $recip) { $to=$recip['to']; $subsub=array(); diff --git a/admin/registration_stats.php b/admin/registration_stats.php index dd4383bb..6ac902e0 100644 --- a/admin/registration_stats.php +++ b/admin/registration_stats.php @@ -63,13 +63,13 @@ foreach ($status_str as $s => $str) { echo ''; echo ''; -$q = $pdo->prepare("SELECT * FROM projectcategories WHERE year='$year' ORDER BY id"); -$q->execute(); +$q = $pdo->prepare("SELECT * FROM projectcategories WHERE year=? ORDER BY id"); +$q->execute([$year]); while ($r = $q->fetch(PDO::FETCH_OBJ)) $cats[$r->id] = $r->category; -$q = $pdo->prepare("SELECT * FROM projectdivisions WHERE year='$year' ORDER BY id"); -$q->execute(); +$q = $pdo->prepare("SELECT * FROM projectdivisions WHERE year=? ORDER BY id"); +$q->execute([$year]); while ($r = $q->fetch(PDO::FETCH_OBJ)) $divs[$r->id] = $r->division; @@ -133,12 +133,12 @@ $q = $pdo->prepare("SELECT registrations.id AS reg_id, left outer join projects on projects.registrations_id=registrations.id WHERE 1 - AND registrations.year='$year' - $wherestatus + AND registrations.year=? + ? ORDER BY - $ORDERBY + ? "); -$q->execute(); +$q->execute([$year,$wherestatus,$ORDERBY]); show_pdo_errors_if_any($pdo); $stats_totalprojects = 0; @@ -188,10 +188,11 @@ while ($r = $q->fetch(PDO::FETCH_OBJ)) { FROM students,schools WHERE - students.registrations_id='$r->reg_id' + students.registrations_id=? AND students.schools_id=schools.id "); + $sq->execute([$r->reg_id]); show_pdo_errors_if_any($pdo); $studnum = 1; diff --git a/admin/registration_webconsent.php b/admin/registration_webconsent.php index d531ef49..43bcea80 100644 --- a/admin/registration_webconsent.php +++ b/admin/registration_webconsent.php @@ -44,12 +44,12 @@ if (get_value_from_array($_POST, 'changed')) { $webphoto = get_value_from_2d_array($_POST, 'webphoto', $id) == 'yes' ? 'yes' : 'no'; $stmt = $pdo->prepare("UPDATE students SET - webfirst='$webfirst', - weblast='$weblast', - webphoto='$webphoto' + webfirst=?, + weblast=?, + webphoto=? WHERE - id='$id'"); - $stmt->execute(); + id=?"); + $stmt->execute([$webfirst,$weblast,$webphoto,$id]); } } @@ -87,12 +87,12 @@ $sq = $pdo->prepare("SELECT students.firstname, students.registrations_id=registrations.id AND\t( registrations.status = 'complete' OR registrations.status='paymentpending' ) AND\tprojects.registrations_id=registrations.id - AND \tregistrations.year='" . $config['FAIRYEAR'] . "' - AND \tprojects.year='" . $config['FAIRYEAR'] . "' - AND \tstudents.year='" . $config['FAIRYEAR'] . "' + AND \tregistrations.year=? + AND \tprojects.year=? + AND \tstudents.year=? ORDER BY projectnumber "); -$sq->execute(); +$sq->execute([$config['FAIRYEAR'],$config['FAIRYEAR'],$config['FAIRYEAR']]); show_pdo_errors_if_any($pdo); echo '