diff --git a/Readme.txt b/Readme.txt index 0a20d52..52d5004 100644 --- a/Readme.txt +++ b/Readme.txt @@ -1,10 +1,10 @@ ########################################################################### VNSB Squares - Version: 4.2 - Released: 1/23/13 + Version: 4.3 + Released: 1/29/2019 Written: www.VNLISTING.com - Demo: http://vnlisting.homelinux.com/superbowl + Demo: http://www.vnlisting.com/superbowl Forum: http://forum.vnlisting.com/ Email: admin@vnlisting.com @@ -24,7 +24,7 @@ For a small donation I can help :::::::::::::::::::::::::::::::::::::::: 1. Setup/install this script on your server. 2. Setup/install this script on our server. You will get a seperate URL for your group to use without having to by a domain name or - pay for posting else where. + pay for posting else where. 3. Most support can be found on the forum, But if you still need help let me know. ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @@ -39,18 +39,16 @@ Requirements: - This was tested with PHP 5.1.2, mySQL 5.0.18, Firefox2, and IE7 How to install: -1. Unzip VNSBsquares_v40.zip script to your local computer. -2. Change data in config.inc.php to reflect your mySQL data and rename it to config.php -3. Create a database in your MySQL as in config.php -4. Import superbowl.sql to your newly created MySQL database -5. Make changes to VNSB_settings as needed. -6. Upload all files to your web server. +1. Unzip VNSBsquares_v50.zip and copy all files to your web server. +2. run the 'setup.php' from your web browser. + i.e. http://www.yourdomain.com/superbowl/setup.php +3. delete 'setup.php' before go live. Usage: 1. On your browser, type "www.yourdomain.com/superbowl" or wherever you uploaded the files 2. Click on any "AVAILABLE" squares to make the selection. Click "Submit" when all squares are selected. -3. Emails will be send to the Admin and the user when selection is made. +3. Emails will be sent to the Admin and the user when selection is made. Administrator: @@ -58,7 +56,25 @@ Administrator: 2. Email will be send to user and admin for each confirmation. 3. When all squares are selected, run randomnumber.php to randomly generate numbers. 4. Email to everyone when random numbers have been generated. +5. Enter scores from the admin page + +===================== CHANGES FROM 4.1 to 5.0 ================================= +1. Add scores, winner indications, email winners +2. php7 compatible +3. easily install and configuration from webpage + + +===================== CHANGES FROM 4.0 to 4.1 ================================= +1. Admin above to confirm all squares from the same users at once. +2. Improve email sending header +3. Improve session header + +===================== CHANGES FROM 3.0 to 4.0 ================================= +1. Move superbowl logo to the database for easy change each year +2. User will be able to make multiple picks before enter information +3. Removed Admin link from user pages + ===================== CHANGES FROM 2.0 to 3.0 ================================= Bugs fixed: @@ -69,20 +85,8 @@ Bugs fixed: via the URL. (Don't worry if you don't know what this mean). 4. Admin only required to login once instead of verifying admin email and password each confirmation. 5. Random number selection is now require login. +i -===================== CHANGES FROM 3.0 to 4.0 ================================= -1. Move superbowl logo to the database for easy change each year -2. User will be able to make multiple picks before enter information -3. Removed Admin link from user pages - -===================== CHANGES FROM 4.0 to 4.1 ================================= -1. Admin above to confirm all squares from the same users at once. -2. Improve email sending header -3. Improve session header - -===================== CHANGES FROM 4.1 to 4.2 ================================= -1. Add scores, winner indications, email winners TODO: -- Auto install of database and scripts -- Paypal implementation \ No newline at end of file +- Paypal implementation diff --git a/admin.php b/admin.php index 985146b..0cb40e3 100644 --- a/admin.php +++ b/admin.php @@ -1,28 +1,32 @@ - - - - - - + + ".$record["NAME"]." - ".$record["SQUARE"].""; } ?> @@ -102,7 +106,7 @@ if (!isset($_SESSION['VNSB'])) {

