/**
  * @inheritdoc
  */
 public function isValid($data, $field = '', array $extra = [])
 {
     $date = $this->repository->getLastDateFromIp($extra['ip']);
     $floodTime = !empty($date) ? $this->date->timestamp($date, true) + 30 : 0;
     $time = $this->date->timestamp('now', true);
     return $floodTime <= $time;
 }
Exemplo n.º 2
0
 /**
  * @param int $id
  * @return array
  */
 public function execute($id)
 {
     if ($this->articleRepository->resultExists((int) $id, $this->date->getCurrentDateTime()) === true) {
         $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
         return ['sidebar_article' => $this->articlesCache->getCache($id)];
     }
 }
 public function fetchSitemapUrls()
 {
     $this->addUrl('news/index/index');
     foreach ($this->newsRepository->getAll($this->date->getCurrentDateTime()) as $result) {
         $this->addUrl(sprintf(Helpers::URL_KEY_PATTERN, $result['id']), $this->date->format($result['updated_at'], 'Y-m-d'));
     }
 }
Exemplo n.º 4
0
Arquivo: Index.php Projeto: acp3/cms
 /**
  * @return array
  */
 public function execute()
 {
     $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
     $resultsPerPage = $this->resultsPerPage->getResultsPerPage(Gallery\Installer\Schema::MODULE_NAME);
     $time = $this->date->getCurrentDateTime();
     $this->pagination->setResultsPerPage($resultsPerPage)->setTotalResults($this->galleryRepository->countAll($time));
     return ['galleries' => $this->galleryRepository->getAll($time, $this->pagination->getResultsStartOffset(), $resultsPerPage), 'dateformat' => $this->settings['dateformat'], 'pagination' => $this->pagination->render()];
 }
Exemplo n.º 5
0
 /**
  * @inheritdoc
  */
 public function process(array $params, \Smarty_Internal_Template $smarty)
 {
     $format = isset($params['format']) ? $params['format'] : 'long';
     if (isset($params['date'])) {
         return $this->date->format($params['date'], $format);
     }
     return '';
 }
Exemplo n.º 6
0
Arquivo: Pics.php Projeto: acp3/cms
 /**
  * @param int $id
  *
  * @return array
  * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
  */
 public function execute($id)
 {
     if ($this->galleryRepository->galleryExists($id, $this->date->getCurrentDateTime()) === true) {
         $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
         $this->breadcrumb->append($this->translator->t('gallery', 'gallery'), 'gallery')->append($this->galleryRepository->getGalleryTitle($id));
         return ['pictures' => $this->galleryCache->getCache($id), 'overlay' => (int) $this->settings['overlay']];
     }
     throw new Core\Controller\Exception\ResultNotExistsException();
 }
Exemplo n.º 7
0
 /**
  * @param int $categoryId
  * @param array $settings
  * @return array
  */
 private function fetchFiles($categoryId, array $settings)
 {
     if (!empty($categoryId)) {
         $files = $this->filesRepository->getAllByCategoryId((int) $categoryId, $this->date->getCurrentDateTime(), $settings['sidebar']);
     } else {
         $files = $this->filesRepository->getAll($this->date->getCurrentDateTime(), $settings['sidebar']);
     }
     return $files;
 }
Exemplo n.º 8
0
 /**
  * @inheritdoc
  */
 public function fetchDataAndRenderColumn(array $column, array $dbResultRow)
 {
     $value = $this->getValue($column, $dbResultRow);
     if ($value !== null && $value !== $this->getDefaultValue($column)) {
         $field = $this->getFirstDbField($column);
         $column['attribute'] += ['data-order' => $this->date->format($dbResultRow[$field], 'U')];
     }
     return $this->render($column, $value);
 }
Exemplo n.º 9
0
 protected function fetchSitemapUrls()
 {
     $this->addUrl('gallery/index/index');
     foreach ($this->galleryRepository->getAll($this->date->getCurrentDateTime()) as $result) {
         $this->addUrl(sprintf(Helpers::URL_KEY_PATTERN_GALLERY, $result['id']), $this->date->format($result['updated_at'], 'Y-m-d'));
         foreach ($this->pictureRepository->getPicturesByGalleryId($result['id']) as $picture) {
             $this->addUrl(sprintf(Helpers::URL_KEY_PATTERN_PICTURE, $picture['id']), $this->date->format($result['updated_at'], 'Y-m-d'));
         }
     }
 }
