예제 #1
0
 public function showAction()
 {
     $jobsMapper = new JobsMapper();
     $userMapper = new UserMapper();
     $id = $this->getRequest()->getParam('id');
     $job = $jobsMapper->getJobsById($id);
     $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuJobs'), array('action' => 'index'))->add($job->getTitle(), array('action' => 'show', 'id' => $id));
     if ($this->getRequest()->getPost('saveApply')) {
         $title = trim($this->getRequest()->getPost('title'));
         $text = trim($this->getRequest()->getPost('text'));
         echo $title;
         if (empty($text)) {
             $this->addMessage('missingText', 'danger');
         } else {
             $date = new \Ilch\Date();
             $job = $jobsMapper->getJobsById($id);
             $user = $userMapper->getUserById($this->getUser()->getId());
             if ($_SESSION['layout'] == $this->getConfig()->get('default_layout') && file_exists(APPLICATION_PATH . '/layouts/' . $this->getConfig()->get('default_layout') . '/views/modules/jobs/layouts/mail/apply.php')) {
                 $messageTemplate = file_get_contents(APPLICATION_PATH . '/layouts/' . $this->getConfig()->get('default_layout') . '/views/modules/jobs/layouts/mail/apply.php');
             } else {
                 $messageTemplate = file_get_contents(APPLICATION_PATH . '/modules/jobs/layouts/mail/apply.php');
             }
             $messageReplace = array('{applyAs}' => $this->getTranslator()->trans('applyAs') . ' ' . $title, '{content}' => $text, '{sitetitle}' => $this->getConfig()->get('page_title'), '{date}' => $date->format("l, d. F Y", true));
             $message = str_replace(array_keys($messageReplace), array_values($messageReplace), $messageTemplate);
             $mail = new \Ilch\Mail();
             $mail->setTo($job->getEmail(), '')->setSubject($this->getTranslator()->trans('applyAs') . ' ' . $title)->setFrom($user->getEmail(), $user->getName())->setMessage($message)->addGeneralHeader('Content-type', 'text/html; charset="utf-8"');
             $mail->send();
             $this->addMessage('sendSuccess');
             $this->redirect(array('action' => 'index'));
         }
     }
     $this->getView()->set('job', $job);
     $this->getView()->set('jobs', $jobsMapper->getJobs(array('show' => 1)));
 }
예제 #2
0
 public function indexAction()
 {
     $catId = (int) $this->getRequest()->getParam('id');
     $forumMapper = new ForumMapper();
     $forumItems = $forumMapper->getForumItemsByParent(1, $catId);
     $cat = $forumMapper->getForumById($catId);
     $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('forum'), array('controller' => 'index', 'action' => 'index'))->add($cat->getTitle(), array('controller' => 'showcat', 'action' => 'index', 'id' => $cat->getId()));
     $this->getLayout()->set('metaTitle', $this->getTranslator()->trans('forumOverview'));
     $this->getLayout()->set('metaDescription', $this->getTranslator()->trans('forumOverview'));
     $this->getView()->set('forumItems', $forumItems);
     $this->getView()->set('forumMapper', $forumMapper);
     $this->getView()->set('cat', $cat);
     $userMapper = new UserMapper();
     $userId = null;
     if ($this->getUser()) {
         $userId = $this->getUser()->getId();
     }
     $user = $userMapper->getUserById($userId);
     $ids = array(0);
     if ($user) {
         $ids = array();
         foreach ($user->getGroups() as $us) {
             $ids[] = $us->getId();
         }
     }
     $readAccess = explode(',', implode(',', $ids));
     $this->getView()->set('readAccess', $readAccess);
 }
 /**
  * Redirects the user to the admin login page, if the user is not logged in, yet.
  *
  * If the user is logged in already redirect the user to the Admincenter.
  *
  * @param array $pluginData
  */
 public function __construct(array $pluginData)
 {
     $request = $pluginData['request'];
     if (isset($pluginData['config'])) {
         $config = $pluginData['config'];
         $userId = null;
         if (isset($_SESSION['user_id'])) {
             $userId = (int) $_SESSION['user_id'];
         }
         $userMapper = new UserMapper();
         $translator = new \Ilch\Translator();
         $user = $userMapper->getUserById($userId);
         if ($config->get('maintenance_mode') && !$request->isAdmin()) {
             if (empty($user)) {
                 $pluginData['layout']->setFile('modules/admin/layouts/maintenance');
             } else {
                 if (!$user->isAdmin()) {
                     $pluginData['layout']->setFile('modules/admin/layouts/maintenance');
                 }
             }
             $_SESSION['messages'][] = array('text' => $translator->trans('siteMaintenanceMode'), 'type' => 'danger');
         }
     }
     if ($request->isAdmin() && $request->getControllerName() !== 'login' && !\Ilch\Registry::get('user')) {
         /*
          * User is not logged in yet but wants to go to the admincenter, redirect him to the login.
          */
         $pluginData['controller']->redirect(array('module' => 'admin', 'controller' => 'login', 'action' => 'index'));
     } elseif ($request->getModuleName() === 'admin' && $request->getControllerName() === 'login' && $request->getActionName() !== 'logout' && \Ilch\Registry::get('user')) {
         /*
          * User is logged in but wants to go to the login, redirect him to the admincenter.
          */
         $pluginData['controller']->redirect(array('module' => 'admin', 'controller' => 'index', 'action' => 'index'));
     }
 }
