Универсальный парсер

Универсальный парсер 0.7.2

Нет прав для скачивания

OmegaSOFT

Заблокирован
Обратите внимание, если вы хотите заключить сделку с этим пользователем, что он заблокирован.
как установить парсер и куда кидать файлы
 

votanumu

Пользователь
Можно ли по умолчанию настроить парсер, чтобы при загрузке описания раздачи, загружался сразу торрент-файл и происходила публикация? Т.е. по умолчанию в опциях парсера уже стояли бы галочки:

Please Login or Register to view hidden text.



Было бы очень удобно для особо ленивых :)

Огромная благодарность Lektor за модуль! Очень облегчает жизнь.
 

Vorezo

Пользователь
Здравствуйте. Подскажите, пожалуйста, что не так. Все поставила по инструкции, все нашла, все ок. Но, какие бы ссылки не вставляла, какие бы опции не выбирала, не происходит ничего. После нажатия на "отправить". Ни-че-го. Поможите, люди добрые)

P.S. Тему прочитала, права на папку cookies поставила (она, кстати, пустая, только .htaccess), видео посмотрела.

P.P.S. Версия 2.1.5, апач, дебиан

Аналогичная проблема. Все сделал по инструкции. Но вместо написанного в инструкции
copy library/ajax/parser.php to library/ajax/parser.php скопировал в папку /ajax/ потому что нету папки library
так же и с copy library/includes/functions_parser.php, скопировал просто в папку includes

Все остальное сделал по инструкции.

Файлы прилагаю.:
<?php

define('BB_SCRIPT', 'ajax');
define('IN_AJAX', true);

$ajax = new ajax_common();

require('./common.php');

$ajax->init();

// Init userdata
$user->session_start();

// Exit if board is disabled via ON/OFF trigger or by admin
if ($ajax->action != 'manage_admin')
{
if ($bb_cfg['board_disable'])
{
$ajax->ajax_die($lang['BOARD_DISABLE']);
}
else if (file_exists(BB_DISABLED))
{
$ajax->ajax_die($lang['BOARD_DISABLE_CRON']);
}
}

// Load actions required modules
switch ($ajax->action)
{
case 'chat':
case 'view_post':
require(INC_DIR .'bbcode.php');
break;

case 'update_peers':
require(BB_ROOT .'mult/config.php');
require(BB_ROOT .'mult/func.php');
require(BB_ROOT .'mult/class.remote.php');
require(BB_ROOT .'mult/class.fbenc.php');
require(BB_ROOT .'mult/class.bittorrent.php');
require(BB_ROOT .'mult/class.getpeers.php');
break;

case 'posts':
case 'post_mod_comment':
require(INC_DIR . 'bbcode.php');
require(INC_DIR . 'functions_post.php');
require(INC_DIR . 'functions_admin.php');
break;

case 'view_torrent':
case 'mod_action':
case 'change_tor_status':
case 'gen_passkey':
require(ATTACH_DIR . 'attachment_mod.php');
require(INC_DIR . 'functions_torrent.php');
break;

case 'change_torrent':
require(ATTACH_DIR . 'attachment_mod.php');
require(INC_DIR . 'functions_torrent.php');
break;

case 'user_register':
require(INC_DIR . 'functions_validate.php');
break;

case 'manage_user':
case 'manage_admin':
require(INC_DIR . 'functions_admin.php');
break;

case 'group_membership':
case 'manage_group':
require(INC_DIR . 'functions_group.php');
break;

case 'sitemap';
require(INC_DIR .'class.sitemap.php');
break;

case 'pars':
require(INC_DIR . 'functions_parser.php');
break;

case 'autoparser':
require(INC_DIR .'class.snoopy.php');
break;
}

// Position in $ajax->valid_actions['xxx']
define('AJAX_AUTH', 0); // 'guest', 'user', 'mod', 'admin', 'super_admin'

$ajax->exec();

