private function collectData() { //Var that needs to be declared, otherwise it will parse an undev error. $userlistRow[0]['user_name'] = null; //Query for username, profile image path, total amount of money, lates login date. parent::setQuery("SELECT id, user_name, user_profile_pic, coins, lates_login FROM `usrlist` WHERE id IN ( SELECT person FROM `sessions` WHERE session_id = '" . $_SESSION['user'] . "') LIMIT 1;"); $usrlistRow = parent::pdoExec(); //Query that gathers all consumed cups of coffee of a user. //parent::setQuery("SELECT SUM(cups_consumed) FROM `coffee_session_candidates` WHERE user= '******'user_name']."';"); $cups = 0; parent::setQuery("SELECT SUM(coins) FROM `usrlist`;"); $tcoins = parent::pdoExec(); $usrlistRow[0]['tcoins'] = $tcoins[0][0]; if (empty($usrlistRow[0]['user_profile_pic'])) { $usrlistRow[0]['user_profile_pic'] = $_SERVER['DOCUMENT_ROOT'] . "/coffee2.0/style/imgs/profile_pics/default.png"; } $cb = $_SERVER['DOCUMENT_ROOT'] . "/coffee2.0/style/imgs/profile_pics/" . $usrlistRow[0]['user_profile_pic']; $path = $cb; $ext = pathinfo($path, PATHINFO_EXTENSION); $usrlistRow[0]['user_profile_pic'] = $this->base64_encode_image($cb, $ext); //First login if (is_array($cups) || is_null($cups)) { $cups = 0; } $usrlistRow[0]['cups_consumed'] = $cups; $this->result = $usrlistRow; }
private function completeUserRegistartion() { parent::setQuery("DELETE FROM `registration_tokens` WHERE `token` ='" . strrev($_SESSION['tempRegSes'][0]) . "';"); parent::pdoExec(); $hands = $this->creatLoginPass(); parent::setQuery("UPDATE `usrlist` SET user_hash = '" . $hands['h'] . "', user_salt='" . $hands['s'] . "' WHERE user_name= '" . $_SESSION['tempRegSes'][1] . "';"); parent::pdoExec(); $newHash = substr(bin2hex(mcrypt_create_iv(14, MCRYPT_DEV_URANDOM)), 0, 13); $newExpirData = date('Y-m-d H:i:s', time() + 7 * 24 * 60 * 60); //echo "UPDATE `sessions` SET `session_id` = '".$newHash."', `expir_date` = '".$newExpirData."' WHERE `person` = '".$this->sqlResults['login'][0]['id']."';"; parent::setQuery("INSERT INTO `sessions` (session_id, person, expir_date, priv_lvl) VALUES ('" . $newHash . "', '" . $this->userID . "', '" . $newExpirData . "', 1);"); parent::pdoExec(); unset($_SESSION); session_destroy(); session_unset(); return "<script>alert('success');"; }
<button onclick="window.location.href=\'/coffee2.0/register.php\'" type="button" class="btn btn-default navbar-btn">Registreren</button>'; } else { echo '<button onclick="window.location.href=\'/coffee2.0/menu.php\'" type="button" class="btn btn-default navbar-btn">Go to Menu</button> <button onclick="window.location.href=\'/coffee2.0/logout.php\'" type="button" class="btn btn-default navbar-btn">Logout</button>'; } ?> <button type="button" class="btn btn-default navbar-btn" data-toggle="modal" data-target="#modal-about">About</button> </div> </div> </nav> <?php if (isset($_SESSION['user'])) { echo $_SESSION['user']; } if (isset($_POST['login'])) { $login = new coffee("login", array($_POST['usr'], $_POST['passwd'])); echo $login->rtrnAll(); } ?> <!-- about-model --> <div class="modal fade" id="modal-about" role="dialog"> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">About Coffee Project</h4> </div> <div class="modal-body"> <p>This is a simple reservation (coffee) system.</p>
<?php /** * @author Kevin Lorenzo Storms * @version 2.0 * * This file receives uploaded profile pictures. * Processes it in the database, and it stores the image serverside with a random generaded name. * */ require_once $_SERVER['DOCUMENT_ROOT'] . '/coffee2.0/_funct/coffee.php'; if (isset($_POST['f']) && !empty($_POST['f'])) { if (isset($_POST['p']) && !empty($_POST['p'])) { $functionTroughAjax = new coffee($_POST['f'], $_POST['p']); } else { $functionTroughAjax = new coffee($_POST['f']); } print_r(json_encode($functionTroughAjax->rtrnAll())); } if (isset($_POST['s'])) { if (!isset($_SESSION['coffeeSession']) || empty($_SESSION['coffeeSession'])) { echo '06'; } else { echo $_SESSION['coffeeSession']; } } //if a File is beeing upload $_GET['f'] = null; if (isset($_FILES) && $_GET['f'] == "profilePhotoUpload") { //checks if there is a file received. if ($_FILES['file']['error'] < 0) {
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/coffee2.0/_funct/coffee.php'; if (!empty($_SESSION['user']) && isset($_SESSION['user'])) { $getUserData = new coffee('renderTemplate'); echo $getUserData->rtrnAll(); } else { echo "<script>alert('First Login');</script>"; echo '<meta http-equiv="refresh" content="0; url=http://' . DOMAIN . '/coffee2.0/" />'; } if (isset($_POST['createNewUser'])) { $newUSer = new coffee('new_user', $_POST); echo $newUSer->rtrnAll(); }
private function search() { parent::setQuery("SELECT * \n\t\t\tFROM `registration_tokens` \n\t\t\tJOIN `usrlist` \n\t\t\tON registration_tokens.user_name = usrlist.id\n\t\t\tWHERE token= '" . $this->submtoken . "';"); return parent::pdoExec(); }
<?php $coffee = new coffee(); if (empty($coffee)) { $coffee->refill(); } else { $coffee->drink(); } ?> // just correcting
<label>Registration form,<br> please enter a valid registration token</label> <div class="panel-body"> <div class="input-group"> <input type="text" class="form-control" name="token" title="token" placeholder="Token" required> <span class="input-group-btn"> <input class="btn btn-default" type="submit" name="GO" title="GO" value="GO"> </span> </form> </div><!-- /input-group --> <?php ///print_r($_SESSION); if (isset($_POST['GO']) && !empty($_POST['token'])) { $regis = new coffee("checkToken", $_POST['token']); echo $regis->rtrnAll(); header('Location: http://localhost/coffee2.0/register.php'); } if (isset($_POST['register'])) { if (isset($_POST['passw1']) && isset($_POST['passw2'])) { if ($_POST['passw1'] == $_POST['passw2']) { $complReg = new coffee("register", array($_POST['passw1'], $_POST['passw2'])); echo "<script>alert('registered successfully!');</script>"; header('Location: http://localhost/coffee2.0'); } else { echo "the passwords do not match"; } } } if (isset($_SESSION['tempRegSes']) && !empty($_SESSION['tempRegSes'][2])) {
private function refreshCoffeeSessions() { parent::setQuery("SELECT `session_id` \n\t\t\t\t\t\t FROM `coffee_session_candidates` \n\t\t\t\t\t\t WHERE user_name IN (\n\t\t\t\t\t\t SELECT user_name \n\t\t\t\t\t\t FROM `usrlist` \n\t\t\t\t\t\t WHERE id IN ( \n\t\t\t\t\t\t SELECT person FROM `sessions` WHERE session_id = '" . $_SESSION['user'] . "')) LIMIT 1"); $availableCoffeeSession = parent::pdoExec(); if (!empty($availableCoffeeSession[0]['session_id'])) { $_SESSION['coffeeSession'] = $availableCoffeeSession[0]['session_id']; } parent::setQuery("SELECT * FROM `coffee_sessions`;"); return parent::pdoExec(); }
private function renewSession() { // $stmt = $this->connPDO->prepare("SELECT * FROM `sessions` WHERE `person` = '".$this->sqlResults['login']['id']."';"); $newHash = substr(bin2hex(mcrypt_create_iv(14, MCRYPT_DEV_URANDOM)), 0, 14); $newExpirData = date('Y-m-d H:i:s', time() + 7 * 24 * 60 * 60); //echo "UPDATE `sessions` SET `session_id` = '".$newHash."', `expir_date` = '".$newExpirData."' WHERE `person` = '".$this->sqlResults['login'][0]['id']."';"; parent::setQuery("UPDATE `sessions` SET `session_id` = '" . $newHash . "', `expir_date` = '" . $newExpirData . "' WHERE `person` = '" . $this->sqlResults['login'][0]['id'] . "';"); parent::pdoExec(); return $newHash; }