- + @@ -126,16 +130,16 @@ if (!isset($_SESSION['VNSB'])) { $square_list = substr_replace($square_list,"",0,2); //echo $square_list."
"; - $query="SELECT * FROM VNSB_squares WHERE $whereclause"; - //echo $query."
"; - $result = mysql_query($query); + $sql="SELECT * FROM `VNSB_squares` WHERE $whereclause"; + //echo $sql."
"; + $result = mysqli_query($conn, $sql); if (!$result) { - echo mysql_error(); + echo mysqli_error(); exit; } $USER_EMAIL_LIST = ''; - while ($record = mysql_fetch_assoc($result)) { + while ($record = mysqli_fetch_assoc($result)) { $USER_EMAIL = ''; $USER_EMAIL = $record["EMAIL"]; @@ -150,10 +154,10 @@ if (!isset($_SESSION['VNSB'])) { $bodyMessage = "\r\nNOTIFICATION\r\n"; //echo $bodyMessage."
"; if ($CONFIRM==1 AND $RELEASE!=1) { - $query="UPDATE VNSB_squares SET CONFIRM='1' WHERE $whereclause"; + $sql="UPDATE `VNSB_squares` SET CONFIRM='1' WHERE $whereclause"; $bodyMessage .= "Your square $square_list is now confirmed.\r\n\n"; } else if ($RELEASE==1 AND $CONFIRM!=1) { - $query="UPDATE VNSB_squares SET NAME='AVAILABLE', EMAIL='', NOTES='', DATE='', CONFIRM='0' WHERE $whereclause"; + $sql="UPDATE `VNSB_squares` SET NAME='AVAILABLE', EMAIL='', NOTES='', DATE='', CONFIRM='0' WHERE $whereclause"; $bodyMessage .= "Your square $square_list selection is now released due to no payment.\r\n"; $bodyMessage .= "If this is an error, please contact me or re-select your square.\r\n\n"; } else if (($CONFIRM!=1 AND $RELEASE!=1) OR ($RELEASE==1 AND $CONFIRM==1) ) { @@ -161,10 +165,10 @@ if (!isset($_SESSION['VNSB'])) { echo "

Back

"; exit; } - //echo $query."
"; - $result = mysql_query($query); + //echo $sql."
"; + $result = mysqli_query($conn, $sql); if (!$result) { - echo mysql_error(); + echo mysqli_error(); } else { $bodyMessage .= $NOTES."\r\n\n"; $bodyMessage .= "Good Luck and enjoy the game.\r\n"; @@ -206,6 +210,6 @@ if (!isset($_SESSION['VNSB'])) { ">

- diff --git a/adminlogin.php b/adminlogin.php index 38c5fed..ed28341 100644 --- a/adminlogin.php +++ b/adminlogin.php @@ -29,22 +29,27 @@ if ($email && $pass) { exit; } // check input variables against database - include "config.php"; - $query = "SELECT Admin_email, Admin_pwd FROM VNSB_settings"; - $result = mysql_query($query); + include('includes/dbTables.inc'); + $conn = dbConnection(); + if (!$conn) { + die("Are you sure your database is setup correctly? I'm giving up!". mysqli_connect_error()); + } + + $sql = "SELECT Admin_email, Admin_pwd FROM `VNSB_settings`"; + $result = mysqli_query($conn, $sql); // in case of an error, throw up an error message and exit if (!$result) { echo "Sorry, there is a problem with accessing your database!!!"; exit; } else { - $record = mysql_fetch_assoc($result); - if ($email==$record['Admin_email'] AND $pass==$record['Admin_pwd']) { + $record = mysqli_fetch_assoc($result); + if ($email==$record['Admin_email'] AND md5($pass)==$record['Admin_pwd']) { $_SESSION['VNSB']=$record['Admin_email']; - mysql_close($db); + mysqli_close($conn); header ("Location: admin.php"); } else { echo "

Invalid login

Admin login

"; - mysql_close($db); + mysqli_close($conn); exit; } } @@ -53,27 +58,27 @@ if ($email && $pass) { ?>

-

Welcome, Admin!
+

Welcome, Admin!
If you feel that the work I've done has value to you, I would greatly appreciate a paypal donation (click button below). I have spent many hours working on this project, and I will continue its development as I find the time. Again, I am very grateful for any and all contributions.

- - - - - - - Enter Donation amount: $       -        - - - + + + + + + +Enter Donation amount: $       +       + + +


Admin login

-

Email:        

+

Email:        

Password:

diff --git a/adminlogout.php b/adminlogout.php index 72ba85c..5be6a29 100644 --- a/adminlogout.php +++ b/adminlogout.php @@ -25,7 +25,7 @@ } ?> -

Home

+

">Home

Admin