예제 #4
0
 public function indexAction()
 {
     $profilMapper = new UserMapper();
     $profil = $profilMapper->getUserById($this->getRequest()->getParam('user'));
     $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuUserList'), array('controller' => 'index'))->add($profil->getName(), array('action' => 'index', 'user' => $this->getRequest()->getParam('user')));
     $this->getView()->set('profil', $profil);
 }
예제 #5
0
 public function indexAction()
 {
     if ($this->getUser()) {
         $forumMapper = new ForumMapper();
         $topicMapper = new TopicMapper();
         $pagination = new \Ilch\Pagination();
         $userMapper = new UserMapper();
         $userId = null;
         $groupIds = array(0);
         $userId = $this->getUser()->getId();
         $user = $userMapper->getUserById($userId);
         $groupIds = array();
         foreach ($user->getGroups() as $groups) {
             $groupIds[] = $groups->getId();
         }
         $groupIdsArray = explode(',', implode(',', $groupIds));
         $pagination->setPage($this->getRequest()->getParam('page'));
         $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('forum'), array('controller' => 'index', 'action' => 'index'))->add($this->getTranslator()->trans('showNewPosts'), array('action' => 'index'));
         $this->getLayout()->set('metaTitle', $this->getTranslator()->trans('showNewPosts'));
         $this->getLayout()->set('metaDescription', $this->getTranslator()->trans('showNewPosts'));
         $this->getView()->set('topicMapper', $topicMapper);
         $this->getView()->set('forumMapper', $forumMapper);
         $this->getView()->set('topics', $topicMapper->getTopics($pagination));
         $this->getView()->set('groupIdsArray', $groupIdsArray);
         $this->getView()->set('pagination', $pagination);
     } else {
         $this->addMessage('noAccessForum', 'warning');
         $this->redirect(array('module' => 'forum', 'controller' => 'index'));
     }
 }
예제 #6
0
 public function indexAction()
 {
     $userMapper = new UserMapper();
     $forumMapper = new ForumMapper();
     $visitMapper = new StatisticMapper();
     $staticsMapper = new ForumStaticsMapper();
     $forumItems = $forumMapper->getForumItemsByParent(1, 0);
     $allOnlineUsers = $visitMapper->getVisitsCountOnline();
     $usersOnline = $visitMapper->getVisitsOnlineUser();
     $userId = null;
     $groupIds = array(0);
     if ($this->getUser()) {
         $userId = $this->getUser()->getId();
         $user = $userMapper->getUserById($userId);
         $groupIds = array();
         foreach ($user->getGroups() as $groups) {
             $groupIds[] = $groups->getId();
         }
     }
     $groupIdsArray = explode(',', implode(',', $groupIds));
     $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('forum'), array('action' => 'index'));
     $this->getLayout()->set('metaTitle', $this->getTranslator()->trans('forumOverview'));
     $this->getLayout()->set('metaDescription', $this->getTranslator()->trans('forumOverview'));
     $this->getView()->set('groupIdsArray', $groupIdsArray);
     $this->getView()->set('forumItems', $forumItems);
     $this->getView()->set('forumMapper', $forumMapper);
     $this->getView()->set('usersOnline', count($usersOnline));
     $this->getView()->set('guestOnline', $allOnlineUsers - count($usersOnline));
     $this->getView()->set('forumStatics', $staticsMapper->getForumStatistics());
 }
