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; }
$comments_date = $row['comments_date']; $author = ''; if ($row['comments_users_id']) { $author = '<span class="admin">' . $row['users_nik'] . '</span>'; } elseif ($row['comments_comusers_id']) { $author = '<span class="comuser">' . $row['comusers_nik'] . '</span> (' . t('комюзер') . ' ' . $row['comments_comusers_id'] . ')'; } else { if (!$row['comments_author_name']) { $row['comments_author_name'] = t('Аноним'); } $author = '<span class="anonymous">' . $row['comments_author_name'] . '</span> (' . t('анонимно') . ')'; } $page_slug = $row['page_slug']; $page_title = '<a target="_blank" href="' . $view_url . $page_slug . '#comment-' . $id . '">«' . htmlspecialchars($row['page_title']) . '»</a>'; // определим XSS и визуально выделим такой комментарий $comments_content_xss_start = mso_xss_clean($row['comments_content'], '<span style="color: red">XSS!!! ', ''); if ($comments_content_xss_start) { $comments_content_xss_end = '</span>'; } else { $comments_content_xss_end = ''; } $comments_content = htmlspecialchars($row['comments_content']); $comments_content = str_replace('<p>', '<br>', $comments_content); $comments_content = str_replace('</p>', '', $comments_content); $comments_content = str_replace('<br />', '<br>', $comments_content); if (mb_strlen($comments_content, 'UTF-8') > 300) { $comments_content = mb_substr($comments_content, 0, 300, 'UTF-8') . ' ...'; } if ($row['comments_approved'] > 0) { $comments_approved = '+'; } else {
$options['real_title'] = 1; } // выводить в title реальный адрес $form = ''; $form .= '<h2>' . t('Настройки') . '</h2>'; $form .= '<p><strong>' . t('Файл для хранения количества скачиваний:') . '</strong><br>' . getinfo('uploads_dir') . ' <input name="f_file" type="text" class="w200px value="' . $options['file'] . '"></p>'; $form .= '<p><strong>' . t('Префикс URL:') . '</strong> ' . getinfo('siteurl') . ' <input name="f_prefix" type="text" class="w100px" value="' . $options['prefix'] . '">/' . t('ссылка') . '</p>'; $form .= '<p><strong>Формат количества переходов:</strong><br><input name="f_format" type="text" value="' . htmlspecialchars($options['format']) . '"></p>'; $chk = $options['referer'] ? ' checked="checked" ' : ''; $form .= '<p><label><input name="f_referer" type="checkbox" ' . $chk . '> <strong>' . t('Запретить переходы с чужих сайтов') . '</strong></label></p>'; $chk = $options['real_title'] ? ' checked="checked" ' : ''; $form .= '<p><label><input name="f_real_title" type="checkbox" ' . $chk . '> <strong>' . t('Выводить в title реальный адрес') . '</strong></label></p>'; echo '<form method="post">' . mso_form_session('f_session_id'); echo $form; echo '<button type="submit" name="f_submit" class="i save">' . t('Сохранить изменения') . '</button>'; echo '</form>'; // выведем ниже формы всю статистику // массив данных: url => array ( count=>77 ) $data = down_count_get_data(); if ($data) { $CI->load->library('table'); $tmpl = array('table_open' => '<table class="page tablesorter">', 'row_alt_start' => '<tr class="alt">', 'cell_alt_start' => '<td class="alt">'); $CI->table->set_template($tmpl); $CI->table->set_heading('URL', t('переходов')); echo '<br><h2>' . t('Статистика переходов') . '</h2>'; foreach ($data as $url => $aaa) { $CI->table->add_row(htmlspecialchars(mso_xss_clean($url)), $data[$url]['count']); } echo $CI->table->generate(); } # end of file
function mso_redirect($url = '', $absolute = false, $header = false) { global $MSO; $url = strip_tags($url); $url = str_replace(array('%0d', '%0a'), '', $url); $url = mso_xss_clean($url); if ($header == 301) { header('HTTP/1.1 301 Moved Permanently'); } elseif ($header == 302) { header('HTTP/1.1 302 Found'); } if ($absolute) { header("Refresh: 0; url={$url}"); header("Location: {$url}"); } else { $url = $MSO->config['site_url'] . $url; header("Refresh: 0; url={$url}"); header("Location: {$url}"); } exit; }
function mso_email_message_new_comment_subscribe($data) { /* Array ( [comments_page_id] => 153 - id страницы [comments_content] => sdafsadfsdaf - текст комментария [comments_approved] => - если 0, то отправки нет [page_title] => тест - заголовок страницы [id] => 607 - id комментария -- [comments_comusers_id] => 1 - номер комюзера - пока не используется -- [comments_date] => 2009-12-10 20:45:39 - дата - пока не используется -- [comments_author_ip] => 127.0.0.1 - ip - пока не используется ) */ # Опция не рассылать подписку. if (!mso_get_option('allow_comments_subscribe', 'general', 1)) { return; } // комментарий не одобрен, не отсылаем if ($data['comments_approved'] == 0) { return; } // разослать нужно всем комюзерам у которых стоит получение уведомления о новом комментарии $CI =& get_instance(); $comusers_all = mso_get_comusers_all(); // все комюзеры $from = mso_get_option('admin_email_server', 'general', ''); $subject = '[' . getinfo('name_site') . '] ' . tf('Новый комментарий к') . ' "' . $data['page_title'] . '"'; $message = tf('Новый комментарий к') . ' "' . $data['page_title'] . '"' . NR . NR; $message .= tf('Текст:') . NR . mso_xss_clean($data['comments_content']); $message .= NR . NR . tf('Перейти к комментарию на сайте:') . NR . mso_get_permalink_page($data['comments_page_id']) . '#comment-' . $data['id'] . NR; foreach ($comusers_all as $comuser) { // отправлять на все комментарии сайта $subscribe_other_comments = (isset($comuser['meta']['subscribe_other_comments']) and $comuser['meta']['subscribe_other_comments']) ? true : false; // только на свой $subscribe_my_comments = (isset($comuser['meta']['subscribe_my_comments']) and $comuser['meta']['subscribe_my_comments']) ? true : false; if ($subscribe_other_comments or $subscribe_my_comments and isset($comuser['comments_pages_id'][$data['comments_page_id']])) { // можно отправлять if (mso_valid_email($comuser['comusers_email'])) { $data = array_merge($data, array('subscription' => true)); //А здесь для smtp_mail важно знать, чтобы запретить сохранять мыло в файл. $res = mso_mail($comuser['comusers_email'], $subject, $message, $from, $data); if (!$res) { break; } // ошибка отправки почты - рубим цикл } } } }
if ($users->num_rows() > 0) { $out .= '<optgroup label="' . t('Авторы') . '">' . NR; foreach ($users->result_array() as $user) { $out .= '<option value="1-' . $user['users_id'] . '"' . ($row['comments_users_id'] == $user['users_id'] ? ' selected="selected"' : '') . '>' . $user['users_nik'] . '</option>' . NR; } $out .= '</optgroup>' . NR; } $CI->db->select('comusers_id , comusers_nik '); $users = $CI->db->get('comusers'); if ($users->num_rows() > 0) { $out .= '<optgroup label="' . t('Комментаторы') . '">' . NR; foreach ($users->result_array() as $user) { if (!$user['comusers_nik']) { $user['comusers_nik'] = '! ' . t('Комментатор') . ' ' . $user['comusers_id']; } $user['comusers_nik'] = mso_xss_clean($user['comusers_nik']); $out .= '<option value="2-' . $user['comusers_id'] . '"' . ($row['comments_comusers_id'] == $user['comusers_id'] ? ' selected="selected"' : '') . '>' . $user['comusers_nik'] . '</option>' . NR; } $out .= '</optgroup>' . NR; } $out .= '</select></p>' . NR; echo t('<p>Выберите пользователя или комментатора, которого вы хотите назначить автором комментария, либо выберите «Аноним» и введите имя анонимного комментатора.</p>') . $out; $checked1 = $checked2 = ''; if ($row['comments_approved']) { $checked1 = 'checked="checked"'; } else { $checked2 = 'checked="checked"'; } echo '<h3>' . t('Модерация') . '</h3><p><label><input type="radio" name="f_comments_approved" value="1" ' . $checked1 . '> ' . t('Одобрить') . '</label> <label><input type="radio" name="f_comments_approved" value="0" ' . $checked2 . '> ' . t('Запретить') . '</label></p>'; echo '<p><input type="hidden" name="f_comments_email_subscribe" value="0"><label><input type="checkbox" name="f_comments_email_subscribe" value="1" ' . $checked2 . '> ' . t('Сразу разослать подписчикам') . '</label></p>'; echo '<p class="br"><input type="submit" name="f_submit" value="' . t('Готово') . '">' . ' <input type="submit" name="f_submit_delete" onClick="if(confirm(\'' . t('Уверены?') . '\')) {return true;} else {return false;}" value="' . t('Удалить комментарий') . '">' . '</p>';
function down_count_init($args = array()) { # опции плагина $options = mso_get_option('plugin_down_count', 'plugins', array()); if (!isset($options['prefix'])) { $options['prefix'] = 'dc'; } if (mso_segment(1) == $options['prefix'] and mso_segment(2)) { if (!isset($options['referer'])) { $options['referer'] = 1; } // запретить скачку с чужих сайтов if ($options['referer']) { // если нет реферера, то рубим if (!isset($_SERVER['HTTP_REFERER'])) { // die(sprintf('<b><font color="red">' . t('Данная ссылка доступна только со <a href="%s">страниц сайта</a>') . '</font></b>', getinfo('siteurl'))); } // проверяем реферер - откуда пришел $p = parse_url($_SERVER['HTTP_REFERER']); if (isset($p['host'])) { $p = $p['host']; } else { $p = ''; } if ($p != $_SERVER['HTTP_HOST']) { // чужой сайт die('<b><font color="red">' . t('Запрещен переход по этой ссылке с чужого сайта') . '</font></b>'); } } // это редирект на указанный в сегментах url $url = base64_decode(mso_segment(2)); // декодируем // проверяем входящий url // в нем может быть закодирована какая-то гадость $url_check = mso_xss_clean($url); if ($url_check != $url) { die('<b><font color="red">Achtung! XSS attack!</font></b>'); } $url = $url_check; // получим данные $data = down_count_get_data(); // вноисм изменения if (isset($data[$url])) { // такой url уже есть $data[$url]['count'] = $data[$url]['count'] + 1; } else { // нет еще $data[$url]['count'] = 1; } // записываем один переход // сохраняем в файл down_count_save_data($data); mso_redirect($url, true); exit; } return $args; }