mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-22 22:33:55 -07:00
Reformat by php-cs-fixer.
This commit is contained in:
parent
8776f12e86
commit
21f9ef22fc
135 changed files with 2141 additions and 1301 deletions
|
@ -32,7 +32,9 @@ if (!$result = DB()->sql_query($sql)) {
|
|||
$new[$config_name] = isset($_POST[$config_name]) ? $_POST[$config_name] : $default_config[$config_name];
|
||||
|
||||
if (isset($_POST['submit']) && $row['config_value'] != $new[$config_name]) {
|
||||
if ($config_name == 'seed_bonus_points' || $config_name == 'seed_bonus_release' || $config_name == 'bonus_upload' || $config_name == 'bonus_upload_price') $new[$config_name] = serialize(str_replace(',', '.', $new[$config_name]));
|
||||
if ($config_name == 'seed_bonus_points' || $config_name == 'seed_bonus_release' || $config_name == 'bonus_upload' || $config_name == 'bonus_upload_price') {
|
||||
$new[$config_name] = serialize(str_replace(',', '.', $new[$config_name]));
|
||||
}
|
||||
bb_update_config(array($config_name => $new[$config_name]));
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +80,9 @@ switch ($mode) {
|
|||
$seed_release = unserialize($new['seed_bonus_release']);
|
||||
|
||||
foreach ($seed_bonus as $i => $row) {
|
||||
if (!$row || !$seed_release[$i]) continue;
|
||||
if (!$row || !$seed_release[$i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$template->assign_block_vars('seed_bonus', array(
|
||||
'RELEASE' => $seed_release[$i],
|
||||
|
@ -92,7 +96,9 @@ switch ($mode) {
|
|||
$price_row = unserialize($new['bonus_upload_price']);
|
||||
|
||||
foreach ($upload_row as $i => $row) {
|
||||
if (!$row || !$price_row[$i]) continue;
|
||||
if (!$row || !$price_row[$i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$template->assign_block_vars('bonus_upload', array(
|
||||
'UP' => $row,
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
<?php
|
||||
|
||||
if (!empty($setmodules)) {
|
||||
if (IS_SUPER_ADMIN) $module['TP']['TRACKER_CONFIG'] = basename(__FILE__);
|
||||
if (IS_SUPER_ADMIN) {
|
||||
$module['TP']['TRACKER_CONFIG'] = basename(__FILE__);
|
||||
}
|
||||
return;
|
||||
}
|
||||
require('./pagestart.php');
|
||||
|
@ -9,7 +11,9 @@ require('./pagestart.php');
|
|||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
||||
if (!IS_SUPER_ADMIN) bb_die($lang['NOT_ADMIN']);
|
||||
if (!IS_SUPER_ADMIN) {
|
||||
bb_die($lang['NOT_ADMIN']);
|
||||
}
|
||||
|
||||
require(INC_DIR . 'functions_admin_torrent.php');
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
<?php
|
||||
|
||||
if (!empty($setmodules)) {
|
||||
if (IS_SUPER_ADMIN) $module['TP']['CRON'] = basename(__FILE__) . '?mode=list';
|
||||
if (IS_SUPER_ADMIN) {
|
||||
$module['TP']['CRON'] = basename(__FILE__) . '?mode=list';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -16,9 +18,13 @@ if ($mode == 'run' && !$job_id) {
|
|||
require(BB_ROOT . 'common.php');
|
||||
$user->session_start();
|
||||
redirect('admin/' . basename(__FILE__) . '?mode=list');
|
||||
} else require('./pagestart.php');
|
||||
} else {
|
||||
require('./pagestart.php');
|
||||
}
|
||||
|
||||
if (!IS_SUPER_ADMIN) bb_die($lang['NOT_ADMIN']);
|
||||
if (!IS_SUPER_ADMIN) {
|
||||
bb_die($lang['NOT_ADMIN']);
|
||||
}
|
||||
|
||||
require(INC_DIR . 'functions_admin_torrent.php');
|
||||
require(INC_DIR . 'functions_admin_cron.php');
|
||||
|
@ -187,7 +193,9 @@ if ($submit) {
|
|||
update_cron_job($_POST);
|
||||
} elseif ($_POST['mode'] == 'add') {
|
||||
insert_cron_job($_POST);
|
||||
} else bb_die('Mode error');
|
||||
} else {
|
||||
bb_die('Mode error');
|
||||
}
|
||||
|
||||
redirect('admin/' . basename(__FILE__) . '?mode=list');
|
||||
} else {
|
||||
|
|
|
@ -42,7 +42,6 @@ if (isset($_POST['add_name'])) {
|
|||
$message .= $lang['DISALLOWED_DELETED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_DISALLOWADMIN'], '<a href="admin_disallow.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
|
||||
|
||||
bb_die($message);
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -116,7 +116,6 @@ if (isset($_POST['submit'])) {
|
|||
|
||||
$datastore->update('cat_forums');
|
||||
bb_die($lang['FORUM_AUTH_UPDATED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_FORUMAUTH'], '<a href="' . "admin_forumauth.php" . '">', "</a>"));
|
||||
|
||||
} // End of submit
|
||||
|
||||
//
|
||||
|
@ -133,7 +132,6 @@ if (empty($forum_id)) {
|
|||
'S_AUTH_ACTION' => 'admin_forumauth.php',
|
||||
'S_AUTH_SELECT' => get_forum_select('admin', 'f', null, 80),
|
||||
));
|
||||
|
||||
} else {
|
||||
// Output the authorisation details if an id was specified
|
||||
$forum_name = $forum_rows[0]['forum_name'];
|
||||
|
|
|
@ -146,7 +146,6 @@ if (isset($_POST['submit'])) {
|
|||
|
||||
$datastore->update('cat_forums');
|
||||
bb_die($lang['FORUM_AUTH_UPDATED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_FORUMAUTH'], '<a href="admin_forumauth_list.php">', "</a>"));
|
||||
|
||||
} // End of submit
|
||||
|
||||
//
|
||||
|
|
|
@ -38,7 +38,7 @@ $mode = ($_REQUEST['mode']) ? (string)$_REQUEST['mode'] : '';
|
|||
$cat_forums = get_cat_forums();
|
||||
|
||||
if ($orphan_sf_sql = get_orphan_sf()) {
|
||||
fix_orphan_sf($orphan_sf_sql, TRUE);
|
||||
fix_orphan_sf($orphan_sf_sql, true);
|
||||
}
|
||||
$forum_parent = $cat_id = 0;
|
||||
$forumname = '';
|
||||
|
@ -114,7 +114,7 @@ if ($mode) {
|
|||
$cat_id = (int)$_REQUEST['c'];
|
||||
}
|
||||
|
||||
$catlist = get_list('category', $cat_id, TRUE);
|
||||
$catlist = get_list('category', $cat_id, true);
|
||||
$forumlocked = $forumunlocked = '';
|
||||
|
||||
$forumstatus == (FORUM_LOCKED) ? $forumlocked = 'selected="selected"' : $forumunlocked = 'selected="selected"';
|
||||
|
@ -563,11 +563,11 @@ if ($mode) {
|
|||
|
||||
$cat_id = $forum_info['cat_id'];
|
||||
|
||||
$move_down_forum_id = FALSE;
|
||||
$move_down_forum_id = false;
|
||||
$forums = $cat_forums[$cat_id]['f_ord'];
|
||||
$forum_order = $forum_info['forum_order'];
|
||||
$prev_forum = (isset($forums[$forum_order - 10])) ? $forums[$forum_order - 10] : FALSE;
|
||||
$next_forum = (isset($forums[$forum_order + 10])) ? $forums[$forum_order + 10] : FALSE;
|
||||
$prev_forum = (isset($forums[$forum_order - 10])) ? $forums[$forum_order - 10] : false;
|
||||
$next_forum = (isset($forums[$forum_order + 10])) ? $forums[$forum_order + 10] : false;
|
||||
|
||||
// move selected forum ($forum_id) UP
|
||||
if ($move < 0 && $prev_forum) {
|
||||
|
@ -734,7 +734,6 @@ if (!$mode || $show_main_page) {
|
|||
$row_bgr = " class=\"$bgr_class\" onmouseover=\"this.className='$bgr_class_over';\" onmouseout=\"this.className='$bgr_class';\"";
|
||||
|
||||
if ($forum_rows[$j]['cat_id'] == $cat_id) {
|
||||
|
||||
$template->assign_block_vars("c.f", array(
|
||||
'FORUM_NAME' => htmlCHR($forum_rows[$j]['forum_name']),
|
||||
'FORUM_DESC' => htmlCHR($forum_rows[$j]['forum_desc']),
|
||||
|
@ -759,7 +758,6 @@ if (!$mode || $show_main_page) {
|
|||
'U_FORUM_MOVE_DOWN' => "admin_forums.php?mode=forum_order&move=15&f=$forum_id&c=$req_cat_id",
|
||||
'U_FORUM_RESYNC' => "admin_forums.php?mode=forum_sync&f=$forum_id",
|
||||
));
|
||||
|
||||
}// if ... forumid == catid
|
||||
} // for ... forums
|
||||
} // for ... categories
|
||||
|
@ -898,10 +896,9 @@ function renumber_order($mode, $cat = 0)
|
|||
if (!$result = DB()->sql_query($sql)) {
|
||||
bb_die('Could not get list of categories / forums #3');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function get_cat_forums($cat_id = FALSE)
|
||||
function get_cat_forums($cat_id = false)
|
||||
{
|
||||
$forums = array();
|
||||
$where_sql = '';
|
||||
|
@ -959,7 +956,7 @@ function get_prev_root_forum_id($forums, $curr_forum_order)
|
|||
$i = $i - 10;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
function get_next_root_forum_id($forums, $curr_forum_order)
|
||||
|
@ -974,7 +971,7 @@ function get_next_root_forum_id($forums, $curr_forum_order)
|
|||
$i = $i + 10;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
function get_orphan_sf()
|
||||
|
@ -999,7 +996,7 @@ function get_orphan_sf()
|
|||
return implode(',', $bad_sf_ary);
|
||||
}
|
||||
|
||||
function fix_orphan_sf($orphan_sf_sql = '', $show_mess = FALSE)
|
||||
function fix_orphan_sf($orphan_sf_sql = '', $show_mess = false)
|
||||
{
|
||||
global $lang;
|
||||
|
||||
|
@ -1067,7 +1064,7 @@ function get_forum_data($forum_id)
|
|||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
function get_max_forum_order($cat_id)
|
||||
|
|
|
@ -18,9 +18,15 @@ $group_id = (int)request_var(POST_GROUPS_URL, 0);
|
|||
$errors = $user_id_sql = array();
|
||||
|
||||
if (isset($_POST['submit'])) {
|
||||
if (!$subject) $errors[] = $lang['EMPTY_SUBJECT'];
|
||||
if (!$message) $errors[] = $lang['EMPTY_MESSAGE'];
|
||||
if (!$group_id) $errors[] = $lang['GROUP_NOT_EXIST'];
|
||||
if (!$subject) {
|
||||
$errors[] = $lang['EMPTY_SUBJECT'];
|
||||
}
|
||||
if (!$message) {
|
||||
$errors[] = $lang['EMPTY_MESSAGE'];
|
||||
}
|
||||
if (!$group_id) {
|
||||
$errors[] = $lang['GROUP_NOT_EXIST'];
|
||||
}
|
||||
|
||||
if (!$errors) {
|
||||
$sql = DB()->fetch_rowset("SELECT ban_userid FROM " . BB_BANLIST . " WHERE ban_userid != 0");
|
||||
|
|
|
@ -76,7 +76,7 @@ if ($mode != '') {
|
|||
$rank_id = (isset($_POST['id'])) ? intval($_POST['id']) : 0;
|
||||
$rank_title = (isset($_POST['title'])) ? trim($_POST['title']) : '';
|
||||
$rank_style = (isset($_POST['style'])) ? trim($_POST['style']) : '';
|
||||
$special_rank = ($_POST['special_rank'] == 1) ? TRUE : 0;
|
||||
$special_rank = ($_POST['special_rank'] == 1) ? true : 0;
|
||||
$min_posts = (isset($_POST['min_posts'])) ? intval($_POST['min_posts']) : -1;
|
||||
$rank_image = ((isset($_POST['rank_image']))) ? trim($_POST['rank_image']) : '';
|
||||
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
<?php
|
||||
|
||||
if (!empty($setmodules)) {
|
||||
if (IS_SUPER_ADMIN) $module['GENERAL']['REBUILD_SEARCH_INDEX'] = basename(__FILE__);
|
||||
if (IS_SUPER_ADMIN) {
|
||||
$module['GENERAL']['REBUILD_SEARCH_INDEX'] = basename(__FILE__);
|
||||
}
|
||||
return;
|
||||
}
|
||||
require('./pagestart.php');
|
||||
|
||||
if (!IS_SUPER_ADMIN) bb_die($lang['NOT_ADMIN']);
|
||||
if (!IS_SUPER_ADMIN) {
|
||||
bb_die($lang['NOT_ADMIN']);
|
||||
}
|
||||
|
||||
require(INC_DIR . 'bbcode.php');
|
||||
|
||||
|
@ -199,8 +203,9 @@ if ($mode == 'submit' || $mode == 'refresh') {
|
|||
'rebuild_session_status' => REBUILD_SEARCH_PROCESSED,
|
||||
));
|
||||
DB()->query("REPLACE INTO " . BB_SEARCH_REBUILD . $args);
|
||||
} else // refresh
|
||||
{
|
||||
} else {
|
||||
// refresh
|
||||
|
||||
// update the last session entry
|
||||
DB()->query("
|
||||
UPDATE " . BB_SEARCH_REBUILD . " SET
|
||||
|
@ -247,8 +252,9 @@ if ($mode == 'submit' || $mode == 'refresh') {
|
|||
$template->assign_vars(array(
|
||||
'CANCEL_BUTTON' => true,
|
||||
));
|
||||
} else // end of processing
|
||||
{
|
||||
} else {
|
||||
// end of processing
|
||||
|
||||
$form_action = "admin_rebuild_search.php";
|
||||
$next_button = $lang['FINISHED'];
|
||||
$progress_bar_img = $images['progress_bar_full'];
|
||||
|
@ -329,8 +335,8 @@ if ($mode == 'submit' || $mode == 'refresh') {
|
|||
|
||||
'S_REBUILD_SEARCH_ACTION' => $form_action,
|
||||
));
|
||||
} else // show the input page
|
||||
{
|
||||
} else {
|
||||
// show the input page
|
||||
// create the page
|
||||
// used only with the select input
|
||||
$post_limit_hidden = ($def_post_limit > $total_posts) ? $total_posts : $def_post_limit;
|
||||
|
@ -362,8 +368,9 @@ if ($mode == 'submit' || $mode == 'refresh') {
|
|||
$clear_search_disabled = 'disabled="disabled"';
|
||||
|
||||
$template->assign_block_vars("start_select_input", array());
|
||||
} else // when finished
|
||||
{
|
||||
} else {
|
||||
// when finished
|
||||
|
||||
if ($last_session_data['end_post_id'] < $max_post_id) {
|
||||
$last_saved_processing = sprintf($lang['INFO_PROCESSING_FINISHED_NEW'], $last_saved_post_id, $total_posts_processed, $last_saved_date, ($total_posts - $total_posts_processed));
|
||||
$clear_search_disabled = 'disabled="disabled"';
|
||||
|
|
|
@ -136,17 +136,23 @@ if (!isset($_REQUEST['dosearch'])) {
|
|||
switch ($mode) {
|
||||
case 'search_username':
|
||||
$username = $_REQUEST['username'];
|
||||
if (!$username) bb_die($lang['SEARCH_INVALID_USERNAME']);
|
||||
if (!$username) {
|
||||
bb_die($lang['SEARCH_INVALID_USERNAME']);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'search_email':
|
||||
$email = $_REQUEST['email'];
|
||||
if (!$email) bb_die($lang['SEARCH_INVALID_EMAIL']);
|
||||
if (!$email) {
|
||||
bb_die($lang['SEARCH_INVALID_EMAIL']);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'search_ip':
|
||||
$ip_address = $_REQUEST['ip_address'];
|
||||
if (!$ip_address) bb_die($lang['SEARCH_INVALID_IP']);
|
||||
if (!$ip_address) {
|
||||
bb_die($lang['SEARCH_INVALID_IP']);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'search_joindate':
|
||||
|
@ -154,55 +160,75 @@ if (!isset($_REQUEST['dosearch'])) {
|
|||
$date_day = $_REQUEST['date_day'];
|
||||
$date_month = $_REQUEST['date_month'];
|
||||
$date_year = $_REQUEST['date_year'];
|
||||
if (!($date_type || $date_day || $date_month || $date_year)) bb_die($lang['SEARCH_INVALID_DATE']);
|
||||
if (!($date_type || $date_day || $date_month || $date_year)) {
|
||||
bb_die($lang['SEARCH_INVALID_DATE']);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'search_group':
|
||||
$group_id = $_REQUEST['group_id'];
|
||||
if (!$group_id) bb_die($lang['SEARCH_INVALID_GROUP']);
|
||||
if (!$group_id) {
|
||||
bb_die($lang['SEARCH_INVALID_GROUP']);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'search_rank':
|
||||
$rank_id = $_REQUEST['rank_id'];
|
||||
if (!$rank_id) bb_die($lang['SEARCH_INVALID_RANK']);
|
||||
if (!$rank_id) {
|
||||
bb_die($lang['SEARCH_INVALID_RANK']);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'search_postcount':
|
||||
$postcount_type = $_REQUEST['postcount_type'];
|
||||
$postcount_value = $_REQUEST['postcount_value'];
|
||||
if (!$postcount_type || (!$postcount_value && $postcount_value != 0)) bb_die($lang['SEARCH_INVALID_POSTCOUNT']);
|
||||
if (!$postcount_type || (!$postcount_value && $postcount_value != 0)) {
|
||||
bb_die($lang['SEARCH_INVALID_POSTCOUNT']);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'search_userfield':
|
||||
$userfield_type = $_REQUEST['userfield_type'];
|
||||
$userfield_value = $_REQUEST['userfield_value'];
|
||||
if (!$userfield_type || !$userfield_value) bb_die($lang['SEARCH_INVALID_USERFIELD']);
|
||||
if (!$userfield_type || !$userfield_value) {
|
||||
bb_die($lang['SEARCH_INVALID_USERFIELD']);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'search_lastvisited':
|
||||
$lastvisited_days = $_REQUEST['lastvisited_days'];
|
||||
$lastvisited_type = $_REQUEST['lastvisited_type'];
|
||||
if (!$lastvisited_days || !$lastvisited_type) bb_die($lang['SEARCH_INVALID_LASTVISITED']);
|
||||
if (!$lastvisited_days || !$lastvisited_type) {
|
||||
bb_die($lang['SEARCH_INVALID_LASTVISITED']);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'search_language':
|
||||
$language_type = $_REQUEST['language_type'];
|
||||
if (!$language_type) bb_die($lang['SEARCH_INVALID_LANGUAGE']);
|
||||
if (!$language_type) {
|
||||
bb_die($lang['SEARCH_INVALID_LANGUAGE']);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'search_timezone':
|
||||
$timezone_type = $_REQUEST['timezone_type'];
|
||||
if (!$timezone_type && $timezone_type != 0) bb_die($lang['SEARCH_INVALID_TIMEZONE']);
|
||||
if (!$timezone_type && $timezone_type != 0) {
|
||||
bb_die($lang['SEARCH_INVALID_TIMEZONE']);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'search_moderators':
|
||||
$moderators_forum = $_REQUEST['moderators_forum'];
|
||||
if (!$moderators_forum) bb_die($lang['SEARCH_INVALID_MODERATORS']);
|
||||
if (!$moderators_forum) {
|
||||
bb_die($lang['SEARCH_INVALID_MODERATORS']);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'search_misc':
|
||||
$misc = $_REQUEST['misc'];
|
||||
if (!$misc) bb_die($lang['SEARCH_INVALID']);
|
||||
if (!$misc) {
|
||||
bb_die($lang['SEARCH_INVALID']);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -231,7 +257,9 @@ if (!isset($_REQUEST['dosearch'])) {
|
|||
$op = '=';
|
||||
}
|
||||
|
||||
if ($username == '') bb_die($lang['SEARCH_INVALID_USERNAME']);
|
||||
if ($username == '') {
|
||||
bb_die($lang['SEARCH_INVALID_USERNAME']);
|
||||
}
|
||||
|
||||
$total_sql .= "SELECT COUNT(user_id) AS total FROM " . BB_USERS . " WHERE {$lower_b}username{$lower_e} $op '" . DB()->escape($username) . "' AND user_id <> " . GUEST_UID;
|
||||
$select_sql .= " WHERE {$lower_b}u.username{$lower_e} $op '" . DB()->escape($username) . "' AND u.user_id <> " . GUEST_UID;
|
||||
|
@ -250,7 +278,9 @@ if (!isset($_REQUEST['dosearch'])) {
|
|||
$op = '=';
|
||||
}
|
||||
|
||||
if ($email == '') bb_die($lang['SEARCH_INVALID_EMAIL']);
|
||||
if ($email == '') {
|
||||
bb_die($lang['SEARCH_INVALID_EMAIL']);
|
||||
}
|
||||
|
||||
$total_sql .= "SELECT COUNT(user_id) AS total FROM " . BB_USERS . " WHERE {$lower_b}user_email{$lower_e} $op '" . DB()->escape($email) . "' AND user_id <> " . GUEST_UID;
|
||||
$select_sql .= " WHERE {$lower_b}u.user_email{$lower_e} $op '" . DB()->escape($email) . "' AND u.user_id <> " . GUEST_UID;
|
||||
|
@ -287,7 +317,9 @@ if (!isset($_REQUEST['dosearch'])) {
|
|||
$range = preg_split('/[-\s]+/', $ip_address);
|
||||
$start_range = explode('.', $range[0]);
|
||||
$end_range = explode('.', $range[1]);
|
||||
if (($start_range[0] . $start_range[1] . $start_range[2] != $end_range[0] . $end_range[1] . $end_range[2]) || ($start_range[3] > $end_range[3])) bb_die($lang['SEARCH_INVALID_IP']);
|
||||
if (($start_range[0] . $start_range[1] . $start_range[2] != $end_range[0] . $end_range[1] . $end_range[2]) || ($start_range[3] > $end_range[3])) {
|
||||
bb_die($lang['SEARCH_INVALID_IP']);
|
||||
}
|
||||
for ($i = $start_range[3]; $i <= $end_range[3]; $i++) {
|
||||
$users[] = encode_ip($start_range[0] . "." . $start_range[1] . "." . $start_range[2] . "." . $i);
|
||||
}
|
||||
|
@ -318,7 +350,9 @@ if (!isset($_REQUEST['dosearch'])) {
|
|||
$where_sql .= ($ip_in_sql != '') ? "poster_ip IN ($ip_in_sql)" : "";
|
||||
$where_sql .= ($ip_like_sql != '') ? ($where_sql != "") ? " OR $ip_like_sql" : "$ip_like_sql" : "";
|
||||
|
||||
if (!$where_sql) bb_die('invalid request');
|
||||
if (!$where_sql) {
|
||||
bb_die('invalid request');
|
||||
}
|
||||
|
||||
// start search
|
||||
$no_result_search = false;
|
||||
|
@ -333,7 +367,7 @@ if (!isset($_REQUEST['dosearch'])) {
|
|||
$no_result_search = true;
|
||||
} else {
|
||||
$total_pages['total'] = DB()->num_rows($result);
|
||||
$total_sql = NULL;
|
||||
$total_sql = null;
|
||||
$ip_users_sql = '';
|
||||
while ($row = DB()->sql_fetchrow($result)) {
|
||||
$ip_users_sql .= ($ip_users_sql == '') ? $row['poster_id'] : ', ' . $row['poster_id'];
|
||||
|
@ -347,9 +381,11 @@ if (!isset($_REQUEST['dosearch'])) {
|
|||
bb_die('Could not count users #2');
|
||||
}
|
||||
if (DB()->num_rows($result) != 0) {
|
||||
if ($no_result_search == true) $no_result_search = false;
|
||||
if ($no_result_search == true) {
|
||||
$no_result_search = false;
|
||||
}
|
||||
$total_pages['total'] = DB()->num_rows($result);
|
||||
$total_sql = NULL;
|
||||
$total_sql = null;
|
||||
while ($row = DB()->sql_fetchrow($result)) {
|
||||
$ip_users_sql .= ($ip_users_sql == '') ? $row['user_id'] : ', ' . $row['user_id'];
|
||||
}
|
||||
|
@ -362,9 +398,11 @@ if (!isset($_REQUEST['dosearch'])) {
|
|||
bb_die('Could not count users #3');
|
||||
}
|
||||
if (DB()->num_rows($result) != 0) {
|
||||
if ($no_result_search == true) $no_result_search = false;
|
||||
if ($no_result_search == true) {
|
||||
$no_result_search = false;
|
||||
}
|
||||
$total_pages['total'] = DB()->num_rows($result);
|
||||
$total_sql = NULL;
|
||||
$total_sql = null;
|
||||
while ($row = DB()->sql_fetchrow($result)) {
|
||||
$ip_users_sql .= ($ip_users_sql == '') ? $row['user_id'] : ', ' . $row['user_id'];
|
||||
}
|
||||
|
@ -572,7 +610,9 @@ if (!isset($_REQUEST['dosearch'])) {
|
|||
$op = '=';
|
||||
}
|
||||
|
||||
if ($userfield_value == '') bb_die($lang['SEARCH_INVALID_USERFIELD']);
|
||||
if ($userfield_value == '') {
|
||||
bb_die($lang['SEARCH_INVALID_USERFIELD']);
|
||||
}
|
||||
|
||||
$userfield_type = trim(strtolower($userfield_type));
|
||||
|
||||
|
|
|
@ -189,10 +189,10 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
|
|||
|
||||
if (bf($onlinerow_reg[$i]['user_opt'], 'user_opt', 'user_viewonline')) {
|
||||
$hidden_users++;
|
||||
$hidden = TRUE;
|
||||
$hidden = true;
|
||||
} else {
|
||||
$registered_users++;
|
||||
$hidden = FALSE;
|
||||
$hidden = false;
|
||||
}
|
||||
|
||||
$row_class = 'row1';
|
||||
|
|
|
@ -6,7 +6,9 @@ require(BB_ROOT . 'common.php');
|
|||
|
||||
$user->session_start();
|
||||
|
||||
if (!IS_ADMIN) bb_die($lang['NOT_AUTHORISED']);
|
||||
if (!IS_ADMIN) {
|
||||
bb_die($lang['NOT_AUTHORISED']);
|
||||
}
|
||||
|
||||
$sql[] = 'SELECT count(*) FROM `' . BB_USERS . '` WHERE `user_lastvisit` < UNIX_TIMESTAMP()-2592000';
|
||||
$sql[] = 'SELECT count(*) FROM `' . BB_USERS . '` WHERE `user_lastvisit` < UNIX_TIMESTAMP()-7776000';
|
||||
|
@ -18,9 +20,7 @@ $sql[] = 'SELECT count(distinct(poster_id)) FROM `' . BB_BT_TORRENTS . '`';
|
|||
$sql[] = 'SELECT count(distinct(poster_id)) FROM `' . BB_BT_TORRENTS . '` WHERE reg_time >= UNIX_TIMESTAMP()-2592000';
|
||||
|
||||
echo '<html><body><head></head>';
|
||||
echo '
|
||||
<br /><br />
|
||||
<table border="1" cellspacing="0" cellpadding="6" align="center">';
|
||||
echo '<br /><br /><table border="1" cellspacing="0" cellpadding="6" align="center">';
|
||||
|
||||
foreach ($sql as $i => $query) {
|
||||
$row = mysql_fetch_row(DB()->query($query)); // TODO: deprecated
|
||||
|
@ -28,7 +28,6 @@ foreach ($sql as $i => $query) {
|
|||
}
|
||||
|
||||
echo '</table>';
|
||||
|
||||
echo '<div align="center"><pre>';
|
||||
|
||||
if ($l = sys('la')) {
|
||||
|
|
|
@ -9,7 +9,9 @@ $di = \TorrentPier\Di::getInstance();
|
|||
|
||||
$user->session_start();
|
||||
|
||||
if (!IS_ADMIN) bb_die($lang['NOT_AUTHORISED']);
|
||||
if (!IS_ADMIN) {
|
||||
bb_die($lang['NOT_AUTHORISED']);
|
||||
}
|
||||
|
||||
$peers_in_last_minutes = array(30, 15, 5, 1);
|
||||
$peers_in_last_sec_limit = 300;
|
||||
|
@ -38,14 +40,12 @@ DB()->query("
|
|||
$stat += DB()->fetch_row("SELECT COUNT(*) AS p_within_ann FROM " . TMP_TRACKER_TABLE . " WHERE update_time >= " . (TIMENOW - $announce_interval));
|
||||
// All peers, "max_peer_time"
|
||||
$stat += DB()->fetch_row("SELECT COUNT(*) AS p_all, SUM(speed_up) as speed_up, SUM(speed_down) as speed_down, UNIX_TIMESTAMP() - MIN(update_time) AS max_peer_time, UNIX_TIMESTAMP() - MAX(update_time) AS last_peer_time FROM " . TMP_TRACKER_TABLE);
|
||||
|
||||
// Active users
|
||||
$stat += DB()->fetch_row("SELECT COUNT(DISTINCT user_id) AS u_bt_active FROM " . TMP_TRACKER_TABLE);
|
||||
// All bt-users
|
||||
$stat += DB()->fetch_row("SELECT COUNT(*) AS u_bt_all FROM " . BB_BT_USERS);
|
||||
// All bb-users
|
||||
$stat += DB()->fetch_row("SELECT COUNT(*) AS u_bb_all FROM " . BB_USERS);
|
||||
|
||||
// Active torrents
|
||||
$stat += DB()->fetch_row("SELECT COUNT(DISTINCT topic_id) AS tor_active FROM " . TMP_TRACKER_TABLE);
|
||||
// With seeder
|
||||
|
@ -81,13 +81,7 @@ function commify_ob($contents)
|
|||
ob_start('commify_ob');
|
||||
|
||||
echo '<html><body><head></head>';
|
||||
echo '
|
||||
<br /><br />
|
||||
<table border="1" cellspacing="0" cellpadding="6" align="center">
|
||||
<col width="40%">
|
||||
<col width="60%">
|
||||
';
|
||||
|
||||
echo '<br /><br /><table border="1" cellspacing="0" cellpadding="6" align="center"><col width="40%"><col width="60%">';
|
||||
echo "\n<tr><td align=center> users: bb-all / bt-all / bt-active </td><td align=center> $stat[u_bb_all] / $stat[u_bt_all] / <b>$stat[u_bt_active]</b> </td></tr>\n";
|
||||
|
||||
echo "\n
|
||||
|
@ -111,12 +105,9 @@ echo "\n
|
|||
|
||||
echo "\n<tr><td align=center> peers: in last " . join(' / ', $peers_in_last_minutes) . " min</td>\n";
|
||||
echo "\n<td align=center>" . join(' / ', $peers_in_last_min) . "</td></tr>\n";
|
||||
|
||||
echo "\n<tr><td align=center> peers in last $peers_in_last_sec_limit sec <br /> [ per second, DESC order --> ] <br /> last peer: $stat[last_peer_time] seconds ago <br /> " . date("j M H:i:s [T O]") . " </td>\n";
|
||||
echo '<td align=center style="font-size: 13px; font-family: \'Courier New\',Courier,monospace;"><pre> ' . join(' ', $peers_in_last_sec) . "</pre></td></tr>\n";
|
||||
|
||||
echo '</table>';
|
||||
|
||||
echo '<div align="center"><pre>';
|
||||
|
||||
if ($l = sys('la')) {
|
||||
|
@ -128,7 +119,6 @@ if ($l = sys('la')) {
|
|||
}
|
||||
|
||||
echo 'gen time: <b>' . sprintf('%.3f', (array_sum(explode(' ', microtime())) - TIMESTART)) . "</b> sec\n";
|
||||
|
||||
echo '</pre></div>';
|
||||
echo '</body></html>';
|
||||
|
||||
|
|
72
ajax.php
72
ajax.php
|
@ -73,10 +73,10 @@ $ajax->exec();
|
|||
//
|
||||
class ajax_common
|
||||
{
|
||||
var $request = [];
|
||||
var $response = [];
|
||||
public $request = [];
|
||||
public $response = [];
|
||||
|
||||
var $valid_actions = [
|
||||
public $valid_actions = [
|
||||
// ACTION NAME AJAX_AUTH
|
||||
'edit_user_profile' => ['admin'],
|
||||
'change_user_rank' => ['admin'],
|
||||
|
@ -103,12 +103,12 @@ class ajax_common
|
|||
'index_data' => ['guest'],
|
||||
];
|
||||
|
||||
var $action = null;
|
||||
public $action = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function ajax_common()
|
||||
public function ajax_common()
|
||||
{
|
||||
ob_start([&$this, 'ob_handler']);
|
||||
header('Content-Type: text/plain');
|
||||
|
@ -117,7 +117,7 @@ class ajax_common
|
|||
/**
|
||||
* Perform action
|
||||
*/
|
||||
function exec()
|
||||
public function exec()
|
||||
{
|
||||
global $lang;
|
||||
|
||||
|
@ -189,7 +189,7 @@ class ajax_common
|
|||
* @param $error_msg
|
||||
* @param int $error_code
|
||||
*/
|
||||
function ajax_die($error_msg, $error_code = E_AJAX_GENERAL_ERROR)
|
||||
public function ajax_die($error_msg, $error_code = E_AJAX_GENERAL_ERROR)
|
||||
{
|
||||
$this->response['error_code'] = $error_code;
|
||||
$this->response['error_msg'] = $error_msg;
|
||||
|
@ -200,7 +200,7 @@ class ajax_common
|
|||
/**
|
||||
* Initialization
|
||||
*/
|
||||
function init()
|
||||
public function init()
|
||||
{
|
||||
$this->request = $_POST;
|
||||
$this->action =& $this->request['action'];
|
||||
|
@ -209,7 +209,7 @@ class ajax_common
|
|||
/**
|
||||
* Send data
|
||||
*/
|
||||
function send()
|
||||
public function send()
|
||||
{
|
||||
$this->response['action'] = $this->action;
|
||||
|
||||
|
@ -228,7 +228,7 @@ class ajax_common
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
function ob_handler($contents)
|
||||
public function ob_handler($contents)
|
||||
{
|
||||
if (DBG_USER) {
|
||||
if ($contents) {
|
||||
|
@ -251,7 +251,7 @@ class ajax_common
|
|||
/**
|
||||
* Admin session
|
||||
*/
|
||||
function check_admin_session()
|
||||
public function check_admin_session()
|
||||
{
|
||||
global $user;
|
||||
|
||||
|
@ -273,7 +273,7 @@ class ajax_common
|
|||
/**
|
||||
* Prompt for password
|
||||
*/
|
||||
function prompt_for_password()
|
||||
public function prompt_for_password()
|
||||
{
|
||||
$this->response['prompt_password'] = 1;
|
||||
$this->send();
|
||||
|
@ -284,9 +284,11 @@ class ajax_common
|
|||
*
|
||||
* @param $confirm_msg
|
||||
*/
|
||||
function prompt_for_confirm($confirm_msg)
|
||||
public function prompt_for_confirm($confirm_msg)
|
||||
{
|
||||
if (empty($confirm_msg)) $this->ajax_die('false');
|
||||
if (empty($confirm_msg)) {
|
||||
$this->ajax_die('false');
|
||||
}
|
||||
|
||||
$this->response['prompt_confirm'] = 1;
|
||||
$this->response['confirm_msg'] = $confirm_msg;
|
||||
|
@ -298,7 +300,7 @@ class ajax_common
|
|||
*
|
||||
* @param $forum_id
|
||||
*/
|
||||
function verify_mod_rights($forum_id)
|
||||
public function verify_mod_rights($forum_id)
|
||||
{
|
||||
global $userdata, $lang;
|
||||
|
||||
|
@ -309,102 +311,102 @@ class ajax_common
|
|||
}
|
||||
}
|
||||
|
||||
function edit_user_profile()
|
||||
public function edit_user_profile()
|
||||
{
|
||||
require(AJAX_DIR . 'edit_user_profile.php');
|
||||
}
|
||||
|
||||
function change_user_rank()
|
||||
public function change_user_rank()
|
||||
{
|
||||
require(AJAX_DIR . 'change_user_rank.php');
|
||||
}
|
||||
|
||||
function change_user_opt()
|
||||
public function change_user_opt()
|
||||
{
|
||||
require(AJAX_DIR . 'change_user_opt.php');
|
||||
}
|
||||
|
||||
function gen_passkey()
|
||||
public function gen_passkey()
|
||||
{
|
||||
require(AJAX_DIR . 'gen_passkey.php');
|
||||
}
|
||||
|
||||
function group_membership()
|
||||
public function group_membership()
|
||||
{
|
||||
require(AJAX_DIR . 'group_membership.php');
|
||||
}
|
||||
|
||||
function manage_group()
|
||||
public function manage_group()
|
||||
{
|
||||
require(AJAX_DIR . 'edit_group_profile.php');
|
||||
}
|
||||
|
||||
function post_mod_comment()
|
||||
public function post_mod_comment()
|
||||
{
|
||||
require(AJAX_DIR . 'post_mod_comment.php');
|
||||
}
|
||||
|
||||
function view_post()
|
||||
public function view_post()
|
||||
{
|
||||
require(AJAX_DIR . 'view_post.php');
|
||||
}
|
||||
|
||||
function change_tor_status()
|
||||
public function change_tor_status()
|
||||
{
|
||||
require(AJAX_DIR . 'change_tor_status.php');
|
||||
}
|
||||
|
||||
function change_torrent()
|
||||
public function change_torrent()
|
||||
{
|
||||
require(AJAX_DIR . 'change_torrent.php');
|
||||
}
|
||||
|
||||
function view_torrent()
|
||||
public function view_torrent()
|
||||
{
|
||||
require(AJAX_DIR . 'view_torrent.php');
|
||||
}
|
||||
|
||||
function user_register()
|
||||
public function user_register()
|
||||
{
|
||||
require(AJAX_DIR . 'user_register.php');
|
||||
}
|
||||
|
||||
function mod_action()
|
||||
public function mod_action()
|
||||
{
|
||||
require(AJAX_DIR . 'mod_action.php');
|
||||
}
|
||||
|
||||
function posts()
|
||||
public function posts()
|
||||
{
|
||||
require(AJAX_DIR . 'posts.php');
|
||||
}
|
||||
|
||||
function manage_user()
|
||||
public function manage_user()
|
||||
{
|
||||
require(AJAX_DIR . 'manage_user.php');
|
||||
}
|
||||
|
||||
function manage_admin()
|
||||
public function manage_admin()
|
||||
{
|
||||
require(AJAX_DIR . 'manage_admin.php');
|
||||
}
|
||||
|
||||
function topic_tpl()
|
||||
public function topic_tpl()
|
||||
{
|
||||
require(AJAX_DIR . 'topic_tpl.php');
|
||||
}
|
||||
|
||||
function index_data()
|
||||
public function index_data()
|
||||
{
|
||||
require(AJAX_DIR . 'index_data.php');
|
||||
}
|
||||
|
||||
function avatar()
|
||||
public function avatar()
|
||||
{
|
||||
require(AJAX_DIR . 'avatar.php');
|
||||
}
|
||||
|
||||
function sitemap()
|
||||
public function sitemap()
|
||||
{
|
||||
require(AJAX_DIR . 'sitemap.php');
|
||||
}
|
||||
|
|
|
@ -17,7 +17,9 @@ if (empty($_SERVER['HTTP_USER_AGENT'])) {
|
|||
|
||||
// Ignore 'completed' event
|
||||
if (isset($_GET['event']) && $_GET['event'] === 'completed') {
|
||||
if (DBG_LOG) dbg_log(' ', '!die-event-completed');
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', '!die-event-completed');
|
||||
}
|
||||
dummy_exit(mt_rand(600, 1200));
|
||||
}
|
||||
|
||||
|
@ -128,7 +130,9 @@ $peer_hash = md5(
|
|||
// Get cached peer info from previous announce (last peer info)
|
||||
$lp_info = $cache->get(PEER_HASH_PREFIX . $peer_hash);
|
||||
|
||||
if (DBG_LOG) dbg_log(' ', '$lp_info-get_from-CACHE-' . ($lp_info ? 'hit' : 'miss'));
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', '$lp_info-get_from-CACHE-' . ($lp_info ? 'hit' : 'miss'));
|
||||
}
|
||||
|
||||
// Drop fast announce
|
||||
if ($lp_info && (!isset($event) || $event !== 'stopped')) {
|
||||
|
@ -151,7 +155,9 @@ function drop_fast_announce($lp_info)
|
|||
|
||||
function msg_die($msg)
|
||||
{
|
||||
if (DBG_LOG) dbg_log(' ', '!die-' . clean_filename($msg));
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', '!die-' . clean_filename($msg));
|
||||
}
|
||||
|
||||
$output = \Rych\Bencode\Bencode::encode([
|
||||
# 'interval' => (int) 1800,
|
||||
|
@ -177,7 +183,9 @@ $stopped = ($event === 'stopped');
|
|||
// Stopped event
|
||||
if ($stopped) {
|
||||
$cache->delete(PEER_HASH_PREFIX . $peer_hash);
|
||||
if (DBG_LOG) dbg_log(' ', 'stopped');
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', 'stopped');
|
||||
}
|
||||
}
|
||||
|
||||
// Get last peer info from DB
|
||||
|
@ -186,7 +194,9 @@ if (!$lp_info) {
|
|||
SELECT * FROM " . BB_BT_TRACKER . " WHERE peer_hash = '$peer_hash' LIMIT 1
|
||||
");
|
||||
|
||||
if (DBG_LOG) dbg_log(' ', '$lp_info-get_from-DB-' . ($lp_info ? 'hit' : 'miss'));
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', '$lp_info-get_from-DB-' . ($lp_info ? 'hit' : 'miss'));
|
||||
}
|
||||
}
|
||||
|
||||
if ($lp_info) {
|
||||
|
@ -315,7 +325,9 @@ if ($tr_cfg['gold_silver_enabled'] && $down_add) {
|
|||
}
|
||||
|
||||
// Freeleech
|
||||
if ($tr_cfg['freeleech'] && $down_add) $down_add = 0;
|
||||
if ($tr_cfg['freeleech'] && $down_add) {
|
||||
$down_add = 0;
|
||||
}
|
||||
|
||||
// Insert / update peer info
|
||||
$peer_info_updated = false;
|
||||
|
@ -346,7 +358,9 @@ if ($lp_info) {
|
|||
|
||||
$peer_info_updated = DB()->affected_rows();
|
||||
|
||||
if (DBG_LOG) dbg_log(' ', 'this_peer-update' . ($peer_info_updated ? '' : '-FAIL'));
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', 'this_peer-update' . ($peer_info_updated ? '' : '-FAIL'));
|
||||
}
|
||||
}
|
||||
|
||||
if (!$lp_info || !$peer_info_updated) {
|
||||
|
@ -355,7 +369,9 @@ if (!$lp_info || !$peer_info_updated) {
|
|||
|
||||
DB()->query("REPLACE INTO " . BB_BT_TRACKER . " ($columns) VALUES ($values)");
|
||||
|
||||
if (DBG_LOG) dbg_log(' ', 'this_peer-insert');
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', 'this_peer-insert');
|
||||
}
|
||||
}
|
||||
|
||||
// Exit if stopped
|
||||
|
@ -377,12 +393,16 @@ $lp_info = array(
|
|||
|
||||
$lp_info_cached = $cache->set(PEER_HASH_PREFIX . $peer_hash, $lp_info, PEER_HASH_EXPIRE);
|
||||
|
||||
if (DBG_LOG && !$lp_info_cached) dbg_log(' ', '$lp_info-caching-FAIL');
|
||||
if (DBG_LOG && !$lp_info_cached) {
|
||||
dbg_log(' ', '$lp_info-caching-FAIL');
|
||||
}
|
||||
|
||||
// Get cached output
|
||||
$output = $cache->get(PEERS_LIST_PREFIX . $topic_id);
|
||||
|
||||
if (DBG_LOG) dbg_log(' ', '$output-get_from-CACHE-' . ($output !== false ? 'hit' : 'miss'));
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', '$output-get_from-CACHE-' . ($output !== false ? 'hit' : 'miss'));
|
||||
}
|
||||
|
||||
if (!$output) {
|
||||
// Retrieve peers
|
||||
|
@ -439,7 +459,9 @@ if (!$output) {
|
|||
|
||||
$peers_list_cached = $cache->set(PEERS_LIST_PREFIX . $topic_id, $output, PEERS_LIST_EXPIRE);
|
||||
|
||||
if (DBG_LOG && !$peers_list_cached) dbg_log(' ', '$output-caching-FAIL');
|
||||
if (DBG_LOG && !$peers_list_cached) {
|
||||
dbg_log(' ', '$output-caching-FAIL');
|
||||
}
|
||||
}
|
||||
|
||||
// Return data to client
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
<?php
|
||||
|
||||
if (!defined('IN_TRACKER')) die(basename(__FILE__));
|
||||
if (!defined('IN_TRACKER')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
// Exit if tracker is disabled
|
||||
if ($tr_cfg['off']) tr_die($tr_cfg['off_reason']);
|
||||
if ($tr_cfg['off']) {
|
||||
tr_die($tr_cfg['off_reason']);
|
||||
}
|
||||
|
||||
//
|
||||
// Functions
|
||||
|
@ -40,7 +44,9 @@ function silent_exit()
|
|||
|
||||
function error_exit($msg = '')
|
||||
{
|
||||
if (DBG_LOG) dbg_log(' ', '!err-' . clean_filename($msg));
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', '!err-' . clean_filename($msg));
|
||||
}
|
||||
|
||||
silent_exit();
|
||||
|
||||
|
@ -52,33 +58,33 @@ function error_exit($msg = '')
|
|||
// Database
|
||||
class sql_db
|
||||
{
|
||||
var $cfg = array();
|
||||
var $cfg_keys = array('dbhost', 'dbname', 'dbuser', 'dbpasswd', 'charset', 'persist');
|
||||
var $link = null;
|
||||
var $result = null;
|
||||
var $db_server = '';
|
||||
var $selected_db = null;
|
||||
public $cfg = array();
|
||||
public $cfg_keys = array('dbhost', 'dbname', 'dbuser', 'dbpasswd', 'charset', 'persist');
|
||||
public $link = null;
|
||||
public $result = null;
|
||||
public $db_server = '';
|
||||
public $selected_db = null;
|
||||
|
||||
var $locked = false;
|
||||
public $locked = false;
|
||||
|
||||
var $num_queries = 0;
|
||||
var $sql_starttime = 0;
|
||||
var $sql_inittime = 0;
|
||||
var $sql_timetotal = 0;
|
||||
var $sql_last_time = 0;
|
||||
var $slow_time = 0;
|
||||
public $num_queries = 0;
|
||||
public $sql_starttime = 0;
|
||||
public $sql_inittime = 0;
|
||||
public $sql_timetotal = 0;
|
||||
public $sql_last_time = 0;
|
||||
public $slow_time = 0;
|
||||
|
||||
var $dbg = array();
|
||||
var $dbg_id = 0;
|
||||
var $dbg_enabled = false;
|
||||
var $cur_query = null;
|
||||
public $dbg = array();
|
||||
public $dbg_id = 0;
|
||||
public $dbg_enabled = false;
|
||||
public $cur_query = null;
|
||||
|
||||
var $DBS = array();
|
||||
public $DBS = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function sql_db($cfg_values)
|
||||
public function sql_db($cfg_values)
|
||||
{
|
||||
global $DBS;
|
||||
|
||||
|
@ -94,7 +100,7 @@ class sql_db
|
|||
/**
|
||||
* Initialize connection
|
||||
*/
|
||||
function init()
|
||||
public function init()
|
||||
{
|
||||
// Connect to server
|
||||
$this->link = $this->connect();
|
||||
|
@ -117,7 +123,7 @@ class sql_db
|
|||
/**
|
||||
* Open connection
|
||||
*/
|
||||
function connect()
|
||||
public function connect()
|
||||
{
|
||||
$this->cur_query = 'connect';
|
||||
$this->debug('start');
|
||||
|
@ -149,7 +155,7 @@ class sql_db
|
|||
/**
|
||||
* Select database
|
||||
*/
|
||||
function select_db()
|
||||
public function select_db()
|
||||
{
|
||||
$this->cur_query = 'select db';
|
||||
$this->debug('start');
|
||||
|
@ -168,7 +174,7 @@ class sql_db
|
|||
/**
|
||||
* Base query method
|
||||
*/
|
||||
function sql_query($query)
|
||||
public function sql_query($query)
|
||||
{
|
||||
if (!is_resource($this->link)) {
|
||||
$this->init();
|
||||
|
@ -192,7 +198,7 @@ class sql_db
|
|||
/**
|
||||
* Execute query WRAPPER (with error handling)
|
||||
*/
|
||||
function query($query)
|
||||
public function query($query)
|
||||
{
|
||||
if (!$result = $this->sql_query($query)) {
|
||||
$this->trigger_error();
|
||||
|
@ -204,7 +210,7 @@ class sql_db
|
|||
/**
|
||||
* Return number of rows
|
||||
*/
|
||||
function num_rows($result = false)
|
||||
public function num_rows($result = false)
|
||||
{
|
||||
$num_rows = false;
|
||||
|
||||
|
@ -218,7 +224,7 @@ class sql_db
|
|||
/**
|
||||
* Return number of affected rows
|
||||
*/
|
||||
function affected_rows()
|
||||
public function affected_rows()
|
||||
{
|
||||
return is_resource($this->link) ? mysql_affected_rows($this->link) : -1;
|
||||
}
|
||||
|
@ -226,7 +232,7 @@ class sql_db
|
|||
/**
|
||||
* Fetch current row
|
||||
*/
|
||||
function sql_fetchrow($result)
|
||||
public function sql_fetchrow($result)
|
||||
{
|
||||
return is_resource($result) ? mysql_fetch_assoc($result) : false;
|
||||
}
|
||||
|
@ -234,7 +240,7 @@ class sql_db
|
|||
/**
|
||||
* Alias of sql_fetchrow()
|
||||
*/
|
||||
function fetch_next($result)
|
||||
public function fetch_next($result)
|
||||
{
|
||||
return $this->sql_fetchrow($result);
|
||||
}
|
||||
|
@ -242,7 +248,7 @@ class sql_db
|
|||
/**
|
||||
* Fetch row WRAPPER (with error handling)
|
||||
*/
|
||||
function fetch_row($query)
|
||||
public function fetch_row($query)
|
||||
{
|
||||
if (!$result = $this->sql_query($query)) {
|
||||
$this->trigger_error();
|
||||
|
@ -254,7 +260,7 @@ class sql_db
|
|||
/**
|
||||
* Fetch all rows
|
||||
*/
|
||||
function sql_fetchrowset($result)
|
||||
public function sql_fetchrowset($result)
|
||||
{
|
||||
$rowset = array();
|
||||
|
||||
|
@ -268,7 +274,7 @@ class sql_db
|
|||
/**
|
||||
* Fetch all rows WRAPPER (with error handling)
|
||||
*/
|
||||
function fetch_rowset($query)
|
||||
public function fetch_rowset($query)
|
||||
{
|
||||
if (!$result = $this->sql_query($query)) {
|
||||
$this->trigger_error();
|
||||
|
@ -280,7 +286,7 @@ class sql_db
|
|||
/**
|
||||
* Escape string used in sql query
|
||||
*/
|
||||
function escape($v, $check_type = false)
|
||||
public function escape($v, $check_type = false)
|
||||
{
|
||||
if (!is_resource($this->link)) {
|
||||
$this->init();
|
||||
|
@ -308,7 +314,7 @@ class sql_db
|
|||
/**
|
||||
* Return sql error array
|
||||
*/
|
||||
function sql_error()
|
||||
public function sql_error()
|
||||
{
|
||||
$return_ary = array(
|
||||
'code' => '',
|
||||
|
@ -328,7 +334,7 @@ class sql_db
|
|||
/**
|
||||
* Close sql connection
|
||||
*/
|
||||
function close()
|
||||
public function close()
|
||||
{
|
||||
if (is_resource($this->link)) {
|
||||
mysql_close($this->link);
|
||||
|
@ -336,13 +342,15 @@ class sql_db
|
|||
|
||||
$this->link = $this->selected_db = null;
|
||||
|
||||
if (DBG_LOG) dbg_log(str_repeat(' ', $this->num_queries), 'DB-num_queries-' . php_sapi_name());
|
||||
if (DBG_LOG) {
|
||||
dbg_log(str_repeat(' ', $this->num_queries), 'DB-num_queries-' . php_sapi_name());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get info about last query
|
||||
*/
|
||||
function query_info()
|
||||
public function query_info()
|
||||
{
|
||||
$info = array();
|
||||
|
||||
|
@ -364,9 +372,11 @@ class sql_db
|
|||
/**
|
||||
* Store debug info
|
||||
*/
|
||||
function debug($mode)
|
||||
public function debug($mode)
|
||||
{
|
||||
if (!SQL_DEBUG) return;
|
||||
if (!SQL_DEBUG) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($mode == 'start') {
|
||||
if (SQL_CALC_QUERY_TIME || DBG_LOG || SQL_LOG_SLOW_QUERIES) {
|
||||
|
@ -396,10 +406,12 @@ class sql_db
|
|||
/**
|
||||
* Trigger error
|
||||
*/
|
||||
function trigger_error($msg = '')
|
||||
public function trigger_error($msg = '')
|
||||
{
|
||||
if (error_reporting()) {
|
||||
if (!$msg) $msg = 'DB Error';
|
||||
if (!$msg) {
|
||||
$msg = 'DB Error';
|
||||
}
|
||||
|
||||
if (DBG_TRACKER === true) {
|
||||
$err = $this->sql_error();
|
||||
|
@ -415,7 +427,7 @@ class sql_db
|
|||
/**
|
||||
* Find caller source
|
||||
*/
|
||||
function debug_find_source()
|
||||
public function debug_find_source()
|
||||
{
|
||||
$source = '';
|
||||
$backtrace = debug_backtrace();
|
||||
|
@ -433,10 +445,14 @@ class sql_db
|
|||
/**
|
||||
* Log error
|
||||
*/
|
||||
function log_error()
|
||||
public function log_error()
|
||||
{
|
||||
if (!SQL_LOG_ERRORS) return;
|
||||
if (!error_reporting()) return;
|
||||
if (!SQL_LOG_ERRORS) {
|
||||
return;
|
||||
}
|
||||
if (!error_reporting()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$msg = array();
|
||||
$err = $this->sql_error();
|
||||
|
|
|
@ -4,7 +4,9 @@ define('IN_TRACKER', true);
|
|||
define('BB_ROOT', './../');
|
||||
require(BB_ROOT . 'common.php');
|
||||
|
||||
if (!$tr_cfg['scrape']) msg_die('Please disable SCRAPE!');
|
||||
if (!$tr_cfg['scrape']) {
|
||||
msg_die('Please disable SCRAPE!');
|
||||
}
|
||||
|
||||
// Recover info_hash
|
||||
if (isset($_GET['?info_hash']) && !isset($_GET['info_hash'])) {
|
||||
|
@ -19,7 +21,9 @@ $info_hash = $_GET['info_hash'];
|
|||
|
||||
function msg_die($msg)
|
||||
{
|
||||
if (DBG_LOG) dbg_log(' ', '!die-' . clean_filename($msg));
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', '!die-' . clean_filename($msg));
|
||||
}
|
||||
|
||||
$output = \Rych\Bencode\Bencode::encode([
|
||||
'min interval' => (int)1800,
|
||||
|
|
|
@ -49,7 +49,9 @@ $message = sprintf($lang['CALLSEED_TEXT'], make_url(TOPIC_URL . $topic_id), $t_d
|
|||
|
||||
if ($user_list) {
|
||||
foreach ($user_list as $row) {
|
||||
if (!empty($row['active_dl'])) continue;
|
||||
if (!empty($row['active_dl'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (bf($row['user_opt'], 'user_opt', 'user_callseed')) {
|
||||
send_pm($row['user_id'], $subject, $message, BOT_UID);
|
||||
|
|
36
common.php
36
common.php
|
@ -1,17 +1,29 @@
|
|||
<?php
|
||||
|
||||
if (isset($_REQUEST['GLOBALS'])) die();
|
||||
if (isset($_REQUEST['GLOBALS'])) {
|
||||
die();
|
||||
}
|
||||
|
||||
ignore_user_abort(true);
|
||||
define('TIMESTART', utime());
|
||||
define('TIMENOW', time());
|
||||
|
||||
if (empty($_SERVER['REMOTE_ADDR'])) $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
||||
if (empty($_SERVER['HTTP_USER_AGENT'])) $_SERVER['HTTP_USER_AGENT'] = '';
|
||||
if (empty($_SERVER['HTTP_REFERER'])) $_SERVER['HTTP_REFERER'] = '';
|
||||
if (empty($_SERVER['SERVER_NAME'])) $_SERVER['SERVER_NAME'] = '';
|
||||
if (empty($_SERVER['REMOTE_ADDR'])) {
|
||||
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
||||
}
|
||||
if (empty($_SERVER['HTTP_USER_AGENT'])) {
|
||||
$_SERVER['HTTP_USER_AGENT'] = '';
|
||||
}
|
||||
if (empty($_SERVER['HTTP_REFERER'])) {
|
||||
$_SERVER['HTTP_REFERER'] = '';
|
||||
}
|
||||
if (empty($_SERVER['SERVER_NAME'])) {
|
||||
$_SERVER['SERVER_NAME'] = '';
|
||||
}
|
||||
|
||||
if (!defined('BB_ROOT')) define('BB_ROOT', './');
|
||||
if (!defined('BB_ROOT')) {
|
||||
define('BB_ROOT', './');
|
||||
}
|
||||
|
||||
header('X-Frame-Options: SAMEORIGIN');
|
||||
|
||||
|
@ -393,8 +405,12 @@ function log_request($file = '', $prepend_str = false, $add_post = true)
|
|||
$file = ($file) ? $file : 'req/' . date('m-d');
|
||||
$str = array();
|
||||
$str[] = date('m-d H:i:s');
|
||||
if ($prepend_str !== false) $str[] = $prepend_str;
|
||||
if (!empty($user->data)) $str[] = $user->id . "\t" . html_entity_decode($user->name);
|
||||
if ($prepend_str !== false) {
|
||||
$str[] = $prepend_str;
|
||||
}
|
||||
if (!empty($user->data)) {
|
||||
$str[] = $user->id . "\t" . html_entity_decode($user->name);
|
||||
}
|
||||
$str[] = sprintf('%-15s', $_SERVER['REMOTE_ADDR']);
|
||||
|
||||
if (isset($_SERVER['REQUEST_URI'])) {
|
||||
|
@ -407,7 +423,9 @@ function log_request($file = '', $prepend_str = false, $add_post = true)
|
|||
$str[] = $_SERVER['HTTP_REFERER'];
|
||||
}
|
||||
|
||||
if (!empty($_POST) && $add_post) $str[] = "post: " . str_compact(urldecode(http_build_query($_POST)));
|
||||
if (!empty($_POST) && $add_post) {
|
||||
$str[] = "post: " . str_compact(urldecode(http_build_query($_POST)));
|
||||
}
|
||||
$str = join("\t", $str) . "\n";
|
||||
bb_log($str, $file);
|
||||
}
|
||||
|
|
4
dl.php
4
dl.php
|
@ -36,7 +36,9 @@ if (!$t_data) {
|
|||
// Auth check
|
||||
$is_auth = auth(AUTH_ALL, $t_data->forum_id, $userdata, $t_data);
|
||||
if (!IS_GUEST) {
|
||||
if (!$is_auth['auth_download']) login_redirect($di->config->get('dl_url') . $topic_id);
|
||||
if (!$is_auth['auth_download']) {
|
||||
login_redirect($di->config->get('dl_url') . $topic_id);
|
||||
}
|
||||
} elseif (!$di->config->get('tracker.guest_tracker')) {
|
||||
login_redirect($di->config->get('dl_url') . $topic_id);
|
||||
}
|
||||
|
|
4
feed.php
4
feed.php
|
@ -17,7 +17,9 @@ $mode = $di->request->request->get('mode');
|
|||
$type = $di->request->request->get('type');
|
||||
$id = $di->request->query->getInt('id');
|
||||
|
||||
if (!$mode) bb_simple_die($di->translator->trans('Do not specify a mode for the feed'));
|
||||
if (!$mode) {
|
||||
bb_simple_die($di->translator->trans('Do not specify a mode for the feed'));
|
||||
}
|
||||
|
||||
if ($mode == 'get_feed_url' && ($type == 'f' || $type == 'u') && $id >= 0) {
|
||||
if ($type == 'f') {
|
||||
|
|
12
group.php
12
group.php
|
@ -31,11 +31,15 @@ function generate_user_info(&$row, $date_format, $group_mod, &$from, &$posts, &$
|
|||
if (bf($row['user_opt'], 'user_opt', 'user_viewemail') || $group_mod) {
|
||||
$email_uri = ($di->config->get('board_email_form')) ? ("profile.php?mode=email&" . POST_USERS_URL . "=" . $row['user_id']) : 'mailto:' . $row['user_email'];
|
||||
$email = '<a class="editable" href="' . $email_uri . '">' . $row['user_email'] . '</a>';
|
||||
} else $email = '';
|
||||
} else {
|
||||
$email = '';
|
||||
}
|
||||
|
||||
if ($row['user_website']) {
|
||||
$www = ($di->config->get('text_buttons')) ? '<a class="txtb" href="' . $row['user_website'] . '" target="_userwww">' . $lang['VISIT_WEBSITE_TXTB'] . '</a>' : '<a class="txtb" href="' . $row['user_website'] . '" target="_userwww"><img src="' . $images['icon_www'] . '" alt="' . $lang['VISIT_WEBSITE'] . '" title="' . $lang['VISIT_WEBSITE'] . '" border="0" /></a>';
|
||||
} else $www = '';
|
||||
} else {
|
||||
$www = '';
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -160,7 +164,9 @@ if (!$group_id) {
|
|||
} else {
|
||||
if (IS_ADMIN) {
|
||||
redirect('admin/admin_groups.php');
|
||||
} else bb_die($lang['NO_GROUPS_EXIST']);
|
||||
} else {
|
||||
bb_die($lang['NO_GROUPS_EXIST']);
|
||||
}
|
||||
}
|
||||
} elseif (isset($_POST['joingroup']) && $_POST['joingroup']) {
|
||||
if ($group_info['group_type'] != GROUP_OPEN) {
|
||||
|
|
12
index.php
12
index.php
|
@ -353,7 +353,9 @@ if ($di->config->get('birthday_check_day') && $di->config->get('birthday_enabled
|
|||
}
|
||||
$week_all = ($week_all) ? ' <a class="txtb" href="#" onclick="ajax.exec({action: \'index_data\', mode: \'birthday_week\'}); return false;" title="' . $lang['ALL'] . '">...</a>' : '';
|
||||
$week_list = sprintf($lang['BIRTHDAY_WEEK'], $di->config->get('birthday_check_day'), join(', ', $week_list)) . $week_all;
|
||||
} else $week_list = sprintf($lang['NOBIRTHDAY_WEEK'], $di->config->get('birthday_check_day'));
|
||||
} else {
|
||||
$week_list = sprintf($lang['NOBIRTHDAY_WEEK'], $di->config->get('birthday_check_day'));
|
||||
}
|
||||
|
||||
if ($stats['birthday_today_list']) {
|
||||
shuffle($stats['birthday_today_list']);
|
||||
|
@ -366,7 +368,9 @@ if ($di->config->get('birthday_check_day') && $di->config->get('birthday_enabled
|
|||
}
|
||||
$today_all = ($today_all) ? ' <a class="txtb" href="#" onclick="ajax.exec({action: \'index_data\', mode: \'birthday_today\'}); return false;" title="' . $lang['ALL'] . '">...</a>' : '';
|
||||
$today_list = $lang['BIRTHDAY_TODAY'] . join(', ', $today_list) . $today_all;
|
||||
} else $today_list = $lang['NOBIRTHDAY_TODAY'];
|
||||
} else {
|
||||
$today_list = $lang['NOBIRTHDAY_TODAY'];
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'WHOSBIRTHDAY_WEEK' => $week_list,
|
||||
|
@ -387,6 +391,8 @@ if (IS_AM) {
|
|||
// Display page
|
||||
define('SHOW_ONLINE', $show_online_users);
|
||||
|
||||
if (isset($_GET['map'])) $template->assign_vars(array('PAGE_TITLE' => $lang['FORUM_MAP']));
|
||||
if (isset($_GET['map'])) {
|
||||
$template->assign_vars(array('PAGE_TITLE' => $lang['FORUM_MAP']));
|
||||
}
|
||||
|
||||
print_page('index.tpl');
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('IN_AJAX')) die(basename(__FILE__));
|
||||
if (!defined('IN_AJAX')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $lang, $user;
|
||||
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
<?php
|
||||
|
||||
if (!defined('IN_AJAX')) die(basename(__FILE__));
|
||||
if (!defined('IN_AJAX')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $userdata, $lang;
|
||||
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
||||
if (!isset($this->request['topic_id'])) $this->ajax_die('Invalid topic_id');
|
||||
if (!isset($this->request['topic_id'])) {
|
||||
$this->ajax_die('Invalid topic_id');
|
||||
}
|
||||
|
||||
$topic_id = (int)$this->request['topic_id'];
|
||||
$mode = (string)$this->request['mode'];
|
||||
|
@ -26,16 +30,24 @@ $tor = DB()->fetch_row("
|
|||
LIMIT 1
|
||||
");
|
||||
|
||||
if (!$tor) $this->ajax_die($lang['TORRENT_FAILED']);
|
||||
if (!$tor) {
|
||||
$this->ajax_die($lang['TORRENT_FAILED']);
|
||||
}
|
||||
|
||||
switch ($mode) {
|
||||
case 'status':
|
||||
$new_status = (int)$this->request['status'];
|
||||
|
||||
// Валидность статуса
|
||||
if (!isset($lang['TOR_STATUS_NAME'][$new_status])) $this->ajax_die($lang['TOR_STATUS_FAILED']);
|
||||
if (!isset($this->request['status'])) $this->ajax_die($lang['TOR_DONT_CHANGE']);
|
||||
if (!IS_AM) $this->ajax_die($lang['NOT_MODERATOR']);
|
||||
if (!isset($lang['TOR_STATUS_NAME'][$new_status])) {
|
||||
$this->ajax_die($lang['TOR_STATUS_FAILED']);
|
||||
}
|
||||
if (!isset($this->request['status'])) {
|
||||
$this->ajax_die($lang['TOR_DONT_CHANGE']);
|
||||
}
|
||||
if (!IS_AM) {
|
||||
$this->ajax_die($lang['NOT_MODERATOR']);
|
||||
}
|
||||
|
||||
// Тот же статус
|
||||
if ($tor['tor_status'] == $new_status) {
|
||||
|
@ -49,7 +61,9 @@ switch ($mode) {
|
|||
|
||||
// Права на изменение статуса
|
||||
if ($tor['tor_status'] == TOR_CLOSED_CPHOLD) {
|
||||
if (!IS_ADMIN) $this->verify_mod_rights($tor['forum_id']);
|
||||
if (!IS_ADMIN) {
|
||||
$this->verify_mod_rights($tor['forum_id']);
|
||||
}
|
||||
DB()->query("UPDATE " . BB_TOPICS . " SET topic_status = " . TOPIC_UNLOCKED . " WHERE topic_id = {$topic_id} LIMIT 1");
|
||||
} else {
|
||||
$this->verify_mod_rights($tor['forum_id']);
|
||||
|
@ -74,7 +88,9 @@ switch ($mode) {
|
|||
$subject = sprintf($lang['TOR_MOD_TITLE'], $tor['topic_title']);
|
||||
$message = sprintf($lang['TOR_MOD_MSG'], get_username($tor['poster_id']), make_url(TOPIC_URL . $topic_id), $di->config->get('tor_icons.' . $new_status) . ' ' . $lang['TOR_STATUS_NAME'][$new_status]);
|
||||
|
||||
if ($comment && $comment != $lang['COMMENT']) $message .= "\n\n[b]" . $lang['COMMENT'] . '[/b]: ' . $comment;
|
||||
if ($comment && $comment != $lang['COMMENT']) {
|
||||
$message .= "\n\n[b]" . $lang['COMMENT'] . '[/b]: ' . $comment;
|
||||
}
|
||||
|
||||
send_pm($tor['poster_id'], $subject, $message, $userdata['user_id']);
|
||||
cache_rm_user_sessions($tor['poster_id']);
|
||||
|
@ -83,12 +99,16 @@ switch ($mode) {
|
|||
break;
|
||||
|
||||
case 'status_reply':
|
||||
if (!$di->config->get('tor_comment')) $this->ajax_die($lang['MODULE_OFF']);
|
||||
if (!$di->config->get('tor_comment')) {
|
||||
$this->ajax_die($lang['MODULE_OFF']);
|
||||
}
|
||||
|
||||
$subject = sprintf($lang['TOR_AUTH_TITLE'], $tor['topic_title']);
|
||||
$message = sprintf($lang['TOR_AUTH_MSG'], get_username($tor['checked_user_id']), make_url(TOPIC_URL . $topic_id), $tor['topic_title']);
|
||||
|
||||
if ($comment && $comment != $lang['COMMENT']) $message .= "\n\n[b]" . $lang['COMMENT'] . '[/b]: ' . $comment;
|
||||
if ($comment && $comment != $lang['COMMENT']) {
|
||||
$message .= "\n\n[b]" . $lang['COMMENT'] . '[/b]: ' . $comment;
|
||||
}
|
||||
|
||||
send_pm($tor['checked_user_id'], $subject, $message, $userdata['user_id']);
|
||||
cache_rm_user_sessions($tor['checked_user_id']);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('IN_AJAX')) die(basename(__FILE__));
|
||||
if (!defined('IN_AJAX')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $lang;
|
||||
|
||||
|
@ -46,13 +48,17 @@ switch ($type) {
|
|||
break;
|
||||
|
||||
case 'del_torrent';
|
||||
if (empty($this->request['confirmed'])) $this->prompt_for_confirm($lang['DEL_TORRENT']);
|
||||
if (empty($this->request['confirmed'])) {
|
||||
$this->prompt_for_confirm($lang['DEL_TORRENT']);
|
||||
}
|
||||
delete_torrent($topic_id);
|
||||
$url = make_url(TOPIC_URL . $topic_id);
|
||||
break;
|
||||
|
||||
case 'del_torrent_move_topic';
|
||||
if (empty($this->request['confirmed'])) $this->prompt_for_confirm($lang['DEL_MOVE_TORRENT']);
|
||||
if (empty($this->request['confirmed'])) {
|
||||
$this->prompt_for_confirm($lang['DEL_MOVE_TORRENT']);
|
||||
}
|
||||
delete_torrent($topic_id);
|
||||
$url = make_url("modcp.php?t=$topic_id&mode=move");
|
||||
break;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('IN_AJAX')) die(basename(__FILE__));
|
||||
if (!defined('IN_AJAX')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $bf, $lang;
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('IN_AJAX')) die(basename(__FILE__));
|
||||
if (!defined('IN_AJAX')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $datastore, $lang;
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('IN_AJAX')) die(basename(__FILE__));
|
||||
if (!defined('IN_AJAX')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $userdata, $lang;
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('IN_AJAX')) die(basename(__FILE__));
|
||||
if (!defined('IN_AJAX')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $lang;
|
||||
|
||||
|
@ -39,18 +41,26 @@ switch ($field) {
|
|||
case 'user_website':
|
||||
if ($value == '' || preg_match('#^https?://[\w\#!$%&~/.\-;:=,?@а-яА-Я\[\]+]+$#iu', $value)) {
|
||||
$this->response['new_value'] = htmlCHR($value);
|
||||
} else $this->ajax_die($lang['WEBSITE_ERROR']);
|
||||
} else {
|
||||
$this->ajax_die($lang['WEBSITE_ERROR']);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'user_gender':
|
||||
if (!$di->config->get('gender')) $this->ajax_die($lang['MODULE_OFF']);
|
||||
if (!$di->config->get('gender')) {
|
||||
$this->ajax_die($lang['MODULE_OFF']);
|
||||
}
|
||||
if (!isset($lang['GENDER_SELECT'][$value])) {
|
||||
$this->ajax_die($lang['ERROR']);
|
||||
} else $this->response['new_value'] = $lang['GENDER_SELECT'][$value];
|
||||
} else {
|
||||
$this->response['new_value'] = $lang['GENDER_SELECT'][$value];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'user_birthday':
|
||||
if (!$di->config->get('birthday_enabled')) $this->ajax_die($lang['MODULE_OFF']);
|
||||
if (!$di->config->get('birthday_enabled')) {
|
||||
$this->ajax_die($lang['MODULE_OFF']);
|
||||
}
|
||||
$birthday_date = date_parse($value);
|
||||
|
||||
if (!empty($birthday_date['year'])) {
|
||||
|
@ -107,7 +117,9 @@ switch ($field) {
|
|||
case 'u_down_total':
|
||||
case 'u_up_release':
|
||||
case 'u_up_bonus':
|
||||
if (!IS_ADMIN) $this->ajax_die($lang['NOT_ADMIN']);
|
||||
if (!IS_ADMIN) {
|
||||
$this->ajax_die($lang['NOT_ADMIN']);
|
||||
}
|
||||
|
||||
$table = BB_BT_USERS;
|
||||
$value = (float)str_replace(',', '.', $this->request['value']);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('IN_AJAX')) die(basename(__FILE__));
|
||||
if (!defined('IN_AJAX')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $userdata, $lang;
|
||||
|
||||
|
@ -18,4 +20,6 @@ if ($req_uid == $userdata['user_id'] || IS_ADMIN) {
|
|||
tracker_rm_user($req_uid);
|
||||
|
||||
$this->response['passkey'] = $passkey;
|
||||
} else $this->ajax_die($lang['NOT_AUTHORISED']);
|
||||
} else {
|
||||
$this->ajax_die($lang['NOT_AUTHORISED']);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('IN_AJAX')) die(basename(__FILE__));
|
||||
if (!defined('IN_AJAX')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $lang, $user;
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('IN_AJAX')) die(basename(__FILE__));
|
||||
if (!defined('IN_AJAX')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $lang, $userdata, $datastore;
|
||||
|
||||
|
@ -22,7 +24,9 @@ switch ($mode) {
|
|||
$html[] = profile_url($week) . ' <span class="small">(' . birthday_age($week['user_birthday']) . ')</span>';
|
||||
}
|
||||
$html = sprintf($lang['BIRTHDAY_WEEK'], $di->config->get('birthday_check_day'), join(', ', $html));
|
||||
} else $html = sprintf($lang['NOBIRTHDAY_WEEK'], $di->config->get('birthday_check_day'));
|
||||
} else {
|
||||
$html = sprintf($lang['NOBIRTHDAY_WEEK'], $di->config->get('birthday_check_day'));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'birthday_today':
|
||||
|
@ -36,7 +40,9 @@ switch ($mode) {
|
|||
$html[] = profile_url($today) . ' <span class="small">(' . birthday_age($today['user_birthday']) . ')</span>';
|
||||
}
|
||||
$html = $lang['BIRTHDAY_TODAY'] . join(', ', $html);
|
||||
} else $html = $lang['NOBIRTHDAY_TODAY'];
|
||||
} else {
|
||||
$html = $lang['NOBIRTHDAY_TODAY'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'get_forum_mods':
|
||||
|
@ -69,8 +75,12 @@ switch ($mode) {
|
|||
|
||||
case 'change_tz':
|
||||
$tz = (int)$this->request['tz'];
|
||||
if ($tz < -12) $tz = -12;
|
||||
if ($tz > 13) $tz = 13;
|
||||
if ($tz < -12) {
|
||||
$tz = -12;
|
||||
}
|
||||
if ($tz > 13) {
|
||||
$tz = 13;
|
||||
}
|
||||
DB()->query("UPDATE " . BB_USERS . " SET user_timezone = $tz WHERE user_id = " . $userdata['user_id'] . " LIMIT 1");
|
||||
cache_rm_user_sessions($userdata['user_id']);
|
||||
break;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('IN_AJAX')) die(basename(__FILE__));
|
||||
if (!defined('IN_AJAX')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $userdata, $lang;
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('IN_AJAX')) die(basename(__FILE__));
|
||||
if (!defined('IN_AJAX')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $userdata, $lang;
|
||||
|
||||
|
@ -13,22 +15,32 @@ $user_id = $this->request['user_id'];
|
|||
switch ($mode) {
|
||||
case 'delete_profile':
|
||||
|
||||
if ($userdata['user_id'] == $user_id) $this->ajax_die($lang['USER_DELETE_ME']);
|
||||
if (empty($this->request['confirmed'])) $this->prompt_for_confirm($lang['USER_DELETE_CONFIRM']);
|
||||
if ($userdata['user_id'] == $user_id) {
|
||||
$this->ajax_die($lang['USER_DELETE_ME']);
|
||||
}
|
||||
if (empty($this->request['confirmed'])) {
|
||||
$this->prompt_for_confirm($lang['USER_DELETE_CONFIRM']);
|
||||
}
|
||||
|
||||
if ($user_id != BOT_UID) {
|
||||
delete_user_sessions($user_id);
|
||||
user_delete($user_id);
|
||||
|
||||
$this->response['info'] = $lang['USER_DELETED'];
|
||||
} else $this->ajax_die($lang['USER_DELETE_CSV']);
|
||||
} else {
|
||||
$this->ajax_die($lang['USER_DELETE_CSV']);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'delete_topics':
|
||||
|
||||
if (empty($this->request['confirmed']) && $userdata['user_id'] == $user_id) $this->prompt_for_confirm($lang['DELETE_USER_POSTS_ME']);
|
||||
if (empty($this->request['confirmed'])) $this->prompt_for_confirm($lang['DELETE_USER_ALL_POSTS_CONFIRM']);
|
||||
if (empty($this->request['confirmed']) && $userdata['user_id'] == $user_id) {
|
||||
$this->prompt_for_confirm($lang['DELETE_USER_POSTS_ME']);
|
||||
}
|
||||
if (empty($this->request['confirmed'])) {
|
||||
$this->prompt_for_confirm($lang['DELETE_USER_ALL_POSTS_CONFIRM']);
|
||||
}
|
||||
|
||||
if (IS_ADMIN) {
|
||||
$user_topics = DB()->fetch_rowset("SELECT topic_id FROM " . BB_TOPICS . " WHERE topic_poster = $user_id", 'topic_id');
|
||||
|
@ -36,26 +48,36 @@ switch ($mode) {
|
|||
$deleted_posts = post_delete('user', $user_id);
|
||||
|
||||
$this->response['info'] = $lang['USER_DELETED_POSTS'];
|
||||
} else $this->ajax_die($lang['NOT_ADMIN']);
|
||||
} else {
|
||||
$this->ajax_die($lang['NOT_ADMIN']);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'delete_message':
|
||||
|
||||
if (empty($this->request['confirmed']) && $userdata['user_id'] == $user_id) $this->prompt_for_confirm($lang['DELETE_USER_POSTS_ME']);
|
||||
if (empty($this->request['confirmed'])) $this->prompt_for_confirm($lang['DELETE_USER_POSTS_CONFIRM']);
|
||||
if (empty($this->request['confirmed']) && $userdata['user_id'] == $user_id) {
|
||||
$this->prompt_for_confirm($lang['DELETE_USER_POSTS_ME']);
|
||||
}
|
||||
if (empty($this->request['confirmed'])) {
|
||||
$this->prompt_for_confirm($lang['DELETE_USER_POSTS_CONFIRM']);
|
||||
}
|
||||
|
||||
if (IS_ADMIN) {
|
||||
post_delete('user', $user_id);
|
||||
|
||||
$this->response['info'] = $lang['USER_DELETED_POSTS'];
|
||||
} else $this->ajax_die($lang['NOT_ADMIN']);
|
||||
} else {
|
||||
$this->ajax_die($lang['NOT_ADMIN']);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'user_activate':
|
||||
|
||||
if (empty($this->request['confirmed'])) $this->prompt_for_confirm($lang['DEACTIVATE_CONFIRM']);
|
||||
if (empty($this->request['confirmed'])) {
|
||||
$this->prompt_for_confirm($lang['DEACTIVATE_CONFIRM']);
|
||||
}
|
||||
|
||||
DB()->query("UPDATE " . BB_USERS . " SET user_active = '1' WHERE user_id = " . $user_id);
|
||||
|
||||
|
@ -65,8 +87,12 @@ switch ($mode) {
|
|||
|
||||
case 'user_deactivate':
|
||||
|
||||
if ($userdata['user_id'] == $user_id) $this->ajax_die($lang['USER_DEACTIVATE_ME']);
|
||||
if (empty($this->request['confirmed'])) $this->prompt_for_confirm($lang['ACTIVATE_CONFIRM']);
|
||||
if ($userdata['user_id'] == $user_id) {
|
||||
$this->ajax_die($lang['USER_DEACTIVATE_ME']);
|
||||
}
|
||||
if (empty($this->request['confirmed'])) {
|
||||
$this->prompt_for_confirm($lang['ACTIVATE_CONFIRM']);
|
||||
}
|
||||
|
||||
DB()->query("UPDATE " . BB_USERS . " SET user_active = '0' WHERE user_id = " . $user_id);
|
||||
delete_user_sessions($user_id);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('IN_AJAX')) die(basename(__FILE__));
|
||||
if (!defined('IN_AJAX')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $userdata, $lang, $datastore;
|
||||
|
||||
|
@ -34,8 +36,12 @@ switch ($mode) {
|
|||
$topic_title = (string)$this->request['topic_title'];
|
||||
$new_title = clean_title($topic_title);
|
||||
|
||||
if (!$topic_id) $this->ajax_die($lang['INVALID_TOPIC_ID']);
|
||||
if ($new_title == '') $this->ajax_die($lang['DONT_MESSAGE_TITLE']);
|
||||
if (!$topic_id) {
|
||||
$this->ajax_die($lang['INVALID_TOPIC_ID']);
|
||||
}
|
||||
if ($new_title == '') {
|
||||
$this->ajax_die($lang['DONT_MESSAGE_TITLE']);
|
||||
}
|
||||
|
||||
if (!$t_data = DB()->fetch_row("SELECT forum_id FROM " . BB_TOPICS . " WHERE topic_id = $topic_id LIMIT 1")) {
|
||||
$this->ajax_die($lang['INVALID_TOPIC_ID_DB']);
|
||||
|
@ -67,7 +73,9 @@ switch ($mode) {
|
|||
$user_id = (int)$this->request['user_id'];
|
||||
$profiledata = get_userdata($user_id);
|
||||
|
||||
if (!$user_id) $this->ajax_die($lang['NO_USER_ID_SPECIFIED']);
|
||||
if (!$user_id) {
|
||||
$this->ajax_die($lang['NO_USER_ID_SPECIFIED']);
|
||||
}
|
||||
|
||||
$reg_ip = DB()->fetch_rowset("SELECT username, user_id, user_rank FROM " . BB_USERS . "
|
||||
WHERE user_reg_ip = '{$profiledata['user_reg_ip']}'
|
||||
|
@ -96,9 +104,11 @@ switch ($mode) {
|
|||
}
|
||||
}
|
||||
|
||||
if ($profiledata['user_level'] == ADMIN && !IS_ADMIN) $reg_ip = $last_ip = $lang['HIDDEN'];
|
||||
elseif ($profiledata['user_level'] == MOD && IS_MOD) $reg_ip = $last_ip = $lang['HIDDEN'];
|
||||
else {
|
||||
if ($profiledata['user_level'] == ADMIN && !IS_ADMIN) {
|
||||
$reg_ip = $last_ip = $lang['HIDDEN'];
|
||||
} elseif ($profiledata['user_level'] == MOD && IS_MOD) {
|
||||
$reg_ip = $last_ip = $lang['HIDDEN'];
|
||||
} else {
|
||||
$user_reg_ip = decode_ip($profiledata['user_reg_ip']);
|
||||
$user_last_ip = decode_ip($profiledata['user_last_ip']);
|
||||
$reg_ip = '<a href="' . $di->config->get('whois_info') . $user_reg_ip . '" class="gen" target="_blank">' . $user_reg_ip . '</a>';
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
<?php
|
||||
|
||||
if (!defined('IN_AJAX')) die(basename(__FILE__));
|
||||
if (!defined('IN_AJAX')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $lang, $userdata;
|
||||
|
||||
$post_id = (int)$this->request['post_id'];
|
||||
$mc_type = (int)$this->request['mc_type'];
|
||||
$mc_text = (string)$this->request['mc_text'];
|
||||
if (!$mc_text = prepare_message($mc_text)) $this->ajax_die($lang['EMPTY_MESSAGE']);
|
||||
if (!$mc_text = prepare_message($mc_text)) {
|
||||
$this->ajax_die($lang['EMPTY_MESSAGE']);
|
||||
}
|
||||
|
||||
$post = DB()->fetch_row("
|
||||
SELECT
|
||||
|
@ -15,7 +19,9 @@ $post = DB()->fetch_row("
|
|||
FROM " . BB_POSTS . " p
|
||||
WHERE p.post_id = $post_id
|
||||
");
|
||||
if (!$post) $this->ajax_die('not post');
|
||||
if (!$post) {
|
||||
$this->ajax_die('not post');
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'mc_comment' => ($mc_type) ? $mc_text : '',
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('IN_AJAX')) die(basename(__FILE__));
|
||||
if (!defined('IN_AJAX')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $lang, $userdata;
|
||||
|
||||
|
@ -19,7 +21,9 @@ if (isset($this->request['post_id'])) {
|
|||
AND f.forum_id = t.forum_id
|
||||
AND p.post_id = pt.post_id
|
||||
LIMIT 1");
|
||||
if (!$post) $this->ajax_die('not post');
|
||||
if (!$post) {
|
||||
$this->ajax_die('not post');
|
||||
}
|
||||
|
||||
$is_auth = auth(AUTH_ALL, $post['forum_id'], $userdata, $post);
|
||||
if ($post['topic_status'] == TOPIC_LOCKED && !$is_auth['auth_mod']) {
|
||||
|
@ -32,7 +36,9 @@ if (isset($this->request['post_id'])) {
|
|||
WHERE t.topic_id = $topic_id
|
||||
AND f.forum_id = t.forum_id
|
||||
LIMIT 1");
|
||||
if (!$post) $this->ajax_die('not post');
|
||||
if (!$post) {
|
||||
$this->ajax_die('not post');
|
||||
}
|
||||
|
||||
$is_auth = auth(AUTH_ALL, $post['forum_id'], $userdata, $post);
|
||||
}
|
||||
|
@ -94,7 +100,9 @@ switch ($this->request['type']) {
|
|||
|
||||
case 'view_message':
|
||||
$message = (string)$this->request['message'];
|
||||
if (!trim($message)) $this->ajax_die($lang['EMPTY_MESSAGE']);
|
||||
if (!trim($message)) {
|
||||
$this->ajax_die($lang['EMPTY_MESSAGE']);
|
||||
}
|
||||
$message = htmlCHR($message, false, ENT_NOQUOTES);
|
||||
|
||||
$this->response['message_html'] = bbcode2html($message);
|
||||
|
@ -135,7 +143,9 @@ switch ($this->request['type']) {
|
|||
'post_text' => $text,
|
||||
));
|
||||
}
|
||||
} else $this->ajax_die($lang['EMPTY_MESSAGE']);
|
||||
} else {
|
||||
$this->ajax_die($lang['EMPTY_MESSAGE']);
|
||||
}
|
||||
|
||||
// Update atom feed
|
||||
update_atom('topic', (int)$this->request['topic_id']);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('IN_AJAX')) die(basename(__FILE__));
|
||||
if (!defined('IN_AJAX')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $lang;
|
||||
|
||||
|
@ -22,7 +24,9 @@ switch ($mode) {
|
|||
break;
|
||||
|
||||
case 'search_update':
|
||||
if (!file_exists(SITEMAP_DIR . 'sitemap.xml')) $map->create();
|
||||
if (!file_exists(SITEMAP_DIR . 'sitemap.xml')) {
|
||||
$map->create();
|
||||
}
|
||||
|
||||
$map_link = make_url(SITEMAP_DIR . 'sitemap.xml');
|
||||
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
<?php
|
||||
|
||||
if (!defined('IN_AJAX')) die(basename(__FILE__));
|
||||
if (!defined('IN_AJAX')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $userdata;
|
||||
|
||||
if (!IS_SUPER_ADMIN) $this->ajax_die('not auth');
|
||||
if (!IS_SUPER_ADMIN) {
|
||||
$this->ajax_die('not auth');
|
||||
}
|
||||
|
||||
array_deep($this->request, 'trim');
|
||||
|
||||
|
@ -140,8 +144,9 @@ switch ($mode) {
|
|||
|
||||
// возможный дубль названия шаблона
|
||||
if ($sql_error) {
|
||||
if ($sql_error['code'] == 1062) // Duplicate entry
|
||||
{
|
||||
if ($sql_error['code'] == 1062) {
|
||||
// Duplicate entry
|
||||
|
||||
$this->ajax_die('Шаблон с таким названием уже существует, выберите другое название');
|
||||
}
|
||||
$this->ajax_die("db error {$sql_error['code']}: {$sql_error['message']}");
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('IN_AJAX')) die(basename(__FILE__));
|
||||
if (!defined('IN_AJAX')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $lang, $userdata;
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('IN_AJAX')) die(basename(__FILE__));
|
||||
if (!defined('IN_AJAX')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $user, $lang;
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('IN_AJAX')) die(basename(__FILE__));
|
||||
if (!defined('IN_AJAX')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $lang;
|
||||
|
||||
|
@ -41,18 +43,18 @@ function build_tor_filelist($file_contents)
|
|||
|
||||
class torrent
|
||||
{
|
||||
var $tor_decoded = array();
|
||||
var $files_ary = array('/' => '');
|
||||
var $multiple = null;
|
||||
var $root_dir = '';
|
||||
var $files_html = '';
|
||||
public $tor_decoded = array();
|
||||
public $files_ary = array('/' => '');
|
||||
public $multiple = null;
|
||||
public $root_dir = '';
|
||||
public $files_html = '';
|
||||
|
||||
function torrent($decoded_file_contents)
|
||||
public function torrent($decoded_file_contents)
|
||||
{
|
||||
$this->tor_decoded = $decoded_file_contents;
|
||||
}
|
||||
|
||||
function get_filelist()
|
||||
public function get_filelist()
|
||||
{
|
||||
$this->build_filelist_array();
|
||||
|
||||
|
@ -68,7 +70,7 @@ class torrent
|
|||
}
|
||||
}
|
||||
|
||||
function build_filelist_array()
|
||||
public function build_filelist_array()
|
||||
{
|
||||
$info = $this->tor_decoded['info'];
|
||||
|
||||
|
@ -129,7 +131,7 @@ class torrent
|
|||
}
|
||||
}
|
||||
|
||||
function build_file_item($name, $length)
|
||||
public function build_file_item($name, $length)
|
||||
{
|
||||
global $images, $lang;
|
||||
|
||||
|
@ -146,7 +148,7 @@ class torrent
|
|||
return "$name <i>$length</i> $magnet_name $magnet_ext";
|
||||
}
|
||||
|
||||
function build_filelist_html()
|
||||
public function build_filelist_html()
|
||||
{
|
||||
global $html;
|
||||
return $html->array2html($this->files_ary);
|
||||
|
@ -158,6 +160,8 @@ function clean_tor_dirname($dirname)
|
|||
return str_replace(array('[', ']', '<', '>', "'"), array('[', ']', '<', '>', '''), $dirname);
|
||||
}
|
||||
|
||||
if ($bnc_error) $tor_filelist = '<b style="color: #993300;">' . $lang['ERROR_BUILD'] . '</b><br /><br />' . $tor_filelist;
|
||||
if ($bnc_error) {
|
||||
$tor_filelist = '<b style="color: #993300;">' . $lang['ERROR_BUILD'] . '</b><br /><br />' . $tor_filelist;
|
||||
}
|
||||
|
||||
$this->response['html'] = $tor_filelist;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
$domain_name = 'torrentpier.me'; // enter here your primary domain name of your site
|
||||
$domain_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : $domain_name;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
// Ratio limits
|
||||
define('TR_RATING_LIMITS', true); // ON/OFF
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
//
|
||||
// $Id: sphinxapi.php 2055 2009-11-06 23:09:58Z shodan $
|
||||
|
@ -128,13 +130,15 @@ function sphPackI64($v)
|
|||
}
|
||||
|
||||
// x32, int
|
||||
if (is_int($v))
|
||||
if (is_int($v)) {
|
||||
return pack("NN", $v < 0 ? -1 : 0, $v);
|
||||
}
|
||||
|
||||
// x32, bcmath
|
||||
if (function_exists("bcmul")) {
|
||||
if (bccomp($v, 0) == -1)
|
||||
if (bccomp($v, 0) == -1) {
|
||||
$v = bcadd("18446744073709551616", $v);
|
||||
}
|
||||
$h = bcdiv($v, "4294967296", 0);
|
||||
$l = bcmod($v, "4294967296");
|
||||
return pack("NN", (float)$h, (float)$l); // conversion to float is intentional; int would lose 31st bit
|
||||
|
@ -151,9 +155,9 @@ function sphPackI64($v)
|
|||
$h = $hi * 2328.0 + $q; // (10 ^ 13) / (1 << 32) = 2328
|
||||
|
||||
if ($v < 0) {
|
||||
if ($l == 0)
|
||||
if ($l == 0) {
|
||||
$h = 4294967296.0 - $h;
|
||||
else {
|
||||
} else {
|
||||
$h = 4294967295.0 - $h;
|
||||
$l = 4294967296.0 - $l;
|
||||
}
|
||||
|
@ -171,8 +175,9 @@ function sphPackU64($v)
|
|||
assert($v >= 0);
|
||||
|
||||
// x64, int
|
||||
if (is_int($v))
|
||||
if (is_int($v)) {
|
||||
return pack("NN", $v >> 32, $v & 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
// x64, bcmath
|
||||
if (function_exists("bcmul")) {
|
||||
|
@ -194,8 +199,9 @@ function sphPackU64($v)
|
|||
}
|
||||
|
||||
// x32, int
|
||||
if (is_int($v))
|
||||
if (is_int($v)) {
|
||||
return pack("NN", 0, $v);
|
||||
}
|
||||
|
||||
// x32, bcmath
|
||||
if (function_exists("bcmul")) {
|
||||
|
@ -223,16 +229,22 @@ function sphUnpackU64($v)
|
|||
list($hi, $lo) = array_values(unpack("N*N*", $v));
|
||||
|
||||
if (PHP_INT_SIZE >= 8) {
|
||||
if ($hi < 0) $hi += (1 << 32); // because php 5.2.2 to 5.2.5 is totally fucked up again
|
||||
if ($lo < 0) $lo += (1 << 32);
|
||||
if ($hi < 0) {
|
||||
$hi += (1 << 32);
|
||||
} // because php 5.2.2 to 5.2.5 is totally fucked up again
|
||||
if ($lo < 0) {
|
||||
$lo += (1 << 32);
|
||||
}
|
||||
|
||||
// x64, int
|
||||
if ($hi <= 2147483647)
|
||||
if ($hi <= 2147483647) {
|
||||
return ($hi << 32) + $lo;
|
||||
}
|
||||
|
||||
// x64, bcmath
|
||||
if (function_exists("bcmul"))
|
||||
if (function_exists("bcmul")) {
|
||||
return bcadd($lo, bcmul($hi, "4294967296"));
|
||||
}
|
||||
|
||||
// x64, no-bcmath
|
||||
$C = 100000;
|
||||
|
@ -243,15 +255,17 @@ function sphUnpackU64($v)
|
|||
$l = $l % $C;
|
||||
}
|
||||
|
||||
if ($h == 0)
|
||||
if ($h == 0) {
|
||||
return $l;
|
||||
}
|
||||
return sprintf("%d%05d", $h, $l);
|
||||
}
|
||||
|
||||
// x32, int
|
||||
if ($hi == 0) {
|
||||
if ($lo > 0)
|
||||
if ($lo > 0) {
|
||||
return $lo;
|
||||
}
|
||||
return sprintf("%u", $lo);
|
||||
}
|
||||
|
||||
|
@ -259,8 +273,9 @@ function sphUnpackU64($v)
|
|||
$lo = sprintf("%u", $lo);
|
||||
|
||||
// x32, bcmath
|
||||
if (function_exists("bcmul"))
|
||||
if (function_exists("bcmul")) {
|
||||
return bcadd($lo, bcmul($hi, "4294967296"));
|
||||
}
|
||||
|
||||
// x32, no-bcmath
|
||||
$hi = (float)$hi;
|
||||
|
@ -275,8 +290,9 @@ function sphUnpackU64($v)
|
|||
|
||||
$h = sprintf("%.0f", $h);
|
||||
$l = sprintf("%07.0f", $l);
|
||||
if ($h == "0")
|
||||
if ($h == "0") {
|
||||
return sprintf("%.0f", (float)$l);
|
||||
}
|
||||
return $h . $l;
|
||||
}
|
||||
|
||||
|
@ -287,21 +303,27 @@ function sphUnpackI64($v)
|
|||
|
||||
// x64
|
||||
if (PHP_INT_SIZE >= 8) {
|
||||
if ($hi < 0) $hi += (1 << 32); // because php 5.2.2 to 5.2.5 is totally fucked up again
|
||||
if ($lo < 0) $lo += (1 << 32);
|
||||
if ($hi < 0) {
|
||||
$hi += (1 << 32);
|
||||
} // because php 5.2.2 to 5.2.5 is totally fucked up again
|
||||
if ($lo < 0) {
|
||||
$lo += (1 << 32);
|
||||
}
|
||||
|
||||
return ($hi << 32) + $lo;
|
||||
}
|
||||
|
||||
// x32, int
|
||||
if ($hi == 0) {
|
||||
if ($lo > 0)
|
||||
if ($lo > 0) {
|
||||
return $lo;
|
||||
}
|
||||
return sprintf("%u", $lo);
|
||||
} // x32, int
|
||||
elseif ($hi == -1) {
|
||||
if ($lo < 0)
|
||||
if ($lo < 0) {
|
||||
return $lo;
|
||||
}
|
||||
return sprintf("%.0f", $lo - 4294967296.0);
|
||||
}
|
||||
|
||||
|
@ -318,8 +340,9 @@ function sphUnpackI64($v)
|
|||
$lo = sprintf("%u", $lo);
|
||||
|
||||
// x32, bcmath
|
||||
if (function_exists("bcmul"))
|
||||
if (function_exists("bcmul")) {
|
||||
return $neg . bcadd(bcadd($lo, bcmul($hi, "4294967296")), $c);
|
||||
}
|
||||
|
||||
// x32, no-bcmath
|
||||
$hi = (float)$hi;
|
||||
|
@ -338,8 +361,9 @@ function sphUnpackI64($v)
|
|||
|
||||
$h = sprintf("%.0f", $h);
|
||||
$l = sprintf("%07.0f", $l);
|
||||
if ($h == "0")
|
||||
if ($h == "0") {
|
||||
return $neg . sprintf("%.0f", (float)$l);
|
||||
}
|
||||
return $neg . $h . $l;
|
||||
}
|
||||
|
||||
|
@ -348,7 +372,9 @@ function sphFixUint($value)
|
|||
{
|
||||
if (PHP_INT_SIZE >= 8) {
|
||||
// x64 route, workaround broken unpack() in 5.2.2+
|
||||
if ($value < 0) $value += (1 << 32);
|
||||
if ($value < 0) {
|
||||
$value += (1 << 32);
|
||||
}
|
||||
return $value;
|
||||
} else {
|
||||
// x32 route, workaround php signed/unsigned braindamage
|
||||
|
@ -360,51 +386,51 @@ function sphFixUint($value)
|
|||
/// sphinx searchd client class
|
||||
class SphinxClient extends cache_common
|
||||
{
|
||||
var $_host; ///< searchd host (default is "localhost")
|
||||
var $_port; ///< searchd port (default is 9312)
|
||||
var $_offset; ///< how many records to seek from result-set start (default is 0)
|
||||
var $_limit; ///< how many records to return from result-set starting at offset (default is 20)
|
||||
var $_mode; ///< query matching mode (default is SPH_MATCH_ALL)
|
||||
var $_weights; ///< per-field weights (default is 1 for all fields)
|
||||
var $_sort; ///< match sorting mode (default is SPH_SORT_RELEVANCE)
|
||||
var $_sortby; ///< attribute to sort by (defualt is "")
|
||||
var $_min_id; ///< min ID to match (default is 0, which means no limit)
|
||||
var $_max_id; ///< max ID to match (default is 0, which means no limit)
|
||||
var $_filters; ///< search filters
|
||||
var $_groupby; ///< group-by attribute name
|
||||
var $_groupfunc; ///< group-by function (to pre-process group-by attribute value with)
|
||||
var $_groupsort; ///< group-by sorting clause (to sort groups in result set with)
|
||||
var $_groupdistinct;///< group-by count-distinct attribute
|
||||
var $_maxmatches; ///< max matches to retrieve
|
||||
var $_cutoff; ///< cutoff to stop searching at (default is 0)
|
||||
var $_retrycount; ///< distributed retries count
|
||||
var $_retrydelay; ///< distributed retries delay
|
||||
var $_anchor; ///< geographical anchor point
|
||||
var $_indexweights; ///< per-index weights
|
||||
var $_ranker; ///< ranking mode (default is SPH_RANK_PROXIMITY_BM25)
|
||||
var $_maxquerytime; ///< max query time, milliseconds (default is 0, do not limit)
|
||||
var $_fieldweights; ///< per-field-name weights
|
||||
var $_overrides; ///< per-query attribute values overrides
|
||||
var $_select; ///< select-list (attributes or expressions, with optional aliases)
|
||||
public $_host; ///< searchd host (default is "localhost")
|
||||
public $_port; ///< searchd port (default is 9312)
|
||||
public $_offset; ///< how many records to seek from result-set start (default is 0)
|
||||
public $_limit; ///< how many records to return from result-set starting at offset (default is 20)
|
||||
public $_mode; ///< query matching mode (default is SPH_MATCH_ALL)
|
||||
public $_weights; ///< per-field weights (default is 1 for all fields)
|
||||
public $_sort; ///< match sorting mode (default is SPH_SORT_RELEVANCE)
|
||||
public $_sortby; ///< attribute to sort by (defualt is "")
|
||||
public $_min_id; ///< min ID to match (default is 0, which means no limit)
|
||||
public $_max_id; ///< max ID to match (default is 0, which means no limit)
|
||||
public $_filters; ///< search filters
|
||||
public $_groupby; ///< group-by attribute name
|
||||
public $_groupfunc; ///< group-by function (to pre-process group-by attribute value with)
|
||||
public $_groupsort; ///< group-by sorting clause (to sort groups in result set with)
|
||||
public $_groupdistinct;///< group-by count-distinct attribute
|
||||
public $_maxmatches; ///< max matches to retrieve
|
||||
public $_cutoff; ///< cutoff to stop searching at (default is 0)
|
||||
public $_retrycount; ///< distributed retries count
|
||||
public $_retrydelay; ///< distributed retries delay
|
||||
public $_anchor; ///< geographical anchor point
|
||||
public $_indexweights; ///< per-index weights
|
||||
public $_ranker; ///< ranking mode (default is SPH_RANK_PROXIMITY_BM25)
|
||||
public $_maxquerytime; ///< max query time, milliseconds (default is 0, do not limit)
|
||||
public $_fieldweights; ///< per-field-name weights
|
||||
public $_overrides; ///< per-query attribute values overrides
|
||||
public $_select; ///< select-list (attributes or expressions, with optional aliases)
|
||||
|
||||
var $_error; ///< last error message
|
||||
var $_warning; ///< last warning message
|
||||
var $_connerror; ///< connection error vs remote error flag
|
||||
public $_error; ///< last error message
|
||||
public $_warning; ///< last warning message
|
||||
public $_connerror; ///< connection error vs remote error flag
|
||||
|
||||
var $_reqs; ///< requests array for multi-query
|
||||
var $_mbenc; ///< stored mbstring encoding
|
||||
var $_arrayresult; ///< whether $result["matches"] should be a hash or an array
|
||||
var $_timeout; ///< connect timeout
|
||||
public $_reqs; ///< requests array for multi-query
|
||||
public $_mbenc; ///< stored mbstring encoding
|
||||
public $_arrayresult; ///< whether $result["matches"] should be a hash or an array
|
||||
public $_timeout; ///< connect timeout
|
||||
|
||||
var $bb_queries = array();
|
||||
var $bb_indexes = array();
|
||||
public $bb_queries = array();
|
||||
public $bb_indexes = array();
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// common stuff
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// create a new client object and fill defaults
|
||||
function SphinxClient()
|
||||
public function SphinxClient()
|
||||
{
|
||||
$this->dbg_enabled = sql_dbg_enabled();
|
||||
|
||||
|
@ -450,32 +476,33 @@ class SphinxClient extends cache_common
|
|||
$this->_timeout = 0;
|
||||
}
|
||||
|
||||
function __destruct()
|
||||
public function __destruct()
|
||||
{
|
||||
if ($this->_socket !== false)
|
||||
if ($this->_socket !== false) {
|
||||
fclose($this->_socket);
|
||||
}
|
||||
}
|
||||
|
||||
/// get last error message (string)
|
||||
function GetLastError()
|
||||
public function GetLastError()
|
||||
{
|
||||
return $this->_error;
|
||||
}
|
||||
|
||||
/// get last warning message (string)
|
||||
function GetLastWarning()
|
||||
public function GetLastWarning()
|
||||
{
|
||||
return $this->_warning;
|
||||
}
|
||||
|
||||
/// get last error flag (to tell network connection errors from searchd errors or broken responses)
|
||||
function IsConnectError()
|
||||
public function IsConnectError()
|
||||
{
|
||||
return $this->_connerror;
|
||||
}
|
||||
|
||||
/// set searchd host name (string) and port (integer)
|
||||
function SetServer($host, $port = 0)
|
||||
public function SetServer($host, $port = 0)
|
||||
{
|
||||
assert(is_string($host));
|
||||
if ($host[0] == '/') {
|
||||
|
@ -491,18 +518,17 @@ class SphinxClient extends cache_common
|
|||
$this->_host = $host;
|
||||
$this->_port = $port;
|
||||
$this->_path = '';
|
||||
|
||||
}
|
||||
|
||||
/// set server connection timeout (0 to remove)
|
||||
function SetConnectTimeout($timeout)
|
||||
public function SetConnectTimeout($timeout)
|
||||
{
|
||||
assert(is_numeric($timeout));
|
||||
$this->_timeout = $timeout;
|
||||
}
|
||||
|
||||
|
||||
function _Send($handle, $data, $length)
|
||||
public function _Send($handle, $data, $length)
|
||||
{
|
||||
if (feof($handle) || fwrite($handle, $data, $length) !== $length) {
|
||||
$this->_error = 'connection unexpectedly closed (timed out?)';
|
||||
|
@ -515,7 +541,7 @@ class SphinxClient extends cache_common
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// enter mbstring workaround mode
|
||||
function _MBPush()
|
||||
public function _MBPush()
|
||||
{
|
||||
$this->_mbenc = "";
|
||||
if (ini_get("mbstring.func_overload") & 2) {
|
||||
|
@ -525,14 +551,15 @@ class SphinxClient extends cache_common
|
|||
}
|
||||
|
||||
/// leave mbstring workaround mode
|
||||
function _MBPop()
|
||||
public function _MBPop()
|
||||
{
|
||||
if ($this->_mbenc)
|
||||
if ($this->_mbenc) {
|
||||
mb_internal_encoding($this->_mbenc);
|
||||
}
|
||||
}
|
||||
|
||||
/// connect to searchd server
|
||||
function _Connect()
|
||||
public function _Connect()
|
||||
{
|
||||
$this->cur_query = "connect to: {$this->_host}";
|
||||
$this->debug('start');
|
||||
|
@ -540,8 +567,9 @@ class SphinxClient extends cache_common
|
|||
if ($this->_socket !== false) {
|
||||
// we are in persistent connection mode, so we have a socket
|
||||
// however, need to check whether it's still alive
|
||||
if (!feof($this->_socket))
|
||||
if (!feof($this->_socket)) {
|
||||
return $this->_socket;
|
||||
}
|
||||
|
||||
// force reopen
|
||||
$this->_socket = false;
|
||||
|
@ -559,16 +587,18 @@ class SphinxClient extends cache_common
|
|||
$port = $this->_port;
|
||||
}
|
||||
|
||||
if ($this->_timeout <= 0)
|
||||
if ($this->_timeout <= 0) {
|
||||
$fp = fsockopen($host, $port, $errno, $errstr);
|
||||
else
|
||||
} else {
|
||||
$fp = fsockopen($host, $port, $errno, $errstr, $this->_timeout);
|
||||
}
|
||||
|
||||
if (!$fp) {
|
||||
if ($this->_path)
|
||||
if ($this->_path) {
|
||||
$location = $this->_path;
|
||||
else
|
||||
} else {
|
||||
$location = "{$this->_host}:{$this->_port}";
|
||||
}
|
||||
|
||||
$errstr = trim($errstr);
|
||||
$this->_error = "connection to $location failed (errno=$errno, msg=$errstr)";
|
||||
|
@ -600,7 +630,7 @@ class SphinxClient extends cache_common
|
|||
}
|
||||
|
||||
/// get and check response packet from searchd server
|
||||
function _GetResponse($fp, $client_ver)
|
||||
public function _GetResponse($fp, $client_ver)
|
||||
{
|
||||
$response = "";
|
||||
$len = 0;
|
||||
|
@ -617,8 +647,9 @@ class SphinxClient extends cache_common
|
|||
}
|
||||
}
|
||||
}
|
||||
if ($this->_socket === false)
|
||||
if ($this->_socket === false) {
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
// check response
|
||||
$read = strlen($response);
|
||||
|
@ -663,7 +694,7 @@ class SphinxClient extends cache_common
|
|||
|
||||
/// set offset and count into result set,
|
||||
/// and optionally set max-matches and cutoff limits
|
||||
function SetLimits($offset, $limit, $max = 0, $cutoff = 0)
|
||||
public function SetLimits($offset, $limit, $max = 0, $cutoff = 0)
|
||||
{
|
||||
assert(is_int($offset));
|
||||
assert(is_int($limit));
|
||||
|
@ -672,15 +703,17 @@ class SphinxClient extends cache_common
|
|||
assert($max >= 0);
|
||||
$this->_offset = $offset;
|
||||
$this->_limit = $limit;
|
||||
if ($max > 0)
|
||||
if ($max > 0) {
|
||||
$this->_maxmatches = $max;
|
||||
if ($cutoff > 0)
|
||||
}
|
||||
if ($cutoff > 0) {
|
||||
$this->_cutoff = $cutoff;
|
||||
}
|
||||
}
|
||||
|
||||
/// set maximum query time, in milliseconds, per-index
|
||||
/// integer, 0 means "do not limit"
|
||||
function SetMaxQueryTime($max)
|
||||
public function SetMaxQueryTime($max)
|
||||
{
|
||||
assert(is_int($max));
|
||||
assert($max >= 0);
|
||||
|
@ -688,7 +721,7 @@ class SphinxClient extends cache_common
|
|||
}
|
||||
|
||||
/// set matching mode
|
||||
function SetMatchMode($mode)
|
||||
public function SetMatchMode($mode)
|
||||
{
|
||||
assert($mode == SPH_MATCH_ALL
|
||||
|| $mode == SPH_MATCH_ANY
|
||||
|
@ -701,7 +734,7 @@ class SphinxClient extends cache_common
|
|||
}
|
||||
|
||||
/// set ranking mode
|
||||
function SetRankingMode($ranker)
|
||||
public function SetRankingMode($ranker)
|
||||
{
|
||||
assert($ranker == SPH_RANK_PROXIMITY_BM25
|
||||
|| $ranker == SPH_RANK_BM25
|
||||
|
@ -712,7 +745,7 @@ class SphinxClient extends cache_common
|
|||
}
|
||||
|
||||
/// set matches sorting mode
|
||||
function SetSortMode($mode, $sortby = "")
|
||||
public function SetSortMode($mode, $sortby = "")
|
||||
{
|
||||
assert(
|
||||
$mode == SPH_SORT_RELEVANCE ||
|
||||
|
@ -730,17 +763,18 @@ class SphinxClient extends cache_common
|
|||
|
||||
/// bind per-field weights by order
|
||||
/// DEPRECATED; use SetFieldWeights() instead
|
||||
function SetWeights($weights)
|
||||
public function SetWeights($weights)
|
||||
{
|
||||
assert(is_array($weights));
|
||||
foreach ($weights as $weight)
|
||||
foreach ($weights as $weight) {
|
||||
assert(is_int($weight));
|
||||
}
|
||||
|
||||
$this->_weights = $weights;
|
||||
}
|
||||
|
||||
/// bind per-field weights by name
|
||||
function SetFieldWeights($weights)
|
||||
public function SetFieldWeights($weights)
|
||||
{
|
||||
assert(is_array($weights));
|
||||
foreach ($weights as $name => $weight) {
|
||||
|
@ -751,7 +785,7 @@ class SphinxClient extends cache_common
|
|||
}
|
||||
|
||||
/// bind per-index weights by name
|
||||
function SetIndexWeights($weights)
|
||||
public function SetIndexWeights($weights)
|
||||
{
|
||||
assert(is_array($weights));
|
||||
foreach ($weights as $index => $weight) {
|
||||
|
@ -763,7 +797,7 @@ class SphinxClient extends cache_common
|
|||
|
||||
/// set IDs range to match
|
||||
/// only match records if document ID is beetwen $min and $max (inclusive)
|
||||
function SetIDRange($min, $max)
|
||||
public function SetIDRange($min, $max)
|
||||
{
|
||||
assert(is_numeric($min));
|
||||
assert(is_numeric($max));
|
||||
|
@ -774,15 +808,16 @@ class SphinxClient extends cache_common
|
|||
|
||||
/// set values set filter
|
||||
/// only match records where $attribute value is in given set
|
||||
function SetFilter($attribute, $values, $exclude = false)
|
||||
public function SetFilter($attribute, $values, $exclude = false)
|
||||
{
|
||||
assert(is_string($attribute));
|
||||
assert(is_array($values));
|
||||
assert(count($values));
|
||||
|
||||
if (is_array($values) && count($values)) {
|
||||
foreach ($values as $value)
|
||||
foreach ($values as $value) {
|
||||
assert(is_numeric($value));
|
||||
}
|
||||
|
||||
$this->_filters[] = array("type" => SPH_FILTER_VALUES, "attr" => $attribute, "exclude" => $exclude, "values" => $values);
|
||||
}
|
||||
|
@ -790,7 +825,7 @@ class SphinxClient extends cache_common
|
|||
|
||||
/// set range filter
|
||||
/// only match records if $attribute value is beetwen $min and $max (inclusive)
|
||||
function SetFilterRange($attribute, $min, $max, $exclude = false)
|
||||
public function SetFilterRange($attribute, $min, $max, $exclude = false)
|
||||
{
|
||||
assert(is_string($attribute));
|
||||
assert(is_numeric($min));
|
||||
|
@ -802,7 +837,7 @@ class SphinxClient extends cache_common
|
|||
|
||||
/// set float range filter
|
||||
/// only match records if $attribute value is beetwen $min and $max (inclusive)
|
||||
function SetFilterFloatRange($attribute, $min, $max, $exclude = false)
|
||||
public function SetFilterFloatRange($attribute, $min, $max, $exclude = false)
|
||||
{
|
||||
assert(is_string($attribute));
|
||||
assert(is_float($min));
|
||||
|
@ -815,7 +850,7 @@ class SphinxClient extends cache_common
|
|||
/// setup anchor point for geosphere distance calculations
|
||||
/// required to use @geodist in filters and sorting
|
||||
/// latitude and longitude must be in radians
|
||||
function SetGeoAnchor($attrlat, $attrlong, $lat, $long)
|
||||
public function SetGeoAnchor($attrlat, $attrlong, $lat, $long)
|
||||
{
|
||||
assert(is_string($attrlat));
|
||||
assert(is_string($attrlong));
|
||||
|
@ -826,7 +861,7 @@ class SphinxClient extends cache_common
|
|||
}
|
||||
|
||||
/// set grouping attribute and function
|
||||
function SetGroupBy($attribute, $func, $groupsort = "@group desc")
|
||||
public function SetGroupBy($attribute, $func, $groupsort = "@group desc")
|
||||
{
|
||||
assert(is_string($attribute));
|
||||
assert(is_string($groupsort));
|
||||
|
@ -843,14 +878,14 @@ class SphinxClient extends cache_common
|
|||
}
|
||||
|
||||
/// set count-distinct attribute for group-by queries
|
||||
function SetGroupDistinct($attribute)
|
||||
public function SetGroupDistinct($attribute)
|
||||
{
|
||||
assert(is_string($attribute));
|
||||
$this->_groupdistinct = $attribute;
|
||||
}
|
||||
|
||||
/// set distributed retries count and delay
|
||||
function SetRetries($count, $delay = 0)
|
||||
public function SetRetries($count, $delay = 0)
|
||||
{
|
||||
assert(is_int($count) && $count >= 0);
|
||||
assert(is_int($delay) && $delay >= 0);
|
||||
|
@ -860,7 +895,7 @@ class SphinxClient extends cache_common
|
|||
|
||||
/// set result set format (hash or array; hash by default)
|
||||
/// PHP specific; needed for group-by-MVA result sets that may contain duplicate IDs
|
||||
function SetArrayResult($arrayresult)
|
||||
public function SetArrayResult($arrayresult)
|
||||
{
|
||||
assert(is_bool($arrayresult));
|
||||
$this->_arrayresult = $arrayresult;
|
||||
|
@ -869,7 +904,7 @@ class SphinxClient extends cache_common
|
|||
/// set attribute values override
|
||||
/// there can be only one override per attribute
|
||||
/// $values must be a hash that maps document IDs to attribute values
|
||||
function SetOverride($attrname, $attrtype, $values)
|
||||
public function SetOverride($attrname, $attrtype, $values)
|
||||
{
|
||||
assert(is_string($attrname));
|
||||
assert(in_array($attrtype, array(SPH_ATTR_INTEGER, SPH_ATTR_TIMESTAMP, SPH_ATTR_BOOL, SPH_ATTR_FLOAT, SPH_ATTR_BIGINT)));
|
||||
|
@ -879,7 +914,7 @@ class SphinxClient extends cache_common
|
|||
}
|
||||
|
||||
/// set select-list (attributes or expressions), SQL-like syntax
|
||||
function SetSelect($select)
|
||||
public function SetSelect($select)
|
||||
{
|
||||
assert(is_string($select));
|
||||
$this->_select = $select;
|
||||
|
@ -888,14 +923,14 @@ class SphinxClient extends cache_common
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// clear all filters (for multi-queries)
|
||||
function ResetFilters()
|
||||
public function ResetFilters()
|
||||
{
|
||||
$this->_filters = array();
|
||||
$this->_anchor = array();
|
||||
}
|
||||
|
||||
/// clear groupby settings (for multi-queries)
|
||||
function ResetGroupBy()
|
||||
public function ResetGroupBy()
|
||||
{
|
||||
$this->_groupby = "";
|
||||
$this->_groupfunc = SPH_GROUPBY_DAY;
|
||||
|
@ -904,7 +939,7 @@ class SphinxClient extends cache_common
|
|||
}
|
||||
|
||||
/// clear all attribute value overrides (for multi-queries)
|
||||
function ResetOverrides()
|
||||
public function ResetOverrides()
|
||||
{
|
||||
$this->_overrides = array();
|
||||
}
|
||||
|
@ -913,7 +948,7 @@ class SphinxClient extends cache_common
|
|||
|
||||
/// connect to searchd server, run given search query through given indexes,
|
||||
/// and return the search results
|
||||
function Query($query, $index = "*", $comment = "")
|
||||
public function Query($query, $index = "*", $comment = "")
|
||||
{
|
||||
assert(empty($this->_reqs));
|
||||
|
||||
|
@ -923,19 +958,21 @@ class SphinxClient extends cache_common
|
|||
$this->bb_queries = array();
|
||||
$this->bb_indexes = array();
|
||||
|
||||
if (!is_array($results))
|
||||
return false; // probably network error; error message should be already filled
|
||||
if (!is_array($results)) {
|
||||
return false;
|
||||
} // probably network error; error message should be already filled
|
||||
|
||||
$this->_error = $results[0]["error"];
|
||||
$this->_warning = $results[0]["warning"];
|
||||
if ($results[0]["status"] == SEARCHD_ERROR)
|
||||
if ($results[0]["status"] == SEARCHD_ERROR) {
|
||||
return false;
|
||||
else
|
||||
} else {
|
||||
return $results[0];
|
||||
}
|
||||
}
|
||||
|
||||
/// helper to pack floats in network byte order
|
||||
function _PackFloat($f)
|
||||
public function _PackFloat($f)
|
||||
{
|
||||
$t1 = pack("f", $f); // machine order
|
||||
list(, $t2) = unpack("L*", $t1); // int in machine order
|
||||
|
@ -944,7 +981,7 @@ class SphinxClient extends cache_common
|
|||
|
||||
/// add query to multi-query batch
|
||||
/// returns index into results array from RunQueries() call
|
||||
function AddQuery($query, $index = "*", $comment = "")
|
||||
public function AddQuery($query, $index = "*", $comment = "")
|
||||
{
|
||||
// mbstring workaround
|
||||
$this->_MBPush();
|
||||
|
@ -954,8 +991,9 @@ class SphinxClient extends cache_common
|
|||
$req .= pack("N", strlen($this->_sortby)) . $this->_sortby;
|
||||
$req .= pack("N", strlen($query)) . $query; // query itself
|
||||
$req .= pack("N", count($this->_weights)); // weights
|
||||
foreach ($this->_weights as $weight)
|
||||
foreach ($this->_weights as $weight) {
|
||||
$req .= pack("N", (int)$weight);
|
||||
}
|
||||
$req .= pack("N", strlen($index)) . $index; // indexes
|
||||
$req .= pack("N", 1); // id64 range marker
|
||||
$req .= sphPackU64($this->_min_id) . sphPackU64($this->_max_id); // id64 range
|
||||
|
@ -968,8 +1006,9 @@ class SphinxClient extends cache_common
|
|||
switch ($filter["type"]) {
|
||||
case SPH_FILTER_VALUES:
|
||||
$req .= pack("N", count($filter["values"]));
|
||||
foreach ($filter["values"] as $value)
|
||||
foreach ($filter["values"] as $value) {
|
||||
$req .= sphPackI64($value);
|
||||
}
|
||||
break;
|
||||
|
||||
case SPH_FILTER_RANGE:
|
||||
|
@ -1006,16 +1045,18 @@ class SphinxClient extends cache_common
|
|||
|
||||
// per-index weights
|
||||
$req .= pack("N", count($this->_indexweights));
|
||||
foreach ($this->_indexweights as $idx => $weight)
|
||||
foreach ($this->_indexweights as $idx => $weight) {
|
||||
$req .= pack("N", strlen($idx)) . $idx . pack("N", $weight);
|
||||
}
|
||||
|
||||
// max query time
|
||||
$req .= pack("N", $this->_maxquerytime);
|
||||
|
||||
// per-field weights
|
||||
$req .= pack("N", count($this->_fieldweights));
|
||||
foreach ($this->_fieldweights as $field => $weight)
|
||||
foreach ($this->_fieldweights as $field => $weight) {
|
||||
$req .= pack("N", strlen($field)) . $field . pack("N", $weight);
|
||||
}
|
||||
|
||||
// comment
|
||||
$req .= pack("N", strlen($comment)) . $comment;
|
||||
|
@ -1058,7 +1099,7 @@ class SphinxClient extends cache_common
|
|||
}
|
||||
|
||||
/// connect to searchd, run queries batch, and return an array of result sets
|
||||
function RunQueries()
|
||||
public function RunQueries()
|
||||
{
|
||||
if (empty($this->_reqs)) {
|
||||
$this->_error = "no queries defined, issue AddQuery() first";
|
||||
|
@ -1101,7 +1142,7 @@ class SphinxClient extends cache_common
|
|||
}
|
||||
|
||||
/// parse and return search query (or queries) response
|
||||
function _ParseSearchResponse($response, $nreqs)
|
||||
public function _ParseSearchResponse($response, $nreqs)
|
||||
{
|
||||
$p = 0; // current position
|
||||
$max = strlen($response); // max position for checks, to protect against broken responses
|
||||
|
@ -1189,10 +1230,11 @@ class SphinxClient extends cache_common
|
|||
$weight = sprintf("%u", $weight);
|
||||
|
||||
// create match entry
|
||||
if ($this->_arrayresult)
|
||||
if ($this->_arrayresult) {
|
||||
$result["matches"][$idx] = array("id" => $doc, "weight" => $weight);
|
||||
else
|
||||
} else {
|
||||
$result["matches"][$doc]["weight"] = $weight;
|
||||
}
|
||||
|
||||
// parse and create attributes
|
||||
$attrvals = array();
|
||||
|
@ -1229,11 +1271,12 @@ class SphinxClient extends cache_common
|
|||
}
|
||||
}
|
||||
|
||||
if ($this->_arrayresult)
|
||||
if ($this->_arrayresult) {
|
||||
$result["matches"][$idx]["attrs"] = $attrvals;
|
||||
else
|
||||
} else {
|
||||
$result["matches"][$doc]["attrs"] = $attrvals;
|
||||
}
|
||||
}
|
||||
|
||||
list($total, $total_found, $msecs, $words) =
|
||||
array_values(unpack("N*N*N*N*", substr($response, $p, 16)));
|
||||
|
@ -1268,7 +1311,7 @@ class SphinxClient extends cache_common
|
|||
/// connect to searchd server, and generate exceprts (snippets)
|
||||
/// of given documents for given query. returns false on failure,
|
||||
/// an array of snippets on success
|
||||
function BuildExcerpts($docs, $index, $words, $opts = array())
|
||||
public function BuildExcerpts($docs, $index, $words, $opts = array())
|
||||
{
|
||||
assert(is_array($docs));
|
||||
assert(is_string($index));
|
||||
|
@ -1286,15 +1329,33 @@ class SphinxClient extends cache_common
|
|||
// fixup options
|
||||
/////////////////
|
||||
|
||||
if (!isset($opts["before_match"])) $opts["before_match"] = "<b>";
|
||||
if (!isset($opts["after_match"])) $opts["after_match"] = "</b>";
|
||||
if (!isset($opts["chunk_separator"])) $opts["chunk_separator"] = " ... ";
|
||||
if (!isset($opts["limit"])) $opts["limit"] = 256;
|
||||
if (!isset($opts["around"])) $opts["around"] = 5;
|
||||
if (!isset($opts["exact_phrase"])) $opts["exact_phrase"] = false;
|
||||
if (!isset($opts["single_passage"])) $opts["single_passage"] = false;
|
||||
if (!isset($opts["use_boundaries"])) $opts["use_boundaries"] = false;
|
||||
if (!isset($opts["weight_order"])) $opts["weight_order"] = false;
|
||||
if (!isset($opts["before_match"])) {
|
||||
$opts["before_match"] = "<b>";
|
||||
}
|
||||
if (!isset($opts["after_match"])) {
|
||||
$opts["after_match"] = "</b>";
|
||||
}
|
||||
if (!isset($opts["chunk_separator"])) {
|
||||
$opts["chunk_separator"] = " ... ";
|
||||
}
|
||||
if (!isset($opts["limit"])) {
|
||||
$opts["limit"] = 256;
|
||||
}
|
||||
if (!isset($opts["around"])) {
|
||||
$opts["around"] = 5;
|
||||
}
|
||||
if (!isset($opts["exact_phrase"])) {
|
||||
$opts["exact_phrase"] = false;
|
||||
}
|
||||
if (!isset($opts["single_passage"])) {
|
||||
$opts["single_passage"] = false;
|
||||
}
|
||||
if (!isset($opts["use_boundaries"])) {
|
||||
$opts["use_boundaries"] = false;
|
||||
}
|
||||
if (!isset($opts["weight_order"])) {
|
||||
$opts["weight_order"] = false;
|
||||
}
|
||||
|
||||
/////////////////
|
||||
// build request
|
||||
|
@ -1302,10 +1363,18 @@ class SphinxClient extends cache_common
|
|||
|
||||
// v.1.0 req
|
||||
$flags = 1; // remove spaces
|
||||
if ($opts["exact_phrase"]) $flags |= 2;
|
||||
if ($opts["single_passage"]) $flags |= 4;
|
||||
if ($opts["use_boundaries"]) $flags |= 8;
|
||||
if ($opts["weight_order"]) $flags |= 16;
|
||||
if ($opts["exact_phrase"]) {
|
||||
$flags |= 2;
|
||||
}
|
||||
if ($opts["single_passage"]) {
|
||||
$flags |= 4;
|
||||
}
|
||||
if ($opts["use_boundaries"]) {
|
||||
$flags |= 8;
|
||||
}
|
||||
if ($opts["weight_order"]) {
|
||||
$flags |= 16;
|
||||
}
|
||||
$req = pack("NN", 0, $flags); // mode=0, flags=$flags
|
||||
$req .= pack("N", strlen($index)) . $index; // req index
|
||||
$req .= pack("N", strlen($words)) . $words; // req words
|
||||
|
@ -1369,7 +1438,7 @@ class SphinxClient extends cache_common
|
|||
/// connect to searchd server, and generate keyword list for a given query
|
||||
/// returns false on failure,
|
||||
/// an array of words on success
|
||||
function BuildKeywords($query, $index, $hits)
|
||||
public function BuildKeywords($query, $index, $hits)
|
||||
{
|
||||
assert(is_string($query));
|
||||
assert(is_string($index));
|
||||
|
@ -1444,7 +1513,7 @@ class SphinxClient extends cache_common
|
|||
return $res;
|
||||
}
|
||||
|
||||
function EscapeString($string)
|
||||
public function EscapeString($string)
|
||||
{
|
||||
$from = array('\\', '(', ')', '|', '-', '!', '@', '~', '"', '&', '/', '^', '$', '=');
|
||||
$to = array('\\\\', '\(', '\)', '\|', '\-', '\!', '\@', '\~', '\"', '\&', '\/', '\^', '\$', '\=');
|
||||
|
@ -1458,15 +1527,16 @@ class SphinxClient extends cache_common
|
|||
|
||||
/// batch update given attributes in given rows in given indexes
|
||||
/// returns amount of updated documents (0 or more) on success, or -1 on failure
|
||||
function UpdateAttributes($index, $attrs, $values, $mva = false)
|
||||
public function UpdateAttributes($index, $attrs, $values, $mva = false)
|
||||
{
|
||||
// verify everything
|
||||
assert(is_string($index));
|
||||
assert(is_bool($mva));
|
||||
|
||||
assert(is_array($attrs));
|
||||
foreach ($attrs as $attr)
|
||||
foreach ($attrs as $attr) {
|
||||
assert(is_string($attr));
|
||||
}
|
||||
|
||||
assert(is_array($values));
|
||||
foreach ($values as $id => $entry) {
|
||||
|
@ -1476,12 +1546,14 @@ class SphinxClient extends cache_common
|
|||
foreach ($entry as $v) {
|
||||
if ($mva) {
|
||||
assert(is_array($v));
|
||||
foreach ($v as $vv)
|
||||
foreach ($v as $vv) {
|
||||
assert(is_int($vv));
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
assert(is_int($v));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// build request
|
||||
$req = pack("N", strlen($index)) . $index;
|
||||
|
@ -1497,23 +1569,28 @@ class SphinxClient extends cache_common
|
|||
$req .= sphPackU64($id);
|
||||
foreach ($entry as $v) {
|
||||
$req .= pack("N", $mva ? count($v) : $v);
|
||||
if ($mva)
|
||||
foreach ($v as $vv)
|
||||
if ($mva) {
|
||||
foreach ($v as $vv) {
|
||||
$req .= pack("N", $vv);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// connect, send query, get response
|
||||
if (!($fp = $this->_Connect()))
|
||||
if (!($fp = $this->_Connect())) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
$len = strlen($req);
|
||||
$req = pack("nnN", SEARCHD_COMMAND_UPDATE, VER_COMMAND_UPDATE, $len) . $req; // add header
|
||||
if (!$this->_Send($fp, $req, $len + 8))
|
||||
if (!$this->_Send($fp, $req, $len + 8)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!($response = $this->_GetResponse($fp, VER_COMMAND_UPDATE)))
|
||||
if (!($response = $this->_GetResponse($fp, VER_COMMAND_UPDATE))) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// parse response
|
||||
list(, $updated) = unpack("N*", substr($response, 0, 4));
|
||||
|
@ -1524,25 +1601,27 @@ class SphinxClient extends cache_common
|
|||
// persistent connections
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function Open()
|
||||
public function Open()
|
||||
{
|
||||
if ($this->_socket !== false) {
|
||||
$this->_error = 'already connected';
|
||||
return false;
|
||||
}
|
||||
if (!$fp = $this->_Connect())
|
||||
if (!$fp = $this->_Connect()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// command, command version = 0, body length = 4, body = 1
|
||||
$req = pack("nnNN", SEARCHD_COMMAND_PERSIST, 0, 4, 1);
|
||||
if (!$this->_Send($fp, $req, 12))
|
||||
if (!$this->_Send($fp, $req, 12)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->_socket = $fp;
|
||||
return true;
|
||||
}
|
||||
|
||||
function Close()
|
||||
public function Close()
|
||||
{
|
||||
if ($this->_socket === false) {
|
||||
$this->_error = 'not connected';
|
||||
|
@ -1559,7 +1638,7 @@ class SphinxClient extends cache_common
|
|||
// status
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function Status()
|
||||
public function Status()
|
||||
{
|
||||
$this->_MBPush();
|
||||
if (!($fp = $this->_Connect())) {
|
||||
|
@ -1581,13 +1660,14 @@ class SphinxClient extends cache_common
|
|||
$p += 8;
|
||||
|
||||
$res = array();
|
||||
for ($i = 0; $i < $rows; $i++)
|
||||
for ($i = 0; $i < $rows; $i++) {
|
||||
for ($j = 0; $j < $cols; $j++) {
|
||||
list(, $len) = unpack("N*", substr($response, $p, 4));
|
||||
$p += 4;
|
||||
$res[$i][] = substr($response, $p, $len);
|
||||
$p += $len;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_MBPop();
|
||||
return $res;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
$datastore->enqueue(array(
|
||||
'smile_replacements',
|
||||
|
@ -220,7 +222,7 @@ function strip_quotes($text)
|
|||
$stack = array();
|
||||
$newtext = '[...] ';
|
||||
$substr_pos = 0;
|
||||
foreach ($pos_list AS $pos => $type) {
|
||||
foreach ($pos_list as $pos => $type) {
|
||||
$stacksize = sizeof($stack);
|
||||
if ($type == 'start') {
|
||||
// empty stack, so add from the last close tag or the beginning of the string
|
||||
|
@ -244,7 +246,7 @@ function strip_quotes($text)
|
|||
// as key points, and repeat. Allows emulation of a non-greedy-type
|
||||
// recursion.
|
||||
if ($stack) {
|
||||
foreach ($stack AS $pos) {
|
||||
foreach ($stack as $pos) {
|
||||
unset($pos_list["$pos"]);
|
||||
}
|
||||
}
|
||||
|
@ -349,7 +351,9 @@ function extract_search_words($text)
|
|||
// short & long words 2
|
||||
$text_out = array();
|
||||
foreach ($text as $word) {
|
||||
if (mb_strlen($word) > $min_word_len && mb_strlen($word) <= $max_word_len) $text_out[] = $word;
|
||||
if (mb_strlen($word) > $min_word_len && mb_strlen($word) <= $max_word_len) {
|
||||
$text_out[] = $word;
|
||||
}
|
||||
}
|
||||
$text = $text_out;
|
||||
|
||||
|
@ -399,11 +403,11 @@ function add_search_words($post_id, $post_message, $topic_title = '', $only_retu
|
|||
|
||||
class bbcode
|
||||
{
|
||||
var $tpl = array(); // шаблоны для замены тегов
|
||||
var $smilies = null; // смайлы
|
||||
var $found_spam = null; // найденные спам "слова"
|
||||
var $del_words = array(); // см. get_words_rate()
|
||||
var $tidy_cfg = array(
|
||||
public $tpl = array(); // шаблоны для замены тегов
|
||||
public $smilies = null; // смайлы
|
||||
public $found_spam = null; // найденные спам "слова"
|
||||
public $del_words = array(); // см. get_words_rate()
|
||||
public $tidy_cfg = array(
|
||||
'drop-empty-paras' => false,
|
||||
'fix-uri' => false,
|
||||
'force-output' => true,
|
||||
|
@ -421,7 +425,7 @@ class bbcode
|
|||
'show-warnings' => false,
|
||||
'wrap' => 0,
|
||||
);
|
||||
var $block_tags = array(
|
||||
public $block_tags = array(
|
||||
'align',
|
||||
'br',
|
||||
'clear',
|
||||
|
@ -431,17 +435,17 @@ class bbcode
|
|||
'quote',
|
||||
'spoiler',
|
||||
);
|
||||
var $preg = array();
|
||||
var $str = array();
|
||||
var $preg_search = array();
|
||||
var $preg_repl = array();
|
||||
var $str_search = array();
|
||||
var $str_repl = array();
|
||||
public $preg = array();
|
||||
public $str = array();
|
||||
public $preg_search = array();
|
||||
public $preg_repl = array();
|
||||
public $str_search = array();
|
||||
public $str_repl = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function bbcode()
|
||||
public function bbcode()
|
||||
{
|
||||
$this->tpl = get_bbcode_tpl();
|
||||
|
||||
|
@ -451,7 +455,7 @@ class bbcode
|
|||
/**
|
||||
* init_replacements
|
||||
*/
|
||||
function init_replacements()
|
||||
public function init_replacements()
|
||||
{
|
||||
$tpl = $this->tpl;
|
||||
$img_exp = '(https?:)?//[^\s\?&;=\#\"<>]+?\.(jpg|jpeg|gif|png)([a-z0-9/?&%;][^\[\]]*)?';
|
||||
|
@ -517,7 +521,7 @@ class bbcode
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
function bbcode2html($text)
|
||||
public function bbcode2html($text)
|
||||
{
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
@ -570,7 +574,7 @@ class bbcode
|
|||
*
|
||||
* @return mixed|string
|
||||
*/
|
||||
static function clean_up($text)
|
||||
public static function clean_up($text)
|
||||
{
|
||||
$text = trim($text);
|
||||
$text = str_replace("\r", '', $text);
|
||||
|
@ -646,7 +650,7 @@ class bbcode
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
function code_callback($m)
|
||||
public function code_callback($m)
|
||||
{
|
||||
$code = trim($m[2]);
|
||||
$code = str_replace(' ', ' ', $code);
|
||||
|
@ -663,7 +667,7 @@ class bbcode
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
function url_callback($m)
|
||||
public function url_callback($m)
|
||||
{
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
@ -671,7 +675,9 @@ class bbcode
|
|||
$url = trim($m[1]);
|
||||
$url_name = (isset($m[2])) ? trim($m[2]) : $url;
|
||||
|
||||
if (!preg_match("#^https?://#isu", $url) && !preg_match("/^#/", $url)) $url = 'http://' . $url;
|
||||
if (!preg_match("#^https?://#isu", $url) && !preg_match("/^#/", $url)) {
|
||||
$url = 'http://' . $url;
|
||||
}
|
||||
|
||||
if (in_array(parse_url($url, PHP_URL_HOST), $di->config->get('nofollow.allowed_url')) || $di->config->get('nofollow.disabled')) {
|
||||
$link = "<a href=\"$url\" class=\"postLink\">$url_name</a>";
|
||||
|
@ -689,7 +695,7 @@ class bbcode
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
function escape_tiltes_callback($m)
|
||||
public function escape_tiltes_callback($m)
|
||||
{
|
||||
$tilte = substr($m[3], 0, 250);
|
||||
$tilte = str_replace(array('[', ']', ':', ')', '"'), array('[', ']', ':', ')', '"'), $tilte);
|
||||
|
@ -705,7 +711,7 @@ class bbcode
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
function make_clickable($text)
|
||||
public function make_clickable($text)
|
||||
{
|
||||
$url_regexp = "#
|
||||
(?<![\"'=])
|
||||
|
@ -739,7 +745,7 @@ class bbcode
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
function make_url_clickable_callback($m)
|
||||
public function make_url_clickable_callback($m)
|
||||
{
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
@ -764,7 +770,7 @@ class bbcode
|
|||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function smilies_pass($text)
|
||||
public function smilies_pass($text)
|
||||
{
|
||||
global $datastore;
|
||||
|
||||
|
@ -786,7 +792,7 @@ class bbcode
|
|||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function new_line2html($text)
|
||||
public function new_line2html($text)
|
||||
{
|
||||
$text = preg_replace('#\n{2,}#', '<span class="post-br"><br /></span>', $text);
|
||||
$text = str_replace("\n", '<br />', $text);
|
||||
|
@ -800,7 +806,7 @@ class bbcode
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
function tidy($text)
|
||||
public function tidy($text)
|
||||
{
|
||||
$text = tidy_repair_string($text, $this->tidy_cfg, 'utf8');
|
||||
return $text;
|
||||
|
@ -825,14 +831,14 @@ function bbcode2html($text)
|
|||
|
||||
class words_rate
|
||||
{
|
||||
var $dbg_mode = false;
|
||||
var $words_rate = 0;
|
||||
var $deleted_words = array();
|
||||
var $del_text_hl = '';
|
||||
var $words_del_exp = '';
|
||||
var $words_cnt_exp = '#[a-zA-Zа-яА-ЯёЁ]{4,}#';
|
||||
public $dbg_mode = false;
|
||||
public $words_rate = 0;
|
||||
public $deleted_words = array();
|
||||
public $del_text_hl = '';
|
||||
public $words_del_exp = '';
|
||||
public $words_cnt_exp = '#[a-zA-Zа-яА-ЯёЁ]{4,}#';
|
||||
|
||||
function words_rate()
|
||||
public function words_rate()
|
||||
{
|
||||
// слова начинающиеся на..
|
||||
$del_list = file_get_contents(BB_ROOT . '/library/words_rate_del_list.txt');
|
||||
|
@ -850,7 +856,7 @@ class words_rate
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
function get_words_rate($text)
|
||||
public function get_words_rate($text)
|
||||
{
|
||||
$this->words_rate = 127; // максимальное значение по умолчанию
|
||||
$this->deleted_words = array();
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
class emailer
|
||||
{
|
||||
var $msg, $subject, $extra_headers;
|
||||
var $addresses, $reply_to, $from;
|
||||
var $use_smtp;
|
||||
public $msg, $subject, $extra_headers;
|
||||
public $addresses, $reply_to, $from;
|
||||
public $use_smtp;
|
||||
|
||||
var $tpl_msg = array();
|
||||
var $vars = array();
|
||||
public $tpl_msg = array();
|
||||
public $vars = array();
|
||||
|
||||
function emailer($use_smtp/*$tpl_name, $sbj, $to_address*/)
|
||||
public function emailer($use_smtp/*$tpl_name, $sbj, $to_address*/)
|
||||
{
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
@ -22,7 +24,7 @@ class emailer
|
|||
$this->use_smtp = $use_smtp;
|
||||
}
|
||||
|
||||
function set_default_vars()
|
||||
public function set_default_vars()
|
||||
{
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
@ -35,7 +37,7 @@ class emailer
|
|||
}
|
||||
|
||||
// Resets all the data (address, template file, etc etc to default
|
||||
function reset()
|
||||
public function reset()
|
||||
{
|
||||
$this->addresses = array();
|
||||
$this->msg = $this->extra_headers = '';
|
||||
|
@ -43,44 +45,44 @@ class emailer
|
|||
}
|
||||
|
||||
// Sets an email address to send to
|
||||
function email_address($address)
|
||||
public function email_address($address)
|
||||
{
|
||||
$this->addresses['to'] = trim($address);
|
||||
}
|
||||
|
||||
function cc($address)
|
||||
public function cc($address)
|
||||
{
|
||||
$this->addresses['cc'][] = trim($address);
|
||||
}
|
||||
|
||||
function bcc($address)
|
||||
public function bcc($address)
|
||||
{
|
||||
$this->addresses['bcc'][] = trim($address);
|
||||
}
|
||||
|
||||
function replyto($address)
|
||||
public function replyto($address)
|
||||
{
|
||||
$this->reply_to = trim($address);
|
||||
}
|
||||
|
||||
function from($address)
|
||||
public function from($address)
|
||||
{
|
||||
$this->from = trim($address);
|
||||
}
|
||||
|
||||
// set up subject for mail
|
||||
function set_subject($subject = '')
|
||||
public function set_subject($subject = '')
|
||||
{
|
||||
$this->subject = trim(preg_replace('#[\n\r]+#s', '', $subject));
|
||||
}
|
||||
|
||||
// set up extra mail headers
|
||||
function extra_headers($headers)
|
||||
public function extra_headers($headers)
|
||||
{
|
||||
$this->extra_headers .= trim($headers) . "\n";
|
||||
}
|
||||
|
||||
function use_template($template_file, $template_lang = '')
|
||||
public function use_template($template_file, $template_lang = '')
|
||||
{
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
@ -118,13 +120,13 @@ class emailer
|
|||
}
|
||||
|
||||
// assign variables
|
||||
function assign_vars($vars)
|
||||
public function assign_vars($vars)
|
||||
{
|
||||
$this->vars = array_merge($this->vars, $vars);
|
||||
}
|
||||
|
||||
// Send the mail out to the recipients set previously in var $this->address
|
||||
function send($email_format = 'text')
|
||||
public function send($email_format = 'text')
|
||||
{
|
||||
global $userdata;
|
||||
|
||||
|
@ -206,7 +208,7 @@ class emailer
|
|||
return true;
|
||||
}
|
||||
|
||||
function encode($str)
|
||||
public function encode($str)
|
||||
{
|
||||
if ($this->encoding == '') {
|
||||
return $str;
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
class sitemap
|
||||
{
|
||||
var $home = '';
|
||||
var $limit = 0;
|
||||
var $topic_priority = '0.5';
|
||||
var $stat_priority = '0.5';
|
||||
var $priority = '0.6';
|
||||
var $cat_priority = '0.7';
|
||||
public $home = '';
|
||||
public $limit = 0;
|
||||
public $topic_priority = '0.5';
|
||||
public $stat_priority = '0.5';
|
||||
public $priority = '0.6';
|
||||
public $cat_priority = '0.7';
|
||||
|
||||
function sitemap()
|
||||
public function sitemap()
|
||||
{
|
||||
$this->home = make_url();
|
||||
}
|
||||
|
||||
function build_map()
|
||||
public function build_map()
|
||||
{
|
||||
$map = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
|
||||
$map .= $this->get_static();
|
||||
|
@ -27,7 +29,7 @@ class sitemap
|
|||
return $map;
|
||||
}
|
||||
|
||||
function build_index($count)
|
||||
public function build_index($count)
|
||||
{
|
||||
$lm = date('c');
|
||||
$map = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
|
||||
|
@ -41,7 +43,7 @@ class sitemap
|
|||
return $map;
|
||||
}
|
||||
|
||||
function build_stat()
|
||||
public function build_stat()
|
||||
{
|
||||
$map = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
|
||||
$map .= $this->get_static();
|
||||
|
@ -51,7 +53,7 @@ class sitemap
|
|||
return $map;
|
||||
}
|
||||
|
||||
function build_map_topic($n)
|
||||
public function build_map_topic($n)
|
||||
{
|
||||
$map = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
|
||||
$map .= $this->get_topic($n);
|
||||
|
@ -60,7 +62,7 @@ class sitemap
|
|||
return $map;
|
||||
}
|
||||
|
||||
function get_forum()
|
||||
public function get_forum()
|
||||
{
|
||||
global $datastore;
|
||||
|
||||
|
@ -79,15 +81,18 @@ class sitemap
|
|||
$sql = DB()->sql_query("SELECT forum_id, forum_topics, forum_parent, forum_name FROM " . BB_FORUMS . " " . $ignore_forum_sql . " ORDER BY forum_id ASC");
|
||||
|
||||
while ($row = DB()->sql_fetchrow($sql)) {
|
||||
if (function_exists('seo_url')) $loc = $this->home . seo_url(FORUM_URL . $row['forum_id'], $row['forum_name']);
|
||||
else $loc = $this->home . FORUM_URL . $row['forum_id'];
|
||||
if (function_exists('seo_url')) {
|
||||
$loc = $this->home . seo_url(FORUM_URL . $row['forum_id'], $row['forum_name']);
|
||||
} else {
|
||||
$loc = $this->home . FORUM_URL . $row['forum_id'];
|
||||
}
|
||||
$xml .= $this->get_xml($loc, $lm);
|
||||
}
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
function get_topic($page = false)
|
||||
public function get_topic($page = false)
|
||||
{
|
||||
global $datastore;
|
||||
|
||||
|
@ -99,7 +104,9 @@ class sitemap
|
|||
$page = $page * 40000;
|
||||
$this->limit = " LIMIT {$page},40000";
|
||||
} else {
|
||||
if ($this->limit < 1) $this->limit = false;
|
||||
if ($this->limit < 1) {
|
||||
$this->limit = false;
|
||||
}
|
||||
if ($this->limit) {
|
||||
$this->limit = " LIMIT 0," . $this->limit;
|
||||
} else {
|
||||
|
@ -118,15 +125,18 @@ class sitemap
|
|||
$sql = DB()->sql_query("SELECT topic_id, topic_title, topic_time FROM " . BB_TOPICS . " " . $ignore_forum_sql . " ORDER BY topic_time ASC" . $this->limit);
|
||||
|
||||
while ($row = DB()->sql_fetchrow($sql)) {
|
||||
if (function_exists('seo_url')) $loc = $this->home . seo_url(TOPIC_URL . $row['topic_id'], $row['topic_title']);
|
||||
else $loc = $this->home . TOPIC_URL . $row['topic_id'];
|
||||
if (function_exists('seo_url')) {
|
||||
$loc = $this->home . seo_url(TOPIC_URL . $row['topic_id'], $row['topic_title']);
|
||||
} else {
|
||||
$loc = $this->home . TOPIC_URL . $row['topic_id'];
|
||||
}
|
||||
$xml .= $this->get_xml($loc, date('c', $row['topic_time']));
|
||||
}
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
function get_static()
|
||||
public function get_static()
|
||||
{
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
@ -151,7 +161,7 @@ class sitemap
|
|||
return $xml;
|
||||
}
|
||||
|
||||
function get_xml($loc, $lm)
|
||||
public function get_xml($loc, $lm)
|
||||
{
|
||||
$xml = "\t<url>\n";
|
||||
$xml .= "\t\t<loc>$loc</loc>\n";
|
||||
|
@ -162,7 +172,7 @@ class sitemap
|
|||
return $xml;
|
||||
}
|
||||
|
||||
function send_url($url, $map)
|
||||
public function send_url($url, $map)
|
||||
{
|
||||
$data = false;
|
||||
$file = $url . urlencode($map);
|
||||
|
@ -185,11 +195,13 @@ class sitemap
|
|||
}
|
||||
}
|
||||
|
||||
function create()
|
||||
public function create()
|
||||
{
|
||||
$row = DB()->fetch_row("SELECT COUNT(*) AS count FROM " . BB_TOPICS);
|
||||
|
||||
if (!$this->limit) $this->limit = $row['count'];
|
||||
if (!$this->limit) {
|
||||
$this->limit = $row['count'];
|
||||
}
|
||||
if ($this->limit > 40000) {
|
||||
$pages_count = ceil($row['count'] / 40000);
|
||||
|
||||
|
|
|
@ -1,20 +1,22 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
class DBS
|
||||
class dbs
|
||||
{
|
||||
var $cfg = array(); // $srv_name => $srv_cfg
|
||||
var $srv = array(); // $srv_name => $db_obj
|
||||
var $alias = array(); // $srv_alias => $srv_name
|
||||
public $cfg = array(); // $srv_name => $srv_cfg
|
||||
public $srv = array(); // $srv_name => $db_obj
|
||||
public $alias = array(); // $srv_alias => $srv_name
|
||||
|
||||
var $log_file = 'sql_queries';
|
||||
var $log_counter = 0;
|
||||
var $num_queries = 0;
|
||||
var $sql_inittime = 0;
|
||||
var $sql_timetotal = 0;
|
||||
public $log_file = 'sql_queries';
|
||||
public $log_counter = 0;
|
||||
public $num_queries = 0;
|
||||
public $sql_inittime = 0;
|
||||
public $sql_timetotal = 0;
|
||||
|
||||
function DBS($cfg)
|
||||
public function DBS($cfg)
|
||||
{
|
||||
$this->cfg = $cfg['db'];
|
||||
$this->alias = $cfg['db_alias'];
|
||||
|
@ -25,7 +27,7 @@ class DBS
|
|||
}
|
||||
|
||||
// получение/инициализация класса для сервера $srv_name
|
||||
function get_db_obj($srv_name_or_alias = 'db1')
|
||||
public function get_db_obj($srv_name_or_alias = 'db1')
|
||||
{
|
||||
$srv_name = $this->get_srv_name($srv_name_or_alias);
|
||||
|
||||
|
@ -37,7 +39,7 @@ class DBS
|
|||
}
|
||||
|
||||
// определение имени сервера
|
||||
function get_srv_name($name)
|
||||
public function get_srv_name($name)
|
||||
{
|
||||
if (isset($this->alias[$name])) {
|
||||
$srv_name = $this->alias[$name];
|
||||
|
|
|
@ -1,44 +1,46 @@
|
|||
<?php
|
||||
|
||||
if (!defined('SQL_DEBUG')) die(basename(__FILE__));
|
||||
if (!defined('SQL_DEBUG')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
class sql_db
|
||||
{
|
||||
var $cfg = array();
|
||||
var $cfg_keys = array('dbhost', 'dbname', 'dbuser', 'dbpasswd', 'charset', 'persist');
|
||||
var $link = null;
|
||||
var $result = null;
|
||||
var $db_server = '';
|
||||
var $selected_db = null;
|
||||
var $inited = false;
|
||||
public $cfg = array();
|
||||
public $cfg_keys = array('dbhost', 'dbname', 'dbuser', 'dbpasswd', 'charset', 'persist');
|
||||
public $link = null;
|
||||
public $result = null;
|
||||
public $db_server = '';
|
||||
public $selected_db = null;
|
||||
public $inited = false;
|
||||
|
||||
var $locked = false;
|
||||
var $locks = array();
|
||||
public $locked = false;
|
||||
public $locks = array();
|
||||
|
||||
var $num_queries = 0;
|
||||
var $sql_starttime = 0;
|
||||
var $sql_inittime = 0;
|
||||
var $sql_timetotal = 0;
|
||||
var $cur_query_time = 0;
|
||||
var $slow_time = 0;
|
||||
public $num_queries = 0;
|
||||
public $sql_starttime = 0;
|
||||
public $sql_inittime = 0;
|
||||
public $sql_timetotal = 0;
|
||||
public $cur_query_time = 0;
|
||||
public $slow_time = 0;
|
||||
|
||||
var $dbg = array();
|
||||
var $dbg_id = 0;
|
||||
var $dbg_enabled = false;
|
||||
var $cur_query = null;
|
||||
public $dbg = array();
|
||||
public $dbg_id = 0;
|
||||
public $dbg_enabled = false;
|
||||
public $cur_query = null;
|
||||
|
||||
var $do_explain = false;
|
||||
var $explain_hold = '';
|
||||
var $explain_out = '';
|
||||
public $do_explain = false;
|
||||
public $explain_hold = '';
|
||||
public $explain_out = '';
|
||||
|
||||
var $shutdown = array();
|
||||
public $shutdown = array();
|
||||
|
||||
var $DBS = array();
|
||||
public $DBS = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function sql_db($cfg_values)
|
||||
public function sql_db($cfg_values)
|
||||
{
|
||||
global $DBS;
|
||||
|
||||
|
@ -58,7 +60,7 @@ class sql_db
|
|||
/**
|
||||
* Initialize connection
|
||||
*/
|
||||
function init()
|
||||
public function init()
|
||||
{
|
||||
// Connect to server
|
||||
$this->link = $this->connect();
|
||||
|
@ -82,7 +84,7 @@ class sql_db
|
|||
/**
|
||||
* Open connection
|
||||
*/
|
||||
function connect()
|
||||
public function connect()
|
||||
{
|
||||
$this->cur_query = ($this->dbg_enabled) ? ($this->cfg['persist'] ? 'p' : '') . "connect to: {$this->cfg['dbhost']}" : 'connect';
|
||||
$this->debug('start');
|
||||
|
@ -107,7 +109,7 @@ class sql_db
|
|||
/**
|
||||
* Select database
|
||||
*/
|
||||
function select_db()
|
||||
public function select_db()
|
||||
{
|
||||
$this->cur_query = ($this->dbg_enabled) ? "select db: {$this->cfg['dbname']}" : 'select db';
|
||||
$this->debug('start');
|
||||
|
@ -126,7 +128,7 @@ class sql_db
|
|||
/**
|
||||
* Base query method
|
||||
*/
|
||||
function sql_query($query)
|
||||
public function sql_query($query)
|
||||
{
|
||||
if (!is_resource($this->link)) {
|
||||
$this->init();
|
||||
|
@ -158,7 +160,7 @@ class sql_db
|
|||
/**
|
||||
* Execute query WRAPPER (with error handling)
|
||||
*/
|
||||
function query($query)
|
||||
public function query($query)
|
||||
{
|
||||
if (!$result = $this->sql_query($query)) {
|
||||
$this->trigger_error();
|
||||
|
@ -170,11 +172,11 @@ class sql_db
|
|||
/**
|
||||
* Return number of rows
|
||||
*/
|
||||
function num_rows($result = false)
|
||||
public function num_rows($result = false)
|
||||
{
|
||||
$num_rows = false;
|
||||
|
||||
if ($result OR $result = $this->result) {
|
||||
if ($result or $result = $this->result) {
|
||||
$num_rows = is_resource($result) ? mysql_num_rows($result) : false;
|
||||
}
|
||||
|
||||
|
@ -184,7 +186,7 @@ class sql_db
|
|||
/**
|
||||
* Return number of affected rows
|
||||
*/
|
||||
function affected_rows()
|
||||
public function affected_rows()
|
||||
{
|
||||
return is_resource($this->link) ? mysql_affected_rows($this->link) : -1;
|
||||
}
|
||||
|
@ -192,7 +194,7 @@ class sql_db
|
|||
/**
|
||||
* Fetch current field
|
||||
*/
|
||||
function sql_fetchfield($field, $rownum = -1, $query_id = 0)
|
||||
public function sql_fetchfield($field, $rownum = -1, $query_id = 0)
|
||||
{
|
||||
if (!$query_id) {
|
||||
$query_id = $this->query_result;
|
||||
|
@ -222,7 +224,7 @@ class sql_db
|
|||
/**
|
||||
* Fetch current row
|
||||
*/
|
||||
function sql_fetchrow($result, $field_name = '')
|
||||
public function sql_fetchrow($result, $field_name = '')
|
||||
{
|
||||
$row = mysql_fetch_assoc($result);
|
||||
|
||||
|
@ -236,7 +238,7 @@ class sql_db
|
|||
/**
|
||||
* Alias of sql_fetchrow()
|
||||
*/
|
||||
function fetch_next($result)
|
||||
public function fetch_next($result)
|
||||
{
|
||||
return $this->sql_fetchrow($result);
|
||||
}
|
||||
|
@ -244,7 +246,7 @@ class sql_db
|
|||
/**
|
||||
* Fetch row WRAPPER (with error handling)
|
||||
*/
|
||||
function fetch_row($query, $field_name = '')
|
||||
public function fetch_row($query, $field_name = '')
|
||||
{
|
||||
if (!$result = $this->sql_query($query)) {
|
||||
$this->trigger_error();
|
||||
|
@ -256,7 +258,7 @@ class sql_db
|
|||
/**
|
||||
* Fetch all rows
|
||||
*/
|
||||
function sql_fetchrowset($result, $field_name = '')
|
||||
public function sql_fetchrowset($result, $field_name = '')
|
||||
{
|
||||
$rowset = array();
|
||||
|
||||
|
@ -270,7 +272,7 @@ class sql_db
|
|||
/**
|
||||
* Fetch all rows WRAPPER (with error handling)
|
||||
*/
|
||||
function fetch_rowset($query, $field_name = '')
|
||||
public function fetch_rowset($query, $field_name = '')
|
||||
{
|
||||
if (!$result = $this->sql_query($query)) {
|
||||
$this->trigger_error();
|
||||
|
@ -282,7 +284,7 @@ class sql_db
|
|||
/**
|
||||
* Fetch all rows WRAPPER (with error handling)
|
||||
*/
|
||||
function fetch_all($query, $field_name = '')
|
||||
public function fetch_all($query, $field_name = '')
|
||||
{
|
||||
if (!$result = $this->sql_query($query)) {
|
||||
$this->trigger_error();
|
||||
|
@ -294,7 +296,7 @@ class sql_db
|
|||
/**
|
||||
* Get last inserted id after insert statement
|
||||
*/
|
||||
function sql_nextid()
|
||||
public function sql_nextid()
|
||||
{
|
||||
return mysql_insert_id($this->link);
|
||||
}
|
||||
|
@ -302,9 +304,9 @@ class sql_db
|
|||
/**
|
||||
* Free sql result
|
||||
*/
|
||||
function sql_freeresult($result = false)
|
||||
public function sql_freeresult($result = false)
|
||||
{
|
||||
if ($result OR $result = $this->result) {
|
||||
if ($result or $result = $this->result) {
|
||||
$return_value = is_resource($result) ? mysql_free_result($result) : false;
|
||||
}
|
||||
|
||||
|
@ -314,10 +316,14 @@ class sql_db
|
|||
/**
|
||||
* Escape data used in sql query
|
||||
*/
|
||||
function escape($v, $check_type = false, $dont_escape = false)
|
||||
public function escape($v, $check_type = false, $dont_escape = false)
|
||||
{
|
||||
if ($dont_escape) return $v;
|
||||
if (!$check_type) return $this->escape_string($v);
|
||||
if ($dont_escape) {
|
||||
return $v;
|
||||
}
|
||||
if (!$check_type) {
|
||||
return $this->escape_string($v);
|
||||
}
|
||||
|
||||
switch (true) {
|
||||
case is_string($v):
|
||||
|
@ -338,7 +344,7 @@ class sql_db
|
|||
/**
|
||||
* Escape string
|
||||
*/
|
||||
function escape_string($str)
|
||||
public function escape_string($str)
|
||||
{
|
||||
if (!is_resource($this->link)) {
|
||||
$this->init();
|
||||
|
@ -352,7 +358,7 @@ class sql_db
|
|||
*
|
||||
* Possible $query_type values: INSERT, INSERT_SELECT, MULTI_INSERT, UPDATE, SELECT
|
||||
*/
|
||||
function build_array($query_type, $input_ary, $data_already_escaped = false, $check_data_type_in_escape = true)
|
||||
public function build_array($query_type, $input_ary, $data_already_escaped = false, $check_data_type_in_escape = true)
|
||||
{
|
||||
$fields = $values = $ary = $query = array();
|
||||
$dont_escape = $data_already_escaped;
|
||||
|
@ -404,7 +410,7 @@ class sql_db
|
|||
return "\n" . $query . "\n";
|
||||
}
|
||||
|
||||
function get_empty_sql_array()
|
||||
public function get_empty_sql_array()
|
||||
{
|
||||
return array(
|
||||
'SELECT' => array(),
|
||||
|
@ -420,7 +426,7 @@ class sql_db
|
|||
);
|
||||
}
|
||||
|
||||
function build_sql($sql_ary)
|
||||
public function build_sql($sql_ary)
|
||||
{
|
||||
$sql = '';
|
||||
array_deep($sql_ary, 'array_unique', false, true);
|
||||
|
@ -463,7 +469,7 @@ class sql_db
|
|||
/**
|
||||
* Return sql error array
|
||||
*/
|
||||
function sql_error()
|
||||
public function sql_error()
|
||||
{
|
||||
if (is_resource($this->link)) {
|
||||
return array('code' => mysql_errno($this->link), 'message' => mysql_error($this->link));
|
||||
|
@ -475,7 +481,7 @@ class sql_db
|
|||
/**
|
||||
* Close sql connection
|
||||
*/
|
||||
function close()
|
||||
public function close()
|
||||
{
|
||||
if (is_resource($this->link)) {
|
||||
$this->unlock();
|
||||
|
@ -497,7 +503,7 @@ class sql_db
|
|||
/**
|
||||
* Add shutdown query
|
||||
*/
|
||||
function add_shutdown_query($sql)
|
||||
public function add_shutdown_query($sql)
|
||||
{
|
||||
$this->shutdown['__sql'][] = $sql;
|
||||
}
|
||||
|
@ -505,9 +511,11 @@ class sql_db
|
|||
/**
|
||||
* Exec shutdown queries
|
||||
*/
|
||||
function exec_shutdown_queries()
|
||||
public function exec_shutdown_queries()
|
||||
{
|
||||
if (empty($this->shutdown)) return;
|
||||
if (empty($this->shutdown)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!empty($this->shutdown['post_html'])) {
|
||||
$post_html_sql = $this->build_array('MULTI_INSERT', $this->shutdown['post_html']);
|
||||
|
@ -524,7 +532,7 @@ class sql_db
|
|||
/**
|
||||
* Lock tables
|
||||
*/
|
||||
function lock($tables, $lock_type = 'WRITE')
|
||||
public function lock($tables, $lock_type = 'WRITE')
|
||||
{
|
||||
if ($this->cfg['persist']) {
|
||||
# return true;
|
||||
|
@ -545,7 +553,7 @@ class sql_db
|
|||
/**
|
||||
* Unlock tables
|
||||
*/
|
||||
function unlock()
|
||||
public function unlock()
|
||||
{
|
||||
if ($this->locked && $this->sql_query("UNLOCK TABLES")) {
|
||||
$this->locked = false;
|
||||
|
@ -557,7 +565,7 @@ class sql_db
|
|||
/**
|
||||
* Obtain user level lock
|
||||
*/
|
||||
function get_lock($name, $timeout = 0)
|
||||
public function get_lock($name, $timeout = 0)
|
||||
{
|
||||
$lock_name = $this->get_lock_name($name);
|
||||
$timeout = (int)$timeout;
|
||||
|
@ -573,7 +581,7 @@ class sql_db
|
|||
/**
|
||||
* Obtain user level lock status
|
||||
*/
|
||||
function release_lock($name)
|
||||
public function release_lock($name)
|
||||
{
|
||||
$lock_name = $this->get_lock_name($name);
|
||||
$row = $this->fetch_row("SELECT RELEASE_LOCK('$lock_name') AS lock_result");
|
||||
|
@ -588,7 +596,7 @@ class sql_db
|
|||
/**
|
||||
* Release user level lock
|
||||
*/
|
||||
function is_free_lock($name)
|
||||
public function is_free_lock($name)
|
||||
{
|
||||
$lock_name = $this->get_lock_name($name);
|
||||
$row = $this->fetch_row("SELECT IS_FREE_LOCK('$lock_name') AS lock_result");
|
||||
|
@ -598,7 +606,7 @@ class sql_db
|
|||
/**
|
||||
* Make per db unique lock name
|
||||
*/
|
||||
function get_lock_name($name)
|
||||
public function get_lock_name($name)
|
||||
{
|
||||
if (!$this->selected_db) {
|
||||
$this->init();
|
||||
|
@ -610,7 +618,7 @@ class sql_db
|
|||
/**
|
||||
* Get info about last query
|
||||
*/
|
||||
function query_info()
|
||||
public function query_info()
|
||||
{
|
||||
$info = array();
|
||||
|
||||
|
@ -618,9 +626,9 @@ class sql_db
|
|||
$info[] = "$num rows";
|
||||
}
|
||||
|
||||
if (is_resource($this->link) AND $ext = mysql_info($this->link)) {
|
||||
if (is_resource($this->link) and $ext = mysql_info($this->link)) {
|
||||
$info[] = "$ext";
|
||||
} else if (!$num && ($aff = $this->affected_rows($this->result) AND $aff != -1)) {
|
||||
} elseif (!$num && ($aff = $this->affected_rows($this->result) and $aff != -1)) {
|
||||
$info[] = "$aff rows";
|
||||
}
|
||||
|
||||
|
@ -630,7 +638,7 @@ class sql_db
|
|||
/**
|
||||
* Get server version
|
||||
*/
|
||||
function server_version()
|
||||
public function server_version()
|
||||
{
|
||||
preg_match('#^(\d+\.\d+\.\d+).*#', mysql_get_server_info(), $m);
|
||||
return $m[1];
|
||||
|
@ -640,7 +648,7 @@ class sql_db
|
|||
* Set slow query marker for xx seconds
|
||||
* This will disable counting other queries as "slow" during this time
|
||||
*/
|
||||
function expect_slow_query($ignoring_time = 60, $new_priority = 10)
|
||||
public function expect_slow_query($ignoring_time = 60, $new_priority = 10)
|
||||
{
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
@ -662,9 +670,11 @@ class sql_db
|
|||
/**
|
||||
* Store debug info
|
||||
*/
|
||||
function debug($mode)
|
||||
public function debug($mode)
|
||||
{
|
||||
if (!SQL_DEBUG) return;
|
||||
if (!SQL_DEBUG) {
|
||||
return;
|
||||
}
|
||||
|
||||
$id =& $this->dbg_id;
|
||||
$dbg =& $this->dbg[$id];
|
||||
|
@ -715,7 +725,7 @@ class sql_db
|
|||
/**
|
||||
* Trigger error
|
||||
*/
|
||||
function trigger_error($msg = 'DB Error')
|
||||
public function trigger_error($msg = 'DB Error')
|
||||
{
|
||||
if (error_reporting()) {
|
||||
if (DBG_LOG === true) {
|
||||
|
@ -732,7 +742,7 @@ class sql_db
|
|||
/**
|
||||
* Find caller source
|
||||
*/
|
||||
function debug_find_source($mode = '')
|
||||
public function debug_find_source($mode = '')
|
||||
{
|
||||
foreach (debug_backtrace() as $trace) {
|
||||
if (!empty($trace['file']) && $trace['file'] !== __FILE__) {
|
||||
|
@ -752,7 +762,7 @@ class sql_db
|
|||
/**
|
||||
* Prepare for logging
|
||||
*/
|
||||
function log_next_query($queries_count = 1, $log_file = 'sql_queries')
|
||||
public function log_next_query($queries_count = 1, $log_file = 'sql_queries')
|
||||
{
|
||||
$this->DBS['log_file'] = $log_file;
|
||||
$this->DBS['log_counter'] = $queries_count;
|
||||
|
@ -761,7 +771,7 @@ class sql_db
|
|||
/**
|
||||
* Log query
|
||||
*/
|
||||
function log_query($log_file = 'sql_queries')
|
||||
public function log_query($log_file = 'sql_queries')
|
||||
{
|
||||
$q_time = ($this->cur_query_time >= 10) ? round($this->cur_query_time, 0) : sprintf('%.4f', $this->cur_query_time);
|
||||
$msg = array();
|
||||
|
@ -782,7 +792,7 @@ class sql_db
|
|||
/**
|
||||
* Log slow query
|
||||
*/
|
||||
function log_slow_query($log_file = 'sql_slow_bb')
|
||||
public function log_slow_query($log_file = 'sql_slow_bb')
|
||||
{
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
@ -799,9 +809,11 @@ class sql_db
|
|||
/**
|
||||
* Log error
|
||||
*/
|
||||
function log_error()
|
||||
public function log_error()
|
||||
{
|
||||
if (!SQL_LOG_ERRORS) return;
|
||||
if (!SQL_LOG_ERRORS) {
|
||||
return;
|
||||
}
|
||||
|
||||
$msg = array();
|
||||
$err = $this->sql_error();
|
||||
|
@ -825,7 +837,7 @@ class sql_db
|
|||
/**
|
||||
* Explain queries (based on code from phpBB3)
|
||||
*/
|
||||
function explain($mode, $html_table = '', $row = '')
|
||||
public function explain($mode, $html_table = '', $row = '')
|
||||
{
|
||||
$query = str_compact($this->cur_query);
|
||||
// remove comments
|
||||
|
@ -855,7 +867,9 @@ class sql_db
|
|||
break;
|
||||
|
||||
case 'stop':
|
||||
if (!$this->explain_hold) break;
|
||||
if (!$this->explain_hold) {
|
||||
break;
|
||||
}
|
||||
|
||||
$id = $this->dbg_id - 1;
|
||||
$htid = 'expl-' . intval($this->link) . '-' . $id;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
bb_log(date('H:i:s - ') . getmypid() . ' --x- SELECT jobs' . LOG_LF, CRON_LOG_DIR . 'cron_check');
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
//
|
||||
// Functions
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
define('IN_CRON', true);
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
$search_results_expire = TIMENOW - 3 * 3600;
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
$datastore->update('cat_forums');
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
$datastore->update('stats');
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
// Lock tables
|
||||
DB()->lock(array(
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
require(CLASS_DIR . 'sitemap.php');
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
@ -30,7 +32,9 @@ if ($di->config->get('seed_bonus_enabled') && $di->config->get('seed_bonus_point
|
|||
$seed_release = unserialize($di->config->get('seed_bonus_release'));
|
||||
|
||||
foreach ($seed_bonus as $i => $points) {
|
||||
if (!$points || !$seed_release[$i]) continue;
|
||||
if (!$points || !$seed_release[$i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$user_points = ((float)$points / 4);
|
||||
$release = (int)$seed_release[$i];
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
DB()->query("
|
||||
UPDATE
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
@ -11,14 +13,18 @@ $timecheck = TIMENOW - 600;
|
|||
$forums_data = DB()->fetch_rowset("SELECT forum_id, allow_reg_tracker, forum_name FROM " . BB_FORUMS);
|
||||
|
||||
if (file_exists($di->config->get('atom.path') . '/f/0.atom')) {
|
||||
if (filemtime($di->config->get('atom.path') . '/f/0.atom') <= $timecheck) update_forum_feed(0, $forums_data);
|
||||
if (filemtime($di->config->get('atom.path') . '/f/0.atom') <= $timecheck) {
|
||||
update_forum_feed(0, $forums_data);
|
||||
}
|
||||
} else {
|
||||
update_forum_feed(0, $forums_data);
|
||||
}
|
||||
|
||||
foreach ($forums_data as $forum_data) {
|
||||
if (file_exists($di->config->get('atom.path') . '/f/' . $forum_data['forum_id'] . '.atom')) {
|
||||
if (filemtime($di->config->get('atom.path') . '/f/' . $forum_data['forum_id'] . '.atom') <= $timecheck) update_forum_feed($forum_data['forum_id'], $forum_data);
|
||||
if (filemtime($di->config->get('atom.path') . '/f/' . $forum_data['forum_id'] . '.atom') <= $timecheck) {
|
||||
update_forum_feed($forum_data['forum_id'], $forum_data);
|
||||
}
|
||||
} else {
|
||||
update_forum_feed($forum_data['forum_id'], $forum_data);
|
||||
}
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
class datastore_apc extends datastore_common
|
||||
{
|
||||
var $engine = 'APC';
|
||||
var $prefix = null;
|
||||
public $engine = 'APC';
|
||||
public $prefix = null;
|
||||
|
||||
function datastore_apc($prefix = null)
|
||||
public function datastore_apc($prefix = null)
|
||||
{
|
||||
if (!$this->is_installed()) {
|
||||
die('Error: APC extension not installed');
|
||||
|
@ -16,7 +18,7 @@ class datastore_apc extends datastore_common
|
|||
$this->prefix = $prefix;
|
||||
}
|
||||
|
||||
function store($title, $var)
|
||||
public function store($title, $var)
|
||||
{
|
||||
$this->data[$title] = $var;
|
||||
|
||||
|
@ -29,7 +31,7 @@ class datastore_apc extends datastore_common
|
|||
return (bool)apc_store($this->prefix . $title, $var);
|
||||
}
|
||||
|
||||
function clean()
|
||||
public function clean()
|
||||
{
|
||||
foreach ($this->known_items as $title => $script_name) {
|
||||
$this->cur_query = "cache->rm('$title')";
|
||||
|
@ -42,7 +44,7 @@ class datastore_apc extends datastore_common
|
|||
}
|
||||
}
|
||||
|
||||
function _fetch_from_store()
|
||||
public function _fetch_from_store()
|
||||
{
|
||||
if (!$items = $this->queued_items) {
|
||||
$src = $this->_debug_find_caller('enqueue');
|
||||
|
@ -60,7 +62,7 @@ class datastore_apc extends datastore_common
|
|||
}
|
||||
}
|
||||
|
||||
function is_installed()
|
||||
public function is_installed()
|
||||
{
|
||||
return function_exists('apc_fetch');
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $bf;
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'name_users' => array(), // only by personal permissions
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
$ranks = array();
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
|
|
@ -1,30 +1,32 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
class datastore_common
|
||||
{
|
||||
/**
|
||||
* Директория с builder-скриптами (внутри INC_DIR)
|
||||
*/
|
||||
var $ds_dir = 'datastore/';
|
||||
public $ds_dir = 'datastore/';
|
||||
/**
|
||||
* Готовая к употреблению data
|
||||
* array('title' => data)
|
||||
*/
|
||||
var $data = array();
|
||||
public $data = array();
|
||||
/**
|
||||
* Список элементов, которые будут извлечены из хранилища при первом же запросе get()
|
||||
* до этого момента они ставятся в очередь $queued_items для дальнейшего извлечения _fetch()'ем
|
||||
* всех элементов одним запросом
|
||||
* array('title1', 'title2'...)
|
||||
*/
|
||||
var $queued_items = array();
|
||||
public $queued_items = array();
|
||||
|
||||
/**
|
||||
* 'title' => 'builder script name' inside "includes/datastore" dir
|
||||
*/
|
||||
var $known_items = array(
|
||||
public $known_items = array(
|
||||
'cat_forums' => 'build_cat_forums.php',
|
||||
'jumpbox' => 'build_cat_forums.php',
|
||||
'viewtopic_forum_select' => 'build_cat_forums.php',
|
||||
|
@ -39,14 +41,14 @@ class datastore_common
|
|||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function datastore_common()
|
||||
public function datastore_common()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array(item1_title, item2_title...) or single item's title
|
||||
*/
|
||||
function enqueue($items)
|
||||
public function enqueue($items)
|
||||
{
|
||||
foreach ((array)$items as $item) {
|
||||
// игнор уже поставленного в очередь либо уже извлеченного
|
||||
|
@ -56,7 +58,7 @@ class datastore_common
|
|||
}
|
||||
}
|
||||
|
||||
function &get($title)
|
||||
public function &get($title)
|
||||
{
|
||||
if (!isset($this->data[$title])) {
|
||||
$this->enqueue($title);
|
||||
|
@ -65,18 +67,18 @@ class datastore_common
|
|||
return $this->data[$title];
|
||||
}
|
||||
|
||||
function store($item_name, $item_data)
|
||||
public function store($item_name, $item_data)
|
||||
{
|
||||
}
|
||||
|
||||
function rm($items)
|
||||
public function rm($items)
|
||||
{
|
||||
foreach ((array)$items as $item) {
|
||||
unset($this->data[$item]);
|
||||
}
|
||||
}
|
||||
|
||||
function update($items)
|
||||
public function update($items)
|
||||
{
|
||||
if ($items == 'all') {
|
||||
$items = array_keys(array_unique($this->known_items));
|
||||
|
@ -86,7 +88,7 @@ class datastore_common
|
|||
}
|
||||
}
|
||||
|
||||
function _fetch()
|
||||
public function _fetch()
|
||||
{
|
||||
$this->_fetch_from_store();
|
||||
|
||||
|
@ -99,11 +101,11 @@ class datastore_common
|
|||
$this->queued_items = array();
|
||||
}
|
||||
|
||||
function _fetch_from_store()
|
||||
public function _fetch_from_store()
|
||||
{
|
||||
}
|
||||
|
||||
function _build_item($title)
|
||||
public function _build_item($title)
|
||||
{
|
||||
if (!empty($this->known_items[$title])) {
|
||||
require(INC_DIR . $this->ds_dir . $this->known_items[$title]);
|
||||
|
@ -112,20 +114,22 @@ class datastore_common
|
|||
}
|
||||
}
|
||||
|
||||
var $num_queries = 0;
|
||||
var $sql_starttime = 0;
|
||||
var $sql_inittime = 0;
|
||||
var $sql_timetotal = 0;
|
||||
var $cur_query_time = 0;
|
||||
public $num_queries = 0;
|
||||
public $sql_starttime = 0;
|
||||
public $sql_inittime = 0;
|
||||
public $sql_timetotal = 0;
|
||||
public $cur_query_time = 0;
|
||||
|
||||
var $dbg = array();
|
||||
var $dbg_id = 0;
|
||||
var $dbg_enabled = false;
|
||||
var $cur_query = null;
|
||||
public $dbg = array();
|
||||
public $dbg_id = 0;
|
||||
public $dbg_enabled = false;
|
||||
public $cur_query = null;
|
||||
|
||||
function debug($mode, $cur_query = null)
|
||||
public function debug($mode, $cur_query = null)
|
||||
{
|
||||
if (!$this->dbg_enabled) return;
|
||||
if (!$this->dbg_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
$id =& $this->dbg_id;
|
||||
$dbg =& $this->dbg[$id];
|
||||
|
@ -146,7 +150,7 @@ class datastore_common
|
|||
}
|
||||
}
|
||||
|
||||
function debug_find_source($mode = '')
|
||||
public function debug_find_source($mode = '')
|
||||
{
|
||||
foreach (debug_backtrace() as $trace) {
|
||||
if ($trace['file'] !== __FILE__) {
|
||||
|
|
|
@ -1,21 +1,23 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
class datastore_file extends datastore_common
|
||||
{
|
||||
var $dir = null;
|
||||
var $prefix = null;
|
||||
var $engine = 'Filecache';
|
||||
public $dir = null;
|
||||
public $prefix = null;
|
||||
public $engine = 'Filecache';
|
||||
|
||||
function datastore_file($dir, $prefix = null)
|
||||
public function datastore_file($dir, $prefix = null)
|
||||
{
|
||||
$this->prefix = $prefix;
|
||||
$this->dir = $dir;
|
||||
$this->dbg_enabled = sql_dbg_enabled();
|
||||
}
|
||||
|
||||
function store($title, $var)
|
||||
public function store($title, $var)
|
||||
{
|
||||
$this->cur_query = "cache->set('$title')";
|
||||
$this->debug('start');
|
||||
|
@ -36,7 +38,7 @@ class datastore_file extends datastore_common
|
|||
return (bool)file_write($filecache, $filename, false, true, true);
|
||||
}
|
||||
|
||||
function clean()
|
||||
public function clean()
|
||||
{
|
||||
$dir = $this->dir;
|
||||
|
||||
|
@ -54,7 +56,7 @@ class datastore_file extends datastore_common
|
|||
}
|
||||
}
|
||||
|
||||
function _fetch_from_store()
|
||||
public function _fetch_from_store()
|
||||
{
|
||||
if (!$items = $this->queued_items) {
|
||||
$src = $this->_debug_find_caller('enqueue');
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
class datastore_memcache extends datastore_common
|
||||
{
|
||||
var $cfg = null;
|
||||
var $memcache = null;
|
||||
var $connected = false;
|
||||
var $engine = 'Memcache';
|
||||
var $prefix = null;
|
||||
public $cfg = null;
|
||||
public $memcache = null;
|
||||
public $connected = false;
|
||||
public $engine = 'Memcache';
|
||||
public $prefix = null;
|
||||
|
||||
function datastore_memcache($cfg, $prefix = null)
|
||||
public function datastore_memcache($cfg, $prefix = null)
|
||||
{
|
||||
if (!$this->is_installed()) {
|
||||
die('Error: Memcached extension not installed');
|
||||
|
@ -22,7 +24,7 @@ class datastore_memcache extends datastore_common
|
|||
$this->dbg_enabled = sql_dbg_enabled();
|
||||
}
|
||||
|
||||
function connect()
|
||||
public function connect()
|
||||
{
|
||||
$connect_type = ($this->cfg['pconnect']) ? 'pconnect' : 'connect';
|
||||
|
||||
|
@ -33,7 +35,9 @@ class datastore_memcache extends datastore_common
|
|||
$this->connected = true;
|
||||
}
|
||||
|
||||
if (DBG_LOG) dbg_log(' ', 'CACHE-connect' . ($this->connected ? '' : '-FAIL'));
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', 'CACHE-connect' . ($this->connected ? '' : '-FAIL'));
|
||||
}
|
||||
|
||||
if (!$this->connected && $this->cfg['con_required']) {
|
||||
die('Could not connect to memcached server');
|
||||
|
@ -43,9 +47,11 @@ class datastore_memcache extends datastore_common
|
|||
$this->cur_query = null;
|
||||
}
|
||||
|
||||
function store($title, $var)
|
||||
public function store($title, $var)
|
||||
{
|
||||
if (!$this->connected) $this->connect();
|
||||
if (!$this->connected) {
|
||||
$this->connect();
|
||||
}
|
||||
$this->data[$title] = $var;
|
||||
|
||||
$this->cur_query = "cache->set('$title')";
|
||||
|
@ -57,9 +63,11 @@ class datastore_memcache extends datastore_common
|
|||
return (bool)$this->memcache->set($this->prefix . $title, $var);
|
||||
}
|
||||
|
||||
function clean()
|
||||
public function clean()
|
||||
{
|
||||
if (!$this->connected) $this->connect();
|
||||
if (!$this->connected) {
|
||||
$this->connect();
|
||||
}
|
||||
foreach ($this->known_items as $title => $script_name) {
|
||||
$this->cur_query = "cache->rm('$title')";
|
||||
$this->debug('start');
|
||||
|
@ -71,14 +79,16 @@ class datastore_memcache extends datastore_common
|
|||
}
|
||||
}
|
||||
|
||||
function _fetch_from_store()
|
||||
public function _fetch_from_store()
|
||||
{
|
||||
if (!$items = $this->queued_items) {
|
||||
$src = $this->_debug_find_caller('enqueue');
|
||||
trigger_error("Datastore: item '$item' already enqueued [$src]", E_USER_ERROR);
|
||||
}
|
||||
|
||||
if (!$this->connected) $this->connect();
|
||||
if (!$this->connected) {
|
||||
$this->connect();
|
||||
}
|
||||
foreach ($items as $item) {
|
||||
$this->cur_query = "cache->get('$item')";
|
||||
$this->debug('start');
|
||||
|
@ -90,7 +100,7 @@ class datastore_memcache extends datastore_common
|
|||
}
|
||||
}
|
||||
|
||||
function is_installed()
|
||||
public function is_installed()
|
||||
{
|
||||
return class_exists('Memcache');
|
||||
}
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
class datastore_redis extends datastore_common
|
||||
{
|
||||
var $cfg = null;
|
||||
var $redis = null;
|
||||
var $prefix = null;
|
||||
var $connected = false;
|
||||
var $engine = 'Redis';
|
||||
public $cfg = null;
|
||||
public $redis = null;
|
||||
public $prefix = null;
|
||||
public $connected = false;
|
||||
public $engine = 'Redis';
|
||||
|
||||
function datastore_redis($cfg, $prefix = null)
|
||||
public function datastore_redis($cfg, $prefix = null)
|
||||
{
|
||||
if (!$this->is_installed()) {
|
||||
die('Error: Redis extension not installed');
|
||||
|
@ -22,7 +24,7 @@ class datastore_redis extends datastore_common
|
|||
$this->prefix = $prefix;
|
||||
}
|
||||
|
||||
function connect()
|
||||
public function connect()
|
||||
{
|
||||
$this->cur_query = 'connect ' . $this->cfg['host'] . ':' . $this->cfg['port'];
|
||||
$this->debug('start');
|
||||
|
@ -39,9 +41,11 @@ class datastore_redis extends datastore_common
|
|||
$this->cur_query = null;
|
||||
}
|
||||
|
||||
function store($title, $var)
|
||||
public function store($title, $var)
|
||||
{
|
||||
if (!$this->connected) $this->connect();
|
||||
if (!$this->connected) {
|
||||
$this->connect();
|
||||
}
|
||||
$this->data[$title] = $var;
|
||||
|
||||
$this->cur_query = "cache->set('$title')";
|
||||
|
@ -53,9 +57,11 @@ class datastore_redis extends datastore_common
|
|||
return (bool)$this->redis->set($this->prefix . $title, serialize($var));
|
||||
}
|
||||
|
||||
function clean()
|
||||
public function clean()
|
||||
{
|
||||
if (!$this->connected) $this->connect();
|
||||
if (!$this->connected) {
|
||||
$this->connect();
|
||||
}
|
||||
foreach ($this->known_items as $title => $script_name) {
|
||||
$this->cur_query = "cache->rm('$title')";
|
||||
$this->debug('start');
|
||||
|
@ -67,14 +73,16 @@ class datastore_redis extends datastore_common
|
|||
}
|
||||
}
|
||||
|
||||
function _fetch_from_store()
|
||||
public function _fetch_from_store()
|
||||
{
|
||||
if (!$items = $this->queued_items) {
|
||||
$src = $this->_debug_find_caller('enqueue');
|
||||
trigger_error("Datastore: item '$item' already enqueued [$src]", E_USER_ERROR);
|
||||
}
|
||||
|
||||
if (!$this->connected) $this->connect();
|
||||
if (!$this->connected) {
|
||||
$this->connect();
|
||||
}
|
||||
foreach ($items as $item) {
|
||||
$this->cur_query = "cache->get('$item')";
|
||||
$this->debug('start');
|
||||
|
@ -86,7 +94,7 @@ class datastore_redis extends datastore_common
|
|||
}
|
||||
}
|
||||
|
||||
function is_installed()
|
||||
public function is_installed()
|
||||
{
|
||||
return class_exists('Redis');
|
||||
}
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
class datastore_sqlite extends datastore_common
|
||||
{
|
||||
var $engine = 'SQLite';
|
||||
var $db = null;
|
||||
var $prefix = null;
|
||||
var $cfg = array(
|
||||
public $engine = 'SQLite';
|
||||
public $db = null;
|
||||
public $prefix = null;
|
||||
public $cfg = array(
|
||||
'db_file_path' => '/path/to/datastore.db.sqlite',
|
||||
'table_name' => 'datastore',
|
||||
'table_schema' => 'CREATE TABLE datastore (
|
||||
|
@ -20,14 +22,14 @@ class datastore_sqlite extends datastore_common
|
|||
'log_name' => 'DATASTORE',
|
||||
);
|
||||
|
||||
function datastore_sqlite($cfg, $prefix = null)
|
||||
public function datastore_sqlite($cfg, $prefix = null)
|
||||
{
|
||||
$this->cfg = array_merge($this->cfg, $cfg);
|
||||
$this->db = new sqlite_common($this->cfg);
|
||||
$this->prefix = $prefix;
|
||||
}
|
||||
|
||||
function store($item_name, $item_data)
|
||||
public function store($item_name, $item_data)
|
||||
{
|
||||
$this->data[$item_name] = $item_data;
|
||||
|
||||
|
@ -39,14 +41,16 @@ class datastore_sqlite extends datastore_common
|
|||
return (bool)$result;
|
||||
}
|
||||
|
||||
function clean()
|
||||
public function clean()
|
||||
{
|
||||
$this->db->query("DELETE FROM " . $this->cfg['table_name']);
|
||||
}
|
||||
|
||||
function _fetch_from_store()
|
||||
public function _fetch_from_store()
|
||||
{
|
||||
if (!$items = $this->queued_items) return;
|
||||
if (!$items = $this->queued_items) {
|
||||
return;
|
||||
}
|
||||
|
||||
$prefix_len = strlen($this->prefix);
|
||||
$prefix_sql = SQLite3::escapeString($this->prefix);
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
class datastore_xcache extends datastore_common
|
||||
{
|
||||
var $prefix = null;
|
||||
var $engine = 'XCache';
|
||||
public $prefix = null;
|
||||
public $engine = 'XCache';
|
||||
|
||||
function datastore_xcache($prefix = null)
|
||||
public function datastore_xcache($prefix = null)
|
||||
{
|
||||
if (!$this->is_installed()) {
|
||||
die('Error: XCache extension not installed');
|
||||
|
@ -17,7 +19,7 @@ class datastore_xcache extends datastore_common
|
|||
$this->prefix = $prefix;
|
||||
}
|
||||
|
||||
function store($title, $var)
|
||||
public function store($title, $var)
|
||||
{
|
||||
$this->data[$title] = $var;
|
||||
|
||||
|
@ -30,7 +32,7 @@ class datastore_xcache extends datastore_common
|
|||
return (bool)xcache_set($this->prefix . $title, $var);
|
||||
}
|
||||
|
||||
function clean()
|
||||
public function clean()
|
||||
{
|
||||
foreach ($this->known_items as $title => $script_name) {
|
||||
$this->cur_query = "cache->rm('$title')";
|
||||
|
@ -43,7 +45,7 @@ class datastore_xcache extends datastore_common
|
|||
}
|
||||
}
|
||||
|
||||
function _fetch_from_store()
|
||||
public function _fetch_from_store()
|
||||
{
|
||||
if (!$items = $this->queued_items) {
|
||||
$src = $this->_debug_find_caller('enqueue');
|
||||
|
@ -61,7 +63,7 @@ class datastore_xcache extends datastore_common
|
|||
}
|
||||
}
|
||||
|
||||
function is_installed()
|
||||
public function is_installed()
|
||||
{
|
||||
return function_exists('xcache_get');
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
function get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div)
|
||||
{
|
||||
|
@ -69,7 +71,9 @@ function set_tracks($cookie_name, &$tracking_ary, $tracks = null, $val = TIMENOW
|
|||
{
|
||||
global $tracking_topics, $tracking_forums, $user;
|
||||
|
||||
if (IS_GUEST) return;
|
||||
if (IS_GUEST) {
|
||||
return;
|
||||
}
|
||||
|
||||
$prev_tracking_ary = $tracking_ary;
|
||||
|
||||
|
@ -406,26 +410,30 @@ function auth($type, $forum_id, $ug_data, $f_access = array(), $group_perm = UG_
|
|||
|
||||
function auth_check($bf_ary, $bf_key, $perm_ary, $perm_key, $is_admin = false)
|
||||
{
|
||||
if ($is_admin) return true;
|
||||
if (!isset($perm_ary[$perm_key])) return false;
|
||||
if ($is_admin) {
|
||||
return true;
|
||||
}
|
||||
if (!isset($perm_ary[$perm_key])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return bf($perm_ary[$perm_key], $bf_ary, $bf_key);
|
||||
}
|
||||
|
||||
class Date_Delta
|
||||
{
|
||||
var $auto_granularity = array(
|
||||
public $auto_granularity = array(
|
||||
60 => 'seconds', // set granularity to "seconds" if delta less then 1 minute
|
||||
10800 => 'minutes', // 3 hours
|
||||
259200 => 'hours', // 3 days
|
||||
31363200 => 'mday', // 12 months
|
||||
311040000 => 'mon', // 10 years
|
||||
);
|
||||
var $intervals = array();
|
||||
var $format = '';
|
||||
public $intervals = array();
|
||||
public $format = '';
|
||||
|
||||
// Creates new object.
|
||||
function Date_Delta()
|
||||
public function Date_Delta()
|
||||
{
|
||||
global $lang;
|
||||
|
||||
|
@ -434,7 +442,7 @@ class Date_Delta
|
|||
}
|
||||
|
||||
// Makes the spellable phrase.
|
||||
function spellDelta($first, $last, $from = 'auto')
|
||||
public function spellDelta($first, $last, $from = 'auto')
|
||||
{
|
||||
if ($last < $first) {
|
||||
$old_first = $first;
|
||||
|
@ -455,7 +463,9 @@ class Date_Delta
|
|||
|
||||
// Solve data delta.
|
||||
$delta = $this->getDelta($first, $last);
|
||||
if (!$delta) return false;
|
||||
if (!$delta) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make spellable phrase.
|
||||
$parts = array();
|
||||
|
@ -472,15 +482,19 @@ class Date_Delta
|
|||
continue;
|
||||
}
|
||||
$parts[] = declension($n, $this->intervals[$k], $this->format);
|
||||
if ($k == $from) break;
|
||||
if ($k == $from) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return join(' ', $parts);
|
||||
}
|
||||
|
||||
// returns the associative array with date deltas.
|
||||
function getDelta($first, $last)
|
||||
public function getDelta($first, $last)
|
||||
{
|
||||
if ($last < $first) return false;
|
||||
if ($last < $first) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Solve H:M:S part.
|
||||
$hms = ($last - $first) % (3600 * 24);
|
||||
|
@ -520,10 +534,12 @@ class Date_Delta
|
|||
}
|
||||
|
||||
// Returns the length (in days) of the specified month.
|
||||
function monthLength($year, $mon)
|
||||
public function monthLength($year, $mon)
|
||||
{
|
||||
$l = 28;
|
||||
while (checkdate($mon, $l + 1, $year)) $l++;
|
||||
while (checkdate($mon, $l + 1, $year)) {
|
||||
$l++;
|
||||
}
|
||||
return $l;
|
||||
}
|
||||
}
|
||||
|
@ -561,15 +577,17 @@ function get_select($select, $selected = null, $return_as = 'html', $first_opt =
|
|||
|
||||
class html_common
|
||||
{
|
||||
var $options = '';
|
||||
var $attr = array();
|
||||
var $cur_attr = null;
|
||||
var $max_length = HTML_SELECT_MAX_LENGTH;
|
||||
var $selected = array();
|
||||
public $options = '';
|
||||
public $attr = array();
|
||||
public $cur_attr = null;
|
||||
public $max_length = HTML_SELECT_MAX_LENGTH;
|
||||
public $selected = array();
|
||||
|
||||
function build_select($name, $params, $selected = null, $max_length = HTML_SELECT_MAX_LENGTH, $multiple_size = null, $js = '')
|
||||
public function build_select($name, $params, $selected = null, $max_length = HTML_SELECT_MAX_LENGTH, $multiple_size = null, $js = '')
|
||||
{
|
||||
if (empty($params)) return '';
|
||||
if (empty($params)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$this->options = '';
|
||||
$this->selected = array_flip((array)$selected);
|
||||
|
@ -593,7 +611,7 @@ class html_common
|
|||
return "\n<select $select_params>\n" . $this->options . "</select>\n";
|
||||
}
|
||||
|
||||
function _build_select_rec($params)
|
||||
public function _build_select_rec($params)
|
||||
{
|
||||
foreach ($params as $opt_name => $opt_val) {
|
||||
$opt_name = rtrim($opt_name);
|
||||
|
@ -623,14 +641,14 @@ class html_common
|
|||
}
|
||||
}
|
||||
|
||||
function array2html($array, $ul = 'ul', $li = 'li')
|
||||
public function array2html($array, $ul = 'ul', $li = 'li')
|
||||
{
|
||||
$this->out = '';
|
||||
$this->_array2html_rec($array, $ul, $li);
|
||||
return "<$ul class=\"tree-root\">{$this->out}</$ul>";
|
||||
}
|
||||
|
||||
function _array2html_rec($array, $ul, $li)
|
||||
public function _array2html_rec($array, $ul, $li)
|
||||
{
|
||||
foreach ($array as $k => $v) {
|
||||
if (is_array($v)) {
|
||||
|
@ -644,7 +662,7 @@ class html_common
|
|||
}
|
||||
|
||||
// all arguments should be already htmlspecialchar()d (if needed)
|
||||
function build_checkbox($name, $title, $checked = false, $disabled = false, $class = null, $id = null, $value = 1)
|
||||
public function build_checkbox($name, $title, $checked = false, $disabled = false, $class = null, $id = null, $value = 1)
|
||||
{
|
||||
$name = ' name="' . $name . '" ';
|
||||
$value = ' value="' . $value . '" ';
|
||||
|
@ -671,8 +689,12 @@ function build_checkbox($name, $title, $checked = false, $disabled = false, $cla
|
|||
|
||||
function replace_quote($str, $double = true, $single = true)
|
||||
{
|
||||
if ($double) $str = str_replace('"', '"', $str);
|
||||
if ($single) $str = str_replace("'", ''', $str);
|
||||
if ($double) {
|
||||
$str = str_replace('"', '"', $str);
|
||||
}
|
||||
if ($single) {
|
||||
$str = str_replace("'", ''', $str);
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
@ -995,7 +1017,9 @@ function get_username($user_id)
|
|||
|
||||
function get_user_id($username)
|
||||
{
|
||||
if (empty($username)) return false;
|
||||
if (empty($username)) {
|
||||
return false;
|
||||
}
|
||||
$row = DB()->fetch_row("SELECT user_id FROM " . BB_USERS . " WHERE username = '" . DB()->escape($username) . "' LIMIT 1");
|
||||
return $row['user_id'];
|
||||
}
|
||||
|
@ -1214,7 +1238,9 @@ function get_userdata($u, $force_name = false, $allow_guest = false)
|
|||
/** @var \TorrentPier\Cache\Adapter $cache */
|
||||
$cache = $di->cache;
|
||||
|
||||
if (!$u) return false;
|
||||
if (!$u) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (intval($u) == GUEST_UID && $allow_guest) {
|
||||
if ($u_data = $cache->get('guest_userdata')) {
|
||||
|
@ -1285,15 +1311,21 @@ function get_forum_select($mode = 'guest', $name = POST_FORUM_URL, $selected = n
|
|||
foreach ($forums['f'] as $fid => $f) {
|
||||
switch ($mode) {
|
||||
case 'guest':
|
||||
if ($f['auth_view'] != AUTH_ALL) continue 2;
|
||||
if ($f['auth_view'] != AUTH_ALL) {
|
||||
continue 2;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'user':
|
||||
if ($f['auth_view'] != AUTH_ALL && $f['auth_view'] != AUTH_REG) continue 2;
|
||||
if ($f['auth_view'] != AUTH_ALL && $f['auth_view'] != AUTH_REG) {
|
||||
continue 2;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'not_auth_forums':
|
||||
if (isset($not_auth_forums_fary[$f['forum_id']])) continue 2;
|
||||
if (isset($not_auth_forums_fary[$f['forum_id']])) {
|
||||
continue 2;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'admin':
|
||||
|
@ -1335,7 +1367,9 @@ function setup_style()
|
|||
|
||||
if (!IS_GUEST && !empty($userdata['tpl_name'])) {
|
||||
foreach ($di->config->get('templates') as $folder => $name) {
|
||||
if ($userdata['tpl_name'] == $folder) $tpl_dir_name = basename($userdata['tpl_name']);
|
||||
if ($userdata['tpl_name'] == $folder) {
|
||||
$tpl_dir_name = basename($userdata['tpl_name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1366,8 +1400,12 @@ function bb_date($gmepoch, $format = false, $friendly_date = true)
|
|||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
||||
if (!$format) $format = $di->config->get('default_dateformat');
|
||||
if (empty($lang)) require_once($di->config->get('default_lang_dir') . 'main.php');
|
||||
if (!$format) {
|
||||
$format = $di->config->get('default_dateformat');
|
||||
}
|
||||
if (empty($lang)) {
|
||||
require_once($di->config->get('default_lang_dir') . 'main.php');
|
||||
}
|
||||
|
||||
if (empty($userdata['session_logged_in'])) {
|
||||
$tz = $di->config->get('board_timezone');
|
||||
|
@ -1394,14 +1432,16 @@ function bb_date($gmepoch, $format = false, $friendly_date = true)
|
|||
$date = 'yesterday' . gmdate($time_format, $gmepoch + (3600 * $tz));
|
||||
} elseif ($today == 1 && $month != 1) {
|
||||
$yesterday = date('t', mktime(0, 0, 0, ($month - 1), 1, $year));
|
||||
if ($date_today == $yesterday && $date_month == ($month - 1) && $date_year == $year)
|
||||
if ($date_today == $yesterday && $date_month == ($month - 1) && $date_year == $year) {
|
||||
$date = 'yesterday' . gmdate($time_format, $gmepoch + (3600 * $tz));
|
||||
}
|
||||
} elseif ($today == 1 && $month == 1) {
|
||||
$yesterday = date('t', mktime(0, 0, 0, 12, 1, ($year - 1)));
|
||||
if ($date_today == $yesterday && $date_month == 12 && $date_year == ($year - 1))
|
||||
if ($date_today == $yesterday && $date_month == 12 && $date_year == ($year - 1)) {
|
||||
$date = 'yesterday' . gmdate($time_format, $gmepoch + (3600 * $tz));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ($di->config->get('translate_dates')) ? strtr(strtoupper($date), $lang['DATETIME']) : $date;
|
||||
}
|
||||
|
@ -1411,7 +1451,9 @@ function birthday_age($date)
|
|||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
||||
if (!$date) return false;
|
||||
if (!$date) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$tz = TIMENOW + (3600 * $di->config->get('board_timezone'));
|
||||
|
||||
|
@ -1422,7 +1464,7 @@ function birthday_age($date)
|
|||
// Pagination routine, generates
|
||||
// page number sequence
|
||||
//
|
||||
function generate_pagination($base_url, $num_items, $per_page, $start_item, $add_prevnext_text = TRUE)
|
||||
function generate_pagination($base_url, $num_items, $per_page, $start_item, $add_prevnext_text = true)
|
||||
{
|
||||
global $lang, $template;
|
||||
|
||||
|
@ -1504,7 +1546,6 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add
|
|||
if ($on_page < $total_pages) {
|
||||
$page_string .= ' <a href="' . $base_url . "&start=" . ($on_page * $per_page) . '">' . $lang['NEXT_PAGE'] . '</a>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$pagination = ($page_string) ? '<a class="menu-root" href="#pg-jump">' . $lang['GOTO_PAGE'] . '</a> : ' . $page_string : '';
|
||||
|
@ -1533,11 +1574,15 @@ function obtain_word_list(&$orig_word, &$replacement_word)
|
|||
/** @var \TorrentPier\Cache\Adapter $cache */
|
||||
$cache = $di->cache;
|
||||
|
||||
if (!$di->config->get('use_word_censor')) return false;
|
||||
if (!$di->config->get('use_word_censor')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$cache->has('censored')) {
|
||||
$sql = DB()->fetch_rowset("SELECT word, replacement FROM " . BB_WORDS);
|
||||
if (!$sql) $sql = [['word' => 1, 'replacement' => 1]];
|
||||
if (!$sql) {
|
||||
$sql = [['word' => 1, 'replacement' => 1]];
|
||||
}
|
||||
$cache->set('censored', $sql, 7200);
|
||||
}
|
||||
|
||||
|
@ -1753,7 +1798,7 @@ function cat_exists($cat_id)
|
|||
//
|
||||
class log_action
|
||||
{
|
||||
var $log_type = [
|
||||
public $log_type = [
|
||||
# LOG_TYPE_NAME LOG_TYPE_ID
|
||||
'mod_topic_delete' => 1,
|
||||
'mod_topic_move' => 2,
|
||||
|
@ -1772,10 +1817,10 @@ class log_action
|
|||
'adm_ban_email' => 15,
|
||||
'adm_ban_name' => 16,
|
||||
];
|
||||
var $log_type_select = [];
|
||||
var $log_disabled = false;
|
||||
public $log_type_select = [];
|
||||
public $log_disabled = false;
|
||||
|
||||
function init()
|
||||
public function init()
|
||||
{
|
||||
global $lang;
|
||||
|
||||
|
@ -1784,12 +1829,16 @@ class log_action
|
|||
}
|
||||
}
|
||||
|
||||
function mod($type_name, $args = array())
|
||||
public function mod($type_name, $args = array())
|
||||
{
|
||||
global $userdata;
|
||||
|
||||
if (empty($this->log_type)) $this->init();
|
||||
if ($this->log_disabled) return;
|
||||
if (empty($this->log_type)) {
|
||||
$this->init();
|
||||
}
|
||||
if ($this->log_disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
$forum_id =& $args['forum_id'];
|
||||
$forum_id_new =& $args['forum_id_new'];
|
||||
|
@ -1825,7 +1874,7 @@ class log_action
|
|||
DB()->query("INSERT INTO " . BB_LOG . " $sql_args");
|
||||
}
|
||||
|
||||
function admin($type_name, $args = array())
|
||||
public function admin($type_name, $args = array())
|
||||
{
|
||||
$this->mod($type_name, $args);
|
||||
}
|
||||
|
@ -1979,7 +2028,7 @@ function print_page($args, $type = '', $mode = '')
|
|||
$tpl = (is_array($args) && !empty($args['tpl'])) ? $args['tpl'] : $args;
|
||||
$tpl = ($type === 'admin') ? ADMIN_TPL_DIR . $tpl : $tpl;
|
||||
|
||||
$gen_simple_header = (is_array($args) && !empty($args['simple']) OR $type === 'simple') ? true : $gen_simple_header;
|
||||
$gen_simple_header = (is_array($args) && !empty($args['simple']) or $type === 'simple') ? true : $gen_simple_header;
|
||||
|
||||
if ($mode !== 'no_header') {
|
||||
require(PAGE_HEADER);
|
||||
|
@ -2044,7 +2093,9 @@ function init_sphinx()
|
|||
global $sphinx;
|
||||
|
||||
if (!isset($sphinx)) {
|
||||
if (!class_exists('SphinxClient')) require(INC_DIR . 'api/sphinx.php');
|
||||
if (!class_exists('SphinxClient')) {
|
||||
require(INC_DIR . 'api/sphinx.php');
|
||||
}
|
||||
$sphinx = new SphinxClient();
|
||||
|
||||
$sphinx->SetConnectTimeout(5);
|
||||
|
@ -2236,10 +2287,16 @@ function profile_url($data)
|
|||
$title = $ranks[$user_rank]['rank_title'];
|
||||
$style = $ranks[$user_rank]['rank_style'];
|
||||
}
|
||||
if (empty($title)) $title = $lang['USER'];
|
||||
if (empty($style)) $style = 'colorUser';
|
||||
if (empty($title)) {
|
||||
$title = $lang['USER'];
|
||||
}
|
||||
if (empty($style)) {
|
||||
$style = 'colorUser';
|
||||
}
|
||||
|
||||
if (!$di->config->get('color_nick')) $style = '';
|
||||
if (!$di->config->get('color_nick')) {
|
||||
$style = '';
|
||||
}
|
||||
|
||||
$username = !empty($data['username']) ? $data['username'] : $lang['GUEST'];
|
||||
$user_id = (!empty($data['user_id']) && $username != $lang['GUEST']) ? $data['user_id'] : GUEST_UID;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
function sync_all_forums()
|
||||
{
|
||||
|
@ -524,9 +526,13 @@ function post_delete($mode_or_post_id, $user_id = null, $exclude_first = true)
|
|||
|
||||
// Get required params
|
||||
if ($del_user_posts) {
|
||||
if (!$user_csv = get_id_csv($user_id)) return false;
|
||||
if (!$user_csv = get_id_csv($user_id)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!$post_csv = get_id_csv($mode_or_post_id)) return false;
|
||||
if (!$post_csv = get_id_csv($mode_or_post_id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// фильтр заглавных сообщений в теме
|
||||
if ($exclude_first) {
|
||||
|
|
|
@ -88,7 +88,9 @@ function insert_cron_job($cron_arr)
|
|||
|
||||
if ($_POST['cron_script'] == $row['cron_script']) {
|
||||
$langmode = $lang['SCRIPT_DUPLICATE'];
|
||||
} else $langmode = $lang['TITLE_DUPLICATE'];
|
||||
} else {
|
||||
$langmode = $lang['TITLE_DUPLICATE'];
|
||||
}
|
||||
|
||||
$message = $langmode . "<br /><br />" . sprintf($lang['CLICK_RETURN_JOBS_ADDED'], "<a href=\"javascript:history.back(-1)\">", "</a>") . "<br /><br />" . sprintf($lang['CLICK_RETURN_JOBS'], "<a href=\"admin_cron.php?mode=list\">", "</a>") . "<br /><br />" . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], "<a href=\"index.php?pane=right\">", "</a>");
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
function update_table_bool($table_name, $key, $field_name, $field_def_val)
|
||||
{
|
||||
|
@ -72,7 +74,6 @@ function set_tpl_vars_lang($default_cfg)
|
|||
'L_' . strtoupper($config_name) . '_EXPL' => isset($lang[$config_name . '_expl']) ? $lang[$config_name . '_expl'] : '',
|
||||
'L_' . strtoupper($config_name) . '_HEAD' => isset($lang[$config_name . '_head']) ? $lang[$config_name . '_head'] : '',
|
||||
));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
// Максимум записей = 50
|
||||
// [Обновлено] - если дата изменения первого поста топика не старее недели (?) или в топике новые сообщения не старее недели (?)
|
||||
|
@ -12,7 +14,9 @@ function update_forum_feed($forum_id, $forum_data)
|
|||
|
||||
$file_path = $di->config->get('atom.path') . '/f/' . $forum_id . '.atom';
|
||||
$select_tor_sql = $join_tor_sql = '';
|
||||
if ($forum_id == 0) $forum_data['atom_forum_name'] = 'Общая по всем разделам';
|
||||
if ($forum_id == 0) {
|
||||
$forum_data['atom_forum_name'] = 'Общая по всем разделам';
|
||||
}
|
||||
if ($forum_id > 0 && $forum_data['atom_tr_allowed']) {
|
||||
$select_tor_sql = ', tor.size AS tor_size, tor.tor_status';
|
||||
$join_tor_sql = "LEFT JOIN " . BB_BT_TORRENTS . " tor ON(t.topic_id = tor.topic_id)";
|
||||
|
@ -55,10 +59,14 @@ function update_forum_feed($forum_id, $forum_data)
|
|||
$topics = array();
|
||||
foreach ($topics_tmp as $topic) {
|
||||
if (isset($topic['topic_status'])) {
|
||||
if ($topic['topic_status'] == TOPIC_MOVED) continue;
|
||||
if ($topic['topic_status'] == TOPIC_MOVED) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (isset($topic['tor_status'])) {
|
||||
if ($di->config->get('tor_frozen.' . $topic['tor_status'])) continue;
|
||||
if ($di->config->get('tor_frozen.' . $topic['tor_status'])) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$topics[] = $topic;
|
||||
}
|
||||
|
@ -66,8 +74,11 @@ function update_forum_feed($forum_id, $forum_data)
|
|||
unlink($file_path);
|
||||
return false;
|
||||
}
|
||||
if (create_atom($file_path, 'f', $forum_id, htmlCHR($forum_data['atom_forum_name']), $topics)) return true;
|
||||
else return false;
|
||||
if (create_atom($file_path, 'f', $forum_id, htmlCHR($forum_data['atom_forum_name']), $topics)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function update_user_feed($user_id, $username)
|
||||
|
@ -96,10 +107,14 @@ function update_user_feed($user_id, $username)
|
|||
$topics = array();
|
||||
foreach ($topics_tmp as $topic) {
|
||||
if (isset($topic['topic_status'])) {
|
||||
if ($topic['topic_status'] == TOPIC_MOVED) continue;
|
||||
if ($topic['topic_status'] == TOPIC_MOVED) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (isset($topic['tor_status'])) {
|
||||
if ($di->config->get('tor_frozen.' . $topic['tor_status'])) continue;
|
||||
if ($di->config->get('tor_frozen.' . $topic['tor_status'])) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$topics[] = $topic;
|
||||
}
|
||||
|
@ -107,8 +122,11 @@ function update_user_feed($user_id, $username)
|
|||
unlink($file_path);
|
||||
return false;
|
||||
}
|
||||
if (create_atom($file_path, 'u', $user_id, wbr($username), $topics)) return true;
|
||||
else return false;
|
||||
if (create_atom($file_path, 'u', $user_id, wbr($username), $topics)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function create_atom($file_path, $mode, $id, $title, $topics)
|
||||
|
@ -118,11 +136,15 @@ function create_atom($file_path, $mode, $id, $title, $topics)
|
|||
|
||||
$dir = dirname($file_path);
|
||||
if (!file_exists($dir)) {
|
||||
if (!bb_mkdir($dir)) return false;
|
||||
if (!bb_mkdir($dir)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
foreach ($topics as $topic) {
|
||||
$last_time = $topic['topic_last_post_time'];
|
||||
if ($topic['topic_last_post_edit_time']) $last_time = $topic['topic_last_post_edit_time'];
|
||||
if ($topic['topic_last_post_edit_time']) {
|
||||
$last_time = $topic['topic_last_post_edit_time'];
|
||||
}
|
||||
$date = bb_date($last_time, 'Y-m-d', 0);
|
||||
$time = bb_date($last_time, 'H:i:s', 0);
|
||||
break;
|
||||
|
@ -150,12 +172,16 @@ function create_atom($file_path, $mode, $id, $title, $topics)
|
|||
$topic_title = wbr($topic_title);
|
||||
$author_name = ($topic['first_username']) ? wbr($topic['first_username']) : 'Гость';
|
||||
$last_time = $topic['topic_last_post_time'];
|
||||
if ($topic['topic_last_post_edit_time']) $last_time = $topic['topic_last_post_edit_time'];
|
||||
if ($topic['topic_last_post_edit_time']) {
|
||||
$last_time = $topic['topic_last_post_edit_time'];
|
||||
}
|
||||
$date = bb_date($last_time, 'Y-m-d', 0);
|
||||
$time = bb_date($last_time, 'H:i:s', 0);
|
||||
$updated = '';
|
||||
$checktime = TIMENOW - 604800; // неделя (week)
|
||||
if ($topic['topic_first_post_edit_time'] && $topic['topic_first_post_edit_time'] > $checktime) $updated = '[Обновлено] ';
|
||||
if ($topic['topic_first_post_edit_time'] && $topic['topic_first_post_edit_time'] > $checktime) {
|
||||
$updated = '[Обновлено] ';
|
||||
}
|
||||
$atom .= "<entry>\n";
|
||||
$atom .= " <title type=\"html\"><![CDATA[$updated$topic_title$tor_size]]></title>\n";
|
||||
$atom .= " <author>\n";
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
function get_sql_log()
|
||||
{
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
function update_user_level($user_id)
|
||||
{
|
||||
|
@ -157,7 +159,9 @@ function delete_permissions($group_id = null, $user_id = null, $cat_id = null)
|
|||
|
||||
function store_permissions($group_id, $auth_ary)
|
||||
{
|
||||
if (empty($auth_ary) || !is_array($auth_ary)) return;
|
||||
if (empty($auth_ary) || !is_array($auth_ary)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$values = array();
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
//
|
||||
// Prepare a message for posting
|
||||
|
@ -36,7 +38,6 @@ function prepare_post(&$mode, &$post_data, &$error_msg, &$username, &$subject, &
|
|||
|
||||
// Check message
|
||||
if (!empty($message)) {
|
||||
|
||||
} elseif ($mode != 'delete') {
|
||||
$error_msg .= (!empty($error_msg)) ? '<br />' . $lang['EMPTY_MESSAGE'] : $lang['EMPTY_MESSAGE'];
|
||||
}
|
||||
|
@ -376,14 +377,18 @@ function insert_post($mode, $topic_id, $forum_id = '', $old_forum_id = '', $new_
|
|||
{
|
||||
global $userdata, $lang;
|
||||
|
||||
if (!$topic_id) return;
|
||||
if (!$topic_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
$post_username = $post_subject = $post_text = $poster_ip = '';
|
||||
|
||||
$post_time = $current_time = TIMENOW;
|
||||
|
||||
if ($mode == 'after_move') {
|
||||
if (!$forum_id || !$old_forum_id) return;
|
||||
if (!$forum_id || !$old_forum_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = "SELECT forum_id, forum_name
|
||||
FROM " . BB_FORUMS . "
|
||||
|
@ -393,7 +398,9 @@ function insert_post($mode, $topic_id, $forum_id = '', $old_forum_id = '', $new_
|
|||
foreach (DB()->fetch_rowset($sql) as $row) {
|
||||
$forum_names[$row['forum_id']] = htmlCHR($row['forum_name']);
|
||||
}
|
||||
if (!$forum_names) return;
|
||||
if (!$forum_names) {
|
||||
return;
|
||||
}
|
||||
|
||||
$post_text = sprintf($lang['BOT_TOPIC_MOVED_FROM_TO'], '[url=' . make_url(FORUM_URL . $old_forum_id) . ']' . $forum_names[$old_forum_id] . '[/url]', '[url=' . make_url(FORUM_URL . $forum_id) . ']' . $forum_names[$forum_id] . '[/url]', profile_url($userdata));
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
// Languages
|
||||
function language_select($default_lang, $select_name = 'language')
|
||||
|
@ -12,7 +14,9 @@ function language_select($default_lang, $select_name = 'language')
|
|||
$x = 0;
|
||||
foreach ($di->config->get('lang') as $key => $data) {
|
||||
$selected = '';
|
||||
if ($key == $default_lang) $selected = ' selected="selected"';
|
||||
if ($key == $default_lang) {
|
||||
$selected = ' selected="selected"';
|
||||
}
|
||||
$lang_select .= '<option value="' . $key . '"' . $selected . '>' . $data['name'] . '</option>';
|
||||
$x++;
|
||||
}
|
||||
|
@ -49,7 +53,9 @@ function templates_select($default_style, $select_name = 'tpl_name')
|
|||
$x = 0;
|
||||
foreach ($di->config->get('templates') as $folder => $name) {
|
||||
$selected = '';
|
||||
if ($folder == $default_style) $selected = ' selected="selected"';
|
||||
if ($folder == $default_style) {
|
||||
$selected = ' selected="selected"';
|
||||
}
|
||||
$templates_select .= '<option value="' . $folder . '"' . $selected . '>' . $name . '</option>';
|
||||
$x++;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
function torrent_auth_check($forum_id, $poster_id)
|
||||
{
|
||||
|
@ -12,7 +14,9 @@ function torrent_auth_check($forum_id, $poster_id)
|
|||
|
||||
if (IS_MOD) {
|
||||
$is_auth = auth(AUTH_MOD, $forum_id, $userdata);
|
||||
if ($is_auth['auth_mod']) return true;
|
||||
if ($is_auth['auth_mod']) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bb_die($lang['NOT_MODERATOR']);
|
||||
|
@ -132,9 +136,15 @@ function tracker_register($topic_id, $mode = '', $tor_status = TOR_NOT_APPROVED,
|
|||
$poster_id = $tor['topic_poster'];
|
||||
|
||||
|
||||
if ($tor['attach_ext_id'] != 8) return torrent_error_exit($lang['NOT_TORRENT']);
|
||||
if (!$tor['allow_reg_tracker']) return torrent_error_exit($lang['REG_NOT_ALLOWED_IN_THIS_FORUM']);
|
||||
if ($tor['tracker_status']) return torrent_error_exit($lang['ALREADY_REG']);
|
||||
if ($tor['attach_ext_id'] != 8) {
|
||||
return torrent_error_exit($lang['NOT_TORRENT']);
|
||||
}
|
||||
if (!$tor['allow_reg_tracker']) {
|
||||
return torrent_error_exit($lang['REG_NOT_ALLOWED_IN_THIS_FORUM']);
|
||||
}
|
||||
if ($tor['tracker_status']) {
|
||||
return torrent_error_exit($lang['ALREADY_REG']);
|
||||
}
|
||||
|
||||
if ($reg_mode != 'mcp_tor_register') {
|
||||
torrent_auth_check($forum_id, $poster_id);
|
||||
|
@ -197,8 +207,9 @@ function tracker_register($topic_id, $mode = '', $tor_status = TOR_NOT_APPROVED,
|
|||
if (!DB()->sql_query($sql)) {
|
||||
$sql_error = DB()->sql_error();
|
||||
|
||||
if ($sql_error['code'] == 1062) // Duplicate entry
|
||||
{
|
||||
if ($sql_error['code'] == 1062) {
|
||||
// Duplicate entry
|
||||
|
||||
return torrent_error_exit($lang['BT_REG_FAIL_SAME_HASH']);
|
||||
}
|
||||
bb_die('Could not register torrent on tracker');
|
||||
|
@ -256,7 +267,9 @@ function change_tor_type($topic_id, $tor_status_gold)
|
|||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
||||
if (!IS_AM) bb_die($lang['ONLY_FOR_MOD']);
|
||||
if (!IS_AM) {
|
||||
bb_die($lang['ONLY_FOR_MOD']);
|
||||
}
|
||||
|
||||
$tor_status_gold = intval($tor_status_gold);
|
||||
$info_hash = null;
|
||||
|
@ -289,7 +302,9 @@ function send_torrent_with_passkey($t_data)
|
|||
if (!isset($row['tor_status'])) {
|
||||
bb_die($lang['PASSKEY_ERR_TOR_NOT_REG']);
|
||||
} elseif ($di->config->get('tor_frozen.' . $row['tor_status'])) {
|
||||
if (!IS_AM) bb_die("Раздача имеет статус: <b>{$lang['TOR_STATUS_NAME'][$row['tor_status']]}</b><br /><br />Скачивание запрещено"); //TODO: перевести
|
||||
if (!IS_AM) {
|
||||
bb_die("Раздача имеет статус: <b>{$lang['TOR_STATUS_NAME'][$row['tor_status']]}</b><br /><br />Скачивание запрещено");
|
||||
} //TODO: перевести
|
||||
}
|
||||
|
||||
$passkey_val = '';
|
||||
|
|
|
@ -1,31 +1,33 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
class upload_common
|
||||
{
|
||||
var $cfg = array(
|
||||
public $cfg = array(
|
||||
'max_size' => 0,
|
||||
'max_width' => 0,
|
||||
'max_height' => 0,
|
||||
'allowed_ext' => array(),
|
||||
'upload_path' => '',
|
||||
);
|
||||
var $file = array(
|
||||
public $file = array(
|
||||
'name' => '',
|
||||
'type' => '',
|
||||
'size' => 0,
|
||||
'tmp_name' => '',
|
||||
'error' => UPLOAD_ERR_NO_FILE,
|
||||
);
|
||||
var $orig_name = '';
|
||||
var $file_path = ''; // Stored file path
|
||||
var $file_ext = '';
|
||||
var $file_ext_id = '';
|
||||
var $file_size = '';
|
||||
var $ext_ids = array(); // array_flip($di->config->get('file_id_ext'))
|
||||
var $errors = array();
|
||||
var $img_types = array(
|
||||
public $orig_name = '';
|
||||
public $file_path = ''; // Stored file path
|
||||
public $file_ext = '';
|
||||
public $file_ext_id = '';
|
||||
public $file_size = '';
|
||||
public $ext_ids = array(); // array_flip($di->config->get('file_id_ext'))
|
||||
public $errors = array();
|
||||
public $img_types = array(
|
||||
1 => 'gif',
|
||||
2 => 'jpg',
|
||||
3 => 'png',
|
||||
|
@ -34,7 +36,7 @@ class upload_common
|
|||
8 => 'tiff',
|
||||
);
|
||||
|
||||
function init($cfg = array(), $post_params = array(), $uploaded_only = true)
|
||||
public function init($cfg = array(), $post_params = array(), $uploaded_only = true)
|
||||
{
|
||||
global $lang;
|
||||
|
||||
|
@ -107,7 +109,7 @@ class upload_common
|
|||
return true;
|
||||
}
|
||||
|
||||
function store($mode = '', $params = array())
|
||||
public function store($mode = '', $params = array())
|
||||
{
|
||||
if ($mode == 'avatar') {
|
||||
delete_avatar($params['user_id'], $this->file_ext_id);
|
||||
|
@ -122,7 +124,7 @@ class upload_common
|
|||
}
|
||||
}
|
||||
|
||||
function _move($file_path)
|
||||
public function _move($file_path)
|
||||
{
|
||||
$dir = dirname($file_path);
|
||||
if (!file_exists($dir)) {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
// !!! $username должен быть предварительно обработан clean_username() !!!
|
||||
function validate_username($username, $check_ban_and_taken = true)
|
||||
|
@ -83,12 +85,13 @@ function validate_email($email, $check_ban_and_taken = true)
|
|||
$email_sql = DB()->escape($email);
|
||||
|
||||
if ($row = DB()->fetch_row("SELECT `user_email` FROM " . BB_USERS . " WHERE user_email = '$email_sql' LIMIT 1")) {
|
||||
if ($row['user_email'] == $userdata['user_email'])
|
||||
if ($row['user_email'] == $userdata['user_email']) {
|
||||
return false;
|
||||
else
|
||||
} else {
|
||||
return $lang['EMAIL_TAKEN'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,18 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_SCRIPT')) define('BB_SCRIPT', 'undefined');
|
||||
if (!defined('BB_CFG_LOADED')) trigger_error('File config.php not loaded', E_USER_ERROR);
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
if (!defined('BB_SCRIPT')) {
|
||||
define('BB_SCRIPT', 'undefined');
|
||||
}
|
||||
if (!defined('BB_CFG_LOADED')) {
|
||||
trigger_error('File config.php not loaded', E_USER_ERROR);
|
||||
}
|
||||
|
||||
if (PHP_VERSION < '5.5') die('TorrentPier requires PHP version 5.5 and above (ZF requirement). Your PHP version is ' . PHP_VERSION);
|
||||
if (PHP_VERSION < '5.5') {
|
||||
die('TorrentPier requires PHP version 5.5 and above (ZF requirement). Your PHP version is ' . PHP_VERSION);
|
||||
}
|
||||
|
||||
/** @var \TorrentPier\Di $di */
|
||||
$di = \TorrentPier\Di::getInstance();
|
||||
|
@ -309,7 +317,9 @@ require(CORE_DIR . 'mysql.php');
|
|||
$user = new user_common();
|
||||
$userdata =& $user->data;
|
||||
|
||||
if (DBG_USER) require(INC_DIR . 'functions_dev.php');
|
||||
if (DBG_USER) {
|
||||
require(INC_DIR . 'functions_dev.php');
|
||||
}
|
||||
|
||||
$html = new html_common();
|
||||
$log_action = new log_action();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $lang;
|
||||
|
||||
|
@ -86,7 +88,9 @@ if ($ulist) {
|
|||
$inline = $block = $short = array();
|
||||
|
||||
foreach ($ulist as $level => $users) {
|
||||
if (empty($users)) continue;
|
||||
if (empty($users)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (count($users) > 200) {
|
||||
$style = 'margin: 3px 0; padding: 2px 4px; border: 1px inset; height: 200px; overflow: auto;';
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue