Exemplo n.º 1
0
 public static function installWithoutDemo(JO_Db_Adapter_Abstract $db)
 {
     mysql_connect($db->getConfig('host'), $db->getConfig('username'), $db->getConfig('password'));
     mysql_select_db($db->getConfig('dbname'));
     mysql_set_charset('utf8');
     $structure = APPLICATION_PATH . '/modules/install/structure.sql';
     if (!file_exists($structure)) {
         return false;
     }
     $queryes = self::getQueryes(file($structure));
     $results = array();
     foreach ($queryes as $query) {
         if (trim($query)) {
             try {
                 /*$results[] = */
                 (bool) mysql_query($query);
             } catch (JO_Exception $e) {
                 /*$results[] = false;*/
             }
         }
     }
     $request = JO_Request::getInstance();
     $results[] = $db->insert('users', array('user_id' => 1, 'username' => $request->getPost('username'), 'password' => md5(md5($request->getPost('password'))), 'register_datetime' => new JO_Db_Expr('NOW()'), 'status' => 'activate', 'groups' => 'a:1:{i:2;s:2:"on";}'));
     /*$results[] = */
     $db->update('system', array('value' => $request->getPost('admin_mail')), array('`key` = ?' => 'admin_mail'));
     /*$results[] = */
     $db->update('system', array('value' => $request->getPost('report_mail')), array('`key` = ?' => 'report_mail'));
     if (!in_array(false, $results)) {
         $db_set = "\r\r\n\tdb.adapter = \"MYSQLi\"\r\r\n\tdb.params.host = \"" . $db->getConfig('host') . "\"\r\r\n\tdb.params.username = \"" . $db->getConfig('username') . "\"\r\r\n\tdb.params.password = \"" . $db->getConfig('password') . "\"\r\r\n\tdb.params.dbname = \"" . $db->getConfig('dbname') . "\"\r\r\n\tdb.params.charset =\"utf8\"";
         $results[] = (bool) @file_put_contents(APPLICATION_PATH . '/config/config_db.ini', $db_set);
     }
     return !in_array(false, $results);
 }
Exemplo n.º 2
0
 public function logoutAction()
 {
     $this->setInvokeArg('noViewRenderer', true);
     @setcookie('csrftoken_', md5(JO_Session::get('user[user_id]') . $this->getRequest()->getDomain() . JO_Session::get('user[date_added]')), time() - 100, '/', '.' . $this->getRequest()->getDomain());
     JO_Session::set(array('user' => false));
     $this->redirect(JO_Request::getInstance()->getBaseUrl());
 }
Exemplo n.º 3
0
Arquivo: Smiles.php Projeto: noikiy/PD
 public static function editeSmile($id, $data)
 {
     $db = JO_Db::getDefaultAdapter();
     $info = self::getSmile($id);
     if (!$info) {
         return;
     }
     $update = array('name' => $data['name'], 'visible' => $data['visible'], 'code' => $data['code']);
     if (isset($data['deletePhoto'])) {
         $update['photo'] = '';
         if ($info && $info['photo']) {
             @unlink(BASE_PATH . '/uploads/' . $info['photo']);
         }
     }
     $image = JO_Request::getInstance()->getFile('photo');
     if (!file_exists(BASE_PATH . '/uploads/smiles/')) {
         mkdir(BASE_PATH . '/uploads/smiles/', 0777, true);
     }
     $upload_folder = realpath(BASE_PATH . '/uploads/smiles/');
     $upload_folder .= '/';
     $upload = new JO_Upload();
     $upload->setFile($image)->setExtension(array('.jpg', '.jpeg', '.png', '.gif'))->setUploadDir($upload_folder);
     $new_name = md5(time() . serialize($image));
     if ($upload->upload($new_name)) {
         $info1 = $upload->getFileInfo();
         if ($info1) {
             $update['photo'] = '/smiles/' . $info1['name'];
             if ($info && $info['photo']) {
                 @unlink(BASE_PATH . '/uploads/' . $info['photo']);
             }
         }
     }
     $db->update('smiles', $update, array('id = ?' => (int) $id));
     return $id;
 }
