Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 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');";
 }
Exemplo n.º 4
0
 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();
 }
Exemplo n.º 5
0
 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();
 }