public function preDispatch(Zend_Controller_Request_Abstract $request) { if (!isset($_SERVER['HTTP_USER_AGENT']) || isset($_SERVER['HTTP_USER_AGENT']) && false === strpos($_SERVER['HTTP_USER_AGENT'], 'sanmax-crawler-bot')) { return; } $config = array('accept_schemes' => 'basic', 'realm' => 'crawler', 'digest_domains' => '/', 'nonce_timeout' => 3600); $adapter = new Zend_Auth_Adapter_Http($config); $basicResolver = new Zend_Auth_Adapter_Http_Resolver_File(APPLICATION_PATH . '/var/bot-basic'); $adapter->setBasicResolver($basicResolver); $response = Zend_Controller_Front::getInstance()->getResponse(); $adapter->setRequest($request); $adapter->setResponse($response); $auth = Zend_Auth::getInstance(); $result = $auth->authenticate($adapter); if (!$result->isValid()) { $response->sendHeaders(); exit; } $user = new SxCms_User(); $gMapper = new SxCms_Group_DataMapper(); $groups = $gMapper->getAll(); foreach ($groups as $group) { $user->addGroup($group); } $storage = $auth->getStorage(); $storage->write($user); $front = Zend_Controller_Front::getInstance(); $front->setParam('isBot', true); $mvc = Zend_Layout::getMvcInstance(); $view = $mvc->getView(); $view->isBot = true; return; }
public function editAction() { SxCms_Acl::requireAcl('filemanager', 'filemanager.edit'); $mapper = new SxCms_Group_DataMapper(); $this->view->groups = $mapper->getAll(); $base = APPLICATION_PATH . '/../public_html/files/'; if ($this->_getParam('file')) { $path = base64_decode($this->_getParam('file')); $file = new SxCms_File($base . $path); } else { $path = base64_decode($this->_getParam('dir')); $file = new SxCms_Dir($base . $path); } if ($this->getRequest()->isPost()) { $file->setFilename($this->_getParam('filename')); if ($this->_getParam('file')) { $file->setTitle($this->_getParam('title'))->setSource($this->_getParam('source'))->setSummary($this->_getParam('summary'))->setLink($this->_getParam('link')); $file->clearPermissions(); foreach ((array) $this->_getParam('group') as $groupId) { $group = new SxCms_Group(); $group->setId($groupId); $file->addPermission($group); } } $file->save(); $flashMessenger = $this->_helper->getHelper('FlashMessenger'); $flashMessenger->addMessage('Bestand werd succesvol aangepast!'); $this->_redirect('/admin/filemanager/index/path/' . $this->_getParam('path')); } $this->view->file = $file; $this->view->path = $this->_getParam('path'); }
public function editAction() { SxCms_Acl::requireAcl('account', 'account.edit'); $id = $this->_getParam('id'); $gMapper = new SxCms_Group_DataMapper(); $this->view->groups = $gMapper->getAll(); $proxy = new SxCms_User_DataMapper(); $user = $proxy->getById($id); if ($this->getRequest()->isPost()) { $user->setFirstName($this->_getParam('first_name'))->setLastName($this->_getParam('last_name')); if ($this->_getParam('password') || $this->_getParam('password_repeat')) { $user->setPassword($this->_getParam('password')); } foreach ($this->_getParam('group') as $groupId) { $group = new SxCms_Group(); $group->setId($groupId); $user->addGroup($group); } $validator = new SxCms_User_UpdateValidator(); $validator->setOldPassword($this->_getParam('old_password')); $validator->setPasswordRepeat($this->_getParam('password_repeat')); if ($validator->validate($user)) { $user->save(); $this->_helper->redirector->gotoSimple('index', 'account'); } } $this->view->user = $user; $this->view->messages = Sanmax_MessageStack::getInstance('SxCms_User'); }
public function indexAction() { SxCms_Acl::requireAcl('group', 'group.index'); $mapper = new SxCms_Group_DataMapper(); $this->view->groups = $mapper->getAll(); }
public function addAction() { SxCms_Acl::requireAcl('page', 'page.add'); $system = new Zend_Session_Namespace('System'); $wizard = new Zend_Session_Namespace('Cms_PageWizard'); if ($this->_getParam('reset')) { $wizard->page = new SxCms_Page(); $wizard->page->setLanguage($system->lng); $this->_helper->redirector->gotoSimple('wizard-type', 'page'); } $mapper = new SxCms_Group_DataMapper(); $this->view->groups = $mapper->getAll(); $revision = new SxCms_Page_Revision(); $revision->setApproved(true); $revision->setNotes($this->admin_tmx->_('newpagecreated')); if ($wizard->page->getId() !== false) { $revision->setApproved(false); $revision->setNotes($this->admin_tmx->_('pageedited')); } if ($this->getRequest()->isPost()) { $path = APPLICATION_ROOT . '/public_html/images/thumbs/1200x160/'; $path1 = APPLICATION_ROOT . '/public_html/images/thumbs/400x180/'; if (!is_dir($path)) { mkdir($path, 0777, true); } if (!is_dir($path1)) { mkdir($path1, 0777, true); } $system->lng = $this->_getParam('lang'); $adapter = new Zend_File_Transfer_Adapter_Http(); $adapter->setDestination($path); $adapter->setOptions(array('ignoreNoFile' => true)); if (!$adapter->receive()) { $msgr = Sanmax_MessageStack::getInstance('SxCms_Page'); $msgr->addMessage('file', $adapter->getMessages(), 'title'); } $wizard->page->setThumb(null); $files = $adapter->getFileInfo(); foreach ($files as $file) { if (!$file['tmp_name']) { continue; } $filename = uniqid() . '.jpg'; $image = new Imagick($file['tmp_name']); $image->cropThumbnailImage(1200, 190); $image->setCompressionQuality(100); $image->setCompression(Imagick::COMPRESSION_JPEG); $image->setImageFormat('jpeg'); $image->writeImage($path . $filename); $image->clear(); $image->destroy(); $image = new Imagick($file['tmp_name']); $image->cropThumbnailImage(400, 180); $image->setCompressionQuality(100); $image->setCompression(Imagick::COMPRESSION_JPEG); $image->setImageFormat('jpeg'); $image->writeImage($path1 . $filename); $image->clear(); $image->destroy(); unlink($file['tmp_name']); $wizard->page->setThumb($filename); } $wizard->page->clearPermissions(); foreach ((array) $this->_getParam('group') as $groupId) { $group = new SxCms_Group(); $group->setId($groupId); $wizard->page->addPermission($group); } $wizard->page->setTitle($this->_getParam('title'))->setTitleFallback($this->_getParam('title_fb'))->setSummary($this->_getParam('summary'))->setSummaryFallback($this->_getParam('summary_fb'))->setContent($this->_getParam('contenti'))->setContentFallback($this->_getParam('content_fb'))->setSource($this->_getParam('source'))->setSourceFallback($this->_getParam('source_fb'))->setLayout($this->_getParam('layout', 'default'))->addTag(explode("\n", $this->_getParam('tags')))->setLink($this->_getParam('link'))->setNavigation($this->_getParam('menu'), false)->setSitemap($this->_getParam('sitemap'), false)->setAllowComments($this->_getParam('comments'), false)->setInvisible($this->_getParam('invisible'))->setSeoTitle($this->_getParam('seotitle'))->setSeoTags($this->_getParam('seotags'))->setSeoDescription($this->_getParam('seodescription')); $revision->setNotes($this->_getParam('notes')); $datePublished = $this->_getParam('date_published') . ' ' . $this->_getParam('publish_h') . ':' . $this->_getParam('publish_i') . ':00'; $dateExpired = null; if ($this->_getParam('date_expired')) { $dateExpired = $this->_getParam('date_expired') . ' ' . $this->_getParam('expire_h') . ':' . $this->_getParam('expire_i') . ':00'; } $wizard->page->setDatePublished($datePublished)->setDateExpired($dateExpired); if ($this->_getParam('translation')) { $wizard->page->markTranslationInvalid(); } if ($wizard->page->isValid()) { $config = Zend_Registry::get('config'); if ($wizard->page->getId() === false) { $lngs = $config->system->language; } else { $lngs[$wizard->page->getLanguage()] = null; } $wizard->page->save(); foreach ($lngs as $lng => $slng) { $revision->setNotes($this->_getParam('notes'))->setLanguage($lng)->setTitle($wizard->page->getTitle())->setTitleFallback($wizard->page->hasTitleFallback())->setSummary($wizard->page->getSummary())->setSummaryFallback($wizard->page->hasSummaryFallback())->setContent($wizard->page->getContent())->setContentFallback($wizard->page->hasContentFallback())->setSource($wizard->page->getSource())->setSourceFallback($wizard->page->hasSourceFallback())->setLink($wizard->page->getLink())->setLinkFallback($wizard->page->hasLinkFallback())->setPageId($wizard->page->getId())->setInvisible($wizard->page->getInvisible()); $revision->setSeoTitle($wizard->page->getSeoTitle())->setSeoTags($wizard->page->getSeoTags())->setSeoDescription($wizard->page->getSeoDescription()); $revision->save(); if (!$this->_getParam('revision')) { $revision->approve(); } } $flashMessenger = $this->_helper->getHelper('FlashMessenger'); $flashMessenger->addMessage($this->admin_tmx->_('pagesavesuccess')); if ($wizard->page->getType() == SxCms_Page::ARTICLE) { $this->_helper->redirector->gotoSimple('news', 'page'); } else { $this->_helper->redirector->gotoSimple('index', 'page'); } $wizard->unsetAll(); } $wizard->page->setDatePublished($this->_getParam('date_published'))->setDateExpired($this->_getParam('date_expired')); } $this->view->page = $wizard->page; $this->view->messages = Sanmax_MessageStack::getInstance('SxCms_Page'); $this->view->revision = $revision; }