Exemplo n.º 1
0
 /**
  * @return array
  */
 public function getNotifications()
 {
     $result = [];
     $query = $this->getAdapter()->select()->from(["n" => $this->_name])->joinLeft(["u" => $this->_dbprefix . "users"], "n.ref_userid=u.userid", ["name", "username"])->joinLeft(["pi" => $this->_dbprefix . "gallery_images"], "pi.id = u.profileImage", ['filename AS pimg', 'albumid AS palbumid'])->where("n.userid=?", $_SESSION['user']->userid)->order("n.unread DESC")->limit(5);
     $res = $this->getAdapter()->fetchAll($query);
     $resCount = count($res);
     for ($i = 0; $i < $resCount; $i++) {
         $d = Notifier::getNotificationData($res[$i]["type"]);
         $res[$i]["message"] = \sprintf($d, $res[$i]["name"]);
         $res[$i]["target"] = Url::convertUrl($res[$i]["target"]);
         if ($res[$i]["unread"] == 1) {
             $result["new"]++;
         }
     }
     $result["all"] = $res;
     return $result;
 }
Exemplo n.º 2
0
 /**
  *
  */
 public function login()
 {
     if (isset($_POST['email'])) {
         if ($_SESSION['user']->email == $_POST['email'] && $_SESSION['user']->password == sha1($_POST['password'] . $_SESSION['user']->salt)) {
             $_SESSION['admin_loggedIn'] = true;
             header("Location:" . Url::convertUrl("index.php?m=admin"));
             exit;
         } else {
             $view = new \Cunity\Admin\View\Login();
             $view->assign("message", "The entered data is not correct!");
             $view->show();
         }
     } else {
         $view = new \Cunity\Admin\View\Login();
         $view->assign("message", "");
         $view->show();
     }
 }
Exemplo n.º 3
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();
     }
 }
Exemplo n.º 4
0
 /**
  * @throws \Exception
  */
 private function crop()
 {
     $file = new Crop(["x" => $_POST['crop-x'], "y" => $_POST['crop-y'], "x1" => $_POST['crop-x1'], "y1" => $_POST['crop-y1'], "thumbwidth" => 970, "directory" => "../data/uploads/" . Cunity::get("settings")->getSetting("core.filesdir"), "prefix" => "cr_"]);
     $file->filter($_POST['crop-image']);
     $events = new Events();
     if ($events->updateEvent($_POST['eventid'], ["imageId" => $_POST['imageid']])) {
         header("Location: " . Url::convertUrl("index.php?m=events&action=" . $_POST['eventid']));
     }
 }
Exemplo n.º 5
0
 /**
  * @param bool $autologin
  * @return bool|null|\Zend_Db_Table_Row_Abstract
  */
 public static function checkAutoLogin($autologin = true)
 {
     if (!isset($_COOKIE['cunity-login']) || !isset($_COOKIE['cunity-login-token'])) {
         return false;
     }
     $users = new Users();
     $user = $users->search("username", base64_decode($_COOKIE['cunity-login']));
     if (md5($user->salt . "-" . $user->registered . "-" . $user->userhash) == $_COOKIE['cunity-login-token']) {
         if ($autologin) {
             $user->setLogin(true);
             header("Location:" . Url::convertUrl("index.php?m=profile"));
             exit;
         } else {
             return $user;
         }
     }
     return false;
 }
Exemplo n.º 6
0
 /**
  * @param $urlString
  * @return string
  */
 public static function convertUrl($urlString)
 {
     return Url::convertUrl($urlString);
 }
Exemplo n.º 7
0
 /**
  * @param $str
  * @return mixed
  */
 private function quote($str)
 {
     $format_search = [];
     $format_replace = [];
     if (preg_match_all('#\\[quote=(.*?)\\](.*?)#is', $str, $matches1, PREG_SET_ORDER) == preg_match_all('#\\[/quote\\]#is', $str, $matches2)) {
         if (empty($matches1)) {
             return $str;
         }
         array_push($format_search, '#\\[quote=(.*?)\\](.*?)#is');
         array_push($format_search, '#\\[/quote\\]#is');
         $user = $_SESSION['user']->getTable()->get($matches1[0][1], "username");
         array_push($format_replace, '<div class="quotation well well-sm"><a class="quotation-user" href="' . Url::convertUrl("index.php?m=profile&action=" . $user->username) . '">' . $user->name . ':</a>$2');
         array_push($format_replace, '</div>');
     }
     return preg_replace($format_search, $format_replace, $str);
 }
Exemplo n.º 8
0
 /** @noinspection PhpUnusedPrivateMethodInspection */
 private function crop()
 {
     $file = new Crop(["x" => $_POST['crop-x'], "y" => $_POST['crop-y'], "x1" => $_POST['crop-x1'], "y1" => $_POST['crop-y1'], "thumbwidth" => $_POST['type'] == "title" ? 970 : 150, "directory" => "../data/uploads/" . Cunity::get("settings")->getSetting("core.filesdir"), "prefix" => "cr_"]);
     $file->filter($_POST['crop-image']);
     if ($_POST['type'] == "title") {
         $_SESSION['user']->titleImage = $_POST['imageid'];
     } else {
         $_SESSION['user']->profileImage = $_POST['imageid'];
     }
     /** @noinspection PhpUndefinedMethodInspection */
     if ($_SESSION['user']->save()) {
         header("Location: " . Url::convertUrl("index.php?m=profile"));
     }
 }
Exemplo n.º 9
0
 /**
  *
  */
 private function reset()
 {
     if (Login::loggedIn()) {
         header("Location:" . Url::convertUrl("index.php?m=profile"));
         exit;
     }
     $register = new Register();
     $register->reset();
 }
Exemplo n.º 10
0
 /**
  * @throws \Zend_Db_Table_Exception
  */
 private function upload()
 {
     $albums = new GalleryAlbums();
     $images = new GalleryImages();
     if (isset($_POST['newsfeed_post'])) {
         /** @var \Cunity\Gallery\Models\Db\Row\Album $album */
         $album = $albums->fetchRow($albums->select()->where("type=?", "newsfeed")->where("owner_id=?", $_SESSION['user']->userid)->where("owner_type IS NULL"));
         if ($album === null) {
             $albumid = $albums->newNewsfeedAlbums($_SESSION['user']->userid);
             $album = $albums->fetchRow($albums->select()->where("id=?", $albumid));
         }
     } else {
         $album = $albums->find($_POST['albumid'])->current();
     }
     $result = $images->uploadImage($album->id, isset($_POST['newsfeed_post']));
     $album->addImage(isset($_POST['newsfeed_post']) ? $result['content'] : $result['imageid']);
     if (isset($_POST['uploadtype']) && $_POST['uploadtype'] == 'single') {
         header("Location: " . Url::convertUrl("index.php?m=gallery&action=" . $_POST['albumid']));
         exit;
     } else {
         $view = new View($result !== false);
         $view->addData($result);
         $view->sendResponse();
     }
 }