$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 down_count_content_callback($matches) { //'|\[dc\]<a(.*?)href="(.*?)"(.*?)>(.*?)</a>\[/dc\]|ui'; // ститик, чтобы не получать каждый раз опции static $prefix, $format, $real_title; if (!isset($prefix) or !isset($format) or !isset($real_title)) { $options = mso_get_option('plugin_down_count', 'plugins', array()); if (!isset($options['prefix'])) { $options['prefix'] = 'dc'; } $prefix = $options['prefix']; if (!isset($options['format'])) { $options['format'] = ' <sup title="' . t('Количество переходов') . '">%COUNT%</sup>'; } $format = $options['format']; if (!isset($options['real_title'])) { $options['real_title'] = 1; } $real_title = $options['real_title']; } $data = down_count_get_data(); // получаем массив из файла, в котором ведется подсчет колва переходов if (isset($data[$matches[2]]['count'])) { $count = $data[$matches[2]]['count']; } else { $count = 0; } $url = base64_encode($matches[2]); // кодируем урл в одну строку $url = getinfo('siteurl') . $prefix . '/' . $url; $format_out = str_replace('%COUNT%', $count, $format); $matches[1] = str_replace('%COUNT%', $count, $matches[1]); $matches[3] = str_replace('%COUNT%', $count, $matches[3]); $title = $real_title ? ' title="' . $matches[2] . '" ' : ' '; $out = '<a' . $matches[1] . 'href="' . $url . '"' . $title . $matches[3] . '>' . $matches[4] . '</a>' . $format_out; return $out; }