Esempio n. 1
0
 /**
  * @throws \Cunity\Core\Exception
  * @throws \Exception
  */
 public function __construct()
 {
     parent::__construct();
     if (Login::loggedIn()) {
         $user = $_SESSION['user'];
         $userData = ["firstname" => $user->firstname, "lastname" => $user->lastname, "email" => $user->email];
     } else {
         $userData = ["firstname" => "", "lastname" => "", "email" => ""];
     }
     $this->registerScript("contact", "contactform");
     $this->assign("userData", $userData);
     $this->show();
 }
Esempio n. 2
0
 /**
  *
  */
 private function handleInput()
 {
     if (isset($_POST['message'])) {
         $contactDb = new Contact();
         $res = $contactDb->insert(["userid" => Login::loggedIn() ? $_SESSION['user']->userid : 0, "firstname" => $_POST['firstname'], "lastname" => $_POST['lastname'], "email" => $_POST['email'], "subject" => $_POST['subject'], "message" => $_POST['message']]);
         if ($res) {
             $cc = isset($_POST['send_copy']) && $_POST['send_copy'] == 1 ? ["email" => $_POST['email'], "name" => $_POST['firstname'] . " " . $_POST['lastname']] : [];
             new ContactMail([], ["subject" => $_POST['subject'], "message" => $_POST['message']], $cc);
             new Message("Finished!", "Your Message was sent successfully!", "success");
         } else {
             new Message("Sorry!", "There was an error in our system, please try again later", "danger");
         }
     }
 }
Esempio n. 3
0
 /**
  * @param string $value
  * @return bool
  */
 public function isValid($value)
 {
     $returnValue = false;
     $this->_setValue($value);
     $users = new Users();
     if (empty($value)) {
         $this->_error(self::EMPTYSTRING);
     } else {
         $user = $users->search("email", $value);
         if ($user !== null && !Login::loggedIn() || Login::loggedIn() && $user->userid !== $_SESSION['user']->userid) {
             $this->_error(self::USED);
             $returnValue = false;
         } else {
             $returnValue = parent::isValid($value);
         }
     }
     return $returnValue;
 }
Esempio n. 4
0
 /**
  *
  */
 protected function handleQuery()
 {
     if (!isset($_GET['m']) || empty($_GET['m'])) {
         if (Login::loggedIn()) {
             header("Location:" . Models\Generator\Url::convertUrl("index.php?m=profile"));
             exit;
         } else {
             $_GET['m'] = 'start';
         }
     }
     $moduleController = new Module($_GET['m']);
     if (!Request::isAjaxRequest() && !$moduleController->isActive()) {
         new PageNotFound();
     } elseif ($moduleController->isValid()) {
         $classname = $moduleController->getClassName();
         new $classname();
     } else {
         new PageNotFound();
     }
 }
Esempio n. 5
0
 /**
  * @param string $value
  * @return bool
  */
 public function isValid($value)
 {
     $this->_setValue($value);
     if (empty($value) || strlen($value) < 2 || strlen($value) > 20) {
         $this->_error(self::LENGTH);
         return false;
     }
     $users = new Users();
     $user = $users->search("username", $value);
     if ($user !== null && (Login::loggedIn() && $user->userid !== $_SESSION['user']->userid)) {
         $this->_error(self::USED);
         return false;
     }
     $status = preg_match('/^[A-Za-z0-9_.-]*$/', $value);
     if (false === $status || !$status) {
         $this->_error(self::INVALID);
         return false;
     }
     return true;
 }
Esempio n. 6
0
 /**
  * @throws \Cunity\Core\Exception
  * @throws \Exception
  */
 public function show()
 {
     if (Login::loggedIn() && $_GET['m'] !== "admin") {
         $this->registerScript("search", "livesearch");
         $this->registerScript("messages", "message-modal");
         $this->registerScript("notifications", "notifications");
         $this->registerScript("messages", "chat");
         $this->registerCss("messages", "chat");
         $this->registerCss("search", "livesearch");
         $this->registerCss("messages", "message-modal");
         $this->registerCss("notifications", "notifications");
         $this->registerScript("friends", "friends");
     }
     $announcements = new Announcements();
     $this->assign("announcements", $announcements->getAnnouncements());
     if (Login::loggedIn()) {
         /** @noinspection PhpUndefinedMethodInspection */
         $this->assign('user', $_SESSION['user']->getTable()->get($_SESSION['user']->userid));
     } else {
         $this->assign('user', []);
     }
     $this->assign('isAdmin', UserHelper::isAdmin());
     $this->assign('hasUpdate', UpdateHelper::hasUpdates());
     $this->assign('menu', new Menu());
     $this->registerCunityPlugin("jscrollpane", ["css/jquery.jscrollpane.css", "js/jquery.jscrollpane.min.js"]);
     $this->registerCunityPlugin("bootstrap-validator", ["css/bootstrapValidator.min.css", "js/bootstrapValidator.min.js"]);
     $this->_metadata["module"] = $_GET['m'];
     $this->assign("meta", $this->_metadata);
     $this->assign('script_head', implode("\n", $this->_headScripts));
     $this->assign('css_head', base64_encode(implode(",", $this->_headCss)));
     $modRewrite = false;
     if (function_exists("apache_get_modules")) {
         $modRewrite = (bool) in_array('mod_rewrite', apache_get_modules());
     }
     $this->assign('modrewrite', $modRewrite);
     if ($this->_useWrapper) {
         $this->assign('tpl_name', $this->_templateDir . '/styles/' . $this->_templateFile);
         $this->display($this->_wrapper);
     } else {
         $this->display($this->_templateDir . DIRECTORY_SEPARATOR . 'styles' . DIRECTORY_SEPARATOR . $this->_templateFile);
     }
 }
Esempio n. 7
0
 /**
  *
  */
 private function reset()
 {
     if (Login::loggedIn()) {
         header("Location:" . Url::convertUrl("index.php?m=profile"));
         exit;
     }
     $register = new Register();
     $register->reset();
 }