Exemplo n.º 1
0
 public function uploadWithPreset($name, $preset_name)
 {
     $config = cmsConfig::getInstance();
     $uploader = new cmsUploader();
     $result = $uploader->upload($name, $this->allowed_extensions);
     if ($result['success']) {
         if (!$uploader->isImage($result['path'])) {
             $result['success'] = false;
             $result['error'] = LANG_UPLOAD_ERR_MIME;
         }
     }
     if (!$result['success']) {
         if (!empty($result['path'])) {
             $uploader->remove($result['path']);
         }
         return $result;
     }
     $preset = $this->model->getPresetByName($preset_name);
     if (!$preset) {
         return array('success' => false, 'error' => '');
     }
     $path = $uploader->resizeImage($result['path'], array('width' => $preset['width'], 'height' => $preset['height'], 'square' => $preset['is_square'], 'quality' => $preset['is_watermark'] && $preset['wm_image'] ? 100 : $preset['quality']));
     $image = array('path' => $path, 'url' => $config->upload_host . '/' . $path);
     if ($preset['is_watermark'] && $preset['wm_image']) {
         img_add_watermark($image['path'], $preset['wm_image']['original'], $preset['wm_origin'], $preset['wm_margin'], $preset['quality']);
     }
     $result['image'] = $image;
     @unlink($result['path']);
     unset($result['path']);
     return $result;
 }
Exemplo n.º 2
0
 public function start()
 {
     $config = cmsConfig::getInstance();
     $this->memcache = new Memcache();
     $this->memcache->connect($config->cache_host, $config->cache_port) or die('Memcache connect error');
     return true;
 }
Exemplo n.º 3
0
 public function run()
 {
     $template = cmsTemplate::getInstance();
     $config = cmsConfig::getInstance();
     $user = cmsUser::getInstance();
     $contact_id = $this->request->get('contact_id') or cmsCore::error404();
     $content = $this->request->get('content') or cmsCore::error404();
     $csrf_token = $this->request->get('csrf_token');
     // Проверяем валидность
     $is_valid = is_numeric($contact_id) && cmsForm::validateCSRFToken($csrf_token, false);
     if (!$is_valid) {
         $result = array('error' => true, 'message' => '');
         $template->renderJSON($result);
     }
     $contact = $this->model->getContact($user->id, $contact_id);
     // Контакт существует?
     if (!$contact) {
         $result = array('error' => true, 'message' => '');
         $template->renderJSON($result);
     }
     // Контакт не в игноре у отправителя?
     if ($contact['is_ignored']) {
         $result = array('error' => true, 'message' => LANG_PM_CONTACT_IS_IGNORED);
         $template->renderJSON($result);
     }
     // Отправитель не в игноре у контакта?
     if ($this->model->isContactIgnored($contact_id, $user->id)) {
         $result = array('error' => true, 'message' => LANG_PM_YOU_ARE_IGNORED);
         $template->renderJSON($result);
     }
     // Контакт принимает сообщения от этого пользователя?
     if (!$user->isPrivacyAllowed($contact, 'messages_pm')) {
         $result = array('error' => true, 'message' => LANG_PM_CONTACT_IS_PRIVATE);
         $template->renderJSON($result);
     }
     //
     // Отправляем сообщение
     //
     $content_html = cmsEventsManager::hook('html_filter', $content);
     if (!$content_html) {
         $template->renderJSON(array('error' => false, 'date' => false, 'message' => false));
     }
     $this->setSender($user->id);
     $this->addRecipient($contact_id);
     $message_id = $this->sendMessage($content_html);
     //
     // Отправляем уведомление на почту
     //
     $user_to = cmsCore::getModel('users')->getUser($contact_id);
     if (!$user_to['is_online']) {
         $this->sendNoticeEmail('messages_new');
     }
     //
     // Получаем и рендерим добавленное сообщение
     //
     $message = $this->model->getMessage($message_id);
     $message_html = $template->render('message', array('messages' => array($message), 'user' => $user), new cmsRequest(array(), cmsRequest::CTX_INTERNAL));
     // Результат
     $template->renderJSON(array('error' => false, 'date' => date($config->date_format, time()), 'message' => $message_html));
 }