Exemplo n.º 10
0
 /**
  * @param int $id
  *
  * @return array
  * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
  */
 public function execute($id)
 {
     if ($this->articleRepository->resultExists($id, $this->date->getCurrentDateTime()) === true) {
         $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
         $article = $this->articlesCache->getCache($id);
         $this->breadcrumb->replaceAncestor($article['title'], '', true);
         return ['page' => array_merge($article, $this->pageBreaksHelper->splitTextIntoPages($this->view->fetchStringAsTemplate($article['text']), $this->request->getUriWithoutPages()))];
     }
     throw new Core\Controller\Exception\ResultNotExistsException();
 }
Exemplo n.º 11
0
 /**
  * @param int $categoryId
  *
  * @return array
  */
 public function execute($categoryId = 0)
 {
     $settings = $this->config->getSettings(News\Installer\Schema::MODULE_NAME);
     if (!empty($categoryId)) {
         $news = $this->newsRepository->getLatestByCategoryId((int) $categoryId, $this->date->getCurrentDateTime());
     } else {
         $news = $this->newsRepository->getLatest($this->date->getCurrentDateTime());
     }
     return ['sidebar_news_latest' => $news, 'dateformat' => $settings['dateformat']];
 }
 public function fetchSitemapUrls()
 {
     $this->addUrl('files/index/index');
     foreach ($this->categoryRepository->getAllByModuleName(Schema::MODULE_NAME) as $category) {
         $this->addUrl('files/index/files/cat_' . $category['id']);
     }
     foreach ($this->filesRepository->getAll($this->date->getCurrentDateTime()) as $result) {
         $this->addUrl(sprintf(Helpers::URL_KEY_PATTERN, $result['id']), $this->date->format($result['updated_at'], 'Y-m-d'));
     }
 }
Exemplo n.º 13
0
 /**
  * @return array
  */
 public function fetchFeedItems()
 {
     $items = [];
     $results = $this->filesRepository->getAll($this->date->getCurrentDateTime(), 10);
     $cResults = count($results);
     for ($i = 0; $i < $cResults; ++$i) {
         $items[] = ['title' => $results[$i]['title'], 'date' => $this->date->timestamp($results[$i]['start']), 'description' => $this->formatter->shortenEntry($results[$i]['text'], 300, 0), 'link' => $this->router->route('files/index/details/id_' . $results[$i]['id'], true)];
     }
     return $items;
 }
Exemplo n.º 14
0
 /**
  * @param int $cat
  *
  * @return array
  * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
  */
 public function execute($cat)
 {
     if ($this->categoryRepository->resultExists($cat) === true) {
         $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
         $category = $this->categoryRepository->getOneById($cat);
         $this->breadcrumb->append($this->translator->t('files', 'files'), 'files')->append($category['title']);
         $settings = $this->config->getSettings(FilesModule\Installer\Schema::MODULE_NAME);
         return ['dateformat' => $settings['dateformat'], 'files' => $this->filesRepository->getAllByCategoryId($cat, $this->date->getCurrentDateTime())];
     }
     throw new Core\Controller\Exception\ResultNotExistsException();
 }
Exemplo n.º 15
0
 /**
  * @param int $id
  * @return array
  * @throws Core\Controller\Exception\ResultNotExistsException
  */
 public function execute($id)
 {
     if ($this->filesRepository->resultExists($id, $this->date->getCurrentDateTime()) === true) {
         $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
         $file = $this->filesCache->getCache($id);
         $this->breadcrumb->append($this->translator->t('files', 'files'), 'files')->append($file['category_title'], 'files/index/files/cat_' . $file['category_id'])->append($file['title']);
         $settings = $this->config->getSettings(Files\Installer\Schema::MODULE_NAME);
         $file['text'] = $this->view->fetchStringAsTemplate($file['text']);
         return ['file' => $file, 'dateformat' => $settings['dateformat'], 'comments_allowed' => $settings['comments'] == 1 && $file['comments'] == 1];
     }
     throw new Core\Controller\Exception\ResultNotExistsException();
 }
