Ejemplo n.º 1
0
 public function __construct()
 {
     parent::__construct();
     $this->permissionModel = \Model\CompanyPermission::getInstance();
     $this->employerModel = \Model\EmployerLogin::getInstance();
     $this->contentType = 'application/json';
 }
Ejemplo n.º 2
0
 public function logout()
 {
     if (Service::getService()->isAuthenticated()) {
         Service::getService()->clearAuthenticated();
         header('Location: /guestbook');
     }
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
 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));
 }
Ejemplo n.º 6
0
 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);
     }
 }
Ejemplo n.º 7
0
 public function __construct()
 {
     parent::__construct();
     $this->contentType = 'application/json';
 }
Ejemplo n.º 8
0
 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;
     }
 }
Ejemplo n.º 9
0
 public function __construct()
 {
     $this->db = Service::get('pdo');
 }
Ejemplo n.º 10
0
 public function regAction()
 {
     $user = Service::get('user');
     $user->save($_POST);
     return new RedirectResponse('/', 303);
 }
Ejemplo n.º 11
0
 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;
 }
Ejemplo n.º 12
0
 public function __construct()
 {
     parent::__construct();
     $this->model = \Model\Job::getInstance();
     $this->contentType = 'application/json';
 }
Ejemplo n.º 13
0
 public function __construct()
 {
     parent::__construct();
     $this->candidateModel = new \Model\Candidate();
     $this->addrModel = new \Model\CandidateAddress();
 }