예제 #1
0
파일: Mailer.php 프로젝트: piratevn/cms-gio
 /**
  * Get mail transport
  * 
  * @return Zend_Mail_Transport
  */
 public static function getMailTransport()
 {
     if (self::$_transport == null) {
         require_once LIB_DIR . DS . 'phpmailer' . DS . 'class.phpmailer.php';
         require_once LIB_DIR . DS . 'phpmailer' . DS . 'class.smtp.php';
         $config = Gio_Core_Module::getConfig('mail', true);
         self::$_transport = new PHPMailer();
         self::$_transport->CharSet = 'utf-8';
         switch ($config['protocol']['protocol']) {
             case 'mail':
                 self::$_transport->Mailer = 'mail';
                 break;
             case 'smtp':
                 self::$_transport->Mailer = 'smtp';
                 $options = array();
                 /**
                  * Check host setting
                  */
                 if (isset($config['smtp']['host'])) {
                     $options['host'] = $config['smtp']['host'];
                 }
                 /**
                  * Check port setting
                  */
                 if (isset($config['smtp']['port'])) {
                     $options['port'] = $config['smtp']['port'];
                 }
                 /**
                  * Check authentication settings
                  */
                 if (isset($config['smtp']['username']) && isset($config['smtp']['password'])) {
                     $options['auth'] = 'login';
                     $options['username'] = $config['smtp']['username'];
                     $options['password'] = $config['smtp']['password'];
                 }
                 /**
                  * Check security setting
                  */
                 if (isset($config['smtp']['security'])) {
                     $options['ssl'] = $config['smtp']['security'];
                 }
                 self::$_transport->Host = $options['host'];
                 // specify main and backup server
                 self::$_transport->Port = $options['port'];
                 // set the port to use
                 self::$_transport->SMTPAuth = true;
                 // turn on SMTP authentication
                 self::$_transport->SMTPSecure = $options['ssl'];
                 self::$_transport->Username = $options['username'];
                 // your SMTP username or your gmail username
                 self::$_transport->Password = $options['password'];
                 // your SMTP password or your gmail password
                 break;
         }
     }
     return self::$_transport;
 }
예제 #2
0
파일: Module.php 프로젝트: piratevn/cms-gio
 public function listAction()
 {
     $modulesDir = MOD_DIR;
     if (!file_exists($modulesDir)) {
         return;
     }
     $modules = Gio_Core_Module::getAllModules(array('core'));
     $this->view->modules = $modules;
 }
예제 #3
0
파일: Widget.php 프로젝트: piratevn/cms-gio
 public function showAction()
 {
     $request = $this->getRequest();
     $this->view->lang = $request->getParam('lang');
     $modules = Modules_Core_Services_Module::getModulesInstalled();
     foreach ($modules as $index => $module) {
         $modules[$index]['resource'] = Gio_Core_Module::getAboutModule($module['module_id'], 'resource');
     }
     $this->view->wModules = $modules;
     $coreResources = Gio_Core_Module::getAboutModule('core');
     $this->view->coreResources = $coreResources;
     $widgetsToolbox = Modules_Core_Services_Widget::dbWidgetsToolbox();
     $this->view->widgetsToolbox = $widgetsToolbox;
 }
예제 #4
0
파일: Route.php 프로젝트: piratevn/cms-gio
 public function __construct()
 {
     $routesFile = array();
     $modules = Gio_Core_Module::getAllModules();
     if (empty($modules)) {
         return;
     }
     foreach ($modules as $index => $module) {
         $routesDir = ROOT_DIR . DS . 'modules' . DS . $module . DS . 'configs' . DS . 'routes';
         if (!file_exists($routesDir)) {
             continue;
         }
         $routesIterator = new DirectoryIterator($routesDir);
         foreach ($routesIterator as $route) {
             if ($route->isDot()) {
                 continue;
             }
             $routeName = $route->getFilename();
             if ('CVS' == $routeName || '.svn' == strtolower($routeName) || 'index.html' == $routeName || '.htaccess' == $routeName) {
                 continue;
             }
             $routesFile[] = $routesDir . DS . $routeName;
         }
     }
     if (!empty($routesFile)) {
         foreach ($routesFile as $index1 => $routeFile) {
             $routesIni = @parse_ini_file($routeFile, true);
             foreach ($routesIni as $index2 => $routeItem) {
                 $route = array();
                 $route['name'] = (string) $index2;
                 $route['frontend'] = isset($routeItem['frontend']) && (string) $routeItem['frontend'] == 'true' ? true : false;
                 $route['url'] = (string) $routeItem['url'];
                 $route['type'] = (string) $routeItem['type'];
                 $route['reverse'] = isset($routeItem['reverse']) ? (string) $routeItem['reverse'] : null;
                 $route['reverse_no_rewrite'] = isset($routeItem['reverse_no_rewrite']) ? (string) $routeItem['reverse_no_rewrite'] : null;
                 $route['module'] = (string) $routeItem['module'];
                 $route['controller'] = (string) $routeItem['controller'];
                 $route['action'] = (string) $routeItem['action'];
                 $route['params'] = isset($routeItem['params']) ? $routeItem['params'] : null;
                 $route['langKey'] = isset($routeItem['langKey']) ? $routeItem['langKey'] : null;
                 $route['csrf'] = isset($routeItem['csrf']) ? (array) $routeItem['csrf'] : null;
                 $route['localization']['enable'] = isset($routeItem['localization']['enable']) && (string) $routeItem['localization']['enable'] == 'true' ? 'true' : 'false';
                 $route['localization']['identifier'] = isset($routeItem['localization']['identifier']) ? (array) $routeItem['localization']['identifier'] : null;
                 $this->_routes[$route['name']] = $route;
             }
         }
     }
     return $this;
 }