예제 #7
0
 public function indexAction()
 {
     $forumMapper = new ForumMapper();
     $topicMapper = new TopicMapper();
     $pagination = new \Ilch\Pagination();
     $userMapper = new UserMapper();
     $forumId = $this->getRequest()->getParam('forumid');
     $forum = $forumMapper->getForumById($forumId);
     $cat = $forumMapper->getCatByParentId($forum->getParentId());
     $userId = null;
     $groupIds = array(0);
     if ($this->getRequest()->isPost() && $this->getRequest()->getPost('forumEdit') === 'forumEdit') {
         $forumEdit = true;
         $this->getView()->set('forumEdit', $forumEdit);
     }
     if ($this->getUser()) {
         $userId = $this->getUser()->getId();
         $user = $userMapper->getUserById($userId);
         $groupIds = array();
         foreach ($user->getGroups() as $groups) {
             $groupIds[] = $groups->getId();
         }
     }
     $groupIdsArray = explode(',', implode(',', $groupIds));
     $this->getLayout()->set('metaTitle', $this->getTranslator()->trans('forum') . ' - ' . $forum->getTitle());
     $this->getLayout()->set('metaDescription', $this->getTranslator()->trans('forum') . ' - ' . $forum->getDesc());
     $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('forum'), array('controller' => 'index', 'action' => 'index'))->add($cat->getTitle(), array('controller' => 'showcat', 'action' => 'index', 'id' => $cat->getId()))->add($forum->getTitle(), array('action' => 'index', 'forumid' => $forumId));
     $pagination->setPage($this->getRequest()->getParam('page'));
     $this->getView()->set('forum', $forum);
     $this->getView()->set('topicMapper', $topicMapper);
     $this->getView()->set('forumMapper', $forumMapper);
     $this->getView()->set('topics', $topicMapper->getTopicsByForumId($forumId, $pagination));
     $this->getView()->set('groupIdsArray', $groupIdsArray);
     $this->getView()->set('pagination', $pagination);
 }
예제 #8
0
파일: Base.php 프로젝트: sCar-w4y/Ilch-2.0
 /**
  * Initializes the menu.
  */
 public function init()
 {
     $UserMenuMapper = new UserMenuMapper();
     $profilMapper = new UserMapper();
     $menu = $UserMenuMapper->getUserMenu();
     $menuLinks = $UserMenuMapper->getUserMenuSettingsLinks($this->getTranslator()->getLocale());
     $this->getView()->set('usermenu', $menu);
     $this->getView()->set('usermenusettingslinks', $menuLinks);
     $this->getView()->set('profil', $profilMapper->getUserById($this->getUser()->getId()));
     $this->getView()->set('galleryAllowed', $this->getConfig()->get('usergallery_allowed'));
 }
예제 #9
0
 public function indexAction()
 {
     $forumMapper = new ForumMapper();
     $id = (int) $this->getRequest()->getParam('id');
     $forum = $forumMapper->getForumById($id);
     $cat = $forumMapper->getCatByParentId($forum->getParentId());
     $this->getLayout()->set('metaTitle', $this->getTranslator()->trans('forum') . ' - ' . $forum->getTitle());
     $this->getLayout()->set('metaDescription', $this->getTranslator()->trans('forum') . ' - ' . $forum->getDesc());
     $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('forum'), array('controller' => 'index', 'action' => 'index'))->add($cat->getTitle(), array('controller' => 'showcat', 'action' => 'index', 'id' => $cat->getId()))->add($forum->getTitle(), array('controller' => 'showtopics', 'action' => 'index', 'forumid' => $id))->add($this->getTranslator()->trans('newTopicTitle'), array('controller' => 'newtopic', 'action' => 'index', 'id' => $id));
     if ($this->getRequest()->getPost('saveNewTopic')) {
         $topicModel = new ForumTopicModel();
         $topicMapper = new TopicMapper();
         $dateTime = new \Ilch\Date();
         $topicModel->setTopicTitle($this->getRequest()->getPost('topicTitle'));
         $topicModel->setText($this->getRequest()->getPost('text'));
         $topicModel->setTopicId($id);
         $topicModel->setForumId($id);
         $topicModel->setCat($id);
         $topicModel->setCreatorId($this->getUser()->getId());
         $topicModel->setType($this->getRequest()->getPost('type'));
         $topicModel->setDateCreated($dateTime);
         $topicMapper->save($topicModel);
         $postMapper = new PostMapper();
         $postModel = new ForumPostModel();
         $lastid = $topicMapper->getLastInsertId();
         $postModel->setTopicId($lastid);
         $postModel->setUserId($this->getUser()->getId());
         $postModel->setText($this->getRequest()->getPost('text'));
         $postModel->setDateCreated($dateTime);
         $postMapper->save($postModel);
         $this->redirect(array('controller' => 'showposts', 'action' => 'index', 'topicid' => $lastid));
     }
     $userMapper = new UserMapper();
     $userId = null;
     if ($this->getUser()) {
         $userId = $this->getUser()->getId();
     }
     $user = $userMapper->getUserById($userId);
     $ids = array(0);
     if ($user) {
         $ids = array();
         foreach ($user->getGroups() as $us) {
             $ids[] = $us->getId();
         }
     }
     $readAccess = explode(',', implode(',', $ids));
     $this->getView()->set('readAccess', $readAccess);
     $this->getView()->set('forum', $forum);
 }
