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;
}
Example #2
0
    // echo $query;
    try {
        $connector->insert($query);
    } catch (Exception $e) {
        echo $e->getMessage();
    }
    echo "Table updated.";
    echo "<p><form action='editdb.php' method=POST><input type='submit' name='xyz' value='Back'></form></p>";
} else {
    if (isset($_POST['submit'])) {
        // page 2
        $registerid = $_POST['radio'];
        $query = "SELECT r.fname, r.lname, c.classes\n            FROM  records r, classes c\n            WHERE c.registerid = {$registerid} and r.registerid = c.registerid";
        $table = "<table border ='1' id='table'><th align='center'>Remove</th><th align='center'>Class</th>";
        try {
            $result = $connector->retrieve($query);
        } catch (Exception $e) {
            echo $e->getMessage();
        }
        $fname = ucfirst($result['fname']);
        $lname = ucfirst($result['lname']);
        $header = "<h1>Classes for {$fname} {$lname}</h1>";
        $class_string = $result['classes'];
        $classes = explode(",", $class_string);
        $all_classes = array_keys(get_classes());
        //print_r($all_classes);
        $not_in = array();
        foreach ($all_classes as $c) {
            if (!in_array($c, $classes)) {
                array_push($not_in, $c);
            }
Example #3
0
<?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>";
    $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) . "'";
    $partner_type = "'" . mysqli_real_escape_string($sqli_ref, $partner_type) . "'";
}
// escape strings
$first_name = mysqli_real_escape_string($sqli_ref, $first_name);
$last_name = mysqli_real_escape_string($sqli_ref, $last_name);
$email = mysqli_real_escape_string($sqli_ref, $email);
$phone = mysqli_real_escape_string($sqli_ref, $phone);
// store into db
$query = "INSERT INTO `records` (`fname`, `lname`, `email`, `phone`, `tickettype`,\n        `dancertype`, `partnerfname`, `partnerlname`, `registerid`) VALUES\n        ('{$first_name}', '{$last_name}', '{$email}', '{$phone}', '{$ticket_type}',\n        '{$type}', {$partner_fname}, {$partner_lname}, NULL);";
try {
    $connection->insert($query);
} catch (Exception $e) {
    $error = $e->getMessage();
    header("Location: error.php?sql_error={$error}");
}
$id = $connection->retrieve("SELECT LAST_INSERT_ID();");
// store id and partner type into session
$_SESSION['submission_id'] = $id["LAST_INSERT_ID()"];
$_SESSION['ticket_type'] = $ticket_type;
$_SESSION['dancertype'] = $type;
if ($partner_fname != "NULL") {
    $_SESSION['partner_pass'] = true;
} else {
    $_SESSION['partner_pass'] = false;
}
header("Location: form.php");
Example #5
0
} 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
        
        <a href="main.php"> <img src="img/CalendAppLogo.png" width="256" height="73" alt="CalendApp" id="logo"> </a>
        <span id="calendarTitle">
            <h1>{$month} {$year}</h1>
        </span>
        <div id="profile">
            <img src='{$profpic}' alt={$user} width='50' height='50'>
            Hello, {$user}!
            <br />
            <a href='profile.php'>Edit Profile</a> 
Example #6
0
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");
}
Example #7
0
$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) {
    $split = explode(",", $entry['classes']);
    if (sizeof($split) > 1) {
        // empty class string
Example #8
0
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!";
        }
    }
}
?>
Example #9
0
<?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>";