public function dispatchLoopStartup(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) { $session = Yaf_Session::getInstance(); if (!isset($_COOKIE['wrm_uuid'])) { $identify = uniqid() . $_COOKIE['PHPSESSID']; setcookie('wrm_uuid', $identify, time() + 604800, '/', ".renmai.cn"); } else { setcookie('wrm_uuid', $_COOKIE['wrm_uuid'], time() + 604800, '/', ".renmai.cn"); } $isLogin = LoginHandler::isLogin(); if (!$isLogin) { $_REQUEST['login'] = false; if ($this->isGuestAccessible($request)) { return; } else { if ($request->get('trace_type') == 'ajax') { echo json_encode(array('code' => -1999, 'data' => array('login_status' => 0))); haloDie(); } else { $this->goLoginWithBackUrl(); } return; } } else { $_REQUEST['login'] = true; $this->syncSession($session, $response); $this->userAccessRedirect($request); // $model = UserAuthModel::singleton(); // $userInfo = $model->getBasicAuthInfo($this->getObjectId(),2); // var_dump($userInfo); } }
public function __construct($request, $action, $dbConnection) { $this->request = $request; switch ($action) { case 'login': $this->template = 'login' . DIRECTORY_SEPARATOR . 'login'; LoginHandler::login($request['username'], $request['password'], $dbConnection); break; default: $this->template = 'login' . DIRECTORY_SEPARATOR . 'default'; break; } }
} Database::Open(); $context = new Context(); $context->setPageID("home"); if (isset($_GET['pageid'])) { $context->setPageID($_GET['pageid']); } else { if (isset($_POST['pageid'])) { $context->setPageID($_POST['pageid']); } } if (isset($_POST['action'])) { $action = $_POST['action']; if ($context->getPageID() == "login") { require_once './lib/Form/LoginHandler.php'; $loginHandler = new LoginHandler(); $loginHandler->handleForm($context, $action); } else { if ($context->getPageID() == "register") { require_once './lib/Form/RegisterHandler.php'; $registerHandler = new RegisterHandler(); $registerHandler->handleForm($context, $action); } else { if ($context->getPageID() == "createInsertion") { require_once './lib/Form/CreateInsertionHandler.php'; $createInsertionHandler = new CreateInsertionHandler(); $createInsertionHandler->handleForm($context, $action); } else { if ($context->getPageID() == "myAccount") { require_once './lib/Form/MyAccountHandler.php'; $myAccountHandler = new MyAccountHandler();
<?php error_reporting(E_ALL ^ E_DEPRECATED); require_once '../config.php'; require_once BASE_PATH . '/login_handler.php'; require_once BASE_PATH . '/components/nav.php'; require_once BASE_PATH . '/medoo.min.php'; //check login status $login = new LoginHandler($config); if (!$login->is_logged_in()) { $login->redirect_login('Please login'); } $userid = $_SESSION['userid']; $con = mysql_connect($config['db']['server'], $config['db']['username'], $config['db']['password']); //change configs $db = mysql_select_db($config['db']['database_name'], $con); //change database $c_id = $_POST["courseid"]; foreach ($_POST as $key => $value) { if ($key != "courseid") { // echo "$key"."-->"."$value[0]"."<br>"; // echo "$key"."-->"."$value[1]"."<br>"; // echo "<br>"."<br>"; mysql_query("INSERT INTO `feedback` (`question_id`,`answer`,`comment`,`courseid`) VALUES ('{$key}','{$value['0']}','{$value['1']}','{$c_id}')") or die(mysql_error()); } } //update student course linkage $db = new medoo($config['db']); $db->update('student_course', ['done' => 1], ["AND" => ['student' => $userid, 'course' => $c_id]]); ?> <!DOCTYPE html>
<?php error_reporting(E_ALL ^ E_DEPRECATED); date_default_timezone_set('Indian/Maldives'); require_once '../config.php'; require_once BASE_PATH . '/login_handler.php'; require_once BASE_PATH . '/medoo.min.php'; //check login status $login = new LoginHandler($config); if (!$login->is_logged_in()) { $login->redirect_login('Please login'); } if ($login->get_user_type() != 'prof') { $login->not_authorized_error(); } if (isset($_GET['operation'])) { header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename=' . date('j\\-m\\-Y\\-\\f\\e\\e\\d\\b\\a\\c\\k') . '.csv'); $con = mysql_connect($config['db']['server'], $config['db']['username'], $config['db']['password']); //change configs $db = mysql_select_db($config['db']['database_name'], $con); //change database $c_id = $_GET['courseid']; $result = mysql_query("SELECT * FROM questions WHERE courseid='{$c_id}'") or die(mysql_error()); $t = 0; while ($row = mysql_fetch_array($result)) { $question[] = $row['question']; $q_id[] = $row['q_id']; $type[] = $row['type']; $t++; }
require_once 'PHP/firebasephp/firebaseLib.php'; //extendedexception files, Will add more over time. require_once 'PHP/extendedexception/errorcodeininput.php'; require_once 'PHP/extendedexception/erroremptyinput.php'; require_once 'PHP/extendedexception/errorusernameexist.php'; require_once 'PHP/extendedexception/errorpasswordnomatch.php'; require_once 'PHP/extendedexception/errorwrongcredentials.php'; require_once 'PHP/extendedexception/erroroverlayingerror.php'; require_once 'PHP/extendedexception/errorwhitespaceusername.php'; //class the firebase database $firebase = new \firebase\FirebaseLib('https://frontpagecustom.firebaseio.com/', 'hKaHrJbh6NSCLXWjrBtqgCvepeYB6fF0dviia05D'); $DataBase = new DataBase($firebase); $SessionModel = new SessionModel(); $LoginModel = new LoginModel($SessionModel, $DataBase); $RegisterModel = new RegisterModel($SessionModel, $DataBase); $OptionsModel = new OptionsModel($SessionModel, $DataBase); $MainModel = new MainModel($SessionModel); $MainView = new MainView(); $OptionsView = new OptionsView(); $LoginView = new LoginView(); $RegisterView = new RegisterView(); $RegisterHandler = new RegisterHandler($RegisterView, $RegisterModel); $LoginHandler = new LoginHandler($LoginView, $LoginModel, $DataBase); $OptionsHandler = new OptionsHandler($OptionsView, $OptionsModel); $MainHandler = new MainHandler($MainView, $MainModel); $ViewHandler = new ViewHandler(); $LoginToken = $LoginHandler->login(); $RegisterHandler->register(); $OptionsHandler->options(); $MainHandler->logout(); $ViewHandler->render($LoginToken, $DataBase, $RegisterView, $LoginView, $OptionsView, $MainView);
<?php require_once 'config.php'; require_once BASE_PATH . '/medoo.min.php'; require_once BASE_PATH . '/login_handler.php'; $login = new LoginHandler($config); if (isset($_POST['username'])) { //do login verification and redirect back to login if ($login->user_login($_POST['username'], $_POST['password'])) { $login->redirect_login('Logging in'); } else { $login->redirect_login('Incorrect username/password'); } } else { //check login and decide redirection / login fields //check login status if ($login->is_logged_in()) { $db = new medoo($config['db']); $result = $db->select('users', ['type'], ['userid' => $_SESSION['userid']]); if ($result[0]['type'] == 'student') { //redirect to course dashboard header('Location: ' . $config['url']['base_url'] . $config['url']['student_dashboard']); } else { if ($result[0]['type'] == 'prof') { header('Location: ' . $config['url']['base_url'] . $config['url']['prof_dashboard']); } else { //redirect to admin panel header('Location: ' . $config['url']['base_url'] . $config['url']['admin_dashboard']); } } } else {
public static function isLogin() { if (isset($_REQUEST['login'])) { return $_REQUEST['login']; } if (!isset($_COOKIE['wrm_aid']) || !isset($_COOKIE['wrm_atype'])) { return false; } else { $cookieId = UidEncryptUtil::decryptUid($_COOKIE['wrm_aid']); $cookieType = $_COOKIE['wrm_atype']; $session = Yaf_Session::getInstance(); $oauthId = $session->offsetGet('wrm_oauth_id'); $oauthType = $session->offsetGet('wrm_oauth_type'); $oauthExpire = intval($session->offsetGet('wrm_oauth_expire')); $oauthToken = $session->offsetGet("wrm_oauth_token"); self::getClient($cookieType); if ($cookieId != $oauthId || $cookieType != $oauthType) { if (!empty($oauthId)) { self::delSession(); } return false; UserApi::getAccessToken($cookieId, $cookieType); $oauthToken = $session->offsetGet("wrm_oauth_token"); } if (empty($oauthToken)) { self::delSession(); self::delCookie(); return false; } if ($oauthExpire > time()) { self::$client = null; self::getClient($cookieType); return true; } else { if (!empty($oauthId) && !empty($oauthType)) { $client = self::getClient($oauthType); $client->getAccessToken(); if ($client->expireTime > time()) { return true; } } self::delSession(); self::delCookie(); return false; } } }
<?php require_once 'config.php'; require_once BASE_PATH . '/login_handler.php'; $login = new LoginHandler($config); if ($login->is_logged_in()) { $login->user_logout(); $login->redirect_login('Logged out Successfully'); } else { $login->redirect_login('You are not logged in'); }