예제 #10
0
 public function indexAction()
 {
     $postMapper = new PostMapper();
     $topicMapper = new TopicMapper();
     $forumMapper = new ForumMapper();
     $topicModel = new ForumTopicModel();
     $pagination = new \Ilch\Pagination();
     $pagination->setPage($this->getRequest()->getParam('page'));
     $topicId = (int) $this->getRequest()->getParam('topicid');
     $forumId = $forumMapper->getForumByTopicId($topicId);
     $forum = $forumMapper->getForumById($forumId->getId());
     $cat = $forumMapper->getCatByParentId($forum->getParentId());
     $posts = $postMapper->getPostByTopicId($topicId, $pagination);
     $post = $topicMapper->getPostById($topicId);
     $this->getLayout()->set('metaTitle', $this->getTranslator()->trans('forum') . ' - ' . $forum->getTitle());
     $this->getLayout()->set('metaDescription', $this->getTranslator()->trans('forum') . ' - ' . $forum->getDesc());
     $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('forum'), array('controller' => 'index', 'action' => 'index'))->add($cat->getTitle(), array('controller' => 'showcat', 'action' => 'index', 'id' => $cat->getId()))->add($forum->getTitle(), array('controller' => 'showtopics', 'action' => 'index', 'forumid' => $forumId->getId()))->add($post->getTopicTitle(), array('controller' => 'showposts', 'action' => 'index', 'topicid' => $topicId));
     $topicModel->setId($topicId);
     $topicModel->setVisits($post->getVisits() + 1);
     $topicMapper->saveVisits($topicModel);
     $userMapper = new UserMapper();
     $userId = null;
     if ($this->getUser()) {
         $userId = $this->getUser()->getId();
         $postMapper = new PostMapper();
         $postModel = new ForumPostModel();
         $lastPost = $topicMapper->getLastPostByTopicId($topicId);
         $lastRead = $lastPost->getRead();
         if (in_array($this->getUser()->getId(), explode(',', $lastRead)) == false) {
             $postModel->setId($lastPost->getId());
             $postModel->setRead($lastPost->getRead() . ',' . $this->getUser()->getId());
             $postMapper->saveRead($postModel);
         }
     }
     $user = $userMapper->getUserById($userId);
     $ids = array(0);
     if ($user) {
         $ids = array();
         foreach ($user->getGroups() as $us) {
             $ids[] = $us->getId();
         }
     }
     $readAccess = explode(',', implode(',', $ids));
     $this->getView()->set('post', $post);
     $this->getView()->set('posts', $posts);
     $this->getView()->set('forum', $forum);
     $this->getView()->set('readAccess', $readAccess);
     $this->getView()->set('pagination', $pagination);
 }
