Перенос новостей из категории А в категорию Б

Хак переносит новости из категории А в категорию Б при наступлении определенной даты, указанной в админ-панели.
1. выполнить sql-запрос к БД (если название префика у таблици отличается от стандартного, подправить):
ALTER TABLE `dles_post` ADD `expires_move` DATE DEFAULT '0000-00-00 ' NOT NULL AFTER `expires` ,
ADD `expires_categories` VARCHAR( 200 ) DEFAULT '0' NOT NULL AFTER `expires_move1`;


2. engine/inc/addnews.php
ищем
<tr>
        <td height="29" style="padding-left:5px;">{$lang['date_expires']}</td>
        <td><input type="text" name="expires" id="e_date_c" size="20"  class=edit>
<img src="engine/skins/images/img.gif"  align="absmiddle" id="e_trigger_c" style="cursor: pointer; border: 0" /><a href="#" class="hintanchor" onMouseover="showhint('{$lang['hint_expires']}', this, event, '320px')">[?]</a>
<script type="text/javascript">
    Calendar.setup({
        inputField     :    "e_date_c",     // id of the input field
        ifFormat       :    "%Y-%m-%d",     // format of the input field
        button         :    "e_trigger_c",  // trigger for the calendar (button ID)
        align          :    "Br",           // alignment
        singleClick    :    true
    });
</script></td>
    </tr>
    <tr>
        <td colspan="2"><div class="hr_line"></div></td>
    </tr>


ниже добавляем

<tr>
        <td height="29" style="padding-left:5px;">Переместить в категорию</td>
        <td><select name="categories">
        {$categories_list}
        </select> после <input type="text" name="expires_move" id="e_date_c_2" size="20" class="edit">
<img src="engine/skins/images/img.gif"  align="absmiddle" id="e_trigger_c_2" style="cursor: pointer; border: 0" /><a href="#" class="hintanchor" onMouseover="showhint('Ваша новость будет автоматически перемещена в указанную категорию, при наступлении установленного времени.', this, event, '320px')">[?]</a>
<script type="text/javascript">
    Calendar.setup({
        inputField     :    "e_date_c_2",     // id of the input field
        ifFormat       :    "%Y-%m-%d",      // format of the input field
        button         :    "e_trigger_c_2",  // trigger for the calendar (button ID)
        align          :    "Br",           // alignment
        singleClick    :    true
    });
</script></td>
    </tr>    
    
    <tr>
        <td colspan="2"><div class="hr_line"></div></td>
    </tr>


ищем
if (trim($_POST['expires']) != "") {
if ((($expires = strtotime($_POST['expires'])) === -1)) {
msg("error",$lang['addnews_error'],$lang['addnews_erdate'], "javascript:history.go(-1)"); }
else {
$expires = date ("Y-m-d", $expires);
}
    } else $expires = '0000-00-00';



ниже добавляем

    //CTAR&K added
if (trim($_POST['expires_move']) != "") {
    if ((($expires_move = strtotime($_POST['expires_move'])) === -1)) {
        msg("error",$lang['addnews_error'],$lang['addnews_erdate'], "javascript:history.go(-1)"); }
    else {
        $expires_move = date ("Y-m-d", $expires_move);
    }
} else $expires_move = '0000-00-00';




ищем
$filecontents = implode("||", $filecontents);

    } else $filecontents = '';