Exemplo n.º 4
0
    public function displayEditor($field_id, $content = '')
    {
        $lang = cmsConfig::get('language');
        $user = cmsUser::getInstance();
        cmsTemplate::getInstance()->addCSS('wysiwyg/ckeditor/samples/sample.css');
        cmsTemplate::getInstance()->addJS('wysiwyg/ckeditor/ckeditor.js');
        $dom_id = str_replace(array('[', ']'), array('_', ''), $field_id);
        echo html_textarea($field_id, $content, array('id' => $dom_id));
        ?>
<script type="text/javascript" >

            <?php 
        if ($user->is_admin) {
            ?>

            $(document).ready(function(){
                CKEDITOR.replace('<?php 
            echo $dom_id;
            ?>
',{
                });
            });

            <?php 
        }
        ?>
        </script>
    <?php 
    }
Exemplo n.º 5
0
 public function getInput($value)
 {
     if ($value) {
         if (is_array($value)) {
             if (!empty($value['date'])) {
                 $value = sprintf('%s %02d:%02d', $value['date'], $value['hours'], $value['mins']);
             }
         }
     }
     $this->data['show_time'] = $this->getOption('show_time');
     $this->data['date'] = $value ? date(cmsConfig::getInstance()->date_format, strtotime($value)) : '';
     if ($this->data['show_time']) {
         if (!$value) {
             $this->data['hours'] = 0;
             $this->data['mins'] = 0;
         } else {
             list($this->data['hours'], $this->data['mins']) = explode(':', date('H:i', strtotime($value)));
         }
         $this->data['fname_date'] = $this->element_name . '[date]';
         $this->data['fname_hours'] = $this->element_name . '[hours]';
         $this->data['fname_mins'] = $this->element_name . '[mins]';
     } else {
         $this->data['fname_date'] = $this->element_name;
     }
     return parent::getInput($value);
 }
Exemplo n.º 6
0
 public function __construct($name = '')
 {
     $this->site_config = cmsConfig::getInstance();
     if ($name) {
         $this->setName($name);
     } else {
         $device_type = cmsRequest::getDeviceType();
         $template = $this->site_config->template;
         // шаблон в зависимости от девайса
         if ($device_type !== 'desktop') {
             $device_template = cmsConfig::get('template_' . $device_type);
             if ($device_template) {
                 $template = $device_template;
             }
         }
         // шаблон админки, можем определить только тут
         $controller = cmsCore::getInstance()->uri_controller;
         if ($controller === 'admin' && $this->site_config->template_admin) {
             $template = $this->site_config->template_admin;
         }
         $this->setName($template);
     }
     $this->options = $this->getOptions();
     $this->setInheritNames($this->getInheritTemplates());
     $this->title = $this->site_config->sitename;
     $is_no_def_meta = isset($this->site_config->is_no_meta) ? $this->site_config->is_no_meta : false;
     if (!$is_no_def_meta) {
         $this->metakeys = $this->site_config->metakeys;
         $this->metadesc = $this->site_config->metadesc;
     }
 }
Exemplo n.º 7
0
    public function displayEditor($field_id, $content = '')
    {
        $lang = cmsConfig::get('language');
        $user = cmsUser::getInstance();
        cmsTemplate::getInstance()->addJS('wysiwyg/tinymce/tinymce.min.js');
        $dom_id = str_replace(array('[', ']'), array('_', ''), $field_id);
        echo html_textarea($field_id, $content, array('id' => $dom_id));
        ?>
<script type="text/javascript" >
$(document).ready(function(){
 	tinymce.init({mode : "exact", 
	              elements : "<?php 
        echo $field_id;
        ?>
",
				  language : "ru",
				 plugins: [
         "link image lists media responsivefilemanager "
   ],
    relative_urls: false,
   
    filemanager_title:"Responsive Filemanager",
    external_filemanager_path:"/filemanager/",
    external_plugins: { "filemanager" : "/filemanager/plugin.min.js"},
    
				  image_advtab: true,
   toolbar1: "undo redo | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | styleselect",
   toolbar2: "| responsivefilemanager | image | media | link unlink anchor | "
	   			  
				  });
				  });
</script>
<?php 
    }
