function print_class_info() { // SQL $fe = new FileEditor('login-info.txt'); $credentials = $fe->readFile(); $login = new Credentials("terrapintango.cgpkve9uh8yp.us-east-1.rds.amazonaws.com", $credentials[0], $credentials[1], "tangodb"); $connector = new SQLConnector($login); $connector->connect(); $query = "SELECT r.fname, r.lname, c.classes, c.passtype\r\n FROM records r, classes c, confirmation f\r\n WHERE r.registerid = c.registerid and r.registerid = f.registerid and\r\n f.payment_status = 'Completed'"; try { $result = $connector->retrieve($query); } catch (Exception $e) { echo $e->getMessage(); } // END SQL $person_classes = array(); $table = "<table border=\"1\">"; $table .= "<th>Name</th><th>Pass Type</th><th>Classes</th>"; echo "<h1>Class Mapping</h1>"; foreach ($result as $record) { //print_r($record); $person_classes[$record['fname'] . " " . $record['lname']] = array($record['passtype'], parse_class_string($record['classes'])); // print_r($translated_classes); // echo "<br>"; } //print_r($person_classes); foreach ($person_classes as $person => $class_ary) { $table .= "<tr><td>{$person}</td>"; $table .= "<td>" . $class_ary[0] . "</td><td>"; $table .= implode(", ", $class_ary[1]) . "</td><tr>"; } echo $table; }
protected function handle_GET_request($request) { $path = $request->request_path(); $path_length = count($path); if (isset($path[0]) && $path[0] === "products") { if ($path_length === 2 && isset($path[1])) { $db = new SQLConnector(); return $db->get_product($path[1]); } else { if ($path_length === 1) { // get all products $db = new SQLConnector(); return $db->get_products(); } else { // invalid path return false; } } } else { return false; } }
<?php require_once "support.php"; require_once "dbLogin.php"; require_once "sqlconnector.php"; session_start(); echo "Sign up (placeholder)<br />"; if (isset($_POST['submit'])) { $host = "localhost"; $dbuser = "******"; $dbpassword = "******"; $database = "calendapp"; $table = "users"; $connector = new SQLConnector(new Credentials($host, $dbuser, $dbpassword, $database)); $connector->connect(); $username = trim($_POST["username"]); $email = trim($_POST['email']); $cryptpw = password_hash($_POST['password'], PASSWORD_DEFAULT); $date = date(DATE_ISO8601); $sqlQuery = "insert into users values('{$username}', '{$cryptpw}', 'temp', '{$date}', '{$email}')"; echo $sqlQuery . "<br />"; if ($connector->insert($sqlQuery)) { $_SESSION['loggedIn'] = true; //Stay logged in $_SESSION['username'] = $username; header("Location: main.php"); } } $body = <<<BODY <form action="signup.php" method="post"> Username: <input type="text" name="username" required="required"><br />
require_once "sqlconnector.php"; require_once "dbLogin.php"; require_once "fileEditor.php"; session_start(); // receive data $selected_classes = implode(",", json_decode($_POST['class_string'])); $passtype = $_POST['passtype']; $price = intval($_POST['price']); $tax = round($price * 0.035 + 0.3, 2); $id = $_SESSION['submission_id']; // prep connecting to db $fe = new FileEditor('login-info.txt'); $credentials = $fe->readFile(); $cred = new Credentials("terrapintango.cgpkve9uh8yp.us-east-1.rds.amazonaws.com", $credentials[0], $credentials[1], "tangodb", 3306); //$cred = new Credentials("localhost", "tango", "tango", "test"); $connection = new SQLConnector($cred); $connection->connect(); $query = "INSERT INTO `classes` (`registerid`, `classes`, `price`, `passtype`)\n VALUES ('{$id}', '{$selected_classes}', '{$price}', '{$passtype}');"; try { $connection->insert($query); } catch (Exception $e) { $error = $e->getMessage(); header("Location: error.php?sql_error={$error}"); } //print_r( $selected_classes); //echo "<br />"; //echo $price; ?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#"> <head>
<?php require_once "support.php"; require_once "dbLogin.php"; require_once "sqlconnector.php"; require_once "fileEditor.php"; require_once "classMapping.php"; require_once "personalClassInfo.php"; # update classes set classes = concat('hi', 'bye') where registerid = 108; $fe = new FileEditor('login-info.txt'); $credentials = $fe->readFile(); $login = new Credentials("terrapintango.cgpkve9uh8yp.us-east-1.rds.amazonaws.com", $credentials[0], $credentials[1], "tangodb"); $connector = new SQLConnector($login); $connector->connect(); echo "<script src='https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js'></script>"; if (isset($_POST['submit2'])) { // page 3 if (isset($_POST['check'])) { $classes_to_remove = $_POST['check']; } else { $classes_to_remove = array(); } if (isset($_POST['notin'])) { $classes_to_add = $_POST['notin']; } else { $classes_to_add = array(); } $class_string = $_POST['qstring']; $registerid = $_POST['registerid']; //echo "Class string".$class_string; if (strlen($class_string) > 1) {
<?php include_once "dbLogin.php"; include_once "sqlconnector.php"; echo "<link rel='stylesheet' href='signUpComplete.css' type='text/css' />"; session_start(); error_reporting(0); $host = "localhost"; $dbuser = "******"; $dbpassword = "******"; $database = "calendapp"; $table = "users"; $connector = new SQLConnector(new Credentials($host, $dbuser, $dbpassword, $database)); $connector->connect(); $UserName = $_SESSION['username']; $UserEmail = $_SESSION['email']; $UserProPic = $connector->retrieve("select profilepic from users where email='{$UserEmail}'")['profilepic']; if ($UserProPic == null) { $UserProPic = 'img/default.jpg'; } else { $UserProPic = "profilepics/" . $UserProPic; } if (isset($_POST["Return"])) { header('Location: main.php'); } /*************************************************************************/ $scriptName = $_SERVER["PHP_SELF"]; echo "\n\t <html>\n <head> \n <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /> \n\t\t <title>Sign Up Complete</title>\n <link rel='stylesheet' href='signUpComplete.css' type='text/css' />\n\t </head>\n\t\t <body>\n\t\t <div id='subtitle'>\n <img src='img/welcome.png' alt='Sign Up' id='signt'>\n </div>\n \n\t\t\t\t<form action='{$scriptName}' method='post' id='form'>\n\t\t\t\t <h2>You can now start posting and uploading pictures of the events around campus!</h2>\n\t\t\t\t\t<h3> To begin just go to the home page and click on the 'Post' button.<br /> If\n\t\t\t\t\tyou feel like browsing, just look thorugh the calendar.</h3>\n\t\t\t\t\t<p>\n\t\t\t\t\t\tUsername: {$UserName}</br><br>\n\t\t\t\t\t\tEmail: {$UserEmail}</br><br>\n\t\t\t\t\t\tProfile Picture: <br><img src='{$UserProPic}' alt='photo' id='profilepic' style='max-height: 200px'/></br>\n\t\t\t\t\t</p>\n\t\t\t\t\t</br>\n\t\t\t\t\t<p>\n\t\t\t\t\t<input type='submit' name='Return' value = 'Go to home page! 'id='join' />\n\t\t\t\t\t</p>\n\t\t\t\t</form>\n\t\t\t\t <div id='sub'>\n <img src='img/welcomeextra.png' alt='Sign Up' id='extra'>\n </div>\n\t\t\t</body>\n\t\t</html>";
<?php require_once "dbLogin.php"; require_once "sqlconnector.php"; require_once "fileEditor.php"; session_start(); session_unset(); // connect to db $fe = new FileEditor('login-info.txt'); $credentials = $fe->readFile(); $cred = new Credentials("terrapintango.cgpkve9uh8yp.us-east-1.rds.amazonaws.com", $credentials[0], $credentials[1], "tangodb", 3306); //$cred = new Credentials("localhost", "tango", "tango", "test"); $connection = new SQLConnector($cred); $connection->connect(); $first_name = $_POST['fname']; $last_name = $_POST['lname']; $email = $_POST['email']; $phone = $_POST['phone']; $ticket_type = $_POST['status']; $type = $_POST['dancer']; $partner_fname = "NULL"; $partner_lname = "NULL"; $partner_type = "NULL"; $sqli_ref = $connection->getConnection(); // Only if partner is selected if ($_POST['partner'] == "2") { $partner_fname = $_POST['fname2']; $partner_lname = $_POST['lname2']; $partner_type = $_POST['partnerdancerh']; $partner_fname = "'" . mysqli_real_escape_string($sqli_ref, $partner_fname) . "'"; $partner_lname = "'" . mysqli_real_escape_string($sqli_ref, $partner_lname) . "'";
include_once "dbLogin.php"; include_once "sqlconnector.php"; session_start(); echo "<link rel='stylesheet' href='main.css' type='text/css' />"; echo "<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600,600italic,700,700italic,800,800italic' rel='stylesheet' type='text/css'>"; echo "<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>"; if (isset($_POST['submitButton'])) { $month = $_POST['month']; $year = $_POST['year']; } else { $month = date("F"); $year = date("Y"); } $cred = new Credentials("localhost", "user", "user", "calendapp"); //update these to real values once we make the db $connection = new SQLConnector($cred); $connection->connect(); if (isset($_SESSION['username'])) { $user = $_SESSION['username']; } else { $user = "******"; } $query = "select profilepic from users where name=\"{$user}\""; //this kind of assumes user is the primary key, could rework with email $profpic = "profilepics/" . $connection->retrieve($query)['profilepic']; $numMonth = date('m', strtotime("{$month}")); $pics = $connection->retrieve("select * from photos where year(date) = '{$year}' and month(date) = '{$numMonth}'"); //Gets relevant pictures //print_r($pics); debugging $body = <<<HEREDOC
function drawPage() { global $credentials; $body = ""; $login = new Credentials("terrapintango.cgpkve9uh8yp.us-east-1.rds.amazonaws.com", $credentials[0], $credentials[1], "tangodb"); $connector = new SQLConnector($login); $connector->connect(); //print_r($result); if (isset($_POST['submit'])) { $fields = $_POST['field']; $fieldsString = implode(", ", $fields); foreach ($fields as $table) { if ($table == "ConfirmedRegistrants") { $query = "SELECT r.fname, r.lname, r.partnerfname, r.email, c.classes, c.passtype, c.price\n FROM records r, classes c, confirmation f\n WHERE r.registerid = c.registerid and r.registerid = f.registerid and\n f.payment_status = 'Completed'"; } else { $query = "select * from {$table}"; } $result = $connector->retrieve($query); $body .= "<h1>" . ucfirst($table) . "</h1>" . drawTable($result); } } else { if (isset($_POST['arbsubmitr'])) { $query = $_POST['arbtext']; $result = $connector->retrieve($query); $body .= "<h1>{$query}</h1>" . drawTable($result); } else { if (isset($_POST['arbsubmiti'])) { $query = $_POST['arbtext']; $error = false; try { $result = $connector->insert($query); } catch (Exception $e) { echo $e->getMessage(); $error = true; } if (!$error) { $body .= "Query successful."; } $body .= "<p><form action='admin.php' method=POST><input type='submit' value='Back'></form></p>"; } else { if (isset($_POST['classprint'])) { header("Location: classBalanceInfo.php"); } else { if (isset($_POST['mapping'])) { echo print_class_info(); } else { if (isset($_POST['edit'])) { header("Location: editdb.php"); } else { $body = <<<BODY <h1> Database Access </h1> <form action="admin.php" method="post"> <p> <strong>Select tables to display</strong><br /> <select name="field[]" multiple="multiple"> <option value="records">Records</option> <option value="classes">Classes</option> <option value="confirmation">Confirmation</option> <option value="ConfirmedRegistrants">Confirmed registrations</option> </select> </p> <p> <input type="submit" name="submit" value="Display Tables"> </p> <p> <input type='text' name='arbtext'> </p> <p> <input type='submit' name='arbsubmitr' value='Submit arbitrary query (Get response)'> <input type='submit' name='arbsubmiti' value='Submit arbitrary query (Do not get response)'> </p> \t\t\t\t\t<p> \t\t\t\t\t\t<input type='submit' name='classprint' value='Class Balance Info'> \t\t\t\t\t</p> <p> \t\t\t\t\t\t<input type='submit' name='mapping' value='Confirmed Schedules'> \t\t\t\t\t</p> <p> \t\t\t\t\t\t<input type='submit' name='edit' value='Edit Classes'> \t\t\t\t\t</p> </form> BODY; } } } } } } echo generatePage($body, "Admin Panel"); }
$class_limit = 20; // 20 leaders, 20 followers $fri_milonga_limit = 150; $sat_milonga_limit = 300; $sun_milonga_limit = 100; $yoga_limit = 100; // map table indices to events $milongas = array(5, 19, 33); $yogas = array(14, 28); // start, end ranges for each day $day1 = array("min" => 2, "max" => 3); $day2 = array("min" => 8, "max" => 17); $day3 = array("min" => 22, "max" => 31); $cred = new Credentials("terrapintango.cgpkve9uh8yp.us-east-1.rds.amazonaws.com", $credentials[0], $credentials[1], "tangodb", 3306); //$cred = new Credentials("localhost", "tango", "tango", "test"); $connection = new SQLConnector($cred); $connection->connect(); try { $class_info = $connection->retrieve("SELECT c.classes, r.dancertype, r.partnerfname\n FROM records r, classes c, confirmation f\n WHERE r.registerid = c.registerid and r.registerid = f.registerid and\n f.payment_status = 'Completed';"); } catch (Exception $e) { echo $e->getMessage(); } // handle case for one entry in db if (isset($class_info['classes'])) { $class_info = array($class_info); } $master_class_list = new Defaultdict(array("LEADER" => 0, "FOLLOWER" => 0)); // <3 from python // loop through entries //print_r($class_info); foreach ($class_info as $entry) {
<?php session_start(); require_once "dbLogin.php"; require_once "sqlconnector.php"; if (isset($_POST["Login"])) { $host = "localhost"; $dbuser = "******"; $dbpassword = "******"; $database = "calendapp"; $table = "users"; $connector = new SQLConnector(new Credentials($host, $dbuser, $dbpassword, $database)); $connector->connect(); $warning = ""; $username = trim($_POST["username"]); $sqlQuery = sprintf("select name, password from %s where name='%s'", $table, $username); if (!($result = $connector->retrieve($sqlQuery))) { $warning = "Whoops! Seems like you haven't signed up yet! Click below to sign up! (username not found)"; } else { if (password_verify($_POST['password'], $result['password'])) { $warning = "Logged in!"; $_SESSION['loggedIn'] = true; //Stay logged in $_SESSION['username'] = $username; $_SESSION['email'] = $connector->retrieve("select email from users where name='{$username}'")['email']; header("Location: main.php"); } else { $warning = "Wrong password!"; } } }
<?php require_once "uploadimage.php"; require_once "dbLogin.php"; require_once "sqlconnector.php"; session_start(); if (isset($_SESSION['username'])) { $CurrentUserName = $_SESSION['username']; } else { $CurrentUserName = "******"; } $host = "localhost"; $dbuser = "******"; $dbpassword = "******"; $database = "calendapp"; $table = "users"; $connector = new SQLConnector(new Credentials($host, $dbuser, $dbpassword, $database)); $connector->connect(); $CurrentEmail = ""; $DateJoined = $connector->retrieve("select joined from users where name='{$_SESSION['username']}'")['joined']; if (isset($_POST['submit'])) { $w = new ImageWorker(null); //no sql here $id = $w->uploadToDir("/profilepics", "filename"); $connector->insert("update users set profilepic='{$id}' where name='{$_SESSION['username']}'"); } $ProPic = "profilepics/" . $connector->retrieve("select profilepic from users where email='{$_SESSION['email']}'")['profilepic']; echo "\n <html>\n <head>\n <title>Profile</title>\n <link rel='stylesheet' href='profile.css' type='text/css' />\n </head>\n <body>\n <a href='main.php'> <img src='img/CalendAppLogo.png' width='256' height='73' alt='CalendApp' id='logo'> </a>\n <div id='subtitle'>\n <img src='img/Pro.png' alt='Profile' id='subtitle'>\n </div>\n \n <form action='profile.php' enctype='multipart/form-data' method='post' id='form'>\n\t\t\t <h1>{$CurrentUserName}</h1>\n <img src='{$ProPic}' alt = 'Profile Picture' id='propic'/>\n\t\t\t <p>\n Date Joined: {$DateJoined}\n </p>\n <p id='upload'>\n Upload New Profile Picture\n <input type='file' name='filename'/><br /><input type='submit' name='submit' value='Upload'>\n </p>\n \n \n </form> \n </body>\n </html>";
<?php require_once 'ipn/ipnlistener.php'; require_once "fileEditor.php"; require_once "sqlconnector.php"; require_once "dbLogin.php"; ini_set('log_errors', true); ini_set('error_log', dirname(__FILE__) . '/ipn_errors.log'); $listener = new IpnListener(); //$listener->use_sandbox = true; $listener->use_curl = false; $fe = new FileEditor('login-info.txt'); $credentials = $fe->readFile(); $cred = new Credentials("terrapintango.cgpkve9uh8yp.us-east-1.rds.amazonaws.com", $credentials[0], $credentials[1], "tangodb", 3306); //$cred = new Credentials("localhost", "tango", "tango", "test"); $connection = new SQLConnector($cred); $connection->connect(); $fe1 = new FileEditor("log.txt"); $fe1->writeToFile("Run"); try { $verified = $listener->processIpn(); } catch (Exception $e) { // fatal error trying to process IPN. $fe1->writeToFile($e); exit(0); } if (isset($_GET['submission_id'])) { $id = $_GET['submission_id']; } else { $id = 22; // debug