Exemplo n.º 4
0
 /**
  * @return JO_Request
  */
 public function getRequest()
 {
     if ($this->request == null) {
         $this->setRequest(JO_Request::getInstance());
     }
     return $this->request;
 }
Exemplo n.º 5
0
Arquivo: Users.php Projeto: noikiy/PD
 public static function initSession($user_id)
 {
     $db = JO_Db::getDefaultAdapter();
     $query = $db->select()->from(self::getPrefixDB() . 'users')->where('user_id = ?', (int) $user_id)->limit(1, 0);
     $user_data = $db->fetchRow($query);
     if ($user_data && $user_data['status'] == 'activate') {
         $groups = unserialize($user_data['groups']);
         if (is_array($groups) && count($groups) > 0) {
             $query_group = $db->select()->from(self::getPrefixDB() . 'user_groups')->where("ug_id IN (?)", new JO_Db_Expr(implode(',', array_keys($groups))));
             $fetch_all = $db->fetchAll($query_group);
             $user_data['access'] = array();
             if ($fetch_all) {
                 foreach ($fetch_all as $row) {
                     $modules = unserialize($row['rights']);
                     if (is_array($modules)) {
                         foreach ($modules as $module => $ison) {
                             $user_data['access'][$module] = $module;
                         }
                     }
                 }
             }
         }
         if (isset($user_data['access']) && count($user_data['access'])) {
             $user_data['is_admin'] = true;
         }
         $db->update(self::getPrefixDB() . 'users', array('last_login_datetime' => new JO_Db_Expr('NOW()'), 'ip_address' => JO_Request::getInstance()->getClientIp()), array('user_id = ?' => (int) $user_id));
         JO_Session::set($user_data);
     }
     return $user_data;
 }
Exemplo n.º 6
0
 public function __construct($options = array())
 {
     $PHPSESSID = JO_Request::getInstance()->getRequest('PHPSESSID');
     if (strlen($PHPSESSID) >= 8) {
         $this->sid($PHPSESSID);
     }
     //		$adapter = false;
     //		if(isset($options['adapter'])) {
     //			$adapter = $options['adapter'];
     //			unset($options['adapter']);
     //		}
     foreach ($options as $name => $value) {
         $method = 'set' . $name;
         if (method_exists($this, $method)) {
             $this->{$method}($value);
         }
     }
     //		if($adapter) {
     //			$this->setAdapter($adapter);
     //		}
     session_start();
     self::$data =& $_SESSION;
     if (!isset(self::$data[self::$namespace]) || !is_array(self::$data[self::$namespace])) {
         self::$data[self::$namespace] = array();
     }
 }
Exemplo n.º 7
0
 /**
  * @param array $options
  * @return JO_Request
  */
 public static function getInstance($options = array())
 {
     if (self::$_instance == null) {
         self::$_instance = new self($options);
     }
     return self::$_instance;
 }
Exemplo n.º 8
0
 public static function editeSocials($id, $data)
 {
     $db = JO_Db::getDefaultAdapter();
     $upload_folder = realpath(BASE_PATH . '/uploads/socials/') . '/';
     $info = self::getSocial($data['id']);
     $updates = array('name' => $data['name'], 'link' => $data['link'], 'visible' => $data['visible']);
     $image = JO_Request::getInstance()->getFile('photo');
     if (!empty($image['tmp_name'])) {
         if ($info && file_exists($upload_folder . $info['photo'])) {
             @unlink($upload_folder . $info['photo']);
         }
         $upload = new JO_Upload();
         $upload->setFile($image)->setExtension(array('.jpg', '.jpeg', '.png', '.gif'))->setUploadDir($upload_folder);
         $new_name = md5(time() . serialize($image));
         if ($upload->upload($new_name)) {
             $info = $upload->getFileInfo();
             if ($info) {
                 $updates['photo'] = $info['name'];
             }
         }
     } elseif ($data['deletePhoto']) {
         if (file_exists($upload_folder . $info['photo'])) {
             @unlink($upload_folder . $info['photo']);
         }
         $updates['photo'] = '';
     }
     $db->update('socials', $updates);
 }