예제 #11
0
 public function indexAction()
 {
     $profilMapper = new UserMapper();
     $profil = $profilMapper->getUserById($this->getRequest()->getParam('user'));
     $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuUserList'), array('controller' => 'index'))->add($profil->getName(), array('controller' => 'profil', 'action' => 'index', 'user' => $this->getRequest()->getParam('user')))->add($this->getTranslator()->trans('menuMail'), array('action' => 'index', 'user' => $this->getRequest()->getParam('user')));
     if ($this->getRequest()->isPost()) {
         $sender = $profilMapper->getUserById($this->getUser()->getId());
         $name = $sender->getName();
         $email = $sender->getEmail();
         $subject = trim($this->getRequest()->getPost('subject'));
         $message = trim($this->getRequest()->getPost('message'));
         if (empty($subject)) {
             $this->addMessage('subjectEmpty');
             $this->redirect(array('action' => 'index', 'user' => $this->getRequest()->getParam('user')));
         } elseif (empty($message)) {
             $this->addMessage('messageEmpty');
             $this->redirect(array('action' => 'index', 'user' => $this->getRequest()->getParam('user')));
         } else {
             $sitetitle = $this->getConfig()->get('page_title');
             $date = new \Ilch\Date();
             if ($_SESSION['layout'] == $this->getConfig()->get('default_layout') && file_exists(APPLICATION_PATH . '/layouts/' . $this->getConfig()->get('default_layout') . '/views/modules/user/layouts/mail/usermail.php')) {
                 $messageTemplate = file_get_contents(APPLICATION_PATH . '/layouts/' . $this->getConfig()->get('default_layout') . '/views/modules/user/layouts/mail/usermail.php');
             } else {
                 $messageTemplate = file_get_contents(APPLICATION_PATH . '/modules/user/layouts/mail/usermail.php');
             }
             $messageReplace = array('{content}' => $message, '{sitetitle}' => $sitetitle, '{date}' => $date->format("l, d. F Y", true));
             $message = str_replace(array_keys($messageReplace), array_values($messageReplace), $messageTemplate);
             $mail = new \Ilch\Mail();
             $mail->setTo($profil->getEmail(), $profil->getName())->setSubject($subject)->setFrom($email, $name)->setMessage($message)->addGeneralHeader('Content-type', 'text/html; charset="utf-8"');
             $mail->send();
             $this->addMessage('emailSuccess');
             $this->redirect(array('controller' => 'profil', 'action' => 'index', 'user' => $this->getRequest()->getParam('user')));
         }
     }
     $this->getView()->set('profil', $profil);
 }
 /**
  * Checks if the user has enought rights to access the requested page.
  *
  * @param array $pluginData
  */
 public function __construct(array $pluginData)
 {
     if (!isset($pluginData['router'], $pluginData['config'])) {
         return;
     }
     $userId = null;
     if (isset($_SESSION['user_id'])) {
         $userId = (int) $_SESSION['user_id'];
     }
     $request = $pluginData['request'];
     if (!$userId) {
         if ($request->getModuleName() == 'events' && !in_array($request->getControllerName(), array('index', 'show', 'regist'))) {
             $pluginData['controller']->redirect(array('module' => 'user', 'controller' => 'login', 'action' => 'index'));
         }
     }
     $userMapper = new UserMapper();
     $user = $userMapper->getUserById($userId);
     if (!is_object($user)) {
         // Happens rarely, for example if a user id is saved in the session before reinstalling and the cms got just installed.
         return;
     }
     if ($user->isAdmin()) {
         /*
          * Administrator group should have sight on everything, return here.
          */
         return;
     }
     if ($request->isAdmin() && !$user->isAdmin()) {
         /*
          * Not admins have only access to modules.
          */
         if ($request->getModuleName() == 'admin' && !in_array($request->getControllerName(), array('index', 'login'))) {
             $pluginData['controller']->redirect(array('module' => 'admin', 'controller' => 'index', 'action' => 'index'));
         }
         /*
          * Check if user has right for this module.
          */
         if (!$user->hasAccess('module_' . $request->getModuleName()) && $request->getModuleName() !== 'admin') {
             $pluginData['controller']->redirect(array('module' => 'admin', 'controller' => 'index', 'action' => 'index'));
         }
     }
 }
예제 #13
0
 public function getPostByTopicId($topicId, $pagination = null)
 {
     $sql = 'SELECT SQL_CALC_FOUND_ROWS *
                        FROM `[prefix]_forum_posts`
                        WHERE topic_id = ' . $topicId . '
                        LIMIT ' . implode(',', $pagination->getLimit());
     $fileArray = $this->db()->queryArray($sql);
     $pagination->setRows($this->db()->querycell('SELECT FOUND_ROWS()'));
     $postEntry = array();
     $userMapper = new UserMapper();
     foreach ($fileArray as $entries) {
         $entryModel = new PostModel();
         $entryModel->setId($entries['id']);
         $entryModel->setText($entries['text']);
         $entryModel->setDateCreated($entries['date_created']);
         $entryModel->setAutor($userMapper->getUserById($entries['user_id']));
         $postEntry[] = $entryModel;
     }
     return $postEntry;
 }