Exemplo n.º 16
0
 /**
  * @param int $id
  *
  * @return array|\Symfony\Component\HttpFoundation\RedirectResponse
  * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
  */
 public function execute($id)
 {
     $answer = $this->request->getPost()->get('answer');
     $time = $this->date->getCurrentDateTime();
     if ($this->pollRepository->pollExists($id, $time, is_array($answer)) === true) {
         if (!empty($answer) || is_array($answer) === true) {
             return $this->executePost($this->request->getPost()->all(), $time, $id);
         }
         $poll = $this->pollRepository->getOneById($id);
         return ['question' => $poll['title'], 'multiple' => $poll['multiple'], 'answers' => $this->answerRepository->getAnswersByPollId($id)];
     }
     throw new Core\Controller\Exception\ResultNotExistsException();
 }
Exemplo n.º 17
0
 /**
  * @return array
  */
 public function execute()
 {
     $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
     $polls = $this->pollRepository->getAll($this->date->getCurrentDateTime());
     $cPolls = count($polls);
     for ($i = 0; $i < $cPolls; ++$i) {
         if ($this->hasAlreadyVoted($polls[$i]['id']) || $polls[$i]['start'] !== $polls[$i]['end'] && $this->date->timestamp($polls[$i]['end']) <= $this->date->timestamp()) {
             $polls[$i]['link'] = 'result';
         } else {
             $polls[$i]['link'] = 'vote';
         }
     }
     return ['polls' => $polls];
 }
Exemplo n.º 18
0
 /**
  * @param int $id
  *
  * @return array
  * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
  */
 public function execute($id)
 {
     $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
     if ($this->pollRepository->pollExists($id, $this->date->getCurrentDateTime()) === true) {
         $question = $this->pollRepository->getOneByIdWithTotalVotes($id);
         $answers = $this->answerRepository->getAnswersWithVotesByPollId($id);
         $cAnswers = count($answers);
         $totalVotes = $question['total_votes'];
         for ($i = 0; $i < $cAnswers; ++$i) {
             $answers[$i]['percent'] = $totalVotes > 0 ? round(100 * $answers[$i]['votes'] / $totalVotes, 2) : '0';
         }
         return ['question' => $question['title'], 'answers' => $answers, 'total_votes' => $totalVotes];
     }
     throw new Core\Controller\Exception\ResultNotExistsException();
 }
Exemplo n.º 19
0
 /**
  * @param int $id
  *
  * @return array
  * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
  */
 public function execute($id)
 {
     if ($this->newsRepository->resultExists($id, $this->date->getCurrentDateTime()) == 1) {
         $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
         $news = $this->newsCache->getCache($id);
         $this->breadcrumb->append($this->translator->t('news', 'news'), 'news');
         if ($this->newsSettings['category_in_breadcrumb'] == 1) {
             $this->breadcrumb->append($news['category_title'], 'news/index/index/cat_' . $news['category_id']);
         }
         $this->breadcrumb->append($news['title']);
         $news['text'] = $this->view->fetchStringAsTemplate($news['text']);
         $news['target'] = $news['target'] == 2 ? ' target="_blank"' : '';
         return ['news' => $news, 'dateformat' => $this->newsSettings['dateformat'], 'comments_allowed' => $this->commentsActive === true && $news['comments'] == 1];
     }
     throw new Core\Controller\Exception\ResultNotExistsException();
 }
Exemplo n.º 20
0
Arquivo: Date.php Projeto: acp3/core
 /**
  * @param string $name
  * @param string $value
  * @param bool   $showTime
  *
  * @return string
  */
 protected function fetchSimpleDatePickerValue($name, $value, $showTime)
 {
     if ($this->request->getPost()->has($name)) {
         return $this->request->getPost()->get($name, '');
     } elseif ($this->dateValidationRule->isValid($value) === true) {
         return $this->date->format($value, $this->getDateFormat($showTime));
     }
     return $this->date->format('now', $this->getDateFormat($showTime), false);
 }
