<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Strawberry форум &mdash; Дополнения: готовые]]></title>
	<link rel="self" href="http://strawberry.goodgirl.ru/forum/feed/atom/forum/10/"/>
	<updated>2011-12-07T11:28:42Z</updated>
	<generator>PunBB</generator>
	<id>http://strawberry.goodgirl.ru/forum/</id>
		<entry>
			<title type="html"><![CDATA[RedirectLinks 1.0]]></title>
			<link rel="alternate" href="http://strawberry.goodgirl.ru/forum/topic/4184/new/posts/"/>
			<summary type="html"><![CDATA[<p>Все внешние ссылки в постах через редирект: <a href="http://icestrawberry.workshop200.com/downloads/oform.html">http://icestrawberry.workshop200.com/do … oform.html</a></p><p>Совместимость: IceStrawberry, Strawberry 1.1.1</p><div class="codebox"><pre><code>&lt;?php
/**
 * @package Plugins
 */

/*
Plugin Name:     RedirectLinks
Plugin URI:     http://icestrawberry.workshop200.com/
Description:     Ссыдки через редирект (файл go.php надо положить в корень сайта)
Version:         1.0
Application:     Strawberry
Author:         cmd
Author URI:     http://icestrawberry.workshop200.com/
*/


/**
 * @access private
 */
add_filter(&#039;news-entry-content&#039;, &#039;replace_url&#039;);

function replace_url( $content, $hook ) {
    
    $content = stripslashes($content);
    
    $pattern = &#039;/&lt;a(.*?)href=[\&quot;\&#039;]([a-z0-9]+)\:\/\/(.*?)\/?[\&quot;\&#039;](.*?)&gt;(.*?)&lt;\/a&gt;/i&#039;;
    
    $content = preg_replace_callback( $pattern, &#039;text_unurl_bad&#039;, $content );
    
    return $content;
}

function text_unurl_bad( $text ) {
    if (strpos($text[3], $_SERVER[&#039;HTTP_HOST&#039;]) === false) {
        return &#039;&lt;a &#039; . $text[1] . &#039;href=&quot;/go.php?url=&#039; . $text[2] . &#039;://&#039; . $text[3] .&#039;&quot; &#039; . $text[4] . &#039;&gt;&#039; . $text[5] . &#039;&lt;/a&gt;&#039;;
    } else {
        return &#039;&lt;a &#039; . $text[1] . &#039;href=&quot;&#039; . $text[2] . &#039;://&#039; . $text[3] .&#039;&quot; &#039; . $text[4] . &#039;&gt;&#039; . $text[5] . &#039;&lt;/a&gt;&#039;;
    }
    
}
?&gt;</code></pre></div>]]></summary>
			<author>
				<name><![CDATA[cmd]]></name>
				<uri>http://strawberry.goodgirl.ru/forum/user/1313/</uri>
			</author>
			<updated>2011-12-07T11:28:42Z</updated>
			<id>http://strawberry.goodgirl.ru/forum/topic/4184/new/posts/</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Similar news addon for Strawberry 1.1.1]]></title>
			<link rel="alternate" href="http://strawberry.goodgirl.ru/forum/topic/4138/new/posts/"/>
			<summary type="html"><![CDATA[<p><em><strong>Дополнение &quot;Похожие новости&quot; для Strawberry 1.1.1</strong></em><br />v.1.0 <a href="http://strawberry.goodgirl.ru/forum/misc.php?item=109&amp;download=0">similar-news_1_0.zip (1.54 kb)</a><br />v.1.1 (<a href="http://strawberry.goodgirl.ru/forum/user/1313/">cmd</a> edition) <a href="http://strawberry.goodgirl.ru/forum/misc.php?item=110&amp;download=0">similar-news_1_1.zip (1.64 kb)</a></p><p><strong>Описание:</strong><br />Выводит $sn_number похожих новостей. Похожесть определяется максимальным количеством совпадающих тэгов (ключевых слов). Работает совместно с плагином keywords.</p><p>Довольно простой метод вывода &quot;новостей по теме&quot; для текущей новости <a href="http://strawberry.goodgirl.ru/docs/additions.html#Keywords">описан в доках</a>. Чем он плох? Да там же в доках все и написано: <em>&quot;Вы пишите новость, указываете кейворды &quot;Путин&quot;, &quot;А лох-то кто?&quot; и &quot;Киркоров&quot;. Все другие новости, которым присвоен кейворд &quot;Киркоров&quot; являются &quot;по теме&quot;.</em> Т.е. в &quot;похожие&quot; новости попадают все, у которых совпадает хотя бы один кейворд, а сортировка идет по дате. В общем релевантность таких новостей оставляет желать лучшего. Дополнение Similar News выводит список действительно похожих новостей, отсортированных сначала по максимальному количеству совпадающих ключевых слов, а затем по дате.</p><p><strong>Использование:</strong><br /><strong>1. </strong>Это дополнение, а не плагин, поэтому распаковываем содержимое архива непосредственно в директорию Strawberry (не в plugins!).<br /><strong>2. </strong>После вывода полной новости пишем нечто вроде:<br /></p><div class="codebox"><pre><code>echo &#039;&lt;hr&gt;&lt;b&gt;Новости по теме:&lt;/b&gt;&lt;br /&gt;&#039;;
$sn_number = 5;
include_once rootpath.&#039;/similar-news.php&#039;;</code></pre></div><p><strong>Changelog:</strong><br /><strong>v.1.1</strong>: <br />* переписана функция, выполняющая запрос к базе данных (by <a href="http://strawberry.goodgirl.ru/forum/user/1313/">cmd</a>), в результате быстродействие увеличилось на 40%.</p><p><strong>v.1.0</strong>: <br />первая версия Similar News.</p><br /><p><strong>Примечания:</strong><br /><strong>1. </strong>Озабоченные вопросом производительности могут ознакомиться с <a href="http://strawberry.goodgirl.ru/forum/post/18359/#p18359">результатами профайлинга для v.1.0</a> (для v.1.1 все <a href="http://strawberry.goodgirl.ru/forum/post/18366/#p18366">еще быстрее</a>).<br /><strong>2. </strong>Особо параноидальные обладатели high-load проектов, не обремененных использованием ЧПУ, могут закомментировать строку</p><div class="codebox"><pre><code>echo &#039;&lt;a href=&quot;&#039;.cute_get_link($news_by_repeat[$snc]).&#039;&quot;&gt;&#039;.$news_by_repeat[$snc][&#039;title&#039;].&#039;&lt;/a&gt;&lt;br /&gt;&#039;; // медленно, но верно</code></pre></div><p> и раскомментировать следующую за ней.</p>]]></summary>
			<author>
				<name><![CDATA[Zomb1e]]></name>
				<uri>http://strawberry.goodgirl.ru/forum/user/6312/</uri>
			</author>
			<updated>2011-09-15T09:24:57Z</updated>
			<id>http://strawberry.goodgirl.ru/forum/topic/4138/new/posts/</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Twitter plugin for Strawberry 1.1.1]]></title>
			<link rel="alternate" href="http://strawberry.goodgirl.ru/forum/topic/4134/new/posts/"/>
			<summary type="html"><![CDATA[<p><em><strong>Twitter plugin for Strawberry 1.1.1</strong></em><br />v.1.0 <a href="http://strawberry.goodgirl.ru/forum/misc.php?item=107&amp;download=0">twitter_plugin_1_0.zip (8.98 kb)</a><br />v.1.1 <a href="http://strawberry.goodgirl.ru/forum/misc.php?item=108&amp;download=0">twitter_plugin_1_1.zip (9.43 kb)</a></p><p><strong>Описание:</strong><br />Постит анонс новости в Twitter в формате &quot;Заголовок_новости URL_новости&quot;. Вместо заголовка будет использовано содержимое текстового поля, если оно заполнено. Аутенификация через oAuth (доступ к API через пару логин-пароль на Twittere прикрыли в сентябре 2010 года). Для ЧПУ реализована работа с сервисом укорачивания ссылок bit.ly</p><p><strong>Установка:</strong><br /><strong>1.</strong> Заходим на <a href="https://dev.twitter.com/apps/new">https://dev.twitter.com/apps/new</a> и регистрируем новое приложение. Обязательно нужно заполнить поле &quot;Callback URL&quot;, можно использовать заглушку (несуществующую страницу), как любезно подсказывает Twitter, а можно просто вбить адрес главной страницы сайта. &quot;Access&quot; устанавливаем как минимум &quot;Read and Write&quot;.<br /><strong>2.</strong> Получаем Consumer key, Consumer secret, Access token и Access token secret.<br /><strong>3.</strong> Распаковываем содержимое архива в папку plugins на сервере.<br /><strong>4.</strong> Настраеваем twitter.php:<br /><strong>&nbsp; &nbsp; 4.1.</strong> Устанавливаем длину URL&#039;а новости в константе POST_URL_LENGTH (по умолчанию 38), для ЧПУ необходимо использовать сервисы укорачивания ссылок.<br /><strong>&nbsp; &nbsp; 4.2.</strong> Полученные на втором шаге пары ключей и токенов записываем в переменные $consumer_key, $consumer_secret, $token, $secret.<br /><strong>&nbsp; &nbsp; 4.3.</strong> Только для ЧПУ: устанавливаем значение константы USE_BITLY в true, в строке 41 формируем URL новости, в строке 47 вписываем свой логин и API key для bit.ly<br /><strong>5.</strong> Включаем плагин в админке.</p><p><strong>Changelog:</strong><br /><strong>v.1.1</strong> (12.09.2011):<br />+ добавлено &quot;умное&quot; укорачивание заголовка новости, если он длиннее, чем ему положено быть;<br />+ добавлена возможность использования сервиса укорачивания ссылок bit.ly (актуально для ЧПУ).</p><p><strong>v.1.0</strong> (07.09.2011): первая версия плагина.</p><br /><p><strong>Чего нет в крайней версии:</strong><br /><strong>1.</strong> Бросаются, но не обрабатываются исключения, полученные в случае ошибок от API Twitter&#039;a - для этого пришлось бы допиливать addnews.mdu, и был бы уже не плагин, а хак (потерялось бы удобство установки).<br /><strong>2.</strong> Нет счетчика введенных/оставшихся символов в текстовом поле, как это сделано в тви-интерфейсе (ибо я не дружу с prototype&#039;ом, а он, в свою очередь, не дружит с jquery).</p><p><strong>PS:</strong> объясните мне кто-нибудь, зачем в addnews.mdu экшн new-save-entry вызывается дважды? (пока это заметил, весь мозг себе поломал в попытках выяснить, почему сервер возвращал код 500)</p>]]></summary>
			<author>
				<name><![CDATA[Zomb1e]]></name>
				<uri>http://strawberry.goodgirl.ru/forum/user/6312/</uri>
			</author>
			<updated>2011-09-07T13:08:48Z</updated>
			<id>http://strawberry.goodgirl.ru/forum/topic/4134/new/posts/</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Плагин меню]]></title>
			<link rel="alternate" href="http://strawberry.goodgirl.ru/forum/topic/4125/new/posts/"/>
			<summary type="html"><![CDATA[<p>Что умеет плагин:<br />- Использовать в качестве пунктов меню как отдельные страницы так и категории<br />- Создавать многоуровневые меню<br />- Временно прятать отдельные пункты меню<br />- Указывать id для каждого пункта меню<br />- Сортировать пункты меню по полю order<br />- При удалении родительского пункта меню детки перемещаются на один уровень вверх.</p><p>Как работает плагин: <br />Плагин работает через отдельную таблицу menu. В идеале там 2 запроса к БД (1) прочитать таблицу menu (2) прочитать нужные строки из таблицы news для генерации правильных url&#039;ов. Кроме того, плагин многократно перелопачивает массивы... Кеш ещё не реализован.</p><p>В head.php добавить в самый конец:<br /></p><div class="codebox"><pre><code>if (plugin_enabled(&#039;menu.php&#039;)) {
//ДОСТАЕМ ИЗ БАЗЫ ДАННЫЕ ПРО МЕНЮ И ПРЕОБРАЗУЕМ ИХ В ДЕРЕВОВИДНЫЙ МАССИВ
$menu = array();
$menu_array = array();
$array_for_menu = array();
$menu = $sql-&gt;select(array(&#039;table&#039; =&gt; &#039;menu&#039;, &#039;orderby&#039; =&gt; array (&#039;order&#039;,&#039;ASC&#039;)));
$menu_array = transform_array_2_list($menu, &#039;id&#039;, &#039;parentid&#039;);    
// СОЗДАЕМ МАССИВ ДЛЯ МЕНЮ    
$array_for_menu = get_array_4_menu($menu); 
}</code></pre></div><p>В папке плагинов создать menu.php (<a href="http://strawberry.goodgirl.ru/forum/misc.php?item=106&amp;download=0">скачать файл</a>)<br /></p><div class="codebox"><pre><code>&lt;?php
/**
 * @package Plugins
 * @access private
 */

/*
Plugin Name:    Menu
Plugin URI:     
Description:    Плагин умеет создавать меню.
Version:         0.3
Application:     Strawberry
Author:         cmd
Author URI:     workshop200.com
*/

add_filter(&#039;options&#039;, &#039;menu_link&#039;);
function menu_link($options) {
global $PHP_SELF;
    $lang[&#039;regmod&#039;] = cute_lang(&#039;plugins/registration&#039;);

    $options[] = array(
        &#039;name&#039;        =&gt; &#039;Менеджер меню&#039;,
        &#039;url&#039;        =&gt; &#039;plugin=control_menu&#039;,
        &#039;category&#039;    =&gt; &#039;tools&#039;,
    );

    return $options;
}

add_action(&#039;plugins&#039; ,&#039;get_control_menu&#039;);
  
function get_control_menu(){

    if ($_GET[&#039;plugin&#039;] == &#039;control_menu&#039; and !$_GET[&#039;loadlist&#039;] and !$_POST[&#039;action&#039;] and !$_GET[&#039;load_menu_list&#039;] and !$_GET[&#039;delmenu&#039;]){
        control_menu();
        return true;
    }
    if ($_GET[&#039;plugin&#039;] == &#039;control_menu&#039; and $_GET[&#039;loadlist&#039;]){
        loadlist_ajax($_GET[&#039;loadlist&#039;]);
        return true;    
    }
    if ($_GET[&#039;plugin&#039;] == &#039;control_menu&#039; and $_GET[&#039;delmenu&#039;]){
        del_menu_position($_GET[&#039;delmenu&#039;]);
        return true;    
    }
    if ($_GET[&#039;plugin&#039;] == &#039;control_menu&#039; and $_GET[&#039;load_menu_list&#039;]) {
        load_menu_list($_GET[&#039;load_menu_list&#039;]);
    }
    if ($_GET[&#039;plugin&#039;] == &#039;control_menu&#039; and $_POST[&#039;action&#039;] == &#039;add_new_position&#039;){    
        add_new_position();
        return true;
    }
    if ($_GET[&#039;plugin&#039;] == &#039;control_menu&#039; and $_POST[&#039;action&#039;] == &#039;edit_position&#039;){    
        edit_position();
        return true;
    }
}

/* ~~~~~~~~~ ВЫВОД МЕНЮ НА СТРАНИЦУ ~~~~~~~~~~~~ */
    
function transform_array_2_list($rows, $idName, $pidName)
    {
        $children = array(); // children of each ID
        $ids = array();
        foreach ($rows as $i=&gt;$r) {
            $row =&amp; $rows[$i]; 
            $id = $row[$idName];
            $pid = $row[$pidName];
            $children[$pid][$id] =&amp; $row;
            if (!isset($children[$id])) $children[$id] = array();
            $row[&#039;childNodes&#039;] =&amp; $children[$id];
            $ids[$row[$idName]] = true;
        }
        // Root elements are elements with non-found PIDs.
        $forest = array();
        foreach ($rows as $i=&gt;$r) {
            $row =&amp; $rows[$i];
            if (!isset($ids[$row[$pidName]])) {
                $forest[$row[$idName]] =&amp; $row;
            }        
        }
        return $forest;
    }
    
function get_array_4_menu($menu){
global $sql, $categories;
    ////////////////////////////////////////////////////////////////////////////////
    // ПЕРЕЛОПАТИТ НОВОСТИ И КАТЕГОРИИ, ЧТОБЫ СОБРАТЬ ИНФОРМАЦИЮ ДЛЯ cute_get_link()
    if(empty($menu)) {return true;}
    foreach ($menu as $key =&gt; $value) { 
        if ($menu[$key][&#039;type&#039;] == &#039;1&#039;) { // отфильтровываем категории
            $categories_array[$menu[$key][&#039;rowid&#039;]] = $menu[$key][&#039;rowid&#039;];
        }
    }

    foreach ($categories_array as $key =&gt; $value) {
    $categories_menu_array[$categories_array[$key]] = $categories[$categories_array[$key]];
    }
    
    $array_4_menu[&#039;1&#039;] = $categories_menu_array;
    
    foreach ($menu as $k =&gt; $v) { 
        if ($menu[$k][&#039;type&#039;] == &#039;2&#039;) { // отфильтровываем новости
            $news_array[] = $menu[$k][&#039;rowid&#039;];
        }
    }
    if(count($news_array) != 0) {
        $i = 1;
            foreach ($news_array as $row_line) {
            if ($i == 1) {
                $where[]  = &#039;id = &#039;.$row_line.&#039;&#039;;
            } else {
                $where[]  = &#039;or&#039;;
                $where[]  = &#039;id = &#039;.$row_line.&#039;&#039;;
            }    
            $i++;    
            }
    $news_array = $sql-&gt;select(array(&#039;table&#039; =&gt; &#039;news&#039;, &#039;where&#039; =&gt; $where));
    foreach ($news_array as $key =&gt; $value) {
        $news_array_by_id[$news_array[$key][&#039;id&#039;]] = $value;
    }
        $array_4_menu[&#039;2&#039;] = $news_array_by_id;
    }
    return $array_4_menu;
}
    
function call_menu($menu_array, $menuid, $menutpl = &#039;&lt;li id=&quot;{id}&quot;&gt;&lt;a href=&quot;{url}&quot;&gt;{name}&lt;/a&gt;&lt;/li&gt;&#039;, $befor = &#039;&lt;ul&gt;&#039;, $after = &#039;&lt;/ul&gt;&#039;, $prefix = &#039;&#039;, $hide = &#039;1&#039;) {
global $array_for_menu;

    $johnny_left_teat .= $befor;
    foreach ($menu_array as $k =&gt; $v) {
    
    if ((($menu_array[$k][&#039;hide&#039;] != &#039;1&#039;) or ($hide != 1)) and $menu_array[$k][&#039;name&#039;] and ($menu_array[$k][&#039;menuid&#039;] == $menuid)) {
        // СОЗДАЕМ ССЫЛКИ ДЛЯ НОВОСТЕЙ
            if ($menu_array[$k][&#039;type&#039;] == &#039;2&#039;) {
                $url = cute_get_link($array_for_menu[&#039;2&#039;][$menu_array[$k][&#039;rowid&#039;]]);
            }        
        // СОЗДАЕМ ССЫЛКИ ДЛЯ СТРАНИЦ
            if ($menu_array[$k][&#039;type&#039;] == &#039;1&#039;) {
                $url = cute_get_link($array_for_menu[&#039;1&#039;][$menu_array[$k][&#039;rowid&#039;]], &#039;category&#039;);    
            }
        
        $find = array(&#039;/{id}/i&#039;, &#039;/{name}/i&#039;, &#039;/{parent}/i&#039;, &#039;/{url}/i&#039;, &#039;/{menuid}/i&#039;, &#039;/{order}/i&#039;, &#039;/\[php\](.*?)\[\/php\]/ie&#039;);
        $repl = array($menu_array[$k][&#039;id&#039;], $menu_array[$k][&#039;name&#039;], $menu_array[$k][&#039;parentid&#039;], $url, $menu_array[$k][&#039;menuid&#039;], $menu_array[$k][&#039;order&#039;], &#039;\\1&#039;);
        $johnny_left_teat .= preg_replace($find, $repl, $menutpl);
        
        unset($url);
        
        if (count($menu_array[$k][&#039;childNodes&#039;]) != 0) {
        // РЕКУРСИЯ    
                    $johnny_left_teat .= call_menu($menu_array[$k][&#039;childNodes&#039;], $menu_array[$k][&#039;menuid&#039;], $prefix.$tpl, $befor, $after, $prefix);            
                    
        }
    }
    
    }
    $johnny_left_teat .= $after;
    
    return $johnny_left_teat;
}
/* ~~~~~~~~~ ВЫВОД МЕНЮ НА СТРАНИЦУ ~~~~~~~~~~~~ */

add_action(&#039;new-advanced-options&#039;, &#039;memu_MySQL_AddEdit&#039;);
add_action(&#039;edit-advanced-options&#039;, &#039;memu_MySQL_AddEdit&#039;);

function memu_MySQL_AddEdit(){
global $sql, $id;

if (!$sql-&gt;table_exists(&#039;menu&#039;)){
$sql-&gt;createtable(array(
        &#039;table&#039;   =&gt; &#039;menu&#039;,
        &#039;columns&#039; =&gt; array(
                      &#039;id&#039;   =&gt; array(&#039;type&#039; =&gt; &#039;int&#039;, &#039;auto_increment&#039; =&gt; 1, &#039;primary&#039; =&gt; 1),
                     &#039;name&#039; =&gt; array(&#039;type&#039; =&gt; &#039;string&#039;),
                      &#039;order&#039; =&gt; array(&#039;type&#039; =&gt; &#039;int&#039;),
                     &#039;type&#039; =&gt; array(&#039;type&#039; =&gt; &#039;int&#039;),
                     &#039;rowid&#039; =&gt; array(&#039;type&#039; =&gt; &#039;int&#039;),
                     &#039;cssid&#039; =&gt; array(&#039;type&#039; =&gt; &#039;string&#039;),
                     &#039;parentid&#039; =&gt; array(&#039;type&#039; =&gt; &#039;int&#039;),
                     &#039;menuid&#039; =&gt; array(&#039;type&#039; =&gt; &#039;int&#039;),
                     &#039;hide&#039; =&gt;  array(&#039;type&#039; =&gt; &#039;bool&#039;),
                      )
        ));
}
    if (count($sql-&gt;select(array(&#039;table&#039; =&gt; &#039;menu&#039;, &#039;where&#039; =&gt; array(&#039;rowid = &#039;.$_GET[&#039;id&#039;].&#039;&#039;)))) &gt; 0) {
        $checked = &#039;checked&#039;;
    }
    $return  = &#039;&lt;fieldset id=&quot;menu&quot;&gt;&lt;legend&gt;Menu&lt;/legend&gt;&lt;input &#039;.$checked.&#039; name=&quot;menu&quot; type=&quot;checkbox&quot;&gt;&#039;.t(&#039;Отметить как пункт меню?&#039;).&#039;&lt;/fieldset&gt;&#039;;

return $return;
}

add_action(&#039;new-save-entry&#039;, &#039;menu_new_save&#039;);
function menu_new_save() {
global $sql, $id;    
    static $i = 0;
    $i++;
    if ($i == 1){ // сработает только один раз, _после_ добавления новости, или поставь 1 и тогда сработает _до_
    if ($_POST[&#039;menu&#039;] == &#039;on&#039;) {
    $menu_id = $sql-&gt;last_insert_id(&#039;menu&#039;, &#039;&#039;, &#039;id&#039;) + 1;
    $sql-&gt;insert(array(
    &#039;table&#039;  =&gt; &#039;menu&#039;,
    &#039;values&#039; =&gt; array(
                      &#039;id&#039;   =&gt; $menu_id,
                     &#039;name&#039; =&gt; &#039;&#039;,
                      &#039;order&#039; =&gt; &#039;&#039;,
                     &#039;type&#039; =&gt; &#039;2&#039;,
                     &#039;rowid&#039; =&gt; $id,
                     &#039;cssid&#039; =&gt; &#039;&#039;,
                     &#039;parentid&#039; =&gt; &#039;&#039;,
                     &#039;menuid&#039; =&gt; &#039;&#039;,
                )
    ));
    }
    }
}

add_action(&#039;edit-save-entry&#039;, &#039;menu_new_edit&#039;);

function menu_new_edit() {
global $sql;

$menu_status = count($sql-&gt;select(array(&#039;table&#039; =&gt; &#039;menu&#039;, &#039;where&#039; =&gt; array(&#039;rowid = &#039;.$_POST[&#039;id&#039;].&#039;&#039;))));

if (($menu_status != 0) or ($_POST[&#039;menu&#039;])) {
    if (($menu_status != 0) and ($_POST[&#039;menu&#039;] == &#039;on&#039;)) {
        return true;
    }

    if (($menu_status == 0) and ($_POST[&#039;menu&#039;] == &#039;on&#039;)) {
        
        $menu_id = $sql-&gt;last_insert_id(&#039;menu&#039;, &#039;&#039;, &#039;id&#039;) + 1;
        $sql-&gt;insert(array(
        &#039;table&#039;  =&gt; &#039;menu&#039;,
        &#039;values&#039; =&gt; array(
                         &#039;id&#039;   =&gt; $menu_id,
                         &#039;name&#039; =&gt; &#039;&#039;,
                         &#039;order&#039; =&gt; &#039;&#039;,
                         &#039;type&#039; =&gt; &#039;2&#039;,
                         &#039;rowid&#039; =&gt; $_POST[&#039;id&#039;],
                         &#039;cssid&#039; =&gt; &#039;&#039;,
                         &#039;parentid&#039; =&gt; &#039;&#039;,
                         &#039;menuid&#039; =&gt; &#039;&#039;,
                    )
        ));    
    }
    
    if (($menu_status == 1) and (!$_POST[&#039;menu&#039;])) {

        $sql-&gt;delete(array(
        &#039;table&#039;  =&gt; &#039;menu&#039;,
        &#039;where&#039; =&gt; array(
                         &#039;rowid = &#039;.$_POST[&#039;id&#039;].&#039;&#039;,
                    )
        ));        
    return true;    
    }
}
}

function del_menu_position($id) {
global $sql;
    
    $array = $sql-&gt;select(array(&#039;table&#039; =&gt; &#039;menu&#039;, &#039;where&#039; =&gt; array(&#039;parentid = &#039;.$_GET[&#039;delmenu&#039;].&#039;&#039;)));    
    print_r($array);
    if (count($array) != 0) {
        $line = $sql-&gt;select(array(&#039;table&#039; =&gt; &#039;menu&#039;, &#039;where&#039; =&gt; array(&#039;id = &#039;.$_GET[&#039;delmenu&#039;].&#039;&#039;)));

        foreach ($array as $k =&gt; $v) {
            echo $array[$k][&#039;id&#039;];
            echo &#039;&lt;hr&gt;&#039;;
            echo $line[&#039;0&#039;][&#039;parentid&#039;];
            $sql-&gt;update(array(
                    &#039;table&#039; =&gt; &#039;menu&#039;, 
                    &#039;where&#039; =&gt; array(&#039;id = &#039;.$array[$k][&#039;id&#039;].&#039;&#039;), 
                    &#039;values&#039; =&gt; array(&#039;parentid&#039; =&gt; $line[&#039;0&#039;][&#039;parentid&#039;]),
                    ));
        }
    }

$sql-&gt;delete(array(&#039;table&#039; =&gt; &#039;menu&#039;, &#039;where&#039; =&gt; array(&#039;id = &#039;.$_GET[&#039;delmenu&#039;].&#039;&#039;)));

header(&#039;Location: index.php?plugin=control_menu&#039;);
return true;
}

function load_menu_list($id) {
global $sql;
    if (!is_numeric($id)) {
        echo &#039;&lt;input type=&quot;text&quot; readonly value=&quot;&quot; onclick=&quot;alert(\&#039;Номер меню не выбран!\&#039;);&quot;&gt;&#039;;
    } else {
    $output = $sql-&gt;select(array(&#039;table&#039; =&gt; &#039;menu&#039;, &#039;where&#039; =&gt; array(&#039;menuid = &#039;.$id.&#039;&#039;)));
        if (count($output) &lt; 1) {
            echo &#039;&lt;b&gt;Тут пунктов ещё нет.&lt;/b&gt;&#039;;
        } else {
                $output_arr[&#039;0&#039;] = &#039;...&#039;;
                foreach ($output as $k =&gt; $v) {
                    $output_arr[$output[$k][&#039;id&#039;]] = $output[$k][&#039;name&#039;];
                }
                echo makeDropDown($output_arr, &#039;parentid&#039;, $_GET[&#039;editthis&#039;]);            
        }
    }
    return true;
}

function edit_position() {
    global $sql;
    
    if ($_POST[&#039;id&#039;] == $_POST[&#039;parentid&#039;]) {
    header(&#039;Location: index.php?plugin=control_menu&amp;msg=parent_error&#039;);
    return true;
    }
        $sql-&gt;update(array(
        &#039;table&#039;  =&gt; &#039;menu&#039;,
        &#039;where&#039; =&gt; array(
                         &#039;id = &#039;.$_POST[&#039;id&#039;].&#039;&#039;
                        ),
        &#039;values&#039; =&gt; array(
                         &#039;name&#039; =&gt; $_POST[&#039;name&#039;],
                         &#039;order&#039; =&gt; ($_POST[&#039;order&#039;] ? $_POST[&#039;order&#039;] : &#039;100&#039;),
                         &#039;type&#039; =&gt; $_POST[&#039;type&#039;],
                         &#039;rowid&#039; =&gt; $_POST[&#039;rowid&#039;],
                         &#039;cssid&#039; =&gt; $_POST[&#039;cssid&#039;],
                         &#039;parentid&#039; =&gt; ($_POST[&#039;parentid&#039;] ? $_POST[&#039;parentid&#039;] : &#039;0&#039;),
                         &#039;menuid&#039; =&gt; $_POST[&#039;menuid&#039;],
                         &#039;hide&#039; =&gt;  ($_POST[&#039;hide&#039;] ? &#039;1&#039; : &#039;0&#039;),
                    )
        ));
    header(&#039;Location: index.php?plugin=control_menu&amp;msg=edit&#039;);
    return true;
}    
function add_new_position() {
    global $sql;
    
    if (!$_POST[&#039;name&#039;] or ($_POST[&#039;type&#039;] == &#039;0&#039;) or !$_POST[&#039;rowid&#039;] or ($_POST[&#039;menuid&#039;] == &#039;0&#039;)) {
        header(&#039;Location: index.php?plugin=control_menu&amp;msg=error&#039;);
        return true;
        }
    if ($_POST[&#039;type&#039;] == 1) {
        
        
        
        $menu_id = $sql-&gt;last_insert_id(&#039;menu&#039;, &#039;&#039;, &#039;id&#039;) + 1;

        $sql-&gt;insert(array(
        &#039;table&#039;  =&gt; &#039;menu&#039;,
        &#039;values&#039; =&gt; array(
                         &#039;id&#039;   =&gt; $menu_id,
                         &#039;name&#039; =&gt; $_POST[&#039;name&#039;],
                         &#039;order&#039; =&gt; ($_POST[&#039;order&#039;] ? $_POST[&#039;order&#039;] : &#039;100&#039;),
                         &#039;type&#039; =&gt; &#039;1&#039;,
                         &#039;rowid&#039; =&gt; $_POST[&#039;rowid&#039;],
                         &#039;cssid&#039; =&gt; $_POST[&#039;cssid&#039;],
                         &#039;parentid&#039; =&gt; ($_POST[&#039;parentid&#039;] ? $_POST[&#039;parentid&#039;] : &#039;0&#039;),
                         &#039;menuid&#039; =&gt; $_POST[&#039;menuid&#039;],
                         &#039;hide&#039; =&gt;  ($_POST[&#039;hide&#039;] ? &#039;1&#039; : &#039;0&#039;),
                    )
        ));
        header(&#039;Location: index.php?plugin=control_menu&amp;msg=add&#039;);
        return true;
    }
    if ($_POST[&#039;type&#039;] == 2) {
        
        $sql-&gt;update(array(
        &#039;table&#039;  =&gt; &#039;menu&#039;,
        &#039;where&#039;  =&gt; array(
                         &#039;rowid = &#039;.$_POST[&#039;rowid&#039;].&#039;&#039;,
                    ),
        &#039;values&#039; =&gt; array(
                         &#039;name&#039; =&gt; $_POST[&#039;name&#039;],
                         &#039;order&#039; =&gt; ($_POST[&#039;order&#039;] ? $_POST[&#039;order&#039;] : &#039;100&#039;),
                         &#039;cssid&#039; =&gt; $_POST[&#039;cssid&#039;],
                         &#039;parentid&#039; =&gt; ($_POST[&#039;parentid&#039;] ? $_POST[&#039;parentid&#039;] : &#039;0&#039;),
                         &#039;menuid&#039; =&gt; $_POST[&#039;menuid&#039;],
                         &#039;hide&#039; =&gt;  ($_POST[&#039;hide&#039;] ? &#039;1&#039; : &#039;0&#039;),
                    )
        ));
    header(&#039;Location: index.php?plugin=control_menu&#039;);
    return true;
    }
}


function control_menu() {
global $config, $sql, $categories, $PHP_SELF;
    if ($_GET[&#039;msg&#039;] == &#039;parent_error&#039;) {
    echoheader(&#039;editnews&#039;, t(&#039;Управление меню - ОШИБКА!&#039;));
    echo &#039;Извините, но пункт меню не может быть родителем сам для себя.
    &lt;br&gt;&lt;br&gt;
    &lt;a href=&quot;index.php?plugin=control_menu&quot;&gt;Вернуться назад&lt;/a&gt;&#039;;
    echofooter();
    return true;
    }
    if ($_GET[&#039;msg&#039;] == &#039;edit&#039;) {
    echoheader(&#039;editnews&#039;, t(&#039;Управление меню - УСПЕШНО ОТРЕДАКТИРОВАНО!&#039;));
    echo &#039;Пункт меню успешно отредакирован...
    &lt;br&gt;&lt;br&gt;
    &lt;a href=&quot;index.php?plugin=control_menu&quot;&gt;Вернуться назад&lt;/a&gt;&#039;;
    echofooter();
    return true;
    }
    if ($_GET[&#039;msg&#039;] == &#039;error&#039;) {
    echoheader(&#039;editnews&#039;, t(&#039;Управление меню - ОШИБКА!&#039;));
    echo &#039;ОШИБКА! Ой, горе какое! Надо указать 4 обязательных значения:
    &lt;ol&gt;
        &lt;li&gt;Навзание пункта меню&lt;/li&gt;
        &lt;li&gt;Тип страницы пункта меню&lt;/li&gt;
        &lt;li&gt;Страницу пункта меню&lt;/li&gt;
        &lt;li&gt;Номер меню, к которому относится пункт меню&lt;/li&gt;
    &lt;/ol&gt;
    &lt;br&gt;&lt;br&gt;
    Вы что-то из этого не сделали!
    &lt;br&gt;&lt;br&gt;
    &lt;a href=&quot;index.php?plugin=control_menu&quot;&gt;Вернуться назад&lt;/a&gt;
    &#039;;
    echofooter();
    return true;
    } 
    if ($_GET[&#039;msg&#039;] == &#039;add&#039;) {
    echoheader(&#039;editnews&#039;, t(&#039;Управление меню - Страница меню добавлена!&#039;));
    echo &#039;Пункт меню успешно добавлен.
    &lt;br&gt;&lt;br&gt;
    &lt;a href=&quot;index.php?plugin=control_menu&quot;&gt;Вернуться назад&lt;/a&gt;
    &#039;;
    echofooter();
    return true;
    } 

if (plugin_enabled(&#039;menu.php&#039;)) {
//ДОСТАЕМ ИЗ БАЗЫ ДАННЫЕ ПРО МЕНЮ И ПРЕОБРАЗУЕМ ИХ В ДЕРЕВОВИДНЫЙ МАССИВ
$menu = $sql-&gt;select(array(&#039;table&#039; =&gt; &#039;menu&#039;, &#039;orderby&#039; =&gt; array (&#039;order&#039;,&#039;ASC&#039;)));
$menu_array = transform_array_2_list($menu, &#039;id&#039;, &#039;parentid&#039;);    
// СОЗДАЕМ МАССИВ ДЛЯ МЕНЮ    
$array_for_menu = get_array_4_menu($menu); 
}
    
    echoheader(&#039;editnews&#039;, t(&#039;Управление меню&#039;));
    
    if (is_numeric($_GET[&#039;editmenu&#039;])) {
        $this_menu = $sql-&gt;select(array(&#039;table&#039; =&gt; &#039;menu&#039;, &#039;where&#039; =&gt; array (&#039;id = &#039;.$_GET[&#039;editmenu&#039;].&#039;&#039;)));
        echo &#039;&lt;a style=&quot;line-height: 25pt;&quot; href=&quot;index.php?plugin=control_menu&quot;&gt;&lt;b&gt;Вернуться в управление меню&lt;/b&gt;&lt;/a&gt;&#039;;
    } else {    
    echo &#039;&lt;noscript&gt;ВНИМАНИЕ! Включите JavaScript в настройках своего браузера! Сейчас он выключен!&lt;/noscript&gt;
    &lt;div style=&quot;border-bottom: 1px solid #ccc; padding: 10px; margin: 10px;&quot;&gt;
    &lt;input checked onclick=&quot;javascript:show(\&#039;editmenu\&#039;);hide(\&#039;addmenu\&#039;);&quot; style=&quot;width:20px;&quot; type=&quot;radio&quot; name=&quot;tubma&quot; value=&quot;editmenuradio&quot;&gt;&lt;b&gt;&#039;.t(&#039;Редактировать меню&#039;).&#039;&lt;/b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
    
    &lt;input style=&quot;width:20px;&quot; type=&quot;radio&quot; name=&quot;tubma&quot; onclick=&quot;javascript:show(\&#039;addmenu\&#039;);hide(\&#039;editmenu\&#039;);&quot; value=&quot;addmenuradio&quot;&gt;&lt;b&gt;&#039;.t(&#039;Добавить пункт в меню&#039;).&#039;&lt;/b&gt; 
    &lt;/div&gt;
    &#039;;
    }
    ?&gt;
    &lt;style&gt;
    select, input {width: 150px;}
    &lt;/style&gt;
    &lt;div id=&quot;addmenu&quot; &lt;?=($_GET[&#039;editmenu&#039;] ? &#039;&#039; : &#039;style=&quot;display: none&quot;&#039;);?&gt;&gt;
    &lt;form action=&quot;&quot; method=&quot;POST&quot; name=&quot;addmenuposition&quot; id=&quot;addmenuposition&quot; onsubmit=&quot;if(checkform() == false) {return false;};&quot;&gt;
    &lt;? if (!$_GET[&#039;editmenu&#039;]) { ?&gt;
    &lt;input type=&quot;text&quot; hidden readonly style=&quot;display: none&quot; value=&quot;add_new_position&quot; name=&quot;action&quot;&gt;
    &lt;? } elseif (is_numeric($_GET[&#039;editmenu&#039;])) { ?&gt;
    &lt;input type=&quot;text&quot; hidden readonly style=&quot;display: none&quot; value=&quot;edit_position&quot; name=&quot;action&quot;&gt;
    &lt;input type=&quot;text&quot; hidden readonly style=&quot;display: none&quot; value=&quot;&lt;?=$_GET[&#039;editmenu&#039;];?&gt;&quot; name=&quot;id&quot;&gt;
    &lt;? } ?&gt;
    &lt;table&gt;
    &lt;tr&gt;
        &lt;td&gt;&lt;?=t(&#039;Название пункта:&#039;);?&gt;
        &lt;td&gt;&lt;input type=&quot;text&quot; value=&quot;&lt;?=$this_menu[0][&#039;name&#039;];?&gt;&quot; name=&quot;name&quot;&gt;
    &lt;tr&gt;
        &lt;td&gt;&lt;?=t(&#039;Порядковый номер:&#039;);?&gt; 
        &lt;td&gt;&lt;input type=&quot;text&quot; value=&quot;&lt;?=$this_menu[0][&#039;order&#039;];?&gt;&quot; name=&quot;order&quot;&gt; &lt;?=t(&#039;по-умолчанию будет 100&#039;);?&gt;
    &lt;tr&gt;
        &lt;td&gt;&lt;?=t(&#039;ID для ссылки (css):&#039;);?&gt; 
        &lt;td&gt;&lt;input type=&quot;text&quot; value=&quot;&lt;?=$this_menu[0][&#039;cssid&#039;];?&gt;&quot; name=&quot;cssid&quot;&gt; &lt;?=t(&#039;(по желанию)&#039;);?&gt;
    &lt;tr&gt;
        &lt;td&gt;&lt;?=t(&#039;Выбрать страницу&#039;);?&gt;
        &lt;td&gt;
            &lt;span id=&quot;chosetype&quot;&gt;
            &lt;select name=&quot;type&quot; id=&quot;type&quot; onChange=&quot;loadlist($F(&#039;type&#039;));&quot;&gt;
                &lt;option value=&quot;0&quot; id=&quot;hideblock&quot;&gt;...&lt;/option&gt;
                &lt;option value=&quot;1&quot; &lt;? if ($this_menu[0][&#039;type&#039;] == &#039;1&#039;) { echo &#039;selected&#039;; }?&gt;&gt;&lt;?=t(&#039;Категория&#039;);?&gt;&lt;/option&gt;
                &lt;option value=&quot;2&quot; &lt;? if ($this_menu[0][&#039;type&#039;] == &#039;2&#039;) { echo &#039;selected&#039;; }?&gt;&gt;&lt;?=t(&#039;Старница&#039;);?&gt;&lt;/option&gt;
            &lt;/select&gt;
            &lt;/span&gt;
    
        &lt;span id=&quot;menulist&quot;&gt;&lt;/span&gt;

    &lt;tr&gt;
        &lt;td&gt;&lt;?=t(&#039;Какой номер меню:&#039;);?&gt;
        &lt;td&gt;
        &lt;select name=&quot;menuid&quot; id=&quot;menuid&quot; onChange=&quot;load_menu_list($F(&#039;menuid&#039;));&quot;&gt;
            &lt;option value=&quot;0&quot;&gt;...&lt;/option&gt;
            &lt;option &lt;? if ($this_menu[0][&#039;menuid&#039;] == &#039;1&#039;) { echo &#039;selected&#039;; }?&gt;&gt;1&lt;/option&gt;
            &lt;option &lt;? if ($this_menu[0][&#039;menuid&#039;] == &#039;2&#039;) { echo &#039;selected&#039;; }?&gt;&gt;2&lt;/option&gt;
            &lt;option &lt;? if ($this_menu[0][&#039;menuid&#039;] == &#039;3&#039;) { echo &#039;selected&#039;; }?&gt;&gt;3&lt;/option&gt;
            &lt;option &lt;? if ($this_menu[0][&#039;menuid&#039;] == &#039;4&#039;) { echo &#039;selected&#039;; }?&gt;&gt;4&lt;/option&gt;
            &lt;option &lt;? if ($this_menu[0][&#039;menuid&#039;] == &#039;5&#039;) { echo &#039;selected&#039;; }?&gt;&gt;5&lt;/option&gt;
            &lt;option &lt;? if ($this_menu[0][&#039;menuid&#039;] == &#039;6&#039;) { echo &#039;selected&#039;; }?&gt;&gt;6&lt;/option&gt;
            &lt;option &lt;? if ($this_menu[0][&#039;menuid&#039;] == &#039;7&#039;) { echo &#039;selected&#039;; }?&gt;&gt;7&lt;/option&gt;
            &lt;option &lt;? if ($this_menu[0][&#039;menuid&#039;] == &#039;8&#039;) { echo &#039;selected&#039;; }?&gt;&gt;8&lt;/option&gt;
            &lt;option &lt;? if ($this_menu[0][&#039;menuid&#039;] == &#039;9&#039;) { echo &#039;selected&#039;; }?&gt;&gt;9&lt;/option&gt;
        &lt;/select&gt; &lt;?=t(&#039;Допускается 9 разных меню&#039;);?&gt;    
    &lt;tr&gt;
        &lt;td&gt;&lt;?=t(&#039;Родительский раздел:&#039;);?&gt;
        &lt;td&gt;
        &lt;span id=&quot;parentbox&quot; name=&quot;parentbox&quot;&gt;
        &lt;? if (is_numeric($_GET[&#039;editmenu&#039;])) { ?&gt;
        &lt;input type=&quot;text&quot; readonly value=&quot;&lt;?=$this_menu[0][&#039;parentid&#039;];?&gt;&quot;&gt;
        &lt;? } else { ?&gt;
        &lt;input type=&quot;text&quot; readonly value=&quot;&quot; onclick=&quot;alert(&#039;Номер меню не выбран!&#039;);&quot;&gt;
        &lt;? } ?&gt;
        &lt;/span&gt;        
        &lt;?=t(&#039;(по желанию)&#039;);?&gt;
    &lt;tr&gt;    
        &lt;td&gt;Спрятать пункт?
        &lt;td&gt;&lt;input &lt;? if ($this_menu[0][&#039;hide&#039;] == &#039;1&#039;) { echo &#039;checked&#039;; }?&gt; type=&quot;checkbox&quot; name=&quot;hide&quot; style=&quot;width: 15px;&quot;&gt;
    &lt;tr&gt;
        &lt;td&gt;
        &lt;td&gt;&lt;input type=&quot;submit&quot; value=&quot;&lt;?=t(&#039;ГОТОВО&#039;);?&gt;&quot; id=&quot;addbutton&quot; &gt;
    &lt;/table&gt;
            &lt;script&gt;
        function load_menu_list(load_menu_list, edit) {
            new Ajax.Updater(
                {success: &#039;load_menu_list&#039;},
                &#039;index.php?plugin=control_menu&amp;load_menu_list=&#039;+load_menu_list+&#039;&amp;editthis=&#039;+edit,
                {
                    insertion: Insertion.Top,
                    onComplete: 
                    function(request){
                        if (request.status == 200){
                            $(&#039;parentbox&#039;).innerHTML = request.responseText;
                        } else {
                            menu_failure(request);
                        }
                    },
                    onFailure: function(request){menu_failure(request)},
                    evalScripts: true
                }
            );
        }
        
        function loadlist(that, edit) {
            new Ajax.Updater(
                {success: &#039;menulist&#039;},
                &#039;index.php?plugin=control_menu&amp;loadlist=&#039;+that+&#039;&amp;editthis=&#039;+edit,
                {
                    insertion: Insertion.Top,
                    onComplete: 
                    function(request) {
                        if (request.status == 200){
                            $(&#039;menulist&#039;).innerHTML = request.responseText;
                            $(&#039;hideblock&#039;).style.display = &#039;none&#039;;
                            $(&#039;addbutton&#039;).style.display = &#039;block&#039;;
                        } else {
                            menu_failure(request);
                        }
                    },
                    onFailure: function(request){menu_failure(request)},
                    evalScripts: true
                }
            );
        }
        

        
        function checkform() { 
            var error_array = new Array();
                i = 0;
          
              if (document.addmenuposition.name.value == null || document.addmenuposition.name.value == &#039;&#039;)
              {    error_array[i] = &#039;... дать название своему пункту меню&#039;;
                i=i+1;  } 
              if (document.addmenuposition.type.value == &#039;0&#039; || document.addmenuposition.type.value == &#039;&#039;)
              {    error_array[i] = &#039;... указать страницу для пункта меню&#039;;
                i=i+1;  }
            if (document.addmenuposition.menuid.value == &#039;...&#039; || document.addmenuposition.type.value == &#039;&#039;)
              {    error_array[i] = &#039;... указать к какому меню относится страница&#039;;
                i=i+1;  }
              if (error_array.length &gt; 0)  {
              alert(&#039;Вы о чем думаете? Вам надо:\n&#039;+ error_array.join(&quot;\n&quot;));
              return false;
              } else {
              return true;
              }
        }
        function show(id) { 
            var ref = document.getElementById(id);
            ref.style.display = &#039;block&#039;;
        }
        function hide(id) {
            var ref = document.getElementById(id);
            ref.style.display = &#039;none&#039;;
        }
        &lt;/script&gt;
        &lt;? if (is_numeric($_GET[&#039;editmenu&#039;])) { ?&gt;
        &lt;script&gt;
        load_menu_list(&#039;&lt;?=$this_menu[0][&#039;menuid&#039;];?&gt;&#039;, &#039;&lt;?=$this_menu[0][&#039;parentid&#039;];?&gt;&#039;);
        loadlist(&#039;&lt;?=$this_menu[0][&#039;type&#039;];?&gt;&#039;, &#039;&lt;?=$this_menu[0][&#039;rowid&#039;];?&gt;&#039;);
        &lt;/script&gt;
        &lt;? } ?&gt;
    &lt;/form&gt;
    &lt;/div&gt;
    &lt;div id=&quot;editmenu&quot; &lt;?=($_GET[&#039;editmenu&#039;] ? &#039;style=&quot;display: none&quot;&#039; : &#039;&#039;);?&gt;&gt;
    &lt;table&gt;
    &lt;tr&gt;
        &lt;td&gt;
&lt;?    
if (count($menu) != 0) {
foreach ($menu as $k =&gt; $v) {
    $all_menu[] = $menu[$k][&#039;menuid&#039;];
}

$all_menu = array_unique($all_menu);
sort($all_menu);

    foreach ($all_menu as $v) {

            echo &#039;&lt;div style=&quot;width: 100%; padding: 0 10px 10px; border-bottom: 3px solid #ccc; float: left; clear: left;&quot;&gt;&lt;h2&gt;Меню № &#039;.$v.&#039;&lt;/h2&gt;&#039;;
                 echo call_menu(
                        $menu_array, 
                        $menuid = $v,
                        $tpl = &#039;&amp;#187; {name} &lt;sup&gt; [&lt;a style=&quot;font-size: xx-small &quot; href=&quot;index.php?plugin=control_menu&amp;editmenu={id}&quot;&gt;edit&lt;/a&gt;] [&lt;a style=&quot;font-size: xx-small &quot; href=&quot;index.php?plugin=control_menu&amp;delmenu={id}&quot;&gt;del&lt;/a&gt;] [порядок: {order}]&lt;/sup&gt;&lt;br&gt;&#039;, 
                        $befor = &#039;&#039;, 
                        $after = &#039;&#039;, 
                        $prefix = &#039;&amp;#187; &#039;,
                        $hide = &#039;0&#039;
                        );
            echo &#039;&lt;/div&gt;&#039;;
        
    }
} else {
echo t(&#039;Ни одного меню ещё не создано.&#039;);
}    
    ?&gt;
    &lt;/table&gt;
    &lt;/div&gt;
&lt;?    
    echofooter();

}

function loadlist_ajax($type) {
global $categories, $sql;
            foreach ($categories as $k =&gt; $v) {
                $cates_name[] = $categories[$k][&#039;name&#039;];
            }    
    if ($_GET[&#039;loadlist&#039;] == 1) {
        foreach ($categories as $k =&gt; $v) {
            $categories__arr[$categories[$k][&#039;id&#039;]] = $categories[$k][&#039;name&#039;];
        }
        echo makeDropDown($categories__arr, &#039;rowid&#039;, $_GET[&#039;editthis&#039;]);
    }        
    
    if ($_GET[&#039;loadlist&#039;] == 2) {
        // Если выбрана новость, то возвращаем список новостей доступных как пункты меню
        $news_array = $sql-&gt;select(array(&#039;table&#039; =&gt; &#039;menu&#039;, &#039;where&#039; =&gt; array(&#039;type = 2&#039;))); // тестовый запрос
        foreach ($news_array as $k =&gt; $v) {
            $newslist[] = $news_array[$k][&#039;rowid&#039;];
        }        
        if (count($newslist) != 0) {
            $i = 1;
            foreach ($newslist as $row_line) {
            if ($i == 1) {
                $where[]  = &#039;id = &#039;.$row_line.&#039;&#039;;
            } else {
                $where[]  = &#039;or&#039;;
                $where[]  = &#039;id = &#039;.$row_line.&#039;&#039;;
            }    
            $i++;    
            }
        $news_array = $sql-&gt;select(array(&#039;table&#039; =&gt; &#039;news&#039;, &#039;where&#039; =&gt; $where));
        foreach ($news_array as $k =&gt; $v) {
            $news__array[$news_array[$k][&#039;id&#039;]] = $news_array[$k][&#039;title&#039;];
        }
        echo makeDropDown($news__array, &#039;rowid&#039;, $_GET[&#039;editthis&#039;]);
        } else {
        echo &#039;&lt;b&gt;Вы не создали страниц для пунктов меню&lt;/b&gt;&#039;;
        }
    }    
}</code></pre></div><p>Потом надо зайти в редактирование или добавление статей (чтобы создалась таблица menu в БД). <em>Этот момент я потом допилю</em>.</p><p>И все... плагин готов к работе.</p><p>Примеры вызова плагина:<br /></p><div class="codebox"><pre><code>&lt;?

    echo call_menu(
        $menu_array, // просто массив, который мы хотим обработать. если не стоит каких-то необычных задач, то это всегда $menu_array
        $menuid = &#039;2&#039;, // порядковый номер меню, которое мы вызываем
        $menutpl = &#039; &lt;a href=&quot;{url}&quot; class=&quot;mainleveltm&quot;&gt;{name}&lt;/a&gt;&#039;,  // шаблон для меню
        $befor = &#039;&lt;a href=&quot;/&quot; class=&quot;mainleveltm&quot;&gt;Главная&lt;/a&gt;&#039;, // теги перед меню
        $after = &#039;&#039;, // тег после меню
        $prefix = &#039;&#039;, // префикс для деток
        $hide = &#039;1&#039; // нужно ли прятать скрытые категории 1 - нужно прятать, 0 - путь отображаются даже скрытые
        );
    echo call_menu(
        $menu_array, 
        $menuid = &#039;1&#039;,
        $menutpl = &#039;&lt;li class=&quot;{id}&quot;&gt;&lt;a href=&quot;{url}&quot;&gt;{name}&lt;/a&gt;&lt;/li&gt;&#039;, 
        $befor = &#039;&lt;ul id=&quot;mainlevel&quot;&gt;&#039;, 
        $after = &#039;&lt;/ul&gt;&#039;, 
        $prefix = &#039;&#039;,
        $hide = &#039;1&#039;
        );    
        
    // а вот пример из самого плагина    
     echo call_menu(
                        $menu_array, 
                        $menuid = &#039;1&#039;,
                        $tpl = &#039;&amp;#187; {name} &lt;sup&gt; [&lt;a style=&quot;font-size: xx-small &quot; href=&quot;index.php?plugin=control_menu&amp;editmenu={id}&quot;&gt;edit&lt;/a&gt;] [&lt;a style=&quot;font-size: xx-small &quot; href=&quot;index.php?plugin=control_menu&amp;delmenu={id}&quot;&gt;del&lt;/a&gt;] [порядок: {order}]&lt;/sup&gt;&lt;br&gt;&#039;, 
                        $befor = &#039;&#039;, 
                        $after = &#039;&#039;, 
                        $prefix = &#039;&amp;#187; &#039;,
                        $hide = &#039;0&#039;
                        );            
?&gt;</code></pre></div><p><span style="color: red"><strong>UPD</strong></span>: <a href="http://strawberry.goodgirl.ru/forum/misc.php?item=106&amp;download=0">Скачать menu.php</a></p>]]></summary>
			<author>
				<name><![CDATA[cmd]]></name>
				<uri>http://strawberry.goodgirl.ru/forum/user/1313/</uri>
			</author>
			<updated>2011-08-02T05:47:27Z</updated>
			<id>http://strawberry.goodgirl.ru/forum/topic/4125/new/posts/</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Тюнинг categories.mdu (Category description 0.1)]]></title>
			<link rel="alternate" href="http://strawberry.goodgirl.ru/forum/topic/4088/new/posts/"/>
			<summary type="html"><![CDATA[<p>/*<br />Plugin Name: &nbsp; &nbsp; Category description<br />Plugin URI:&nbsp; &nbsp; &nbsp;<br />Description: &nbsp; &nbsp; Snippet for category full description<br />Version: &nbsp; &nbsp; &nbsp; &nbsp; 0.1<br />Application: &nbsp; &nbsp; Strawberry<br />Author: &nbsp; &nbsp; &nbsp; &nbsp; cmd<br />Author URI:&nbsp; &nbsp; &nbsp;<a href="http://strawberry.goodgirl.ru/forum/user/1313/">http://strawberry.goodgirl.ru/forum/user/1313/</a><br />*/</p><p>4 дополнительных текстовых поля для открытой категории:<br />1. мета-заголовок<br />2. мета-описание<br />3. короткий текст<br />4. полный текст</p><p><a href="http://strawberry.goodgirl.ru/forum/misc.php?item=105&amp;download=0">Скачать</a>.</p><p>Вызывать на странице, где есть переменная $_GET[&#039;category&#039;].<br />Вверху страницы после head.php написать что-то типа:<br /></p><div class="codebox"><pre><code>&lt;?$catinfo = get_catinfo();?&gt;</code></pre></div><p>Там дальше можете вывести массив $catinfo и все станет ясно.</p><p>Отписал ещё <a href="http://www.workshop200.com/blog/sategory-description-v01.html">тут</a>.</p>]]></summary>
			<author>
				<name><![CDATA[cmd]]></name>
				<uri>http://strawberry.goodgirl.ru/forum/user/1313/</uri>
			</author>
			<updated>2011-05-02T14:36:01Z</updated>
			<id>http://strawberry.goodgirl.ru/forum/topic/4088/new/posts/</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Плагин Images thumbs]]></title>
			<link rel="alternate" href="http://strawberry.goodgirl.ru/forum/topic/4074/new/posts/"/>
			<summary type="html"><![CDATA[<p>Plugin Name:&nbsp; &nbsp; Images thumbs<br />Plugin URI:&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://strawberry.goodgirl.ru/forum/post/17938/">http://strawberry.goodgirl.ru/forum/post/17938/</a><br />Description:&nbsp; &nbsp; Тумборез для вывода картинки в шаблоне. <br />Version:&nbsp; &nbsp; &nbsp; &nbsp; 0.1<br />Application: &nbsp; &nbsp; Strawberry<br />Author:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cmd<br />Author URI:&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.workshop200.com">http://www.workshop200.com</a></p><p>Пример вызова в шаблоне:<br /></p><div class="codebox"><pre><code>&lt;?=small_image($tpl[&#039;post&#039;][&#039;img&#039;], 120); ?&gt;</code></pre></div><p>- будет показывать миниатюры с шириной 120px<br /></p><div class="codebox"><pre><code>&lt;?=small_image($tpl[&#039;post&#039;][&#039;img&#039;], 80, $type = &#039;height&#039;); ?&gt;</code></pre></div><p>- будет показывать миниатюры с высотой 80px</p><p>Пример использования в шаблоне:<br /></p><div class="codebox"><pre><code>&lt;? if ($tpl[&#039;post&#039;][&#039;img&#039;]) { ?&gt;
            &lt;img src=&quot;&lt;?=small_image($tpl[&#039;post&#039;][&#039;img&#039;], 100, $type = &#039;height&#039;); ?&gt;&quot; style=&quot;float: left; margin: 5px; heigth: 100px;&quot; /&gt;
            &lt;? } ?&gt;</code></pre></div><p><strong>Установка:</strong><br />1. Скачать файл в папку с плагинами и включить плагин в админке.<br />2. В show.news.php добавить строку<br /></p><div class="codebox"><pre><code>$tpl[&#039;post&#039;][&#039;img&#039;]           = $row[&#039;avatar&#039;];</code></pre></div><p><a href="http://strawberry.goodgirl.ru/forum/misc.php?item=98&amp;download=0"><strong>DOWNLOAD</strong></a></p><p><a href="http://www.workshop200.com/blog/images-thumbs-tumborez-dlya-kartinok-s-kesh-strawberry-1-1-1.html">Подробности тут</a>.</p><p><em><span style="color: #cccccc">10 часов, 31 минуту и 59 секунд спустя:</span></em></p><p><span style="color: red"><br />______________________________________________________________</span></p><p><span style="color: red"><strong>UPDATED</strong>:</span> Я понимаю, что прошло всего 12 часов, но все равно неприятно... Хоть кто-то мог посмотреть на код и сказать: <em>Евгений, нахуя Вы все так усложняете?</em></p><p>И правда... чего это я...</p><p>Выкладываю версию 0.2, которая намного фунциональнее и понятнее, чем версия 0.1.</p><p><a href="http://strawberry.goodgirl.ru/forum/misc.php?item=102&amp;download=0"><strong>DOWNLOAD Images thumbs v. 0.2</strong></a></p><p>Вот функция small_image с атрибутами:<br /></p><div class="codebox"><pre><code>small_image($file_image, $file_size, $rgb = 0xFFFFFF, $quality = 100)</code></pre></div><p>Я поменял вызов. Теперь вызывать так:<br /></p><div class="codebox"><pre><code>&lt;?=small_image($tpl[&#039;post&#039;][&#039;img&#039;], &#039;100x150&#039;); ?&gt;</code></pre></div><p>Если указать один из параметров 0 (ноль), то масштабирование будет только по второму параметру. Например:<br /></p><div class="codebox"><pre><code>&lt;?=small_image($tpl[&#039;post&#039;][&#039;img&#039;], &#039;100x0&#039;); ?&gt;</code></pre></div><p> выдаст миниатюру с шириной 100px и произвольной высотой.</p><p>Кроме того при желании можно указывать цвет фона (т.н. поля) - переменная $rgb и качество миниатюры ($quality).</p><p><em><span style="color: #cccccc">10 часов, 47 минут и 39 секунд спустя:</span></em></p><p>Кеширование работает ОК. Пойду куплю себе медаль.</p>]]></summary>
			<author>
				<name><![CDATA[cmd]]></name>
				<uri>http://strawberry.goodgirl.ru/forum/user/1313/</uri>
			</author>
			<updated>2011-04-18T14:55:22Z</updated>
			<id>http://strawberry.goodgirl.ru/forum/topic/4074/new/posts/</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Вывод новостей в формате таблицы]]></title>
			<link rel="alternate" href="http://strawberry.goodgirl.ru/forum/topic/4069/new/posts/"/>
			<summary type="html"><![CDATA[<p>Реализовал вывод новостей в формате таблицы. Если кому не лень - можно сделать из этого отдельный плагин.</p><p>1. Добавить куда-то (например после include &#039;/.../head.php&#039;;) две функции:<br /></p><div class="codebox"><pre><code>function make_table($number, $in_rows) {
$rows = ceil($number/$in_rows);
$row_array[&#039;rows&#039;] = $rows;
$row_array[&#039;lines&#039;][] = 1;
    for ($i = 1; $i &lt; $rows; $i++) {
        $row_array[&#039;lines&#039;][] = $in_rows*$i+1;
    }
$row_array[&#039;empty_td&#039;] = $i*$in_rows - $number;
$row_array[&#039;number&#039;] = $number;
$row_array[&#039;in_row&#039;] = $in_rows;

echo &#039;&lt;table&gt;&#039;;

return $row_array;
}

function close_table($in_row,$news_number) {

$news_number = $news_number - 1;
if ($news_number &lt; $in_row[&#039;in_row&#039;]) {
$in_row[&#039;empty_td&#039;] = $in_row[&#039;in_row&#039;] - $news_number;
} 
elseif ($news_number == $in_row[&#039;in_row&#039;]) {
$in_row[&#039;empty_td&#039;] = 0;
}
elseif (($news_number &gt; $in_row[&#039;in_row&#039;]) and ($news_number &lt; $in_row[&#039;number&#039;])) {
$full_content_row = floor($news_number/$in_row[&#039;in_row&#039;]); // заполнено полностью строк
$in_row[&#039;empty_td&#039;] = $in_row[&#039;in_row&#039;] - ($news_number - ($in_row[&#039;in_row&#039;] * $full_content_row)); // незаполнено ячеек в последней строке
    if ($in_row[&#039;empty_td&#039;] == $in_row[&#039;in_row&#039;]) {
        $in_row[&#039;empty_td&#039;] = 0;
    }
} 
        for ($i &gt; 1; $i &lt; $in_row[&#039;empty_td&#039;]; $i++) {
            echo &#039;&lt;td&gt;&#039;;
        }    
echo &#039;&lt;/table&gt;&#039;;

}</code></pre></div><p>2. В нужный шаблон active.tpl новости добавить </p><p>в начало:<br /></p><div class="codebox"><pre><code>if ($in_row) {
    if (in_array($news_number, $in_row[&#039;lines&#039;])) {
        echo &#039;&lt;tr&gt;&#039;;
    }
}</code></pre></div><p>а в конец:<br /></p><div class="codebox"><pre><code>&lt;?
$news_number++;
?&gt;</code></pre></div><p>3. Вызывать ленту новостей так:<br /></p><div class="codebox"><pre><code>$news_number = 1;
$number = 10;
$in_row = make_table($number, 5); // где 4 это кол-во элементов в строке
include rootpath.&#039;/show_news.php&#039;;
close_table($in_row,$news_number);
unset($news_number, $in_row);</code></pre></div><p>4. Сделать пагинацию. Тут возможны варианты.</p><p><a href="http://www.workshop200.com/blog/table4strawberry.html">Подробнее тут</a>.</p>]]></summary>
			<author>
				<name><![CDATA[cmd]]></name>
				<uri>http://strawberry.goodgirl.ru/forum/user/1313/</uri>
			</author>
			<updated>2011-04-08T21:21:29Z</updated>
			<id>http://strawberry.goodgirl.ru/forum/topic/4069/new/posts/</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Автоматическое разделение на страницы <!--nextpage-->]]></title>
			<link rel="alternate" href="http://strawberry.goodgirl.ru/forum/topic/4054/new/posts/"/>
			<summary type="html"><![CDATA[<p>Plugin Name:&nbsp; &nbsp; Авто-разделение новости на страницы<br />Plugin URI: &nbsp; &nbsp; <a href="http://strawberry.goodgirl.ru/forum/post/17816/">http://strawberry.goodgirl.ru/forum/post/17816/</a><br />Description:&nbsp; &nbsp; Вставляет разделение на страницы каждое Н-ое количество знаков. Слова не разрывает, но теги в целях безопасности сносит нафиг.<br />Version: &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0.1<br />Application: &nbsp; &nbsp; Strawberry 1.1.1<br />Author: &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cmd<br />Author URI:&nbsp; &nbsp; &nbsp; <a href="http://www.weblancer.net/users/cmd/">http://www.weblancer.net/users/cmd/</a></p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://strawberry.goodgirl.ru/forum/misc.php?item=95&amp;download=0"><strong>Скачать плагин</strong></a></p><p>Выглядит это так:<br /><span class="postimg"><img src="http://strawberry.goodgirl.ru/forum/misc.php?item=96&amp;download=0" alt="http://strawberry.goodgirl.ru/forum/misc.php?item=96&amp;amp;download=0" /></span></p>]]></summary>
			<author>
				<name><![CDATA[cmd]]></name>
				<uri>http://strawberry.goodgirl.ru/forum/user/1313/</uri>
			</author>
			<updated>2011-03-24T22:15:11Z</updated>
			<id>http://strawberry.goodgirl.ru/forum/topic/4054/new/posts/</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Плагин мета тегов для ЧПУ и MySQL (meta-tags-mysql.php)]]></title>
			<link rel="alternate" href="http://strawberry.goodgirl.ru/forum/topic/4035/new/posts/"/>
			<summary type="html"><![CDATA[<p>Plugin Name:&nbsp; &nbsp; Meta tags for MySQL<br />Plugin URI: &nbsp; &nbsp; <a href="http://strawberry.goodgirl.ru/forum/post/17717/">http://strawberry.goodgirl.ru/forum/post/17717/</a><br />Description:&nbsp; &nbsp; Поддержка MySQL и ЧПУ. Пример функции &lt;br /&gt;&lt;code&gt;&amp;lt;title&amp;gt;&amp;lt;?=meta_tag_MySQL(1, 0);?&amp;gt;&amp;lt;/title&amp;gt;&lt;/code&gt;&lt;br /&gt;, где &quot;1&quot; означает title, а &quot;0&quot; означает отсутсвие ЧПУ. Допустимые значения первой переменной 1 - title, 2 - keywords, 3 - description. Допустимые значени второй переменно &quot;0&quot; (вызов по id) и &quot;1&quot; (вызов по url).<br />Version: &nbsp; &nbsp; 0.3<br />Application: &nbsp; &nbsp; Strawberry<br />Author: &nbsp; &nbsp; cmd<br />Author URI:&nbsp; &nbsp; &nbsp;<a href="http://strawberry.goodgirl.ru/forum/user/1313/">http://strawberry.goodgirl.ru/forum/user/1313/</a></p><p>Представляю <strong>Meta tags for MySQL v 0.3</strong> дорабатывать которую я (в ближайшее время) не собираюсь. Как и предыдущие версии плагин работает с таблицей meta, которую сам и создает. Установка плагина сводится к копированию одного файла в папку <strong>.../plugins/</strong>.</p><p>Плагин умеет выводить мета-теги с ЧПУ и без ЧПУ.</p><p>В версии 0.3 внесены некоторые правки в код, а так же добавлены функции, в частности:<br />1. Если при добавлении новости поля meta-title остается незаполненным, то автоматически вставляется название новости.<br />2. Если у новости нет мета-тайтла (например, если новость была добавлена на сервер до того, как был установлен плагин), то в &lt;title&gt; не будет пусто - плагин будет обращаться к БД и подставлять заголовок новости из таблицы news.<br />3. Кавычки идут нафиг.</p><p><a href="http://strawberry.goodgirl.ru/forum/misc.php?item=90&amp;download=0"><strong>Скачать Meta tags for MySQL v 0.3</strong></a></p><br /><p>/*************************************************/</p><p>Plugin Name:&nbsp; &nbsp; Meta tags for MySQL<br />Plugin URI: &nbsp; &nbsp; <a href="http://strawberry.goodgirl.ru/forum/post/17717/">http://strawberry.goodgirl.ru/forum/post/17717/</a><br />Description:&nbsp; &nbsp; Поддержка MySQL и ЧПУ. Пример функции &lt;br /&gt;&lt;code&gt;&amp;lt;title&amp;gt;&amp;lt;?=meta_tag_MySQL(1, 0);?&amp;gt;&amp;lt;/title&amp;gt;&lt;/code&gt;&lt;br /&gt;, где &quot;1&quot; означает title, а &quot;0&quot; означает отсутсвие ЧПУ. Допустимые значения первой переменной 1 - title, 2 - keywords, 3 - description. Допустимые значени второй переменно &quot;0&quot; (вызов по id) и &quot;1&quot; (вызов по url).<br />Version: &nbsp; &nbsp; 0.2<br />Application: &nbsp; &nbsp; Strawberry<br />Author: &nbsp; &nbsp; cmd<br />Author URI:&nbsp; &nbsp; &nbsp;<a href="http://strawberry.goodgirl.ru/forum/user/1313/">http://strawberry.goodgirl.ru/forum/user/1313/</a></p><p>Лажанул с v 0.1 с проверкой наличия записи. Вместо POST написал GET. При редактировании возникало дублирование. Исправил. </p><p><a href="http://strawberry.goodgirl.ru/forum/misc.php?item=86&amp;download=0">Скачать v 0.2</a></p><p>На перспективу: надо будет дописать удаление строки из таблицы meta при удалении новости... Учитывая, что id удаленной новости не может быть присвоен другой, наличие лишних строк в meta не проблема, но для красоты надо будет сделать...</p><p>*******************************************************************</p><p>Plugin Name:&nbsp; &nbsp; Meta tags for MySQL<br />Plugin URI: &nbsp; &nbsp; <a href="http://strawberry.goodgirl.ru/forum/post/17717/">http://strawberry.goodgirl.ru/forum/post/17717/</a><br />Description:&nbsp; &nbsp; Поддержка MySQL и ЧПУ. Пример функции &lt;br /&gt;&lt;code&gt;&amp;lt;title&amp;gt;&amp;lt;?=meta_tag_MySQL(1, 0);?&amp;gt;&amp;lt;/title&amp;gt;&lt;/code&gt;&lt;br /&gt;, где &quot;1&quot; означает title, а &quot;0&quot; означает отсутсвие ЧПУ. Допустимые значения первой переменной 1 - title, 2 - keywords, 3 - description. Допустимые значени второй переменно &quot;0&quot; (вызов по id) и &quot;1&quot; (вызов по url).<br />Version: &nbsp; &nbsp; 0.1<br />Application: &nbsp; &nbsp; Strawberry<br />Author: &nbsp; &nbsp; cmd<br />Author URI:&nbsp; &nbsp; &nbsp;<a href="http://strawberry.goodgirl.ru/forum/user/1313/">http://strawberry.goodgirl.ru/forum/user/1313/</a></p><br /><p>Чтобы не откладывать в долгий ящик выкладываю продукт своих сегодняшних трудов. Плагин является альтернативной стандартному плагину <strong>meta-tags.php</strong> (ака Meta tags), который работает на базе доп. полей. Этот плагин никаким образом не дополняет <strong>meta-tags.php</strong> и не отвечает на вопрос: <em>а как мне перенести свои мета-теги в БД?</em></p><p>Принцип работы: работает через отдельную таблицу <strong>префикс_meta</strong>.</p><p>Плагин поддерживает вызов новостей с ЧПУ и без него.</p><p>Примеры вызова <br /></p><div class="codebox"><pre><code>&lt;title&gt;&lt;?=meta_tag_MySQL(1, 0);?&gt;&lt;/title&gt;</code></pre></div><p>, где &quot;1&quot; означает что нам надо title, а &quot;0&quot; означает отсутсвие ЧПУ (вызов по id). </p><p>Допустимые значения первой переменной: <br />1 - title, <br />2 - keywords, <br />3 - description</p><p>Допустимые значени второй переменно &quot;0&quot; (вызов по id) и &quot;1&quot; (вызов по url).</p><p>Другой пример вызова для наглядности<br /></p><div class="codebox"><pre><code>&lt;meta name=&quot;Description&quot; content=&quot;&lt;?=meta_tag_MySQL(3, 1);?&gt;&quot; /&gt; </code></pre></div><p>Тут мы достаем Description для сайта с включенным ЧПУ (т.е. по url).</p><p><strong>ВЕРСИЯ 0.1</strong></p><p><strong><a href="http://strawberry.goodgirl.ru/forum/misc.php?item=85&amp;download=0">СКАЧАТЬ</a></strong></p><p><strong>Strawberry 1.1.1</strong></p><p>Bag report&#039;ы приветствуются!</p><p><em><span style="color: #cccccc">22 минуты и 21 секунду спустя:</span></em></p><p><span style="color: red">К слову:</span><br />Не смотря на то, что перенос данных из старых полей в БД не предусмотрен, плагин можно без проблем ставить на уже работающие сайты.</p><p><em><span style="color: #cccccc">1 неделя, 3 дня и 6 часов спустя:</span></em></p><p><span style="color: red"><strong>UPD 10 марта</strong>:</span> добавлена версия 0.3.</p>]]></summary>
			<author>
				<name><![CDATA[cmd]]></name>
				<uri>http://strawberry.goodgirl.ru/forum/user/1313/</uri>
			</author>
			<updated>2011-02-27T15:28:35Z</updated>
			<id>http://strawberry.goodgirl.ru/forum/topic/4035/new/posts/</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Плагин анонсов]]></title>
			<link rel="alternate" href="http://strawberry.goodgirl.ru/forum/topic/4032/new/posts/"/>
			<summary type="html"><![CDATA[<p>Plugin Name: &nbsp; &nbsp; Announcements<br />Plugin URI:&nbsp; &nbsp; &nbsp;<a href="http://strawberry.goodgirl.ru/forum/post/17695/">http://strawberry.goodgirl.ru/forum/post/17695/</a><br />Description: &nbsp; &nbsp; Плагин анонсов задает дату для события, которое должно произойти в будущем.<br />Version: &nbsp; &nbsp; &nbsp; &nbsp; 0.2<br />Application: &nbsp; &nbsp; Strawberry<br />Author: &nbsp; &nbsp; &nbsp; &nbsp; cmd<br />Author URI:&nbsp; &nbsp; &nbsp;<a href="http://strawberry.goodgirl.ru/forum/user/1313/">http://strawberry.goodgirl.ru/forum/user/1313/</a></p><p>Установка:<br />1. Скопировать файл в папку с плагинами и активировать<br />2. Указать свой префикс в 42 строке<br />3. В файл <strong>show.news.php</strong> записываем:<br /></p><div class="codebox"><pre><code>(isset($tpl[&#039;post&#039;][&#039;rdate&#039;]) ? $tpl[&#039;post&#039;][&#039;rdate&#039;] = langdate($config[&#039;timestamp_active&#039;], $row[&#039;rdate&#039;]) : $tpl[&#039;post&#039;][&#039;rdate&#039;] = NULL);</code></pre></div><p><a href="http://strawberry.goodgirl.ru/forum/misc.php?item=83&amp;download=0">Скачать версию 0.2</a></p><p><strong>_______________________________</strong></p><p>Plugin Name: &nbsp; &nbsp; Announcements<br />Plugin URI:&nbsp; &nbsp; &nbsp;<a href="http://strawberry.goodgirl.ru/forum/post/17695/">http://strawberry.goodgirl.ru/forum/post/17695/</a><br />Description: &nbsp; &nbsp; Плагин анонсов задает дату для события, которое должно произойти в будущем.<br />Version: &nbsp; &nbsp; &nbsp; &nbsp; 0.1<br />Application: &nbsp; &nbsp; Strawberry<br />Author: &nbsp; &nbsp; &nbsp; &nbsp; cmd<br />Author URI:&nbsp; &nbsp; &nbsp;<a href="http://strawberry.goodgirl.ru/forum/user/1313/">http://strawberry.goodgirl.ru/forum/user/1313/</a></p><p>Strawberry 1.1.1.</p><p><a href="http://strawberry.goodgirl.ru/forum/misc.php?item=82&amp;download=0">Скачать плагин</a></p><p>Как это выглядит?<br /><span class="postimg"><img src="http://strawberry.goodgirl.ru/forum/misc.php?item=81&amp;download=0" alt="http://strawberry.goodgirl.ru/forum/misc.php?item=81&amp;amp;download=0" /></span></p><p><strong>Установка:</strong><br />1. Активировать плагин в списке плагинов.<br />2. В файле<em> addnews.mdu</em> найти <br /></p><div class="codebox"><pre><code>    $sql-&gt;insert(array(
    &#039;table&#039;  =&gt; &#039;story&#039;,
    &#039;values&#039; =&gt; array(
                &#039;post_id&#039; =&gt; $id,
                &#039;short&#039;   =&gt; replace_news(&#039;add&#039;, $short_story),
                &#039;full&#039;    =&gt; replace_news(&#039;add&#039;, $full_story)
                )
    ));</code></pre></div><p>и добавить после<br /></p><div class="codebox"><pre><code>    if ($_POST[&#039;rdate&#039;] == &#039;on&#039;) {
        $rdate = mktime(0, 0, 1, $_POST[&#039;amonth&#039;], $_POST[&#039;aday&#039;], $_POST[&#039;ayear&#039;]);
        mysql_query(&quot;UPDATE &quot;.$config[&#039;dbprefix&#039;].&quot;news SET rdate = &quot;.$rdate.&quot; WHERE id = $id&quot;);
    }
    else {
        mysql_query(&quot;UPDATE &quot;.$config[&#039;dbprefix&#039;].&quot;news SET rdate = NULL WHERE id = $id&quot;);
    }</code></pre></div><p>3. В файле<em> editnews.mdu</em> найти <br /></p><div class="codebox"><pre><code>    $sql-&gt;update(array(
    &#039;table&#039;  =&gt; &#039;story&#039;,
    &#039;where&#039;  =&gt; array(&quot;post_id = $id&quot;),
    &#039;values&#039; =&gt; array(
                &#039;short&#039; =&gt; replace_news(&#039;add&#039;, $short_story),
                &#039;full&#039;  =&gt; replace_news(&#039;add&#039;, $full_story)
                )
    ));</code></pre></div><p>и добавить после:<br /></p><div class="codebox"><pre><code>    if ($_POST[&#039;rdate&#039;] == &#039;on&#039;) {
        $rdate = mktime(0, 0, 1, $_POST[&#039;amonth&#039;], $_POST[&#039;aday&#039;], $_POST[&#039;ayear&#039;]);
        mysql_query(&quot;UPDATE &quot;.$config[&#039;dbprefix&#039;].&quot;news SET rdate = &quot;.$rdate.&quot; WHERE id = $id&quot;);
    }
    else {
        mysql_query(&quot;UPDATE &quot;.$config[&#039;dbprefix&#039;].&quot;news SET rdate = NULL WHERE id = $id&quot;);
    }</code></pre></div><p>4. В файле <em>show.news.php</em> найти строку:<br /></p><div class="codebox"><pre><code>$tpl[&#039;post&#039;][&#039;date&#039;]          = langdate($config[&#039;timestamp_active&#039;], $row[&#039;date&#039;]);</code></pre></div><p>и добавить:<br /></p><div class="codebox"><pre><code>$tpl[&#039;post&#039;][&#039;rdate&#039;]         = langdate($config[&#039;timestamp_active&#039;], $row[&#039;rdate&#039;]);</code></pre></div><p><strong>Использование плагина:</strong><br />1. Можно выводить анонсы событий на следующие N дней. Например, вот так выводим события на следующие 30 дней:<br /></p><div class="codebox"><pre><code>&lt;?
$show_from = time;
$show_to = (time + 60 * 60 * 24 * 30); // 30 дней
$template = &#039;Headlines&#039;;
include rootpath.&#039;/show_news.php&#039;;
unset($show_from, $show_to);
?&gt;</code></pre></div><p>2. Можно делать сортировку по дате анонса:<br /></p><div class="codebox"><pre><code>$sort = array(&#039;rdate&#039;, &#039;ASC&#039;); // ну или DESC
$template = &#039;Headlines&#039;;
include rootpath.&#039;/show_news.php&#039;;</code></pre></div><p>3. В шаблонах новостей можно делать вывод даты анонса:<br /></p><div class="codebox"><pre><code>&lt;?=$tpl[&#039;post&#039;][&#039;rdate&#039;]; ?&gt;</code></pre></div><p>4. Можно переделать функцию cn_calendar() под анонсы:<br /></p><div class="codebox"><pre><code>function cn_calendar(){
global $cache, $year, $month, $day, $PHP_SELF, $sql, $config;

    $year  = ($year ? $year : $_GET[&#039;year&#039;]);
    $month = ($month ? $month : $_GET[&#039;month&#039;]);
    $day   = ($day ? $day : $_GET[&#039;day&#039;]);

    if (!$post_arr = $cache-&gt;unserialize(&#039;calendar&#039;, ($day ? $day.&#039;.&#039; : date(&#039;d&#039;, time)).($month ? $month : date(&#039;m&#039;, time)).&#039;.&#039;.($year ? $year : date(&#039;Y&#039;, time)))){
        $time = ($month ? $month : date(&#039;m&#039;, time)).&#039;/01/&#039;.($year ? $year : date(&#039;Y&#039;, time));
        $fday = strtotime(date(&#039;m/d/Y 00:00:01&#039;, strtotime($time)));
        $lday = strtotime(date(&#039;m/t/Y 23:59:59&#039;, strtotime($time)));

        $tmonth = $sql-&gt;select(array(
                 &#039;table&#039;   =&gt; &#039;news&#039;,
                 &#039;where&#039;   =&gt; array(&#039;rdate &gt; &#039;.$fday, &#039;and&#039;, &#039;rdate &lt; &#039;.$lday),
                 &#039;orderby&#039; =&gt; array(&#039;rdate&#039;, &#039;ASC&#039;),
                 &#039;select&#039;  =&gt; array(&#039;rdate&#039;)
                 ));
        $pmonth = $sql-&gt;select(array(
                  &#039;table&#039;   =&gt; &#039;news&#039;,
                  &#039;where&#039;   =&gt; array(&#039;rdate &lt; &#039;.$tmonth[0][&#039;rdate&#039;]),
                  &#039;orderby&#039; =&gt; array(&#039;rdate&#039;, &#039;DESC&#039;),
                  &#039;limit&#039;   =&gt; array(0, 100),
                  &#039;select&#039;  =&gt; array(&#039;rdate&#039;)
                  ));

        $nmonth = $sql-&gt;select(array(
                  &#039;table&#039; =&gt; &#039;news&#039;,
                  &#039;where&#039; =&gt; array(&#039;rdate &gt; &#039;.$tmonth[(count($tmonth) - 1)][&#039;rdate&#039;]),
                  &#039;orderby&#039; =&gt; array(&#039;rdate&#039;, &#039;ASC&#039;),
                  &#039;limit&#039;   =&gt; array(0, 100),
                  &#039;select&#039;  =&gt; array(&#039;rdate&#039;)
                  ));


        foreach (array_merge($pmonth, $tmonth, $nmonth) as $row){
            $post_arr[] = $row[&#039;rdate&#039;];
        }


        @rsort($post_arr);
        $post_arr = $cache-&gt;serialize($post_arr);
    }

    if ($year and $month){
        $_this[&#039;month&#039;] = $month;
        $_this[&#039;year&#039;]  = $year;
    } else {
        $_this[&#039;month&#039;] = date(&#039;m&#039;, $post_arr[0]);
        $_this[&#039;year&#039;]  = date(&#039;Y&#039;, $post_arr[0]);
    }

    if (!$calendar = $cache-&gt;get(($day ? $day.&#039;.&#039; : &#039;&#039;).$_this[&#039;month&#039;].&#039;.&#039;.$_this[&#039;year&#039;])){
        foreach ($post_arr as $date){
            if ($_this[&#039;year&#039;] == date(&#039;Y&#039;, $date) and $_this[&#039;month&#039;] == date(&#039;m&#039;, $date)){
                $events[date(&#039;j&#039;, $date)] = $date;
            }

            if ($_this[&#039;month&#039;].$_this[&#039;year&#039;] != date(&#039;mY&#039;, $date)){
                $prev_next[] = $date;
            }
        }

        $calendar = $cache-&gt;put(calendar($_this[&#039;month&#039;], $_this[&#039;year&#039;], $events, $prev_next));
    }

return $calendar;
}</code></pre></div><p>---------</p><p><strong>Недостатки</strong>:<br />1. Приведенная функция &quot;календаря анонсов&quot; содержит sql запрос с параметром <strong>&#039;limit&#039;&nbsp; &nbsp;=&gt; array(0, 100),</strong> который со всей очевидностью не является оптимальным. Проблема в том, что не все новости являются анонсами и использование <strong>&#039;limit&#039;&nbsp; &nbsp;=&gt; array(0, 1),</strong> приведет тому, что переключатель между месяцами может работать неправильно. <br />2. В файле announcements.php есть кусок кода, который создает столбец в БД:<br /></p><div class="codebox"><pre><code>$result = mysql_query(&#039;ALTER TABLE blog_news ADD rdate INT&#039;); 
// тут надо дописать проверку наличия столбца, но хрен его знает как это сделать, если таблица пустая.</code></pre></div><p><em>Других недостатков пока замечено не было, но должен признаться что плагин &quot;только с конвейера&quot; и полевых испытаний ещё не проходил.</em></p><p><em><span style="color: #cccccc">4 дня, 23 часа и 5 минут спустя:</span></em></p><p><strong>UPDATE</strong>. Для красоты сделал v.0.2. Теперь проще устанавливать.<br />До ума доведу под настроение....</p>]]></summary>
			<author>
				<name><![CDATA[cmd]]></name>
				<uri>http://strawberry.goodgirl.ru/forum/user/1313/</uri>
			</author>
			<updated>2011-02-21T20:16:03Z</updated>
			<id>http://strawberry.goodgirl.ru/forum/topic/4032/new/posts/</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Менеджер файлов Quixplorer for Strawberry 1.1.9]]></title>
			<link rel="alternate" href="http://strawberry.goodgirl.ru/forum/topic/4000/new/posts/"/>
			<summary type="html"><![CDATA[<p>С наступающим Новым 2011 годом, друзья! И в качестве новогоднего подарка:</p><p><strong>Управление прикреплёнными файлами, закачанными на сайт плагином &quot;Adepto Fastload&quot;.</strong></p><p>Попытки адаптировать знаменитый менеджер файлов Quixplorer (последняя версия - 2.3.1) под Strawberry предпринимались и ранее (см. описание в упаковке), но в своём проекте я подогнал его именно под attach-файлы, отбросив все лишние возможности.</p><p>На первый взгляд, это не самостоятельный плагин, а &quot;надстройка&quot; к плагину &quot;Adepto Fastload&quot;. Хотя, если поменять настройки путей (см. ниже в разделе &quot;Установка&quot;), то можно будет через web-интерфейс управлять всей файловой системой сайта (про необходимую степень осторожности читайте ниже в разделе &quot;Безопасность&quot;).</p><p><strong>Установка</strong> </p><p>1. Распаковываем <a href="http://strawberry.goodgirl.ru/forum/misc.php?item=71&amp;download=0">архив</a> и копируем его содержимое в папку plugins.</p><p>2. Настраиваем файл <strong>plugins/quixplorer/.config/conf.php</strong> так:</p><div class="codebox"><pre><code>// количество файлов/папок на страницу (0 - без разбиения на страницы)
$GLOBALS[&quot;count_list&quot;] = 20;

// the home directory for the filemanager: (use &#039;/&#039;, not &#039;\&#039; or &#039;\\&#039;, no trailing &#039;/&#039;)
// относительный путь к директории с файлами (не ставить &#039;/&#039; в конце)
$GLOBALS[&quot;home_dir&quot;] = &quot;../../data/attach&quot;;

// the url corresponding with the home directory: (no trailing &#039;/&#039;)
// абсолютный путь к директории с файлами (не ставить &#039;/&#039; в конце)
$GLOBALS[&quot;home_url&quot;] = &quot;http://&quot;.$siteroot.&quot;/data/attach&quot;;</code></pre></div><p> Остальное - без изменений. В принципе, если у вас в настройках плагина Adepto Fastload установлен путь &quot;по умолчанию&quot; (data/attach), то ничего настраивать не нужно.</p><p>3. Активизируем плагин Quixplorer в админке &quot;Настройки - Плагины&quot;.</p><p>Всё! В настройках Strawberry появилась ссылка &quot;Управление прикреплёнными файлами&quot;. Все подробности о возможностях плагина - в &quot;Справке&quot; по нему.</p><p><strong>Что нового у меня</strong></p><p>1. Авторизация от Strawberry. Теперь, если пользователь не авторизован в системе, или если его группе не разрешено пользоваться этим плагином (разрешения в <strong>usergroups</strong>), то даже попытка запустить плагин так: хттп://сайт.ру/strawberry/plugins/quixplorer/index.php ни к чему не приведёт. Раньше было можно, а это серьёзная дыра в безопасности!</p><p>2. Убрал все внутренние настройки Quixplorer&#039;а и прочий &quot;обвес&quot;. Размер плагина сократился примерно в два раза, он стал безопаснее.</p><p>3. Добавил возможность разбиения списка папок/файлов на страницы. Раньше громоздкие файловые списки на серьёзных сайтах грузились полностью и работа с папкой data/attach здорово напрягала сервер.</p><p>4. Добавил возможность делать <span class="bbu">в шаблонах</span> ссылку на папку attach-контента новости - для непосредственного управления attach-контентом этой новости без входа в админ-центр Strawberry:</p><div class="codebox"><pre><code>&lt;? if (($tpl[&#039;post&#039;][&#039;attachment&#039;]) and ($is_logged_in) and (cute_get_rights(&#039;quixplorer&#039;, &#039;read&#039;))) { ?&gt;
&lt;a target=&quot;_blank&quot; href=&quot;&lt;?=$config[&#039;http_script_dir&#039;].&#039;/plugins/quixplorer/index.php?dir=&#039;.$tpl[&#039;post&#039;][&#039;id&#039;];?&gt;&quot;&gt;Редактировать прикрепленные файлы&lt;/a&gt;
&lt;? } ?&gt;</code></pre></div><p> (если у новости есть прикреплённые файлы, если пользователь залогинен, если ему даны права на эту новость и на плагин Quixplorer, то открыть папку с файлами этой новости). Даже если у вас в папке data/attach астрономически огромный список папок и файлов, то в данном случае откроется только нужная папка.</p><p><strong><span style="color: red">Безопасность</span></strong></p><p><span style="color: red">Будьте внимательны при использовании плагина!</span> Я, конечно же, постарался предусмотреть максимум возможностей взлома сайта через этот плагин и отсечь их, но тем не менее всегда найдётся умелец, который знает больше меня. Поэтому давайте договоримся, что данный плагин вы будете использовать <span style="color: red">на свой страх и риск!</span></p><p><strong>Упражнения &quot;на вырост&quot;</strong></p><p>1. Попробовал кэшировать информацию о папке data/attach, но по сути чтение/запись в кэш в данном случае - ничуть не менее громоздкая операция, чем простое чтение списка папок/файлов из папки data/attach. В принципе, желающие могут поупражняться с функцией make_tables из файла plugins/quixplorer/.include/fun_list.php.</p><p>2. Если заставить плагин Adepto Fastload работать через аякс, то можно попробовать вызывать Quixplorer прямо в режиме редактирования новости в админке.</p><p>3. Какие ещё способы защиты от взлома сайта можно применить, кроме предложенных мной? Напоминаю мои: авторизация через Strawberry, запрет доступа к файлам/папкам плагина в .htaccess&#039;ах, сокрытие ключевых папок плагина через префикс &quot;.&quot;.</p>]]></summary>
			<author>
				<name><![CDATA[ANT-Soft]]></name>
				<uri>http://strawberry.goodgirl.ru/forum/user/43/</uri>
			</author>
			<updated>2010-12-27T08:06:35Z</updated>
			<id>http://strawberry.goodgirl.ru/forum/topic/4000/new/posts/</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Тюнинг import.mdu]]></title>
			<link rel="alternate" href="http://strawberry.goodgirl.ru/forum/topic/3984/new/posts/"/>
			<summary type="html"><![CDATA[<p>Собираем данные через rss, делаем парсинг и загоняем всё в страбери 1.1.1.<br />+ проверяем наличие новости, чтобы не загонять по 2 раза</p><p>1. В начало import.mdu вставляем функцию парсинга. Её вам предстоит дописать с учетом особенностей страниц, который вы собираетесь парсить. Я предлагаю парсить отдельно заголовок и отдельно контент.</p><p>Парсим заголовок:<br /></p><div class="codebox"><pre><code>unction the_title ($URL) {
     $body=file_get_contents($URL);
     ТУТ ВСТАВЛЯЕМ АЛГОРИТМ ПАРСИНГА
     return $the_title; // объявляем нужное значение
}</code></pre></div><p>Парсим контент<br /></p><div class="codebox"><pre><code>function content_desc ($URL) {
     $body=file_get_contents($URL);
     ТУТ ВСТАВЛЯЕМ АЛГОРИТМ ПАРСИНГА
     return $content_desc; // объявляем нужное значение
}</code></pre></div><p>Эти две функции идут вверх.<br />--------------</p><p>Объявляем тег link (ссылка на новость)</p><div class="codebox"><pre><code>$tags = array(&#039;title&#039;, &#039;description&#039;, &#039;pubDate&#039;, &#039;category&#039;, &#039;link&#039;);</code></pre></div><p>------------</p><p>Теперь самое интересное (комментарии в коде)<br /></p><div class="codebox"><pre><code>for ($i = 0; $i &lt; count($result[&#039;title&#039;]); $i++){
            foreach ($tags as $tag){
                if ($result[$tag][$i]){
                    $result[$tag][$i] = join(&#039;,&#039;, $result[$tag][$i]);
                    $result[$tag][$i] = remove_cdata($result[$tag][$i]);

                    if (strtolower($config[&#039;charset&#039;]) != strtolower($match[3])){
                        $result[$tag][$i] = iconv($match[3], $config[&#039;charset&#039;], $result[$tag][$i]);
                    }
                }
            }            
                    $URL = $result[&#039;link&#039;][$i]; // объявляем адрес страницы для парсинга
                    $the_title = the_title($URL); // получаем наш спарсингованный заголовок
                    
/* проверяем наличие заголовка в базе  */
                    $test = &#039;SELECT title FROM news_news WHERE title=&quot;&#039;.$the_title.&#039;&quot;&#039;; 
                    $testresult = mysql_query($test);
                    if (!$testresult) { 
                        echo &quot;Could not successfully run query ($test) from DB: &quot; . mysql_error(); 
                        }
                    if (mysql_num_rows($testresult) == 0) { // если строк в базе с таким заголовком 0, то дабавляем ГОУ!
                        $go = &#039;go&#039;; 
                    } else {
                        $go = &#039;stop&#039;; // если новость (или новости) с таким названием в базе есть, то СТОП
                    }
                
                    if ($go == &#039;go&#039;) { // если ГОУ, то добавляем
                    $content_desc = content_desc($URL); // объявили контент

            $sql-&gt;insert(array(
            &#039;table&#039;  =&gt; &#039;news&#039;,
            &#039;values&#039; =&gt; array(
                        &#039;id&#039;       =&gt; ($id + $i),
                        &#039;date&#039;     =&gt; ($result[&#039;pubDate&#039;][$i] ? strtotime($result[&#039;pubDate&#039;][$i]) : time),
                        &#039;author&#039;   =&gt; $member[&#039;username&#039;],
                        &#039;category&#039; =&gt; $category,
                        &#039;title&#039;    =&gt; replace_news(&#039;add&#039;, $the_title), // вот сюда пошел наш спарсингованый title
                        &#039;url&#039;      =&gt; namespace(totranslit($result[&#039;title&#039;][$i])),
                        &#039;hidden&#039;   =&gt; cute_get_rights(&#039;approve_news&#039;),
                        &#039;short&#039;    =&gt; strlen(replace_news(&#039;add&#039;, $result[&#039;description&#039;][$i])),
                        &#039;full&#039;     =&gt; &#039;0&#039;
                        )
            ));

            $sql-&gt;insert(array(
            &#039;table&#039;   =&gt; &#039;story&#039;,
            &#039;values&#039;  =&gt; array(
                         &#039;post_id&#039; =&gt; ($id + $i),
                         &#039;short&#039;   =&gt; replace_news(&#039;add&#039;, $result[&#039;description&#039;][$i]),
                         &#039;full&#039;    =&gt; replace_news(&#039;add&#039;, $content_desc), // вот сюда пошел наш спарсингованый контент
                         )
            ));
            }
        }</code></pre></div><p>Работает.</p><p>Недостаток: если из 10 новостей в базе есть все 10, то после обработки нам напишет &quot;10 новостей успешно добавлены&quot;, хотя добавлены они не будут. Короче, информер про результат выполнения операции я не делал.</p><p><strong>P.S.</strong> Можно ограничить тюнинг импортом с проверокй наличия (без парсинга). <br />Для этого вместо<br /></p><div class="codebox"><pre><code>$test = &#039;SELECT title FROM news_news WHERE title=&quot;&#039;.$the_title.&#039;&quot;&#039;</code></pre></div><p>надо<br /></p><div class="codebox"><pre><code>$test = &#039;SELECT title FROM news_news WHERE title=&quot;&#039;.$result[&#039;title&#039;].&#039;&quot;&#039;</code></pre></div><p>и значения в <strong>&#039;values&#039; =&gt; array(</strong> надо будет вернуть те, которые по-умолчанию в оригинальном import.mdu</p><p><em><span style="color: #cccccc">15 минут и 3 секунды спустя:</span></em></p><p><strong>P.S.</strong> Только что дошло, что я префикс указал <strong>news_</strong> - это мой префикс. У вас должен быть свой.</p>]]></summary>
			<author>
				<name><![CDATA[cmd]]></name>
				<uri>http://strawberry.goodgirl.ru/forum/user/1313/</uri>
			</author>
			<updated>2010-11-27T19:31:34Z</updated>
			<id>http://strawberry.goodgirl.ru/forum/topic/3984/new/posts/</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[MyRobo - Роботы на сайте]]></title>
			<link rel="alternate" href="http://strawberry.goodgirl.ru/forum/topic/3978/new/posts/"/>
			<summary type="html"><![CDATA[<p>Название: MyRobo<br /> Версия: 1 (public beta)<br /> Описание: система обнаружения роботов, посещающих ваш сайт.<br /> Автор: Mr.Miksar<br /> Контакты:<br />&nbsp; &nbsp; E-mail: miksar@mail.ru<br />&nbsp; &nbsp; WWW: <a href="http://www.mgcorp.ru">http://www.mgcorp.ru</a><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.strawberry.su">http://www.strawberry.su</a></p><br /><br /><br /><p><strong>&nbsp; 1. Дополнительные функции:</strong></p><p>В ваш пакет(библиотеку) необходимо включить функцию:</p><div class="codebox"><pre><code>### Получение пользовательского агента
function getagent() {
    if (getenv(&quot;HTTP_USER_AGENT&quot;) &amp;&amp; strcasecmp(getenv(&quot;HTTP_USER_AGENT&quot;), &quot;unknown&quot;)) {
        $agent = htmlspecialchars(getenv(&quot;HTTP_USER_AGENT&quot;));
    } elseif (!empty($_SERVER[&#039;HTTP_USER_AGENT&#039;]) &amp;&amp; strcasecmp($_SERVER[&#039;HTTP_USER_AGENT&#039;], &quot;unknown&quot;)) {
        $agent = htmlspecialchars($_SERVER[&#039;HTTP_USER_AGENT&#039;]);
    } else {
        $agent = &quot;unknown&quot;;
    }
    return $agent;
}</code></pre></div><br /><br /><br /><br /><br /><p><strong>&nbsp; 2. Константы</strong></p><p>Для безопасности подключаемого файла с роботами, в ваших файлах<br />должны определяться константы str_define и robots_file. Т.е. все ваши подключаемые <br />страницы должны подчиняться выражениям:</p><div class="codebox"><pre><code>define(&quot;str_define&quot;, true); 
define(&#039;robots_file&#039;, &#039;путь/к/файлу/robots.php&#039;); // желательно от корня системы</code></pre></div><p>Для этого скопируйте их в файл, который всегда подключается выше остальных файлов.<br />Проще говоря - эти строки должны вызываться одними из первых.<br />(Для Strawberry это добавляется к аналогичным записям в файле inc/defined.inc.php)</p><br /><br /><br /><br /><p><strong>&nbsp; 3. Сравнение</strong><br />&nbsp; <br />Этот скрипт является основным. Его нужно прописать выше ваших счетчиков и прочих<br />систем и видов статистики, подключения новостей, определения/авторизации пользователей,<br />открытия сессии и т.д. (Для Strawberry -&nbsp; в head.php&nbsp; после строки include_once include_once includes_directory.&#039;/functions.inc.php&#039;; - она примерно 25)</p><div class="codebox"><pre><code>################################################
############# robots finder #########################
### Дополнительные переменные
  $ua = getagent(); // агент пользователя
  $ua_to_lower = str_replace(&quot;/&quot;, &quot;-::-&quot;, strtolower($ua)); // заменяем у агента слеши на значек -::- для сравнения с ключами массива роботов
  $ua_ln = strlen($ua); // определяем длину заголовка агента посетителя. Если длинна менее 30, то это, скорее всего, робот
### Скрипт сравнения
if(file_exists(robots_file) and filesize(robots_file) != 0 and $ua_ln &gt; 30) {  // проверяем файл и агент
  include_once robots_file; // если все в порядке - подключаем список роботов
    foreach ($allrobots as $rk =&gt; $rv) { // производим разложение массива на ключи и содержимое
       if (!empty($rk) and preg_match(&quot;#&quot;.$rk.&quot;#i&quot;, $ua_to_lower)) { //  если ключ есть и он присутствует в заголовке агента, то
          $robots[&#039;now&#039;] = !empty($rk) ? $rk : &quot;UnKnown&quot;; // сохраняем ключ агента 
          $spider_here = 1; // и сообщаем
          break; // При первом же совпадении завершаем перебор роботов из списка
       }
    }
} elseif($ua_ln &lt; 30) { // если заголовок агента менее 30 символов, то
   $robots[&#039;now&#039;] = $ua; // сохраняем его агент
   $spider_here = 1; // и сообщаем остальному скрипту, что на сайте робот
}
    
if (!empty($spider_here)) { // если робот на сайте, то
   $sesuser = &quot;robot&quot;;        // сессионная переменная пользователя содержит в себе ключ robot
   $id_session = 0;            // и id сессии зануляем
} else {                          // если робот не обнаружен, то
   @session_start();          // запускаем сессии для пользователя
   $id_session = @session_id(); // и получаем id сессии
}

############# robots finder #########################
################################################</code></pre></div><br /><br /><p><strong>&nbsp; 4. Заметки</strong></p><p>В системе Strawberry 1.2 переменная $sesuser далее (если зашел не робот) содержит в себе ключ <br />&quot;guest&quot; - если пользователь не авторизовался<br />&quot;user&quot; - если пользователь авторизовался</p><p>Это можно организовать так:</p><div class="codebox"><pre><code>if (!empty($is_logged_in)) {
 $sesuser = &quot;user&quot;;
} else {
 $sesuser = &quot;guest&quot;;
}</code></pre></div><p>Этот кусок можно вставить в файле head.php&nbsp; выше строки LoadActivePlugins();</p><br /><p>Данные ключи могут использоваться для хранения сессий в базе (в частности для определения кто он-лайн)</p><p>Переменную $spider_here удобно использовать для ограничения какой-то информации для роботов<br />или же наоборот - показывания ему нужной информации (например, разрешать роботу просматривать <br />скрытые поля от гостей в новостях, форумах и т.д.).</p><br /><p>-----------------------<br />Файл: <strong>robots.php</strong><br />Обновление: 12 ноября 2010<br />Число записей: 2360<br />Уникальность: более 2300<br />Вес: 121 кб<br />-----------------------</p><br /><p>Приветствуются отзывы и предложения по оптимизации кода сверки агента и списка роботов.<br /><strong>Внимание!</strong> скрипт может увеличить скорость загрузки страницы на 0.03-0.1 секунды...</p><p><em><span style="color: #cccccc">1 час, 5 минут и 58 секунд спустя:</span></em></p><p><a href="http://strawberry.goodgirl.ru/forum/misc.php?item=66&amp;download=1">http://strawberry.goodgirl.ru/forum/mis … download=1</a></p>]]></summary>
			<author>
				<name><![CDATA[Miksar]]></name>
				<uri>http://strawberry.goodgirl.ru/forum/user/688/</uri>
			</author>
			<updated>2010-11-13T13:20:21Z</updated>
			<id>http://strawberry.goodgirl.ru/forum/topic/3978/new/posts/</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Корзина Jcart интеграция]]></title>
			<link rel="alternate" href="http://strawberry.goodgirl.ru/forum/topic/3969/new/posts/"/>
			<summary type="html"><![CDATA[<p>Корзина Jcart <a href="http://conceptlogic.com/jcart/">http://conceptlogic.com/jcart/</a> </p><p>1 . настраивается шаблон новости<br /></p><div class="codebox"><pre><code>&lt;form method=&quot;post&quot; action=&quot;&quot; class=&quot;jcart&quot;&gt;
                    &lt;fieldset&gt;
                        &lt;input type=&quot;hidden&quot; name=&quot;my-item-id&quot; value=&quot;&lt;?=$tpl[&#039;post&#039;][&#039;id&#039;]; ?&gt;&quot; /&gt;
                        &lt;input type=&quot;hidden&quot; name=&quot;my-item-name&quot; value=&quot;&lt;?=$tpl[&#039;post&#039;][&#039;title&#039;]; ?&gt;&quot; /&gt;
                        &lt;input type=&quot;hidden&quot; name=&quot;my-item-price&quot; value=&quot;_доп поле цена_&quot; /&gt;

                        &lt;ul&gt;
                            &lt;li&gt;&lt;strong&gt;&lt;a href=&quot;&lt;?=$tpl[&#039;post&#039;][&#039;link&#039;][&#039;post&#039;]; ?&gt;&quot;&gt;&lt;?=$tpl[&#039;post&#039;][&#039;title&#039;]; ?&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;
           &lt;li&gt;&lt;img src=&quot;_путь к картинке_&quot; alt=&quot;&quot; border=&quot;0&quot; width=&quot;178&quot;&gt; &lt;/li&gt;
                            &lt;li&gt;Price: $&lt;?=_доп поле цена_?&gt;&lt;/li&gt;
                            &lt;li&gt;
                                &lt;label&gt;Qty: &lt;input type=&quot;text&quot; name=&quot;my-item-qty&quot; value=&quot;1&quot; size=&quot;3&quot; /&gt;&lt;/label&gt;
                            &lt;/li&gt;
                        &lt;/ul&gt;
         
                        &lt;input type=&quot;submit&quot; name=&quot;my-add-button&quot; value=&quot;add to cart&quot; class=&quot;button&quot; /&gt;
      
                    &lt;/fieldset&gt;
                &lt;/form&gt;</code></pre></div><p>2. .htaccess <br />php_flag register_globals off<br />php_value error_reporting 0</p><p>3. добавляется код корзины на страницу <br /></p><div class="codebox"><pre><code>&lt;?php $cart-&gt;display_cart($jcart);?&gt;</code></pre></div><br /><p>4.&nbsp; в начале index.php нужно сделать инклюд</p><div class="codebox"><pre><code>&lt;?php

// INCLUDE JCART BEFORE SESSION START
include &#039;jcart/jcart.php&#039;;

// START SESSION
session_start();

// INITIALIZE JCART AFTER SESSION START
$cart =&amp; $_SESSION[&#039;jcart&#039;]; if(!is_object($cart)) $cart = new jcart();

?&gt;</code></pre></div><p>5. index.php перед &lt;/head&gt; дописать</p><div class="codebox"><pre><code>            &lt;style type=&quot;text/css&quot;&gt;
            * { margin:0; padding:0; }

            #wrapper { }

            h2 { margin-bottom:1em; }

            #sidebar { width:35%; float:right; }

            #content  { width:60%; }

            .jcart { margin:0 20px 20px 0; padding-top:20px; border:dashed 2px #66cc66; float:left; background:#fff; text-align:center; }
            .jcart ul { margin:0; list-style:none; padding:0 20px; text-align:left; }
            .jcart fieldset { border:0; }
            .jcart strong { color:#000066; }
            .jcart .button { margin:20px; padding:5px; }

            fieldset { border:0; }
            #paypal-button { display:block; padding:10px; margin:20px auto; }

            .clear { clear:both; }
        &lt;/style&gt;

    &lt;script type=&quot;text/javascript&quot; src=&quot;jcart/jquery-1.3.2.min.js&quot;&gt;&lt;/script&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;jcart/jcart-javascript.min.php&quot;&gt;&lt;/script&gt;
      &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;screen, projection&quot; href=&quot;jcart/jcart.css&quot; /&gt;</code></pre></div><p>6. В файле jcart-gateway.php поменять MAIL@DOMAIN на свой email</p><p>7. добавить libmail.php в директорию jcart, где<br /> jcart-gateway.php и jcart.php</p><p>8. На gmail заказ может отправляться в папку Спам. </p><p>Все. <br />С исправленной кодировкой <a href="http://butea.net/files/jcart-new.rar">http://butea.net/files/jcart-new.rar</a></p><p>На новой версии может не работать так как писалось для JCART v1.1.<br />Поэтому на всякий случай прикрепляю эту версию&nbsp; <a href="http://butea.net/files/jcart-1.1.zip">http://butea.net/files/jcart-1.1.zip</a></p>]]></summary>
			<author>
				<name><![CDATA[annsun]]></name>
				<uri>http://strawberry.goodgirl.ru/forum/user/6623/</uri>
			</author>
			<updated>2010-10-27T09:09:49Z</updated>
			<id>http://strawberry.goodgirl.ru/forum/topic/3969/new/posts/</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Улучшенное управление картинками v.2]]></title>
			<link rel="alternate" href="http://strawberry.goodgirl.ru/forum/topic/3931/new/posts/"/>
			<summary type="html"><![CDATA[<p><strong>Улучшенное управление картинками v.2</strong><br /><em><strong>для Strawberry 1.1.1</strong></em></p><p><a href="http://strawberry.goodgirl.ru/forum/misc.php?item=56">images.mdu.v.2.rar (7 Kb)</a></p><p>Создавалась эта хрень на базе стандартного images.mdu и к вот <a href="http://strawberry.goodgirl.ru/forum/topic/126/">этому решению</a> отношения не имеет.</p><p><strong>Фичлист:</strong><br /><strong>1.</strong> Теперь есть возможность иметь две уменьшенные копии загружаемой картинки - для короткой и для полной новости.<br /><strong>2.</strong> Расширены возможности ресайза:<br />&nbsp; &nbsp; <strong>2.1.</strong> Готовые пресеты (150 пикселей по длинной стороне для короткой новости, 300 пикселей по ширине и по длинной стороне для полной новости).<br />&nbsp; &nbsp; <strong>2.2.</strong> Возможность задать ширину и высоту вручную (уменьшение будет происходить без сохранения пропорций, но если задать только высоту или только ширину - ресайзиться будет пропорционально до заданного размера).<br />&nbsp; &nbsp; <strong>2.3.</strong> &quot;Классический&quot; ресайз в процентах от оригинального изображения.<br /><strong>3.</strong> Какой же ресайз без шарпа? Правильно, х#@вый. Поэтому реализован шарпинг по алгоритму хорошо всем известного фотошопного плагина unsharp mask. Все три параметра настраиваются (amount - эффект шарпинга, radius - радиус пятна размытия для маски и treshhold - порог, при превышении значения которого разностью между маской и исходным изображением, будет срабатывать фильтр для каждого пикселя).<br /><strong>4.</strong> Полностью независимые настройки для обоих уменьшенных изображений.<br /><strong>5.</strong> Отдельные коды вставки для каждого из уменьшенных изображений (уменьшенное изображение является ссылкой на полноразмерное), плюс отдельный код для случая, когда не создается ни одной уменьшенной копии.<br /><strong>6.</strong> В списке изображений выводится размер в пикселях и килобайтах как для полноразмерной картинки, так и для ее уменьшенных копий (если они присутствуют).</p><p>А вот так все это выглядит:<br /><span class="postimg"><img src="http://www.xcnews.ru/images/mod-images.gif" alt="http://www.xcnews.ru/images/mod-images.gif" /></span></p><p><strong>Установка: </strong><br />Заменить /inc/mod/images.mdu файлом из архива.<br />Для изображений я использую <a href="http://highslide.com/">highslide</a> , а также обрамляю их вот таким div&#039;ом:<br /></p><div class="codebox"><pre><code>.news_img {float:left; border:none; margin-top: 8px; margin-right: 8px;}</code></pre></div><p>Если вам не нужны эти свистелки и перделки, просто закомментируйте строки 302, 309, 314 и раскомментируйте 301, 308 и 313.</p><p>Приятной работы с картинками без фотошопа!</p><p><strong>PS:</strong> если кто-нибудь допилит сюда вотермарк, будет ему респект и уважуха.</p>]]></summary>
			<author>
				<name><![CDATA[Zomb1e]]></name>
				<uri>http://strawberry.goodgirl.ru/forum/user/6312/</uri>
			</author>
			<updated>2010-09-07T21:12:22Z</updated>
			<id>http://strawberry.goodgirl.ru/forum/topic/3931/new/posts/</id>
		</entry>
</feed>