예제 #5
0
파일: Page.php 프로젝트: piratevn/cms-gio
 public static function factory()
 {
     $request = Gio_Core_Request::getInstance();
     $config = Gio_Core_Module::getConfig('page');
     $param = isset($config['url']['param']) ? $config['url']['param'] : 'page_id';
     $category = null;
     switch ($param) {
         case 'slug':
             $page = Modules_Page_Services_Page::getBySlug($request->getParam($param));
             break;
     }
     if (null == $page) {
         $page = Modules_Page_Services_Page::getById($request->getParam('page_id'));
     }
     return $page;
 }
예제 #6
0
 public static function factory()
 {
     $request = Gio_Core_Request::getInstance();
     $config = Gio_Core_Module::getConfig('category');
     $param = isset($config['url']['param']) ? $config['url']['param'] : 'category_id';
     $category = null;
     switch ($param) {
         case 'category_path':
             $category = Modules_Category_Services_Category::getByPath($request->getParam($param));
             break;
     }
     if (null == $category) {
         $category = Modules_Category_Services_Category::getById($request->getParam('category_id'));
     }
     return $category;
 }
예제 #7
0
 public function run()
 {
     $request = Gio_Core_Request::getInstance();
     $configs = Gio_Core_Config_Xml::getConfig('web');
     /**
      * Do nothing if we are in page of managing permalink
      */
     $uri = $request->getRequestUri();
     $uri = strtolower($uri);
     $uri = rtrim($uri, '/') . '/';
     $adminPrefix = $configs->admin->url_prefix;
     $adminPrefix = rtrim(ltrim($adminPrefix, '/'), '/');
     if (is_int(strpos($uri, '/' . $adminPrefix . '/core/permalink'))) {
         return;
     }
     $defaultFile = ROOT_DIR . DS . 'configs' . DS . 'permalink.xml';
     $host = $request->getServerName();
     $host = substr($host, 0, 3) == 'www' ? substr($host, 4) : $host;
     $file = ROOT_DIR . DS . 'configs' . DS . $host . '.' . 'permalink.xml';
     $file = file_exists($file) ? $file : $defaultFile;
     if (!file_exists($file)) {
         return;
     }
     $route = Gio_Core_Route::getInstance();
     $config = @simplexml_load_file($file);
     if (!isset($config->item) || empty($config->item)) {
         return;
     }
     $categoryConfig = Gio_Core_Module::getConfig('category');
     $param = isset($categoryConfig['url']['param']) ? $categoryConfig['url']['param'] : 'category_id';
     foreach ($config->item as $index => $item) {
         $item = (array) $item;
         if (!in_array($item['name'], $this->_inArray)) {
             $route->setRoute($item['name'], $item);
         } elseif ($param == 'category_path' && in_array($item['name'], $this->_inArray)) {
             $route->setRoute($item['name'], $item);
         }
     }
 }
예제 #8
0
파일: Mail.php 프로젝트: piratevn/cms-gio
 /**
  * Get mail server configurations
  * 
  * @return array
  */
 public static function getConfig()
 {
     return Gio_Core_Module::getConfig('mail', true);
 }
예제 #9
0
파일: User.php 프로젝트: piratevn/cms-gio
 public function registerAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $userData = $request->getPost('user');
         $userData = Modules_Core_Services_User::validate($userData);
         /**
          * Check user exist 
          */
         if ($userData['username'] && Modules_Core_Services_User::getByUsername($userData['username'])) {
             $userData['messages_error'] = true;
             $userData['messages']['username'] = '******';
         }
         /**
          * Check user exist 
          */
         if ($userData['email'] && Modules_Core_Services_User::getByEmail($userData['email'])) {
             $userData['messages_error'] = true;
             $userData['messages']['email'] = 'user_email_exist';
         }
         if (isset($userData['messages_error']) && $userData['messages_error']) {
             $this->view->errorMessages = $userData['messages'];
             $this->view->userData = $userData;
             return;
         }
         $config = Gio_Core_Module::getConfig('core', true);
         if (!isset($config['user']['default_role_id']) || null == ($role = Modules_Core_Services_Role::getById($config['user']['default_role_id']))) {
             return;
         }
         $salt = md5(time());
         $user = array('username' => $userData['username'], 'password' => md5(md5($userData['password']) . $salt), 'email' => $this->view->STRING->escape($userData['email']), 'fullname' => $this->view->STRING->escape($userData['fullname']), 'salt' => $salt, 'status' => 'active', 'created_date' => date('Y-m-d H:i:s'), 'role_id' => $role['role_id']);
         $userId = Modules_Core_Services_User::add($user);
         /**
          * Send welcome mail
          */
         Modules_Core_Services_User::registerSuccess($user['username'], $user['email']);
         Gio_Core_Messenger::getInstance()->addMessage($this->view->TRANSLATOR->translator('user_register_success'));
         $this->redirect($this->view->url('core_user_register'));
     }
 }