Exemplo n.º 21
0
 /**
  * @param int $id
  * @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  * @throws Core\Controller\Exception\ResultNotExistsException
  */
 public function execute($id)
 {
     if ($this->filesRepository->resultExists($id, $this->date->getCurrentDateTime()) === true) {
         $file = $this->filesCache->getCache($id);
         $path = $this->appPath->getUploadsDir() . 'files/';
         if (is_file($path . $file['file'])) {
             $ext = strrchr($file['file'], '.');
             $filename = $this->stringFormatter->makeStringUrlSafe($file['title']) . $ext;
             $response = new BinaryFileResponse($path . $file['file']);
             $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $filename);
             return $response;
         } elseif (preg_match('/^([a-z]+):\\/\\//', $file['file'])) {
             // External file
             return $this->redirect()->toNewPage($file['file']);
         }
     }
     throw new Core\Controller\Exception\ResultNotExistsException();
 }
Exemplo n.º 22
0
 /**
  * @param int $cat
  *
  * @return array
  */
 public function execute($cat = 0)
 {
     $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
     $this->addBreadcrumbStep($cat);
     $time = $this->date->getCurrentDateTime();
     $this->pagination->setResultsPerPage($this->resultsPerPage->getResultsPerPage(News\Installer\Schema::MODULE_NAME))->setTotalResults($this->newsRepository->countAll($time, $cat));
     $news = $this->fetchNews($cat, $time);
     $cNews = count($news);
     for ($i = 0; $i < $cNews; ++$i) {
         $news[$i]['text'] = $this->view->fetchStringAsTemplate($news[$i]['text']);
         if ($this->commentsActive === true && $news[$i]['comments'] == 1) {
             $news[$i]['comments_count'] = $this->get('comments.helpers')->commentsCount(News\Installer\Schema::MODULE_NAME, $news[$i]['id']);
         }
         if ($this->newsSettings['readmore'] == 1 && $news[$i]['readmore'] == 1) {
             $news[$i]['text'] = $this->addReadMoreLink($news[$i]);
         }
     }
     return ['news' => $news, 'dateformat' => $this->newsSettings['dateformat'], 'categories' => $this->categoriesHelpers->categoriesList('news', $cat), 'pagination' => $this->pagination->render()];
 }
Exemplo n.º 23
0
 /**
  * @return array
  */
 public function execute()
 {
     $poll = $this->pollRepository->getLatestPoll($this->date->getCurrentDateTime());
     $answers = [];
     $this->setTemplate('Polls/Widget/index.vote.tpl');
     if (!empty($poll)) {
         $answers = $this->answerRepository->getAnswersWithVotesByPollId($poll['id']);
         if ($this->hasAlreadyVoted($poll['id'])) {
             $totalVotes = $poll['total_votes'];
             $cAnswers = count($answers);
             for ($i = 0; $i < $cAnswers; ++$i) {
                 $votes = $answers[$i]['votes'];
                 $answers[$i]['votes'] = $votes > 1 ? $this->translator->t('polls', 'number_of_votes', ['%votes%' => $votes]) : $this->translator->t('polls', $votes == 1 ? 'one_vote' : 'no_votes');
                 $answers[$i]['percent'] = $totalVotes > 0 ? round(100 * $votes / $totalVotes, 2) : '0';
             }
             $this->setTemplate('Polls/Widget/index.result.tpl');
         }
     }
     return ['sidebar_polls' => $poll, 'sidebar_poll_answers' => $answers];
 }
Exemplo n.º 24
0
Arquivo: Details.php Projeto: acp3/cms
 /**
  * @param int $id
  *
  * @return array
  * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
  */
 public function execute($id)
 {
     if ($this->pictureRepository->pictureExists($id, $this->date->getCurrentDateTime()) === true) {
         $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
         $picture = $this->pictureRepository->getOneById($id);
         $this->breadcrumb->append($this->translator->t('gallery', 'gallery'), 'gallery')->append($picture['title'], 'gallery/index/pics/id_' . $picture['gallery_id'])->append($this->translator->t('gallery', 'details'));
         $this->title->setPageTitlePrefix($picture['title'])->setPageTitlePostfix($this->translator->t('gallery', 'picture_x', ['%picture%' => $picture['pic']]));
         $picture = $this->calculatePictureDimensions($picture);
         $previousPicture = $this->pictureRepository->getPreviousPictureId($picture['pic'], $picture['gallery_id']);
         if (!empty($previousPicture)) {
             $this->setPreviousPage((int) $previousPicture);
         }
         $nextPicture = $this->pictureRepository->getNextPictureId($picture['pic'], $picture['gallery_id']);
         if (!empty($nextPicture)) {
             $this->setNextPage((int) $nextPicture);
         }
         return ['picture' => $picture, 'picture_next' => $nextPicture, 'picture_previous' => $previousPicture, 'comments_allowed' => $this->isCommentsAllowed($picture)];
     }
     throw new Core\Controller\Exception\ResultNotExistsException();
 }
