function userLogged() { $app = \Slim\Slim::getInstance(); session_regenerate_id(); if (isset($_SESSION['perfil'])) { $session = Utilities::getSession(); $action = ''; if ($session['level'] <= 10) { $app->redirect('/' . $session['username']); } else { $app->redirect('/admin/' . $session['username']); } } }
public function usersList($username) { $session = Utilities::getSession(); $username = strip_tags(htmlspecialchars($username)); $username = filter_var($username, FILTER_SANITIZE_STRING); if ($session['username'] == $username) { $users = User::with('perfil', 'level')->where('level_id', '=', 4)->get(); $links = Utilities::getMenu($session); foreach ($users as $key => $value) { $action = '/' . $value->perfil->username; $value->perfil->action = $action; } $this->view = new UsersListView($users, $links); $this->view->display(); } else { $this->app->redirect($app->urlFor('admin-login')); } }
public function index() { date_default_timezone_set('America/Mexico_City'); $total_alumnos = 12; $fecha_actual = date('Y-m-d'); $fecha_actual = date_create($fecha_actual); $cursos = Curso::where('status', '=', 1)->where('total_alumnos', '<', $total_alumnos)->get(); $lista_cursos = array(); $session = Utilities::getSession(); $links = Utilities::getMenu($session); foreach ($cursos as $key => $value) { $fechaInicio = date_create($value->fechaInicio); $interval = date_diff($fecha_actual, $fechaInicio); if ($interval->invert == 0 && $interval->d >= 0) { $value->action = '/suscribirme/' . $value->curso_id; $lista_cursos[] = $value; } } //Utilities::printData( $lista_cursos ); $this->view = new Index($this->app->urlFor('join'), $lista_cursos, $links); $this->view->display(); }
public function cambiarFotoView($params) { $usuario_id = strip_tags(htmlspecialchars($params['usuario'])); $usuario_id = intval($usuario_id); $usuario_id = filter_var($usuario_id, FILTER_VALIDATE_INT); $error = 0; if (!$usuario_id || $usuario_id == 0) { $error = 1; } $usuario = Perfil::find($usuario_id); if (count($usuario) == 0) { $error = 2; } $action = '/usuario/' . $usuario_id . '/foto/'; $session = Utilities::getSession(); $links = Utilities::getMenu($session); $this->view = new FotoView($action, Utilities::createToken(), $usuario, $links, $error); $this->view->display(); }
public function loginPost($post) { $email = strip_tags(htmlspecialchars($post['email_input_data'])); $password = strip_tags(htmlspecialchars($post['password_input_data'])); $email = filter_var($email, FILTER_SANITIZE_EMAIL); $email = filter_var($email, FILTER_VALIDATE_EMAIL); if (!$email) { $this->app->redirect($this->app->urlFor('maestro-login') . '?attempt=1'); } if (Authentication::Authenticate($email, $password, 100)) { $session = Utilities::getSession(); $action = '/admin/maestro/' . $session['username']; $this->app->redirect($action); } else { $this->app->redirect($this->app->urlFor('maestro-login') . '?attempt=2'); } }
public function editView($params) { $curso_id = strip_tags(htmlspecialchars($params['curso'])); $curso_id = intval($curso_id); $curso_id = filter_var($curso_id, FILTER_VALIDATE_INT); $attempt = 0; $session = Utilities::getSession(); $links = Utilities::getMenu($session); if (isset($params['attempt']) && is_int($params['attempt'])) { $attempt = strip_tags(htmlspecialchars($params['attempt'])); $attempt = intval($attempt); $attempt = filter_var($attempt, FILTER_VALIDATE_INT); } if (!$curso_id) { $this->app->redirect($this->app->urlFor('Index')); } $curso = Curso::find($curso_id); if (count($curso) == 0) { $this->app->redirect($this->app->urlFor('Index')); } $action = '/curso/' . $curso->curso_id . '/edit'; $tipo_curso = TipoCurso::all(); $maestros = Maestro::with('perfil')->get(); $this->view = new CursoEditView($links, $curso, $tipo_curso, $maestros, $action, $attempt); $this->view->display(); //Utilities::printData($maestros); }