예제 #14
0
 public function showImageAction()
 {
     $profilMapper = new UserMapper();
     $commentMapper = new CommentMapper();
     $imageMapper = new GalleryImageMapper();
     $galleryMapper = new GalleryMapper();
     $id = $this->getRequest()->getParam('id');
     $galleryId = $this->getRequest()->getParam('gallery');
     $userId = $this->getRequest()->getParam('user');
     $gallery = $galleryMapper->getGalleryById($galleryId);
     $comments = $commentMapper->getCommentsByKey('user/gallery/showimage/user/' . $userId . '/gallery/' . $galleryId . '/id/' . $id);
     $image = $imageMapper->getImageById($id);
     $profil = $profilMapper->getUserById($this->getRequest()->getParam('user'));
     $this->getLayout()->set('metaTitle', $this->getTranslator()->trans('gallery') . ' - ' . $gallery->getTitle() . ' - ' . $image->getImageTitle());
     $this->getLayout()->set('metaDescription', $this->getTranslator()->trans('gallery') . ' - ' . $gallery->getDesc());
     $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuUserList'), array('controller' => 'index'))->add($profil->getName(), array('controller' => 'profil', 'action' => 'index', 'user' => $this->getRequest()->getParam('user')))->add($this->getTranslator()->trans('menuGallery'), array('controller' => 'gallery', 'action' => 'index', 'user' => $this->getRequest()->getParam('user')))->add($gallery->getTitle(), array('action' => 'show', 'user' => $this->getRequest()->getParam('user'), 'id' => $galleryId))->add($image->getImageTitle(), array('action' => 'showimage', 'user' => $this->getRequest()->getParam('user'), 'gallery' => $galleryId, 'id' => $id));
     if ($this->getRequest()->getPost('saveComment')) {
         $date = new \Ilch\Date();
         $commentModel = new CommentModel();
         if ($this->getRequest()->getPost('fkId')) {
             $commentModel->setKey('user/gallery/showimage/user/' . $userId . '/gallery/' . $galleryId . '/id/' . $id . '/id_c/' . $this->getRequest()->getPost('fkId'));
             $commentModel->setFKId($this->getRequest()->getPost('fkId'));
         } else {
             $commentModel->setKey('user/gallery/showimage/user/' . $userId . '/gallery/' . $galleryId . '/id/' . $id);
         }
         $commentModel->setText($this->getRequest()->getPost('gallery_comment_text'));
         $commentModel->setDateCreated($date);
         $commentModel->setUserId($this->getUser()->getId());
         $commentMapper->save($commentModel);
     }
     $model = new GalleryImageModel();
     $model->setImageId($image->getImageId());
     $model->setVisits($image->getVisits() + 1);
     $imageMapper->saveVisits($model);
     $this->getView()->set('image', $imageMapper->getImageById($id));
     $this->getView()->set('comments', $comments);
 }
예제 #15
0
 public function getLastPostByTopicId($topicId)
 {
     $sql = 'SELECT `t`.`id`, `t`.`topic_id`, `p`.`read`, `p`.`id`, `p`.`topic_id`, `p`.`date_created`, `p`.`user_id`
             FROM `[prefix]_forum_topics` AS `t`
             LEFT JOIN `[prefix]_forum_posts` AS `p` ON `t`.`id` = `p`.`topic_id`
             WHERE `t`.`topic_id` = ' . $topicId . '
             ORDER BY `p`.`id` DESC';
     $fileRow = $this->db()->queryRow($sql);
     if (empty($fileRow)) {
         return null;
     }
     $entryModel = new PostModel();
     $userMapper = new UserMapper();
     $entryModel->setId($fileRow['id']);
     $entryModel->setAutor($userMapper->getUserById($fileRow['user_id']));
     $entryModel->setDateCreated($fileRow['date_created']);
     $entryModel->setTopicId($fileRow['topic_id']);
     $entryModel->setRead($fileRow['read']);
     $posts = $this->getCountPostsByTopicId($fileRow['topic_id']) - 1;
     $page = floor($posts / 20) + 1;
     $entryModel->setPage($page);
     return $entryModel;
 }
예제 #16
0
 public function getLastPostByTopicId($id)
 {
     $sql = 'SELECT p.id, p.topic_id, p.date_created, p.user_id, p.read
             FROM [prefix]_forum_posts as p 
             WHERE p.topic_id = ' . $id . '
               ORDER BY p.id DESC         ';
     $fileRow = $this->db()->queryRow($sql);
     if (empty($fileRow)) {
         return null;
     }
     $entryModel = new PostModel();
     $userMapper = new UserMapper();
     $forumMapper = new ForumMapper();
     $entryModel->setId($fileRow['id']);
     $entryModel->setAutor($userMapper->getUserById($fileRow['user_id']));
     $entryModel->setDateCreated($fileRow['date_created']);
     $entryModel->setTopicId($fileRow['topic_id']);
     $entryModel->setRead($fileRow['read']);
     $posts = $forumMapper->getCountPostsByTopicId($fileRow['topic_id']) - 1;
     $page = floor($posts / 20) + 1;
     $entryModel->setPage($page);
     return $entryModel;
 }
