<?php
function ajax_add() {
global $ucoz;
global $_cfg;
$_POST['text'] = str_replace( '\\"', '"', $_POST['text'] );
$_POST['text'] = str_replace( "\\'", "'", $_POST['text'] );
$_POST['full'] = str_replace( '\\"', '"', $_POST['full'] );
$_POST['full'] = str_replace( "\\'", "'", $_POST['full'] );
if( $_cfg['grabber']['savecontents'] == TRUE ) {
list( $usec, $sec ) = explode( ' ', microtime() );
list( ,$usec ) = explode( '.', $usec );
$name = md5( $_POST['title'] . $_POST['text'] . $_POST['full'] . $_POST['cat'] ) . "_{$sec}_{$usec}";
$text = $_POST['text'];
$full = $_POST['full'];
unset( $_POST['text'] );
unset( $_POST['full'] );
file_put_contents( ROOT_PATH . 'contents/data/' . $name . '.txt', serialize( $_POST ) );
file_put_contents( ROOT_PATH . 'contents/' . $name . '_text.txt', $text );
file_put_contents( ROOT_PATH . 'contents/' . $name . '_full.txt', $full );
echo "1";
exit;
}
$ucoz_login = $ucoz->login();
if( $ucoz_login == FALSE ) {
echo iconv( 'windows-1251', 'utf-8', "Îøèáêà àâòîðèçàöèè" );
exit;
}
$text = $ucoz->parse_img( $_POST['text'] );
$full = $ucoz->parse_img( $_POST['full'] );
$text = preg_replace( '/<script/i', '<script', $text );
$full = preg_replace( '/<script/i', '<script', $full );
$news_add = $ucoz->news_add( $_POST['title'], $text, $full, $_POST['cat'] );
if( $news_add == FALSE ) {
echo iconv( 'windows-1251', 'utf-8', "Ïîëüçîâàòåëü {$ucoz->config['login']} íå ìîæåò äîáàâëÿòü íîâîñòè" );
exit;
}
echo "1";
sleep(45); // Добавить
}