ниже:
заменяем $db->query("INSERT INTO "..... на это:

    $db->query("INSERT INTO " . PREFIX . "_post (date, autor, short_story, full_story, xfields, title, descr, keywords, category, alt_name, allow_comm, approve, allow_main, fixed, allow_rate, allow_br, votes, access, expires, expires_move, expires_categories, symbol, flag) values ('$thistime', '$member_db[2]', '$short_story', '$full_story', '$filecontents', '$title', '{$metatags['description']}', '{$metatags['keywords']}', '$category_list', '$alt_name', '$allow_comm', '$approve', '$allow_main', '$news_fixed', '$allow_rating', '$allow_br', '$add_vote', '$group_regel', '$expires', '$expires_move', '$categories', '$catalog_url', '1')");



==============================================================================
3. engine/inc/editnews.php
ищем
$allow_br = isset($_POST['allow_br']) ? intval($_POST['allow_br']) : 0;
ниже добавляем
//CTAR&K added
$categories = isset($_POST['categories']) ? intval($_POST['categories']) : 0;



ищем
<tr>
        <td height="29" style="padding-left:5px;">{$lang['date_expires']}</td>
        <td><input type="text" name="expires" id="e_date_c" size="20"  class="edit" value="{$row['expires']}">
<img src="engine/skins/images/img.gif"  align="absmiddle" id="e_trigger_c" style="cursor: pointer; border: 0" /><a href="#" class="hintanchor" onMouseover="showhint('{$lang['hint_expires']}', this, event, '320px')">[?]</a>
<script type="text/javascript">
    Calendar.setup({
        inputField     :    "e_date_c",     // id of the input field
        ifFormat       :    "%Y-%m-%d",      // format of the input field
        button         :    "e_trigger_c",  // trigger for the calendar (button ID)
        align          :    "Br",           // alignment
        singleClick    :    true
    });
</script></td>
    </tr>
    <tr>
        <td colspan="2"><div class="hr_line"></div></td>
    </tr>




ниже добавляем
<tr>
        <td height="29" style="padding-left:5px;">Переместить в категорию</td>
        <td><select name="categories">
        {$categories_list}
        </select> после <input type="text" name="expires_move" id="e_date_c_2" size="20" class="edit">
<img src="engine/skins/images/img.gif"  align="absmiddle" id="e_trigger_c_2" style="cursor: pointer; border: 0" /><a href="#" class="hintanchor" onMouseover="showhint('Ваша новость будет автоматически перемещена в указанную категорию, при наступлении установленного времени.', this, event, '320px')">[?]</a>
<script type="text/javascript">
    Calendar.setup({
        inputField     :    "e_date_c_2",     // id of the input field
        ifFormat       :    "%Y-%m-%d",      // format of the input field
        button         :    "e_trigger_c_2",  // trigger for the calendar (button ID)
        align          :    "Br",           // alignment
        singleClick    :    true
    });
</script></td>
    </tr>
    <tr>
        <td colspan="2"><div class="hr_line"></div></td>
    </tr>





ищем
if (trim($_POST['expires']) != "") {
if ((($expires = strtotime($_POST['expires'])) === -1)) {
msg("error",$lang['addnews_error'],$lang['addnews_erdate'], "javascript:history.go(-1)"); }
else {
$expires = date ("Y-m-d", $expires);
}
    } else $expires = '0000-00-00';



ниже добавляем
   //CTAR&K added
if (trim($_POST['expires_move']) != "") {
    if ((($expires_move = strtotime($_POST['expires_move'])) === -1)) {
        msg("error",$lang['addnews_error'],$lang['addnews_erdate'], "javascript:history.go(-1)"); }
    else {
        $expires_move = date ("Y-m-d", $expires_move);
    }
} else $expires_move = '0000-00-00';




ищем

$result = $db->query("UPDATE " . PREFIX . "_post set title='$title', date='$thistime', ......
заменяем целиком стоку. т.е. в итоге должно получиться так:
    $result = $db->query("UPDATE " . PREFIX . "_post set title='$title', date='$thistime', short_story='$short_story', full_story='$full_story', descr='{$metatags['description']}', keywords='{$metatags['keywords']}', category='$category_list', alt_name='$alt_name', allow_comm='$allow_comm', approve='$approve', allow_main='$allow_main', allow_rate='$allow_rating', fixed='$news_fixed', allow_br='$allow_br', votes='$add_vote', access='$group_regel', expires='$expires', expires_move='$expires_move', expires_categories='$categories', symbol='$catalog_url', flag='1' WHERE id='$item_db[0]'");



и ниже после } else {

$result = $db->query("UPDATE " . PREFIX . "_post set title='$title', short_story='$short_story' ...
заменяем на
$result = $db->query("UPDATE " . PREFIX . "_post set title='$title', short_story='$short_story', full_story='$full_story', descr='{$metatags['description']}', keywords='{$metatags['keywords']}', category='$category_list', alt_name='$alt_name', allow_comm='$allow_comm', approve='$approve', allow_main='$allow_main', allow_rate='$allow_rating', fixed='$news_fixed', allow_br='$allow_br', votes='$add_vote', access='$group_regel', expires='$expires', expires_move='$expires_move', expires_categories='$categories', symbol='$catalog_url' WHERE id='$item_db[0]'");



============================================================
4. engine/modules/cron.php
ищем
if ($cron == 2) {


ниже добавляем
    //CTAR&K added
    $cron_move = $db->query("SELECT id, expires_move, expires_categories FROM " . PREFIX . "_post WHERE expires_move != '0000-00-00' AND expires_move < '".date("Y-m-d", $_TIME)."'");

    while($rows = $db->get_row($cron_move)){
        $db->query("UPDATE " . PREFIX . "_post SET category='{$rows['expires_categories']}', expires_move='0000-00-00', expires_categories='0' WHERE id='{$rows['id']}'");
    }
        $db->free($cron_move);


hack_move.zip [18,62 Kb] (cкачиваний: 37)
Другие новости по теме:

Категория: Хаки ----- Просмотров: 2055 ----- Комментариев: 2

Вернуться

  • Группа: Гости
  • ICQ: --
  • Регистрация: --
  • Комментариев: 0
  • Публикаций: 0
^
Большое спасибо! Пригодится для меня в самый раз, так как есть категория на сайте Афиша, ну а после того, как пройдет мероприятие, то перенесет новость в обычный раздел! Пасибо )
  • SkiFteL

  • 24 августа 2009 20:39
  • Группа: Гости
  • ICQ: --
  • Регистрация: --
  • Комментариев: 0
  • Публикаций: 0
^
Да превосходная вещь кто подскажет на дле 8.2 покатит?