Exemplo n.º 8
0
 public static function getInstance()
 {
     if (self::$instance === null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Exemplo n.º 9
0
 function __construct($request)
 {
     parent::__construct($request);
     $config = cmsConfig::getInstance();
     $this->name = str_replace('backend', '', $this->name);
     $this->root_path = $config->root_path . 'system/controllers/' . $this->name . '/backend/';
 }
Exemplo n.º 10
0
 public function clean($key)
 {
     if (!cmsConfig::get('cache_enabled')) {
         return false;
     }
     return $this->cacher->clean($key);
 }
Exemplo n.º 11
0
 public function addContentType($ctype)
 {
     $id = $this->insert('content_types', $ctype);
     $config = cmsConfig::getInstance();
     // получаем структуру таблиц для хранения контента данного типа
     $content_table_struct = $this->getContentTableStruct();
     $fields_table_struct = $this->getFieldsTableStruct();
     $props_table_struct = $this->getPropsTableStruct();
     $props_bind_table_struct = $this->getPropsBindTableStruct();
     $props_values_table_struct = $this->getPropsValuesTableStruct();
     // создаем таблицы
     $table_name = $this->table_prefix . $ctype['name'];
     $this->db->createTable($table_name, $content_table_struct);
     $this->db->createTable("{$table_name}_fields", $fields_table_struct, $config->db_engine);
     $this->db->createCategoriesTable("{$table_name}_cats");
     $this->db->createCategoriesBindsTable("{$table_name}_cats_bind");
     $this->db->createTable("{$table_name}_props", $props_table_struct, $config->db_engine);
     $this->db->createTable("{$table_name}_props_bind", $props_bind_table_struct, $config->db_engine);
     $this->db->createTable("{$table_name}_props_values", $props_values_table_struct, $config->db_engine);
     //
     // добавляем стандартные поля
     //
     // заголовок
     $this->addContentField($ctype['name'], array('name' => 'title', 'title' => LANG_TITLE, 'type' => 'caption', 'ctype_id' => $id, 'is_in_list' => 1, 'is_in_item' => 1, 'is_in_filter' => 1, 'is_fixed' => 1, 'is_fixed_type' => 1, 'is_system' => 0, 'options' => array('label_in_list' => 'none', 'label_in_item' => 'none', 'min_length' => 3, 'max_length' => 100, 'is_required' => true)), true);
     // дата публикации
     $this->addContentField($ctype['name'], array('name' => 'date_pub', 'title' => LANG_DATE_PUB, 'type' => 'date', 'ctype_id' => $id, 'is_in_list' => 1, 'is_in_item' => 1, 'is_in_filter' => 1, 'is_fixed' => 1, 'is_fixed_type' => 1, 'is_system' => 1, 'options' => array('label_in_list' => 'none', 'label_in_item' => 'left', 'show_time' => true)), true);
     // автор
     $this->addContentField($ctype['name'], array('name' => 'user', 'title' => LANG_AUTHOR, 'type' => 'user', 'ctype_id' => $id, 'is_in_list' => 1, 'is_in_item' => 1, 'is_in_filter' => 0, 'is_fixed' => 1, 'is_fixed_type' => 1, 'is_system' => 1, 'options' => array('label_in_list' => 'none', 'label_in_item' => 'left')), true);
     // фотография
     $this->addContentField($ctype['name'], array('name' => 'photo', 'title' => LANG_PHOTO, 'type' => 'image', 'ctype_id' => $id, 'is_in_list' => 1, 'is_in_item' => 1, 'is_fixed' => 1, 'options' => array('size_teaser' => 'small', 'size_full' => 'normal', 'sizes' => array('micro', 'small', 'normal', 'big'))), true);
     // описание
     $this->addContentField($ctype['name'], array('name' => 'content', 'title' => LANG_DESCRIPTION, 'type' => 'text', 'ctype_id' => $id, 'is_in_list' => 1, 'is_in_item' => 1, 'is_fixed' => 1, 'options' => array('label_in_list' => 'none', 'label_in_item' => 'none')), true);
     cmsCache::getInstance()->clean("content.types");
     return $id;
 }
Exemplo n.º 12
0
 public function run($do = false)
 {
     $updater = new cmsUpdater();
     $update = $updater->checkUpdate();
     if ($update == cmsUpdater::UPDATE_NOT_AVAILABLE) {
         cmsUser::addSessionMessage(LANG_CP_UPDATE_NOT_AVAILABLE);
         $this->redirectToAction('update');
     }
     if ($update == cmsUpdater::UPDATE_CHECK_ERROR || empty($update['version'])) {
         cmsUser::addSessionMessage(LANG_CP_UPDATE_CHECK_FAIL, 'error');
         $this->redirectToAction('update');
     }
     if (!function_exists('curl_init')) {
         cmsUser::addSessionMessage(LANG_CP_UPDATE_DOWNLOAD_FAIL, 'error');
         $this->redirectToAction('update');
     }
     $url = $update['url'];
     $package_name = basename($url);
     $destination = cmsConfig::get('upload_path') . 'installer/' . $package_name;
     $result = file_save_from_url($url, $destination);
     if ($result === false) {
         cmsUser::addSessionMessage(LANG_CP_UPDATE_DOWNLOAD_FAIL, 'error');
         $this->redirectToAction('update');
     }
     $this->redirectToAction('install', false, array('package_name' => $package_name));
 }
Exemplo n.º 13
0
 public function run($user)
 {
     $cfg = cmsConfig::getInstance();
     $dest_dir = $cfg->upload_path . "u{$user['id']}";
     files_remove_directory($dest_dir);
     return $user;
 }
Exemplo n.º 14
0
 public function processUpload($album_id)
 {
     $config = cmsConfig::getInstance();
     $uploader = new cmsUploader();
     $result = $uploader->upload('qqfile');
     if (!$result['success']) {
         cmsTemplate::getInstance()->renderJSON($result);
         $this->halt();
     }
     $preset = array('width' => 600, 'height' => 460, 'is_square' => false, 'is_watermark' => false);
     if (!empty($this->options['preset'])) {
         $preset = cmsCore::getModel('images')->getPresetByName($this->options['preset']);
     }
     $result['paths'] = array('big' => $uploader->resizeImage($result['path'], array('width' => $preset['width'], 'height' => $preset['height'], 'square' => $preset['is_square'])), 'normal' => $uploader->resizeImage($result['path'], array('width' => 160, 'height' => 160, 'square' => true)), 'small' => $uploader->resizeImage($result['path'], array('width' => 64, 'height' => 64, 'square' => true)), 'original' => $result['url']);
     if ($preset['is_watermark'] && !empty($preset['wm_image'])) {
         $images_controller = cmsCore::getController('images');
         $images_controller->addWatermark($result['paths']['big'], $preset['wm_image']['original'], $preset['wm_origin'], $preset['wm_margin']);
     }
     $result['filename'] = basename($result['path']);
     if (empty($this->options['is_origs'])) {
         @unlink($result['path']);
         unset($result['paths']['original']);
     }
     unset($result['path']);
     $result['url'] = $config->upload_host . '/' . $result['paths']['small'];
     $result['id'] = $this->model->addPhoto($album_id, $result['paths']);
     cmsTemplate::getInstance()->renderJSON($result);
     $this->halt();
 }
Exemplo n.º 15
0
 public function store($value, $is_submitted, $old_value = null)
 {
     $config = cmsConfig::getInstance();
     $files_model = cmsCore::getModel('files');
     if ($value) {
         $file = cmsModel::yamlToArray($old_value);
         $path = $config->upload_path . $file['path'];
         @unlink($path);
         $files_model->deleteFile($file['id']);
         $old_value = null;
     }
     $uploader = new cmsUploader();
     if (!$uploader->isUploaded($this->name)) {
         return $old_value;
     }
     $allowed_extensions = $this->getOption('extensions');
     $max_size_mb = $this->getOption('max_size_mb');
     if (!trim($allowed_extensions)) {
         $allowed_extensions = false;
     }
     if (!$max_size_mb) {
         $max_size_mb = 0;
     }
     $result = $uploader->upload($this->name, $allowed_extensions, $max_size_mb * 1048576);
     if (!$result['success']) {
         if (!empty($result['path'])) {
             $uploader->remove($result['path']);
         }
         cmsUser::addSessionMessage($result['error'], 'error');
         return null;
     }
     $file = $files_model->registerFile($result['url'], $result['name']);
     return array('id' => $file['id'], 'url_key' => $file['url_key'], 'name' => $result['name'], 'size' => $result['size'], 'path' => $result['url']);
 }
Exemplo n.º 16
0
 public function run()
 {
     if (cmsUser::isLogged()) {
         $this->redirectToHome();
     }
     $email = $this->request->get('login_email');
     $password = $this->request->get('login_password');
     $remember = (bool) $this->request->get('remember');
     $back_url = $this->request->has('back') ? $this->request->get('back') : false;
     $is_site_offline = !cmsConfig::get('is_site_on');
     if ($this->request->has('submit')) {
         $is_captcha_valid = true;
         if (cmsUser::sessionGet('is_auth_captcha') && $this->options['auth_captcha']) {
             $is_captcha_valid = cmsEventsManager::hook('captcha_validate', $this->request);
         }
         if ($is_captcha_valid) {
             cmsUser::sessionUnset('is_auth_captcha');
             $logged_id = cmsUser::login($email, $password, $remember);
             if ($logged_id) {
                 if ($is_site_offline) {
                     $userSession = cmsUser::sessionGet('user');
                     if (!$userSession['is_admin']) {
                         cmsUser::addSessionMessage(LANG_LOGIN_ADMIN_ONLY, 'error');
                         cmsUser::logout();
                         $this->redirectBack();
                     }
                 }
                 cmsEventsManager::hook('auth_login', $logged_id);
                 $is_back = $this->request->get('is_back');
                 if ($is_back) {
                     $this->redirectBack();
                 }
                 if ($back_url) {
                     $this->redirect($back_url);
                 } else {
                     $this->redirectToHome();
                 }
             }
         }
         if ($this->options['auth_captcha'] && !$is_site_offline) {
             cmsUser::sessionSet('is_auth_captcha', true);
         }
         if ($is_captcha_valid) {
             cmsUser::addSessionMessage(LANG_LOGIN_ERROR, 'error');
             if ($is_site_offline) {
                 $this->redirectBack();
             }
         } else {
             cmsUser::addSessionMessage(LANG_CAPTCHA_ERROR, 'error');
         }
     }
     if ($back_url) {
         cmsUser::addSessionMessage(LANG_LOGIN_REQUIRED, 'error');
     }
     if (cmsUser::sessionGet('is_auth_captcha')) {
         $captcha_html = cmsEventsManager::hook('captcha_html');
     }
     return cmsTemplate::getInstance()->render('login', array('back_url' => $back_url, 'captcha_html' => isset($captcha_html) ? $captcha_html : false));
 }
Exemplo n.º 17
0
 public function getPathAndFile($key)
 {
     $path = cmsConfig::get('cache_path') . str_replace('.', '/', $key);
     $file = explode('/', $path);
     $path = dirname($path);
     $file = $path . '/' . $file[sizeof($file) - 1] . '.dat';
     return array($path, $file);
 }
Exemplo n.º 18
0
 private function isAllowByIp()
 {
     $allow_ips = cmsConfig::get('allow_ips');
     if (!$allow_ips) {
         return true;
     }
     return string_in_mask_list(cmsUser::getIp(), $allow_ips);
 }
Exemplo n.º 19
0
 public function run($ctype)
 {
     $cfg = cmsConfig::getInstance();
     if ($cfg->frontpage == "content:{$ctype['name']}" && !$ctype['options']['list_on']) {
         $cfg->update('frontpage', 'none');
     }
     return true;
 }
Exemplo n.º 20
0
 public function run()
 {
     $result = cmsConfig::getInstance()->update('is_site_on', 1);
     if (!$result) {
         cmsUser::addSessionMessage(LANG_CP_SETTINGS_NOT_WRITABLE, 'error');
     }
     $this->redirectBack();
 }
Exemplo n.º 21
0
 public function run($ctype)
 {
     $cfg = cmsConfig::getInstance();
     if ($cfg->frontpage == "content:{$ctype['name']}") {
         $cfg->update('frontpage', 'none');
     }
     return $ctype;
 }
Exemplo n.º 22
0
 public function parseRoute($uri)
 {
     $config = cmsConfig::getInstance();
     $action_name = parent::parseRoute($uri);
     if (!$action_name && $config->ctype_default) {
         $action_name = parent::parseRoute($config->ctype_default . '/' . $uri);
     }
     return $action_name;
 }
Exemplo n.º 23
0
 private function getPackageContentsDir()
 {
     $config = cmsConfig::getInstance();
     $path = $config->upload_path . $this->installer_upload_path . '/' . 'package';
     if (!is_dir($path)) {
         return false;
     }
     return $path;
 }
Exemplo n.º 24
0
function upgrade_component_usermaps()
{
    $inCore = cmsCore::getInstance();
    $inDB = cmsDatabase::getInstance();
    $inConf = cmsConfig::getInstance();
    include $_SERVER['DOCUMENT_ROOT'] . '/includes/dbimport.inc.php';
    dbRunSQL($_SERVER['DOCUMENT_ROOT'] . '/components/usermaps/update.sql', $inConf->db_prefix);
    return true;
}
Exemplo n.º 25
0
 public function init($do)
 {
     $groups = cmsCore::getModel('users')->getGroups();
     return array('basic' => array('type' => 'fieldset', 'childs' => array(new fieldString('title', array('title' => LANG_USERS_MIG_TITLE, 'rules' => array(array('required'), array('max_length', 256)))), new fieldCheckbox('is_active', array('title' => LANG_USERS_MIG_IS_ACTIVE)))), array('type' => 'fieldset', 'childs' => array(new fieldList('is_keep_group', array('title' => LANG_USERS_MIG_ACTION, 'items' => array(0 => LANG_USERS_MIG_ACTION_CHANGE, 1 => LANG_USERS_MIG_ACTION_ADD))), new fieldList('group_from_id', array('title' => LANG_USERS_MIG_FROM, 'generator' => function () use($groups) {
         return array_collection_to_list($groups, 'id', 'title');
     })), new fieldList('group_to_id', array('title' => LANG_USERS_MIG_TO, 'generator' => function () use($groups) {
         return array_collection_to_list($groups, 'id', 'title');
     })))), array('type' => 'fieldset', 'childs' => array(new fieldCheckbox('is_passed', array('title' => LANG_USERS_MIG_COND_DATE)), new fieldList('passed_from', array('title' => LANG_USERS_MIG_PASSED_FROM, 'items' => array(0 => LANG_USERS_MIG_PASSED_REG, 1 => LANG_USERS_MIG_PASSED_MIG))), new fieldNumber('passed_days', array('title' => LANG_USERS_MIG_PASSED)))), array('type' => 'fieldset', 'childs' => array(new fieldCheckbox('is_rating', array('title' => LANG_USERS_MIG_COND_RATING)), new fieldNumber('rating', array('title' => LANG_USERS_MIG_RATING)))), array('type' => 'fieldset', 'childs' => array(new fieldCheckbox('is_karma', array('title' => LANG_USERS_MIG_COND_KARMA)), new fieldNumber('karma', array('title' => LANG_USERS_MIG_KARMA)))), array('type' => 'fieldset', 'childs' => array(new fieldCheckbox('is_notify', array('title' => LANG_USERS_MIG_NOTIFY)), new fieldHtml('notify_text', array('title' => LANG_USERS_MIG_NOTIFY_TEXT, 'options' => array('editor' => cmsConfig::get('default_editor')))))));
 }
Exemplo n.º 26
0
 public function __construct()
 {
     $config = cmsConfig::getInstance();
     if ($config->cache_enabled) {
         $cacher_class = 'cmsCache' . string_to_camel('_', $config->cache_method);
         $this->cacher = new $cacher_class();
         $this->cache_ttl = $config->cache_ttl;
         $this->is_debug = $config->debug;
     }
 }
Exemplo n.º 27
0
 public function run()
 {
     // автоматическое получение опций через $this->options здесь не
     // работает, потому что форма опций не содержит полей, они заполняются
     // динамически в админке
     $options = $this->loadOptions($this->name);
     if (!$options) {
         return false;
     }
     $sources_list = $options['sources'];
     if (!$sources_list) {
         return false;
     }
     $config = cmsConfig::getInstance();
     if (!is_writable($config->root_path . 'cache/static/sitemaps/')) {
         return false;
     }
     $sources = array();
     $sitemaps = array();
     foreach ($sources_list as $item => $is_enabled) {
         if (!$is_enabled) {
             continue;
         }
         list($controller_name, $source) = explode('|', $item);
         $sources[$controller_name][] = $source;
     }
     foreach ($sources as $controller_name => $items) {
         $urls = array();
         $controller = cmsCore::getController($controller_name);
         foreach ($items as $item) {
             $urls = $controller->runHook('sitemap_urls', array($item));
             if (!$urls) {
                 continue;
             }
             if (count($urls) > $this->max_count) {
                 $chunk_data = array_chunk($urls, $this->max_count, true);
                 foreach ($chunk_data as $index => $chunk_urls) {
                     $index = $index ? '_' . $index : '';
                     $xml = cmsTemplate::getInstance()->renderInternal($this, 'sitemap', array('urls' => $chunk_urls));
                     $sitemap_file = "sitemap_{$controller_name}_{$item}{$index}.xml";
                     file_put_contents($config->root_path . "cache/static/sitemaps/{$sitemap_file}", $xml);
                     $sitemaps[] = $sitemap_file;
                 }
             } else {
                 $xml = cmsTemplate::getInstance()->renderInternal($this, 'sitemap', array('urls' => $urls));
                 $sitemap_file = "sitemap_{$controller_name}_{$item}.xml";
                 file_put_contents($config->root_path . "cache/static/sitemaps/{$sitemap_file}", $xml);
                 $sitemaps[] = $sitemap_file;
             }
         }
     }
     $xml = cmsTemplate::getInstance()->renderInternal($this, 'sitemap_index', array('sitemaps' => $sitemaps, 'host' => $config->host));
     file_put_contents(cmsConfig::get('root_path') . 'cache/static/sitemaps/sitemap.xml', $xml);
     return true;
 }
Exemplo n.º 28
0
 public function __construct()
 {
     $config = cmsConfig::getInstance();
     $this->groups = array(GUEST_GROUP_ID);
     $this->ip = self::getIp();
     self::loadOnlineUsersIds();
     if (self::isSessionSet('user:id')) {
         // уже авторизован
         $this->id = self::sessionGet('user:id');
     } elseif (self::getCookie('auth')) {
         // пробуем авторизовать по кукису
         $this->id = self::autoLogin(self::getCookie('auth'));
     }
     self::deleteOldSessions($this->id);
     //
     // если авторизован, заполняем объект данными из базы
     //
     if ($this->id) {
         $model = cmsCore::getModel('users');
         $user = $model->getUser($this->id);
         if (!$user) {
             self::logout();
             return;
         }
         // если дата последнего визита еще не сохранена в сессии,
         // значит авторизация была только что
         // сохраним дату в сессии и обновим в базе
         if (!self::isSessionSet('user:date_log')) {
             self::sessionSet('user:date_log', $user['date_log']);
             $model->update('{users}', $this->id, array('date_log' => null), true);
         }
         // заполняем объект данными из базы
         foreach ($user as $field => $value) {
             $this->{$field} = $value;
         }
         // конвертим список аватаров в массив
         // к пути каждого аватара добавляем путь корня
         $this->avatar = cmsModel::yamlToArray($this->avatar);
         if ($this->avatar) {
             foreach ($this->avatar as $size => $path) {
                 $this->avatar[$size] = $config->upload_host . '/' . $path;
             }
         }
         // кешируем список друзей в сессию
         $this->recacheFriends();
         // создаем online-сессию
         self::createSession($this->id);
         // восстанавливаем те поля, которые не должны
         // изменяться в течении сессии
         $this->date_log = self::sessionGet('user:date_log');
         $this->perms = self::getPermissions($user['groups'], $user['id']);
         $this->is_logged = true;
         cmsEventsManager::hook('user_loaded', $user);
     }
 }
Exemplo n.º 29
0
 public function getOptions()
 {
     return array(new fieldList('editor', array('title' => LANG_PARSER_HTML_EDITOR, 'default' => cmsConfig::get('default_editor'), 'generator' => function ($item) {
         $items = array();
         $editors = cmsCore::getWysiwygs();
         foreach ($editors as $editor) {
             $items[$editor] = $editor;
         }
         return $items;
     })), new fieldCheckbox('is_html_filter', array('title' => LANG_PARSER_HTML_FILTERING)), new fieldCheckbox('build_redirect_link', array('title' => LANG_PARSER_BUILD_REDIRECT_LINK)), new fieldNumber('teaser_len', array('title' => LANG_PARSER_HTML_TEASER_LEN, 'hint' => LANG_PARSER_HTML_TEASER_LEN_HINT)), new fieldCheckbox('in_fulltext_search', array('title' => LANG_PARSER_IN_FULLTEXT_SEARCH, 'hint' => LANG_PARSER_IN_FULLTEXT_SEARCH_HINT, 'default' => false)));
 }
Exemplo n.º 30
0
function install_component_battleways()
{
    $inCore = cmsCore::getInstance();
    //подключаем ядро
    $inDB = cmsDatabase::getInstance();
    //подключаем базу данных
    $inConf = cmsConfig::getInstance();
    include $_SERVER['DOCUMENT_ROOT'] . '/includes/dbimport.inc.php';
    dbRunSQL($_SERVER['DOCUMENT_ROOT'] . '/components/battleways/install.sql', $inConf->db_prefix);
    return true;
}