diff --git a/emailall.php b/emailall.php index cae5ed9..7e20ee7 100644 --- a/emailall.php +++ b/emailall.php @@ -14,8 +14,14 @@ if (!$_SESSION['VNSB']) { - diff --git a/images/AFC_logo.gif b/images/AFC_logo.gif new file mode 100644 index 0000000..a105d8e Binary files /dev/null and b/images/AFC_logo.gif differ diff --git a/images/NFC_logo.gif b/images/NFC_logo.gif new file mode 100644 index 0000000..76a3816 Binary files /dev/null and b/images/NFC_logo.gif differ diff --git a/images/NFL-logo.gif b/images/NFL-logo.gif new file mode 100644 index 0000000..bd3a7ff Binary files /dev/null and b/images/NFL-logo.gif differ diff --git a/images/VNLogo.gif b/images/VNLogo.gif new file mode 100644 index 0000000..11b9b46 Binary files /dev/null and b/images/VNLogo.gif differ diff --git a/images/sb_logo.jpg b/images/sb_logo.jpg new file mode 100644 index 0000000..3a517b8 Binary files /dev/null and b/images/sb_logo.jpg differ diff --git a/includes/config.inc b/includes/config.inc new file mode 100644 index 0000000..aefdcec --- /dev/null +++ b/includes/config.inc @@ -0,0 +1,21 @@ +{ + "db_host": "localhost", + "db_user": "llam", + "db_pass": "vnlisting", + "db_name": "superbowl", + "site_url": "http:\/\/172.23.49.14\/superbowl_v50", + "admin_email": "vnlisting@gmail.com", + "admin_pass": "vnlisting", + "sb_logo": "images\/sb_logo.jpg", + "afc_champ": "AFC", + "afc_champ_logo": "images\/AFC_logo.gif", + "nfc_champ": "NFC", + "nfc_champ_logo": "images\/NFC_logo.gif", + "sb_date": "Sunday, February 03, 2019", + "sb_time": "15:30", + "cost": "5", + "first": "20", + "second": "25", + "third": "20", + "final": "35" +} \ No newline at end of file diff --git a/includes/dbTables.inc b/includes/dbTables.inc new file mode 100644 index 0000000..093b922 --- /dev/null +++ b/includes/dbTables.inc @@ -0,0 +1,347 @@ +db_host, $tempJSON->db_user, $tempJSON->db_pass, $tempJSON->db_name); + + if (!$conn) { + die("Connection failed!!!
".mysqli_connect_error()); + } else { + return $conn; + } + + } else { + echo "ERROR: Unable to connect to ".$tempJSON->db_host."
".mysqli_error($conn); + return FALSE; + } +} + +# Table structure for table `VNSB_numbers` +function create_VNSB_numbers($conn) { + $sql = "DROP TABLE IF EXISTS `VNSB_numbers`;"; + if (!mysqli_query($conn, $sql)) { + echo "ERROR: Unable to DROP `VNSB_numbers`!
".mysqli_error($conn); + } + + $sql = "CREATE TABLE IF NOT EXISTS `VNSB_numbers` ( + `NFC` tinyint(2) DEFAULT NULL, + `AFC` tinyint(2) DEFAULT NULL + ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Randomly picked numbers'; + "; + if (!mysqli_query($conn, $sql)) { + echo "ERROR: Unable to CREATE `VNSB_numbers`!
".mysqli_error($conn); + } else { + echo "

`VNSB_numbers` created successfully.

"; + } +} + +# Table structure for table `VNSB_scores` +function create_VNSB_scores($conn) { + $sql = "DROP TABLE IF EXISTS `VNSB_scores`;"; + if (!mysqli_query($conn, $sql)) { + echo "ERROR: Unable to DROP `VNSB_scores`!
".mysqli_error($conn); + } + + $sql = "CREATE TABLE IF NOT EXISTS `VNSB_scores` ( + `ID` tinyint(2) NOT NULL, + `NFC_FIRST` varchar(2) DEFAULT NULL, + `AFC_FIRST` varchar(2) DEFAULT NULL, + `NFC_HALF` varchar(2) DEFAULT NULL, + `AFC_HALF` varchar(2) DEFAULT NULL, + `NFC_THIRD` varchar(2) DEFAULT NULL, + `AFC_THIRD` varchar(2) DEFAULT NULL, + `NFC_FINAL` varchar(2) DEFAULT NULL, + `AFC_FINAL` varchar(2) DEFAULT NULL + ) ENGINE=MyISAM DEFAULT CHARSET=latin1; + "; + if (!mysqli_query($conn, $sql)) { + echo "ERROR: Unable to CREATE `VNSB_scores`!
".mysqli_error($conn); + } else { + echo "

`VNSB_scores` created successfully.

"; + } +} + +# Table structure for table `VNSB_squares` +function create_VNSB_squares($conn) { + $sql = "DROP TABLE IF EXISTS `VNSB_squares`;"; + if (!mysqli_query($conn, $sql)) { + echo "ERROR: Unable to DROP `VNSB_squares`!
".mysqli_error($conn); + } + + $sql = "CREATE TABLE IF NOT EXISTS `VNSB_squares` ( + `SQUARE` varchar(15) NOT NULL DEFAULT '', + `NAME` varchar(30) NOT NULL DEFAULT 'AVAILABLE', + `EMAIL` varchar(45) DEFAULT NULL, + `NOTES` text, + `DATE` datetime DEFAULT CURRENT_TIMESTAMP, + `CONFIRM` tinyint(1) NOT NULL DEFAULT '0', + `FIRST` tinyint(1) NOT NULL DEFAULT '0', + `HALF` tinyint(1) NOT NULL DEFAULT '0', + `THIRD` tinyint(1) NOT NULL DEFAULT '0', + `FINAL` tinyint(1) NOT NULL DEFAULT '0', + UNIQUE KEY `SQUARE` (`SQUARE`) + ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Super Bowl Squares'; + "; + if (!mysqli_query($conn, $sql)) { + echo "ERROR: Unable to CREAT `VNSB_squares`!
".mysqli_error($conn); + } else { + + for ($l=0; $l < 100; $l++) { + $sql = "INSERT INTO `VNSB_squares` VALUES ('".sprintf("%02d", $l)."', 'AVAILABLE', NULL, NULL, NULL, 0, 0, 0, 0, 0);"; + if (!mysqli_query($conn, $sql)) { + echo "ERROR: Unable to populate squares!
".mysqli_error($conn); + } + } + echo "

`VNSB_squares` created successfully.

"; + } +} + +# Table structure for table `VNSB_settings` +function create_VNSB_settings() { + + $VERSION = "5.0"; + if (file_exists("includes/config.inc")) { + $notJSON = file_get_contents("includes/config.inc"); + $tempJSON = json_decode($notJSON); + + $conn = mysqli_connect($tempJSON->db_host, $tempJSON->db_user, $tempJSON->db_pass, $tempJSON->db_name); + + if (!$conn) { + die("Connection failed!!!
".mysqli_connect_error()); + } else { + + $sql = "DROP TABLE IF EXISTS `VNSB_settings`;"; + if (!mysqli_query($conn, $sql)) { + echo "ERROR: Unable to DROP `VNSB_settings`!
".mysqli_error($conn); + } + + $sql = "CREATE TABLE IF NOT EXISTS `VNSB_settings` ( + `sb_date` varchar(30) NOT NULL DEFAULT 'Sunday, February 7, 2021', + `sb_time` varchar(30) NOT NULL DEFAULT '3:30 PM', + `sb_logo` varchar(30) DEFAULT NULL, + `NFC_team` varchar(30) DEFAULT NULL, + `NFC_logo` varchar(80) DEFAULT NULL, + `AFC_team` varchar(30) DEFAULT NULL, + `AFC_logo` varchar(80) DEFAULT NULL, + `Bet` varchar(5) NOT NULL DEFAULT '5.00', + `Win_first` tinyint(2) NOT NULL DEFAULT '20', + `Win_second` tinyint(2) NOT NULL DEFAULT '25', + `Win_third` tinyint(2) NOT NULL DEFAULT '20', + `Win_final` tinyint(2) NOT NULL DEFAULT '35', + `Version` char(3) NOT NULL DEFAULT '5.0', + `Admin_email` varchar(80) NOT NULL DEFAULT 'admin@email.com', + `Admin_pwd` varchar(80) NOT NULL DEFAULT 'password', + PRIMARY KEY (`sb_date`) + ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Setting for VN SuperBowl Squares'; + "; + if (!mysqli_query($conn, $sql)) { + echo "ERROR: Unable to CREATE `VNSB_settings`!
".mysqli_error($conn); + } else { + echo "

`VNSB_settings` created successfully.

"; + } + + # populate table + $sql = "INSERT INTO `VNSB_settings` VALUES ('".$tempJSON->sb_date."', '".$tempJSON->sb_time."', '".$tempJSON->sb_logo."', '".$tempJSON->nfc_champ."', '".$tempJSON->nfc_champ_logo."', '".$tempJSON->afc_champ."', '".$tempJSON->afc_champ_logo."', '".$tempJSON->cost."', '".$tempJSON->first."', '".$tempJSON->second."', '".$tempJSON->third."', '".$tempJSON->final."', '".$VERSION."', '".$tempJSON->admin_email."', '".md5($tempJSON->admin_pass)."');"; +# echo $sql; + if (!mysqli_query($conn, $sql)) { + echo "ERROR: Unable to populate 'VNSB_settings's!
".mysqli_error($conn); + } + } +# $mysqli_close($conn); + + } else { + echo "ERROR: Configuration file does not existi or required fields are missing!"; + } +} + +# databse +function dbInquery() { + + if (file_exists("includes/config.inc")) { + # Read back json file + $myJSON = file_get_contents("includes/config.inc"); + $notJSON = json_decode($myJSON); + $db_host = $notJSON->db_host; + $db_user = $notJSON->db_user; + $db_pass = $notJSON->db_pass; + $db_name = $notJSON->db_name; + } else { + $db_host = "localhost"; + $db_user = "vnsb"; + $db_pass = "vnlisting"; + $db_name = "superbowl"; + } + + echo "

Minimum PHP version 5.5.9 recommeneded.
"; + if (version_compare(PHP_VERSION, '5.5.9') >= 0) { + echo "Your PHP version: ".PHP_VERSION."

"; + } else { + echo "Your PHP version: ".PHP_VERSION."
DOES NOT MEET MINIMUM RECOMENDATION

"; + } + + echo(' + +
  mySQL   +
HomeHome Numbers Scores Logout
+ + + + + + + + + +
Hostname: +
Username: +
Password: +
Database: +

+

Warning: Any existing databse with the same name will be deleted!

+ + + '); +} + +# Admin +function adminInquery() { + + if (file_exists("includes/config.inc")) { + # Read back json file + $myJSON = file_get_contents("includes/config.inc"); + $notJSON = json_decode($myJSON); + $admin_email = $notJSON->admin_email; + $admin_pass = $notJSON->admin_pass; + $site_url = $notJSON->site_url; + } else { + $admin_email = "admin@email.com"; + $admin_pass = "password"; + $site_url = $_SERVER['REQUEST_SCHEME']."://".$_SERVER['HTTP_HOST'].trim($_SERVER['PHP_SELF'], "setup.php"); + } + + echo(' +
+
  Admin   + + + + + + + + +
Site URL: +
Admin Email: +
Admin Password: +

+
+
+ '); +} + +# configuration +function configInquery() { + + if (file_exists("includes/config.inc")) { + # Read back json file + $myJSON = file_get_contents("includes/config.inc"); + $notJSON = json_decode($myJSON); + $sb_logo = $notJSON->sb_logo; + $afc_champ = $notJSON->afc_champ; + $afc_champ_logo = $notJSON->afc_champ_logo; + $nfc_champ = $notJSON->nfc_champ; + $nfc_champ_logo = $notJSON->nfc_champ_logo; + $sb_date = $notJSON->sb_date; + $sb_time = $notJSON->sb_time; + $cost = $notJSON->cost; + $first = $notJSON->first; + $second = $notJSON->second; + $third = $notJSON->third; + $final = $notJSON->final; + $cost_total = (float)$cost * 100; + $first_value = ((int)$first * $cost_total) / 100; + $second_value = ((int)$second * $cost_total) / 100; + $third_value = ((int)$third * $cost_total) / 100; + $final_value = ((int)$final * $cost_total) / 100; + } else { + $sb_logo = "images/sb_logo.jpg"; + $afc_champ = "AFC"; + $afc_champ_logo = "images/AFC_logo.gif"; + $nfc_champ = "NFC"; + $nfc_champ_logo = "images/NFC_logo.gif"; + $sb_date = "Sunday, February 7, 2021"; + $sb_time = "3:30PM"; + $cost = "5"; + $first = "20"; + $second = "25"; + $third = "20"; + $final = "35"; + $cost_total = (int)$cost * 100; + $first_value = ((int)$first * $cost_total) / 100; + $second_value = ((int)$second * $cost_total) / 100; + $third_value = ((int)$third * $cost_total) / 100; + $final_value = ((int)$final * $cost_total) / 100; + } + + echo(' +
+
  NFL   + + + + + + + + + + + + + + + +
Super Bowl Logo: +
AFC Champion: +
AFC Logo: +
NFC Champion: +
NFC Logo: +
Super Bowl Date: +
Super Bowl Time: +
+
+ +
  Payout   + + + + + + + + + + + +
Cost per square:$      $ +
1st quarter:%      $ +
2nd quarter:%      $ +
3rd quarter:%      $ +
Final:%      $ +
+
+ +

+
+ '); +} + +?> diff --git a/includes/footer.inc b/includes/footer.inc new file mode 100644 index 0000000..3890c6f --- /dev/null +++ b/includes/footer.inc @@ -0,0 +1,19 @@ + + + +

+ + + + + +
Copyright © 2004- VNLISTINGVNSB Squares
+

+ + + + diff --git a/includes/header.inc b/includes/header.inc new file mode 100644 index 0000000..491a506 --- /dev/null +++ b/includes/header.inc @@ -0,0 +1,58 @@ + + +Sorry, Technical problem occurred... Can't read from database.

Please notify this site admin"; + exit; +} +?> + + +VNLISTING :: Online Super Bowl Squares v5.0 + + + + + + + +
+

+ + + + + + +


   vs   
+
diff --git a/index.php b/index.php index 599917a..d817fe6 100644 --- a/index.php +++ b/index.php @@ -2,10 +2,17 @@ www.vnlisting.com Online Super Bowl Squares Script Please read the "Readme.txt for license agreement, installation and usage instructions -Version: 4.2 1/24/2013 +Version: 5.0 2/7/2019 --> + - + - + ".$NFC_TEAM."
".$NFC[$i].""; @@ -78,16 +66,16 @@ if ($record = mysql_fetch_assoc($result)) { ".$AFC_TEAM."
".$AFC[$i]."";} if ($record['NAME'] == "AVAILABLE") { @@ -154,8 +142,8 @@ Check all your desired squares and click Submit to enter your information
  • $ per square
  • You can buy as many squares as you want
  • Your square(s) is/are not guaranteed until your payment is verified
  • -
  • Numbers will be randomly draw and assigned after all squares are taken
  • When confirmed, your square(s) will be changed to GREEN
  • +
  • Numbers will be randomly draw and assigned after all squares are taken
  • "; - $query="SELECT * FROM VNSB_squares ORDER BY SQUARE"; - $result = mysql_query($query); + $sql="SELECT * FROM VNSB_squares ORDER BY SQUARE"; + $result = mysqli_query($conn, $sql); if (!$result) { - echo mysql_error(); + echo mysqli_error(); exit; } $cnt_row = 0; $i=0; - while ($record = mysql_fetch_assoc($result)) { + while ($record = mysqli_fetch_assoc($result)) { if ($cnt_row==0) {$i++; echo"";} if ($record['NAME'] == "AVAILABLE") { echo ""; @@ -145,10 +150,10 @@ if (!$_SESSION['VNSB']) { // save to database if (isset($RANDOM)) { for ($n=1; $n<=10; $n++) { - $query="INSERT INTO VNSB_numbers (NFC, AFC) VALUES ('".$NFC[$n]."','".$AFC[$n]."')"; - $result = mysql_query($query); + $sql="INSERT INTO VNSB_numbers (NFC, AFC) VALUES ('".$NFC[$n]."','".$AFC[$n]."')"; + $result = mysqli_query($conn, $sql); if (!$result) { - echo mysql_error(); + echo mysqli_error(); echo "

    PROBLEM WRITING NUMBERS INTO DATABASE!

    "; exit; } @@ -156,7 +161,7 @@ if (!$_SESSION['VNSB']) { } echo $LINKS; - require "footer.inc"; + require "ncludes/footer.inc"; } ?> diff --git a/scores.php b/scores.php index de6a26a..5ee2ec7 100644 --- a/scores.php +++ b/scores.php @@ -12,43 +12,12 @@ if (!$_SESSION['VNSB']) { www.vnlisting.com Online Super Bowl Squares Script Please read the "Readme.txt for license agreement, installation and usage instructions -Version: 4.2 1/24/2013 - -TODO: -- email winners -- "0" score is not working +Version: 4.3 1/29/2019 --> Sorry, Technical problem occurred... your scores were not added.

    Email this problem to ".$ADMIN_EMAIL.""; - exit; - } -} + $superbowlURL = $_SERVER['REQUEST_SCHEME']."://".$_SERVER['HTTP_HOST'].trim($_SERVER['PHP_SELF'], "scores.php"); function email_notify ($mailto) { @@ -62,14 +31,45 @@ function email_notify ($mailto) mail("$mailto", "$mail_subject", "$mailmessage", "$mail_headers"); } -$query="SELECT * FROM `VNSB_scores`"; -$result = mysql_query($query); -if (!$result) { - echo mysql_error(); - exit; +require_once('includes/dbTables.inc'); +$conn = dbConnection(); +if (!$conn) { + die("Are you sure your database is setup correctly? I'm giving up!".mysqli_connect_error()); +} + +require "includes/header.inc"; + +$EMAIL = $_REQUEST['m']; + +$NFC = array(); +$AFC = array(); +$NAME = array(); +$NFC_1 = $_POST['NFC_1']; +$NFC_2 = $_POST['NFC_2']; +$NFC_3 = $_POST['NFC_3']; +$NFC_4 = $_POST['NFC_4']; +$AFC_1 = $_POST['AFC_1']; +$AFC_2 = $_POST['AFC_2']; +$AFC_3 = $_POST['AFC_3']; +$AFC_4 = $_POST['AFC_4']; + + +// Update +if (isset($_REQUEST['addscores'])) { + $sql="INSERT INTO `VNSB_scores` VALUES (NULL, '".$NFC_1."', '".$AFC_1."', '".$NFC_2."', '".$AFC_2."', '".$NFC_3."', '".$AFC_3."', '".$NFC_4."', '".$AFC_4."');"; + $result = mysqli_query($conn, $sql); + if (!$result) { + echo "

    Sorry, Technical problem occurred... Scores were not added.

    ". mysqli_error($conn); + } } -$scores = mysql_fetch_assoc($result); +$sql="SELECT * FROM `VNSB_scores` ORDER BY ID DESC LIMIT 1"; +$result = mysqli_query($conn, $sql); +if (!$result) { + die("ERROR: Unable to read record from 'VNSB_scores'!.
    ". mysqli_error($conn)); +} + +$scores = mysqli_fetch_assoc($result); $NFC_FIRST=$scores['NFC_FIRST']; $AFC_FIRST=$scores['AFC_FIRST']; $NFC_HALF=$scores['NFC_HALF']; @@ -79,33 +79,32 @@ $AFC_THIRD=$scores['AFC_THIRD']; $NFC_FINAL=$scores['NFC_FINAL']; $AFC_FINAL=$scores['AFC_FINAL']; -if (!isset($NFC_FINAL) && !isset($AFC_FINAL) ) { $ADD_SCORES = 1; } else { $ADD_SCORES = 0; }; +#if (!isset($NFC_FINAL) && !isset($AFC_FINAL) ) { $ADD_SCORES = 1; } else { $ADD_SCORES = 0; }; +if ($NFC_FINAL==NULL || $AFC_FINAL==NULL) { $ADD_SCORES = 1; } else { $ADD_SCORES = 0; }; //Get assigned numbers -$query="SELECT * FROM VNSB_numbers"; -$result = mysql_query($query); +$sql="SELECT * FROM VNSB_numbers"; +$result = mysqli_query($conn, $sql); if (!$result) { - echo mysql_error(); - exit; + die("ERROR: Unable to read records from 'VNSB_numbers'!.
    ". mysqli_error($conn)); } $cnt=0; -while ($record = mysql_fetch_assoc($result)) { - $cnt++; - $NFC[$cnt]=$record['NFC']; - $AFC[$cnt]=$record['AFC']; +while ($record = mysqli_fetch_assoc($result)) { + $cnt++; + $NFC[$cnt]=$record['NFC']; + $AFC[$cnt]=$record['AFC']; } // Get name for each squares -$query="SELECT * FROM VNSB_squares"; -$result = mysql_query($query); +$sql="SELECT * FROM VNSB_squares"; +$result = mysqli_query($conn, $sql); if (!$result) { - echo mysql_error(); - exit; + die("ERROR: Unable to read records from 'VNSB_squares'!.
    ". mysqli_error($conn)); } -while ($record = mysql_fetch_assoc($result)) { - $NAME[$record['SQUARE']] = $record['NAME']; - $EMAIL[$record['SQUARE']] = $record['EMAIL']; +while ($record = mysqli_fetch_assoc($result)) { + $NAME[$record['SQUARE']] = $record['NAME']; + $EMAIL[$record['SQUARE']] = $record['EMAIL']; } @@ -118,10 +117,14 @@ if ($ADD_SCORES) { - - - - + + + + @@ -175,39 +178,35 @@ if ($ADD_SCORES) { "; -// Display only on date of superbowl or later -// sb_date in the VNSB_settings must be in this format (February 3, 2013) for this to work correctly -if ( (strtotime(trim($SB_DATE)) <= strtotime(date("F j, Y"))) && ( $NFC_FIRST && $AFC_FIRST ) ) { +# Notify winners +echo ('email winners'); - echo ('email winners'); - - $cnt=0; - for ($y=1; $y<=10; $y++) { - for ($x=1; $x<=10; $x++) { - if ($cnt<10) { $square = "0".$cnt; } else { $square = $cnt; } - if ( ($NFC[$x] == substr($NFC_FIRST, -1)) && ($AFC[$y] == substr($AFC_FIRST, -1)) && ( $NFC_FIRST && $AFC_FIRST ) ) { - echo "

    1st Quarter Winner ($NFC[$x],$AFC[$y])     Square #$square (".$NAME[$square].")

    "; - mysql_query("UPDATE VNSB_squares SET FIRST='1' WHERE SQUARE='$square' LIMIT 1"); - if ( $EMAIL=="yes" ) { notify_email($EMAIL[$square]); } - } - if ( ($NFC[$x] == substr($NFC_HALF, -1)) && ($AFC[$y] == substr($AFC_HALF, -1)) && ( $NFC_HALF && $AFC_HALF ) ) { - echo "

    Halftime Winner ($NFC[$x],$AFC[$y])     Square #$square (".$NAME[$square].")

    "; - mysql_query("UPDATE VNSB_squares SET HALF='1' WHERE SQUARE='$square' LIMIT 1"); - if ( $EMAIL=="yes" ) { notify_email($EMAIL[$square]); } - } - if ( ($NFC[$x] == substr($NFC_THIRD, -1)) && ($AFC[$y] == substr($AFC_THIRD, -1)) && ( $NFC_THIRD && $AFC_THIRD ) ) { - echo "

    3rd Quarter Winner ($NFC[$x],$AFC[$y])     Square #$square (".$NAME[$square].")

    "; - mysql_query("UPDATE VNSB_squares SET THIRD='1' WHERE SQUARE='$square' LIMIT 1"); - if ( $EMAIL=="yes" ) { notify_email($EMAIL[$square]); } - } - if ( ($NFC[$x] == substr($NFC_FINAL, -1)) && ($AFC[$y] == substr($AFC_FINAL, -1) && ( $NFC_FINAL && $AFC_FINAL )) ) { - echo "

    Final Winner ($NFC[$x],$AFC[$y])     Square #$square (".$NAME[$square].")

    "; - mysql_query("UPDATE VNSB_squares SET FINAL='1' WHERE SQUARE='$square' LIMIT 1"); - if ( $EMAIL=="yes" ) { notify_email($EMAIL[$square]); } - } - $cnt++; - } +$cnt=0; +for ($y=1; $y<=10; $y++) { + for ($x=1; $x<=10; $x++) { + if ($cnt<10) { $square = "0".$cnt; } else { $square = $cnt; } + if ( ($NFC[$x] == substr($NFC_FIRST, -1)) && ($AFC[$y] == substr($AFC_FIRST, -1)) && ( $NFC_FIRST && $AFC_FIRST ) ) { + echo "

    1st Quarter Winner ($NFC[$x],$AFC[$y])     Square #$square (".$NAME[$square].")

    "; + mysqli_query("UPDATE VNSB_squares SET FIRST='1' WHERE SQUARE='$square' LIMIT 1"); + if ( $EMAIL=="yes" ) { notify_email($EMAIL[$square]); } } + if ( ($NFC[$x] == substr($NFC_HALF, -1)) && ($AFC[$y] == substr($AFC_HALF, -1)) && ( $NFC_HALF && $AFC_HALF ) ) { + echo "

    Halftime Winner ($NFC[$x],$AFC[$y])     Square #$square (".$NAME[$square].")

    "; + mysqli_query("UPDATE VNSB_squares SET HALF='1' WHERE SQUARE='$square' LIMIT 1"); + if ( $EMAIL=="yes" ) { notify_email($EMAIL[$square]); } + } + if ( ($NFC[$x] == substr($NFC_THIRD, -1)) && ($AFC[$y] == substr($AFC_THIRD, -1)) && ( $NFC_THIRD && $AFC_THIRD ) ) { + echo "

    3rd Quarter Winner ($NFC[$x],$AFC[$y])     Square #$square (".$NAME[$square].")

    "; + mysqli_query("UPDATE VNSB_squares SET THIRD='1' WHERE SQUARE='$square' LIMIT 1"); + if ( $EMAIL=="yes" ) { notify_email($EMAIL[$square]); } + } + if ( ($NFC[$x] == substr($NFC_FINAL, -1)) && ($AFC[$y] == substr($AFC_FINAL, -1) && ( $NFC_FINAL && $AFC_FINAL )) ) { + echo "

    Final Winner ($NFC[$x],$AFC[$y])     Square #$square (".$NAME[$square].")

    "; + mysqli_query("UPDATE VNSB_squares SET FINAL='1' WHERE SQUARE='$square' LIMIT 1"); + if ( $EMAIL=="yes" ) { notify_email($EMAIL[$square]); } + } + $cnt++; + } } echo "

    "; @@ -215,11 +214,12 @@ echo "

    ";



    @@ -192,4 +180,4 @@ Check all your desired squares and click Submit to enter your information

    - + diff --git a/randomnumber.php b/randomnumber.php index 514af84..21093ef 100644 --- a/randomnumber.php +++ b/randomnumber.php @@ -2,7 +2,6 @@ www.vnlisting.com Online Super Bowl Squares Script Please read the "Readme.txt for license agreement, installation and usage instructions -Version: 4.1 1/9/2012 --> "; - require "header.inc"; + require "includes/header.inc"; echo "

    Numbers Assignment

    @@ -38,9 +43,9 @@ if (!$_SESSION['VNSB']) { "; // makesure all squares are selected - $query="SELECT * FROM VNSB_squares WHERE `NAME`='AVAILABLE'"; - $result = mysql_query($query); - if ($record = mysql_fetch_assoc($result)) { + $sql="SELECT * FROM VNSB_squares WHERE `NAME`='AVAILABLE'"; + $result = mysqli_query($conn, $sql); + if ($record = mysqli_fetch_assoc($result)) { echo "

    Squares are still available!!!


    "; echo $LINKS; require "footer.inc"; @@ -48,9 +53,9 @@ if (!$_SESSION['VNSB']) { } // stop if numbers existed - $query="SELECT * FROM VNSB_numbers"; - $result = mysql_query($query); - if ($record = mysql_fetch_assoc($result)) { + $sql="SELECT * FROM VNSB_numbers"; + $result = mysqli_query($conn, $sql); + if ($record = mysqli_fetch_assoc($result)) { echo "

    Numbers already exist!!!


    "; echo $LINKS; require "footer.inc"; @@ -107,15 +112,15 @@ if (!$_SESSION['VNSB']) {
    $AFC_TEAM
    ".$AFC[$i]."
    ".stripslashes($record['NAME'])."
    ".$record['SQUARE']."
    First
    Half
    Third
    Final
    First
    +
    Half
    +
    Third
    +
    Final
    +
    - - - + + + +
    HomeAdminLogoutHomeAdminScoresLogout

    - + diff --git a/setup.php b/setup.php new file mode 100644 index 0000000..ff93e97 --- /dev/null +++ b/setup.php @@ -0,0 +1,177 @@ + + + + + +VNSB - Super Bowl Quares - Installation + + + + +
    + +

    +

    Super Bowl Squares
    Installation

    + + +".mysqli_connect_error()); + } else { + # Create database + $sql = "CREATE DATABASE IF NOT EXISTS ".$_POST['db_name']; + if (!mysqli_query($dbconn, $sql)) { + die("ERROR: Unable to create new database!!!
    ".mysqli_connect_error()); + } + mysqli_close($dbconn); + sleep(2); + + # Create connection for tables + $conn = mysqli_connect($_POST['db_host'], $_POST['db_user'], $_POST['db_pass'], $_POST['db_name']); + + if (!$conn) { + die("ERROR: Connection failed!!!
    ".mysqli_connect_error()); + } else { + + echo "

    Database connected sucessful!

    "; + + create_VNSB_squares($conn); + create_VNSB_numbers($conn); + create_VNSB_scores($conn); + + # Create json file with all configurations + $dbObj->db_host = $_POST['db_host']; + $dbObj->db_user = $_POST['db_user']; + $dbObj->db_pass = $_POST['db_pass']; + $dbObj->db_name = $_POST['db_name']; + + $myJSON = json_encode($dbObj, JSON_PRETTY_PRINT); + + if (file_exists("includes/config.inc")) { + $notJSON = file_get_contents("includes/config.inc"); + $tempJSON = json_decode($notJSON); + $tempJSON->db_host = $_POST['db_host']; + $tempJSON->db_user = $_POST['db_user']; + $tempJSON->db_pass = $_POST['db_pass']; + $tempJSON->db_name = $_POST['db_name']; + + $myJSON = json_encode($tempJSON, JSON_PRETTY_PRINT); + } + + $fh = fopen("includes/config.inc", "w") or die ("Error opening file!"); + fwrite($fh, $myJSON); + fclose($fh); + + # Admin + adminInquery(); + } + } + + } else { + echo "ERROR: Database information CANNOT be blank!!!"; + } + +} elseif ($_REQUEST['ADsubmit']) { + + if ($_POST['site_url'] && $_POST['admin_email'] && $_POST['admin_pass']) { + + # Read back json file + if (file_exists("includes/config.inc")) { + $notJSON = file_get_contents("includes/config.inc"); + $tempJSON = json_decode($notJSON); + $tempJSON->site_url = $_POST['site_url']; + $tempJSON->admin_email = $_POST['admin_email']; + $tempJSON->admin_pass = $_POST['admin_pass']; + $myJSON = json_encode($tempJSON, JSON_PRETTY_PRINT); + + $fh = fopen("includes/config.inc", "w") or die ("Error opening file!"); + fwrite($fh, $myJSON); + fclose($fh); + + # Configuration + configInquery(); + + } else { + echo "ERROR: Databse configuration file does not exist!"; + } + } else { + echo "ERROR: One or more field(s) is invalid or empty!!!"; + } + +} elseif ($_REQUEST['VNsubmit']) { + + if ($_POST['afc_champ'] && $_POST['nfc_champ'] && $_POST['sb_date']) { + + # Read back json file + if (file_exists("includes/config.inc")) { + $notJSON = file_get_contents("includes/config.inc"); + $tempJSON = json_decode($notJSON); + $tempJSON->sb_logo = $_POST['sb_logo']; + $tempJSON->afc_champ = $_POST['afc_champ']; + $tempJSON->afc_champ_logo = $_POST['afc_champ_logo']; + $tempJSON->nfc_champ = $_POST['nfc_champ']; + $tempJSON->nfc_champ_logo = $_POST['nfc_champ_logo']; + # date format + $sbDate = new DateTime($_POST['sb_date']); + $date_of_week = date('l', strtotime($_POST['sb_date'])); + $tempJSON->sb_date = $date_of_week.", ".$sbDate->format('F d, Y'); + $tempJSON->sb_time = $_POST['sb_time']; + $tempJSON->cost = $_POST['cost']; + $tempJSON->first = $_POST['first']; + $tempJSON->second = $_POST['second']; + $tempJSON->third = $_POST['third']; + $tempJSON->final = $_POST['final']; + + $myJSON = json_encode($tempJSON, JSON_PRETTY_PRINT); + + $fh = fopen("includes/config.inc", "w") or die ("Error opening file!"); + fwrite($fh, $myJSON); + fclose($fh); + + # Populate settings + create_VNSB_settings(); + + # Done + $notJSON = file_get_contents("includes/config.inc"); + $tempJSON = json_decode($notJSON); + echo "Congratulation... You are ready to go!
    "; + echo "

    ".$tempJSON->site_url."

    "; +# foreach ($tempJSON as $key=>$value) { + # echo $key. ": " .$value. "
    "; + # } + + echo "

    >>>>> MAKE SURE YOU DELETE 'setup.php' BEFORE YOU GO LIVE <<<<<

    "; + + } else { + echo "ERROR: Databse configuration file does not exist!"; + } + } else { + echo "ERROR: One or more field(s) is invalid or empty!!!"; + } + +} else { + # database + dbInquery(); +} + +?> + +
    + + + diff --git a/signup.php b/signup.php index 45a32ba..4050e0c 100644 --- a/signup.php +++ b/signup.php @@ -5,8 +5,15 @@ Please read the "Readme.txt for license agreement, installation and usage instru -->

    SQUARE SELECTION

    @@ -42,7 +49,7 @@ if ( isset($_REQUEST['sqSelect_Submit']) ) {

    Name

    -

    Email

    +

    Email

    Notes to Admin

    @@ -57,4 +64,4 @@ if ( isset($_REQUEST['sqSelect_Submit']) ) {

    Home

    - + diff --git a/thankyou.php b/thankyou.php index b96288b..56b74fd 100644 --- a/thankyou.php +++ b/thankyou.php @@ -6,8 +6,15 @@ Please read the "Readme.txt for license agreement, installation and usage instru Back"; exit; } else { - $record = mysql_fetch_assoc($result); + $record = mysqli_fetch_assoc($result); } } //continue only if the square is available -if ($record['DATE'] == "0000-00-00 00:00:00") { +if ($record['DATE'] == "0000-00-00 00:00:00" || $record['DATE'] == NULL) { //check for required fields for ($i=1;$i<=$sqTotal;$i++) { if (($sqSelect[$i] >= 00 OR $sqSelect[$i] < 100) AND $name != '' AND $email != '') { - $query="UPDATE VNSB_squares SET NAME='".$name."', EMAIL='".$email."', NOTES='".$notes."', DATE='".$date."', CONFIRM='".$confirm."' WHERE SQUARE='".$sqSelect[$i]."' LIMIT 1"; - $result = mysql_query($query); + $sql="UPDATE VNSB_squares SET NAME='".$name."', EMAIL='".$email."', NOTES='".$notes."', DATE='".$date."', CONFIRM='".$confirm."' WHERE SQUARE='".$sqSelect[$i]."' LIMIT 1"; + $result = mysqli_query($conn, $sql); if (!$result) { - echo mysql_error(); + echo mysqli_error(); echo "
    Sorry, Technical problem occurred... your selection was not added.

    Email this problem to ".$ADMIN_EMAIL.""; exit; } @@ -99,11 +106,11 @@ $bodyMessage .= $notes."\r\n\n"; notify_admin($email,$bodyMessage,$headers); -require "footer.inc"; ?> +require "includes/footer.inc"; ?> $square is NOT available! Someone must have just selected that same square.

    Please go back and select another square.

    "; exit; } -?> \ No newline at end of file +?>