вопрос
Помогите поправить скрипт, нужно чтоб этот скрипт, который сейчас создаёт дубликат новости в в той же базе данных, копировал новость в другую базу. Таблицы абсолютно идентичны.
<?php
@error_reporting ( E_ALL ^ E_WARNING ^ E_NOTICE );
@ini_set ( 'display_errors', true );
@ini_set ( 'html_errors', false );
@ini_set ( 'error_reporting', E_ALL ^ E_WARNING ^ E_NOTICE );
define( 'DATALIFEENGINE', true );
define( 'ROOT_DIR', substr( dirname( __FILE__ ), 0, -12 ) );
define( 'ENGINE_DIR', ROOT_DIR . '/engine' );
include ENGINE_DIR . '/data/config.php';
date_default_timezone_set ( $config['date_adjust'] );
if( $config['http_home_url'] == "" ) {
$config['http_home_url'] = explode( "engine/ajax/dubl.php", $_SERVER['PHP_SELF'] );
$config['http_home_url'] = reset( $config['http_home_url'] );
$config['http_home_url'] = "http://" . $_SERVER['HTTP_HOST'] . $config['http_home_url'];
}
require_once ENGINE_DIR . '/classes/mysql.php';
require_once ENGINE_DIR . '/data/dbconfig.php';
require_once ENGINE_DIR . '/modules/functions.php';
dle_session();
if ( isset( $_POST['snd'] ) )
{
$newsid = $_POST['snd'];
}
$d_post = $db->super_query( "SELECT * FROM " . PREFIX . "_post WHERE id = '{$newsid}'" );
$d_post_extras = $db->super_query( "SELECT * FROM " . PREFIX . "_post_extras WHERE news_id = '{$newsid}'" );
$d_images = $db->super_query( "SELECT * FROM " . PREFIX . "_images WHERE news_id = '{$newsid}'" );
$db->query( "SELECT tag FROM " . PREFIX . "_tags WHERE news_id = '{$newsid}'" );
while ( $d_tags = $db->get_row () ) {
$tags[] = "('" . $newsid . "', '" . trim( $d_tags['tag'] ) . "')";
}
$tags = implode( ", ", $tags );
$d_post['allow_comm'] = intval($d_post['allow_comm']);
$d_post['allow_main'] = intval($d_post['allow_main']);
$d_post['news_fixed'] = intval($d_post['fixed']);
$d_post['allow_br'] = intval($d_post['allow_br']);
$d_post['xfields'] = $db->safesql( $d_post['xfields'] );
$d_post['full_story'] = $db->safesql( $d_post['full_story'] );
$d_post['short_story'] = $db->safesql( $d_post['short_story'] );
$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_br, symbol, tags, metatitle) values ('{$d_post['date']}', '{$d_post['autor']}', '{$d_post['short_story']}', '{$d_post['full_story']}', '{$d_post['xfields']}', '{$d_post['title']}', '{$d_post['descr']}', '{$d_post['keywords']}', '{$d_post['category']}', '{$d_post['alt_name']}', '{$d_post['allow_comm']}', '0', '{$d_post['allow_main']}', '{$d_post['news_fixed']}', '{$d_post['allow_br']}', '{$d_post['catalog_url']}', '{$d_post['tags']}', '{$d_post['metatitle']}')" );
$row = $db->insert_id();
$usr = $db->super_query( "SELECT user_id FROM " . USERPREFIX . "_users WHERE name = '{$d_post['autor']}'" );
$db->query( "INSERT INTO " . PREFIX . "_post_extras (news_id, allow_rate, votes, disable_index, user_id) VALUES('{$row}', '{$d_post_extras['allow_rate']}', '0', '{$d_post_extras['disable_index']}', '{$usr['user_id']}')" );
if ( $tags ) $db->query( "INSERT INTO " . PREFIX . "_tags (news_id, tag) VALUES " . $tags );
//$db->query( "INSERT INTO " . PREFIX . "_images (images, news_id, author, date) VALUES('{$d_images['images']}', '{$row}', '{$d_post['autor']}', '{$d_images['date']}')" );
$db->query( "UPDATE " . USERPREFIX . "_users SET news_num=news_num+1 WHERE user_id='{$usr['user_id']}'" );
echo "<a href=" . $config['http_home_url'] . $config['admin_path'] . "?mod=editnews&action=editnews&id=" . $row . " target=\"_blank\">Auftrag bearbeiten</a>";