public function logoutAction() { $this->disableLayout(); $this->setNoRender(); Gio_Core_Session::destroy(); $this->redirect($this->view->url('core_index_index')); }
public function addAction() { $request = $this->getRequest(); $this->view->defaultModule = $this->_defaultModule; $sourceId = $request->getParam('source_id'); $sourceCategory = null == $sourceId ? null : Modules_Category_Services_Category::getById($sourceId); $this->view->sourceCategory = $sourceCategory; $this->view->lang = $request->getParam('lang'); $conn = Gio_Db_Connection::getConnection(); $categoryDao = new Modules_Category_Models_Mysql_Category(); $categoryDao->setConnection($conn); $this->view->categoryDao = $categoryDao; if ($request->isPost()) { $user = Gio_Core_Session::getUser(); $categoryData = $request->getPost('category'); $categoryData = Modules_Category_Services_Category::validate($categoryData); if (isset($categoryData['messages_error']) && $categoryData['messages_error']) { $this->view->errorMessages = $categoryData['messages']; $this->view->categoryData = $categoryData; return; } $parentCategory = null; if ($categoryData['parent_id']) { $parentCategory = Modules_Category_Services_Category::getById($categoryData['parent_id']); } $path = $parentCategory && $parentCategory['category_path'] ? $parentCategory['category_path'] . '/' . $categoryData['slug'] : $categoryData['slug']; $category = array('name' => $this->view->STRING->escape($categoryData['name']), 'slug' => $this->view->STRING->escape($categoryData['slug']), 'category_path' => $this->view->STRING->escape($path), 'meta' => $this->view->STRING->escape($categoryData['meta']), 'status' => $this->view->STRING->escape($categoryData['status']), 'module_id' => $this->view->STRING->escape($categoryData['module_id']), 'parent_id' => $this->view->STRING->escape($categoryData['parent_id']), 'language' => $this->view->STRING->escape($categoryData['language']), 'status' => $this->view->STRING->escape($categoryData['status']), 'created_date' => date('Y-m-d H:i:s'), 'modified_date' => date('Y-m-d H:i:s'), 'user_id' => $user['user_id']); $sourceItem = isset($categoryData['source_item']) ? $categoryData['source_item'] : null; $categoryId = Modules_Category_Services_Category::add($category, $sourceItem); Gio_Core_Messenger::getInstance()->addMessage($this->view->TRANSLATOR->translator('category_actions_add_success')); $this->redirect($this->view->url('category_category_add')); } }
public function showAction() { $json = new Services_JSON(); $params = $this->_request->getParam('params'); $params = (array) $json->decode($params); $this->view->uploadElementId = 'uploadFile_' . uniqid(); $this->view->sessionId = Gio_Core_Session::getId(); $this->view->editor = 'ckeditor'; $this->view->currModule = Gio_Core_Controller::getIntance()->getModuleName(); }
public static function isAllowed($action, $controller = null, $module = null) { $phpSessionId = $request->getPost('PHPSESSID'); $session = Gio_Core_Session::getSessionById($phpSessionId); $json = new Services_JSON(); $user = null == $session || null == $session['data'] ? null : $json->decode($session['data']); if (null == $user) { return false; } }
public function __construct() { $this->_rules = Modules_Core_Services_Rule::getAclRules(); $request = Gio_Core_Request::getInstance(); $phpSessionId = $request->getPost('PHPSESSID'); $session = Gio_Core_Session::getSessionById($phpSessionId); $json = new Services_JSON(); $user = null == $session || null == $session['data'] ? null : $json->decode($session['data']); $this->_user = $user; }
public function run() { $request = Gio_Core_Request::getInstance(); $configs = Gio_Core_Config_Xml::getConfig('web'); $adminPrefixUrl = $configs->admin->url_prefix; $adminTemplate = $configs->admin->template; $adminSkin = isset($configs->admin->skin) ? $configs->admin->skin : 'default'; $baseUrl = $request->getBaseUrl(); $uri = $request->getRequestUri(); $serverName = $request->getServerName(); $serverPort = $request->getServerPort(); $serverPort = $serverPort == 80 ? '' : ':' . $serverPort; $uri = 'http://' . $serverName . $serverPort . $uri; $currentUrl = str_replace($baseUrl, '', $uri); $currentUrl = '/' . rtrim(ltrim($currentUrl, '/'), '/') . '/'; /** * 7 is length of /admin/ */ $length = strlen($adminPrefixUrl) + 2; if (!$adminPrefixUrl || substr($currentUrl, 0, $length) != "/{$adminPrefixUrl}/") { return; } $controllerFront = Gio_Core_Controller::getIntance(); $controllerFront->setTemplate($adminTemplate); $view = Gio_Core_View::getInstance(); $view->APP_TEMPLATE = $adminTemplate; $view->APP_SKIN = $adminSkin; $view->setAdminSection(true); /** * Check admin login */ $phpSessionId = $request->getPost('PHPSESSID'); $session = Gio_Core_Session::getSessionById($phpSessionId); $json = new Services_JSON(); $user = null == $session || null == $session['data'] ? null : $json->decode($session['data']); $view->userLogin = $user; //return; $route = Gio_Core_Route::getCurrentRoute(true); if ((null == $user || !isset($user->username) || null == $user->username) && (null == $route || $route['name'] != 'core_auth_login')) { $return = $_SERVER['REQUEST_URI']; $return = $return ? rawurlencode(base64_encode($return)) : null; $link = $view->url('core_auth_login'); if (strpos($link, '?') !== false) { $return = $return != null ? '&return=' . $return : null; } else { $return = $return != null ? '?return=' . $return : null; } header('Location: ' . $link . $return); exit; } }
public function __construct($blocks = array()) { $this->setBlocks($blocks); $configs = Gio_Core_Config_Xml::getConfig(); /** * Not installed GioCMS */ if (!Gio_Core_Application::_initInstallChecker()) { $request = Gio_Core_Request::getInstance(); $configs->server->static = $request->getBaseUrl(); $configs->server->resource = $request->getBaseUrl(); $configs->web->url = $request->getBaseUrl(); } $this->APP_STATIC_SERVER = (string) $configs->server->static; $this->APP_RESOURCE_SERVER = (string) $configs->server->resource; $this->APP_WEB_URL = (string) $configs->web->url; $this->APP_WEB_NAME = (string) $configs->web->name; $this->APP_TEMPLATE = (string) $configs->web->template; $this->APP_SKIN = (string) $configs->web->skin; $this->APP_META_KEYWORD = (string) $configs->web->meta->keyword; $this->APP_META_DESCRIPTION = (string) $configs->web->meta->description; $defaultLanguage = (string) $configs->web->language; //$lang = Gio_Core_Request::getInstance()->getParam('lang'); //$this->APP_LANG = ($lang && $defaultLanguage != $lang) ? $lang : $defaultLanguage; $this->APP_LANG = $defaultLanguage; $routes = Gio_Core_Route::getInstance(); $this->routes = $routes; $string = Gio_Core_String::getInstance(); $this->STRING = $string; $translator = new Gio_Core_Translator(); $this->TRANSLATOR = $translator; if (Gio_Core_Application::_initInstallChecker() == true) { $acl = Gio_Core_Acl::getIntance(); $this->ACL = $acl; } $messenger = Gio_Core_Messenger::getInstance(); $this->MESSENGER = $messenger; if (Gio_Core_Application::_initInstallChecker()) { $user = Gio_Core_Session::getUser(); $this->USER = $user; } /** * JSON */ $json = new Services_JSON(); $this->JSON = $json; $this->CONFIG = $configs; }
public function uploadAction() { $this->disableLayout(); $this->setNoRender(); $request = $this->getRequest(); if (!$request->isPost()) { exit; } /** * Authentication */ $phpSessionId = $request->getPost('PHPSESSID'); $session = Gio_Core_Session::getSessionById($phpSessionId); $json = new Services_JSON(); $user = null == $session || null == $session['data'] ? null : $json->decode($session['data']); if (null == $user) { return; } /** * Get config */ $configFile = MOD_DIR . DS . 'upload' . DS . 'configs' . DS . 'config.ini'; $iniArray = @parse_ini_file($configFile, true); $tool = isset($iniArray['thumbnail']['tool']) ? $iniArray['thumbnail']['tool'] : 'gd'; $sizes = array(); foreach ($iniArray['size'] as $key => $value) { list($method, $width, $height) = explode('_', $value); $sizes[$key] = array('method' => $method, 'width' => $width, 'height' => $height); } $user = (array) $user; $userName = $user['username']; $module = $request->getPost('mod'); $thumbnailSizes = $request->getPost('thumbnails', null); /** * Prepare folders */ $dir = ROOT_DIR . DS . 'upload'; $path = implode(DS, array($module, $userName, date('Y'), date('m'))); Gio_Core_File::createDirs($dir, $path); /** * Upload file */ $ext = explode('.', $_FILES['Filedata']['name']); $extension = $ext[count($ext) - 1]; unset($ext[count($ext) - 1]); $fileName = date('YmdHis_') . implode('', $ext); $file = $dir . DS . $path . DS . $fileName . '.' . $extension; move_uploaded_file($_FILES['Filedata']['tmp_name'], $file); /** * Water mark * @since 2.0.4 */ $watermark = $request->getParam('watermark'); $overlayText = $color = $overlayImage = $position = $sizesApplied = null; if ((bool) $watermark) { $overlayText = $request->getParam('text'); $color = $request->getParam('color'); $overlayImage = $request->getParam('image'); $position = $request->getParam('position'); $sizesApplied = $request->getParam('sizes'); $sizesApplied = explode(',', $sizesApplied); } /** * Generate thumbnails if requested */ if (!isset($thumbnailSizes) || $thumbnailSizes == null) { $thumbnailSizes = array_keys($sizes); } else { if ($thumbnailSizes != 'none') { $thumbnailSizes = explode(',', $thumbnailSizes); } } $service = null; switch (strtolower($tool)) { case 'imagemagick': $service = new Gio_Image_ImageMagick(); break; case 'gd': $service = new Gio_Image_GD(); break; } $ret = array(); /** * Remove script filename from base URL */ $baseUrl = $request->getBaseUrl(); $prefixUrl = rtrim($baseUrl, '/') . '/upload/' . $module . '/' . $userName . '/' . date('Y') . '/' . date('m'); $ret['original'] = array('url' => $prefixUrl . '/' . $fileName . '.' . $extension, 'size' => null); if ($thumbnailSizes != 'none') { $service->setFile($file); $ret['original']['size'] = $service->getWidth() . ' x ' . $service->getHeight(); foreach ($thumbnailSizes as $s) { $service->setFile($file); $method = $sizes[$s]['method']; $width = $sizes[$s]['width']; $height = $sizes[$s]['height']; $f = $fileName . '_' . $s . '.' . $extension; $newFile = $dir . DS . $path . DS . $f; /** * Create thumbnail */ switch ($method) { case 'resize': $service->resizeLimit($newFile, $width, $height); break; case 'crop': $service->crop($newFile, $width, $height); break; } /** * Create watermark if requested */ if ((bool) $watermark) { $service->setWatermarkFont(ROOT_DIR . DS . 'data' . DS . 'upload' . DS . self::WATERMARK_FONT); $service->setFile($newFile); if ($overlayText && in_array($s, $sizesApplied)) { $service->watermarkText($overlayText, $position, array('color' => $color, 'rotation' => 0, 'opacity' => 50, 'size' => null)); } if ($overlayImage && in_array($s, $sizesApplied)) { $overlay = explode('/', $overlayImage); $n = count($overlay); $overlay = implode(DS, array($dir, 'multimedia', $overlay[$n - 4], $overlay[$n - 3], $overlay[$n - 2], $overlay[$n - 1])); $service->watermarkImage($overlay, $position); } } $ret[$s] = array('url' => $prefixUrl . '/' . $f, 'size' => $width . ' x ' . $height); } } /** * Return the reponse */ $json = new Services_JSON(); $this->getResponse()->setBody($json->encodeUnsafe($ret)); }
/** * List mail templates * * @return void */ public function listAction() { $request = $this->getRequest(); $pageIndex = $request->getParam('pageIndex', 1); $perPage = 20; $offset = ($pageIndex - 1) * $perPage; $user = Gio_Core_Session::getUser(); $templates = Modules_Mail_Services_Template::getTemplates($user, $offset, $perPage); $numTemplates = Modules_Mail_Services_Template::count($user); $this->view->templates = $templates; $this->view->numTemplates = $numTemplates; // Pager require_once LIB_DIR . DS . 'PEAR' . DS . 'Pager' . DS . 'Sliding.php'; $pagerPath = $this->view->url('mail_template_list'); $pagerOptions = array('mode' => 'Sliding', 'append' => false, 'perPage' => $perPage, 'delta' => 5, 'urlVar' => 'page', 'path' => $pagerPath, 'fileName' => 'pag-/%d', 'separator' => '', 'nextImg' => '<small class="icon arrow_right"></small>', 'prevImg' => '<small class="icon arrow_left"></small>', 'altNext' => '', 'altPrev' => '', 'altPage' => '', 'totalItems' => $numTemplates, 'currentPage' => $pageIndex, 'urlSeparator' => '/', 'spacesBeforeSeparator' => 0, 'spacesAfterSeparator' => 0, 'curPageSpanPre' => '<a href="javascript: void();" class="current">', 'curPageSpanPost' => '</a>'); $pager = new Pager_Sliding($pagerOptions); $this->view->pager = $pager; }
public function editAction() { $request = $this->getRequest(); $this->view->lang = $request->getParam('lang'); $menuId = $request->getParam('menu_id'); $menu = Modules_Menu_Services_Menu::getById($menuId); if (null == $menu) { Modules_Core_Services_Exception::error('DATA_NOT_FOUND'); } $menuData = $menu; /** * Get menu items */ $items = Modules_Menu_Services_Item::getTree($menuId); $menuData['items'] = $items; $this->view->menuData = $menuData; /** * Get source item */ $sourceMenu = Modules_Menu_Services_Menu::getSource($menu); $this->view->sourceMenu = $sourceMenu; if ($request->isPost()) { $user = Gio_Core_Session::getUser(); $menuData = $request->getPost('menu'); $json = new Services_JSON(); $items = $menuData['items'] ? (array) $json->decode($menuData['items']) : array(); $menuData = Modules_Menu_Services_Menu::validate($menuData); if (isset($menuData['messages_error']) && $menuData['messages_error']) { $this->view->errorMessages = $menuData['messages']; $menuData['items'] = $items; $this->view->menuData = $menuData; return; } $menu = array('menu_id' => $menuId, 'name' => $this->view->STRING->escape($menuData['name']), 'description' => $this->view->STRING->escape($menuData['description']), 'language' => $this->view->STRING->escape($menuData['language'])); $sourceItem = isset($menuData['source_item']) ? $menuData['source_item'] : null; $id = Modules_Menu_Services_Menu::update($menu, $items, $sourceItem); Gio_Core_Messenger::getInstance()->addMessage($this->view->TRANSLATOR->translator('menu_edit_success')); $this->redirect($this->view->url('menu_menu_edit', $menu)); } }
/** * Add new page * * @return void */ public function addAction() { $request = $this->getRequest(); $sourceId = $request->getParam('source_id'); $sourcePage = null == $sourceId ? null : Modules_Page_Services_Page::getById($sourceId); $configs = Gio_Core_Config_Xml::getConfig('web'); $this->view->frontendTemplate = $configs->template; $this->view->frontendSkin = $configs->skin; $this->view->sourcePage = $sourcePage; $this->view->lang = $request->getParam('lang'); if ($request->isPost()) { $user = Gio_Core_Session::getUser(); $pageData = $request->getPost('page'); $pageData = Modules_Page_Services_Page::validate($pageData); if (isset($pageData['messages_error']) && $pageData['messages_error']) { $this->view->errorMessages = $pageData['messages']; $this->view->pageData = $pageData; return; } /** * Check page slug exist */ if (Modules_Page_Services_Page::getBySlug($pageData['slug'])) { $pageData['messages']['slug'] = 'page_slug_exist'; $this->view->errorMessages = $pageData['messages']; $this->view->pageData = $pageData; return; } $page = array('name' => $this->view->STRING->escape($pageData['name']), 'slug' => $this->view->STRING->escape($pageData['slug']), 'description' => $pageData['description'], 'content' => $pageData['content'], 'parent_id' => $pageData['parent_id'], 'num_views' => 0, 'created_date' => date('Y-m-d H:i:s'), 'modified_date' => date('Y-m-d H:i:s'), 'user_id' => $user['user_id'], 'language' => $pageData['language'], 'status' => $pageData['status']); $sourceItem = isset($pageData['source_item']) ? $pageData['source_item'] : null; Modules_Page_Services_Page::add($page, $sourceItem); Gio_Core_Messenger::getInstance()->addMessage($this->view->TRANSLATOR->translator('page_actions_add_success')); $this->redirect($this->view->url('page_page_add')); } }
private function _getSession() { if (null == $this->_session) { $this->_session = Gio_Core_Session::getSessionById(); } return $this->_session; }
/** * List news articles */ public function listAction() { $request = $this->getRequest(); $lang = $request->getParam('lang'); $this->view->lang = $lang; $paramLang = $lang ? '/' . $lang : null; $perPage = 20; $pageIndex = (int) $request->getParam('page_index'); if (null == $pageIndex || '' == $pageIndex || $pageIndex < 0) { $pageIndex = 1; } $start = ($pageIndex - 1) * $perPage; $this->view->pageIndex = $pageIndex; $this->view->articleDao = new Modules_News_Models_Mysql_Article(); $user = Gio_Core_Session::getUser(); $condition = array('status' => 'active', 'created_date_from' => date('Y-m-d 00:00:00'), 'created_date_to' => date('Y-m-d H:i:s'), 'search_form' => false, 'user_id' => $user['user_id'], 'search_my_articles' => true); $json = new Services_JSON(); if ($request->isPost()) { $condition = $request->getPost('condition'); $createdDateFrom = $request->getPost('created_date_from'); $fromHour = isset($createdDateFrom['hour']) && $createdDateFrom['hour'] ? $createdDateFrom['hour'] : date('H'); $fromMinute = isset($createdDateFrom['minute']) && $createdDateFrom['minute'] ? $createdDateFrom['minute'] : date('i'); $fromSecond = isset($createdDateFrom['second']) && $createdDateFrom['second'] ? $createdDateFrom['second'] : date('s'); $fromDay = isset($createdDateFrom['day']) && $createdDateFrom['day'] ? $createdDateFrom['day'] : date('d'); $fromMonth = isset($createdDateFrom['month']) && $createdDateFrom['month'] ? $createdDateFrom['month'] : date('m'); $fromYear = isset($createdDateFrom['year']) && $createdDateFrom['year'] ? $createdDateFrom['year'] : date('Y'); $condition['created_date_from'] = date('Y-m-d H:i:s', strtotime("{$fromYear}-{$fromMonth}-{$fromDay} {$fromHour}:{$fromMinute}:{$fromSecond}")); $createdDateTo = $request->getPost('created_date_to'); $toHour = isset($createdDateTo['hour']) && $createdDateTo['hour'] ? $createdDateTo['hour'] : date('H'); $toMinute = isset($createdDateTo['minute']) && $createdDateTo['minute'] ? $createdDateTo['minute'] : date('i'); $toSecond = isset($createdDateTo['second']) && $createdDateTo['second'] ? $createdDateTo['second'] : date('s'); $toDay = isset($createdDateTo['day']) && $createdDateTo['day'] ? $createdDateTo['day'] : date('d'); $toMonth = isset($createdDateTo['month']) && $createdDateTo['month'] ? $createdDateTo['month'] : date('m'); $toYear = isset($createdDateTo['year']) && $createdDateTo['year'] ? $createdDateTo['year'] : date('Y'); $condition['created_date_to'] = date('Y-m-d H:i:s', strtotime("{$toYear}-{$toMonth}-{$toDay} {$toHour}:{$toMinute}:{$toSecond}")); $condition['search_form'] = true; /** * Search in my articles */ $searchMyArticles = isset($condition['search_my_articles']) && $condition['search_my_articles'] == 1 ? true : false; $condition['user_id'] = $searchMyArticles ? $user['user_id'] : null; $params = rawurlencode(base64_encode($json->encodeUnsafe($condition))); } else { $params = $request->getParam('q'); $params != null ? $condition = (array) $json->decode(rawurldecode(base64_decode($params))) : ($params = rawurlencode(base64_encode($json->encodeUnsafe($condition)))); } $params = empty($condition) ? null : $params; $this->view->condition = $condition; $articles = Modules_News_Services_Article::find($start, $perPage, $condition); $numArticles = Modules_News_Services_Article::count($condition); $this->view->articles = $articles; // Pager require_once LIB_DIR . DS . 'PEAR' . DS . 'Pager' . DS . 'Sliding.php'; $pagerPath = $this->view->url('news_article_list'); $pagerOptions = array('mode' => 'Sliding', 'append' => false, 'perPage' => $perPage, 'delta' => 3, 'urlVar' => 'page', 'path' => $pagerPath, 'fileName' => null == $params ? 'page-%d' . $paramLang : 'page-%d' . $paramLang . '/?q=' . $params, 'separator' => '', 'nextImg' => '<small class="icon arrow_right"></small>', 'prevImg' => '<small class="icon arrow_left"></small>', 'altNext' => '', 'altPrev' => '', 'altPage' => '', 'totalItems' => $numArticles, 'currentPage' => $pageIndex, 'urlSeparator' => '/', 'spacesBeforeSeparator' => 0, 'spacesAfterSeparator' => 0, 'curPageSpanPre' => '<a href="javascript: void();" class="current">', 'curPageSpanPost' => '</a>'); $pager = new Pager_Sliding($pagerOptions); $this->view->pager = $pager; }
/** * Set captcha word * * @param string $word * @return Zend_Captcha_Word */ protected function _setWord($word) { $session = Gio_Core_Session::getUser(); $session['word'] = $word; $this->_word = $word; return $this; }