Exemplo n.º 25
0
 /**
  * @param array $formData
  * @param array $settings
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 protected function executePost(array $formData, array $settings)
 {
     return $this->actionHelper->handlePostAction(function () use($formData, $settings) {
         $this->registrationFormValidation->validate($formData);
         $systemSettings = $this->config->getSettings(Schema::MODULE_NAME);
         $subject = $this->translator->t('users', 'register_mail_subject', ['{title}' => $systemSettings['site_title'], '{host}' => $this->request->getHost()]);
         $body = $this->translator->t('users', 'register_mail_message', ['{name}' => $formData['nickname'], '{mail}' => $formData['mail'], '{password}' => $formData['pwd'], '{title}' => $systemSettings['site_title'], '{host}' => $this->request->getHost()]);
         $mailIsSent = $this->sendEmail->execute('', $formData['mail'], $settings['mail'], $subject, $body);
         $salt = $this->secureHelper->salt(Users\Model\UserModel::SALT_LENGTH);
         $insertValues = ['id' => '', 'nickname' => $this->get('core.helpers.secure')->strEncode($formData['nickname']), 'pwd' => $this->secureHelper->generateSaltedPassword($salt, $formData['pwd'], 'sha512'), 'pwd_salt' => $salt, 'mail' => $formData['mail'], 'date_format_long' => $systemSettings['date_format_long'], 'date_format_short' => $systemSettings['date_format_short'], 'time_zone' => $systemSettings['date_time_zone'], 'language' => $systemSettings['lang'], 'registration_date' => $this->date->getCurrentDateTime()];
         $lastId = $this->userRepository->insert($insertValues);
         $bool2 = $this->permissionsHelpers->updateUserRoles([2], $lastId);
         $this->setTemplate($this->get('core.helpers.alerts')->confirmBox($this->translator->t('users', $mailIsSent === true && $lastId !== false && $bool2 !== false ? 'register_success' : 'register_error'), $this->appPath->getWebRoot()));
     }, $this->request->getFullPath());
 }
Exemplo n.º 26
0
 /**
  * @param string $value
  * @return string
  */
 public function doEscape($value)
 {
     return $this->date->toSQL($value);
 }
Exemplo n.º 27
0
 /**
  * @param string $template
  * @return array
  */
 public function execute($template = '')
 {
     $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
     $this->setTemplate($template);
     return ['sidebar_articles' => $this->articleRepository->getAll($this->date->getCurrentDateTime(), 5)];
 }
 /**
  * @param string $fields
  * @param string $searchTerm
  * @param string $sortDirection
  *
  * @return array
  */
 public function getAllSearchResults($fields, $searchTerm, $sortDirection)
 {
     return $this->db->fetchAll("SELECT `id`, `title`, `text` FROM {$this->getTableName()} WHERE MATCH ({$fields}) AGAINST ({$this->db->getConnection()->quote($searchTerm)} IN BOOLEAN MODE) AND {$this->getPublicationPeriod()} ORDER BY `start` {$sortDirection}, `end` {$sortDirection}, `id` {$sortDirection}", ['time' => $this->date->getCurrentDateTime()]);
 }
Exemplo n.º 29
0
Arquivo: Index.php Projeto: acp3/cms
 /**
  * @return array
  */
 public function execute()
 {
     $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
     $settings = $this->config->getSettings(Gallery\Installer\Schema::MODULE_NAME);
     return ['sidebar_galleries' => $this->galleryModel->getAll($this->date->getCurrentDateTime(), $settings['sidebar'])];
 }
Exemplo n.º 30
0
 /**
  * @param int $status
  * @param int $accountId
  *
  * @return bool|int
  */
 protected function addAccountHistory($status, $accountId)
 {
     $historyInsertValues = ['newsletter_account_id' => $accountId, 'date' => $this->date->toSQL(), 'action' => $status];
     return $this->accountHistoryRepository->insert($historyInsertValues);
 }