예제 #17
0
 public function dialogviewAction()
 {
     $profilMapper = new UserMapper();
     $DialogMapper = new DialogMapper();
     $ilchdate = new IlchDate();
     $profil = $profilMapper->getUserById($this->getUser()->getId());
     $c_id = $this->getRequest()->getParam('id');
     $user = $DialogMapper->getDialogCheckByCId($c_id);
     if ($this->getUser()->getId() != $user->getUserTwo()) {
         $user_two = $user->getUserOne();
     } else {
         $user_two = $user->getUserTwo();
     }
     if ($this->getUser()->getId() == $user_two) {
         if ($this->getRequest()->isPost()) {
             $u_id_fk = $this->getUser()->getId();
             $text = trim($this->getRequest()->getPost('text'));
             $model = new \Modules\User\Models\Dialog();
             $model->setCId($c_id);
             $model->setId($u_id_fk);
             $model->setTime($ilchdate->toDb());
             $model->setText($text);
             $DialogMapper->save($model);
             $this->redirect(array('action' => 'dialogview', 'id' => $c_id));
         }
         $this->getView()->set('inbox', $DialogMapper->getDialogMessage($c_id));
         $this->getView()->set('profil', $profil);
     } else {
         $this->redirect(array('action' => 'dialog'));
     }
 }
예제 #18
0
 /**
  * Checks if a user id was given in the request and sets the user.
  *
  * If no user id is given a default user will be created.
  *
  * @param array $pluginData
  */
 public function __construct(array $pluginData)
 {
     if (!isset($pluginData['config'])) {
         return;
     }
     $userId = null;
     if (isset($_SESSION['user_id'])) {
         $userId = (int) $_SESSION['user_id'];
     }
     $mapper = new UserMapper();
     $user = $mapper->getUserById($userId);
     \Ilch\Registry::set('user', $user);
     if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]) && preg_match("/^[0-9a-zA-Z\\/.:]{7,}\$/", $_SERVER["HTTP_X_FORWARDED_FOR"])) {
         $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
     } elseif (preg_match("/^[0-9a-zA-Z\\/.:]{7,}\$/", $_SERVER["REMOTE_ADDR"])) {
         $ip = $_SERVER["REMOTE_ADDR"];
     } else {
         $ip = '128.0.0.1';
     }
     if (empty($_SERVER['PATH_INFO']) or strpos($_SERVER['PATH_INFO'], 'admin', 1)) {
         $site = '';
     } else {
         $site = $_SERVER['PATH_INFO'];
     }
     function statisticOS($useragent)
     {
         $osArray = array('Windows XP' => '=Windows NT 5.1|Windows XP=', 'Windows Vista' => '=Windows NT 6.0|Windows Vista=', 'Windows 7' => '=Windows NT 6.1|Windows 7=', 'Windows 8' => '=Windows NT 6.2|Windows 8=', 'Windows 8.1' => '=Windows NT 6.3|Windows 8.1=', 'Windows 10' => '=Windows NT 10.0|Windows 10=', 'Windows 2000' => '=Windows NT 5.0|Windows 2000=', 'Windows Server 2003\\Windows XP x64' => '=Windows NT 5\\.2|Windows Server 2003|Windows XP x64=', 'Windows NT' => '=Windows NT 4|WinNT4=', 'Windows 98' => '=Windows 98=', 'Windows 95' => '=Windows 95=', 'Android' => '=Android=', 'Linux' => '=Linux|Ubuntu|X11=', 'SunOs' => '=SunOS=', 'iPhone' => '=iPhone=', 'iPad' => '=iPad=', 'Mac OS' => '=Mac OS X=', 'Macintosh' => '=Mac_PowerPC|Macintosh=');
         foreach ($osArray as $os => $regex) {
             if (preg_match($regex, $useragent)) {
                 return $os;
             }
         }
         return 0;
     }
     $os = statisticOS($_SERVER['HTTP_USER_AGENT']);
     function statisticBrowser($useragent)
     {
         if (preg_match("=Firefox/([\\.a-zA-Z0-9]*)=", $useragent, $browser)) {
             return "Firefox " . $browser[1];
         } elseif (preg_match("=MSIE ([0-9]{1,2})\\.[0-9]{1,2}=", $useragent, $browser)) {
             return "Internet Explorer " . $browser[1];
         } elseif (preg_match("=rv:([0-9]{1,2})\\.[0-9]{1,2}=", $useragent, $browser)) {
             return "Internet Explorer " . $browser[1];
         } elseif (preg_match("=Opera[/ ]([0-9\\.]+)=", $useragent, $browser)) {
             return "Opera " . $browser[1];
         } elseif (preg_match("=OPR\\/([0-9\\.]*)=", $useragent, $browser)) {
             $tmp = explode('.', $browser[1]);
             if (count($tmp) > 2) {
                 $browser[1] = $tmp[0] . '.' . $tmp[1];
             }
             return "Opera " . $browser[1];
         } elseif (preg_match("=Edge/([0-9\\.]*)=", $useragent, $browser)) {
             $tmp = explode('.', $browser[1]);
             if (count($tmp) > 2) {
                 $browser[1] = $tmp[0] . '.' . $tmp[1];
             }
             return "Edge " . $browser[1];
         } elseif (preg_match("=Chrome/([0-9\\.]*)=", $useragent, $browser)) {
             $tmp = explode('.', $browser[1]);
             if (count($tmp) > 2) {
                 $browser[1] = $tmp[0] . '.' . $tmp[1];
             }
             return "Chrome " . $browser[1];
         } elseif (preg_match('=Safari/=', $useragent)) {
             if (preg_match('=Version/([\\.0-9]*)=', $useragent, $browser)) {
                 $version = ' ' . $browser[1];
             } else {
                 $version = '';
             }
             return "Safari" . $version;
         } elseif (preg_match("=Konqueror=", $useragent)) {
             return "Konqueror";
         } elseif (preg_match("=Netscape|Navigator=", $useragent)) {
             return "Netscape";
         } else {
             return 0;
         }
     }
     $browser = statisticBrowser($_SERVER['HTTP_USER_AGENT']);
     if (empty($_SERVER["HTTP_REFERER"])) {
         $referer = '';
     } else {
         $referer = $_SERVER["HTTP_REFERER"];
     }
     $lang = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0, 2);
     $statisticMapper = new \Modules\Statistic\Mappers\Statistic();
     $statisticMapper->saveVisit(array('user_id' => $userId, 'site' => $site, 'referer' => $referer, 'os' => $os, 'browser' => $browser, 'ip' => $ip, 'lang' => $lang));
     if ($pluginData['request']->getParam('language')) {
         $_SESSION['language'] = $pluginData['request']->getParam('language');
     }
     if ($pluginData['request']->getParam('ilch_layout')) {
         $_SESSION['layout'] = $pluginData['request']->getParam('ilch_layout');
     }
     $pluginData['translator']->setLocale($pluginData['config']->get('locale'));
     if (!empty($_SESSION['language'])) {
         $pluginData['translator']->setLocale($_SESSION['language']);
     }
 }
