mirror of
https://github.com/jakejarvis/spoons.git
synced 2025-04-26 12:18:27 -04:00
change all database stuff to MySQLi
This commit is contained in:
parent
c89c6821e0
commit
438a9db194
@ -4,11 +4,11 @@ include('db_connect.php');
|
|||||||
include('functions.php');
|
include('functions.php');
|
||||||
|
|
||||||
if($_POST) {
|
if($_POST) {
|
||||||
$order = getHighestOrderNum() + 1;
|
$order = getHighestOrderNum($conn) + 1;
|
||||||
for($i = 0; $i < $_POST['num']; $i++) {
|
for($i = 0; $i < $_POST['num']; $i++) {
|
||||||
if($_POST['first-' . $i] != "") {
|
if($_POST['first-' . $i] != "") {
|
||||||
if(!$_POST['staff-' . $i]) $_POST['staff-' . $i] = 0;
|
if(!$_POST['staff-' . $i]) $_POST['staff-' . $i] = 0;
|
||||||
mysql_query('INSERT INTO spooners (first, last, order_num, staff) VALUES ("' . mysql_real_escape_string($_POST['first-' . $i]) . '", "' . mysql_real_escape_string($_POST['last-' . $i]) . '", ' . $order . ', ' . mysql_real_escape_string($_POST['staff-' . $i]) . ')') or die(mysql_error());
|
mysqli_query($conn, 'INSERT INTO spooners (first, last, order_num, staff) VALUES ("' . mysqli_real_escape_string($conn, $_POST['first-' . $i]) . '", "' . mysqli_real_escape_string($conn, $_POST['last-' . $i]) . '", ' . $order . ', ' . mysqli_real_escape_string($conn, $_POST['staff-' . $i]) . ')') or die(mysqli_error($conn));
|
||||||
$order++;
|
$order++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
/* site config */
|
/* site config */
|
||||||
$site_url = "http://spoons.scrabblerocks.com";
|
$site_url = "https://idspoons.herokuapp.com";
|
||||||
$site_password = "asdf1234";
|
$site_password = "asdf1234";
|
||||||
|
|
||||||
/* database config */
|
if(isset(getenv('JAWSDB_URL'))) {
|
||||||
$db_host = "loalhost";
|
$db_parts = parse_url(getenv('JAWSDB_URL'));
|
||||||
$db_port = 8889;
|
|
||||||
$db_user = "root";
|
$db_host = $db_parts['host'];
|
||||||
$db_pass = "lol";
|
$db_user = $db_parts['user'];
|
||||||
$db_name = "spoons";
|
$db_pass = $db_parts['pass'];
|
||||||
|
$db_name = ltrim($db_parts['path'],'/');
|
||||||
|
$db_port = 3306;
|
||||||
|
} else {
|
||||||
|
$db_host = "localhost";
|
||||||
|
$db_port = 8889;
|
||||||
|
$db_user = "root";
|
||||||
|
$db_pass = "lol";
|
||||||
|
$db_name = "spoons";
|
||||||
|
}
|
||||||
|
|
||||||
$timezone_number = "-4:00";
|
$timezone_number = "-4:00";
|
||||||
$timezone_name = "America/New_York";
|
$timezone_name = "America/New_York";
|
||||||
|
|
||||||
date_default_timezone_set($timezone_name);
|
date_default_timezone_set($timezone_name);
|
||||||
?>
|
?>
|
||||||
|
@ -1,6 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
mysql_connect($db_host . ":" . $db_port, $db_user, $db_pass);
|
//mysql_connect($db_host . ":" . $db_port, $db_user, $db_pass);
|
||||||
mysql_select_db($db_name);
|
//mysql_select_db($db_name);
|
||||||
|
|
||||||
mysql_query('SET time_zone = "' . $timezone_number . '"');
|
//mysql_query('SET time_zone = "' . $timezone_number . '"');
|
||||||
?>
|
|
||||||
|
|
||||||
|
// Create connection
|
||||||
|
$conn = mysqli_connect($db_host, $db_user, $db_pass, $db_name);
|
||||||
|
|
||||||
|
// Check connection
|
||||||
|
if (!$conn) {
|
||||||
|
die("Connection failed: " . mysqli_connect_error());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
@ -45,20 +45,6 @@
|
|||||||
<script src="<?php echo $site_url ?>/assets/js/bootstrap-collapse.js"></script>
|
<script src="<?php echo $site_url ?>/assets/js/bootstrap-collapse.js"></script>
|
||||||
<script src="<?php echo $site_url ?>/assets/js/bootstrap-carousel.js"></script>
|
<script src="<?php echo $site_url ?>/assets/js/bootstrap-carousel.js"></script>
|
||||||
<script src="<?php echo $site_url ?>/assets/js/bootstrap-typeahead.js"></script>
|
<script src="<?php echo $site_url ?>/assets/js/bootstrap-typeahead.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
var _gauges = _gauges || [];
|
|
||||||
(function() {
|
|
||||||
var t = document.createElement('script');
|
|
||||||
t.type = 'text/javascript';
|
|
||||||
t.async = true;
|
|
||||||
t.id = 'gauges-tracker';
|
|
||||||
t.setAttribute('data-site-id', '517087f5613f5d77c300005e');
|
|
||||||
t.src = '//secure.gaug.es/track.js';
|
|
||||||
var s = document.getElementsByTagName('script')[0];
|
|
||||||
s.parentNode.insertBefore(t, s);
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||||
|
@ -1,64 +1,64 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
function logSMS($message, $response, $number) {
|
function logSMS($message, $response, $number, $conn) {
|
||||||
mysql_query('INSERT INTO texts (message, response, phone_number) VALUES ("' . mysql_real_escape_string($message) . '", "' . mysql_real_escape_string($response) . '", "' . mysql_real_escape_string($number) . '")');
|
mysqli_query($conn, 'INSERT INTO texts (message, response, phone_number) VALUES ("' . mysqli_real_escape_string($conn, $message) . '", "' . mysqli_real_escape_string($conn, $response) . '", "' . mysqli_real_escape_string($conn, $number) . '")');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNumTotalSpooners() {
|
function getNumTotalSpooners($conn) {
|
||||||
$result = mysql_query("SELECT id FROM spooners");
|
$result = mysqli_query($conn, "SELECT id FROM spooners");
|
||||||
return mysql_num_rows($result);
|
return mysqli_num_rows($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNumActiveSpooners() {
|
function getNumActiveSpooners($conn) {
|
||||||
$result = mysql_query("SELECT id FROM spooners WHERE spooned = 0");
|
$result = mysqli_query($conn, "SELECT id FROM spooners WHERE spooned = 0");
|
||||||
return mysql_num_rows($result);
|
return mysqli_num_rows($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNumActiveCamperSpooners() {
|
function getNumActiveCamperSpooners($conn) {
|
||||||
$result = mysql_query("SELECT id FROM spooners WHERE spooned = 0 AND staff = 0");
|
$result = mysqli_query($conn, "SELECT id FROM spooners WHERE spooned = 0 AND staff = 0");
|
||||||
return mysql_num_rows($result);
|
return mysqli_num_rows($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNumActiveStaffSpooners() {
|
function getNumActiveStaffSpooners($conn) {
|
||||||
$result = mysql_query("SELECT id FROM spooners WHERE spooned = 0 AND staff = 1");
|
$result = mysqli_query($conn, "SELECT id FROM spooners WHERE spooned = 0 AND staff = 1");
|
||||||
return mysql_num_rows($result);
|
return mysqli_num_rows($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLowestOrderNum() {
|
function getLowestOrderNum($conn) {
|
||||||
$result = mysql_query("SELECT order_num FROM spooners WHERE spooned = 0 ORDER BY order_num ASC LIMIT 1");
|
$result = mysqli_query($conn, "SELECT order_num FROM spooners WHERE spooned = 0 ORDER BY order_num ASC LIMIT 1");
|
||||||
$spooner = mysql_fetch_array($result);
|
$spooner = mysqli_fetch_array($result);
|
||||||
return $spooner['order_num'];
|
return $spooner['order_num'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getHighestOrderNum() {
|
function getHighestOrderNum($conn) {
|
||||||
$result = mysql_query("SELECT order_num FROM spooners WHERE spooned = 0 ORDER BY order_num DESC LIMIT 1");
|
$result = mysqli_query($conn, "SELECT order_num FROM spooners WHERE spooned = 0 ORDER BY order_num DESC LIMIT 1");
|
||||||
$spooner = mysql_fetch_array($result);
|
$spooner = mysqli_fetch_array($result);
|
||||||
return $spooner['order_num'];
|
return $spooner['order_num'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCamperIDs(){
|
function getCamperIDs($conn){
|
||||||
$camper_ids = array();
|
$camper_ids = array();
|
||||||
|
|
||||||
$result = mysql_query("SELECT id FROM spooners WHERE spooned = 0 AND staff = 0 ORDER BY id");
|
$result = mysqli_query($conn, "SELECT id FROM spooners WHERE spooned = 0 AND staff = 0 ORDER BY id");
|
||||||
while($spooner = mysql_fetch_array($result)) {
|
while($spooner = mysqli_fetch_array($result)) {
|
||||||
array_push($camper_ids, $spooner['id']);
|
array_push($camper_ids, $spooner['id']);
|
||||||
}
|
}
|
||||||
return $camper_ids;
|
return $camper_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStaffIDs(){
|
function getStaffIDs($conn){
|
||||||
$staff_ids = array();
|
$staff_ids = array();
|
||||||
|
|
||||||
$result = mysql_query("SELECT id FROM spooners WHERE spooned = 0 AND staff = 1 ORDER BY id");
|
$result = mysqli_query($conn, "SELECT id FROM spooners WHERE spooned = 0 AND staff = 1 ORDER BY id");
|
||||||
while($spooner = mysql_fetch_array($result)) {
|
while($spooner = mysqli_fetch_array($result)) {
|
||||||
array_push($staff_ids, $spooner['id']);
|
array_push($staff_ids, $spooner['id']);
|
||||||
}
|
}
|
||||||
return $staff_ids;
|
return $staff_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
function shuffleSpooners() {
|
function shuffleSpooners($conn) {
|
||||||
$camper_ids = getCamperIDs();
|
$camper_ids = getCamperIDs($conn);
|
||||||
$staff_ids = getStaffIDs();
|
$staff_ids = getStaffIDs($conn);
|
||||||
|
|
||||||
shuffle($camper_ids);
|
shuffle($camper_ids);
|
||||||
shuffle($staff_ids);
|
shuffle($staff_ids);
|
||||||
@ -70,7 +70,7 @@ function shuffleSpooners() {
|
|||||||
$spacing = round(count($camper_ids)/count($staff_ids))+1;
|
$spacing = round(count($camper_ids)/count($staff_ids))+1;
|
||||||
|
|
||||||
|
|
||||||
while(count($random_ids) < getNumActiveSpooners()){
|
while(count($random_ids) < getNumActiveSpooners($conn)){
|
||||||
for($i = 0; $i < $spacing-1; $i++){
|
for($i = 0; $i < $spacing-1; $i++){
|
||||||
array_push($random_ids, array_pop($camper_ids));
|
array_push($random_ids, array_pop($camper_ids));
|
||||||
}
|
}
|
||||||
@ -89,48 +89,48 @@ function shuffleSpooners() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$result = mysql_query("SELECT id FROM spooners WHERE spooned = 0 ORDER BY id");
|
$result = mysqli_query($conn, "SELECT id FROM spooners WHERE spooned = 0 ORDER BY id");
|
||||||
|
|
||||||
for ($i=0; $spooner = mysql_fetch_array($result); $i++) {
|
for ($i=0; $spooner = mysqli_fetch_array($result); $i++) {
|
||||||
mysql_query("UPDATE spooners SET order_num = " . $i . " WHERE id = " . $random_ids[$i]);
|
mysqli_query($conn, "UPDATE spooners SET order_num = " . $i . " WHERE id = " . $random_ids[$i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIDByLooseName($subject) {
|
function getIDByLooseName($subject, $conn) {
|
||||||
$subject = trim($subject);
|
$subject = trim($subject);
|
||||||
$subject = strtolower($subject);
|
$subject = strtolower($subject);
|
||||||
$subject = str_replace(".", "", $subject); // remove periods
|
$subject = str_replace(".", "", $subject); // remove periods
|
||||||
|
|
||||||
// subject only contains one word
|
// subject only contains one word
|
||||||
if(substr_count($subject, " ") == 0) {
|
if(substr_count($subject, " ") == 0) {
|
||||||
$result = mysql_query('SELECT id FROM spooners WHERE LOWER(first) = "' . $subject . '"');
|
$result = mysqli_query($conn, 'SELECT id FROM spooners WHERE LOWER(first) = "' . $subject . '"');
|
||||||
if(mysql_num_rows($result) == 1) {
|
if(mysqli_num_rows($result) == 1) {
|
||||||
$spooner = mysql_fetch_array($result);
|
$spooner = mysqli_fetch_array($result);
|
||||||
return $spooner['id']; // MATCH!
|
return $spooner['id']; // MATCH!
|
||||||
} else if(mysql_num_rows($result) > 1) {
|
} else if(mysqli_num_rows($result) > 1) {
|
||||||
return "multiple"; // more than one found
|
return "multiple"; // more than one found
|
||||||
}
|
}
|
||||||
} else if(substr_count($subject, " ") == 1) { // one space, let's assume first space last
|
} else if(substr_count($subject, " ") == 1) { // one space, let's assume first space last
|
||||||
$first = substr($subject, 0, strpos($subject, " "));
|
$first = substr($subject, 0, strpos($subject, " "));
|
||||||
$last = substr($subject, strpos($subject, " ") + 1);
|
$last = substr($subject, strpos($subject, " ") + 1);
|
||||||
if(strlen($last) == 1) { // last initial
|
if(strlen($last) == 1) { // last initial
|
||||||
$result = mysql_query('SELECT id FROM spooners WHERE LOWER(first) = "' . $first . '" AND LOWER(SUBSTRING(last, 1, 1)) = "' . $last . '"');
|
$result = mysqli_query($conn, 'SELECT id FROM spooners WHERE LOWER(first) = "' . $first . '" AND LOWER(SUBSTRING(last, 1, 1)) = "' . $last . '"');
|
||||||
if(mysql_num_rows($result) > 0) {
|
if(mysqli_num_rows($result) > 0) {
|
||||||
$spooner = mysql_fetch_array($result);
|
$spooner = mysqli_fetch_array($result);
|
||||||
return $spooner['id']; // MATCH!
|
return $spooner['id']; // MATCH!
|
||||||
}
|
}
|
||||||
} else { // full last name
|
} else { // full last name
|
||||||
$result = mysql_query('SELECT id FROM spooners WHERE LOWER(first) = "' . $first . '" AND LOWER(last) = "' . $last . '"');
|
$result = mysqli_query($conn, 'SELECT id FROM spooners WHERE LOWER(first) = "' . $first . '" AND LOWER(last) = "' . $last . '"');
|
||||||
if(mysql_num_rows($result) > 0) {
|
if(mysqli_num_rows($result) > 0) {
|
||||||
$spooner = mysql_fetch_array($result);
|
$spooner = mysqli_fetch_array($result);
|
||||||
return $spooner['id']; // MATCH!
|
return $spooner['id']; // MATCH!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// still not found, take whole subject and compare to concatenated first + last in database
|
// still not found, take whole subject and compare to concatenated first + last in database
|
||||||
$result = mysql_query('SELECT id FROM spooners WHERE LOWER(CONCAT_WS(" ", first, last)) = "' . $subject . '"');
|
$result = mysqli_query($conn, 'SELECT id FROM spooners WHERE LOWER(CONCAT_WS(" ", first, last)) = "' . $subject . '"');
|
||||||
if(mysql_num_rows($result) > 0) {
|
if(mysqli_num_rows($result) > 0) {
|
||||||
$spooner = mysql_fetch_array($result);
|
$spooner = mysqli_fetch_array($result);
|
||||||
return $spooner['id'];
|
return $spooner['id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,11 +138,11 @@ function getIDByLooseName($subject) {
|
|||||||
return "none";
|
return "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNameByID($id) {
|
function getNameByID($id, $conn) {
|
||||||
if($id) {
|
if($id) {
|
||||||
$result = mysql_query("SELECT first, last FROM spooners WHERE id = " . $id) or die(mysql_error());
|
$result = mysqli_query($conn, "SELECT first, last FROM spooners WHERE id = " . $id) or die(mysqli_error());
|
||||||
if(mysql_num_rows($result) == 1) {
|
if(mysqli_num_rows($result) == 1) {
|
||||||
$spooner = mysql_fetch_array($result);
|
$spooner = mysqli_fetch_array($result);
|
||||||
$name = $spooner['first'];
|
$name = $spooner['first'];
|
||||||
if($spooner['last']) $name .= ' ' . $spooner['last'];
|
if($spooner['last']) $name .= ' ' . $spooner['last'];
|
||||||
return $name;
|
return $name;
|
||||||
@ -152,64 +152,64 @@ function getNameByID($id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFirstNameByID($id) {
|
function getFirstNameByID($id, $conn) {
|
||||||
$result = mysql_query("SELECT first FROM spooners WHERE id = " . $id);
|
$result = mysqli_query($conn, "SELECT first FROM spooners WHERE id = " . $id);
|
||||||
$spooner = mysql_fetch_array($result);
|
$spooner = mysqli_fetch_array($result);
|
||||||
return $spooner['first'];
|
return $spooner['first'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTargetByID($id) {
|
function getTargetByID($id, $conn) {
|
||||||
$result = mysql_query("SELECT order_num FROM spooners WHERE id = " . $id);
|
$result = mysqli_query($conn, "SELECT order_num FROM spooners WHERE id = " . $id);
|
||||||
$spooner = mysql_fetch_array($result);
|
$spooner = mysqli_fetch_array($result);
|
||||||
if($spooner['order_num'] == getHighestOrderNum()) { // if last person in the list
|
if($spooner['order_num'] == getHighestOrderNum($conn)) { // if last person in the list
|
||||||
$result2 = mysql_query("SELECT id FROM spooners WHERE spooned = 0 AND order_num = " . getLowestOrderNum());
|
$result2 = mysqli_query($conn, "SELECT id FROM spooners WHERE spooned = 0 AND order_num = " . getLowestOrderNum($conn));
|
||||||
$spooner2 = mysql_fetch_array($result2);
|
$spooner2 = mysqli_fetch_array($result2);
|
||||||
return $spooner2['id'];
|
return $spooner2['id'];
|
||||||
} else {
|
} else {
|
||||||
$result2 = mysql_query("SELECT id FROM spooners WHERE spooned = 0 AND order_num > " . $spooner['order_num'] . " ORDER BY order_num ASC LIMIT 1");
|
$result2 = mysqli_query($conn, "SELECT id FROM spooners WHERE spooned = 0 AND order_num > " . $spooner['order_num'] . " ORDER BY order_num ASC LIMIT 1");
|
||||||
$spooner2 = mysql_fetch_array($result2);
|
$spooner2 = mysqli_fetch_array($result2);
|
||||||
return $spooner2['id'];
|
return $spooner2['id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getReverseTargetByID($id) { // aka get the person above the passed in person
|
function getReverseTargetByID($id, $conn) { // aka get the person above the passed in person
|
||||||
$result = mysql_query("SELECT order_num FROM spooners WHERE id = " . $id);
|
$result = mysqli_query($conn, "SELECT order_num FROM spooners WHERE id = " . $id);
|
||||||
$spooner = mysql_fetch_array($result);
|
$spooner = mysqli_fetch_array($result);
|
||||||
if($spooner['order_num'] == getLowestOrderNum()) { // if first person in the list
|
if($spooner['order_num'] == getLowestOrderNum($conn)) { // if first person in the list
|
||||||
$result2 = mysql_query("SELECT id FROM spooners WHERE spooned = 0 AND order_num = " . getHighestOrderNum());
|
$result2 = mysqli_query($conn, "SELECT id FROM spooners WHERE spooned = 0 AND order_num = " . getHighestOrderNum($conn));
|
||||||
$spooner2 = mysql_fetch_array($result2);
|
$spooner2 = mysqli_fetch_array($result2);
|
||||||
return $spooner2['id'];
|
return $spooner2['id'];
|
||||||
} else {
|
} else {
|
||||||
$result2 = mysql_query("SELECT id FROM spooners WHERE spooned = 0 AND order_num < " . $spooner['order_num'] . " ORDER BY order_num DESC LIMIT 1");
|
$result2 = mysqli_query($conn, "SELECT id FROM spooners WHERE spooned = 0 AND order_num < " . $spooner['order_num'] . " ORDER BY order_num DESC LIMIT 1");
|
||||||
$spooner2 = mysql_fetch_array($result2);
|
$spooner2 = mysqli_fetch_array($result2);
|
||||||
return $spooner2['id'];
|
return $spooner2['id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkSpoonedByID($id) {
|
function checkSpoonedByID($id, $conn) {
|
||||||
$result = mysql_query("SELECT spooned FROM spooners WHERE id = " . $id);
|
$result = mysqli_query($conn, "SELECT spooned FROM spooners WHERE id = " . $id);
|
||||||
$spooner = mysql_fetch_array($result);
|
$spooner = mysqli_fetch_array($result);
|
||||||
return $spooner['spooned'];
|
return $spooner['spooned'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function spoonByID($id) {
|
function spoonByID($id, $conn) {
|
||||||
mysql_query('SET time_zone = "' . $timezone_number . '"');
|
mysqli_query($conn, 'SET time_zone = "' . $timezone_number . '"');
|
||||||
mysql_query("UPDATE spooners SET spooned_by = " . getReverseTargetByID($id) . ", time_spooned = NOW(), spooned = 1, order_num = -1 WHERE id = " . $id);
|
mysqli_query($conn, "UPDATE spooners SET spooned_by = " . getReverseTargetByID($id, $conn) . ", time_spooned = NOW(), spooned = 1, order_num = -1 WHERE id = " . $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function reviveByID($id) {
|
function reviveByID($id, $conn) {
|
||||||
mysql_query("UPDATE spooners SET spooned = 0, order_num = " . (getHighestOrderNum() + 1) . " WHERE id = " . $id);
|
mysqli_query($conn, "UPDATE spooners SET spooned = 0, order_num = " . (getHighestOrderNum($conn) + 1) . " WHERE id = " . $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSpoonedByIDByID($id) {
|
function getSpoonedByIDByID($id, $conn) {
|
||||||
$result = mysql_query("SELECT spooned_by FROM spooners WHERE id = " . $id);
|
$result = mysqli_query($conn, "SELECT spooned_by FROM spooners WHERE id = " . $id);
|
||||||
$spooner = mysql_fetch_array($result);
|
$spooner = mysqli_fetch_array($result);
|
||||||
return $spooner['spooned_by'];
|
return $spooner['spooned_by'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTimeSpoonedByID($id) {
|
function getTimeSpoonedByID($id, $conn) {
|
||||||
$result = mysql_query("SELECT time_spooned FROM spooners WHERE id = " . $id);
|
$result = mysqli_query($conn, "SELECT time_spooned FROM spooners WHERE id = " . $id);
|
||||||
$spooner = mysql_fetch_array($result);
|
$spooner = mysqli_fetch_array($result);
|
||||||
return $spooner['time_spooned'];
|
return $spooner['time_spooned'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@
|
|||||||
<link href="<?php echo $site_url ?>/assets/css/bootstrap-responsive.css" rel="stylesheet">
|
<link href="<?php echo $site_url ?>/assets/css/bootstrap-responsive.css" rel="stylesheet">
|
||||||
|
|
||||||
<!-- Pretty font -->
|
<!-- Pretty font -->
|
||||||
<script type="text/javascript" src="http://use.typekit.com/zhe6udw.js"></script>
|
<script type="text/javascript" src="https://use.typekit.com/zhe6udw.js"></script>
|
||||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||||
|
|
||||||
<!-- Le JQuery -->
|
<!-- Le JQuery -->
|
||||||
|
@ -3,10 +3,10 @@ include('init.php');
|
|||||||
|
|
||||||
// needs to be at top so we can redirect to prevent double-shuffling or double-clearing
|
// needs to be at top so we can redirect to prevent double-shuffling or double-clearing
|
||||||
if(isset($_GET['shuffle']) && isset($_GET['confirmed'])) {
|
if(isset($_GET['shuffle']) && isset($_GET['confirmed'])) {
|
||||||
shuffleSpooners();
|
shuffleSpooners($conn);
|
||||||
header("Location:" . $site_url . "/shuffle/done");
|
header("Location:" . $site_url . "/shuffle/done");
|
||||||
} else if(isset($_GET['clear']) && isset($_GET['confirmed'])) {
|
} else if(isset($_GET['clear']) && isset($_GET['confirmed'])) {
|
||||||
mysql_query("TRUNCATE spooners");
|
mysqli_query($conn, "TRUNCATE spooners");
|
||||||
header("Location:" . $site_url . "/clear/done");
|
header("Location:" . $site_url . "/clear/done");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,21 +103,21 @@ h2, h4{
|
|||||||
|
|
||||||
/*********** SPOONING **********/
|
/*********** SPOONING **********/
|
||||||
if(isset($_GET['spoon'])) {
|
if(isset($_GET['spoon'])) {
|
||||||
spoonByID($_GET['spoon']);
|
spoonByID($_GET['spoon'], $conn);
|
||||||
?>
|
?>
|
||||||
<div class="alert">
|
<div class="alert">
|
||||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||||
<h4><strong><?php echo getNameByID($_GET['spoon']) ?></strong> has been spooned! <?php echo getNameByID(getSpoonedByIDByID($_GET['spoon'])) ?></strong>'s new target is <?php echo getNameByID(getTargetByID(getSpoonedByIDByID($_GET['spoon']))) ?>.</h4>
|
<h4><strong><?php echo getNameByID($_GET['spoon'], $conn) ?></strong> has been spooned! <?php echo getNameByID(getSpoonedByIDByID($_GET['spoon'], $conn), $conn) ?></strong>'s new target is <?php echo getNameByID(getTargetByID(getSpoonedByIDByID($_GET['spoon'], $conn), $conn), $conn) ?>.</h4>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($_GET['revive'])) {
|
if(isset($_GET['revive'])) {
|
||||||
reviveByID($_GET['revive']);
|
reviveByID($_GET['revive'], $conn);
|
||||||
?>
|
?>
|
||||||
<div class="alert">
|
<div class="alert">
|
||||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||||
<h4><strong><?php echo getNameByID($_GET['revive']) ?></strong> has been revived, but note that he or she has been added to the end of the list.</h4>
|
<h4><strong><?php echo getNameByID($_GET['revive'], $conn) ?></strong> has been revived, but note that he or she has been added to the end of the list.</h4>
|
||||||
<p>It's recommended to drag the revived spooner below a staff member so that you don't have to tell a camper that his or her target has changed for no reason.</p>
|
<p>It's recommended to drag the revived spooner below a staff member so that you don't have to tell a camper that his or her target has changed for no reason.</p>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
@ -198,12 +198,12 @@ $(document).ready(function() {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$result = mysql_query("SELECT id, first, last, staff FROM spooners WHERE spooned = 0 ORDER BY order_num") or die(mysql_error());
|
$result = mysqli_query($conn, "SELECT id, first, last, staff FROM spooners WHERE spooned = 0 ORDER BY order_num") or die(mysqli_error($conn));
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<h4>Active Spooners (<?php echo mysql_num_rows($result) ?>)</h4>
|
<h4>Active Spooners (<?php echo mysqli_num_rows($result) ?>)</h4>
|
||||||
|
|
||||||
<?php if(mysql_num_rows($result) > 0) { ?>
|
<?php if(mysqli_num_rows($result) > 0) { ?>
|
||||||
<table class="table table-active">
|
<table class="table table-active">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="row">
|
<tr class="row">
|
||||||
@ -215,7 +215,7 @@ $result = mysql_query("SELECT id, first, last, staff FROM spooners WHERE spooned
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
while($spooner = mysql_fetch_array($result)) {
|
while($spooner = mysqli_fetch_array($result)) {
|
||||||
echo ' <tr id="' . $spooner['id'] . '" class="row';
|
echo ' <tr id="' . $spooner['id'] . '" class="row';
|
||||||
if($spooner['staff']) echo ' success'; // highlight staff with green row
|
if($spooner['staff']) echo ' success'; // highlight staff with green row
|
||||||
echo '">
|
echo '">
|
||||||
@ -223,7 +223,7 @@ $result = mysql_query("SELECT id, first, last, staff FROM spooners WHERE spooned
|
|||||||
<td>' . $spooner['first'] . '</td>
|
<td>' . $spooner['first'] . '</td>
|
||||||
<td>' . $spooner['last'] . '</td>
|
<td>' . $spooner['last'] . '</td>
|
||||||
<td class="drag align-center"><i class="icon-list"></i></td>
|
<td class="drag align-center"><i class="icon-list"></i></td>
|
||||||
<!-- <td><small>Targeting ' . getNameByID(getTargetByID($spooner['id'])) . ', targeted by ' . getNameByID(getReverseTargetByID($spooner['id'])) . '</small></td> -->
|
<!-- <td><small>Targeting ' . getNameByID(getTargetByID($spooner['id'], $conn), $conn) . ', targeted by ' . getNameByID(getReverseTargetByID($spooner['id'], $conn), $conn) . '</small></td> -->
|
||||||
</tr>
|
</tr>
|
||||||
';
|
';
|
||||||
}
|
}
|
||||||
@ -237,12 +237,12 @@ $result = mysql_query("SELECT id, first, last, staff FROM spooners WHERE spooned
|
|||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$result = mysql_query("SELECT id, first, last, staff, spooned_by, time_spooned FROM spooners WHERE spooned = 1 ORDER BY time_spooned DESC") or die(mysql_error());
|
$result = mysqli_query($conn, "SELECT id, first, last, staff, spooned_by, time_spooned FROM spooners WHERE spooned = 1 ORDER BY time_spooned DESC") or die(mysqli_error($conn));
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<h4>Dead Spooners (<?php echo mysql_num_rows($result) ?>)</h4>
|
<h4>Dead Spooners (<?php echo mysqli_num_rows($result) ?>)</h4>
|
||||||
|
|
||||||
<?php if(mysql_num_rows($result) > 0) { ?>
|
<?php if(mysqli_num_rows($result) > 0) { ?>
|
||||||
<table class="table table-inactive">
|
<table class="table table-inactive">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="row">
|
<tr class="row">
|
||||||
@ -254,14 +254,14 @@ $result = mysql_query("SELECT id, first, last, staff, spooned_by, time_spooned F
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
while($spooner = mysql_fetch_array($result)) {
|
while($spooner = mysqli_fetch_array($result)) {
|
||||||
echo ' <tr id="' . $spooner['id'] . '" class="row';
|
echo ' <tr id="' . $spooner['id'] . '" class="row';
|
||||||
if($spooner['staff']) echo ' success'; // highlight staff with green row
|
if($spooner['staff']) echo ' success'; // highlight staff with green row
|
||||||
echo '">
|
echo '">
|
||||||
<td class="align-center" style="min-width:40px;"><a href="' . $site_url . '/revive/' . $spooner['id'] . '" class="btn hidden-phone" type="submit"><i class="icon-arrow-up"></i> Revive</a><a href="' . $site_url . '/revive/' . $spooner['id'] . '" class="btn visible-phone" style="padding-left:10px !important; width:40px !important;"> <i class="icon-arrow-up"></i></a></td>
|
<td class="align-center" style="min-width:40px;"><a href="' . $site_url . '/revive/' . $spooner['id'] . '" class="btn hidden-phone" type="submit"><i class="icon-arrow-up"></i> Revive</a><a href="' . $site_url . '/revive/' . $spooner['id'] . '" class="btn visible-phone" style="padding-left:10px !important; width:40px !important;"> <i class="icon-arrow-up"></i></a></td>
|
||||||
<td>' . $spooner['first'] . ' ' . $spooner['last'] . '</td>
|
<td>' . $spooner['first'] . ' ' . $spooner['last'] . '</td>
|
||||||
<td class="hidden-phone"><small>Spooned by <strong>' . getNameByID($spooner['spooned_by']) . '</strong> on <strong>' . date('l', strtotime($spooner['time_spooned'])) . '</strong> at <strong>' . date('g:i A', strtotime($spooner['time_spooned'])) . '</strong>.</small></td>
|
<td class="hidden-phone"><small>Spooned by <strong>' . getNameByID($spooner['spooned_by'], $conn) . '</strong> on <strong>' . date('l', strtotime($spooner['time_spooned'])) . '</strong> at <strong>' . date('g:i A', strtotime($spooner['time_spooned'])) . '</strong>.</small></td>
|
||||||
<td class="visible-phone"><small>Spooned by <strong>' . getNameByID($spooner['spooned_by']) . '</strong></br> on <strong>' . date('l', strtotime($spooner['time_spooned'])) . '</strong> at <strong>' . date('g:i A', strtotime($spooner['time_spooned'])) . '</strong>.</small></td>
|
<td class="visible-phone"><small>Spooned by <strong>' . getNameByID($spooner['spooned_by'], $conn) . '</strong></br> on <strong>' . date('l', strtotime($spooner['time_spooned'])) . '</strong> at <strong>' . date('g:i A', strtotime($spooner['time_spooned'])) . '</strong>.</small></td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
';
|
';
|
||||||
|
@ -9,10 +9,10 @@ if(!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] == FALSE) {
|
|||||||
|
|
||||||
include('db_connect.php');
|
include('db_connect.php');
|
||||||
|
|
||||||
$result = mysql_query("SELECT first, last FROM spooners WHERE spooned = 0 ORDER BY order_num") or die(mysql_error());
|
$result = mysqli_query($conn, "SELECT first, last FROM spooners WHERE spooned = 0 ORDER BY order_num") or die(mysqli_error($conn));
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while($spooner = mysql_fetch_array($result)) {
|
while($spooner = mysqli_fetch_array($result)) {
|
||||||
$spooners[$i]['name'] = $spooner['first'];
|
$spooners[$i]['name'] = $spooner['first'];
|
||||||
if($spooner['last']) $spooners[$i]['name'] .= " " . $spooner['last'];
|
if($spooner['last']) $spooners[$i]['name'] .= " " . $spooner['last'];
|
||||||
|
|
||||||
|
@ -5,6 +5,6 @@ include('db_connect.php');
|
|||||||
$order_array = explode(",", $_POST['order']);
|
$order_array = explode(",", $_POST['order']);
|
||||||
foreach($order_array as $key => $value) {
|
foreach($order_array as $key => $value) {
|
||||||
echo $value . ' > ' . $key . "\n";
|
echo $value . ' > ' . $key . "\n";
|
||||||
mysql_query("UPDATE spooners SET order_num = " . $key . " WHERE id = " . $value) or die(mysql_error());
|
mysqli_query($conn, ("UPDATE spooners SET order_num = " . $key . " WHERE id = " . $value) or die(mysqli_error($conn));
|
||||||
}
|
}
|
||||||
?>
|
?>
|
Loading…
x
Reference in New Issue
Block a user