Example #1
0
function theme_switch_init($args = array())
{
    global $MSO;
    // если есть get ?theme=шаблон , то выставляем новую куку по этому значению
    // идея nicothin (Николай Громов) - http://forum.max-3000.com/viewtopic.php?p=9943#p9943
    $get = mso_parse_url_get(mso_url_get());
    $get = (isset($get['theme']) and $get['theme']) ? mso_xss_clean($get['theme']) : false;
    // проверяем есть ли post
    if ($post = mso_check_post(array('f_session_id', 'f_theme_switch_submit', 'theme_switch_radio')) or $get) {
        if (!$get) {
            mso_checkreferer();
            $dir = $post['theme_switch_radio'][0];
            // каталог шаблона
        } else {
            $dir = $get;
        }
        // если он есть - проверяем, то пишем куку и редиректимся
        if (file_exists(getinfo('templates_dir') . $dir . '/index.php')) {
            $opt = mso_get_option('theme_switch', 'plugins', array());
            if (isset($opt['templates'][$dir])) {
                // 30 дней = 2592000 секунд 60 * 60 * 24 * 30
                mso_add_to_cookie('theme_switch', $dir, time() + 2592000, true);
            }
        }
    }
    // проверяем существование куки theme_switch
    if (isset($_COOKIE['theme_switch'])) {
        $dir = $_COOKIE['theme_switch'];
        // значение текущего кука
        if (file_exists(getinfo('templates_dir') . $dir . '/index.php')) {
            $opt = mso_get_option('theme_switch', 'plugins', array());
            if (isset($opt['templates'][$dir])) {
                $MSO->config['template'] = $dir;
                $functions_file = $MSO->config['templates_dir'] . $dir . '/functions.php';
                if (file_exists($functions_file)) {
                    require_once $functions_file;
                }
            } else {
                @setcookie('theme_switch', '', time());
            }
            // сбросили куку
        } else {
            @setcookie('theme_switch', '', time());
        }
        // сбросили куку
    }
    return $args;
}
Example #2
0
 public function __construct()
 {
     parent::__construct();
     # подключаем свою библиотеку
     $this->load->library('maxsite_lib');
     # получаем к своему массиву параметров текущий URI
     $this->data_def['uri_segment'] = mso_segment_array();
     $this->data_def['uri_get'] = mso_url_get();
     // здесь строчка _GET
     # в случае ошибки с адресами, расскоментируйте это строчку
     # $this->data_def['uri_segment'] = $this->uri->segment_array();
     # проверяем rss
     if (count($this->data_def['uri_segment']) > 0 and $this->data_def['uri_segment'][count($this->data_def['uri_segment'])] == 'feed') {
         $this->data_def['is_feed'] = '1';
     } else {
         $this->data_def['is_feed'] = '0';
     }
     # инициализация + проверка залогиненности
     mso_initalizing();
     $this->data_def['session'] = $this->session->userdata;
     # $this->session->sess_destroy(); // для тестирования - обнуление сессии
 }
Example #3
0
function loginza_auth_init($arg = array())
{
    if (mso_segment(1) == 'maxsite-loginza-auth') {
        // тут придет token
        if (!empty($_POST['token'])) {
            // token пришел? делаем редрект на страницу авторизации
            $auth_url = "http://loginza.ru/api/authinfo?token=" . $_POST['token'];
            $profile = loginza_auth_request($auth_url);
            $profile = json_decode($profile);
            if (!is_object($profile) || !empty($profile->error_message) || !empty($profile->error_type)) {
                $res_profile = (array) $profile['error_type'];
                die($res_profile['error_type']);
            }
            $curpage = mso_url_get();
            if ($curpage == getinfo('site_url')) {
                $curpage = false;
            }
            $email = (isset($profile->email) and mso_valid_email($profile->email)) ? $profile->email : null;
            $nick = isset($profile->name->full_name) ? $profile->name->full_name : null;
            if (isset($profile->email) and mso_valid_email($profile->email)) {
                require_once getinfo('common_dir') . 'comments.php';
                mso_comuser_auth(array('email' => $email, 'comusers_nik' => $nick, 'redirect' => $curpage));
                mso_redirect(getinfo('site_url'), true, 301);
            } else {
                // ссылка на главную или на предыдущую
                // pr( $profile );
                $txt = t('Не удалось авторизоваться с помощью выбранного сервиса.<br>Возможно это связано с тем, что в ответ на запрос 
				     сервис не возратил Ваш e-mail') . '<br>';
                $txt .= t('Вернуться на') . ' <a href="' . getinfo('site_url') . $curpage . '">' . t('предыдущую страницу') . '</a><br>';
                $txt .= t('Вернуться на') . ' <a href="' . getinfo('site_url') . '">' . t('главную страницу') . '</a><br>';
                die($txt);
            }
            die;
        }
    }
    return $arg;
}