//
// Ajax
//
class ajax_common
{
var $request = array();
var $response = array();

var $valid_actions = array(
// ACTION NAME AJAX_AUTH
'edit_user_profile' => array('admin'),
'change_user_rank' => array('admin'),
'change_user_opt' => array('admin'),
'manage_user' => array('admin'),
'manage_admin' => array('admin'),
'sitemap' => array('admin'),
'autoparser' => array('admin'),

'mod_action' => array('mod'),
'topic_tpl' => array('mod'),
'group_membership' => array('mod'),
'post_mod_comment' => array('mod'),
'update_peers' => array('mod'),

'avatar' => array('user'),
'gen_passkey' => array('user'),
'change_torrent' => array('user'),
'change_tor_status' => array('user'),
'manage_group' => array('user'),
'pars' => array('user'),
'user_stats' => array('user'),
'users_today' => array('user'),

'view_post' => array('guest'),
'view_torrent' => array('guest'),
'user_register' => array('guest'),
'posts' => array('guest'),
'index_data' => array('guest'),
'chat' => array('guest'),
);

var $action = null;

/**
* Constructor
*/
function ajax_common()
{
ob_start(array(&$this, 'ob_handler'));
header('Content-Type: text/plain');
}

/**
* Perform action
*/
function exec()
{
global $lang;

// Exit if we already have errors
if (!empty($this->response['error_code']))
{
$this->send();
}

// Check that requested action is valid
$action = $this->action;

if (!$action || !is_string($action))
{
$this->ajax_die('no action specified');
}
elseif (!$action_params =& $this->valid_actions[$action])
{
$this->ajax_die('invalid action: ' . $action);
}

// Auth check
switch ($action_params[AJAX_AUTH])
{
// GUEST
case 'guest':
break;

// USER
case 'user':
if (IS_GUEST)
{
$this->ajax_die($lang['NEED_TO_LOGIN_FIRST']);
}
break;

// MOD
case 'mod':
if (!IS_AM)
{
$this->ajax_die($lang['ONLY_FOR_MOD']);
}
$this->check_admin_session();
break;

// ADMIN
case 'admin':
if (!IS_ADMIN)
{
$this->ajax_die($lang['ONLY_FOR_ADMIN']);
}
$this->check_admin_session();
break;

// SUPER_ADMIN
case 'super_admin':
if (!IS_SUPER_ADMIN)
{
$this->ajax_die($lang['ONLY_FOR_SUPER_ADMIN']);
}
$this->check_admin_session();
break;

default:
trigger_error("invalid auth type for $action", E_USER_ERROR);
}

// Run action
$this->$action();

// Send output
$this->send();
}

/**
* Exit on error
*/
function ajax_die($error_msg, $error_code = E_AJAX_GENERAL_ERROR)
{
$this->response['error_code'] = $error_code;
$this->response['error_msg'] = $error_msg;

$this->send();
}

/**
* Initialization
*/
function init()
{
$this->request = $_POST;
$this->action =& $this->request['action'];
}

/**
* Send data
*/
function send()
{
$this->response['action'] = $this->action;

if (DBG_USER && SQL_DEBUG && !empty($_COOKIE['sql_log']))
{
$this->response['sql_log'] = get_sql_log();
}

// sending output will be handled by $this->ob_handler()
exit();
}

/**
* OB Handler
*/
function ob_handler($contents)
{
if (DBG_USER)
{
if ($contents)
{
$this->response['raw_output'] = $contents;
}
}

$response_js = bb_json_encode($this->response);

if (GZIP_OUTPUT_ALLOWED && !defined('NO_GZIP'))
{
if (UA_GZIP_SUPPORTED && strlen($response_js) > 2000)
{
header('Content-Encoding: gzip');
$response_js = gzencode($response_js, 1);
}
}

return $response_js;
}

/**
* Admin session
*/
function check_admin_session()
{
global $user;

if (!$user->data['session_admin'])
{
if (empty($this->request['user_password']))
{
$this->prompt_for_password();
}
else
{
$login_args = array(
'login_username' => $user->data['username'],
'login_password' => $_POST['user_password'],
);
if (!$user->login($login_args, true))
{
$this->ajax_die('Wrong password');
}
}
}
}

/**
* Prompt for password
*/
function prompt_for_password()
{
$this->response['prompt_password'] = 1;
$this->send();
}

/**
* Prompt for confirmation
*/
function prompt_for_confirm($confirm_msg)
{
if (empty($confirm_msg)) $this->ajax_die('false');

$this->response['prompt_confirm'] = 1;
$this->response['confirm_msg'] = $confirm_msg;
$this->send();
}

/**
* Verify mod rights
*/
function verify_mod_rights($forum_id)
{
global $userdata, $lang;

$is_auth = auth(AUTH_MOD, $forum_id, $userdata);

if (!$is_auth['auth_mod'])
{
$this->ajax_die($lang['ONLY_FOR_MOD']);
}
}

function edit_user_profile()
{
require(AJAX_DIR . 'edit_user_profile.php');
}

function change_user_rank()
{
require(AJAX_DIR . 'change_user_rank.php');
}

function change_user_opt()
{
require(AJAX_DIR . 'change_user_opt.php');
}

function gen_passkey()
{
require(AJAX_DIR . 'gen_passkey.php');
}

function group_membership()
{
require(AJAX_DIR . 'group_membership.php');
}

function manage_group()
{
require(AJAX_DIR . 'edit_group_profile.php');
}

function pars()
{
require(AJAX_DIR . 'parser.php');
}

function post_mod_comment()
{
require(AJAX_DIR . 'post_mod_comment.php');
}

function view_post()
{
require(AJAX_DIR . 'view_post.php');
}

function change_tor_status()
{
require(AJAX_DIR . 'change_tor_status.php');
}

function change_torrent()
{
require(AJAX_DIR . 'change_torrent.php');
}

function view_torrent()
{
require(AJAX_DIR . 'view_torrent.php');
}

function user_register()
{
require(AJAX_DIR . 'user_register.php');
}

function mod_action()
{
require(AJAX_DIR . 'mod_action.php');
}

function posts()
{
require(AJAX_DIR . 'posts.php');
}

function manage_user()
{
require(AJAX_DIR . 'manage_user.php');
}

function manage_admin()
{
require(AJAX_DIR . 'manage_admin.php');
}

function topic_tpl()
{
require(AJAX_DIR . 'topic_tpl.php');
}

function index_data()
{
require(AJAX_DIR . 'index_data.php');
}

function avatar()
{
require(AJAX_DIR . 'avatar.php');
}

function sitemap()
{
require(AJAX_DIR .'sitemap.php');
}

function user_stats()
{
global $bb_cfg, $lang;
$user_id = (int) $this->request['user_id'];
$btu = get_bt_userdata($user_id);

$ratio = get_bt_ratio($btu);
$u_up_total = humn_size($btu['u_up_total']);
$u_up_bonus = humn_size($btu['u_up_bonus']);
$u_up_release = humn_size($btu['u_up_release']);
$u_down_total = humn_size($btu['u_down_total']);
if ($btu['u_down_total'] < MIN_DL_FOR_RATIO) $ratio = '---';
############ Закончили ###################
############ Выводим данные ##############
$this->response['post_id'] = (int) $this->request['post_id'];
$this->response['html'] = '
<table class="ratio1 table-wrap bCenter borderless w100" cellspacing="1" style="border-style: inset;">
<tr class="row6 tCenter">
<td colspan="2" class="bold">Статистика</td>
</tr>
<tr class="row5 seed">
<td class="med tLeft">&nbsp;'.$lang['USER_RATIO'].':</p></td>
<td class="bold tLeft">&nbsp;'.$ratio.'</td>
</tr>
<tr class="row5 leech">
<td class="med tLeft">&nbsp;<a class="leechsmall" href="search.php?dlu='.$user_id.'&dlc=1#results">'.$lang['DOWNLOADED'].'</a>:&nbsp;</td>
<td class="bold tLeft">&nbsp;'.$u_down_total.'</td>
</tr>
<tr class="row1 seed">
<td class="med tLeft">&nbsp;'.$lang['UPLOADED'].':&nbsp;</p></td>
<td class="bold tLeft">&nbsp;'.$u_up_total.'</td>
</tr>
<tr class="row5 seed">
<td class="med tLeft">&nbsp;<i><a class="seedsmall" href="tracker.php?rid='.$user_id.'#results">'.$lang['RELEASED'].'</a>:</i>&nbsp;</td>
<td class="tLeft">&nbsp;<i>'.$u_up_release.'</i></td>
</tr>
<tr class="row1 dlWill">
<td class="med tLeft">&nbsp;<i><a class="small dlWill" href="viewtopic.php?t=5">'.$lang['BONUS'].'</a>:</i>&nbsp;</td>
<td class="tLeft">&nbsp;<i>'.$u_up_bonus.'</i></td>
</tr>
</table>
';
}

function users_today()
{
require(AJAX_DIR .'users_today.php');
}

function update_peers()
{
global $db, $cfg_ann, $lang;
$seed = $leech = 0;
$topic_id = (int) $this->request['topic_id'];
$row = DB()->fetch_row("SELECT info_hash FROM ".BB_BT_TORRENTS." WHERE topic_id = ".$topic_id." LIMIT 1");
if($row && $info_hash = $row['info_hash'])
{
$gp = new getpeers();
$data = $gp->get_peers(1, serialize($cfg_ann), bin2hex($info_hash), false);
foreach($data['peers'] as $announce)
{
$seed = (int) $seed + $announce[0];
$leech = (int) $leech + $announce[1];
}
//DB()->query("UPDATE ".BB_BT_TORRENTS." SET last_update = ".$data['last_update'].", ext_seeder = ".$seed.", ext_leecher = ".$leech." WHERE info_hash = '".DB()->escape($info_hash)."'");
DB()->query("UPDATE ".BB_BT_TORRENTS." SET last_update = ".$data['last_update'].", ext_seeder = ".$seed.", ext_leecher = ".$leech." WHERE topic_id = $topic_id");
$html = '<div class="mrg_4 pad_4">';
$html .= '<span class="seed">'. $lang['SEEDERS'] .':&nbsp; <b>'. $seed .'</b> &nbsp;[&nbsp; 0 KB/s &nbsp;]</span> &nbsp;';
$html .= '<span class="leech">'. $lang['LEECHERS'] .':&nbsp; <b>'. $leech .'</b> &nbsp;[&nbsp; 0 KB/s &nbsp;]</span> &nbsp;';
$html .= '</div>';
}
$this->response['html'] = $html;
$this->response['topic_id'] = $topic_id;
}

function autoparser()
{
global $lang, $bb_cfg;

$mode = (string) $this->request['mode'];

if($mode == 'cookie')
{
$login = (string) DB()->escape($this->request['login']);
@$cookie = (string) urldecode($this->request['cookie']);
$id = (int) $this->request['id'];

$row = DB()->fetch_row("SELECT * FROM parser_users WHERE login = '$login'");
if(!$row) bb_die('Такой учетки нет в базе');

$snoopy = new Snoopy;
$snoopy->host = "rutracker.org";
$snoopy->agent = "opera";
$snoopy->referer = "

Please Login or Register to view hidden text.

";
$snoopy->rawheaders["Pragma"] = "no-cache";

$snoopy->cookies['bb_data'] = $cookie;
$snoopy->fetch("

Please Login or Register to view hidden text.

");

if(preg_match('#privmsg#', $snoopy->results))
{
if($cookie != $row['cookie'])
{
DB()->query("UPDATE parser_users SET cookie = '$cookie', time = ". TIMENOW ." WHERE login = '$login' AND id = $id");
}
$this->response['html'] = '<img src="'. make_url('images/good.gif') .'">';
$this->response['time'] = '<span class="tr_tm">только что</span>';
}
else
{
$this->response['html'] = '<img src="'. make_url('images/bad.gif') .'">';
}

$this->response['cookie'] = $cookie;
$this->response['login'] = $login;
}
elseif($mode == 'pass')
{
$login = (string) DB()->escape($this->request['login']);
$id = (int) $this->request['id'];
$pass = (string) $this->request['pass'];
$row = DB()->fetch_row("SELECT * FROM parser_users WHERE login = '$login' AND id = $id");
if(!$row) $this->ajax_die('Такой учетки нет в базе');

DB()->query("UPDATE parser_users SET pass = '$pass' WHERE login = '$login' AND id = $id");
}
elseif($mode == 'user_del')
{
$login = (string) DB()->escape($this->request['login']);
$id = (int) $this->request['id'];

if(!IS_SUPER_ADMIN) $this->ajax_die($lang['ONLY_FOR_SUPER_ADMIN']);
if (empty($this->request['confirmed'])) $this->prompt_for_confirm($lang['USER_DELETE_CONFIRM']);

DB()->query("DELETE FROM parser_users WHERE login = '$login' AND id = $id");

$this->response['id'] = $id;
}
elseif($mode == 'forum_del')
{
$from_url = (string) urldecode($this->request['from_url']);

DB()->query("DELETE FROM parser_from_urls WHERE from_url = '$from_url'");
}
elseif($mode == 'change_user_id')
{
$new_user = (string) $this->request['user'];
$url = (string) $this->request['url'];

if(!$url || !$new_user) $this->ajax_die('false id');
if(($new_user != BOT_UID) && !$new = get_userdata($new_user)) $this->ajax_die($lang['NO_USER_ID_SPECIFIED']);
if($new) $new_user = $new['user_id'];

DB()->query("UPDATE parser_from_urls SET user_id = $new_user WHERE from_url = '$url'");

$this->response['user'] = ($new) ? profile_url($new) : 'Bot';
$this->response['url'] = md5($url);
}
elseif($mode == 'all_status')
{
$from_url = (string) urldecode($this->request['from_url']);
if(!$from_url) $this->ajax_die('false id');

$row = DB()->fetch_row("SELECT * FROM parser_from_urls WHERE from_url = '$from_url'");
if(!$row) $this->ajax_die('Такой записи нет в базе');

$all_status = (int) !$row['all_status'];

DB()->query("UPDATE parser_from_urls SET all_status = $all_status WHERE from_url = '$from_url'");
}
elseif($mode == 'all_forum')
{
$from_url = (string) urldecode($this->request['from_url']);
if(!$from_url) $this->ajax_die('false id');

$row = DB()->fetch_row("SELECT * FROM parser_from_urls WHERE from_url = '$from_url'");
if(!$row) $this->ajax_die('Такой записи нет в базе');

$all_forum = (int) !$row['all_forum'];

DB()->query("UPDATE parser_from_urls SET all_forum = $all_forum WHERE from_url = '$from_url'");
}
elseif($mode == 'active')
{
$from_url = (string) urldecode($this->request['from_url']);
if(!$from_url) $this->ajax_die('false id');

$row = DB()->fetch_row("SELECT * FROM parser_from_urls WHERE from_url = '$from_url'");
if(!$row) $this->ajax_die('Такой записи нет в базе');

$active = (int) !$row['active'];

DB()->query("UPDATE parser_from_urls SET active = $active WHERE from_url = '$from_url'");
}

$this->response['mode'] = $mode;
}

function chat()
{
require(AJAX_DIR .'chat.php');
}
}

<?php

define('IN_FORUM', true);
define('BB_SCRIPT', 'posting');
define('BB_ROOT', './');
require(BB_ROOT ."common.php");
require(INC_DIR .'bbcode.php');
require(INC_DIR .'functions_post.php');
require(ATTACH_DIR .'attachment_mod.php');

$page_cfg['load_tpl_vars'] = array('post_icons');

$submit = (bool) @$_REQUEST['post'];
$preview = (bool) @$_REQUEST['preview'];
$delete = (bool) @$_REQUEST['delete'];

$forum_id = (int) @$_REQUEST[POST_FORUM_URL];
$topic_id = (int) @$_REQUEST[POST_TOPIC_URL];
$post_id = (int) @$_REQUEST[POST_POST_URL];

$mode = (string) @$_REQUEST['mode'];

$confirm = isset($_POST['confirm']);

$refresh = $preview;
$orig_word = $replacement_word = array();

// Set topic type
$topic_type = (@$_POST['topictype']) ? (int) $_POST['topictype'] : POST_NORMAL;
$topic_type = in_array($topic_type, array(POST_NORMAL, POST_STICKY, POST_ANNOUNCE)) ? $topic_type : POST_NORMAL;

$selected_rg = 0;
$switch_rg_sig = 0;
$switch_poster_rg_sig = 0;

if ($mode == 'smilies')
{
generate_smilies('window');
exit;
}

$tracking_topics = get_tracks('topic');
$tracking_forums = get_tracks('forum');

// Start session management
$user->session_start();

set_die_append_msg($forum_id, $topic_id);

// What auth type do we need to check?
$is_auth = array();
switch ($mode)
{
case 'newtopic':
case 'new_rel':
if (bf($userdata['user_opt'], 'user_opt', 'dis_topic'))
{
bb_die($lang['RULES_POST_CANNOT']);
}
if ($topic_type == POST_ANNOUNCE)
{
$is_auth_type = 'auth_announce';
}
elseif ($topic_type == POST_STICKY)
{
$is_auth_type = 'auth_sticky';
}
else
{
$is_auth_type = 'auth_post';
}
break;

case 'reply':
case 'quote':
if (bf($userdata['user_opt'], 'user_opt', 'dis_post'))
{
bb_die($lang['RULES_REPLY_CANNOT']);
}
$is_auth_type = 'auth_reply';
break;

case 'editpost':
if (bf($userdata['user_opt'], 'user_opt', 'dis_post_edit'))
{
bb_die($lang['RULES_EDIT_CANNOT']);
}
$is_auth_type = 'auth_edit';
break;

case 'delete':
$is_auth_type = 'auth_delete';
break;

default:
bb_die($lang['NO_POST_MODE']);
break;
}

// Here we do various lookups to find topic_id, forum_id, post_id etc.
// Doing it here prevents spoofing (eg. faking forum_id, topic_id or post_id
$error_msg = '';
$post_data = array();
switch ($mode)
{
case 'newtopic':
case 'new_rel':
if (!$forum_id)
{
bb_die($lang['FORUM_NOT_EXIST']);
}
$sql = "SELECT * FROM ". BB_FORUMS ." WHERE forum_id = $forum_id LIMIT 1";
break;

case 'reply':
if (!$topic_id)
{
bb_die($lang['NO_TOPIC_ID']);
}
$sql = "SELECT f.*, t.*
FROM ". BB_FORUMS ." f, ". BB_TOPICS ." t
WHERE t.topic_id = $topic_id
AND f.forum_id = t.forum_id
LIMIT 1";
break;

case 'quote':
case 'editpost':
case 'delete':
if (!$post_id)
{
bb_die($lang['NO_POST_ID']);
}

$select_sql = 'SELECT f.*, t.*, p.*';
$select_sql .= (!$submit) ? ', pt.*, u.username, u.user_id' : '';

$from_sql = "FROM ". BB_POSTS ." p, ". BB_TOPICS ." t, ". BB_FORUMS ." f";
$from_sql .= (!$submit) ? ", " . BB_POSTS_TEXT . " pt, " . BB_USERS . " u" : '';

$where_sql = "
WHERE p.post_id = $post_id
AND t.topic_id = p.topic_id
AND f.forum_id = p.forum_id
";
$where_sql .= (!$submit) ? "
AND pt.post_id = p.post_id
AND u.user_id = p.poster_id
" : '';

$sql = "$select_sql $from_sql $where_sql LIMIT 1";
break;

default:
bb_die($lang['NO_VALID_MODE']);
}

if ($post_info = DB()->fetch_row($sql))
{
$forum_id = $post_info['forum_id'];
$forum_name = $post_info['forum_name'];

$is_auth = auth(AUTH_ALL, $forum_id, $userdata, $post_info);

if ($post_info['forum_status'] == FORUM_LOCKED && !$is_auth['auth_mod'])
{
bb_die($lang['FORUM_LOCKED']);
}
elseif ($mode != 'newtopic' && $mode != 'new_rel' && $post_info['topic_status'] == TOPIC_LOCKED && !$is_auth['auth_mod'])
{
bb_die($lang['TOPIC_LOCKED']);
}

if ($mode == 'editpost' || $mode == 'delete')
{
$topic_id = $post_info['topic_id'];

$post_data['poster_post'] = ($post_info['poster_id'] == $userdata['user_id']);
$post_data['first_post'] = ($post_info['topic_first_post_id'] == $post_id);
$post_data['last_post'] = ($post_info['topic_last_post_id'] == $post_id);
$post_data['last_topic'] = ($post_info['forum_last_post_id'] == $post_id);
$post_data['topic_type'] = $post_info['topic_type'];
$post_data['poster_id'] = $post_info['poster_id'];

$selected_rg = $post_info['poster_rg_id'];
$switch_rg_sig = ($post_info['attach_rg_sig']) ? true : false;

// Can this user edit/delete the post?
if ($post_info['poster_id'] != $userdata['user_id'] && !$is_auth['auth_mod'])
{
$auth_err = ($delete || $mode == 'delete') ? $lang['DELETE_OWN_POSTS'] : $lang['EDIT_OWN_POSTS'];
}
elseif (!$post_data['last_post'] && !$is_auth['auth_mod'] && ($mode == 'delete' || $delete))
{
$auth_err = $lang['CANNOT_DELETE_REPLIED'];
}

if (isset($auth_err)) bb_die($auth_err);
}
else
{
if ($mode == 'quote')
{
$topic_id = $post_info['topic_id'];
}
if ($mode == 'newtopic')
{
$post_data['topic_type'] = POST_NORMAL;
}
$post_data['first_post'] = ($mode == 'newtopic');
$post_data['last_post'] = false;
}
}
else
{
bb_die($lang['NO_SUCH_POST']);
}

// The user is not authed, if they're not logged in then redirect
// them, else show them an error message
if (!$is_auth[$is_auth_type])
{
if (!IS_GUEST)
{
bb_die(sprintf($lang['SORRY_'. strtoupper($is_auth_type)], $is_auth[$is_auth_type .'_type']));
}

switch ($mode)
{
case 'newtopic':
$redirect = "mode=newtopic&f=$forum_id";
break;
case 'new_rel':
$redirect = "mode=new_rel&f=$forum_id";
break;
case 'reply':
$redirect = "mode=reply&t=$topic_id";
break;
case 'quote':
case 'editpost':
$redirect = "mode=quote&p=$post_id";
break;
default:
$redirect = '';
}
redirect(LOGIN_URL . "?redirect=/". POSTING_URL ."?$redirect");
}

if ($mode == 'new_rel')
{
if ($tor_status = join(',', $bb_cfg['tor_cannot_new']))
{
$sql = DB()->fetch_rowset("SELECT t.topic_title, t.topic_id, tor.tor_status
FROM ". BB_BT_TORRENTS ." tor, ". BB_TOPICS ." t
WHERE poster_id = {$userdata['user_id']}
AND tor.topic_id = t.topic_id
AND tor.tor_status IN ($tor_status)
ORDER BY tor.reg_time
");

$topics = '';
foreach($sql as $row)
{
$topics .= $bb_cfg['tor_icons'][$row['tor_status']] .'<a href="'. TOPIC_URL . $row['topic_id'] .'">'. $row['topic_title'] .'</a><div class="spacer_12"></div>';
}
if ($topics) bb_die($topics . $lang['UNEXECUTED_RELEASE']);
}
require(INC_DIR .'posting_tpl.php');
exit;
}

// Notify
if ($submit || $refresh)
{
$notify_user = (int) !empty($_POST['notify']);
}
else
{
$notify_user = bf($userdata['user_opt'], 'user_opt', 'user_notify');

if (!IS_GUEST && $mode != 'newtopic' && !$notify_user)
{
$notify_user = (int) DB()->fetch_row("SELECT topic_id FROM ". BB_TOPICS_WATCH ." WHERE topic_id = $topic_id AND user_id = ". $userdata['user_id']);
}
}

$update_post_time = !empty($_POST['update_post_time']);

execute_posting_attachment_handling();

// если за время пока вы писали ответ, в топике появились новые сообщения, перед тем как ваше сообщение будет отправлено, выводится предупреждение с обзором этих сообщений
$topic_has_new_posts = false;

if (!IS_GUEST && $mode != 'newtopic' && ($submit || $preview || $mode == 'quote' || $mode == 'reply') && isset($_COOKIE[COOKIE_TOPIC]))
{
if ($topic_last_read = max(intval(@$tracking_topics[$topic_id]), intval(@$tracking_forums[$forum_id])))
{
$sql = "SELECT p.*, pt.post_text, u.username, u.user_rank
FROM ". BB_POSTS ." p, ". BB_POSTS_TEXT ." pt, ". BB_USERS ." u
WHERE p.topic_id = ". (int) $topic_id ."
AND u.user_id = p.poster_id
AND pt.post_id = p.post_id
AND p.post_time > $topic_last_read
ORDER BY p.post_time
LIMIT ". $bb_cfg['posts_per_page'];

if ($rowset = DB()->fetch_rowset($sql))
{
$topic_has_new_posts = true;

foreach ($rowset as $i => $row)
{
$template->assign_block_vars('new_posts', array(
'ROW_CLASS' => !($i % 2) ? 'row1' : 'row2',
'POSTER' => profile_url($row),
'POSTER_NAME_JS' => addslashes($row['username']),
'POST_DATE' => bb_date($row['post_time'], $bb_cfg['post_date_format']),
'MESSAGE' => get_parsed_post($row),
));
}
$template->assign_vars(array(
'TPL_SHOW_NEW_POSTS' => true,
));

set_tracks(COOKIE_TOPIC, $tracking_topics, $topic_id);
unset($rowset);
}
}
}

// --------------------
// What shall we do?
//
if ( ( $delete || $mode == 'delete' ) && !$confirm )
{
if (isset($_POST['cancel']))
{
redirect(POST_URL . "$post_id#$post_id");
}
//
// Confirm deletion
//
$hidden_fields = array(
'p' => $post_id,
'mode' => 'delete',
);

print_confirmation(array(
'QUESTION' => $lang['CONFIRM_DELETE'],
'FORM_ACTION' => POSTING_URL,
'HIDDEN_FIELDS' => build_hidden_fields($hidden_fields),
));
}
elseif ( ($submit || $confirm) && !$topic_has_new_posts )
{
//
// Submit post (newtopic, edit, reply, etc.)
//
$return_message = '';
$return_meta = '';

switch ($mode)
{
case 'editpost':
case 'newtopic':
case 'reply':
$username = ( !empty($_POST['username']) ) ? clean_username($_POST['username']) : '';
$subject = ( !empty($_POST['subject']) ) ? clean_title($_POST['subject']) : '';
$message = ( !empty($_POST['message']) ) ? prepare_message($_POST['message']) : '';
$attach_rg_sig = (isset($_POST['attach_rg_sig']) && isset($_POST['poster_rg']) && $_POST['poster_rg'] != -1) ? 1 : 0;
$poster_rg_id = (isset($_POST['poster_rg']) && $_POST['poster_rg'] != -1) ? (int) $_POST['poster_rg'] : 0;

prepare_post($mode, $post_data, $error_msg, $username, $subject, $message);

if (!$error_msg)
{
$topic_type = ( isset($post_data['topic_type']) && $topic_type != $post_data['topic_type'] && !$is_auth['auth_sticky'] && !$is_auth['auth_announce'] ) ? $post_data['topic_type'] : $topic_type;

submit_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id, $topic_type, DB()->escape($username), DB()->escape($subject), DB()->escape($message), $update_post_time, $poster_rg_id, $attach_rg_sig);

$post_url = POST_URL ."$post_id#$post_id";
$post_msg = ($mode == 'editpost') ? $lang['EDITED']: $lang['STORED'];
$onclick = ($mode == 'editpost') ? 'onclick="return post2url(this.href);"': '';
$return_message .= $post_msg .'<br /><br />
<a '. $onclick .' href="'. $post_url .'" >'. $lang['POST_RETURN'] .'</a>
';
}
break;

case 'delete':
require_once(INC_DIR .'functions_admin.php');
delete_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id);
break;
}

if (!$error_msg)
{
if (!in_array($mode, array('editpost', 'delete')))
{
$user_id = ( $mode == 'reply' || $mode == 'newtopic' ) ? $userdata['user_id'] : $post_data['poster_id'];
update_post_stats($mode, $post_data, $forum_id, $topic_id, $post_id, $user_id);
}
$attachment_mod['posting']->insert_attachment($post_id);

if (!$error_msg)
{
user_notification($mode, $post_data, $post_info['topic_title'], $forum_id, $topic_id, $notify_user);
}

if ($mode == 'newtopic' || $mode == 'reply')
{
set_tracks(COOKIE_TOPIC, $tracking_topics, $topic_id);
}

// Постеры раздач
if ($bb_cfg['last_added'])
{
if ($mode == 'newtopic' && defined('TORRENT_ATTACH_ID') || defined('TORRENT_ATTACH_ID') && $bb_cfg['bt_newtopic_auto_reg'] && !$error_msg)
{
$row = DB()->fetch_row("SELECT post_text FROM ". BB_POSTS_TEXT ." WHERE post_id = $post_id");
preg_match_all('/\[gposter=right\](.*?)\[\/gposter\]/i', $row['post_text'], $poster7, PREG_SET_ORDER);
preg_match_all('/\[gposter=left\](.*?)\[\/gposter\]/i', $row['post_text'], $poster6, PREG_SET_ORDER);
preg_match_all('/\[gposter\](.*?)\[\/gposter\]/i', $row['post_text'], $poster5, PREG_SET_ORDER);
preg_match_all('/\[poster\](.*?)\[\/poster\]/i', $row['post_text'], $poster4, PREG_SET_ORDER);
preg_match_all('/\[img=right\](.*?)\[\/img\]/i', $row['post_text'], $poster3, PREG_SET_ORDER);
preg_match_all('/\[img=left\](.*?)\[\/img\]/i', $row['post_text'], $poster2, PREG_SET_ORDER);
preg_match_all('/\[img\](.*?)\[\/img\]/i', $row['post_text'], $poster1, PREG_SET_ORDER);
$url = '';
if (isset($poster7[0][1])) $url = $poster7[0][1];
elseif (isset($poster6[0][1])) $url = $poster6[0][1];
elseif (isset($poster5[0][1])) $url = $poster5[0][1];
elseif (isset($poster4[0][1])) $url = $poster4[0][1];
elseif (isset($poster3[0][1])) $url = $poster3[0][1];
elseif (isset($poster2[0][1])) $url = $poster2[0][1];
elseif (isset($poster1[0][1])) $url = $poster1[0][1];
DB()->query("UPDATE ". BB_TOPICS ." SET topic_image = '$url' WHERE topic_id = $topic_id ");
CACHE('lenta')->rm();
}
}

if (defined('TORRENT_ATTACH_ID') && $bb_cfg['bt_newtopic_auto_reg'] && !$error_msg)
{
include(INC_DIR .'functions_torrent.php');
if (!DB()->fetch_row("SELECT attach_id FROM ". BB_BT_TORRENTS ." WHERE attach_id = ". TORRENT_ATTACH_ID))
{
if ($bb_cfg['premod'])
{
// Получение списка id форумов начиная с parent
$forum_parent = $forum_id;
if ($post_info['forum_parent']) $forum_parent = $post_info['forum_parent'];
$count_rowset = DB()->fetch_rowset("SELECT forum_id FROM ". BB_FORUMS ." WHERE forum_parent = $forum_parent");
$sub_forums = array();
foreach ($count_rowset as $count_row)
{
if ($count_row['forum_id'] != $forum_id) $sub_forums[] = $count_row['forum_id'];
}
$sub_forums[] = $forum_id;
$sub_forums = join(',', $sub_forums);
// Подсчет проверенных релизов в форумах раздела
$count_checked_releases = DB()->fetch_row("
SELECT COUNT(*) AS checked_releases
FROM ". BB_BT_TORRENTS ."
WHERE poster_id = ". $userdata['user_id'] ."
AND forum_id IN($sub_forums)
AND tor_status IN(". TOR_APPROVED .",". TOR_DOUBTFUL .",". TOR_TMP .")
LIMIT 1
", 'checked_releases');
if ($count_checked_releases || IS_AM)
{
tracker_register(TORRENT_ATTACH_ID, 'newtopic', TOR_NOT_APPROVED);
}
else
{
tracker_register(TORRENT_ATTACH_ID, 'newtopic', TOR_PREMOD);
}
}
else tracker_register(TORRENT_ATTACH_ID, 'newtopic', TOR_NOT_APPROVED);
}
}

// Update atom feed
update_atom('topic', $topic_id);

if ($mode == 'reply' && $post_info['topic_status'] == TOPIC_LOCKED)
{
$locked_warn = '
<div class="warnColor1">
<b>'. $lang['LOCKED_WARN'] .'</b>
</div>
<br /><hr /><br />
';
$return_message = $locked_warn . $return_message;
}

bb_die($return_message);
}
}

if ($refresh || $error_msg || ($submit && $topic_has_new_posts))
{
$username = ( !empty($_POST['username']) ) ? clean_username($_POST['username']) : '';
$subject = ( !empty($_POST['subject']) ) ? clean_title($_POST['subject']) : '';
$message = ( !empty($_POST['message']) ) ? prepare_message($_POST['message']) : '';

if ($preview)
{
$preview_subject = $subject;
$preview_username = $username;
$preview_message = htmlCHR($message, false, ENT_NOQUOTES);
$preview_message = bbcode2html($preview_message);

$template->assign_vars(array(
'TPL_PREVIEW_POST' => true,
'TOPIC_TITLE' => wbr($preview_subject),
'POST_SUBJECT' => $preview_subject,
'POSTER_NAME' => $preview_username,
'POST_DATE' => bb_date(TIMENOW),
'PREVIEW_MSG' => $preview_message,
));
}
}
else
{
// User default entry point
if ( $mode == 'newtopic' )
{
$username = ($userdata['session_logged_in']) ? $userdata['username'] : '';
$subject = $message = '';
}
elseif ( $mode == 'reply' )
{
$username = ( $userdata['session_logged_in'] ) ? $userdata['username'] : '';
$subject = $message = '';
}
elseif ( $mode == 'quote' || $mode == 'editpost' )
{
$subject = ( $post_data['first_post'] ) ? $post_info['topic_title'] : '';
$message = $post_info['post_text'];

if ( $mode == 'quote' )
{
if (!defined('WORD_LIST_OBTAINED'))
{
$orig_word = array();
$replace_word = array();
obtain_word_list($orig_word, $replace_word);
define('WORD_LIST_OBTAINED', TRUE);
}

if ($post_info['post_attachment'] && !IS_AM) $message = $post_info['topic_title'];
$quote_username = ($post_info['post_username'] != '') ? $post_info['post_username'] : $post_info['username'];
$message = '
'. $quote_username .' написал(а):
[qpost='. $post_info['post_id'] .']' . $message . '
';

// hide user passkey
$message = preg_replace('#(?<=\?uk=)[a-zA-Z0-9]{10}(?=&)#', 'passkey', $message);
// hide sid
$message = preg_replace('#(?<=[\?&;]sid=)[a-zA-Z0-9]{12}#', 'sid', $message);

if (!empty($orig_word))
{
$subject = (!empty($subject)) ? preg_replace($orig_word, $replace_word, $subject) : '';
$message = (!empty($message)) ? preg_replace($orig_word, $replace_word, $message) : '';
}

if ( !preg_match('/^Re:/', $subject) && strlen($subject) > 0 )
{
$subject = 'Re: ' . $subject;
}

$mode = 'reply';
}
else
{
$username = ( $post_info['user_id'] == GUEST_UID && !empty($post_info['post_username']) ) ? $post_info['post_username'] : '';
}
}
}

if ($error_msg)
{
$template->assign_vars(array(
'ERROR_MESSAGE' => $error_msg,
));
}

if (IS_GUEST || ($mode == 'editpost' && $post_info['poster_id'] == GUEST_UID))
{
$template->assign_var('POSTING_USERNAME');
}

// Notify checkbox
if (!IS_GUEST)
{
if ($mode != 'editpost' || ($mode == 'editpost' && $post_info['poster_id'] != GUEST_UID))
{
$template->assign_var('SHOW_NOTIFY_CHECKBOX');
}
}

// Topic type selection
$topic_type_toggle = '';
if ( $mode == 'newtopic' || ( $mode == 'editpost' && $post_data['first_post'] ) )
{
$template->assign_block_vars('switch_type_toggle', array());

if( $is_auth['auth_sticky'] )
{
$topic_type_toggle .= '<label><input type="radio" name="topictype" value="' . POST_STICKY . '"';
if ( isset($post_data['topic_type']) && ($post_data['topic_type'] == POST_STICKY || $topic_type == POST_STICKY) )
{
$topic_type_toggle .= ' checked="checked"';
}
$topic_type_toggle .= ' /> ' . $lang['POST_STICKY'] . '</label>&nbsp;&nbsp;';
}

if( $is_auth['auth_announce'] )
{
$topic_type_toggle .= '<label><input type="radio" name="topictype" value="' . POST_ANNOUNCE . '"';
if ( isset($post_data['topic_type']) && ($post_data['topic_type'] == POST_ANNOUNCE || $topic_type == POST_ANNOUNCE) )
{
$topic_type_toggle .= ' checked="checked"';
}
$topic_type_toggle .= ' /> ' . $lang['POST_ANNOUNCEMENT'] . '</label>&nbsp;&nbsp;';
}

if ( $topic_type_toggle != '' )
{
$topic_type_toggle = $lang['POST_TOPIC_AS'] . ': <label><input type="radio" name="topictype" value="' . POST_NORMAL .'"' . ( (!isset($post_data['topic_type']) || $post_data['topic_type'] == POST_NORMAL || $topic_type == POST_NORMAL) ? ' checked="checked"' : '' ) . ' /> ' . $lang['POST_NORMAL'] . '</label>&nbsp;&nbsp;' . $topic_type_toggle;
}
}
//bt
$topic_dl_type = (isset($post_info['topic_dl_type'])) ? $post_info['topic_dl_type'] : 0;

if ($post_info['allow_reg_tracker'] && $post_data['first_post'] && ($topic_dl_type || $is_auth['auth_mod']))
{
$sql = "
SELECT tor.attach_id
FROM ". BB_POSTS ." p
LEFT JOIN ". BB_BT_TORRENTS ." tor ON (p.post_id = tor.post_id)
WHERE p.post_id = $post_id
";
$result = DB()->fetch_row($sql);
if (!empty($result['attach_id']))
{
if (!$topic_type_toggle)
{
$topic_type_toggle = $lang['POST_TOPIC_AS'] . ': ';
}

$dl_ds = $dl_ch = $dl_hid = '';
$dl_type_name = 'topic_dl_type';
$dl_type_val = ($topic_dl_type) ? 1 : 0;

if (!$post_info['allow_reg_tracker'] && !$is_auth['auth_mod'])
{
$dl_ds = ' disabled="disabled" ';
$dl_hid = '<input type="hidden" name="topic_dl_type" value="'. $dl_type_val .'" />';
$dl_type_name = '';
}

$dl_ch = ($mode == 'editpost' && $post_data['first_post'] && $topic_dl_type) ? ' checked="checked" ' : '';

$topic_type_toggle .= '<nobr><input type="checkbox" name="'. $dl_type_name .'" id="topic_dl_type_id" '. $dl_ds . $dl_ch .' /><label for="topic_dl_type_id"> '.$lang['POST_DOWNLOAD'].'</label></nobr>';
$topic_type_toggle .= $dl_hid;
}
}
//bt end

// Get poster release group data
if ($userdata['user_level'] == GROUP_MEMBER || IS_AM)
{
$poster_rgroups = '';

$sql = "SELECT ug.group_id, g.group_name, g.release_group
FROM ". BB_USER_GROUP ." ug
INNER JOIN ". BB_GROUPS ." g ON(g.group_id = ug.group_id)
WHERE ug.user_id = {$userdata['user_id']}
AND g.release_group = 1
ORDER BY g.group_name";

foreach (DB()->fetch_rowset($sql) as $row)
{
$selected_opt = ($row['group_id'] == $selected_rg) ? 'selected' : '';
$poster_rgroups .= '<option value="'. $row['group_id'] .'" '. $selected_opt .'>'. $row['group_name'] .'</option>';
}
}

$hidden_form_fields = '<input type="hidden" name="mode" value="' . $mode . '" />';

switch( $mode )
{
case 'newtopic':
$page_title = $lang['POST_A_NEW_TOPIC'];
$hidden_form_fields .= '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />';
break;

case 'reply':
$page_title = $lang['POST_A_REPLY'];
$hidden_form_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" />';
break;

case 'editpost':
$page_title = $lang['EDIT_POST'];
$hidden_form_fields .= '<input type="hidden" name="' . POST_POST_URL . '" value="' . $post_id . '" />';
break;
}

// Generate smilies listing for page output
generate_smilies('inline');

$template->set_filenames(array(
'body' => 'posting.tpl',
));

// Output the data to the template
$template->assign_vars(array(
'FORUM_NAME' => htmlCHR($forum_name),
'PAGE_TITLE' => $page_title,
'POSTING_TYPE_TITLE' => $page_title,
'POSTING_TOPIC_ID' => ($mode != 'newtopic') ? $topic_id : '',
'POSTING_TOPIC_TITLE' => ($mode != 'newtopic') ? wbr($post_info['topic_title']) : '',
'U_VIEW_FORUM' => "viewforum.php?" . POST_FORUM_URL . "=$forum_id",

'USERNAME' => @$username,
'CAPTCHA_HTML' => (IS_GUEST) ? CAPTCHA()->get_html() : '',
'SUBJECT' => $subject,
'MESSAGE' => $message,

'POSTER_RGROUPS' => isset($poster_rgroups) && !empty($poster_rgroups) ? $poster_rgroups : '',
'ATTACH_RG_SIG' => ($switch_rg_sig) ? $switch_rg_sig : false,

'U_VIEWTOPIC' => ($mode == 'reply') ? "viewtopic.php?" . POST_TOPIC_URL . "=$topic_id&amp;postorder=desc" : '',

'S_NOTIFY_CHECKED' => ($notify_user) ? 'checked="checked"' : '',
'S_TYPE_TOGGLE' => $topic_type_toggle,
'S_TOPIC_ID' => $topic_id,
'S_POST_ACTION' => POSTING_URL,
'S_HIDDEN_FORM_FIELDS' => $hidden_form_fields,
));

if ($mode == 'newtopic' || $post_data['first_post'])
{
$template->assign_var('POSTING_SUBJECT');
}
if (!$bb_cfg['parsmod_disable'] && ($mode == 'newtopic' || $post_data['first_post']))
{
$template->assign_var('PARSMOD_ON');
}

// Update post time
if ($mode == 'editpost' && $post_data['last_post'] && !$post_data['first_post'])
{
$template->assign_vars(array(
'SHOW_UPDATE_POST_TIME' => ($is_auth['auth_mod'] || ($post_data['poster_post'] && $post_info['post_time'] + 3600*3 > TIMENOW)),
'UPDATE_POST_TIME_CHECKED' => ($post_data['poster_post'] && ($post_info['post_time'] + 3600*2 > TIMENOW)),
));
}

// Topic review
if( $mode == 'reply' && $is_auth['auth_read'] )
{
topic_review($topic_id);
}

require(PAGE_HEADER);

$template->pparse('body');

require(PAGE_FOOTER);

<div class="menu-sub" id="pars-opt">
<table cellspacing="1" cellpadding="4">
<tr><th>{L_PARS_OPT_TITLE}</th></tr>
<tr><td>
<fieldset id="p_tor">
<legend>{L_PARS_OPT_TOR}</legend>
<div class="pad_4">
<label><input id="dwnld_tor" name="pars_tor" type="checkbox" <!-- IF DOWNLOAD_TORRENT_ON -->{CHECKED}<!-- ENDIF -->
onclick="return checkmeman(this, {DOWNLOAD_TORRENT});" />{L_PARS_OPT_DWNLD}
</label><label>
<input id="not_dwnld_tor" name="pars_tor" type="checkbox" <!-- IF NOT_DOWNLOAD_TORRENT_ON -->{CHECKED}<!-- ENDIF -->
onclick="return checkmeman(this, {NOT_DOWNLOAD_TORRENT});" />{L_PARS_OPT_NO_DWNLD}
</label></div>
</fieldset>
<fieldset id="p_view">
<legend>{L_PARS_OPT_VIEW}</legend>
<div class="pad_4">
<label>
<input id="p_no_view" name="pars_view" type="checkbox" <!-- IF PARS_NO_VIEW_ON -->{CHECKED}<!-- ENDIF -->
onclick="return checkmeman(this, {PARS_NO_VIEW});" />{L_PARS_OPT_NO_VIEW}
</label><label>
<input id="p_view_mess" name="pars_view" type="checkbox" <!-- IF PARS_VIEW_MESSAGE_ON -->{CHECKED}<!-- ENDIF -->
onclick="return checkmeman(this, {PARS_VIEW_MESSAGE});" />{L_PARS_OPT_QVIEW}
</label><label>
<input id="p_preview_mess" name="pars_view" type="checkbox" <!-- IF PARS_PREVIEW_MESSAGE_ON -->{CHECKED}<!-- ENDIF -->
onclick="return checkmeman(this, {PARS_PREVIEW_MESSAGE});" />{L_PARS_OPT_PREVIEW}
</label><label>
<input id="p_post_topic" name="pars_view" type="checkbox" <!-- IF PARS_POST_TOPIC_ON -->{CHECKED}<!-- ENDIF -->
onclick="return checkmeman(this, {PARS_POST_TOPIC});" />{L_PARS_OPT_POST}
</label></div>
</fieldset>
</td></tr>
</table>
</div>

<div class="spacer_12"></div>

<!-- IF TPL_SHOW_NEW_POSTS -->
<!--========================================================================-->

<table class="topic" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" class="catTitle td2">{L_NEW_POSTS_PREVIEW}</td>
</tr>
<tr>
<th class="thHead td1">{L_AUTHOR}</th>
<th class="thHead td2">{L_MESSAGE}</th>
</tr>
<!-- BEGIN new_posts -->
<tr class="{new_posts.ROW_CLASS}">
<td width="120" class="poster_info td1">
<p class="nick" onclick="bbcode.onclickPoster('{new_posts.POSTER_NAME_JS}');">
<a href="#" onclick="return false;">{new_posts.POSTER}</a>
</p>
<p><img src="{SPACER}" width="120" height="10" alt="" /></p>
</td>
<td class="message td2">
<div class="post_head pad_4">{MINIPOST_IMG_NEW} {new_posts.POST_DATE}</div>
<div class="post_wrap post_body">{new_posts.MESSAGE}</div>
</td>
</tr>
<!-- END new_posts -->

</table>

<div class="spacer_12"></div>

<!--========================================================================-->
<!-- ENDIF / TPL_SHOW_NEW_POSTS -->

<!-- IF TPL_PREVIEW_POST -->
<!--========================================================================-->

<table class="forumline">
<tr>
<th>{L_PREVIEW}</th>
</tr>
<tr>
<td class="row1"><div class="post_wrap post_body">{PREVIEW_MSG}</div></td>
</tr>
</table>

<div class="spacer_12"></div>

<!--========================================================================-->
<!-- ENDIF / TPL_PREVIEW_POST -->

<p class="nav">
<a href="{U_INDEX}">{T_INDEX}</a>
<!-- IF U_VIEW_FORUM --><em>&raquo;</em> <a href="{U_VIEW_FORUM}">{FORUM_NAME}</a><!-- ENDIF -->
<!-- IF POSTING_TOPIC_ID --><em>&raquo;</em> <a class="normal" href="{TOPIC_URL}{POSTING_TOPIC_ID}">{POSTING_TOPIC_TITLE}</a><!-- ENDIF -->
</p>

<form action="{S_POST_ACTION}" method="post" name="post" onsubmit="if(checkForm(this)){ dis_submit_btn(); }else{ return false; }" {S_FORM_ENCTYPE}>
{S_HIDDEN_FORM_FIELDS}
{ADD_ATTACH_HIDDEN_FIELDS}
{POSTED_ATTACHMENTS_HIDDEN_FIELDS}

<table class="bordered">
<col class="row1">
<col class="row2">

<tbody class="pad_4">

<!-- IF PARSMOD_ON -->
<tbody class="pad_4">
<tr>
<th colspan="2" class="thHead"><b>{L_PARS_NEW_RELEASE}</b><div class="floatR med bold"><a class="menu-root" style="color:white;" href="#pars-opt">{L_PARS_OPT}</a></div></th>
</tr>
<tr>
<td style="vertical-align:top;">
<div title="{L_PARS_ALLOWED_SOURCES}" style="float: right;vertical-align:top;">
<img src="./templates/default/images/p/rutracker.ico" alt="Rutracker" title="{L_PARS_RUTRACKER_SOURCES}">
<img src="./templates/default/images/p/nnm-club.ico" alt="nnm-club" title="{L_PARS_NNM_SOURCES}">
<img src="./templates/default/images/p/rutor.ico" alt="Rutor" title="{L_PARS_RUTOR_SOURCES}"><br>
</div>
<b>{L_PARS_SOURCE}</b> <br>
</td>
<td>
<input id="release_url" type="url" size=60 placeholder="{l_PARS_PASTE_SOURCE_URL}"> <input type="button" value="{L_SUBMIT}" name="Send" id="pars">


<div id="hida"></div>
</td>


</tr>
<script type="text/javascript">

function checkmeman(e, val){
var ptag = $(e).attr('name');
user.set(ptag, ( $(e).is(":checked") ? val : 0 ), 365, false);
$("input[name="+ptag+"]:checked").attr('checked', false);
$(e).attr('checked', true);
}

$('#pars').click(function(){
var fileid = [0,0];
var gettorrent = (($( "input[name='pars_tor']:checked" ).attr('id')) == 'dwnld_tor') ? 1:0;
var filename = $(".gen:contains('torrent')" ).text();
var mode = $("input[name|=mode]" ).val();

if (filename && gettorrent && mode == 'editpost') gettorrent = confirm("ѕерезаписать торрент?")? 1:0;
if (filename && gettorrent) {
var attach_url = $("a:contains("+filename+")").attr('href');
if (fileid = attach_url.match(/dl\.php\?id=(\d+)/)) {
††††††††var tmp_str = $("input[name|='update_attachment["+fileid[1]+"]']" ).next("input" ).attr("name");
††††††††var phys_name = tmp_str.match(/del_attachment\[(.*)\]/);
††††††††$( "input[value|='"+fileid[1]+"']" ).remove();
}else{
††††††††††††††††var phys_name = attach_url.match(/.*\/(.*)/);
var fileid = [0,0];
}

††††††††$( "input[value|='"+filename+"']" ).remove();
††††††††$( "input[value|='"+phys_name[1]+"']" ).remove();
††††††††$("a:contains("+filename+")").attr({href:" "});
$("a:contains("+filename+")").text(' ');
}

ajax.exec({action: 'pars', pars_url: $('#release_url').val(), gettorrent:gettorrent, tor_id:fileid[1]});
ajax.callback.pars = function(data) {
$( "#hida" ).html(data.hid);
$( "input[name='subject']" ).val(data.title);
$('textarea#message').val(data.bbcode)
var p_view = $("input[name='pars_view']:checked").attr('id');
switch (p_view) {
case 'p_view_mess': ajax.exec({ action: 'posts', type: 'view_message', message: $('textarea#message').val()});break
case 'p_preview_mess': $('#post-preview-btn').click();break
case 'p_post_topic': $('#post-submit-btn').click();break
}
};
});

</script>
<!-- ENDIF -->

<tr>
<th colspan="2" class="thHead"><b>{POSTING_TYPE_TITLE}</b></th>
</tr>
<tr id="view_message" class="hidden">
<td colspan="2">
<div class="view-message"></div>
</td>
</tr>
<!-- IF POSTING_USERNAME -->
<tr>
<td><b>{L_USERNAME}</b></td>
<td>
<input type="text" name="username" size="25" maxlength="25" tabindex="1" value="{USERNAME}" />&nbsp;
<input type="submit" name="usersubmit" class="lite" value="{L_FIND_USERNAME}" onclick="window.open('{U_SEARCH_USER}', '_bbsearch', IWP_US);return false;" />
</td>
</tr>
<!-- ENDIF -->
<!-- IF POSTING_SUBJECT -->
<tr>
<td><b>{L_SUBJECT}</b></td>
<td><input type="text" name="subject" size="90" tabindex="2" value="{SUBJECT}" maxlength="250" style="width: 98%;" /></td>
</tr>
<!-- ENDIF -->
</tbody>

<tr>
<td class="vTop pad_4">
<p><b>{L_MESSAGE}</b></p>
<table id="smilies" class="smilies borderless mrg_16">
<!-- BEGIN smilies_row -->
<tr>
<!-- BEGIN smilies_col -->
<td><a href="#" onclick="bbcode && bbcode.emoticon('{smilies_row.smilies_col.SMILEY_CODE}'); return false;"><img src="{smilies_row.smilies_col.SMILEY_IMG}" alt="" title="{smilies_row.smilies_col.SMILEY_DESC}" /></a></td>
<!-- END smilies_col -->
</tr>
<!-- END smilies_row -->
<!-- BEGIN switch_smilies_extra -->
<tr>
<td colspan="{S_SMILIES_COLSPAN}"><a href="{U_MORE_SMILIES}" onclick="window.open('{U_MORE_SMILIES}', '_bbsmilies', IWP_SM); return false;" target="_bbsmilies" class="med">{L_MORE_EMOTICONS}</a></td>
</tr>
<!-- END switch_smilies_extra -->
</table><!--/smilies-->
</td>
<td class="vTop pad_0 w100"><!-- INCLUDE posting_editor.tpl --></td>
</tr>
<!-- IF IN_PM -->
<!-- ELSEIF LOGGED_IN -->
<tr>
<td class="vTop pad_4" valign="top">
<p><b>{L_OPTIONS}</b></p>
</td>
<td>
<div class="floatL">
<table class="borderless inline">
<!-- IF SHOW_UPDATE_POST_TIME -->
<tr>
<td><input type="checkbox" id="update_post_time" name="update_post_time" <!-- IF UPDATE_POST_TIME_CHECKED -->checked="checked"<!-- ENDIF --> /></td>
<td><label for="update_post_time">{L_UPDATE_POST_TIME}</label></td>
</tr>
<!-- ENDIF -->
<!-- IF SHOW_NOTIFY_CHECKBOX -->
<tr>
<td><input type="checkbox" id="notify" name="notify" {S_NOTIFY_CHECKED} /></td>
<td><label for="notify">{L_NOTIFY}</label></td>
</tr>
<!-- ENDIF -->
</table>
</div>
</td>
</tr>
<!-- IF ATTACHBOX && POSTER_RGROUPS -->
<tr>
<td class="vTop pad_4" valign="top"><b>{L_POST_RELEASE_FROM_GROUP}</b></td>
<td>
<select name="poster_rg">
<option value="-1">{L_CHOOSE_RELEASE_GROUP}</option>
{POSTER_RGROUPS}
</select>
<label><input type="checkbox" name="attach_rg_sig" <!-- IF ATTACH_RG_SIG -->checked<!-- ENDIF -->/> {L_ATTACH_RG_SIG}</label>
</td>
</tr>
<!-- ENDIF -->
<!-- ENDIF / LOGGED_IN -->
<!-- BEGIN switch_type_toggle -->
<tr>
<td colspan="2" class="row2 tCenter pad_6">{S_TYPE_TOGGLE}</td>
</tr>
<!-- END switch_type_toggle -->
<!-- IF ATTACHBOX --><!-- INCLUDE posting_attach.tpl --><!-- ENDIF -->
</table>

</form>

<!-- IF TPL_TOPIC_REVIEW -->
<!--========================================================================-->

<div class="spacer_12"></div>

<table class="topic" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" class="catTitle td2">{L_TOPIC_REVIEW}</td>
</tr>
<tr>
<th class="thHead td1">{L_AUTHOR}</th>
<th class="thHead td2">{L_MESSAGE}</th>
</tr>
<!-- BEGIN review -->
<tr class="{review.ROW_CLASS}">
<td width="120" class="poster_info td1">
<p class="nick" onclick="bbcode.onclickPoster('{review.POSTER_NAME_JS}');">
<a href="#" onclick="return false;">{review.POSTER}</a>
</p>
<p><img src="{SPACER}" width="120" height="10" alt="" /></p>
</td>
<td class="message td2">
<div class="post_head pad_4">{MINIPOST_IMG} {review.POST_DATE}</div>
<div class="post_wrap post_body">{review.MESSAGE}</div>
</td>
</tr>
<!-- END review -->

</table>

<div class="spacer_12"></div>

<!--========================================================================-->
<!-- ENDIF / TPL_TOPIC_REVIEW -->

Заранее спасибо за помощь.
Данные сервера:
Apache 2.2.15 (CentOS )
PHP/5.3.29
TP: 2.1.1
 

Vorezo

Пользователь
Сделал все, ругается только на nnm club,
А именно выдает след. нотисы:
Notice: Undefined offset: 1 in /var/www/....................../includes/functions_parser.php on line 37 Notice: Undefined offset: 1 in /var/www/............./includes/functions_parser.php on line 55 Notice: Undefined offset: 1 in /var/www/............................/includes/functions_parser.php on line 37 Notice: Undefined offset: 1 in /var/www/.........................../includes/functions_parser.php on line 43 Notice: Undefined offset: 1 in /var/www/........................../includes/functions_parser.php on line 46 Notice: Undefined offset: 1 in /var/www/........................./includes/functions_parser.php on line 55

Может быть кто нибудь сталкивался с этим? Буду благодарен за помощь.
 

the_chosen_one

Пользователь
Доброго времени суток.
Парсер работает очень хорошо, но иногда появляется ошибка при парсинге с рутора, а именно
500 Internal Server Error (если включена функция предварительного просмотра), когда снимаю галочки со всех просмотров и оставляю только "скачивать торрент из источника" то сверху появляется надпись:
Warning: curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in /var/www/мой логин/data/www/мой сайт/library/includes/functions_parser.php on line 220

А вот и сама 220 строчка:
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

Сама по себе ошибка возникает при парсинге раздач фильмов в формате HD (хотя не вижу в этом никакой связи) - например раздачу с фильмом размером 2-3 ГБ парсит всегда безошибочно, а вот раздачи, где в итоге будет скачан фильм размером 5-7 ГБ - иногда с ошибкой иногда нормально.

Зараннее спасибо.
 

Ress Kent

Пользователь
Пытаюсь добавить возможность при парсинге автоматическую замену ссылок на рейтинг imdb и кинопоиска под этот мод

В файле functions_parser.php нашел нужную строку преобразующую ссылки из html в bb

PHP:
$text = preg_replace("#<a href=\"(.*?)\".*?>(.*?)</a>#si", "\\2", $copy_release);

Добавил ниже строки для замены на рейтинги

PHP:
$text = preg_replace("#<a href=\"http://www.imdb.com/title/(.*?)\".*?>.*?</a>#si", "[imdb]http://www.imdb.com/title/\\1[/imdb]", $copy_release);
$text = preg_replace("#<a href=\"http://www.kinopoisk.ru/film/(.*?)\".*?>.*?</a>#si", "[kp]http://www.kinopoisk.ru/film/\\1[/kp]", $copy_release);

Преобразуют из

HTML:
<a href="http://www.imdb.com/title/tt2967224/" target="_blank"><img src="http://s.rutor.org/imdb/pic/2967224.gif"></a>

<a href="http://www.kinopoisk.ru/film/770625/" target="_blank"><img src="http://www.kinopoisk.ru/rating/770625.gif"></a>

На

Код:
[imdb]http://www.imdb.com/title/tt2967224/[/imdb]
[kp]http://www.kinopoisk.ru/film/770625/[/kp]

Этот способ работает, но только одна из этих трех строк (например если сработают мои строчки то все остальные обычные ссылки не работают).

Они заменяют друг друга в зависимости какую расположить в конце, подскажите что можно придумать что-бы они работали вместе
 
Сверху