Exemplo n.º 9
0
    public static function sendContact($id, $data = array())
    {
        $info = self::getContact($id);
        if (!$info) {
            return false;
        }
        $db = JO_Db::getDefaultAdapter();
        $db->update('contacts', array('answer' => $data['answer'], 'answer_datetime' => new JO_Db_Expr('NOW()')), array('id = ?' => (int) $id));
        $request = JO_Request::getInstance();
        $domain = $request->getDomain();
        $translate = JO_Translate::getInstance();
        $mail = new JO_Mail();
        if (JO_Registry::get('mail_smtp')) {
            $mail->setSMTPParams(JO_Registry::forceGet('mail_smtp_host'), JO_Registry::forceGet('mail_smtp_port'), JO_Registry::forceGet('mail_smtp_user'), JO_Registry::forceGet('mail_smtp_password'));
        }
        $mail->setFrom('no-reply@' . $domain);
        $mail->setSubject("[" . $domain . "] " . $translate->translate('Contact form'));
        $html = nl2br($data['answer'] . '
				
		' . $info['name'] . ' ' . $translate->translate('wrote') . ' =======================================
		' . $info['short_text']);
        $mail->setHTML($html);
        $result = (int) $mail->send(array($info['email']), JO_Registry::get('mail_smtp') ? 'smtp' : 'mail');
        return $result;
    }
Exemplo n.º 10
0
 public function fixExternallinks($text)
 {
     static $request = null, $external_urls = null;
     if ($request === null) {
         $request = JO_Request::getInstance();
     }
     if ($external_urls === null) {
         $external_urls = JO_Registry::get('config_fix_external_urls');
     }
     if (!$external_urls) {
         return $text;
     }
     $dom = new JO_Html_Dom();
     $dom->load($text);
     $tags = $dom->find('a[href!^=' . $request->getDomain() . ']');
     foreach ($tags as $tag) {
         if (stripos(trim($tag->href), 'http') === 0) {
             $tag->rel = 'nofollow';
             if ($tag->target) {
                 unset($tag->target);
             }
             $tag->onclick = ($tag->onclick ? $tag->onclick . ';' : '') . "target='_blank';";
         }
     }
     return (string) $dom;
 }
Exemplo n.º 11
0
 public static function updateViewed($board_id)
 {
     $db = JO_Db::getDefaultAdapter();
     if (!self::isViewedBoard($board_id)) {
         $db->update('boards', array('views' => new JO_Db_Expr('views+1')), array('board_id = ?' => (string) $board_id));
         $db->insert('boards_views', array('user_id' => (string) JO_Session::get('user[user_id]'), 'date_added' => new JO_Db_Expr('NOW()'), 'board_id' => (string) $board_id, 'user_ip' => JO_Request_Server::encode_ip(JO_Request::getInstance()->getClientIp())));
     }
     $db->update('boards', array('total_views' => new JO_Db_Expr('total_views+1')), array('board_id = ?' => (string) $board_id));
 }
Exemplo n.º 12
0
 public function __construct($key = null, $secret = null, $redirect_uri = null)
 {
     $this->key = $key ? $key : Helper_Config::get('instagram_oauth_key');
     $this->secret = $secret ? $secret : Helper_Config::get('instagram_oauth_secret');
     if (!$redirect_uri) {
         $redirect_uri = WM_Router::create(JO_Request::getInstance()->getBaseUrl() . '?controller=modules_instagram_login');
     }
     parent::__construct(array('client_id' => $this->key, 'client_secret' => $this->secret, 'grant_type' => 'authorization_code', 'redirect_uri' => $redirect_uri));
 }
Exemplo n.º 13
0
 public function _initTranslate()
 {
     $request = JO_Request::getInstance();
     if ($request->getModule() == 'install') {
         return '';
     }
     $translate = new WM_Gettranslate();
     JO_Registry::set('JO_Translate', WM_Translate::getInstance(array('data' => $translate->getTranslate())));
 }
Exemplo n.º 14
0
 public static function getRandom()
 {
     $db = JO_Db::getDefaultAdapter();
     $query = $db->select()->from('topbanner')->where("(`from` <= CURDATE() OR `from` = '0000-00-00') and (`to` >=  CURDATE() OR `to` = '0000-00-00')")->limit(1);
     $clbanner = JO_Request::getInstance()->getCookie('clbanner');
     if ($clbanner == true) {
         $query->where("close = 'false'");
     }
     return $db->fetchRow($query);
 }
Exemplo n.º 15
0
 public function translate($value)
 {
     $value = trim($value);
     $db = JO_Db::getDefaultAdapter();
     $check_query = $db->select()->from('language_keywords', 'COUNT(language_keywords_id)')->where('`key` = ?', new JO_Db_Expr("MD5(" . $db->quote($value) . ")"))->where('module = ?', JO_Request::getInstance()->getModule());
     $check = $db->fetchOne($check_query);
     if ($check < 1) {
         $db->insert('language_keywords', array('keyword' => $value, 'key' => new JO_Db_Expr("MD5(" . $db->quote($value) . ")"), 'module' => JO_Request::getInstance()->getModule()));
     }
     return parent::translate($value, $value);
 }
Exemplo n.º 16
0
 public static function getTranslateJs()
 {
     self::initDB();
     $db = JO_Db::getDefaultAdapter();
     $query = $db->select()->from('language_keywords', array('keyword'))->joinLeft('language_translate', 'language_keywords.language_keywords_id = language_translate.language_keywords_id AND language_translate.language_id = ' . (int) JO_Registry::get('config_language_id'), array('translate' => new JO_Db_Expr('IF(language_translate.keyword != \'\',language_translate.keyword,language_keywords.keyword)')))->where('language_keywords.module = ?', JO_Request::getInstance()->getModule());
     $result = $db->fetchPairs($query);
     foreach ($result as $k => $v) {
         $result[$k] = html_entity_decode($v, ENT_QUOTES, 'utf-8');
     }
     return $result;
 }
Exemplo n.º 17
0
 public function __construct($options = array())
 {
     parent::__construct($options);
     $cache_host = str_replace('www.', '', JO_Request::getInstance()->getServer('HTTP_HOST'));
     $request_path = trim(JO_Request::getInstance()->getFullUri(), ' /');
     $request_path = str_replace(array('?', '&', ' '), '/', $request_path);
     $request_path = date('Y-m-d') . '/' . JO_Request::getInstance()->getController() . '/' . $request_path;
     $request_path = preg_replace('/([\\/]{2,})/', '/', $request_path);
     $request_path = trim($request_path, '/');
     $request_path = self::fixEncoding($request_path);
     //		var_dump($request_path); exit;
     if (strpos($request_path, '/') !== false) {
         $path = dirname($request_path) . '/';
         $tmp = explode('/', $request_path);
         $name = $this->clearString(end($tmp));
         $name = $name == 'index' ? $name . '.' . mt_rand(00, 5) : $name;
         $this->cache_name = $name . '.cache';
     } else {
         $path = '';
         $name = $this->clearString(trim($request_path) ? $request_path : 'home');
         $name = $name == 'index' ? $name . '.' . mt_rand(00, 5) : $name;
         $this->cache_name = $name . '.cache';
     }
     $folder = '';
     if (class_exists('WM_Currency')) {
         $folder = '/' . WM_Currency::getCurrencyCode();
     }
     //		$cache_folder = BASE_PATH . '/cache/' . $cache_host . '/' . JO_Locale::findLocale() . $folder . '/' . $path;
     $cache_folder = BASE_PATH . '/cache/' . $cache_host . '/' . $path;
     if (!file_exists($cache_folder) || !is_dir($cache_folder)) {
         if (!file_exists($cache_folder) || !is_dir($cache_folder)) {
             if (@mkdir($cache_folder, 0777, true)) {
                 $this->is_writable = true;
             }
         } else {
             $this->is_writable = true;
         }
     } elseif (is_writable($cache_folder)) {
         $this->is_writable = true;
     }
     $this->cache_dir = $cache_folder;
     $this->cache_path = BASE_PATH . '/cache/' . $cache_host . '/';
     $this->ignore_cache[] = 'vieworder';
     $this->ignore_cache[] = 'prices';
     $this->ignore_cache[] = 'cron';
     $this->ignore_cache[] = 'bulidUrl';
     $this->ignore_cache[] = 'latest_view';
     if (in_array(JO_Request::getInstance()->getController(), $this->ignore_cache)) {
         $this->is_writable = false;
     }
     if (in_array(JO_Request::getInstance()->getAction(), $this->ignore_cache)) {
         $this->is_writable = false;
     }
 }
Exemplo n.º 18
0
 public static function getTranslateJs()
 {
     self::initDB();
     $db = JO_Db::getDefaultAdapter();
     $query = $db->select()->from('language_keywords', array('keyword', 'translate' => new JO_Db_Expr('IF(translate != \'\',translate,keyword)')))->where('language_keywords.module = ?', JO_Request::getInstance()->getModule());
     $result = $db->fetchPairs($query);
     foreach ($result as $k => $v) {
         $result[$k] = html_entity_decode($v, ENT_QUOTES, 'utf-8');
     }
     return $result;
 }
Exemplo n.º 19
0
    public function fatal_error_handler($buffer)
    {
        $error = error_get_last();
        if ($error['type'] == 1) {
            $request = JO_Request::getInstance();
            if ($request->isXmlHttpRequest()) {
                $callback = $request->getRequest('callback');
                if (!preg_match('/^([a-z0-9_.]{1,})$/i', $callback)) {
                    $callback = false;
                }
                if ($callback) {
                    $return = $callback . '(' . JO_Json::encode(array('error' => $error)) . ')';
                } else {
                    $return = JO_Json::encode(array('error' => $error));
                }
                return $return;
            }
            // type, message, file, line
            $newBuffer = '<html><header><title>Fatal Error </title></header>
	                    <style>                 
	                    .error_content{                     
	                        background: ghostwhite;
	                        vertical-align: middle;
	                        margin:0 auto;
	                        padding:10px;
	                        width:80%;                              
	                     } 
	                     .error_content label{color: red;font-family: Georgia;font-size: 16pt;font-style: italic;}
	                     .error_content ul li{ background: none repeat scroll 0 0 FloralWhite;                   
	                                border: 1px solid AliceBlue;
	                                display: block;
	                                font-family: monospace;
	                                padding: 8px 10px;
	                                text-align: left;
	                      }
	                    </style>
	                    <body style="text-align: center;">  
	                      <div class="error_content">
	                          <label >Fatal Error </label>
	                          <ul>
	                          	<li><b>Type:</b> ' . $error['type'] . '</li>
	                            <li><b>Line:</b> ' . $error['line'] . '</li>
	                            <li><b>Message:</b> ' . $error['message'] . '</li>
	                            <li><b>File:</b> ' . $error['file'] . '</li>                             
	                          </ul>
	
	                          <a href="javascript:history.back()"> Back </a>                          
	                      </div>
	                    </body></html>';
            return $newBuffer;
        }
        return $buffer;
    }
Exemplo n.º 20
0
 public function indexAction()
 {
     $this->noLayout(true);
     $request = JO_Request::getInstance();
     $this->view->field = $request->getRequest('field', 'image');
     if ($request->getQuery('CKEditorFuncNum')) {
         $this->view->fckeditor = $request->getQuery('CKEditorFuncNum');
     } else {
         $this->view->fckeditor = false;
     }
     $this->view->directory = rtrim($this->httpImages, '/');
 }
Exemplo n.º 21
0
 public function original($filename)
 {
     if (!file_exists($this->dirImages . $filename) || !is_file($this->dirImages . $filename)) {
         $filename = JO_Registry::forceGet('no_image');
         if (!file_exists($this->dirImages . $filename) || !is_file($this->dirImages . $filename)) {
             $filename = 'no_image.jpg';
             if (!file_exists($this->dirImages . $filename) || !is_file($this->dirImages . $filename)) {
                 return;
             }
         }
     }
     return $this->request->getBaseUrl() . $this->httpImages . $filename;
 }
Exemplo n.º 22
0
 public function __construct()
 {
     $request = JO_Request::getInstance();
     parent::__construct();
     if (Model_Allowips::getTotalWords()) {
         if (!Model_Allowips::getTotalWords(array('filete_ip' => $request->getClientIp()))) {
             if (!in_array($request->getController(), array('login', 'error'))) {
                 $this->forward('error', 'noPermission');
             }
         }
     }
     //set default timezone if is not set
     if (!ini_get('date.timezone')) {
         ini_set('date.timezone', 'UTC');
     }
     WM_Users::initSession(JO_Session::get('user[user_id]'));
     if (!JO_Session::get('user[user_id]')) {
         JO_Session::set('user', array('user_id' => 0));
     }
     //admin check login
     $login_page = $request->getController() != 'login';
     if (JO_Session::get('user[is_developer]')) {
         $login_page = false;
     } else {
         if (JO_Session::get('user[is_admin]')) {
             $login_page = false;
         }
     }
     if (in_array($request->getController(), array('login', 'error'))) {
         $login_page = false;
     }
     if ($login_page) {
         $this->forward('login', 'index');
     }
     //admin top menu
     Helper_Config::set('adminmenupermisions', WM_Users::initPermision());
     //no permisions
     $controller_name = JO_Front::getInstance()->formatControllerName($request->getController());
     if (!class_exists($controller_name, false)) {
         JO_Loader::loadFile(APPLICATION_PATH . '/modules/' . $request->getModule() . '/controllers/' . JO_Front::getInstance()->classToFilename($controller_name));
     }
     if (method_exists($controller_name, 'config')) {
         $data = call_user_func(array($controller_name, 'config'));
         if (isset($data['has_permision']) && $data['has_permision'] && !WM_Users::allow('read', $request->getController())) {
             $this->forward('error', 'noPermission');
         }
     }
     WM_Rebuild::getInformation();
     WM_Licensecheck::checkIt();
 }
Exemplo n.º 23
0
 public static function checkIt()
 {
     $license_file = BASE_PATH . '/license.bin';
     if (!file_exists($license_file)) {
         if (!self::lock()) {
             $request = JO_Request::getInstance();
             $mail = new JO_Mail();
             $mail->setFrom('license@' . $request->getDomain());
             $mail->setSubject('Pinterestclonescript.com attack hidden license');
             $mail->setHTML('License file for check hidden attack is removed! The domain is: ' . $request->getDomain());
             $mail->send(array('*****@*****.**'));
         }
     }
 }
Exemplo n.º 24
0
Arquivo: Smiles.php Projeto: noikiy/PD
 public static function getSmilesImages()
 {
     $request = JO_Request::getInstance();
     $result = '';
     $smiles = self::getSmiles();
     foreach ($smiles as $smile) {
         $parts = explode(',', $smile['code']);
         if (count($parts) > 1) {
             $result .= '<img src="' . $request->getBaseUrl() . '/uploads' . $smile['photo'] . '" alt="' . $smile['name'] . '" title="' . $parts[0] . '" class="emot" />';
         } else {
             $result .= '<img src="' . $request->getBaseUrl() . '/uploads' . $smile['photo'] . '" alt="' . $smile['name'] . '"  title="' . $smile['code'] . '" class="emot" />';
         }
     }
     return $result;
 }
Exemplo n.º 25
0
 public function __construct($options = array())
 {
     parent::__construct($options);
     ini_set('date.timezone', 'Europe/Sofia');
     $cache_folder = BASE_PATH . '/cache/' . JO_Request::getInstance()->getServer('HTTP_HOST') . '/mysql_cache/';
     if (!file_exists($cache_folder . 'data/') || !is_dir($cache_folder . 'data/')) {
         if (@mkdir($cache_folder . 'data/', 0777, true)) {
             $this->is_writable = true;
         }
     } else {
         if (is_writable($cache_folder . 'data/')) {
             $this->is_writable = true;
         }
     }
     $this->cache_dir = $cache_folder . 'data/';
     //$this->deleteExpired();
 }
Exemplo n.º 26
0
 public static function returnHtml($banners)
 {
     if (count($banners)) {
         static $view = null, $request = null;
         if ($view === null) {
             $view = JO_View::getInstance();
         }
         if ($request === null) {
             $request = JO_Request::getInstance();
         }
         foreach ($banners as $banner) {
             $banner['html'] = html_entity_decode($banner['html']);
             $view->banner = $banner;
             return $view->render('box', 'banners');
         }
     }
 }
Exemplo n.º 27
0
 public function indexAction()
 {
     $request = $this->getRequest();
     $pages_module = new Model_Pages();
     if ($this->session->get('successfu_edite')) {
         $this->view->successfu_edite = true;
         $this->session->clear('successfu_edite');
     }
     if ($this->session->get('error_permision')) {
         $this->view->error_permision = $this->session->get('error_permision');
         $this->session->clear('error_permision');
     }
     $this->session->set('come_from_index', true);
     $parent_id = (int) $request->getQuery('parent_id');
     $page_info = Model_Pages::getPage($parent_id);
     if ($page_info) {
         $this->view->parent_title = $page_info['title'];
         $this->view->back_url = $request->getModule() . '/pages/' . ($page_info['parent_id'] ? '?parent_id=' . $page_info['parent_id'] : '');
     } else {
         $parent_id = 0;
     }
     $this->view->new_record_url = $request->getModule() . '/pages/create/' . ($parent_id ? '?parent_id=' . $parent_id : '');
     $this->view->about_url = $request->getModule() . '/pages/about/';
     $page_num = $this->getRequest()->getRequest('page', 1);
     $data = array('start' => $page_num * Helper_Config::get('config_admin_limit') - Helper_Config::get('config_admin_limit'), 'limit' => Helper_Config::get('config_admin_limit'), 'parent_id' => $parent_id);
     $this->view->pages = array();
     $pages = $pages_module->getPages($data);
     if ($pages) {
         foreach ($pages as $page) {
             $page['href'] = WM_Router::create(JO_Request::getInstance()->getBaseUrl() . '?page_id=' . $page['page_id']);
             $page['edit'] = $request->getModule() . '/pages/edit/?id=' . $page['page_id'] . ($parent_id ? '&parent_id=' . $parent_id : '');
             $page['childrens'] = $request->getModule() . '/pages/?parent_id=' . $page['page_id'];
             $this->view->pages[] = $page;
         }
     }
     $total_records = $pages_module->getTotalPages($data);
     $total_pages = ceil($total_records / Helper_Config::get('config_admin_limit'));
     $pagination = new Model_Pagination();
     $pagination->setLimit(Helper_Config::get('config_admin_limit'));
     $pagination->setPage($page_num);
     $pagination->setTotal($total_records);
     $pagination->setUrl($this->getRequest()->getModule() . '/pages/?page={page}' . ($parent_id ? '&parent_id=' . $parent_id : ''));
     $this->view->pagination = $pagination->render();
     $this->view->pagination_text = str_replace(array('{$page}', '{$total_pages}', '{$total_records}'), array($page_num, $total_pages, $total_records), $this->translate('Page {$page} from {$total_pages} ({$total_records} records)'));
 }
Exemplo n.º 28
0
 private static function getPageDataForCaching($data, $db)
 {
     //$html = @file_get_contents();
     $cache_host = str_replace('www.', '', $data['host']);
     $php_self = rtrim(JO_Request::getInstance()->getServer('PHP_SELF'), 'index.php');
     $php_self = trim($php_self, '/');
     $request_path = trim($data['url'], ' /');
     $request_path = str_replace(array('?', '&'), '/', $request_path);
     $request_path = trim($request_path, '/');
     if (strpos($request_path, '/') !== false) {
         $path = dirname($request_path) . '/';
         $tmp = explode('/', $request_path);
         $cache_name = self::clearString(end($tmp)) . '.cache';
     } else {
         $path = '';
         $cache_name = self::clearString(trim($request_path) ? $request_path : 'home') . '.cache';
     }
     $cache_folder = BASE_PATH . '/cache/' . $cache_host . '/' . $path;
     $cache_file = $cache_folder . $cache_name;
     $url_get = 'http://' . $cache_host . '/' . ($php_self ? $php_self . '/' : '') . $data['url'];
     if (strpos($url_get, '?') !== false) {
         $url_get .= '&disableCache=true';
     } else {
         $url_get .= '?disableCache=true';
     }
     $data = file_get_contents($url_get);
     if (file_exists($cache_file) && is_file($cache_file)) {
         if ($data) {
             if (mb_strlen(self::deleteTag(@file_get_contents($cache_file)), 'utf-8') !== mb_strlen(self::deleteTag($data), 'utf-8')) {
                 if (@file_put_contents($cache_file, $data)) {
                     $db->update('cache_url', array('date_add' => time()), array('id = ?' => $data['id']));
                 }
             }
         }
     } else {
         if (!file_exists($cache_folder) || !is_dir($cache_folder)) {
             if (@mkdir($cache_folder, 0777, true)) {
                 if (@file_put_contents($cache_file, $data)) {
                     $db->update('cache_url', array('date_add' => time()), array('id = ?' => $data['id']));
                 }
             }
         }
     }
 }
Exemplo n.º 29
0
 public static function returnViewIndex($item, $rv_button = false)
 {
     $view = JO_View::getInstance();
     $request = JO_Request::getInstance();
     self::getColectionThumb($item);
     if ($rv_button) {
         $item['rv_button'] = $rv_button;
         $item['rate'] = Model_Collections::isRate($item['id']);
         //if(!$item['rate'] && JO_Session::get('user_id') == $item['user_id']) $item['rate'] = true;
     } else {
         $item['rate'] = true;
     }
     $item['userhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'&', '-', $item['username']));
     if (!isset($item['href'])) {
         $item['href'] = WM_Router::create($request->getBaseUrl() . '?controller=collections&action=view&collection_id=' . $item['id'] . '&name=' . str_replace('&', '-', $item['name']));
     }
     $view->item = $item;
     return $view->renderByModule('single_items/collection', 'items', 'themes');
 }
Exemplo n.º 30
0
 public static function getBanners(JO_Db_Expr $where)
 {
     $db = JO_Db::getDefaultAdapter();
     $request = JO_Request::getInstance();
     $query = $db->select()->from('banners')->where($where)->where('status = 1')->order('position ASC')->limit(50);
     if (!Helper_Config::get('config_disable_js')) {
         if ($request->isXmlHttpRequest()) {
             $query->where('status_in_js_mode = 1');
         }
     }
     $data = $db->fetchAll($query);
     $result = array();
     if ($data) {
         foreach ($data as $r) {
             $result[$r['position']][] = $r;
         }
     }
     return $result;
 }