public function showAll() { session_start(); $login = new Login(); $id = $login->isLogged(); if ($id) { $user = new User($id); $regNumber = $user->regNumber; $data["user"] = $user; //echo $regNumber; } else { header('Location: http://localhost/WEB_Projeto_Final/public_html/home'); } $show_questions = new Questao(); $results = $show_questions->getAll(); $getSubjects = $show_questions->getSubjects($regNumber); //var_dump($getSubjects); $data["subjects"] = array_unique($getSubjects); $data['questions'] = $results; $data['images'] = $show_questions->getImages($results); $data['answers'] = $show_questions->getAnswer($results); $this->view('questoes/listar', $data); // echo $result[0]->value; // var_dump($results); }
public function g() { session_start(); $data = array(); $loginClass = new Login(); $id = $loginClass->isLogged(); if ($id) { $notif = new Notifications(); $notif->newNotification(2, 0); } else { $this->redirect(''); } }
public function home($params = null) { session_start(); $data = array(); $loginClass = new Login(); $id = $loginClass->isLogged(); if ($id) { $user = new User($id); $data['user'] = $user; $this->view('panel', $data); } else { $this->view('index'); } }
public function processLogin() { ob_start(); set_include_path(implode(PATH_SEPARATOR, array(realpath(ROOT_PATH . DS . TEMPLATE_DIR), realpath(ROOT_PATH . DS . PAGES_DIR), get_include_path()))); //process cPage de load duoc trang log in $url = $_SERVER['REQUEST_URI']; if (substr($url, 0, 1) == '/') { $url = substr($url, 1); } if (substr($url, -1) == '/') { $url = substr($url, 0, -1); } $url = explode('?', $url)[0]; $url = explode('/', $url); array_shift($url); $cPage = array_shift($url); $this->cPage = $cPage; if (Login::isLogged()) { //echo '1'; $this->processURL($cPage, $url); } else { //echo '2'; if (Login::checkCookie()) { //echo '2'; $this->processURL($cPage, $url); } else { //echo '3'; if ($cPage == 'login') { require_once ROOT_PATH . DS . PAGES_DIR . DS . $cPage . '.php'; } else { Helper::redirect(Login::$_login_page); } } } ob_get_flush(); //$cPage = $this->objURL->cpage; //$params = $this->objURL->params; //process Login //if(in_array($cPage, Login::$_not_required)) { // // require_once(ROOT_PATH.DS.PAGES_DIR.DS.$cPage.'.php'); // // } else { // // // } }
public static function mostrar($mensaje = '') { // IDEA obtener la instancia de Slim (como se hace aquí) en todos los métodos que la requieran para evitar tener que pasar la referencia en todas las llamadas $app = \Slim\Slim::getInstance(); global $twig; $r = Dictado::escuchar($app->db, Login::getEmail()); if (is_null($r)) { $valores['message'] = "¡<b>Enhorabuena</b>! <br>A día de hoy ha realizado correctamente todos nuestros dictados. <br> ¿Se animaría a <a href='/dictado/crear'>crear uno nuevo</a>?"; // Avisamos al administrador que alguien ha conseguido realizar todos los dictados para que cree alguno nuevo Email::enviar(Email::ADMIN_EMAIL, 'Dictados agotados', Email::getMessageDictadosTerminados(Login::getEmail())); } else { $valores = array('dictado' => json_encode($r), 'id_dictado' => $r['ID']); // IDEA Sería interesante que este mensaje desapareciese al rato de aparecer en pantalla if ($mensaje != '') { $valores['message'] = $mensaje; } if (!Login::isLogged()) { $valores['consejo'] = "Para evitar dictados repetidos, <a href='/usuario/login'><strong>identifícate</strong></a>"; } } echo $twig->render('dictadoEscuchar.php', $valores); }
<?php session_start(); if (Login::isLogged(Login::$_login_front)) { Helper::redirect(Login::$_dashboard_front); } $objForm = new Form(); $objValid = new Validation($objForm); $objUser = new User(); // login form if ($objForm->isPost('login_email')) { if ($objUser->isUser($objForm->getPost('login_email'), $objForm->getPost('login_password'))) { Login::loginFront($objUser->_id, Url::getReferrerUrl()); } else { $objValid->add2Errors('login'); } } // registration form if ($objForm->isPost('first_name')) { $objValid->_expected = array('first_name', 'last_name', 'address_1', 'address_2', 'town', 'county', 'post_code', 'country', 'email', 'password', 'confirm_password'); $objValid->_required = array('first_name', 'last_name', 'address_1', 'town', 'county', 'post_code', 'country', 'email', 'password', 'confirm_password'); $objValid->_special = array('email' => 'email'); $objValid->_post_remove = array('confirm_password'); $objValid->_post_format = array('password' => 'password'); // validate password $pass_1 = $objForm->getPost('password'); $pass_2 = $objForm->getPost('confirm_password'); if (!empty($pass_1) && !empty($pass_2) && $pass_1 != $pass_2) { $objValid->add2Errors('password_mismatch'); } $email = $objForm->getPost('email');
// Cierra la sesión de usuario $app->get('/logout', function () use($app) { global $twig; unset($_SESSION['user']); session_destroy(); echo $twig->render('inicio.php'); }); // Accion asociada al email de login $app->get('/autenticar/:token', function ($token) use($app) { $email = $app->request->get('email'); // Si intentan autenticarse (estando ya logados en el sistema) ignoramos el token vílmente // (si quieres entrar, estando ya dentro... pues disfruta) if (Login::isLogged()) { $email = Login::getEmail(); } if (Login::isLogged() || Login::autenticar($app->db, $email, $token)) { global $twig; echo $twig->render('inicio.php', array('message' => "Bienvenido/a <b>{$email}</b>")); } else { global $twig; echo $twig->render('login.php', array('error' => 'El enlace de acceso utilizado ya <strong>no está en vigor</strong>.<br>Indique su dirección de correo electrónico y le enviaremos uno válido.<br>Disculpe las molestias.')); } }); }); $app->group('/dictado', function () use($app) { // Anota que un usuario ha realizado todos los dictados para poder avisarle cuando se cree uno nuevo $app->get('/avisar', 'Login::forzarLogin', function () use($app) { Dictado::avisar($app->db, Login::getEmail()); }); $app->get('/escuchar', function () use($app) { Dictado::mostrar();
public function getAll() { $login = new Login(); $id = $login->isLogged(); if ($id) { $user = new User($id); $regNumber = $user->regNumber; // echo $regNumber; } else { header('Location: http://localhost/WEB_Projeto_Final/public_html/home'); } $query_questoes = DB::conn()->prepare("SELECT * FROM __questions_question WHERE regNumber = {$regNumber} "); $query_questoes->execute(); /* $query_options = DB::conn()->prepare("SELECT * FROM __questions_options "); $query_options->execute(); $query_open = DB::conn()->prepare("SELECT * FROM __question_open "); $query_open->execute(); */ $query = $query_questoes->fetchAll(PDO::FETCH_OBJ); /* $query['questions'] = $query_questoes->fetchAll(PDO::FETCH_OBJ); $query['options'] = $query_options->fetchAll(PDO::FETCH_OBJ); $query['open'] = $query_open->fetchAll(PDO::FETCH_OBJ); */ return $query; }
// echo ' '; // echo 'id '.$result['id']; ?> </a></h5> <?php if (Login::isLogged()) { echo '<div id="logged_as">Logged in as: <a href="' . $this->objPage->generateURL('member', array('id' => $current_user['id'])) . '"><strong>' . $current_user['name'] . '</strong></a> | <a href="/sugarkms/logout">Logout</a></div>'; } ?> </div> </div> <div id="outer"> <div id="wrapper"> <div id="left"> <?php if (Login::isLogged()) { ?> <h2>Directory Panels </h2> <ul class="navigation"> <li><a href="<?php echo $this->objPage->generateURL('member'); ?> ">Search Member</a></li> <li><a href="<?php echo $this->objPage->generateURL('project'); ?> " >Search Project</a></li> <li><a href="<?php echo $this->objPage->generateURL('exco'); ?> ">Search EXCO</a></li>
<?php if (Login::isLogged(Login::$_login_admin)) { echo '<div id="logged_as">Logged in as: <strong>'; echo Login::getFullNameFront(Session::getSession(Login::$_login_admin)); echo '</strong> | <a href="/admin/?page=logout">Logout</a></div>'; } else { echo '<div id="logged_as"><a href="/admin/">Login</a></div>'; } ?> </div> </div> <div id="outer"> <div id="wrapper"> <div id="left"> <?php if (Login::isLogged(Login::$_login_admin)) { ?> <h2>Navigation</h2> <div class="dev br_td"> </div> <ul id="navigation"> <li> <a href="/admin/?page=products" <?php echo Helper::getActive(array('page' => 'products')); ?> > products </a> </li> <li> <a href="/admin/?page=categories"
public function add() { session_start(); $subject = $_POST["subject_opt"]; $type = $_POST["type"]; $tags = $_POST["tags"]; $difficulty = $_POST['difficulty']; $question = $_POST["question"]; $i = 1; $opcoes = array(); $resp = array(); $correct = array(); $file["file_name"] = ""; $file["img_name"] = ""; $login = new Login(); $id = $login->isLogged(); if ($id) { $user1 = new User($id); var_dump($user1); $regNumber = $user1->regNumber; echo "regNumber: {$regNumber} "; } else { header('Location: http://localhost/WEB_Projeto_Final/public_html/showInserir'); } if (isset($_FILES["img"])) { $image = $_FILES["img"]; echo "<br>Image name-> " . $image["name"] . ",algo?"; //Precisa checar se a pasta existe ? $folder = "images/questions/"; $file["img_name"] = $image["name"]; $file["file_name"] = $folder . $image["name"]; move_uploaded_file($image["tmp_name"], $file["file_name"]); } switch ($type) { case '1': while (!empty($_POST["opt" . $i])) { $opcoes[$i - 1] = $_POST["opt" . $i]; $resp[$i - 1] = $_POST["answer_op" . $i]; $correct[$i - 1] = 1; $i++; } break; case '2': while (!empty($_POST["opt" . $i])) { $opcoes[$i - 1] = $_POST["opt" . $i]; $correct[$i - 1] = 0; $i++; } $indice = $_POST["answer_mc"]; echo $indice; $indice--; $correct[$indice] = 1; break; case '3': while (!empty($_POST["tf" . $i])) { $opcoes[$i - 1] = $_POST["tf" . $i]; if (isset($_POST["answer_tf" . $i])) { $correct[$i - 1] = 1; } else { $correct[$i - 1] = 0; } $i++; } break; } echo "<br/>Perguntas:<br/>"; var_dump($opcoes); echo "<br/>Respostas:<br/>"; var_dump($correct); $new_questao = new Questao(); $new_questao->add($question, $type, $difficulty, $subject, $tags, $opcoes, $resp, $correct, $file, $regNumber); header('Location: http://localhost/Adriel/public_html/questoes/showInserir'); }
public function runAdmin() { $this->objAdmin = new Admin($this->objLanguage); if ($this->objUrl->main == 'logout') { Login::logout(); } else { if ($this->objUrl->c == 'login' && Login::isLogged()) { Helper::redirect('/panel/content/c/pages/a/index'); } else { if ($this->objUrl->c != 'login' && !Login::isLogged()) { Helper::redirect('/panel'); } else { if (Login::isLogged()) { $this->admin = $this->objAdmin->getOne($_SESSION[Login::$key_user_id]); } } } } $file = ROOT_PATH . DS . 'admin' . DS . 'core' . DS . $this->objUrl->c . DS . $this->objUrl->a . '.php'; if (!is_file($file)) { $file = ROOT_PATH . DS . 'admin' . DS . 'core' . DS . 'error' . DS . 'index.php'; } ob_start(); require_once $file; echo ob_get_clean(); }