예제 #19
0
파일: Index.php 프로젝트: sCar-w4y/Ilch-2.0
 /**
  * Deletes the given user.
  */
 public function deleteAction()
 {
     $userMapper = new UserMapper();
     $userId = $this->getRequest()->getParam('id');
     if ($userId && $this->getRequest()->isSecure()) {
         $deleteUser = $userMapper->getUserById($userId);
         /*
          * Admingroup has always id "1" because group is not deletable.
          */
         if ($deleteUser->getId() == Registry::get('user')->getId()) {
             $this->addMessage('delOwnUserProhibited', 'warning');
         } elseif ($deleteUser->hasGroup(1) && $userMapper->getAdministratorCount() === 1) {
             $this->addMessage('delLastAdminProhibited', 'warning');
             /*
              * Delete adminuser only if he is not the last admin.
              */
         } else {
             if ($deleteUser->getAvatar() != 'static/img/noavatar.jpg') {
                 unlink($deleteUser->getAvatar());
             }
             if (is_dir(APPLICATION_PATH . '/modules/user/static/upload/gallery/' . $userId)) {
                 $path = APPLICATION_PATH . '/modules/user/static/upload/gallery/' . $userId;
                 $files = array_diff(scandir($path), array('.', '..'));
                 foreach ($files as $file) {
                     unlink(realpath($path) . '/' . $file);
                 }
                 rmdir($path);
             }
             if ($userMapper->delete($userId)) {
                 $this->addMessage('delUserMsg');
             }
         }
     }
     $this->redirect(array('action' => 'index'));
 }
예제 #20
0
 /**
  * Deletes the given user.
  */
 public function deleteAction()
 {
     $userMapper = new UserMapper();
     $userId = $this->getRequest()->getParam('id');
     if ($userId && $this->getRequest()->isSecure()) {
         $deleteUser = $userMapper->getUserById($userId);
         /*
          * Admingroup has always id "1" because group is not deletable.
          */
         if ($deleteUser->getId() == Registry::get('user')->getId()) {
             $this->addMessage('delOwnUserProhibited', 'warning');
         } elseif ($deleteUser->hasGroup(1) && $userMapper->getAdministratorCount() === 1) {
             $this->addMessage('delLastAdminProhibited', 'warning');
             /*
              * Delete adminuser only if he is not the last admin.
              */
         } else {
             if ($deleteUser->getAvatar() != 'static/img/noavatar.jpg') {
                 unlink($deleteUser->getAvatar());
             }
             if ($userMapper->delete($userId)) {
                 $this->addMessage('delUserMsg');
             }
         }
     }
     $this->redirect(array('action' => 'index'));
 }