query( "UPDATE " . PREFIX . "_post SET {$field}='{$value}' WHERE id='{$id}'" );
if( $field == "approve" ) {
if( $value ) {
$db->query( "DELETE FROM " . PREFIX . "_tags WHERE news_id = '{$id}'" );
$row = $db->super_query( "SELECT tags FROM " . PREFIX . "_post where id = '{$id}'" );
if( $row['tags'] ) {
$tags = array ();
$row['tags'] = explode( ",", $row['tags'] );
foreach ( $row['tags'] as $tags_value ) {
$tags[] = "('" . $id . "', '" . trim( $tags_value ) . "')";
}
$tags = implode( ", ", $tags );
$db->query( "INSERT INTO " . PREFIX . "_tags (news_id, tag) VALUES " . $tags );
}
} else {
$db->query( "DELETE FROM " . PREFIX . "_tags WHERE news_id = '{$id}'" );
}
}
if ( $field == "rating" ) {
$db->query( "DELETE FROM " . PREFIX . "_rate WHERE type_id = '{$id}' AND type=1" );
}
}
$cache->clear();
msg( "info", $lang['db_ok'], $lang['db_ok_1'], $_SESSION['admin_referrer'] );
}
if( $k_mass ) {
echoheader( "options", $lang['mass_head'] );
echo <<
HTML;
echofooter();
exit();
}
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Подтвреждение удаления
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
if( $action == "mass_delete" ) {
echoheader( "options", $lang['mass_head'] );
echo <<
HTML;
echofooter();
exit();
}
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Удаление новостей
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
elseif( $action == "do_mass_delete" ) {
$deleted_articles = 0;
foreach ( $selected_news as $id ) {
$id = intval( $id );
$row = $db->super_query( "SELECT autor FROM " . PREFIX . "_post where id = '$id'" );
$db->query( "UPDATE " . USERPREFIX . "_users set news_num=news_num-1 where name='{$row['autor']}'" );
$deleted_articles ++;
$db->query( "DELETE FROM " . PREFIX . "_post WHERE id='$id'" );
$db->query( "DELETE FROM " . PREFIX . "_comments WHERE post_id='$id'" );
$db->query( "SELECT onserver FROM " . PREFIX . "_files WHERE news_id = '$id'" );
while ( $row = $db->get_row() ) {
@unlink( ROOT_DIR . "/uploads/files/" . $row['onserver'] );
}
$db->query("SELECT id, link, thumb FROM " . PREFIX . "_covers WHERE newsid = '$id'");
while($row_covers = $db->get_row()){
@unlink(ROOT_DIR."/uploads".$row_covers['link']);
@unlink(ROOT_DIR."/uploads".$row_covers['thumb']);
}
$db->query("DELETE FROM " . PREFIX . "_covers WHERE newsid = '$id'");
$db->query("SELECT id, onserver FROM " . PREFIX . "_torrents WHERE news_id = '$id'");
while($row_torrents = $db->get_row()){
@unlink(ROOT_DIR."/uploads/torrents/".$row_torrents['onserver']);
}
$db->query( "UPDATE " . PREFIX . "_torrents SET flags=1 where news_id='$id'" );
$db->free();
$db->query( "DELETE FROM " . PREFIX . "_files WHERE news_id = '$id'" );
$db->query( "DELETE FROM " . PREFIX . "_poll WHERE news_id = '$id'" );
$db->query( "DELETE FROM " . PREFIX . "_poll_log WHERE news_id = '$id'" );
$db->query( "DELETE FROM " . PREFIX . "_rate WHERE type_id = '$id' AND type=1" );
$db->query( "DELETE FROM " . PREFIX . "_tags WHERE news_id = '$id'" );
$row = $db->super_query( "SELECT images FROM " . PREFIX . "_images where news_id = '$id'" );
$listimages = explode( "|||", $row['images'] );
if( $row['images'] != "" ) foreach ( $listimages as $dataimages ) {
$url_image = explode( "/", $dataimages );
if( count( $url_image ) == 2 ) {
$folder_prefix = $url_image[0] . "/";
$dataimages = $url_image[1];
} else {
$folder_prefix = "";
$dataimages = $url_image[0];
}
@unlink( ROOT_DIR . "/uploads/posts/" . $folder_prefix . $dataimages );
@unlink( ROOT_DIR . "/uploads/posts/" . $folder_prefix . "thumbs/" . $dataimages );
}
$db->query( "DELETE FROM " . PREFIX . "_images WHERE news_id = '$id'" );
}
$cache->clear();
if( count( $selected_news ) == $deleted_articles ) {
msg( "info", $lang['mass_head'], $lang['mass_delok'], $_SESSION['admin_referrer'] );
} else {
msg( "error", $lang['mass_notok'], "$deleted_articles $lang[mass_i] " . count( $selected_news ) . " $lang[mass_notok_1]", $_SESSION['admin_referrer'] );
}
}
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Подтвеждение смены категорий
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
elseif( $action == "mass_move_to_cat" ) {
echoheader( "options", $lang['mass_cat'] );
$count = count( $selected_news );
if( $config['allow_multi_category'] ) $category_multiple = "class=\"cat_select\" multiple";
else $category_multiple = "";
echo <<
HTML;
echofooter();
exit();
}
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
смена категории
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
elseif( $action == "do_mass_move_to_cat" ) {
$moved_articles = 0;
$move_to_category = $db->safesql( implode( ',', $_REQUEST['move_to_category'] ) );
foreach ( $selected_news as $id ) {
$moved_articles ++;
$id = intval( $id );
$db->query( "UPDATE " . PREFIX . "_post set category='$move_to_category' WHERE id='$id'" );
}
$cache->clear();
if( count( $selected_news ) == $moved_articles ) {
msg( "info", $lang['mass_cat_ok'], "$lang[mass_cat_ok] ($moved_articles)", $_SESSION['admin_referrer'] );
} else {
msg( "error", $lang['mass_cat_notok'], $lang['mass_cat_notok_1'], $_SESSION['admin_referrer'] );
}
}
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ничего не выбрано
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
else {
msg( "info", $lang['mass_noact'], $lang['mass_noact_1'], $_SESSION['admin_referrer'] );
}
?>