function ushki_to_hook_autoload() { // для админки плагин не работает if (mso_segment(1) != 'admin') { mso_hook_add('init', 'ushki_to_hook_custom'); } }
function admin_ip_admin_init($args = array()) { // проверяем сегменты URL // получаем из опций секретный сегмент // если это секретный, то сбрасываем ip // получаем список разрешенных IP из опций // получаем текущий IP юзера // если его нет в разрешенных, то die('no'); global $MSO; $options_key = 'plugin_admin_ip'; $options = mso_get_option($options_key, 'plugins', array()); if (!isset($options['secret'])) { $options['secret'] = ''; } if (!isset($options['ip'])) { $options['ip'] = ''; } if ($options['secret'] and mso_segment(3) == $options['secret']) { // сброс ip // http://localhost/codeigniter/admin/plugin_admin_ip/secret_to_reset - secret_to_reset $options['ip'] = ''; mso_add_option($options_key, $options, 'plugins'); mso_redirect('admin/plugin_admin_ip'); // редирект на страницу плагина } if ($options['ip']) { // указаны IP $ips = explode("\n", $options['ip']); $curr_ip = $MSO->data['session']['ip_address']; $ok = false; // признак, что доступ разрешен foreach ($ips as $ip) { if (trim($ip) == $curr_ip) { $ok = true; break; } } if (!$ok) { die('Access denied'); } // рубим } if (!mso_check_allow('admin_ip_admin_page')) { return $args; // 'Доступ запрещен'; } $this_plugin_url = 'plugin_admin_ip'; // url и hook # добавляем свой пункт в меню админки # первый параметр - группа в меню # второй - это действие/адрес в url - http://сайт/admin/demo # можно использовать добавочный, например demo/edit = http://сайт/admin/demo/edit # Третий - название ссылки mso_admin_menu_add('plugins', $this_plugin_url, 'Admin IP'); # прописываем для указаного admin_url_ + $this_plugin_url - (он будет в url) # связанную функцию именно она будет вызываться, когда # будет идти обращение по адресу http://сайт/admin/_null mso_admin_url_hook($this_plugin_url, 'admin_ip_admin_page'); return $args; }
function range_url_autoload() { // в админке и rss не используем if (mso_segment(1) != 'admin' and !is_feed()) { mso_hook_add('init', 'range_url_init'); } # хук на init }
function upload_editor_autoload() { if (is_login() && mso_check_allow('admin_files')) { mso_hook_add('new_page', 'upload_editor_new_page'); if (mso_segment(2) == 'page_new') { mso_hook_add('admin_content', 'upload_editor_js'); } } }
function cron_custom($args = array()) { $options = mso_get_option('plugin_cron', 'plugins', array()); if (!isset($options['slug'])) { $options['slug'] = 'cron'; } if (mso_segment(1) == $options['slug']) { mso_hook('cron'); # это крон, выполняем его хук die('Cron done'); # после крона всегда останавливаем выполнение } else { return $args; } }
function feedburner_init($args = array()) { if (!is_feed()) { return $args; } $options = mso_get_option('plugin_feedburner', 'plugins', array()); if (!isset($options['key'])) { return $args; } if (!preg_match("!feedburner|feedvalidator!i", $_SERVER['HTTP_USER_AGENT'])) { if (mso_segment(1) == 'feed') { header("Location: http://feeds2.feedburner.com/" . trim($options['key'])); header("HTTP/1.1 302 Temporary Redirect"); exit; } } return $args; }
function admin_comments_admin($args = array()) { # выносим админские функции отдельно в файл global $MSO; if (!mso_check_allow('admin_comments')) { echo t('Доступ запрещен'); return $args; } $seg = mso_segment(3); if ($seg == 'edit') { mso_hook_add_dinamic('mso_admin_header', ' return $args . t("Редактирование комментария"); '); mso_hook_add_dinamic('admin_title', ' return t("Редактирование комментария") . " - " . $args; '); require $MSO->config['admin_plugins_dir'] . 'admin_comments/edit.php'; } else { mso_hook_add_dinamic('mso_admin_header', ' return $args . t("Комментарии"); '); mso_hook_add_dinamic('admin_title', ' return t("Комментарии") . " - " . $args; '); require $MSO->config['admin_plugins_dir'] . 'admin_comments/admin.php'; } }
function admin_users_admin($args = array()) { # выносим админские функции отдельно в файл global $MSO; if (!mso_check_allow('admin_users_users')) { echo t('Доступ запрещен'); return $args; } # если идет вызов с номером юзера, то подключаем страницу для редактирования // Определим текущую страницу (на основе сегмента url) // http://localhost/codeigniter/admin/users/edit/1 $seg = mso_segment(3); // третий - edit mso_hook_add_dinamic('mso_admin_header', ' return $args . "' . t('Пользователи') . '"; '); mso_hook_add_dinamic('admin_title', ' return "' . t('Пользователи') . ' - " . $args; '); // подключаем соответственно нужный файл if ($seg == '') { require $MSO->config['admin_plugins_dir'] . 'admin_users/users.php'; } elseif ($seg == 'edit') { require $MSO->config['admin_plugins_dir'] . 'admin_users/edit.php'; } }
function global_cache_autoload($args = array()) { // в админке кэш не работает if (mso_segment(1) != 'admin') { $options = mso_get_option('plugin_global_cache', 'plugins', array()); // кэш включен? if (isset($options['on']) and $options['on']) { // админам включить кэш? if (!isset($options['onlogin']) or isset($options['onlogin']) and !$options['onlogin']) { mso_hook_add('global_cache_start', 'global_cache_start'); mso_hook_add('global_cache_end', 'global_cache_end'); # дополнительные хуки, которые позволяют сбросить кэш - использовать в плагинах и т.п. mso_hook_add('global_cache_key_flush', 'global_cache_key_flush'); // сброс кэша текущей страницы mso_hook_add('global_cache_all_flush', 'global_cache_all_flush'); // сброс всего html-кэша # сброс кэша если была отправка POST if (isset($_POST) and $_POST) { global_cache_all_flush(); } } } } }
function admin_plugin_options_admin($args = array()) { if (!mso_check_allow('admin_plugin_options')) { echo t('Доступ запрещен'); return $args; } mso_hook_add_dinamic('mso_admin_header', ' return $args . "' . t('Настройка плагина') . '"; '); mso_hook_add_dinamic('admin_title', ' return "' . t('Настройка плагина') . ' - " . $args; '); if ($plugin = mso_segment(3)) { if (!file_exists(getinfo('plugins_dir') . $plugin . '/index.php')) { echo t('Плагин не найден.'); return $args; } if (!function_exists($plugin . '_mso_options')) { echo t('Для данного плагина настроек не предусмотрено.'); return $args; } else { $fn = $plugin . '_mso_options'; $fn(); } } else { echo t('Неверно указан плагин.'); } }
<?php if (!defined('BASEPATH')) { exit('No direct script access allowed'); } // получим массив всех рубрик $cats = mso_cat_array_single('page', 'category_menu_order', 'ASC', '', true, false); // pr($cats); // если массив рубрик получен if ($cats) { // найдем нужную рубрику и получим данные о ней foreach ($cats as $cat) { if (mso_segment(2) == $cat['category_slug']) { $cat_id = $cat['category_id']; $cat_descr = $cat['category_desc']; $cat_name = $cat['category_name']; $cat_url = $cat['category_slug']; break; } } // сделаем запрос за записями этой рубрики $par = array('type' => false, 'cat_id' => $cat_id, 'limit' => mso_get_option('limit_post', 'templates', '10'), 'cut' => mso_get_option('more', 'templates', 'Читать полностью »'), 'type' => false, 'content' => false, 'get_page_count_comments' => false); $pages = mso_get_pages($par, $pagination); // pr($pages); // определим метаданные mso_head_meta('title', $cat_name . ' - ' . getinfo('name_site')); mso_head_meta('description', $cat_descr); mso_head_meta('keywords', $cat_descr); $admin_link = ''; if (is_login()) { $admin_link = ' <a href="' . getinfo('siteurl') . 'admin/page_edit/' . $page['page_id'] . '">Редактировать</a>';
echo '<div class="update">' . t('Обновлено!') . '</div>'; // . $result['description']; mso_flush_cache(); // сбросим кэш } else { echo '<div class="error">' . t('Ошибка обновления') . ' (' . $result['description'] . ')</div>'; } } # вспомогательная функция # имя поле значение function _mso_add_row($title, $field, $val) { $CI =& get_instance(); $CI->table->add_row($title, form_input(array('name' => $field, 'style' => 'width: 99%', 'value' => $val))); } $id = (int) mso_segment(4); // номер пользователя по сегменту url if ($id) { # подготавливаем выборку из базы $CI->db->select('*'); $CI->db->from('comusers'); $CI->db->where('comusers_id', $id); $query = $CI->db->get(); // если есть данные, то выводим if ($query->num_rows() > 0) { $CI->load->helper('form'); $CI->load->library('table'); $tmpl = array('table_open' => '<table class="page" border="0" width="99%"> <colgroup><colgroup>', 'row_alt_start' => '<tr class="alt">', 'cell_alt_start' => '<td class="alt">'); $CI->table->set_template($tmpl); // шаблон таблицы
<?php if (!defined('BASEPATH')) { exit('No direct script access allowed'); } /** * MaxSite CMS * (c) http://max-3000.com/ */ require_once getinfo('common_dir') . 'comments.php'; // получим всю информацию о комюзере - номер в сегменте url $comuser_info = mso_get_comuser(mso_segment(2)); if ($f = mso_page_foreach('users-head-meta')) { require $f; } else { mso_head_meta('title', tf('Комментаторы') . '. ' . getinfo('title')); // meta title страницы } if (!$comuser_info and mso_get_option('page_404_http_not_found', 'templates', 1)) { header('HTTP/1.0 404 Not Found'); } // теперь сам вывод # начальная часть шаблона if ($fn = mso_find_ts_file('main/main-start.php')) { require $fn; } echo NR . '<div class="mso-type-users"><div class="mso-page-only"><div class="mso-page-content mso-type-users-content">'; if ($comuser_info) { extract($comuser_info[0]); if ($f = mso_page_foreach('users')) { require $f;
function mso_page_view_count_first($unique = false, $name_cookies = 'maxsite-cms', $expire = 2592000) { global $_COOKIE, $_SESSION; if (!mso_get_option('page_view_enable', 'templates', '1') and !$unique) { return true; } //если нет такой опции или не пришло в функцию, то выходим if (!$unique) { $unique = mso_get_option('page_view_enable', 'templates', '1'); } $slug = mso_segment(2); $all_slug = array(); if ($unique == 0) { return false; } elseif ($unique == 1) { if (isset($_COOKIE[$name_cookies])) { $all_slug = explode('|', $_COOKIE[$name_cookies]); } // значения текущего кука if (in_array($slug, $all_slug)) { return false; } // уже есть текущий урл - не увеличиваем счетчик } elseif ($unique == 2) { session_start(); if (isset($_SESSION[$name_cookies])) { $all_slug = explode('|', $_SESSION[$name_cookies]); } // значения текущей сессии if (in_array($slug, $all_slug)) { return false; } // уже есть текущий урл - не увеличиваем счетчик } // нужно увеличить счетчик $all_slug[] = $slug; // добавляем текущий slug $all_slug = array_unique($all_slug); // удалим дубли на всякий пожарный $all_slug = implode('|', $all_slug); // соединяем обратно в строку $expire = time() + $expire; if ($unique == 1) { @setcookie($name_cookies, $all_slug, $expire); } elseif ($unique == 2) { $_SESSION[$name_cookies] = $all_slug; } // записали в сессию // получим текущее значение page_view_count // и увеличиваем значение на 1 $CI =& get_instance(); $CI->db->select('page_view_count'); if (is_numeric($slug)) { // ссылка вида http://site.com/page/1 $CI->db->where('page_id', $slug); } else { $CI->db->where('page_slug', $slug); } $CI->db->limit(1); $query = $CI->db->get('page'); if ($query->num_rows() > 0) { $pages = $query->row_array(); $page_view_count = $pages['page_view_count'] + 1; $CI->db->where('page_slug', $slug); $CI->db->update('page', array('page_view_count' => $page_view_count)); $CI->db->cache_delete('page', $slug); return true; } }
<?php if (!defined('BASEPATH')) { exit('No direct script access allowed'); } ?> <div class="admin-h-menu"> <?php # сделаем меню горизонтальное в текущей закладке // основной url этого плагина - жестко задается $plugin_url = $MSO->config['site_admin_url'] . 'sidebars'; // само меню $a = mso_admin_link_segment_build($plugin_url, '', t('Настройки сайдбаров'), 'select') . ' | '; $a .= mso_admin_link_segment_build($plugin_url, 'widgets', t('Настройка виджетов'), 'select'); echo $a; ?> </div> <?php // Определим текущую страницу (на основе сегмента url) $seg = mso_segment(3); // подключаем соответственно нужный файл if ($seg == '') { require $MSO->config['admin_plugins_dir'] . 'admin_sidebars/sidebars.php'; } elseif ($seg == 'widgets') { require $MSO->config['admin_plugins_dir'] . 'admin_sidebars/widgets.php'; }
function calendar_widget_custom($arg = array(), $num = 1) { # массив названий месяцев if (!isset($arg['months'])) { $arg['months'] = array(t('Январь'), t('Февраль'), t('Март'), t('Апрель'), t('Май'), t('Июнь'), t('Июль'), t('Август'), t('Сентябрь'), t('Октябрь'), t('Ноябрь'), t('Декабрь')); } # массив названий дней недели if (!isset($arg['days'])) { $arg['days'] = array(t('Пн'), t('Вт'), t('Ср'), t('Чт'), t('Пт'), t('Сб'), t('Вс')); } # оформление виджета if (!isset($arg['header'])) { $arg['header'] = '<h2 class="box"><span>' . t('Календарь') . '</span></h2>'; } if (!isset($arg['block_start'])) { $arg['block_start'] = '<div class="calendar">'; } if (!isset($arg['block_end'])) { $arg['block_end'] = '</div>'; } if (!isset($arg['elem_previous'])) { $arg['elem_previous'] = '««'; } if (!isset($arg['elem_next'])) { $arg['elem_next'] = '»»'; } $prefs = array('start_day' => 'monday', 'month_type' => 'long', 'day_type' => 'long', 'show_next_prev' => TRUE, 'local_time' => time(), 'next_prev_url' => getinfo('site_url') . 'archive/'); $prefs['template'] = ' {table_open}<table border="0" cellpadding="0" cellspacing="0">{/table_open} {heading_row_start}<tr>{/heading_row_start} {heading_previous_cell}<th><a href="{previous_url}">' . $arg['elem_previous'] . '</a></th>{/heading_previous_cell} {heading_title_cell}<th colspan="{colspan}">{heading}</th>{/heading_title_cell} {heading_next_cell}<th><a href="{next_url}">' . $arg['elem_next'] . '</a></th>{/heading_next_cell} {heading_row_end}</tr>{/heading_row_end} {week_row_start}<tr class="week">{/week_row_start} {week_day_cell}<td>{week_day}</td>{/week_day_cell} {week_row_end}</tr>{/week_row_end} {cal_row_start}<tr>{/cal_row_start} {cal_cell_start}<td>{/cal_cell_start} {cal_cell_content}<a href="{content}">{day}</a>{/cal_cell_content} {cal_cell_content_today}<div class="today-content"><a href="{content}">{day}</a></div>{/cal_cell_content_today} {cal_cell_no_content}{day}{/cal_cell_no_content} {cal_cell_no_content_today}<div class="today">{day}</div>{/cal_cell_no_content_today} {cal_cell_blank} {/cal_cell_blank} {cal_cell_end}</td>{/cal_cell_end} {cal_row_end}</tr>{/cal_row_end} {table_close}</table>{/table_close}'; $CI =& get_instance(); $CI->load->library('calendar', $prefs); $mktime = mktime() + getinfo('time_zone') * 60 * 60; // с учетом часового пояса ? # если это архив, то нужно показать календарь на этот год и месяц if (is_type('archive')) { $year = (int) mso_segment(2); if ($year > date('Y', $mktime) or $year < 2000) { $year = date('Y', $mktime); } $month = (int) mso_segment(3); if ($month > 12 or $month < 1) { $month = date('m', $mktime); } } else { $year = date('Y', $mktime); $month = date('m', $mktime); } # для выделения дат нужно смотреть записи, которые в этом месяце $CI->db->select('page_date_publish'); $CI->db->from('page'); $CI->db->join('page_type', 'page_type.page_type_id = page.page_type_id'); $CI->db->where('page_status', 'publish'); $CI->db->where('page_type_name', 'blog'); $CI->db->where('page_date_publish >= ', mso_date_convert_to_mysql($year, $month)); $CI->db->where('page_date_publish < ', mso_date_convert_to_mysql($year, $month + 1)); # не выводить неопубликованные $CI->db->where('page_date_publish < ', mso_date_convert('Y-m-d H:i:s', date('Y-m-d H:i:s'))); $query = $CI->db->get(); $data = array(); if ($query->num_rows() > 0) { $pages = $query->result_array(); foreach ($pages as $key => $page) { $d = (int) mso_date_convert('d', $page['page_date_publish']); $data[$d] = getinfo('site_url') . 'archive/' . $year . '/' . $month . '/' . $d; } /* $data = array( 3 => 'http://your-site.com/news/article/2006/03/', 7 => 'http://your-site.com/news/article/2006/07/" title="123', 26 => 'http://your-site.com/news/article/2006/26/' ); */ } $out = $CI->calendar->generate($year, $month, $data); $month_en = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); $day_en = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'); $out = str_replace($month_en, $arg['months'], $out); $out = str_replace($day_en, $arg['days'], $out); # если используется английский, то заменим большие названия на маленькие $out = str_replace(array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'), array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'), $out); $out = $arg['header'] . $arg['block_start'] . $out . $arg['block_end']; return $out; }
function range_url_init($arg = array()) { global $MSO; $options = mso_get_option('plugin_range_url', 'plugins', array()); // главное зеркало сайта if (isset($options['siteurl_enable']) and $options['siteurl_enable'] and isset($options['siteurl']) and $options['siteurl']) { if ($MSO->config['site_url'] != $options['siteurl']) { mso_redirect($options['siteurl'] . mso_current_url(), true, 301); } } $current_url = mso_current_url(); // текущий адрес if ($current_url === '') { return $arg; } // главная // отдельно правило для главной // если это home, но без next, то 301-редиректим на главную if (mso_segment(1) == 'home' and mso_segment(2) != 'next') { mso_redirect('', false, 301); } if (!isset($options['templates'])) { $options['templates'] = ''; } $templates = explode("\n", trim($options['templates'])); // разобъем по строкам if (!isset($options['page_404_redirect'])) { $options['page_404_redirect'] = 0; } if (!isset($options['page_404_header'])) { $options['page_404_header'] = 1; } if (!isset($options['default-templates'])) { $options['default-templates'] = true; } if ($options['default-templates']) { // в шаблоны добавим дефолтные адреса array_push($templates, '(page_404)', '(contact)', '(logout)', '(login)', '(password-recovery)', '(loginform)', '(loginform)(*)', '(require-maxsite)', '(require-maxsite)(*)', '(ajax)', '(ajax)(*)', '(remote)', '(sitemap)', '(sitemap)(next)(*)', '(sitemap)(cat)', '(sitemap)(cat)(next)(*)', '(home)(next)(*)', '(category)(*)', '(category)(*)(next)(*)', '(page)(*)', '(page)(*)(next)(*)', '(tag)(*)', '(tag)(*)(next)(*)', '(archive)', '(archive)(*)', '(archive)(*)(next)(*)', '(archive)(*)(*)', '(archive)(*)(*)(next)(*)', '(archive)(*)(*)(*)', '(archive)(*)(*)(*)(next)(*)', '(author)(*)', '(author)(*)(next)(*)', '(users)', '(users)(*)', '(users)(*)(edit)', '(users)(*)(lost)', '(search)(*)', '(search)(*)(next)(*)', '(comments)', '(comments)(*)', '(comments)(*)(next)(*)', '(dc)(*)', '(guestbook)', '(guestbook)(next)(*)', '(gallery)', '(gallery)(*)'); } $templates = mso_hook('range_url', $templates); // можно добавить свои шаблоны url if (!isset($options['min-count-segment'])) { $options['min-count-segment'] = 1; } // минимальное количество сегментов $options['min-count-segment'] = (int) $options['min-count-segment']; if (count(explode('/', $current_url)) <= $options['min-count-segment']) { return $arg; } // адрес имеет менее N сегментов $allow = false; // результат foreach ($templates as $template) { $template = trim($template); if (!$template) { continue; } $reg = str_replace('(*)', '(.[^/]*)', $template); $reg = '~' . str_replace(')(', '){1}/(', $reg) . '\\z~siu'; //pr($current_url); //pr($reg); if (preg_match($reg, $current_url)) { $allow = true; break; } } // pr($allow); if (!$allow) { if ($options['page_404_header']) { @header('HTTP/1.0 404 Not Found'); } if ($options['page_404_redirect']) { mso_redirect('page_404'); } else { $MSO->data['type'] = 'page_404'; } } return $arg; }
<?php if (!defined('BASEPATH')) { exit('No direct script access allowed'); } if (isset($pages[0]['page_categories_detail'])) { // описание рубрики foreach ($pages[0]['page_categories_detail'] as $_cat) { if ($_cat['category_slug'] == mso_segment(2)) { if ($_cat['category_desc']) { echo '<div class="category_desc">' . $_cat['category_desc'] . '</div>'; } break; } } }
if (!defined('BASEPATH')) { exit('No direct script access allowed'); } /** * MaxSite CMS * (c) http://max-3000.com/ */ // для users может быть несколько разных действий в зависимости от сегментов // формируем по ним правильный путь к файлу if (mso_segment(3) == 'edit') { if ($fn = mso_find_ts_file('type/users/units/users-form.php')) { require $fn; return; } } elseif (mso_segment(3) == 'lost') { if ($fn = mso_find_ts_file('type/users/units/users-form-lost.php')) { require $fn; return; } } elseif (mso_segment(2) == '') { if ($fn = mso_find_ts_file('type/users/units/users-all.php')) { require $fn; return; } } else { if ($fn = mso_find_ts_file('type/users/units/users.php')) { require $fn; return; } } # end file
<?php if (!defined('BASEPATH')) { exit('No direct script access allowed'); } echo '<h3 class="category"><a href="' . getinfo('siteurl') . mso_segment(1) . '/' . mso_segment(2) . '/feed">' . tf('Подписаться на эту метку по RSS') . '</a></h3>';
<?php if (!defined('BASEPATH')) { exit('No direct script access allowed'); } /** * MaxSite CMS * (c) http://max-3000.com/ */ if (mso_get_option('category_show_rss_text', 'templates', 1)) { if ($f = mso_page_foreach('tag-show-rss-text')) { require $f; } else { echo mso_get_val('show_rss_text_start', '<p class="mso-show-rss-text">') . '<a href="' . getinfo('siteurl') . mso_segment(1) . '/' . mso_segment(2) . '/feed">' . tf('Подписаться на эту метку по RSS') . '</a>' . mso_get_val('show_rss_text_end', '</p>'); } } # end of file
<?php if (!defined('BASEPATH')) { exit('No direct script access allowed'); } /** * MaxSite CMS * (c) http://max-3000.com/ */ # подготовка данных $min_search_chars = 2; // минимальное кол-во симоволов при поиске $search = mso_segment(2); $search = mso_strip(strip_tags($search)); $searh_to_text = mb_strtolower($search, 'UTF8'); if ($f = mso_page_foreach('search-head-meta')) { require $f; } else { mso_head_meta('title', $search); } $search_len = true; // поисковая фраза более 2 символов // параметры для получения страниц if (!$search or $search_len = strlen(mso_slug($search)) < $min_search_chars) { $search = tf('Поиск'); $pages = false; // нет страниц $categories = false; // нет рубрик $tags = false; // нет меток
mso_redirect('loginform'); } eval(mso_tmpl_ts('type/loginform/units/loginform-user-tmpl.php')); } elseif ($comuser = is_login_comuser()) { if (mso_segment(2) == 'error') { mso_redirect('loginform'); } if (!$comuser['comusers_nik']) { $hello = t('Привет!'); } else { $hello = t('Привет,') . ' ' . $comuser['comusers_nik'] . '!'; } eval(mso_tmpl_ts('type/loginform/units/loginform-comuser-tmpl.php')); } else { $redirect_url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : getinfo('siteurl'); if (mso_segment(2) == 'error') { eval(mso_tmpl_ts('type/loginform/units/loginform-error.php')); } // если разрешена регистрация, то выведем ссылку if (mso_get_option('allow_comment_comusers', 'general', '1')) { $reg = '<a href="' . getinfo('siteurl') . 'registration">' . tf('Регистрация') . '</a> | '; } else { $reg = ''; } $login_form = mso_login_form(array('login' => tf('Логин'), 'password' => tf('Пароль'), 'submit' => '', 'submit_value' => tf('Войти'), 'form_end' => '<div class="mso-loginform-end">' . $reg . '<a href="' . getinfo('siteurl') . 'password-recovery">' . tf('Забыли пароль?') . '</a> | ' . '<a href="' . getinfo('siteurl') . '">' . tf('Вернуться к сайту') . '</a></div>'), $redirect_url, false); eval(mso_tmpl_ts('type/loginform/units/loginform-tmpl.php')); } echo NR . '</div><!-- class="mso-type-loginform" -->' . NR; if ($fn = mso_find_ts_file('main/main-end.php')) { require $fn; }
$f = str_replace('~', '-', $f); $f = str_replace('\\', '-', $f); $f = getinfo('template_dir') . $f; // есть такой файл if (file_exists($f)) { $content_file = file_get_contents($f); $file_path = mso_segment(3); } } // pr(getinfo('template')); // pr($directory); // pr($files); $select = '<option value="" selected>-</option>'; foreach ($files as $file) { if (strpos($file, 'optgroup') === false) { $opt_selected = (mso_segment(3) and base64_encode($file) === mso_segment(3)) ? ' selected' : ''; $select .= '<option value="' . base64_encode($file) . '"' . $opt_selected . '>' . $file . '</option>'; } else { $select .= $file; } } ?> <h1><?php echo t('Файлы для редактирования шаблона') . ' «' . getinfo('template') . '»'; ?> </h1> <p class="mar30-t"><?php echo t('Выберите файл:'); ?>
<?php if (!defined('BASEPATH')) { exit('No direct script access allowed'); } ?> <h1><?php echo t('Логи'); ?> </h1> <?php $q_id = mso_segment(4); if (is_numeric($q_id)) { $CI =& get_instance(); // Получаем название голосования $query = $CI->db->select('q_question')->where('q_id', $q_id)->limit(1)->get('sp_questions'); if ($query->num_rows()) { $row = $query->row(); $edit_url = getinfo('site_url') . 'admin/samborsky_polls/manage/' . $q_id; echo '<h2>' . t('Голосование:') . ' <a href="', $edit_url, '">', $row->q_question, '</a></h2>'; $CI->db->select('sp_logs.*,sp_answers.a_answer'); $CI->db->join('sp_answers', 'sp_answers.a_id = sp_logs.l_aid', 'left'); $CI->db->where('l_qid', $q_id); $query = $CI->db->order_by('l_id', 'asc')->get('sp_logs'); if ($query->num_rows()) { $CI->load->library('table'); $CI->table->clear(); $tmpl = array('table_open' => '<table class="page samborsky_polls_list">', 'row_alt_start' => '<tr class="alt">', 'cell_alt_start' => '<td class="alt">'); $CI->table->set_template($tmpl);
function sape_init($args = array()) { global $SAPE, $SAPE_CONTENT, $SAPE_ARTICLE; $options = mso_get_option('sape', 'plugins', array()); // получаем опции if (isset($options['kod']) and isset($options['go']) and $options['go'] and isset($options['start']) and $options['start']) { // если вкючен античек if (isset($options['anticheck']) and $options['anticheck']) { // анализируем входящий url на предмет ? // если есть, то делаем редирект на то, что до ? // таким образом обнаружить продажную ссылку будет невозможно if (isset($_SERVER['argv']) and $_SERVER['argv']) { $url = $_SERVER['REQUEST_URI']; // /?nono /about/?momo $url = explode('?', $url); if (isset($url[0])) { $url = $url[0]; } else { $url = ''; } $url = '/' . trim(str_replace('/', ' ', $url)); $url = str_replace(' ', '/', $url); $url = 'http://' . $_SERVER['HTTP_HOST'] . $url; header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . $url); exit; } } if (!defined('_SAPE_USER')) { define('_SAPE_USER', $options['kod']); } // если файла сапы нет, то выходим if (!file_exists($_SERVER['DOCUMENT_ROOT'] . '/' . _SAPE_USER . '/sape.php')) { return $args; } require_once $_SERVER['DOCUMENT_ROOT'] . '/' . _SAPE_USER . '/sape.php'; $sa['charset'] = 'UTF-8'; //$sa['fetch_remote_type'] = 'file_get_contents'; // file_get_contents|curl|socket if (isset($options['test']) and $options['test']) { $sa['force_show_code'] = true; } if (isset($options['multi_site']) and $options['multi_site']) { $sa['multi_site'] = true; } $SAPE = new SAPE_client($sa); if (isset($options['context']) and $options['context']) { if (!isset($SAPE_CONTENT)) { $SAPE_CONTENT = new SAPE_context(array('charset' => 'UTF-8')); } mso_hook_add('content_content', 'sape_content'); # хук на конечный текст для вывода if (isset($options['context_comment']) and $options['context_comment']) { mso_hook_add('comments_content_out', 'sape_content'); } # хук на конечный текст для вывода в комментариях } else { $SAPE_CONTENT = false; } if (isset($options['articles']) and $options['articles']) { if (!isset($SAPE_ARTICLE)) { $SAPE_ARTICLE = new SAPE_articles(); } // это вывод рекламной статьи if (isset($options['articles_url']) and mso_segment(1) == $options['articles_url']) { # хук для подключения к шаблону mso_hook_add('custom_page_404', 'sape_articles_custom_page_404'); } // или запрос шаблона от робота сапы if (isset($options['articles_template']) and mso_segment(1) == $options['articles_template']) { # хук для подключения к шаблону mso_hook_add('custom_page_404', 'sape_articles_template_custom_page_404'); } } else { $SAPE_ARTICLE = false; } } return $args; }
return false; }); }); // фоновое сохранение $(function(){ $("#bsave").click(function() { $("div.bsave_result").html("' . t('Сохранение...') . '"); $.post( "' . getinfo('ajax') . base64_encode('admin/plugins/admin_page/bsave-post-ajax.php') . '", { params: $("#form_editor").serialize(), id: ' . (mso_segment(3) ? mso_segment(3) : 0) . ' }, function(data) { // Здесь мы получаем данные, $("div.bsave_result").html(data); } ); }); }); $(function(){ function select_page_type() { var page_type_id = +$(".mso-tabs-box.other input:radio:checked").val(), page_type_obj = ' . $page_type_js_obj . ', page_meta_block = $(".page_meta_block"),
require $f; } else { mso_head_meta('title', mso_segment(2)); // meta title страницы } if (!$pages and mso_get_option('page_404_http_not_found', 'templates', 1)) { header('HTTP/1.0 404 Not Found'); } if ($fn = mso_find_ts_file('main/main-start.php')) { require $fn; } echo NR . '<div class="mso-type-tag"><section>' . NR; if ($f = mso_page_foreach('tag-do')) { require $f; } else { echo '<h1 class="mso-tag">' . htmlspecialchars(mso_segment(2)) . '</h1>'; } if ($pages) { if ($fn = mso_find_ts_file('type/tag/units/tag-do-pages.php')) { require $fn; } if (function_exists('ushka')) { echo ushka('tag-do-pages'); } // цикл вывода в отдельных юнитах if ($full_posts) { if ($fn = mso_find_ts_file('type/tag/units/tag-full.php')) { require $fn; } } else { if ($fn = mso_find_ts_file('type/tag/units/tag-list.php')) {
function mso_view_ini($all = false) { if (!$all) { return ''; } //pr($all); $CI =& get_instance(); $CI->load->library('table'); $tmpl = array('table_open' => '<table class="page "><colgroup style="width: 25%;">', 'row_alt_start' => '<tr class="alt">', 'cell_alt_start' => '<td class="alt">'); $CI->table->clear(); // очистим, если были старые данные $CI->table->set_template($tmpl); // шаблон таблицы // заголовки //$CI->table->set_heading(t('Настройка'), t('Значение')); $table = ''; $out = ''; $nav = ''; // блок навигации // сформируем массив всех опций - ключей $k_where = array(); foreach ($all as $k => $v) { if (isset($v['options_key']) and $v['options_key']) { $k_where[] = $v['options_key']; } } // делаем одним запросов выборку всех опций по этим ключам $CI->db->where_in('options_key', $k_where); $query = $CI->db->get('options'); if ($query->num_rows() > 0) { // есть запись $all_options = $query->result_array(); } else { $all_options = array(); } //pr($all_options); //pr($all); foreach ($all as $key => $row) { if (isset($row['options_key'])) { $options_key = stripslashes(trim($row['options_key'])); } else { continue; } if (!isset($row['options_type'])) { $options_type = 'general'; } else { $options_type = stripslashes(trim($row['options_type'])); } if (!isset($row['type'])) { if ($options_key !== 'none') { $type = 'textfield'; } else { $type = 'none'; } } else { $type = stripslashes(trim($row['type'])); } if (!isset($row['values'])) { $value = ''; } else { $values = _mso_ini_check_php(stripslashes(htmlspecialchars(trim($row['values'])))); } if (!isset($row['description'])) { $description = ''; } else { $description = _mso_ini_check_php(stripslashes(trim(t($row['description'])))); } if (!isset($row['delimer'])) { $delimer = '<br>'; } else { $delimer = stripslashes($row['delimer']); } if (!isset($row['default'])) { $default = ''; } else { $default = _mso_ini_check_php(stripslashes(htmlspecialchars(trim($row['default'])))); } // получаем текущее значение опции из массива $all_options $options_present = false; $value = t($default); // нет значения, поэтому берем дефолт foreach ($all_options as $v) { if ($v['options_type'] == $options_type and $v['options_key'] == $options_key) { $value = htmlspecialchars($v['options_value']); $options_present = true; // признак, что опция есть в базе break; } } $f = NR; // тип none не создает поля - фиктивная опция if ($options_key != 'none') { $name_f = 'f_options[' . $options_key . '_m_s_o_' . $options_type . ']'; } else { $name_f = ''; } if ($type == 'textfield') { $value = str_replace('_QUOT_', '"', $value); // в этом типе может быть свой type для input if (!isset($row['textfield_type'])) { $textfield_type = 'text'; } else { $textfield_type = stripslashes($row['textfield_type']); } $f .= '<input type="' . $textfield_type . '" name="' . $name_f . '" value="' . $value . '">' . NR; } elseif ($type == 'color') { $f .= mso_load_jquery('jscolor.js', getinfo('common_url') . 'jquery/jscolor/'); $f .= '<input type="text" name="' . $name_f . '" value="' . $value . '" class="color">' . NR; } elseif ($type == 'textarea') { $value = str_replace('_NR_', "\n", $value); $value = str_replace('_QUOT_', '"', $value); if (!isset($row['rows'])) { $rr = 7; } else { $rr = (int) $row['rows']; } $f .= '<textarea rows="' . $rr . '" name="' . $name_f . '">' . $value . '</textarea>' . NR; } elseif ($type == 'checkbox') { if ($value) { $checked = 'checked="checked"'; } else { $checked = ''; } $f .= '<label><input type="checkbox" name="' . $name_f . '" ' . $checked . '> ' . t($key) . '</label>' . NR; $f .= '<input type="hidden" name="f_all_checkbox[' . $options_key . '_m_s_o_' . $options_type . ']">' . NR; } elseif ($type == 'multicheckbox') { $mr = $value; // отмеченные пункты - массив в виде стандартного option if ($mr) { // служебные замены $mr = str_replace('&', '&', $mr); $mr = str_replace('"', '"', $mr); if (preg_match('|_serialize_|A', $mr)) { $mr = preg_replace('|_serialize_|A', '', $mr, 1); $mr = @unserialize($mr); } if (!is_array($mr)) { $mr = array($mr); } } else { $mr = array(); } // $mr теперь массив! $values = explode('#', $values); if ($values) { foreach ($values as $val) { $ar = explode('||', $val); if (isset($ar[0])) { $mr1 = trim($ar[0]); } // ключ чекбокса if (isset($ar[1])) { $mr2 = trim($ar[1]); } else { $mr2 = $mr1; } if (in_array($mr1, $mr)) { $checked = 'checked="checked"'; } else { $checked = ''; } //для каждого чекбокса свой ключ! $mkey = $options_key . '_' . mso_slug($mr1) . '_m_s_o_' . $options_type; $name_f1 = 'f_options[' . $mkey . ']'; $f .= '<label><input type="checkbox" name="' . $name_f . '[]" value="' . $mr1 . '" ' . $checked . '> ' . t($mr2) . '</label>' . $delimer . NR; } $f .= '<input type="hidden" name="f_all_checkbox[' . $options_key . '_m_s_o_' . $options_type . ']">' . NR; } } elseif ($type == 'radio') { $values = explode('#', $values); // все значения разделены # if ($values) { foreach ($values as $val) { $ar = explode('||', $val); if (isset($ar[0])) { $mr1 = trim($ar[0]); } // ключ if (isset($ar[1])) { $mr2 = trim($ar[1]); } else { $mr2 = $mr1; } if ($value == trim($mr1)) { $checked = 'checked="checked"'; } else { $checked = ''; } // преобразование в html $mr2 = str_replace('_QUOT_', '"', $mr2); $mr2 = str_replace('<', '<', $mr2); $mr2 = str_replace('>', '>', $mr2); $f .= '<label><input type="radio" name="' . $name_f . '" value="' . $mr1 . '" ' . $checked . '> ' . t($mr2) . '</label>' . $delimer . NR; } } } elseif ($type == 'select') { $values = explode('#', $values); // все значения разделены # if ($values) { $f .= '<select name="' . $name_f . '">'; foreach ($values as $val) { // $val может быть с || val - текст $val = trim($val); $val_t = $val; $ar = explode('||', $val); if (isset($ar[0])) { $val = trim($ar[0]); } if (isset($ar[1])) { $val_t = trim($ar[1]); } if ($value == $val) { $checked = 'selected="selected"'; } else { $checked = ''; } $f .= NR . '<option value="' . $val . '" ' . $checked . '>' . t($val_t) . '</option>'; } $f .= NR . '</select>' . NR; } } if ($description) { $f .= '<p><em>' . t($description) . '</em></p>'; } if ($options_key != 'none') { if (!$options_present) { $key = '<span title="' . $options_key . ' (' . $row['options_type'] . ')" class="mso-alert">* ' . t($key) . '</span>'; } else { $key = '<strong title="' . $options_key . ' (' . $row['options_type'] . ')">' . t($key) . '</strong>'; } } else { $key = ''; } // если есть новая секция, то выводим пустую инфо-строчку if (isset($row['section'])) { if ($CI->table->rows) { $table .= $CI->table->generate(); } $CI->table->clear(); // очистим, если были старые данные $tmpl['table_open'] = NR . '<table class="page page-responsive section_' . mso_slug($row['section']) . '"><colgroup style="width: 25%;">'; $CI->table->set_template($tmpl); // шаблон таблицы if (isset($row['section_description'])) { $CI->table->add_row(array('class' => 'section', 'colspan' => 2, 'data' => '<a id="a-' . mso_slug($row['section']) . '"></a><h2 class="section">' . t($row['section']) . '</h2><p>' . t($row['section_description']) . '</p>')); } else { $CI->table->add_row(array('class' => 'section', 'colspan' => 2, 'data' => '<a id="a-' . mso_slug($row['section']) . '"></a><div class="section"><h2>' . t($row['section']) . '</h2></div>')); } $nav .= '<a href="#a-' . mso_slug($row['section']) . '" id="' . mso_slug($row['section']) . '">' . t($row['section']) . '</a> '; } if ($key) { $CI->table->add_row($key, $f); } } if ($CI->table->rows) { $table .= $CI->table->generate(); } // последняя генерация $out .= '<form action="' . mso_current_url(true) . '" method="post">' . mso_form_session('f_session_id'); $out .= '<a id="atop"></a><input type="hidden" value="1" name="f_ini">'; // доп. поле - индикатор, что это ini-форма if ($nav) { $out .= '<p class="nav">' . str_replace(' ', '<span class="sep"></span>', trim($nav)) . '</p>'; } $out .= $table; // вывод подготовленной таблицы $out .= NR . '<a id="abottom"></a><button type="submit" name="f_submit" class="mso-save-ini i-save">' . t('Сохранить') . '</button>'; $out .= '</form>'; $out .= mso_load_jquery('jquery.cookie.js') . "\r\n<script>\r\n\t\$(function()\r\n\t{\r\n\t\t\$('table.page').hide();\r\n\r\n\t\tvar NameCookie = 'curSection_" . mso_segment(2) . "',\r\n\t\tcookieIndex = \$.cookie(NameCookie);\r\n\r\n\t\tif (cookieIndex != null && \$('table').is('.section_'+cookieIndex)) // есть кука и есть соответсвующая ей таблица\r\n\t\t{\r\n\t\t\t\$('table.section_'+cookieIndex).show();\r\n\t\t\t\$('#'+cookieIndex).addClass('current');\r\n\t\t}\r\n\t\telse // если нет куки или соответвующей таблицы\r\n\t\t{\r\n\t\t\t\$('table.page:first').show(); // показывем только первую таблицу\r\n\t\t\t\$('p.nav a:first').addClass('current'); // к первому пункту навигации добавляем класс\r\n\t\t}\r\n\r\n\t\t\$('p.nav a').click(function(){\r\n\t\t\tvar id = \$(this).attr('id');\r\n\t\t\t\$('table.page').hide();\r\n\r\n\t\t\t\$(this).addClass('current').siblings().removeClass(); // добавляем класс на кликнутый пункт, а у всех соседних удаляем\r\n\t\t\t\$('table.section_'+id).show();\r\n\t\t\t\$.cookie(NameCookie, id, {expires: 30, path: '/'});\r\n\t\t\treturn false;\r\n\t\t});\r\n\t});\r\n</script>"; return $out; }
<?php if (!defined('BASEPATH')) { exit('No direct script access allowed'); } $CI =& get_instance(); $f_all_comments = false; // только неразрешенные комментарии if (mso_segment(3) == 'all') { $f_all_comments = true; } elseif (mso_segment(3) == 'moderation') { $f_all_comments = false; } require_once getinfo('common_dir') . 'comments.php'; // функции комментариев # разрешить или запретить if ($post = mso_check_post(array('f_session_id', 'f_check_comments')) and (isset($_POST['f_aproved_submit']) or isset($_POST['f_unaproved_submit']))) { mso_checkreferer(); $action = '0'; // запретить по-умолчанию if (isset($post['f_aproved_submit'])) { $action = '1'; } // разрешить $f_check_comments = $post['f_check_comments']; // номера отмеченных // на всякий случай пройдемся по массиву и составим массив из ID $arr_ids = array(); // список всех где ON foreach ($f_check_comments as $id_com => $val) { if ($val) {