public function __construct() { parent::__construct(); $this->permissionModel = \Model\CompanyPermission::getInstance(); $this->employerModel = \Model\EmployerLogin::getInstance(); $this->contentType = 'application/json'; }
public function logout() { if (Service::getService()->isAuthenticated()) { Service::getService()->clearAuthenticated(); header('Location: /guestbook'); } }
public function __construct() { $pdo = Service::getService()->getPDO(); if (is_null($pdo)) { throw new ConfigExeption(); } self::$db = new \PDO($pdo['dns'], $pdo['user'], $pdo['password']); self::$db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); }
public function getUser() { if ($this->load()) { $sth = $this->doStatement($this->get_user, array('username' => $this->username)); $sth->setFetchMode(\PDO::FETCH_CLASS, __CLASS__); $row = $sth->fetch(); if ($row->password === $this->password) { Service::getService()->setAuthenticate(); return true; } } return false; }
private function mainAction($active_page = 1, $message = null, GuestbookModel $model_data = null) { $model = new GuestbookModel(); $rec_num = $model->getNumberRecords(); $per_page = Service::getService()->recordsPerPage(); $pages = ceil($rec_num / $per_page); if ($active_page <= $pages || $pages == 0) { $model = (array) $model->getLimitRecords($active_page * $per_page - $per_page, $per_page); } else { throw new HttpNotFoundException("Page not found"); } return $this->render('index', $model, array('pages' => $pages, 'active_page' => $active_page, 'message' => $message, 'model_data' => $model_data)); }
public function run() { try { Service::getService()->init($this->config); $route = (array) Service::getService()->getRequestURI(); $route = array_key_exists(1, $route) ? $route[1] : ""; $controller = Controller::getController($route); $controller->defaultAction(); } catch (HttpNotFoundException $exc) { $error = "This page does not exist."; $this->errorRender($error); } catch (SecurityExeption $exc) { $error = "Permission denied."; $this->errorRender($error); } catch (ConfigExeption $exc) { $error = "Problems with config file."; $this->errorRender($error); } catch (\Exception $exc) { $error = "Something goes wrong. Go back and try again."; $this->errorRender($error); } }
public function __construct() { parent::__construct(); $this->contentType = 'application/json'; }
public function insCourse($id, $arr) { try { $sql = "INSERT INTO `user_course`\n (`user_id`,`course_id`)\n VALUES\n ( :id, :course)"; $stmt = $this->db->prepare($sql); foreach ($arr as $val) { $stmt->execute(array(':id' => $id, ':course' => $val)); } } catch (\PDOException $e) { Service::get('log')->error($e->getMessage() . " & Code " . $e->getCode()); require URL . "/src/error.php"; exit; } }
public function __construct() { $this->db = Service::get('pdo'); }
public function regAction() { $user = Service::get('user'); $user->save($_POST); return new RedirectResponse('/', 303); }
public function validate($attributeNames = null) { foreach ($this->getRequired() as $key => $required) { if ($required == "") { $this->valid_errs[$key] = "Must be filled!"; return false; } } if (!filter_var($this->email, FILTER_VALIDATE_EMAIL)) { $this->valid_errs['email'] = "Invalid email format"; } if (!preg_match("/^[a-zA-Z ]*\$/", $this->name)) { $this->valid_errs['name'] = "Only letters and white space allowed"; } if ($this->website != "") { $parts = parse_url($this->website); if (!isset($parts["scheme"])) { $this->website = "http://{$this->website}"; } if (!filter_var($this->website, FILTER_VALIDATE_URL)) { $this->valid_errs['website'] = "Invalid URL"; } } if (Service::getService()->getCaptchaText() !== strtoupper($this->captcha)) { $this->valid_errs['captcha'] = "The text doesn't match. Try again"; } return count($this->valid_errs) > 0 ? false : true; }
public function __construct() { parent::__construct(); $this->model = \Model\Job::getInstance(); $this->contentType = 'application/json'; }
public function __construct() { parent::__construct(); $this->candidateModel = new \Model\Candidate(); $this->addrModel = new \Model\CandidateAddress(); }