';
+ $last_cat_id = $row['cat_id'];
+ }
+
+ $forums_list .= '' . (($row['forum_parent']) ? HTML_SF_SPACER : '') . htmlCHR($row['forum_name']) . ' ';
+ }
+ }
+
+ $lastvisited = array(1, 7, 14, 30, 60, 120, 365, 500, 730, 1000);
+ $lastvisited_list = '';
+
+ foreach ($lastvisited as $days) {
+ $lastvisited_list .= '' . $days . ' ' . (($days > 1) ? $lang['DAYS'] : $lang['DAY']) . ' ';
+ }
+
+ $template->assign_vars(array(
+ 'TPL_ADMIN_USER_SEARCH_MAIN' => true,
+
+ 'YEAR' => date("Y"),
+ 'MONTH' => date("m"),
+ 'DAY' => date("d"),
+ 'GROUP_LIST' => $group_list,
+ 'RANK_SELECT_BOX' => $rank_select_box,
+ 'LANGUAGE_LIST' => $language_list,
+ 'TIMEZONE_LIST' => $timezone_list,
+ 'FORUMS_LIST' => $forums_list,
+ 'LASTVISITED_LIST' => $lastvisited_list,
+
+ 'S_SEARCH_ACTION' => 'admin_user_search.php',
+ ));
+} else {
+ $mode = '';
+
+ // validate mode
+ if (isset($_REQUEST['search_username'])) {
+ $mode = 'search_username';
+ } elseif (isset($_REQUEST['search_email'])) {
+ $mode = 'search_email';
+ } elseif (isset($_REQUEST['search_ip'])) {
+ $mode = 'search_ip';
+ } elseif (isset($_REQUEST['search_joindate'])) {
+ $mode = 'search_joindate';
+ } elseif (isset($_REQUEST['search_group'])) {
+ $mode = 'search_group';
+ } elseif (isset($_REQUEST['search_rank'])) {
+ $mode = 'search_rank';
+ } elseif (isset($_REQUEST['search_postcount'])) {
+ $mode = 'search_postcount';
+ } elseif (isset($_REQUEST['search_userfield'])) {
+ $mode = 'search_userfield';
+ } elseif (isset($_REQUEST['search_lastvisited'])) {
+ $mode = 'search_lastvisited';
+ } elseif (isset($_REQUEST['search_language'])) {
+ $mode = 'search_language';
+ } elseif (isset($_REQUEST['search_timezone'])) {
+ $mode = 'search_timezone';
+ } elseif (isset($_REQUEST['search_moderators'])) {
+ $mode = 'search_moderators';
+ } elseif (isset($_REQUEST['search_misc'])) {
+ $mode = 'search_misc';
+ }
+
+ // validate fields (that they exist)
+ switch ($mode) {
+ case 'search_username':
+ $username = $_REQUEST['username'];
+ if (!$username) {
+ bb_die($lang['SEARCH_INVALID_USERNAME']);
+ }
+ break;
+
+ case 'search_email':
+ $email = $_REQUEST['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']);
+ }
+ break;
+
+ case 'search_joindate':
+ $date_type = $_REQUEST['date_type'];
+ $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']);
+ }
+ break;
+
+ case 'search_group':
+ $group_id = $_REQUEST['group_id'];
+ 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']);
+ }
+ 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']);
+ }
+ 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']);
+ }
+ 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']);
+ }
+ break;
+
+ case 'search_language':
+ $language_type = $_REQUEST['language_type'];
+ 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']);
+ }
+ break;
+
+ case 'search_moderators':
+ $moderators_forum = $_REQUEST['moderators_forum'];
+ if (!$moderators_forum) {
+ bb_die($lang['SEARCH_INVALID_MODERATORS']);
+ }
+ break;
+
+ case 'search_misc':
+ $misc = $_REQUEST['misc'];
+ if (!$misc) {
+ bb_die($lang['SEARCH_INVALID']);
+ }
+ break;
+
+ default:
+ bb_die('Invalid mode');
+ }
+
+ $base_url = 'admin_user_search.php?dosearch=true';
+
+ $select_sql = "SELECT u.user_id, u.username, u.user_rank, u.user_email, u.user_posts, u.user_regdate, u.user_level, u.user_active, u.user_lastvisit FROM " . BB_USERS . " AS u";
+
+ $lower_b = 'LOWER(';
+ $lower_e = ')';
+
+ // validate data & prepare sql
+ switch ($mode) {
+ case 'search_username':
+ $base_url .= '&search_username=true&username=' . rawurlencode(stripslashes($username));
+
+ $text = sprintf($lang['SEARCH_FOR_USERNAME'], strip_tags(htmlspecialchars(stripslashes($username))));
+
+ $username = preg_replace('/\*/', '%', trim(strip_tags(strtolower($username))));
+
+ if (strstr($username, '%')) {
+ $op = 'LIKE';
+ } else {
+ $op = '=';
+ }
+
+ 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;
+ break;
+
+ case 'search_email':
+ $base_url .= '&search_email=true&email=' . rawurlencode(stripslashes($email));
+
+ $text = sprintf($lang['SEARCH_FOR_EMAIL'], strip_tags(htmlspecialchars(stripslashes($email))));
+
+ $email = preg_replace('/\*/', '%', trim(strip_tags(strtolower($email))));
+
+ if (strstr($email, '%')) {
+ $op = 'LIKE';
+ } else {
+ $op = '=';
+ }
+
+ 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;
+ break;
+
+ case 'search_ip':
+ $base_url .= '&search_ip=true&ip_address=' . rawurlencode(stripslashes($ip_address));
+
+ $ip_address = trim($ip_address);
+
+ $text = sprintf($lang['SEARCH_FOR_IP'], strip_tags(htmlspecialchars(stripslashes($ip_address))));
+
+ unset($users);
+ $users = array();
+
+ // Let's see if they entered a full valid IPv4 address
+ if (preg_match('/^([0-9]{1,2}|[0-2][0-9]{0,2})(\.([0-9]{1,2}|[0-2][0-9]{0,2})){3}$/', $ip_address)) {
+ $ip = encode_ip($ip_address);
+ $users[] = $ip;
+ } elseif (preg_match('/^([0-9]{1,2}|[0-2][0-9]{0,2})(\.([0-9]{1,2}|[0-2][0-9]{0,2})){0,2}\.\*/', $ip_address)) {
+ $ip_split = explode('.', $ip_address);
+ switch (count($ip_split)) {
+ case 4:
+ $users[] = encode_ip($ip_split[0] . "." . $ip_split[1] . "." . $ip_split[2] . ".255");
+ break;
+ case 3:
+ $users[] = encode_ip($ip_split[0] . "." . $ip_split[1] . ".255.255");
+ break;
+ case 2:
+ $users[] = encode_ip($ip_split[0] . ".255.255.255");
+ break;
+ }
+ } elseif (preg_match('/^([0-9]{1,2}|[0-2][0-9]{0,2})(\.([0-9]{1,2}|[0-2][0-9]{0,2})){3}(\s)*-(\s)*([0-9]{1,2}|[0-2][0-9]{0,2})(\.([0-9]{1,2}|[0-2][0-9]{0,2})){3}$/', $ip_address)) {
+ $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']);
+ }
+ for ($i = $start_range[3]; $i <= $end_range[3]; $i++) {
+ $users[] = encode_ip($start_range[0] . "." . $start_range[1] . "." . $start_range[2] . "." . $i);
+ }
+ } else {
+ bb_die($lang['SEARCH_INVALID_IP']);
+ }
+
+ $ip_in_sql = $ip_like_sql = $ip_like_sql_flylast = $ip_like_sql_flyreg = '';
+
+ foreach ($users as $address) {
+ if (preg_match('/(ff){1,3}$/i', $address)) {
+ if (preg_match('/[0-9a-f]{2}ffffff/i', $address)) {
+ $ip_start = substr($address, 0, 2);
+ } elseif (preg_match('/[0-9a-f]{4}ffff/i', $address)) {
+ $ip_start = substr($address, 0, 4);
+ } elseif (preg_match('/[0-9a-f]{6}ff/i', $address)) {
+ $ip_start = substr($address, 0, 6);
+ }
+ $ip_like_sql_flylast = $ip_like_sql . ($ip_like_sql != '') ? " OR user_last_ip LIKE '" . $ip_start . "%'" : "user_last_ip LIKE '" . $ip_start . "%'";
+ $ip_like_sql_flyreg = $ip_like_sql . ($ip_like_sql != '') ? " OR user_reg_ip LIKE '" . $ip_start . "%'" : "user_reg_ip LIKE '" . $ip_start . "%'";
+ $ip_like_sql .= ($ip_like_sql != '') ? " OR poster_ip LIKE '" . $ip_start . "%'" : "poster_ip LIKE '" . $ip_start . "%'";
+ } else {
+ $ip_in_sql .= ($ip_in_sql == '') ? "'$address'" : ", '$address'";
+ }
+ }
+
+ $where_sql = '';
+ $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');
+ }
+
+ // start search
+ $no_result_search = false;
+ $ip_users_sql = '';
+ $sql = "SELECT poster_id FROM " . BB_POSTS . " WHERE poster_id <> " . GUEST_UID . " AND ($where_sql) GROUP BY poster_id";
+
+ if (!$result = DB()->sql_query($sql)) {
+ bb_die('Could not count users #1');
+ }
+
+ if (DB()->num_rows($result) == 0) {
+ $no_result_search = true;
+ } else {
+ $total_pages['total'] = DB()->num_rows($result);
+ $total_sql = null;
+ $ip_users_sql = '';
+ while ($row = DB()->sql_fetchrow($result)) {
+ $ip_users_sql .= ($ip_users_sql == '') ? $row['poster_id'] : ', ' . $row['poster_id'];
+ }
+ }
+ $where_sql = '';
+ $where_sql .= ($ip_in_sql != '') ? "user_last_ip IN ($ip_in_sql)" : "";
+ $where_sql .= ($ip_like_sql_flylast != '') ? ($where_sql != "") ? " OR $ip_like_sql_flylast" : "$ip_like_sql_flylast" : "";
+ $sql = "SELECT user_id FROM " . BB_USERS . " WHERE user_id <> " . GUEST_UID . " AND ($where_sql) GROUP BY user_id";
+ if (!$result = DB()->sql_query($sql)) {
+ bb_die('Could not count users #2');
+ }
+ if (DB()->num_rows($result) != 0) {
+ if ($no_result_search == true) {
+ $no_result_search = false;
+ }
+ $total_pages['total'] = DB()->num_rows($result);
+ $total_sql = null;
+ while ($row = DB()->sql_fetchrow($result)) {
+ $ip_users_sql .= ($ip_users_sql == '') ? $row['user_id'] : ', ' . $row['user_id'];
+ }
+ }
+ $where_sql = '';
+ $where_sql .= ($ip_in_sql != '') ? "user_reg_ip IN ($ip_in_sql)" : "";
+ $where_sql .= ($ip_like_sql_flyreg != '') ? ($where_sql != "") ? " OR $ip_like_sql_flyreg" : "$ip_like_sql_flyreg" : "";
+ $sql = "SELECT user_id FROM " . BB_USERS . " WHERE user_id <> " . GUEST_UID . " AND ($where_sql) GROUP BY user_id";
+ if (!$result = DB()->sql_query($sql)) {
+ bb_die('Could not count users #3');
+ }
+ if (DB()->num_rows($result) != 0) {
+ if ($no_result_search == true) {
+ $no_result_search = false;
+ }
+ $total_pages['total'] = DB()->num_rows($result);
+ $total_sql = null;
+ while ($row = DB()->sql_fetchrow($result)) {
+ $ip_users_sql .= ($ip_users_sql == '') ? $row['user_id'] : ', ' . $row['user_id'];
+ }
+ }
+ if ($no_result_search == true) {
+ bb_die($lang['SEARCH_NO_RESULTS']);
+ }
+
+ $select_sql .= " WHERE u.user_id IN ($ip_users_sql)";
+ break;
+
+ case 'search_joindate':
+ $base_url .= '&search_joindate=true&date_type=' . rawurlencode($date_type) . '&date_day=' . rawurlencode($date_day) . '&date_month=' . rawurlencode($date_month) . '&date_year=' . rawurlencode(stripslashes($date_year));
+
+ $date_type = trim(strtolower($date_type));
+
+ if ($date_type != 'before' && $date_type != 'after') {
+ bb_die($lang['SEARCH_INVALID_DATE']);
+ }
+
+ $date_day = intval($date_day);
+
+ if (!preg_match('/^([1-9]|[0-2][0-9]|3[0-1])$/', $date_day)) {
+ bb_die($lang['SEARCH_INVALID_DAY']);
+ }
+
+ $date_month = intval($date_month);
+
+ if (!preg_match('/^(0?[1-9]|1[0-2])$/', $date_month)) {
+ bb_die($lang['SEARCH_INVALID_MONTH']);
+ }
+
+ $date_year = intval($date_year);
+
+ if (!preg_match('/^(20[0-9]{2}|19[0-9]{2})$/', $date_year)) {
+ bb_die($lang['SEARCH_INVALID_YEAR']);
+ }
+
+ $text = sprintf($lang['SEARCH_FOR_DATE'], strip_tags(htmlspecialchars(stripslashes($date_type))), $date_year, $date_month, $date_day);
+
+ $time = mktime(0, 0, 0, $date_month, $date_day, $date_year);
+
+ if ($date_type == 'before') {
+ $arg = '<';
+ } else {
+ $arg = '>';
+ }
+
+ $total_sql .= "SELECT COUNT(user_id) AS total FROM " . BB_USERS . " WHERE user_regdate $arg $time AND user_id <> " . GUEST_UID;
+ $select_sql .= " WHERE u.user_regdate $arg $time AND u.user_id <> " . GUEST_UID;
+ break;
+
+ case 'search_group':
+ $group_id = intval($group_id);
+
+ $base_url .= '&search_group=true&group_id=' . rawurlencode($group_id);
+
+ if (!$group_id) {
+ bb_die($lang['SEARCH_INVALID_GROUP']);
+ }
+
+ $sql = "SELECT group_name FROM " . BB_GROUPS . " WHERE group_id = $group_id AND group_single_user = 0";
+
+ if (!$result = DB()->sql_query($sql)) {
+ bb_die('Could not select group data #2');
+ }
+
+ if (DB()->num_rows($result) == 0) {
+ bb_die($lang['SEARCH_INVALID_GROUP']);
+ }
+
+ $group_name = DB()->sql_fetchrow($result);
+
+ $text = sprintf($lang['SEARCH_FOR_GROUP'], strip_tags(htmlspecialchars($group_name['group_name'])));
+
+ $total_sql .= "SELECT COUNT(u.user_id) AS total
+ FROM " . BB_USERS . " AS u, " . BB_USER_GROUP . " AS ug
WHERE u.user_id = ug.user_id
AND ug.group_id = $group_id
- AND u.user_id <> ".GUEST_UID;
+ AND u.user_id <> " . GUEST_UID;
- $select_sql .= ", ".BB_USER_GROUP." AS ug
+ $select_sql .= ", " . BB_USER_GROUP . " AS ug
WHERE u.user_id = ug.user_id
AND ug.group_id = $group_id
- AND u.user_id <> ".GUEST_UID;
- break;
+ AND u.user_id <> " . GUEST_UID;
+ break;
- case 'search_rank':
- $rank_id = intval($rank_id);
+ case 'search_rank':
+ $rank_id = intval($rank_id);
- $base_url .= '&search_rank=true&rank_id='. rawurlencode($rank_id);
+ $base_url .= '&search_rank=true&rank_id=' . rawurlencode($rank_id);
- if (!$rank_id)
- {
- bb_die($lang['SEARCH_INVALID_RANK']);
- }
+ if (!$rank_id) {
+ bb_die($lang['SEARCH_INVALID_RANK']);
+ }
- $sql = "SELECT rank_title FROM ".BB_RANKS." WHERE rank_id = $rank_id AND rank_special = 1";
+ $sql = "SELECT rank_title FROM " . BB_RANKS . " WHERE rank_id = $rank_id AND rank_special = 1";
- if (!$result = DB()->sql_query($sql))
- {
- bb_die('Could not select rank data');
- }
+ if (!$result = DB()->sql_query($sql)) {
+ bb_die('Could not select rank data');
+ }
- if (DB()->num_rows($result)==0)
- {
- bb_die($lang['SEARCH_INVALID_RANK']);
- }
+ if (DB()->num_rows($result) == 0) {
+ bb_die($lang['SEARCH_INVALID_RANK']);
+ }
- $rank_title = DB()->sql_fetchrow($result);
+ $rank_title = DB()->sql_fetchrow($result);
- $text = sprintf($lang['SEARCH_FOR_RANK'], strip_tags(htmlspecialchars($rank_title['rank_title'])));
+ $text = sprintf($lang['SEARCH_FOR_RANK'], strip_tags(htmlspecialchars($rank_title['rank_title'])));
- $total_sql .= "SELECT COUNT(user_id) AS total
- FROM ".BB_USERS."
+ $total_sql .= "SELECT COUNT(user_id) AS total
+ FROM " . BB_USERS . "
WHERE user_rank = $rank_id
- AND user_id <> ".GUEST_UID;
+ AND user_id <> " . GUEST_UID;
- $select_sql .= " WHERE u.user_rank = $rank_id
- AND u.user_id <> ".GUEST_UID;
- break;
+ $select_sql .= " WHERE u.user_rank = $rank_id
+ AND u.user_id <> " . GUEST_UID;
+ break;
- case 'search_postcount':
- $postcount_type = trim(strtolower($postcount_type));
- $postcount_value = trim(strtolower($postcount_value));
+ case 'search_postcount':
+ $postcount_type = trim(strtolower($postcount_type));
+ $postcount_value = trim(strtolower($postcount_value));
- $base_url .= '&search_postcount=true&postcount_type='. rawurlencode($postcount_type) .'&postcount_value='. rawurlencode(stripslashes($postcount_value));
+ $base_url .= '&search_postcount=true&postcount_type=' . rawurlencode($postcount_type) . '&postcount_value=' . rawurlencode(stripslashes($postcount_value));
- switch($postcount_type)
- {
- case 'greater':
- $postcount_value = intval($postcount_value);
+ switch ($postcount_type) {
+ case 'greater':
+ $postcount_value = intval($postcount_value);
- $text = sprintf($lang['SEARCH_FOR_POSTCOUNT_GREATER'], $postcount_value);
+ $text = sprintf($lang['SEARCH_FOR_POSTCOUNT_GREATER'], $postcount_value);
- $total_sql .= "SELECT COUNT(user_id) AS total
- FROM ".BB_USERS."
+ $total_sql .= "SELECT COUNT(user_id) AS total
+ FROM " . BB_USERS . "
WHERE user_posts > $postcount_value
- AND user_id <> ".GUEST_UID;
+ AND user_id <> " . GUEST_UID;
- $select_sql .= " WHERE u.user_posts > $postcount_value
- AND u.user_id <> ".GUEST_UID;
- break;
- case 'lesser':
- $postcount_value = intval($postcount_value);
+ $select_sql .= " WHERE u.user_posts > $postcount_value
+ AND u.user_id <> " . GUEST_UID;
+ break;
+ case 'lesser':
+ $postcount_value = intval($postcount_value);
- $text = sprintf($lang['SEARCH_FOR_POSTCOUNT_LESSER'], $postcount_value);
+ $text = sprintf($lang['SEARCH_FOR_POSTCOUNT_LESSER'], $postcount_value);
- $total_sql .= "SELECT COUNT(user_id) AS total
- FROM ".BB_USERS."
+ $total_sql .= "SELECT COUNT(user_id) AS total
+ FROM " . BB_USERS . "
WHERE user_posts < $postcount_value
- AND user_id <> ".GUEST_UID;
+ AND user_id <> " . GUEST_UID;
- $select_sql .= " WHERE u.user_posts < $postcount_value
- AND u.user_id <> ".GUEST_UID;
- break;
- case 'equals':
- // looking for a -
- if (strstr($postcount_value, '-'))
- {
- $range = preg_split('/[-\s]+/', $postcount_value);
+ $select_sql .= " WHERE u.user_posts < $postcount_value
+ AND u.user_id <> " . GUEST_UID;
+ break;
+ case 'equals':
+ // looking for a -
+ if (strstr($postcount_value, '-')) {
+ $range = preg_split('/[-\s]+/', $postcount_value);
- $range_begin = intval($range[0]);
- $range_end = intval($range[1]);
+ $range_begin = intval($range[0]);
+ $range_end = intval($range[1]);
- if ($range_begin > $range_end)
- {
- bb_die($lang['SEARCH_INVALID_POSTCOUNT']);
- }
+ if ($range_begin > $range_end) {
+ bb_die($lang['SEARCH_INVALID_POSTCOUNT']);
+ }
- $text = sprintf($lang['SEARCH_FOR_POSTCOUNT_RANGE'], $range_begin, $range_end);
+ $text = sprintf($lang['SEARCH_FOR_POSTCOUNT_RANGE'], $range_begin, $range_end);
- $total_sql .= "SELECT COUNT(user_id) AS total
- FROM ".BB_USERS."
+ $total_sql .= "SELECT COUNT(user_id) AS total
+ FROM " . BB_USERS . "
WHERE user_posts >= $range_begin
AND user_posts <= $range_end
- AND user_id <> ".GUEST_UID;
+ AND user_id <> " . GUEST_UID;
- $select_sql .= " WHERE u.user_posts >= $range_begin
+ $select_sql .= " WHERE u.user_posts >= $range_begin
AND u.user_posts <= $range_end
- AND u.user_id <> ".GUEST_UID;
- }
- else
- {
- $postcount_value = intval($postcount_value);
+ AND u.user_id <> " . GUEST_UID;
+ } else {
+ $postcount_value = intval($postcount_value);
- $text = sprintf($lang['SEARCH_FOR_POSTCOUNT_EQUALS'], $postcount_value);
+ $text = sprintf($lang['SEARCH_FOR_POSTCOUNT_EQUALS'], $postcount_value);
- $total_sql .= "SELECT COUNT(user_id) AS total
- FROM ".BB_USERS."
+ $total_sql .= "SELECT COUNT(user_id) AS total
+ FROM " . BB_USERS . "
WHERE user_posts = $postcount_value
- AND user_id <> ".GUEST_UID;
+ AND user_id <> " . GUEST_UID;
- $select_sql .= " WHERE u.user_posts = $postcount_value
- AND u.user_id <> ".GUEST_UID;
- }
- break;
- default:
- bb_die($lang['SEARCH_INVALID']);
- }
- break;
+ $select_sql .= " WHERE u.user_posts = $postcount_value
+ AND u.user_id <> " . GUEST_UID;
+ }
+ break;
+ default:
+ bb_die($lang['SEARCH_INVALID']);
+ }
+ break;
- case 'search_userfield':
- $base_url .= '&search_userfield=true&userfield_type='. rawurlencode($userfield_type) .'&userfield_value='. rawurlencode(stripslashes($userfield_value));
+ case 'search_userfield':
+ $base_url .= '&search_userfield=true&userfield_type=' . rawurlencode($userfield_type) . '&userfield_value=' . rawurlencode(stripslashes($userfield_value));
- $text = strip_tags(htmlspecialchars(stripslashes($userfield_value)));
+ $text = strip_tags(htmlspecialchars(stripslashes($userfield_value)));
- $userfield_value = preg_replace('/\*/', '%', trim(strip_tags(strtolower($userfield_value))));
+ $userfield_value = preg_replace('/\*/', '%', trim(strip_tags(strtolower($userfield_value))));
- if (strstr($userfield_value, '%'))
- {
- $op = 'LIKE';
- }
- else
- {
- $op = '=';
- }
+ if (strstr($userfield_value, '%')) {
+ $op = 'LIKE';
+ } else {
+ $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));
+ $userfield_type = trim(strtolower($userfield_type));
- switch ($userfield_type)
- {
- case 'icq':
- $text = sprintf($lang['SEARCH_FOR_USERFIELD_ICQ'],$text);
- $field = 'user_icq';
- break;
- case 'skype':
- $text = sprintf($lang['SEARCH_FOR_USERFIELD_SKYPE'],$text);
- $field = 'user_skype';
- break;
- case 'twitter':
- $text = sprintf($lang['SEARCH_FOR_USERFIELD_TWITTER'],$text);
- $field = 'user_twitter';
- break;
- case 'website':
- $text = sprintf($lang['SEARCH_FOR_USERFIELD_WEBSITE'],$text);
- $field = 'user_website';
- break;
- case 'location':
- $text = sprintf($lang['SEARCH_FOR_USERFIELD_LOCATION'],$text);
- $field = 'user_from';
- break;
- case 'interests':
- $text = sprintf($lang['SEARCH_FOR_USERFIELD_INTERESTS'],$text);
- $field = 'user_interests';
- break;
- case 'occupation':
- $text = sprintf($lang['SEARCH_FOR_USERFIELD_OCCUPATION'],$text);
- $field = 'user_occ';
- break;
- default:
- bb_die( $lang['SEARCH_INVALID']);
- }
+ switch ($userfield_type) {
+ case 'icq':
+ $text = sprintf($lang['SEARCH_FOR_USERFIELD_ICQ'], $text);
+ $field = 'user_icq';
+ break;
+ case 'skype':
+ $text = sprintf($lang['SEARCH_FOR_USERFIELD_SKYPE'], $text);
+ $field = 'user_skype';
+ break;
+ case 'twitter':
+ $text = sprintf($lang['SEARCH_FOR_USERFIELD_TWITTER'], $text);
+ $field = 'user_twitter';
+ break;
+ case 'website':
+ $text = sprintf($lang['SEARCH_FOR_USERFIELD_WEBSITE'], $text);
+ $field = 'user_website';
+ break;
+ case 'location':
+ $text = sprintf($lang['SEARCH_FOR_USERFIELD_LOCATION'], $text);
+ $field = 'user_from';
+ break;
+ case 'interests':
+ $text = sprintf($lang['SEARCH_FOR_USERFIELD_INTERESTS'], $text);
+ $field = 'user_interests';
+ break;
+ case 'occupation':
+ $text = sprintf($lang['SEARCH_FOR_USERFIELD_OCCUPATION'], $text);
+ $field = 'user_occ';
+ break;
+ default:
+ bb_die($lang['SEARCH_INVALID']);
+ }
- $total_sql .= "SELECT COUNT(user_id) AS total
- FROM ".BB_USERS."
- WHERE {$lower_b}$field{$lower_e} $op '".DB()->escape($userfield_value)."'
- AND user_id <> ".GUEST_UID;
+ $total_sql .= "SELECT COUNT(user_id) AS total
+ FROM " . BB_USERS . "
+ WHERE {$lower_b}$field{$lower_e} $op '" . DB()->escape($userfield_value) . "'
+ AND user_id <> " . GUEST_UID;
- $select_sql .= " WHERE {$lower_b}u.$field{$lower_e} $op '".DB()->escape($userfield_value)."'
- AND u.user_id <> ".GUEST_UID;
- break;
+ $select_sql .= " WHERE {$lower_b}u.$field{$lower_e} $op '" . DB()->escape($userfield_value) . "'
+ AND u.user_id <> " . GUEST_UID;
+ break;
- case 'search_lastvisited':
- $lastvisited_type = trim(strtolower($lastvisited_type));
- $lastvisited_days = intval($lastvisited_days);
+ case 'search_lastvisited':
+ $lastvisited_type = trim(strtolower($lastvisited_type));
+ $lastvisited_days = intval($lastvisited_days);
- $base_url .= '&search_lastvisited=true&lastvisited_type='. rawurlencode(stripslashes($lastvisited_type)) .'&lastvisited_days='. rawurlencode($lastvisited_days);
+ $base_url .= '&search_lastvisited=true&lastvisited_type=' . rawurlencode(stripslashes($lastvisited_type)) . '&lastvisited_days=' . rawurlencode($lastvisited_days);
- $lastvisited_seconds = ( TIMENOW - ( ( ( $lastvisited_days * 24 ) * 60 ) * 60 ) );
+ $lastvisited_seconds = (TIMENOW - ((($lastvisited_days * 24) * 60) * 60));
- switch($lastvisited_type)
- {
- case 'in':
- $text = sprintf($lang['SEARCH_FOR_LASTVISITED_INTHELAST'], $lastvisited_days, ( ( $lastvisited_days > 1 ) ? $lang['DAYS'] : $lang['DAY'] ) );
+ switch ($lastvisited_type) {
+ case 'in':
+ $text = sprintf($lang['SEARCH_FOR_LASTVISITED_INTHELAST'], $lastvisited_days, (($lastvisited_days > 1) ? $lang['DAYS'] : $lang['DAY']));
- $total_sql .= "SELECT COUNT(user_id) AS total
- FROM ".BB_USERS."
+ $total_sql .= "SELECT COUNT(user_id) AS total
+ FROM " . BB_USERS . "
WHERE user_lastvisit >= $lastvisited_seconds
- AND user_id <> ".GUEST_UID;
+ AND user_id <> " . GUEST_UID;
- $select_sql .= " WHERE u.user_lastvisit >= $lastvisited_seconds
- AND u.user_id <> ".GUEST_UID;
- break;
- case 'after':
- $text = sprintf($lang['SEARCH_FOR_LASTVISITED_AFTERTHELAST'], $lastvisited_days, ( ( $lastvisited_days > 1 ) ? $lang['DAYS'] : $lang['DAY'] ));
+ $select_sql .= " WHERE u.user_lastvisit >= $lastvisited_seconds
+ AND u.user_id <> " . GUEST_UID;
+ break;
+ case 'after':
+ $text = sprintf($lang['SEARCH_FOR_LASTVISITED_AFTERTHELAST'], $lastvisited_days, (($lastvisited_days > 1) ? $lang['DAYS'] : $lang['DAY']));
- $total_sql .= "SELECT COUNT(user_id) AS total
- FROM ".BB_USERS."
+ $total_sql .= "SELECT COUNT(user_id) AS total
+ FROM " . BB_USERS . "
WHERE user_lastvisit < $lastvisited_seconds
- AND user_id <> ".GUEST_UID;
+ AND user_id <> " . GUEST_UID;
- $select_sql .= " WHERE u.user_lastvisit < $lastvisited_seconds
- AND u.user_id <> ".GUEST_UID;
+ $select_sql .= " WHERE u.user_lastvisit < $lastvisited_seconds
+ AND u.user_id <> " . GUEST_UID;
- break;
- default:
- bb_die($lang['SEARCH_INVALID_LASTVISITED']);
- }
- break;
+ break;
+ default:
+ bb_die($lang['SEARCH_INVALID_LASTVISITED']);
+ }
+ break;
- case 'search_language':
- $base_url .= '&search_language=true&language_type='. rawurlencode(stripslashes($language_type));
+ case 'search_language':
+ $base_url .= '&search_language=true&language_type=' . rawurlencode(stripslashes($language_type));
- $language_type = trim(strtolower(stripslashes($language_type)));
+ $language_type = trim(strtolower(stripslashes($language_type)));
- if ($language_type == '')
- {
- bb_die($lang['SEARCH_INVALID_LANGUAGE']);
- }
+ if ($language_type == '') {
+ bb_die($lang['SEARCH_INVALID_LANGUAGE']);
+ }
- $text = sprintf($lang['SEARCH_FOR_LANGUAGE'], strip_tags(htmlspecialchars($language_type)));
+ $text = sprintf($lang['SEARCH_FOR_LANGUAGE'], strip_tags(htmlspecialchars($language_type)));
- $total_sql .= "SELECT COUNT(user_id) AS total
- FROM ".BB_USERS."
- WHERE user_lang = '".DB()->escape($language_type)."'
- AND user_id <> ".GUEST_UID;
+ $total_sql .= "SELECT COUNT(user_id) AS total
+ FROM " . BB_USERS . "
+ WHERE user_lang = '" . DB()->escape($language_type) . "'
+ AND user_id <> " . GUEST_UID;
- $select_sql .= " WHERE u.user_lang = '".DB()->escape($language_type)."'
- AND u.user_id <> ".GUEST_UID;
- break;
+ $select_sql .= " WHERE u.user_lang = '" . DB()->escape($language_type) . "'
+ AND u.user_id <> " . GUEST_UID;
+ break;
- case 'search_timezone':
- $base_url .= '&search_timezone=true&timezone_type='. rawurlencode(stripslashes($timezone_type));
- $text = sprintf($lang['SEARCH_FOR_TIMEZONE'], strip_tags(htmlspecialchars(stripslashes($timezone_type))));
+ case 'search_timezone':
+ $base_url .= '&search_timezone=true&timezone_type=' . rawurlencode(stripslashes($timezone_type));
+ $text = sprintf($lang['SEARCH_FOR_TIMEZONE'], strip_tags(htmlspecialchars(stripslashes($timezone_type))));
- $timezone_type = intval($timezone_type);
+ $timezone_type = intval($timezone_type);
- $total_sql .= "SELECT COUNT(user_id) AS total
- FROM ".BB_USERS."
+ $total_sql .= "SELECT COUNT(user_id) AS total
+ FROM " . BB_USERS . "
WHERE user_timezone = $timezone_type
- AND user_id <> ".GUEST_UID;
+ AND user_id <> " . GUEST_UID;
- $select_sql .= " WHERE u.user_timezone = $timezone_type
- AND u.user_id <> ".GUEST_UID;
- break;
+ $select_sql .= " WHERE u.user_timezone = $timezone_type
+ AND u.user_id <> " . GUEST_UID;
+ break;
- case 'search_moderators':
- $base_url .= '&search_moderators=true&moderators_forum='. rawurlencode(stripslashes($moderators_forum));
- $moderators_forum = intval($moderators_forum);
+ case 'search_moderators':
+ $base_url .= '&search_moderators=true&moderators_forum=' . rawurlencode(stripslashes($moderators_forum));
+ $moderators_forum = intval($moderators_forum);
- $sql = "SELECT forum_name FROM ".BB_FORUMS." WHERE forum_id = ".$moderators_forum;
+ $sql = "SELECT forum_name FROM " . BB_FORUMS . " WHERE forum_id = " . $moderators_forum;
- if (!$result = DB()->sql_query($sql))
- {
- bb_die('Could not select forum data');
- }
+ if (!$result = DB()->sql_query($sql)) {
+ bb_die('Could not select forum data');
+ }
- if (DB()->num_rows($result)==0)
- {
- bb_die($lang['SEARCH_INVALID_MODERATORS']);
- }
+ if (DB()->num_rows($result) == 0) {
+ bb_die($lang['SEARCH_INVALID_MODERATORS']);
+ }
- $forum_name = DB()->sql_fetchrow($result);
+ $forum_name = DB()->sql_fetchrow($result);
- $text = sprintf($lang['SEARCH_FOR_MODERATORS'], htmlCHR($forum_name['forum_name']));
+ $text = sprintf($lang['SEARCH_FOR_MODERATORS'], htmlCHR($forum_name['forum_name']));
- $total_sql .= "SELECT COUNT(DISTINCT u.user_id) AS total
- FROM ".BB_USERS." AS u, ".BB_GROUPS." AS g, ".BB_USER_GROUP." AS ug, ".BB_AUTH_ACCESS." AS aa
+ $total_sql .= "SELECT COUNT(DISTINCT u.user_id) AS total
+ FROM " . BB_USERS . " AS u, " . BB_GROUPS . " AS g, " . BB_USER_GROUP . " AS ug, " . BB_AUTH_ACCESS . " AS aa
WHERE u.user_id = ug.user_id
AND ug.group_id = g.group_id
AND g.group_id = aa.group_id
- AND aa.forum_id = ". $moderators_forum ."
- AND aa.forum_perm & ". BF_AUTH_MOD ."
- AND u.user_id <> ".GUEST_UID;
+ AND aa.forum_id = " . $moderators_forum . "
+ AND aa.forum_perm & " . BF_AUTH_MOD . "
+ AND u.user_id <> " . GUEST_UID;
- $select_sql .= ", ".BB_GROUPS." AS g, ".BB_USER_GROUP." AS ug, ".BB_AUTH_ACCESS." AS aa
+ $select_sql .= ", " . BB_GROUPS . " AS g, " . BB_USER_GROUP . " AS ug, " . BB_AUTH_ACCESS . " AS aa
WHERE u.user_id = ug.user_id
AND ug.group_id = g.group_id
AND g.group_id = aa.group_id
- AND aa.forum_id = ". $moderators_forum ."
- AND aa.forum_perm & ". BF_AUTH_MOD ."
- AND u.user_id <> ".GUEST_UID."
+ AND aa.forum_id = " . $moderators_forum . "
+ AND aa.forum_perm & " . BF_AUTH_MOD . "
+ AND u.user_id <> " . GUEST_UID . "
GROUP BY u.user_id, u.username, u.user_email, u.user_posts, u.user_regdate, u.user_level, u.user_active, u.user_lastvisit";
- break;
+ break;
- case 'search_misc':
- default:
- $misc = trim(strtolower($misc));
+ case 'search_misc':
+ default:
+ $misc = trim(strtolower($misc));
- $base_url .= '&search_misc=true&misc='. rawurlencode(stripslashes($misc));
+ $base_url .= '&search_misc=true&misc=' . rawurlencode(stripslashes($misc));
- switch ($misc)
- {
- case 'admins':
- $text = $lang['SEARCH_FOR_ADMINS'];
+ switch ($misc) {
+ case 'admins':
+ $text = $lang['SEARCH_FOR_ADMINS'];
- $total_sql .= "SELECT COUNT(user_id) AS total
- FROM ".BB_USERS."
- WHERE user_level = ".ADMIN."
- AND user_id <> ".GUEST_UID;
+ $total_sql .= "SELECT COUNT(user_id) AS total
+ FROM " . BB_USERS . "
+ WHERE user_level = " . ADMIN . "
+ AND user_id <> " . GUEST_UID;
- $select_sql .= " WHERE u.user_level = ".ADMIN."
- AND u.user_id <> ".GUEST_UID;
- break;
- case 'mods':
- $text = $lang['SEARCH_FOR_MODS'];
+ $select_sql .= " WHERE u.user_level = " . ADMIN . "
+ AND u.user_id <> " . GUEST_UID;
+ break;
+ case 'mods':
+ $text = $lang['SEARCH_FOR_MODS'];
- $total_sql .= "SELECT COUNT(user_id) AS total
- FROM ".BB_USERS."
- WHERE user_level = ".MOD."
- AND user_id <> ".GUEST_UID;
+ $total_sql .= "SELECT COUNT(user_id) AS total
+ FROM " . BB_USERS . "
+ WHERE user_level = " . MOD . "
+ AND user_id <> " . GUEST_UID;
- $select_sql .= " WHERE u.user_level = ".MOD."
- AND u.user_id <> ".GUEST_UID;
- break;
- case 'banned':
- $text = $lang['SEARCH_FOR_BANNED'];
+ $select_sql .= " WHERE u.user_level = " . MOD . "
+ AND u.user_id <> " . GUEST_UID;
+ break;
+ case 'banned':
+ $text = $lang['SEARCH_FOR_BANNED'];
- $total_sql .= "SELECT COUNT(u.user_id) AS total
- FROM ".BB_USERS." AS u, ".BB_BANLIST." AS b
+ $total_sql .= "SELECT COUNT(u.user_id) AS total
+ FROM " . BB_USERS . " AS u, " . BB_BANLIST . " AS b
WHERE u.user_id = b.ban_userid
- AND u.user_id <> ".GUEST_UID;
+ AND u.user_id <> " . GUEST_UID;
- $select_sql .= ", ".BB_BANLIST." AS b
+ $select_sql .= ", " . BB_BANLIST . " AS b
WHERE u.user_id = b.ban_userid
- AND u.user_id <> ".GUEST_UID;
+ AND u.user_id <> " . GUEST_UID;
- break;
- case 'disabled':
- $text = $lang['SEARCH_FOR_DISABLED'];
+ break;
+ case 'disabled':
+ $text = $lang['SEARCH_FOR_DISABLED'];
- $total_sql .= "SELECT COUNT(user_id) AS total
- FROM ".BB_USERS."
+ $total_sql .= "SELECT COUNT(user_id) AS total
+ FROM " . BB_USERS . "
WHERE user_active = 0
- AND user_id <> ".GUEST_UID;
+ AND user_id <> " . GUEST_UID;
- $select_sql .= " WHERE u.user_active = 0
- AND u.user_id <> ".GUEST_UID;
+ $select_sql .= " WHERE u.user_active = 0
+ AND u.user_id <> " . GUEST_UID;
- break;
- default:
- bb_die($lang['SEARCH_INVALID']);
- }
- }
+ break;
+ default:
+ bb_die($lang['SEARCH_INVALID']);
+ }
+ }
- $select_sql .= " ORDER BY ";
+ $select_sql .= " ORDER BY ";
- switch (strtolower(@$_GET['sort']))
- {
- case 'regdate':
- $sort = 'regdate';
- $select_sql .= 'u.user_regdate';
- break;
+ switch (strtolower(@$_GET['sort'])) {
+ case 'regdate':
+ $sort = 'regdate';
+ $select_sql .= 'u.user_regdate';
+ break;
- case 'posts':
- $sort = 'posts';
- $select_sql .= 'u.user_posts';
- break;
+ case 'posts':
+ $sort = 'posts';
+ $select_sql .= 'u.user_posts';
+ break;
- case 'user_email':
- $sort = 'user_email';
- $select_sql .= 'u.user_email';
- break;
+ case 'user_email':
+ $sort = 'user_email';
+ $select_sql .= 'u.user_email';
+ break;
- case 'lastvisit':
- $sort = 'lastvisit';
- $select_sql .= 'u.user_lastvisit';
- break;
+ case 'lastvisit':
+ $sort = 'lastvisit';
+ $select_sql .= 'u.user_lastvisit';
+ break;
- case 'username':
- default:
- $sort = 'username';
- $select_sql .= 'u.username';
- }
+ case 'username':
+ default:
+ $sort = 'username';
+ $select_sql .= 'u.username';
+ }
- switch (@$_GET['order'])
- {
- case 'DESC':
- $order = 'DESC';
- $o_order = 'ASC';
- break;
+ switch (@$_GET['order']) {
+ case 'DESC':
+ $order = 'DESC';
+ $o_order = 'ASC';
+ break;
- default:
- $o_order = 'DESC';
- $order = 'ASC';
- }
+ default:
+ $o_order = 'DESC';
+ $order = 'ASC';
+ }
- $select_sql .= " $order";
+ $select_sql .= " $order";
- $page = ( isset($_GET['page']) ) ? intval($_GET['page']) : intval(trim(@$_POST['page']));
+ $page = (isset($_GET['page'])) ? intval($_GET['page']) : intval(trim(@$_POST['page']));
- if ($page < 1)
- {
- $page = 1;
- }
+ if ($page < 1) {
+ $page = 1;
+ }
- if ($page == 1)
- {
- $offset = 0;
- }
- else
- {
- $offset = ( ($page - 1) * $bb_cfg['topics_per_page']);
- }
+ if ($page == 1) {
+ $offset = 0;
+ } else {
+ $offset = (($page - 1) * $bb_cfg['topics_per_page']);
+ }
- $limit = "LIMIT $offset, ".$bb_cfg['topics_per_page'];
+ $limit = "LIMIT $offset, " . $bb_cfg['topics_per_page'];
- $select_sql .= " $limit";
+ $select_sql .= " $limit";
- if (!is_null($total_sql))
- {
- if (!$result = DB()->sql_query($total_sql))
- {
- bb_die('Could not count users');
- }
+ if (!is_null($total_sql)) {
+ if (!$result = DB()->sql_query($total_sql)) {
+ bb_die('Could not count users');
+ }
- $total_pages = DB()->sql_fetchrow($result);
+ $total_pages = DB()->sql_fetchrow($result);
- if ($total_pages['total'] == 0)
- {
- bb_die($lang['SEARCH_NO_RESULTS']);
- }
- }
- $num_pages = ceil( ( $total_pages['total'] / $bb_cfg['topics_per_page'] ) );
+ if ($total_pages['total'] == 0) {
+ bb_die($lang['SEARCH_NO_RESULTS']);
+ }
+ }
+ $num_pages = ceil(($total_pages['total'] / $bb_cfg['topics_per_page']));
- $pagination = '';
+ $pagination = '';
- if ($page > 1)
- {
- $pagination .= ''. $lang['PREVIOUS'] .' ';
- }
- if ($page < $num_pages)
- {
- $pagination .= ( $pagination == '' ) ? ''.$lang['NEXT'].' ' : ' | '.$lang['NEXT'].' ';
- }
- if ($num_pages > 2)
- {
- $pagination .= ' ';
- }
- $template->assign_vars(array(
- 'TPL_ADMIN_USER_SEARCH_RESULTS' => true,
+ if ($page > 1) {
+ $pagination .= '' . $lang['PREVIOUS'] . ' ';
+ }
+ if ($page < $num_pages) {
+ $pagination .= ($pagination == '') ? '' . $lang['NEXT'] . ' ' : ' | ' . $lang['NEXT'] . ' ';
+ }
+ if ($num_pages > 2) {
+ $pagination .= ' ';
+ }
+ $template->assign_vars(array(
+ 'TPL_ADMIN_USER_SEARCH_RESULTS' => true,
- 'PAGE_NUMBER' => sprintf($lang['PAGE_OF'], $page, $num_pages),
- 'PAGINATION' => $pagination,
- 'NEW_SEARCH' => sprintf($lang['SEARCH_USERS_NEW'],$text, $total_pages['total'], 'admin_user_search.php'),
+ 'PAGE_NUMBER' => sprintf($lang['PAGE_OF'], $page, $num_pages),
+ 'PAGINATION' => $pagination,
+ 'NEW_SEARCH' => sprintf($lang['SEARCH_USERS_NEW'], $text, $total_pages['total'], 'admin_user_search.php'),
- 'U_USERNAME' => ($sort == 'username') ? "$base_url&sort=$sort&order=$o_order" : "$base_url&sort=username&order=$order",
- 'U_EMAIL' => ($sort == 'user_email') ? "$base_url&sort=$sort&order=$o_order" : "$base_url&sort=user_email&order=$order",
- 'U_POSTS' => ($sort == 'posts') ? "$base_url&sort=$sort&order=$o_order" : "$base_url&sort=posts&order=$order",
- 'U_JOINDATE' => ($sort == 'regdate') ? "$base_url&sort=$sort&order=$o_order" : "$base_url&sort=regdate&order=$order",
- 'U_LASTVISIT' => ($sort == 'lastvisit') ? "$base_url&sort=$sort&order=$o_order" : "$base_url&sort=lastvisit&order=$order",
+ 'U_USERNAME' => ($sort == 'username') ? "$base_url&sort=$sort&order=$o_order" : "$base_url&sort=username&order=$order",
+ 'U_EMAIL' => ($sort == 'user_email') ? "$base_url&sort=$sort&order=$o_order" : "$base_url&sort=user_email&order=$order",
+ 'U_POSTS' => ($sort == 'posts') ? "$base_url&sort=$sort&order=$o_order" : "$base_url&sort=posts&order=$order",
+ 'U_JOINDATE' => ($sort == 'regdate') ? "$base_url&sort=$sort&order=$o_order" : "$base_url&sort=regdate&order=$order",
+ 'U_LASTVISIT' => ($sort == 'lastvisit') ? "$base_url&sort=$sort&order=$o_order" : "$base_url&sort=lastvisit&order=$order",
- 'S_POST_ACTION' => "$base_url&sort=$sort&order=$order"
- ));
+ 'S_POST_ACTION' => "$base_url&sort=$sort&order=$order"
+ ));
- if (!$result = DB()->sql_query($select_sql))
- {
- bb_die('Could not select user data');
- }
+ if (!$result = DB()->sql_query($select_sql)) {
+ bb_die('Could not select user data');
+ }
- $rowset = DB()->sql_fetchrowset($result);
+ $rowset = DB()->sql_fetchrowset($result);
- $users_sql = '';
+ $users_sql = '';
- foreach ($rowset as $array)
- {
- $users_sql .= ( $users_sql == '' ) ? $array['user_id'] : ', '.$array['user_id'];
- }
+ foreach ($rowset as $array) {
+ $users_sql .= ($users_sql == '') ? $array['user_id'] : ', ' . $array['user_id'];
+ }
- $sql = "SELECT ban_userid AS user_id FROM ". BB_BANLIST ." WHERE ban_userid IN ($users_sql)";
+ $sql = "SELECT ban_userid AS user_id FROM " . BB_BANLIST . " WHERE ban_userid IN ($users_sql)";
- if (!$result = DB()->sql_query($sql))
- {
- bb_die('Could not select banned data');
- }
+ if (!$result = DB()->sql_query($sql)) {
+ bb_die('Could not select banned data');
+ }
- unset($banned);
+ unset($banned);
- $banned = array();
+ $banned = array();
- while ($row = DB()->sql_fetchrow($result))
- {
- $banned[$row['user_id']] = true;
- }
+ while ($row = DB()->sql_fetchrow($result)) {
+ $banned[$row['user_id']] = true;
+ }
- for ($i = 0; $i < count($rowset); $i++)
- {
- $row_class = !($i % 2) ? 'row1' : 'row2';
+ for ($i = 0; $i < count($rowset); $i++) {
+ $row_class = !($i % 2) ? 'row1' : 'row2';
- $template->assign_block_vars('userrow', array(
- 'ROW_CLASS' => $row_class,
- 'USER' => profile_url($rowset[$i]),
- 'EMAIL' => $rowset[$i]['user_email'],
- 'JOINDATE' => bb_date($rowset[$i]['user_regdate']),
- 'LASTVISIT' => bb_date($rowset[$i]['user_lastvisit']),
- 'POSTS' => $rowset[$i]['user_posts'],
- 'BAN' => ( ( !isset($banned[$rowset[$i]['user_id']]) ) ? $lang['NOT_BANNED'] : $lang['BANNED'] ),
- 'ABLED' => ( ( $rowset[$i]['user_active'] ) ? $lang['ENABLED'] : $lang['DISABLED'] ),
+ $template->assign_block_vars('userrow', array(
+ 'ROW_CLASS' => $row_class,
+ 'USER' => profile_url($rowset[$i]),
+ 'EMAIL' => $rowset[$i]['user_email'],
+ 'JOINDATE' => bb_date($rowset[$i]['user_regdate']),
+ 'LASTVISIT' => bb_date($rowset[$i]['user_lastvisit']),
+ 'POSTS' => $rowset[$i]['user_posts'],
+ 'BAN' => ((!isset($banned[$rowset[$i]['user_id']])) ? $lang['NOT_BANNED'] : $lang['BANNED']),
+ 'ABLED' => (($rowset[$i]['user_active']) ? $lang['ENABLED'] : $lang['DISABLED']),
- 'U_VIEWPOSTS' => "../search.php?search_author=1&uid={$rowset[$i]['user_id']}",
- 'U_MANAGE' => '../profile.php?mode=editprofile&'. POST_USERS_URL .'='.$rowset[$i]['user_id'].'&admin=1',
- 'U_PERMISSIONS' => 'admin_ug_auth.php?mode=user&'. POST_USERS_URL .'='. $rowset[$i]['user_id'],
- ));
- }
+ 'U_VIEWPOSTS' => "../search.php?search_author=1&uid={$rowset[$i]['user_id']}",
+ 'U_MANAGE' => '../profile.php?mode=editprofile&' . POST_USERS_URL . '=' . $rowset[$i]['user_id'] . '&admin=1',
+ 'U_PERMISSIONS' => 'admin_ug_auth.php?mode=user&' . POST_USERS_URL . '=' . $rowset[$i]['user_id'],
+ ));
+ }
}
-print_page('admin_user_search.tpl', 'admin');
\ No newline at end of file
+print_page('admin_user_search.tpl', 'admin');
diff --git a/admin/admin_words.php b/admin/admin_words.php
index e46de3025..23891efe0 100644
--- a/admin/admin_words.php
+++ b/admin/admin_words.php
@@ -1,157 +1,151 @@
($bb_cfg[\'use_word_censor\'] in config.php)');
+if (!$bb_cfg['use_word_censor']) {
+ bb_die('Word censor disabled ($bb_cfg[\'use_word_censor\'] in config.php)');
}
$mode = request_var('mode', '');
$mode = htmlspecialchars($mode);
-if (isset($_POST['add']))
-{
- $mode = 'add';
-}
-else if (isset($_POST['save']))
-{
- $mode = 'save';
+if (isset($_POST['add'])) {
+ $mode = 'add';
+} elseif (isset($_POST['save'])) {
+ $mode = 'save';
}
-if ($mode != '')
-{
- if ($mode == 'edit' || $mode == 'add')
- {
- $word_id = intval(request_var('id', 0));
+if ($mode != '') {
+ if ($mode == 'edit' || $mode == 'add') {
+ $word_id = intval(request_var('id', 0));
- $s_hidden_fields = $word = $replacement = '';
+ $s_hidden_fields = $word = $replacement = '';
- if ($mode == 'edit')
- {
- if ($word_id)
- {
- $sql = "SELECT * FROM " . BB_WORDS . " WHERE word_id = $word_id";
- if (!$result = DB()->sql_query($sql))
- {
- bb_die('Could not query words table #1');
- }
+ if ($mode == 'edit') {
+ if ($word_id) {
+ $sql = "SELECT * FROM " . BB_WORDS . " WHERE word_id = $word_id";
+ if (!$result = DB()->sql_query($sql)) {
+ bb_die('Could not query words table #1');
+ }
- $word_info = DB()->sql_fetchrow($result);
- $s_hidden_fields .= ' ';
- $word = $word_info['word'];
- $replacement = $word_info['replacement'];
- }
- else
- {
- bb_die($lang['NO_WORD_SELECTED']);
- }
- }
+ $word_info = DB()->sql_fetchrow($result);
+ $s_hidden_fields .= ' ';
+ $word = $word_info['word'];
+ $replacement = $word_info['replacement'];
+ } else {
+ bb_die($lang['NO_WORD_SELECTED']);
+ }
+ }
- $template->assign_vars(array(
- 'TPL_ADMIN_WORDS_EDIT' => true,
- 'WORD' => $word,
- 'REPLACEMENT' => $replacement,
- 'S_WORDS_ACTION' => 'admin_words.php',
- 'S_HIDDEN_FIELDS' => $s_hidden_fields,
- ));
- }
- else if ($mode == 'save')
- {
- $word_id = intval(request_var('id', 0));
- $word = trim(request_var('word', ''));
- $replacement = trim(request_var('replacement', ''));
+ $template->assign_vars(array(
+ 'TPL_ADMIN_WORDS_EDIT' => true,
+ 'WORD' => $word,
+ 'REPLACEMENT' => $replacement,
+ 'S_WORDS_ACTION' => 'admin_words.php',
+ 'S_HIDDEN_FIELDS' => $s_hidden_fields,
+ ));
+ } elseif ($mode == 'save') {
+ $word_id = intval(request_var('id', 0));
+ $word = trim(request_var('word', ''));
+ $replacement = trim(request_var('replacement', ''));
- if ($word == '' || $replacement == '')
- {
- bb_die($lang['MUST_ENTER_WORD']);
- }
+ if ($word == '' || $replacement == '') {
+ bb_die($lang['MUST_ENTER_WORD']);
+ }
- if ($word_id)
- {
- $sql = "UPDATE " . BB_WORDS . "
+ if ($word_id) {
+ $sql = "UPDATE " . BB_WORDS . "
SET word = '" . DB()->escape($word) . "', replacement = '" . DB()->escape($replacement) . "'
WHERE word_id = $word_id";
- $message = $lang['WORD_UPDATED'];
- }
- else
- {
- $sql = "INSERT INTO " . BB_WORDS . " (word, replacement)
+ $message = $lang['WORD_UPDATED'];
+ } else {
+ $sql = "INSERT INTO " . BB_WORDS . " (word, replacement)
VALUES ('" . DB()->escape($word) . "', '" . DB()->escape($replacement) . "')";
- $message = $lang['WORD_ADDED'];
- }
+ $message = $lang['WORD_ADDED'];
+ }
- if (!$result = DB()->sql_query($sql))
- {
- bb_die('Could not insert data into words table');
- }
+ if (!$result = DB()->sql_query($sql)) {
+ bb_die('Could not insert data into words table');
+ }
- CACHE('bb_cache')->rm('censored');
- $message .= ' ' . sprintf($lang['CLICK_RETURN_WORDADMIN'], '', ' ') . ' ' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', ' ');
+ CACHE('bb_cache')->rm('censored');
+ $message .= ' ' . sprintf($lang['CLICK_RETURN_WORDADMIN'], '', ' ') . ' ' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', ' ');
- bb_die($message);
- }
- else if ($mode == 'delete')
- {
- $word_id = intval(request_var('id', 0));
+ bb_die($message);
+ } elseif ($mode == 'delete') {
+ $word_id = intval(request_var('id', 0));
- if ($word_id)
- {
- $sql = "DELETE FROM " . BB_WORDS . " WHERE word_id = $word_id";
+ if ($word_id) {
+ $sql = "DELETE FROM " . BB_WORDS . " WHERE word_id = $word_id";
- if (!$result = DB()->sql_query($sql))
- {
- bb_die('Could not remove data from words table');
- }
+ if (!$result = DB()->sql_query($sql)) {
+ bb_die('Could not remove data from words table');
+ }
- CACHE('bb_cache')->rm('censored');
+ CACHE('bb_cache')->rm('censored');
- bb_die($lang['WORD_REMOVED'] . ' ' . sprintf($lang['CLICK_RETURN_WORDADMIN'], '', ' ') . ' ' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', ' '));
- }
- else
- {
- bb_die($lang['NO_WORD_SELECTED']);
- }
- }
-}
-else
-{
- $sql = "SELECT * FROM " . BB_WORDS . " ORDER BY word";
- if (!$result = DB()->sql_query($sql))
- {
- bb_die('Could not query words table #2');
- }
+ bb_die($lang['WORD_REMOVED'] . ' ' . sprintf($lang['CLICK_RETURN_WORDADMIN'], '', ' ') . ' ' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', ' '));
+ } else {
+ bb_die($lang['NO_WORD_SELECTED']);
+ }
+ }
+} else {
+ $sql = "SELECT * FROM " . BB_WORDS . " ORDER BY word";
+ if (!$result = DB()->sql_query($sql)) {
+ bb_die('Could not query words table #2');
+ }
- $word_rows = DB()->sql_fetchrowset($result);
- $word_count = count($word_rows);
+ $word_rows = DB()->sql_fetchrowset($result);
+ $word_count = count($word_rows);
- $template->assign_vars(array(
- 'TPL_ADMIN_WORDS_LIST' => true,
- 'S_WORDS_ACTION' => 'admin_words.php',
- 'S_HIDDEN_FIELDS' => '',
- ));
+ $template->assign_vars(array(
+ 'TPL_ADMIN_WORDS_LIST' => true,
+ 'S_WORDS_ACTION' => 'admin_words.php',
+ 'S_HIDDEN_FIELDS' => '',
+ ));
- for ($i = 0; $i < $word_count; $i++)
- {
- $word = $word_rows[$i]['word'];
- $replacement = $word_rows[$i]['replacement'];
- $word_id = $word_rows[$i]['word_id'];
+ for ($i = 0; $i < $word_count; $i++) {
+ $word = $word_rows[$i]['word'];
+ $replacement = $word_rows[$i]['replacement'];
+ $word_id = $word_rows[$i]['word_id'];
- $row_class = !($i % 2) ? 'row1' : 'row2';
+ $row_class = !($i % 2) ? 'row1' : 'row2';
- $template->assign_block_vars('words', array(
- 'ROW_CLASS' => $row_class,
- 'WORD' => $word,
- 'REPLACEMENT' => $replacement,
- 'U_WORD_EDIT' => "admin_words.php?mode=edit&id=$word_id",
- 'U_WORD_DELETE' => "admin_words.php?mode=delete&id=$word_id",
- ));
- }
+ $template->assign_block_vars('words', array(
+ 'ROW_CLASS' => $row_class,
+ 'WORD' => $word,
+ 'REPLACEMENT' => $replacement,
+ 'U_WORD_EDIT' => "admin_words.php?mode=edit&id=$word_id",
+ 'U_WORD_DELETE' => "admin_words.php?mode=delete&id=$word_id",
+ ));
+ }
}
-print_page('admin_words.tpl', 'admin');
\ No newline at end of file
+print_page('admin_words.tpl', 'admin');
diff --git a/admin/index.php b/admin/index.php
index 33c3cd5f7..5e838b41a 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -1,292 +1,272 @@
get('admin_module'))
- {
- $dir = @opendir('.');
- $setmodules = 1;
- while ($file = @readdir($dir))
- {
- if (preg_match('/^admin_.*?\.php$/', $file))
- {
- include('./' . $file);
- }
- }
- unset($setmodules);
- @closedir($dir);
- CACHE('bb_cache')->set('admin_module', $module, 600);
- }
+if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
+ if (!$module = CACHE('bb_cache')->get('admin_module')) {
+ $dir = @opendir('.');
+ $setmodules = 1;
+ while ($file = @readdir($dir)) {
+ if (preg_match('/^admin_.*?\.php$/', $file)) {
+ include('./' . $file);
+ }
+ }
+ unset($setmodules);
+ @closedir($dir);
+ CACHE('bb_cache')->set('admin_module', $module, 600);
+ }
- $template->assign_vars(array(
- 'TPL_ADMIN_NAVIGATE' => true,
- 'U_FORUM_INDEX' => '../index.php',
- 'U_ADMIN_INDEX' => 'index.php?pane=right',
- ));
+ $template->assign_vars(array(
+ 'TPL_ADMIN_NAVIGATE' => true,
+ 'U_FORUM_INDEX' => '../index.php',
+ 'U_ADMIN_INDEX' => 'index.php?pane=right',
+ ));
- ksort($module);
+ ksort($module);
- while (list($cat, $action_array) = each($module))
- {
- $cat = (!empty($lang[$cat])) ? $lang[$cat] : preg_replace('/_/', ' ', $cat);
+ while (list($cat, $action_array) = each($module)) {
+ $cat = (!empty($lang[$cat])) ? $lang[$cat] : preg_replace('/_/', ' ', $cat);
- $template->assign_block_vars('catrow', array(
- 'ADMIN_CATEGORY' => $cat,
- ));
+ $template->assign_block_vars('catrow', array(
+ 'ADMIN_CATEGORY' => $cat,
+ ));
- ksort($action_array);
+ ksort($action_array);
- $row_count = 0;
- while (list($action, $file) = each($action_array))
- {
- $row_class = !($row_count % 2) ? 'row1' : 'row2';
+ $row_count = 0;
+ while (list($action, $file) = each($action_array)) {
+ $row_class = !($row_count % 2) ? 'row1' : 'row2';
- $action = (!empty($lang[$action])) ? $lang[$action] : preg_replace('/_/', ' ', $action);
+ $action = (!empty($lang[$action])) ? $lang[$action] : preg_replace('/_/', ' ', $action);
- $template->assign_block_vars('catrow.modulerow', array(
- 'ROW_CLASS' => $row_class,
- 'ADMIN_MODULE' => $action,
- 'U_ADMIN_MODULE' => $file,
- ));
- $row_count++;
- }
- }
-}
-elseif (isset($_GET['pane']) && $_GET['pane'] == 'right')
-{
- $template->assign_vars(array(
- 'TPL_ADMIN_MAIN' => true,
- 'ADMIN_LOCK' => ($bb_cfg['board_disable']) ? true : false,
- 'ADMIN_LOCK_CRON' => (file_exists(BB_DISABLED)) ? true :false,
- ));
+ $template->assign_block_vars('catrow.modulerow', array(
+ 'ROW_CLASS' => $row_class,
+ 'ADMIN_MODULE' => $action,
+ 'U_ADMIN_MODULE' => $file,
+ ));
+ $row_count++;
+ }
+ }
+} elseif (isset($_GET['pane']) && $_GET['pane'] == 'right') {
+ $template->assign_vars(array(
+ 'TPL_ADMIN_MAIN' => true,
+ 'ADMIN_LOCK' => ($bb_cfg['board_disable']) ? true : false,
+ 'ADMIN_LOCK_CRON' => (file_exists(BB_DISABLED)) ? true : false,
+ ));
- // Get forum statistics
- $total_posts = get_db_stat('postcount');
- $total_users = get_db_stat('usercount');
- $total_topics = get_db_stat('topiccount');
- $start_date = bb_date($bb_cfg['board_startdate']);
- $boarddays = (TIMENOW - $bb_cfg['board_startdate']) / 86400;
+ // Get forum statistics
+ $total_posts = get_db_stat('postcount');
+ $total_users = get_db_stat('usercount');
+ $total_topics = get_db_stat('topiccount');
+ $start_date = bb_date($bb_cfg['board_startdate']);
+ $boarddays = (TIMENOW - $bb_cfg['board_startdate']) / 86400;
- $posts_per_day = sprintf('%.2f', $total_posts / $boarddays);
- $topics_per_day = sprintf('%.2f', $total_topics / $boarddays);
- $users_per_day = sprintf('%.2f', $total_users / $boarddays);
+ $posts_per_day = sprintf('%.2f', $total_posts / $boarddays);
+ $topics_per_day = sprintf('%.2f', $total_topics / $boarddays);
+ $users_per_day = sprintf('%.2f', $total_users / $boarddays);
- $avatar_dir_size = 0;
+ $avatar_dir_size = 0;
- if ($avatar_dir = @opendir(BB_ROOT . $bb_cfg['avatar_path']))
- {
- while( $file = @readdir($avatar_dir) )
- {
- if( $file != '.' && $file != '..' )
- {
- $avatar_dir_size += @filesize(BB_ROOT . $bb_cfg['avatar_path'] . '/' . $file);
- }
- }
- @closedir($avatar_dir);
+ if ($avatar_dir = @opendir(BB_ROOT . $bb_cfg['avatar_path'])) {
+ while ($file = @readdir($avatar_dir)) {
+ if ($file != '.' && $file != '..') {
+ $avatar_dir_size += @filesize(BB_ROOT . $bb_cfg['avatar_path'] . '/' . $file);
+ }
+ }
+ @closedir($avatar_dir);
- $avatar_dir_size = humn_size($avatar_dir_size);
- }
- else
- {
- $avatar_dir_size = $lang['NOT_AVAILABLE'];
- }
+ $avatar_dir_size = humn_size($avatar_dir_size);
+ } else {
+ $avatar_dir_size = $lang['NOT_AVAILABLE'];
+ }
- if (intval($posts_per_day) > $total_posts)
- {
- $posts_per_day = $total_posts;
- }
+ if (intval($posts_per_day) > $total_posts) {
+ $posts_per_day = $total_posts;
+ }
- if (intval($topics_per_day) > $total_topics)
- {
- $topics_per_day = $total_topics;
- }
+ if (intval($topics_per_day) > $total_topics) {
+ $topics_per_day = $total_topics;
+ }
- if ($users_per_day > $total_users)
- {
- $users_per_day = $total_users;
- }
+ if ($users_per_day > $total_users) {
+ $users_per_day = $total_users;
+ }
- // DB size ... MySQL only
- $sql = "SELECT VERSION() AS mysql_version";
- if ($result = DB()->sql_query($sql))
- {
- $row = DB()->sql_fetchrow($result);
- $version = $row['mysql_version'];
+ // DB size ... MySQL only
+ $sql = "SELECT VERSION() AS mysql_version";
+ if ($result = DB()->sql_query($sql)) {
+ $row = DB()->sql_fetchrow($result);
+ $version = $row['mysql_version'];
- if (preg_match('/^(3\.23|4\.|5\.|10\.)/', $version))
- {
- $dblist = array();
- foreach ($bb_cfg['db'] as $name => $row)
- {
- $sql = "SHOW TABLE STATUS FROM {$row[1]}";
- if ($result = DB()->sql_query($sql))
- {
- $tabledata_ary = DB()->sql_fetchrowset($result);
+ if (preg_match('/^(3\.23|4\.|5\.|10\.)/', $version)) {
+ $dblist = array();
+ foreach ($bb_cfg['db'] as $name => $row) {
+ $sql = "SHOW TABLE STATUS FROM {$row[1]}";
+ if ($result = DB()->sql_query($sql)) {
+ $tabledata_ary = DB()->sql_fetchrowset($result);
- $dbsize = 0;
- for ($i = 0; $i < count($tabledata_ary); $i++)
- {
- if( @$tabledata_ary[$i]['Type'] != 'MRG_MYISAM' )
- {
- $dbsize += $tabledata_ary[$i]['Data_length'] + $tabledata_ary[$i]['Index_length'];
- }
- }
- $dblist[] = ''. humn_size($dbsize) .' ';
- }
- }
- $dbsize = implode(' | ', $dblist);
- }
- else
- {
- $dbsize = $lang['NOT_AVAILABLE'];
- }
- }
- else
- {
- $dbsize = $lang['NOT_AVAILABLE'];
- }
+ $dbsize = 0;
+ for ($i = 0; $i < count($tabledata_ary); $i++) {
+ if (@$tabledata_ary[$i]['Type'] != 'MRG_MYISAM') {
+ $dbsize += $tabledata_ary[$i]['Data_length'] + $tabledata_ary[$i]['Index_length'];
+ }
+ }
+ $dblist[] = '' . humn_size($dbsize) . ' ';
+ }
+ }
+ $dbsize = implode(' | ', $dblist);
+ } else {
+ $dbsize = $lang['NOT_AVAILABLE'];
+ }
+ } else {
+ $dbsize = $lang['NOT_AVAILABLE'];
+ }
- $template->assign_vars(array(
- 'NUMBER_OF_POSTS' => $total_posts,
- 'NUMBER_OF_TOPICS' => $total_topics,
- 'NUMBER_OF_USERS' => $total_users,
- 'START_DATE' => $start_date,
- 'POSTS_PER_DAY' => $posts_per_day,
- 'TOPICS_PER_DAY' => $topics_per_day,
- 'USERS_PER_DAY' => $users_per_day,
- 'AVATAR_DIR_SIZE' => $avatar_dir_size,
- 'DB_SIZE' => $dbsize,
- 'GZIP_COMPRESSION' => ($bb_cfg['gzip_compress']) ? $lang['ON'] : $lang['OFF'],
- ));
+ $template->assign_vars(array(
+ 'NUMBER_OF_POSTS' => $total_posts,
+ 'NUMBER_OF_TOPICS' => $total_topics,
+ 'NUMBER_OF_USERS' => $total_users,
+ 'START_DATE' => $start_date,
+ 'POSTS_PER_DAY' => $posts_per_day,
+ 'TOPICS_PER_DAY' => $topics_per_day,
+ 'USERS_PER_DAY' => $users_per_day,
+ 'AVATAR_DIR_SIZE' => $avatar_dir_size,
+ 'DB_SIZE' => $dbsize,
+ 'GZIP_COMPRESSION' => ($bb_cfg['gzip_compress']) ? $lang['ON'] : $lang['OFF'],
+ ));
- if (@$_GET['users_online'])
- {
- $template->assign_vars(array(
- 'SHOW_USERS_ONLINE' => true,
- ));
+ if (@$_GET['users_online']) {
+ $template->assign_vars(array(
+ 'SHOW_USERS_ONLINE' => true,
+ ));
- // Get users online information.
- $sql = "SELECT u.user_id, u.username, u.user_rank, s.session_time AS user_session_time, u.user_opt, s.session_logged_in, s.session_ip, s.session_start
+ // Get users online information.
+ $sql = "SELECT u.user_id, u.username, u.user_rank, s.session_time AS user_session_time, u.user_opt, s.session_logged_in, s.session_ip, s.session_start
FROM " . BB_USERS . " u, " . BB_SESSIONS . " s
WHERE s.session_logged_in = 1
AND u.user_id = s.session_user_id
AND u.user_id <> " . GUEST_UID . "
- AND s.session_time >= " . ( TIMENOW - 300 ) . "
+ AND s.session_time >= " . (TIMENOW - 300) . "
ORDER BY s.session_ip ASC, s.session_time DESC";
- if (!$result = DB()->sql_query($sql))
- {
- bb_die('Could not obtain reged user / online information');
- }
- $onlinerow_reg = DB()->sql_fetchrowset($result);
+ if (!$result = DB()->sql_query($sql)) {
+ bb_die('Could not obtain reged user / online information');
+ }
+ $onlinerow_reg = DB()->sql_fetchrowset($result);
- $sql = "SELECT session_logged_in, session_time, session_ip, session_start
+ $sql = "SELECT session_logged_in, session_time, session_ip, session_start
FROM " . BB_SESSIONS . "
WHERE session_logged_in = 0
- AND session_time >= " . ( TIMENOW - 300 ) . "
+ AND session_time >= " . (TIMENOW - 300) . "
ORDER BY session_ip ASC, session_time DESC";
- if (!$result = DB()->sql_query($sql))
- {
- bb_die('Could not obtain guest user / online information');
- }
- $onlinerow_guest = DB()->sql_fetchrowset($result);
+ if (!$result = DB()->sql_query($sql)) {
+ bb_die('Could not obtain guest user / online information');
+ }
+ $onlinerow_guest = DB()->sql_fetchrowset($result);
- $reg_userid_ary = array();
+ $reg_userid_ary = array();
- if (count($onlinerow_reg))
- {
- $registered_users = $hidden_users = 0;
+ if (count($onlinerow_reg)) {
+ $registered_users = $hidden_users = 0;
- for ($i = 0, $cnt = count($onlinerow_reg); $i < $cnt; $i++)
- {
- if (!in_array($onlinerow_reg[$i]['user_id'], $reg_userid_ary))
- {
- $reg_userid_ary[] = $onlinerow_reg[$i]['user_id'];
+ for ($i = 0, $cnt = count($onlinerow_reg); $i < $cnt; $i++) {
+ if (!in_array($onlinerow_reg[$i]['user_id'], $reg_userid_ary)) {
+ $reg_userid_ary[] = $onlinerow_reg[$i]['user_id'];
- $username = $onlinerow_reg[$i]['username'];
+ $username = $onlinerow_reg[$i]['username'];
- if (bf($onlinerow_reg[$i]['user_opt'], 'user_opt', 'user_viewonline'))
- {
- $hidden_users++;
- $hidden = TRUE;
- }
- else
- {
- $registered_users++;
- $hidden = FALSE;
- }
+ if (bf($onlinerow_reg[$i]['user_opt'], 'user_opt', 'user_viewonline')) {
+ $hidden_users++;
+ $hidden = true;
+ } else {
+ $registered_users++;
+ $hidden = false;
+ }
- $row_class = 'row1';
+ $row_class = 'row1';
- $reg_ip = decode_ip($onlinerow_reg[$i]['session_ip']);
+ $reg_ip = decode_ip($onlinerow_reg[$i]['session_ip']);
- $template->assign_block_vars('reg_user_row', array(
- 'ROW_CLASS' => $row_class,
- 'USER' => profile_url($onlinerow_reg[$i]),
- 'STARTED' => bb_date($onlinerow_reg[$i]['session_start'], 'H:i', false),
- 'LASTUPDATE' => bb_date($onlinerow_reg[$i]['user_session_time'], 'H:i', false),
- 'IP_ADDRESS' => $reg_ip,
- 'U_WHOIS_IP' => $bb_cfg['whois_info'] . $reg_ip,
- ));
- }
- }
- }
+ $template->assign_block_vars('reg_user_row', array(
+ 'ROW_CLASS' => $row_class,
+ 'USER' => profile_url($onlinerow_reg[$i]),
+ 'STARTED' => bb_date($onlinerow_reg[$i]['session_start'], 'H:i', false),
+ 'LASTUPDATE' => bb_date($onlinerow_reg[$i]['user_session_time'], 'H:i', false),
+ 'IP_ADDRESS' => $reg_ip,
+ 'U_WHOIS_IP' => $bb_cfg['whois_info'] . $reg_ip,
+ ));
+ }
+ }
+ }
- // Guest users
- if (count($onlinerow_guest))
- {
- $guest_users = 0;
+ // Guest users
+ if (count($onlinerow_guest)) {
+ $guest_users = 0;
- for ($i = 0; $i < count($onlinerow_guest); $i++)
- {
- $guest_userip_ary[] = $onlinerow_guest[$i]['session_ip'];
- $guest_users++;
+ for ($i = 0; $i < count($onlinerow_guest); $i++) {
+ $guest_userip_ary[] = $onlinerow_guest[$i]['session_ip'];
+ $guest_users++;
- $row_class = 'row2';
+ $row_class = 'row2';
- $guest_ip = decode_ip($onlinerow_guest[$i]['session_ip']);
+ $guest_ip = decode_ip($onlinerow_guest[$i]['session_ip']);
- $template->assign_block_vars('guest_user_row', array(
- 'ROW_CLASS' => $row_class,
- 'STARTED' => bb_date($onlinerow_guest[$i]['session_start'], 'H:i', false),
- 'LASTUPDATE' => bb_date($onlinerow_guest[$i]['session_time'], 'H:i' , false),
- 'IP_ADDRESS' => $guest_ip,
- 'U_WHOIS_IP' => $bb_cfg['whois_info'] . $guest_ip,
- ));
- }
- }
- }
- else
- {
- $template->assign_vars(array(
- 'USERS_ONLINE_HREF' => 'index.php?pane=right&users_online=1',
- ));
- }
-}
-else
-{
- // Generate frameset
- $template->assign_vars(array(
- 'CONTENT_ENCODING' => $bb_cfg['lang'][$userdata['user_lang']]['encoding'],
- 'TPL_ADMIN_FRAMESET' => true,
- ));
- send_no_cache_headers();
- print_page('index.tpl', 'admin', 'no_header');
+ $template->assign_block_vars('guest_user_row', array(
+ 'ROW_CLASS' => $row_class,
+ 'STARTED' => bb_date($onlinerow_guest[$i]['session_start'], 'H:i', false),
+ 'LASTUPDATE' => bb_date($onlinerow_guest[$i]['session_time'], 'H:i', false),
+ 'IP_ADDRESS' => $guest_ip,
+ 'U_WHOIS_IP' => $bb_cfg['whois_info'] . $guest_ip,
+ ));
+ }
+ }
+ } else {
+ $template->assign_vars(array(
+ 'USERS_ONLINE_HREF' => 'index.php?pane=right&users_online=1',
+ ));
+ }
+} else {
+ // Generate frameset
+ $template->assign_vars(array(
+ 'CONTENT_ENCODING' => $bb_cfg['lang'][$userdata['user_lang']]['encoding'],
+ 'TPL_ADMIN_FRAMESET' => true,
+ ));
+ send_no_cache_headers();
+ print_page('index.tpl', 'admin', 'no_header');
}
print_page('index.tpl', 'admin');
// Functions
-function inarray ($needle, $haystack)
+function inarray($needle, $haystack)
{
- for ($i = 0; $i < sizeof($haystack); $i++)
- {
- if ($haystack[$i] == $needle)
- {
- return true;
- }
- }
- return false;
-}
\ No newline at end of file
+ for ($i = 0; $i < sizeof($haystack); $i++) {
+ if ($haystack[$i] == $needle) {
+ return true;
+ }
+ }
+ return false;
+}
diff --git a/admin/pagestart.php b/admin/pagestart.php
index 40449b461..c8c38371c 100644
--- a/admin/pagestart.php
+++ b/admin/pagestart.php
@@ -1,28 +1,48 @@
session_start();
-if (IS_GUEST)
-{
- redirect(LOGIN_URL . "?redirect=admin/index.php");
+if (IS_GUEST) {
+ redirect(LOGIN_URL . "?redirect=admin/index.php");
}
-if (!IS_ADMIN)
-{
- bb_die($lang['NOT_ADMIN']);
+if (!IS_ADMIN) {
+ bb_die($lang['NOT_ADMIN']);
}
-if (!$userdata['session_admin'])
-{
- $redirect = url_arg($_SERVER['REQUEST_URI'], 'admin', 1);
- redirect("login.php?redirect=$redirect");
-}
\ No newline at end of file
+if (!$userdata['session_admin']) {
+ $redirect = url_arg($_SERVER['REQUEST_URI'], 'admin', 1);
+ redirect("login.php?redirect=$redirect");
+}
diff --git a/admin/stats/tr_stats.php b/admin/stats/tr_stats.php
index 523a395a4..e3c4c093f 100644
--- a/admin/stats/tr_stats.php
+++ b/admin/stats/tr_stats.php
@@ -1,48 +1,70 @@
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';
-$sql[] = 'SELECT round(avg(size)/1048576) FROM `'.BB_BT_TORRENTS.'`';
-$sql[] = 'SELECT count(*) FROM `'.BB_BT_TORRENTS.'`';
-$sql[] = 'SELECT count(distinct(topic_id)) FROM `'.BB_BT_TRACKER_SNAP.'` WHERE seeders > 0';
-$sql[] = 'SELECT count(distinct(topic_id)) FROM `'.BB_BT_TRACKER_SNAP.'` WHERE seeders > 5';
-$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';
+$sql[] = 'SELECT count(*) FROM `' . BB_USERS . '` WHERE `user_lastvisit` < UNIX_TIMESTAMP()-2592000';
+$sql[] = 'SELECT count(*) FROM `' . BB_USERS . '` WHERE `user_lastvisit` < UNIX_TIMESTAMP()-7776000';
+$sql[] = 'SELECT round(avg(size)/1048576) FROM `' . BB_BT_TORRENTS . '`';
+$sql[] = 'SELECT count(*) FROM `' . BB_BT_TORRENTS . '`';
+$sql[] = 'SELECT count(distinct(topic_id)) FROM `' . BB_BT_TRACKER_SNAP . '` WHERE seeders > 0';
+$sql[] = 'SELECT count(distinct(topic_id)) FROM `' . BB_BT_TRACKER_SNAP . '` WHERE seeders > 5';
+$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 '';
echo '
';
-foreach ($sql as $i => $query)
-{
- $row = mysqli_fetch_row(DB()->query($query));
- echo "{$lang['TR_STATS'][$i]} {$row[0]} ";
+foreach ($sql as $i => $query) {
+ $row = mysqli_fetch_row(DB()->query($query));
+ echo "{$lang['TR_STATS'][$i]} {$row[0]} ";
}
echo '
';
echo '';
-if ($l = sys('la'))
-{
- $l = explode(' ', $l);
- for ($i=0; $i < 3; $i++)
- {
- $l[$i] = round($l[$i], 1);
- }
- echo "\n\nloadavg: $l[0] $l[1] $l[2]\n\n";
+if ($l = sys('la')) {
+ $l = explode(' ', $l);
+ for ($i = 0; $i < 3; $i++) {
+ $l[$i] = round($l[$i], 1);
+ }
+ echo "\n\nloadavg: $l[0] $l[1] $l[2]\n\n";
}
-echo 'gen time: '. sprintf('%.3f', (array_sum(explode(' ', microtime())) - TIMESTART)) ." sec\n";
+echo 'gen time: ' . sprintf('%.3f', (array_sum(explode(' ', microtime())) - TIMESTART)) . " sec\n";
echo ' ';
echo '';
diff --git a/admin/stats/tracker.php b/admin/stats/tracker.php
index 69d9922d8..2e892f4dc 100644
--- a/admin/stats/tracker.php
+++ b/admin/stats/tracker.php
@@ -1,12 +1,37 @@
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;
@@ -17,7 +42,7 @@ $stat = array();
define('TMP_TRACKER_TABLE', 'tmp_tracker');
DB()->query("
- CREATE TEMPORARY TABLE ". TMP_TRACKER_TABLE ." (
+ CREATE TEMPORARY TABLE " . TMP_TRACKER_TABLE . " (
`topic_id` mediumint(8) unsigned NOT NULL default '0',
`user_id` mediumint(9) NOT NULL default '0',
`ip` char(8) binary NOT NULL default '0',
@@ -28,53 +53,53 @@ DB()->query("
)
SELECT
topic_id, user_id, ip, seeder, speed_up, speed_down, update_time
- FROM ". BB_BT_TRACKER ."
+ FROM " . BB_BT_TRACKER . "
");
// Peers within announce interval
-$stat += DB()->fetch_row("SELECT COUNT(*) AS p_within_ann FROM ". TMP_TRACKER_TABLE ." WHERE update_time >= ". (TIMENOW - $announce_interval));
+$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);
+$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);
+$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);
+$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);
+$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);
+$stat += DB()->fetch_row("SELECT COUNT(DISTINCT topic_id) AS tor_active FROM " . TMP_TRACKER_TABLE);
// With seeder
-$stat += DB()->fetch_row("SELECT COUNT(DISTINCT topic_id) AS tor_with_seeder FROM ". TMP_TRACKER_TABLE ." WHERE seeder = 1");
+$stat += DB()->fetch_row("SELECT COUNT(DISTINCT topic_id) AS tor_with_seeder FROM " . TMP_TRACKER_TABLE . " WHERE seeder = 1");
// All torrents
-$stat += DB()->fetch_row("SELECT COUNT(*) AS tor_all, SUM(size) AS torrents_size FROM ". BB_BT_TORRENTS);
+$stat += DB()->fetch_row("SELECT COUNT(*) AS tor_all, SUM(size) AS torrents_size FROM " . BB_BT_TORRENTS);
// Last xx minutes
$peers_in_last_min = array();
-foreach ($peers_in_last_minutes as $t)
-{
- $row = DB()->fetch_row("
- SELECT COUNT(*) AS peers FROM ". TMP_TRACKER_TABLE ." WHERE update_time >= ". (TIMENOW - 60*$t) ."
+foreach ($peers_in_last_minutes as $t) {
+ $row = DB()->fetch_row("
+ SELECT COUNT(*) AS peers FROM " . TMP_TRACKER_TABLE . " WHERE update_time >= " . (TIMENOW - 60 * $t) . "
");
- $peers_in_last_min[$t] = (int) $row['peers'];
+ $peers_in_last_min[$t] = (int)$row['peers'];
}
// Last xx seconds
$peers_in_last_sec = array();
-$rowset = DB()->fetch_rowset("SELECT COUNT(*) AS peers FROM ". TMP_TRACKER_TABLE ." GROUP BY update_time DESC LIMIT $peers_in_last_sec_limit");
-foreach ($rowset as $cnt => $row)
-{
- $peers_in_last_sec[] = sprintf('%3s', $row['peers']) . (($cnt && !(++$cnt%15)) ? " \n" : '');
+$rowset = DB()->fetch_rowset("SELECT COUNT(*) AS peers FROM " . TMP_TRACKER_TABLE . " GROUP BY update_time DESC LIMIT $peers_in_last_sec_limit");
+foreach ($rowset as $cnt => $row) {
+ $peers_in_last_sec[] = sprintf('%3s', $row['peers']) . (($cnt && !(++$cnt % 15)) ? " \n" : '');
}
-function commify_callback ($matches)
+function commify_callback($matches)
{
- return commify($matches[0]);
+ return commify($matches[0]);
}
-function commify_ob ($contents)
+
+function commify_ob($contents)
{
- return preg_replace_callback("#\b\d+\b#", 'commify_callback', $contents);
+ return preg_replace_callback("#\b\d+\b#", 'commify_callback', $contents);
}
+
ob_start('commify_ob');
echo '';
@@ -92,7 +117,7 @@ echo "\n
$stat[tor_all] / $stat[tor_active] / $stat[tor_with_seeder]
- [ ". humn_size($stat['torrents_size']) ." ]
+ [ " . humn_size($stat['torrents_size']) . " ]
\n";
@@ -101,36 +126,34 @@ echo "\n
$stat[p_all] / $stat[p_within_ann]
- [ up: ". humn_size($stat['speed_up']) ."/s,
- down: ". humn_size($stat['speed_down']) ."/s ]
+ [ up: " . humn_size($stat['speed_up']) . "/s,
+ down: " . humn_size($stat['speed_down']) . "/s ]
\n";
-echo "\n peers: in last ". join(' / ', $peers_in_last_minutes) ." min \n";
-echo "\n". join(' / ', $peers_in_last_min) ." \n";
+echo "\n peers: in last " . join(' / ', $peers_in_last_minutes) . " min \n";
+echo "\n" . join(' / ', $peers_in_last_min) . " \n";
-echo "\n peers in last $peers_in_last_sec_limit sec [ per second, DESC order --> ] last peer: $stat[last_peer_time] seconds ago ". date("j M H:i:s [T O]") ." \n";
-echo ' '. join(' ', $peers_in_last_sec) ." \n";
+echo "\n peers in last $peers_in_last_sec_limit sec [ per second, DESC order --> ] last peer: $stat[last_peer_time] seconds ago " . date("j M H:i:s [T O]") . " \n";
+echo ' ' . join(' ', $peers_in_last_sec) . " \n";
echo '';
echo '';
-if ($l = sys('la'))
-{
- $l = explode(' ', $l);
- for ($i=0; $i < 3; $i++)
- {
- $l[$i] = round($l[$i], 1);
- }
- echo "\n\nloadavg: $l[0] $l[1] $l[2]\n\n";
+if ($l = sys('la')) {
+ $l = explode(' ', $l);
+ for ($i = 0; $i < 3; $i++) {
+ $l[$i] = round($l[$i], 1);
+ }
+ echo "\n\nloadavg: $l[0] $l[1] $l[2]\n\n";
}
-echo 'gen time: '. sprintf('%.3f', (array_sum(explode(' ', microtime())) - TIMESTART)) ." sec\n";
+echo 'gen time: ' . sprintf('%.3f', (array_sum(explode(' ', microtime())) - TIMESTART)) . " sec\n";
echo ' ';
echo '';
-DB()->query("DROP TEMPORARY TABLE ". TMP_TRACKER_TABLE);
+DB()->query("DROP TEMPORARY TABLE " . TMP_TRACKER_TABLE);
-bb_exit();
\ No newline at end of file
+bb_exit();
diff --git a/ajax.php b/ajax.php
index b0d3e8b0b..92b6fb2ac 100644
--- a/ajax.php
+++ b/ajax.php
@@ -1,4 +1,27 @@
init();
$user->session_start();
// Exit if board is disabled via ON/OFF trigger or by admin
-if ($ajax->action != 'manage_admin')
-{
- if ($bb_cfg['board_disable'])
- {
- $ajax->ajax_die($lang['BOARD_DISABLE']);
- }
- else if (file_exists(BB_DISABLED))
- {
- $ajax->ajax_die($lang['BOARD_DISABLE_CRON']);
- }
+if ($ajax->action != 'manage_admin') {
+ if ($bb_cfg['board_disable']) {
+ $ajax->ajax_die($lang['BOARD_DISABLE']);
+ } elseif (file_exists(BB_DISABLED)) {
+ $ajax->ajax_die($lang['BOARD_DISABLE_CRON']);
+ }
}
// Load actions required modules
-switch ($ajax->action)
-{
- case 'view_post':
- require(INC_DIR . 'bbcode.php');
- break;
+switch ($ajax->action) {
+ case 'view_post':
+ require(INC_DIR . 'bbcode.php');
+ break;
- case 'posts':
- case 'post_mod_comment':
- require(INC_DIR . 'bbcode.php');
- require(INC_DIR . 'functions_post.php');
- require(INC_DIR . 'functions_admin.php');
- break;
+ case 'posts':
+ case 'post_mod_comment':
+ require(INC_DIR . 'bbcode.php');
+ require(INC_DIR . 'functions_post.php');
+ require(INC_DIR . 'functions_admin.php');
+ break;
- case 'view_torrent':
- case 'mod_action':
- case 'change_tor_status':
- case 'gen_passkey':
- require(ATTACH_DIR . 'attachment_mod.php');
- require(INC_DIR . 'functions_torrent.php');
- break;
+ case 'view_torrent':
+ case 'mod_action':
+ case 'change_tor_status':
+ case 'gen_passkey':
+ require(ATTACH_DIR . 'attachment_mod.php');
+ require(INC_DIR . 'functions_torrent.php');
+ break;
- case 'change_torrent':
- require(ATTACH_DIR . 'attachment_mod.php');
- require(INC_DIR . 'functions_torrent.php');
- break;
+ case 'change_torrent':
+ require(ATTACH_DIR . 'attachment_mod.php');
+ require(INC_DIR . 'functions_torrent.php');
+ break;
- case 'user_register':
- require(INC_DIR . 'functions_validate.php');
- break;
+ case 'user_register':
+ require(INC_DIR . 'functions_validate.php');
+ break;
- case 'manage_user':
- case 'manage_admin':
- require(INC_DIR . 'functions_admin.php');
- break;
+ case 'manage_user':
+ case 'manage_admin':
+ require(INC_DIR . 'functions_admin.php');
+ break;
- case 'group_membership':
- case 'manage_group':
- require(INC_DIR . 'functions_group.php');
- break;
+ case 'group_membership':
+ case 'manage_group':
+ require(INC_DIR . 'functions_group.php');
+ break;
- case 'sitemap';
- require(CLASS_DIR .'sitemap.php');
- break;
+ case 'sitemap';
+ require(CLASS_DIR . 'sitemap.php');
+ break;
}
// Position in $ajax->valid_actions['xxx']
@@ -81,348 +99,330 @@ $ajax->exec();
//
class ajax_common
{
- var $request = array();
- var $response = array();
+ public $request = array();
+ public $response = array();
- var $valid_actions = array(
- // ACTION NAME AJAX_AUTH
- 'edit_user_profile' => array('admin'),
- 'change_user_rank' => array('admin'),
- 'change_user_opt' => array('admin'),
- 'manage_user' => array('admin'),
- 'manage_admin' => array('admin'),
- 'sitemap' => array('admin'),
+ public $valid_actions = array(
+ // ACTION NAME AJAX_AUTH
+ 'edit_user_profile' => array('admin'),
+ 'change_user_rank' => array('admin'),
+ 'change_user_opt' => array('admin'),
+ 'manage_user' => array('admin'),
+ 'manage_admin' => array('admin'),
+ 'sitemap' => array('admin'),
- 'mod_action' => array('mod'),
- 'topic_tpl' => array('mod'),
- 'group_membership' => array('mod'),
- 'post_mod_comment' => array('mod'),
+ 'mod_action' => array('mod'),
+ 'topic_tpl' => array('mod'),
+ 'group_membership' => array('mod'),
+ 'post_mod_comment' => array('mod'),
- 'avatar' => array('user'),
- 'gen_passkey' => array('user'),
- 'change_torrent' => array('user'),
- 'change_tor_status' => array('user'),
- 'manage_group' => array('user'),
+ 'avatar' => array('user'),
+ 'gen_passkey' => array('user'),
+ 'change_torrent' => array('user'),
+ 'change_tor_status' => array('user'),
+ 'manage_group' => array('user'),
- 'view_post' => array('guest'),
- 'view_torrent' => array('guest'),
- 'user_register' => array('guest'),
- 'posts' => array('guest'),
- 'index_data' => array('guest'),
- );
+ 'view_post' => array('guest'),
+ 'view_torrent' => array('guest'),
+ 'user_register' => array('guest'),
+ 'posts' => array('guest'),
+ 'index_data' => array('guest'),
+ );
- var $action = null;
+ public $action = null;
- /**
- * Constructor
- */
- function ajax_common()
- {
- ob_start(array(&$this, 'ob_handler'));
- header('Content-Type: text/plain');
- }
+ /**
+ * Constructor
+ */
+ public function ajax_common()
+ {
+ ob_start(array(&$this, 'ob_handler'));
+ header('Content-Type: text/plain');
+ }
- /**
- * Perform action
- */
- function exec()
- {
- global $lang;
+ /**
+ * Perform action
+ */
+ public function exec()
+ {
+ global $lang;
- // Exit if we already have errors
- if (!empty($this->response['error_code']))
- {
- $this->send();
- }
+ // Exit if we already have errors
+ if (!empty($this->response['error_code'])) {
+ $this->send();
+ }
- // Check that requested action is valid
- $action = $this->action;
+ // Check that requested action is valid
+ $action = $this->action;
- if (!$action || !is_string($action))
- {
- $this->ajax_die('no action specified');
- }
- elseif (!$action_params =& $this->valid_actions[$action])
- {
- $this->ajax_die('invalid action: ' . $action);
- }
+ if (!$action || !is_string($action)) {
+ $this->ajax_die('no action specified');
+ } elseif (!$action_params =& $this->valid_actions[$action]) {
+ $this->ajax_die('invalid action: ' . $action);
+ }
- // Auth check
- switch ($action_params[AJAX_AUTH])
- {
- // GUEST
- case 'guest':
- break;
+ // Auth check
+ switch ($action_params[AJAX_AUTH]) {
+ // GUEST
+ case 'guest':
+ break;
- // USER
- case 'user':
- if (IS_GUEST)
- {
- $this->ajax_die($lang['NEED_TO_LOGIN_FIRST']);
- }
- break;
+ // USER
+ case 'user':
+ if (IS_GUEST) {
+ $this->ajax_die($lang['NEED_TO_LOGIN_FIRST']);
+ }
+ break;
- // MOD
- case 'mod':
- if (!IS_AM)
- {
- $this->ajax_die($lang['ONLY_FOR_MOD']);
- }
- $this->check_admin_session();
- break;
+ // MOD
+ case 'mod':
+ if (!IS_AM) {
+ $this->ajax_die($lang['ONLY_FOR_MOD']);
+ }
+ $this->check_admin_session();
+ break;
- // ADMIN
- case 'admin':
- if (!IS_ADMIN)
- {
- $this->ajax_die($lang['ONLY_FOR_ADMIN']);
- }
- $this->check_admin_session();
- break;
+ // ADMIN
+ case 'admin':
+ if (!IS_ADMIN) {
+ $this->ajax_die($lang['ONLY_FOR_ADMIN']);
+ }
+ $this->check_admin_session();
+ break;
- // SUPER_ADMIN
- case 'super_admin':
- if (!IS_SUPER_ADMIN)
- {
- $this->ajax_die($lang['ONLY_FOR_SUPER_ADMIN']);
- }
- $this->check_admin_session();
- break;
+ // SUPER_ADMIN
+ case 'super_admin':
+ if (!IS_SUPER_ADMIN) {
+ $this->ajax_die($lang['ONLY_FOR_SUPER_ADMIN']);
+ }
+ $this->check_admin_session();
+ break;
- default:
- trigger_error("invalid auth type for $action", E_USER_ERROR);
- }
+ default:
+ trigger_error("invalid auth type for $action", E_USER_ERROR);
+ }
- // Run action
- $this->$action();
+ // Run action
+ $this->$action();
- // Send output
- $this->send();
- }
+ // Send output
+ $this->send();
+ }
- /**
- * Exit on error
- */
- function ajax_die($error_msg, $error_code = E_AJAX_GENERAL_ERROR)
- {
- $this->response['error_code'] = $error_code;
- $this->response['error_msg'] = $error_msg;
+ /**
+ * Exit on 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;
- $this->send();
- }
+ $this->send();
+ }
- /**
- * Initialization
- */
- function init()
- {
- $this->request = $_POST;
- $this->action =& $this->request['action'];
- }
+ /**
+ * Initialization
+ */
+ public function init()
+ {
+ $this->request = $_POST;
+ $this->action =& $this->request['action'];
+ }
- /**
- * Send data
- */
- function send()
- {
- $this->response['action'] = $this->action;
+ /**
+ * Send data
+ */
+ public function send()
+ {
+ $this->response['action'] = $this->action;
- if (DBG_USER && SQL_DEBUG && !empty($_COOKIE['sql_log']))
- {
- $this->response['sql_log'] = get_sql_log();
- }
+ if (DBG_USER && SQL_DEBUG && !empty($_COOKIE['sql_log'])) {
+ $this->response['sql_log'] = get_sql_log();
+ }
- // sending output will be handled by $this->ob_handler()
- exit();
- }
+ // sending output will be handled by $this->ob_handler()
+ exit();
+ }
- /**
- * OB Handler
- */
- function ob_handler($contents)
- {
- if (DBG_USER)
- {
- if ($contents)
- {
- $this->response['raw_output'] = $contents;
- }
- }
+ /**
+ * OB Handler
+ */
+ public function ob_handler($contents)
+ {
+ if (DBG_USER) {
+ if ($contents) {
+ $this->response['raw_output'] = $contents;
+ }
+ }
- $response_js = Zend\Json\Json::encode($this->response);
+ $response_js = Zend\Json\Json::encode($this->response);
- if (GZIP_OUTPUT_ALLOWED && !defined('NO_GZIP'))
- {
- if (UA_GZIP_SUPPORTED && strlen($response_js) > 2000)
- {
- header('Content-Encoding: gzip');
- $response_js = gzencode($response_js, 1);
- }
- }
+ if (GZIP_OUTPUT_ALLOWED && !defined('NO_GZIP')) {
+ if (UA_GZIP_SUPPORTED && strlen($response_js) > 2000) {
+ header('Content-Encoding: gzip');
+ $response_js = gzencode($response_js, 1);
+ }
+ }
- return $response_js;
- }
+ return $response_js;
+ }
- /**
- * Admin session
- */
- function check_admin_session()
- {
- global $user;
+ /**
+ * Admin session
+ */
+ public function check_admin_session()
+ {
+ global $user;
- if (!$user->data['session_admin'])
- {
- if (empty($this->request['user_password']))
- {
- $this->prompt_for_password();
- }
- else
- {
- $login_args = array(
- 'login_username' => $user->data['username'],
- 'login_password' => $_POST['user_password'],
- );
- if (!$user->login($login_args, true))
- {
- $this->ajax_die('Wrong password');
- }
- }
- }
- }
+ if (!$user->data['session_admin']) {
+ if (empty($this->request['user_password'])) {
+ $this->prompt_for_password();
+ } else {
+ $login_args = array(
+ 'login_username' => $user->data['username'],
+ 'login_password' => $_POST['user_password'],
+ );
+ if (!$user->login($login_args, true)) {
+ $this->ajax_die('Wrong password');
+ }
+ }
+ }
+ }
- /**
- * Prompt for password
- */
- function prompt_for_password()
- {
- $this->response['prompt_password'] = 1;
- $this->send();
- }
+ /**
+ * Prompt for password
+ */
+ public function prompt_for_password()
+ {
+ $this->response['prompt_password'] = 1;
+ $this->send();
+ }
- /**
- * Prompt for confirmation
- */
- function prompt_for_confirm($confirm_msg)
- {
- if (empty($confirm_msg)) $this->ajax_die('false');
+ /**
+ * Prompt for confirmation
+ */
+ public function prompt_for_confirm($confirm_msg)
+ {
+ if (empty($confirm_msg)) {
+ $this->ajax_die('false');
+ }
- $this->response['prompt_confirm'] = 1;
- $this->response['confirm_msg'] = $confirm_msg;
- $this->send();
- }
+ $this->response['prompt_confirm'] = 1;
+ $this->response['confirm_msg'] = $confirm_msg;
+ $this->send();
+ }
- /**
- * Verify mod rights
- */
- function verify_mod_rights($forum_id)
- {
- global $userdata, $lang;
+ /**
+ * Verify mod rights
+ */
+ public function verify_mod_rights($forum_id)
+ {
+ global $userdata, $lang;
- $is_auth = auth(AUTH_MOD, $forum_id, $userdata);
+ $is_auth = auth(AUTH_MOD, $forum_id, $userdata);
- if (!$is_auth['auth_mod'])
- {
- $this->ajax_die($lang['ONLY_FOR_MOD']);
- }
- }
+ if (!$is_auth['auth_mod']) {
+ $this->ajax_die($lang['ONLY_FOR_MOD']);
+ }
+ }
- function edit_user_profile()
- {
- require(AJAX_DIR . 'edit_user_profile.php');
- }
+ public function edit_user_profile()
+ {
+ require(AJAX_DIR . 'edit_user_profile.php');
+ }
- function change_user_rank()
- {
- require(AJAX_DIR . 'change_user_rank.php');
- }
+ public function change_user_rank()
+ {
+ require(AJAX_DIR . 'change_user_rank.php');
+ }
- function change_user_opt()
- {
- require(AJAX_DIR . 'change_user_opt.php');
- }
+ public function change_user_opt()
+ {
+ require(AJAX_DIR . 'change_user_opt.php');
+ }
- function gen_passkey()
- {
- require(AJAX_DIR . 'gen_passkey.php');
- }
+ public function gen_passkey()
+ {
+ require(AJAX_DIR . 'gen_passkey.php');
+ }
- function group_membership()
- {
- require(AJAX_DIR . 'group_membership.php');
- }
+ public function group_membership()
+ {
+ require(AJAX_DIR . 'group_membership.php');
+ }
- function manage_group()
- {
- require(AJAX_DIR . 'edit_group_profile.php');
- }
+ public function manage_group()
+ {
+ require(AJAX_DIR . 'edit_group_profile.php');
+ }
- function post_mod_comment()
- {
- require(AJAX_DIR . 'post_mod_comment.php');
- }
+ public function post_mod_comment()
+ {
+ require(AJAX_DIR . 'post_mod_comment.php');
+ }
- function view_post()
- {
- require(AJAX_DIR . 'view_post.php');
- }
+ public function view_post()
+ {
+ require(AJAX_DIR . 'view_post.php');
+ }
- function change_tor_status()
- {
- require(AJAX_DIR . 'change_tor_status.php');
- }
+ public function change_tor_status()
+ {
+ require(AJAX_DIR . 'change_tor_status.php');
+ }
- function change_torrent()
- {
- require(AJAX_DIR . 'change_torrent.php');
- }
+ public function change_torrent()
+ {
+ require(AJAX_DIR . 'change_torrent.php');
+ }
- function view_torrent()
- {
- require(AJAX_DIR . 'view_torrent.php');
- }
+ public function view_torrent()
+ {
+ require(AJAX_DIR . 'view_torrent.php');
+ }
- function user_register()
- {
- require(AJAX_DIR . 'user_register.php');
- }
+ public function user_register()
+ {
+ require(AJAX_DIR . 'user_register.php');
+ }
- function mod_action()
- {
- require(AJAX_DIR . 'mod_action.php');
- }
+ public function mod_action()
+ {
+ require(AJAX_DIR . 'mod_action.php');
+ }
- function posts()
- {
- require(AJAX_DIR . 'posts.php');
- }
+ public function posts()
+ {
+ require(AJAX_DIR . 'posts.php');
+ }
- function manage_user()
- {
- require(AJAX_DIR . 'manage_user.php');
- }
+ public function manage_user()
+ {
+ require(AJAX_DIR . 'manage_user.php');
+ }
- function manage_admin()
- {
- require(AJAX_DIR . 'manage_admin.php');
- }
+ public function manage_admin()
+ {
+ require(AJAX_DIR . 'manage_admin.php');
+ }
- function topic_tpl()
- {
- require(AJAX_DIR . 'topic_tpl.php');
- }
+ public function topic_tpl()
+ {
+ require(AJAX_DIR . 'topic_tpl.php');
+ }
- function index_data()
- {
- require(AJAX_DIR . 'index_data.php');
- }
+ public function index_data()
+ {
+ require(AJAX_DIR . 'index_data.php');
+ }
- function avatar()
- {
- require(AJAX_DIR . 'avatar.php');
- }
+ public function avatar()
+ {
+ require(AJAX_DIR . 'avatar.php');
+ }
- function sitemap()
- {
- require(AJAX_DIR .'sitemap.php');
- }
-}
\ No newline at end of file
+ public function sitemap()
+ {
+ require(AJAX_DIR . 'sitemap.php');
+ }
+}
diff --git a/bt/announce.php b/bt/announce.php
index 70fc72331..a66fd5c9a 100644
--- a/bt/announce.php
+++ b/bt/announce.php
@@ -1,185 +1,190 @@
0xFFFF)
-{
- msg_die('Invalid port');
+if (!isset($port) || $port < 0 || $port > 0xFFFF) {
+ msg_die('Invalid port');
}
-if (!isset($uploaded) || $uploaded < 0 || $uploaded > $max_up_down_val || $uploaded == 1844674407370)
-{
- msg_die('Invalid uploaded value');
+if (!isset($uploaded) || $uploaded < 0 || $uploaded > $max_up_down_val || $uploaded == 1844674407370) {
+ msg_die('Invalid uploaded value');
}
-if (!isset($downloaded) || $downloaded < 0 || $downloaded > $max_up_down_val || $downloaded == 1844674407370)
-{
- msg_die('Invalid downloaded value');
+if (!isset($downloaded) || $downloaded < 0 || $downloaded > $max_up_down_val || $downloaded == 1844674407370) {
+ msg_die('Invalid downloaded value');
}
-if (!isset($left) || $left < 0 || $left > $max_left_val)
-{
- msg_die('Invalid left value');
+if (!isset($left) || $left < 0 || $left > $max_left_val) {
+ msg_die('Invalid left value');
}
-if (!verify_id($passkey, BT_AUTH_KEY_LENGTH))
-{
- msg_die('Invalid passkey');
+if (!verify_id($passkey, BT_AUTH_KEY_LENGTH)) {
+ msg_die('Invalid passkey');
}
// IP
$ip = $_SERVER['REMOTE_ADDR'];
-if (!$bb_cfg['ignore_reported_ip'] && isset($_GET['ip']) && $ip !== $_GET['ip'])
-{
- if (!$bb_cfg['verify_reported_ip'])
- {
- $ip = $_GET['ip'];
- }
- elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && preg_match_all('#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#', $_SERVER['HTTP_X_FORWARDED_FOR'], $matches))
- {
- foreach ($matches[0] as $x_ip)
- {
- if ($x_ip === $_GET['ip'])
- {
- if (!$bb_cfg['allow_internal_ip'] && preg_match("#^(10|172\.16|192\.168)\.#", $x_ip))
- {
- break;
- }
- $ip = $x_ip;
- break;
- }
- }
- }
+if (!$bb_cfg['ignore_reported_ip'] && isset($_GET['ip']) && $ip !== $_GET['ip']) {
+ if (!$bb_cfg['verify_reported_ip']) {
+ $ip = $_GET['ip'];
+ } elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && preg_match_all('#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#', $_SERVER['HTTP_X_FORWARDED_FOR'], $matches)) {
+ foreach ($matches[0] as $x_ip) {
+ if ($x_ip === $_GET['ip']) {
+ if (!$bb_cfg['allow_internal_ip'] && preg_match("#^(10|172\.16|192\.168)\.#", $x_ip)) {
+ break;
+ }
+ $ip = $x_ip;
+ break;
+ }
+ }
+ }
}
// Check that IP format is valid
-if (!verify_ip($ip))
-{
- msg_die("Invalid IP: $ip");
+if (!verify_ip($ip)) {
+ msg_die("Invalid IP: $ip");
}
// Convert IP to HEX format
$ip_sql = encode_ip($ip);
// Peer unique id
$peer_hash = md5(
- rtrim($info_hash, ' ') . $passkey . $ip . $port
+ rtrim($info_hash, ' ') . $passkey . $ip . $port
);
// Get cached peer info from previous announce (last peer info)
$lp_info = CACHE('tr_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'))
-{
- drop_fast_announce($lp_info);
+if ($lp_info && (!isset($event) || $event !== 'stopped')) {
+ drop_fast_announce($lp_info);
}
// Functions
-function drop_fast_announce ($lp_info)
+function drop_fast_announce($lp_info)
{
- global $announce_interval;
+ global $announce_interval;
- if ($lp_info['update_time'] < (TIMENOW - $announce_interval + 60))
- {
- return; // if announce interval correct
- }
+ if ($lp_info['update_time'] < (TIMENOW - $announce_interval + 60)) {
+ return; // if announce interval correct
+ }
- $new_ann_intrv = $lp_info['update_time'] + $announce_interval - TIMENOW;
+ $new_ann_intrv = $lp_info['update_time'] + $announce_interval - TIMENOW;
- dummy_exit($new_ann_intrv);
+ dummy_exit($new_ann_intrv);
}
-function msg_die ($msg)
+function msg_die($msg)
{
- if (DBG_LOG) dbg_log(' ', '!die-'. clean_filename($msg));
+ if (DBG_LOG) {
+ dbg_log(' ', '!die-' . clean_filename($msg));
+ }
- $output = bencode(array(
+ $output = bencode(array(
# 'interval' => (int) 1800,
- 'min interval' => (int) 1800,
+ 'min interval' => (int)1800,
# 'peers' => (string) DUMMY_PEER,
- 'failure reason' => (string) $msg,
- 'warning message' => (string) $msg,
- ));
+ 'failure reason' => (string)$msg,
+ 'warning message' => (string)$msg,
+ ));
- die($output);
+ die($output);
}
# $agent = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '-';
@@ -189,160 +194,137 @@ function msg_die ($msg)
define('TR_ROOT', './');
require(TR_ROOT . 'includes/init_tr.php');
-$seeder = ($left == 0) ? 1 : 0;
+$seeder = ($left == 0) ? 1 : 0;
$stopped = ($event === 'stopped');
// Stopped event
-if ($stopped)
-{
- CACHE('tr_cache')->rm(PEER_HASH_PREFIX . $peer_hash);
- if (DBG_LOG) dbg_log(' ', 'stopped');
+if ($stopped) {
+ CACHE('tr_cache')->rm(PEER_HASH_PREFIX . $peer_hash);
+ if (DBG_LOG) {
+ dbg_log(' ', 'stopped');
+ }
}
// Get last peer info from DB
-if (!CACHE('tr_cache')->used && !$lp_info)
-{
- $lp_info = DB()->fetch_row("
- SELECT * FROM ". BB_BT_TRACKER ." WHERE peer_hash = '$peer_hash' LIMIT 1
+if (!CACHE('tr_cache')->used && !$lp_info) {
+ $lp_info = DB()->fetch_row("
+ 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)
-{
- if (!$stopped)
- {
- drop_fast_announce($lp_info);
- }
+if ($lp_info) {
+ if (!$stopped) {
+ drop_fast_announce($lp_info);
+ }
- $user_id = $lp_info['user_id'];
- $topic_id = $lp_info['topic_id'];
- $releaser = $lp_info['releaser'];
- $tor_type = $lp_info['tor_type'];
-}
-else
-{
- // Verify if torrent registered on tracker and user authorized
- $info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
- $passkey_sql = DB()->escape($passkey);
+ $user_id = $lp_info['user_id'];
+ $topic_id = $lp_info['topic_id'];
+ $releaser = $lp_info['releaser'];
+ $tor_type = $lp_info['tor_type'];
+} else {
+ // Verify if torrent registered on tracker and user authorized
+ $info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
+ $passkey_sql = DB()->escape($passkey);
- $sql = "
+ $sql = "
SELECT tor.topic_id, tor.poster_id, tor.tor_type, u.*
- FROM ". BB_BT_TORRENTS ." tor
- LEFT JOIN ". BB_BT_USERS ." u ON u.auth_key = '$passkey_sql'
+ FROM " . BB_BT_TORRENTS . " tor
+ LEFT JOIN " . BB_BT_USERS . " u ON u.auth_key = '$passkey_sql'
WHERE tor.info_hash = '$info_hash_sql'
LIMIT 1
";
- $row = DB()->fetch_row($sql);
+ $row = DB()->fetch_row($sql);
- if (empty($row['topic_id']))
- {
- msg_die('Torrent not registered, info_hash = ' . bin2hex($info_hash_sql));
- }
- if (empty($row['user_id']))
- {
- msg_die('Please LOG IN and REDOWNLOAD this torrent (user not found)');
- }
+ if (empty($row['topic_id'])) {
+ msg_die('Torrent not registered, info_hash = ' . bin2hex($info_hash_sql));
+ }
+ if (empty($row['user_id'])) {
+ msg_die('Please LOG IN and REDOWNLOAD this torrent (user not found)');
+ }
- $user_id = $row['user_id'];
- $topic_id = $row['topic_id'];
- $releaser = (int) ($user_id == $row['poster_id']);
- $tor_type = $row['tor_type'];
+ $user_id = $row['user_id'];
+ $topic_id = $row['topic_id'];
+ $releaser = (int)($user_id == $row['poster_id']);
+ $tor_type = $row['tor_type'];
- // Ratio limits
- if ((TR_RATING_LIMITS || $tr_cfg['limit_concurrent_ips']) && !$stopped)
- {
- $user_ratio = ($row['u_down_total'] && $row['u_down_total'] > MIN_DL_FOR_RATIO) ? ($row['u_up_total'] + $row['u_up_release'] + $row['u_up_bonus']) / $row['u_down_total'] : 1;
- $rating_msg = '';
+ // Ratio limits
+ if ((TR_RATING_LIMITS || $tr_cfg['limit_concurrent_ips']) && !$stopped) {
+ $user_ratio = ($row['u_down_total'] && $row['u_down_total'] > MIN_DL_FOR_RATIO) ? ($row['u_up_total'] + $row['u_up_release'] + $row['u_up_bonus']) / $row['u_down_total'] : 1;
+ $rating_msg = '';
- if (!$seeder)
- {
- foreach ($rating_limits as $ratio => $limit)
- {
- if ($user_ratio < $ratio)
- {
- $tr_cfg['limit_active_tor'] = 1;
- $tr_cfg['limit_leech_count'] = $limit;
- $rating_msg = " (ratio < $ratio)";
- break;
- }
- }
- }
+ if (!$seeder) {
+ foreach ($rating_limits as $ratio => $limit) {
+ if ($user_ratio < $ratio) {
+ $tr_cfg['limit_active_tor'] = 1;
+ $tr_cfg['limit_leech_count'] = $limit;
+ $rating_msg = " (ratio < $ratio)";
+ break;
+ }
+ }
+ }
- // Limit active torrents
- if (!isset($bb_cfg['unlimited_users'][$user_id]) && $tr_cfg['limit_active_tor'] && (($tr_cfg['limit_seed_count'] && $seeder) || ($tr_cfg['limit_leech_count'] && !$seeder)))
- {
- $sql = "SELECT COUNT(DISTINCT topic_id) AS active_torrents
- FROM ". BB_BT_TRACKER ."
+ // Limit active torrents
+ if (!isset($bb_cfg['unlimited_users'][$user_id]) && $tr_cfg['limit_active_tor'] && (($tr_cfg['limit_seed_count'] && $seeder) || ($tr_cfg['limit_leech_count'] && !$seeder))) {
+ $sql = "SELECT COUNT(DISTINCT topic_id) AS active_torrents
+ FROM " . BB_BT_TRACKER . "
WHERE user_id = $user_id
AND seeder = $seeder
AND topic_id != $topic_id";
- if (!$seeder && $tr_cfg['leech_expire_factor'] && $user_ratio < 0.5)
- {
- $sql .= " AND update_time > ". (TIMENOW - 60*$tr_cfg['leech_expire_factor']);
- }
- $sql .= " GROUP BY user_id";
+ if (!$seeder && $tr_cfg['leech_expire_factor'] && $user_ratio < 0.5) {
+ $sql .= " AND update_time > " . (TIMENOW - 60 * $tr_cfg['leech_expire_factor']);
+ }
+ $sql .= " GROUP BY user_id";
- if ($row = DB()->fetch_row($sql))
- {
- if ($seeder && $tr_cfg['limit_seed_count'] && $row['active_torrents'] >= $tr_cfg['limit_seed_count'])
- {
- msg_die('Only '. $tr_cfg['limit_seed_count'] .' torrent(s) allowed for seeding');
- }
- elseif (!$seeder && $tr_cfg['limit_leech_count'] && $row['active_torrents'] >= $tr_cfg['limit_leech_count'])
- {
- msg_die('Only '. $tr_cfg['limit_leech_count'] .' torrent(s) allowed for leeching'. $rating_msg);
- }
- }
- }
+ if ($row = DB()->fetch_row($sql)) {
+ if ($seeder && $tr_cfg['limit_seed_count'] && $row['active_torrents'] >= $tr_cfg['limit_seed_count']) {
+ msg_die('Only ' . $tr_cfg['limit_seed_count'] . ' torrent(s) allowed for seeding');
+ } elseif (!$seeder && $tr_cfg['limit_leech_count'] && $row['active_torrents'] >= $tr_cfg['limit_leech_count']) {
+ msg_die('Only ' . $tr_cfg['limit_leech_count'] . ' torrent(s) allowed for leeching' . $rating_msg);
+ }
+ }
+ }
- // Limit concurrent IPs
- if ($tr_cfg['limit_concurrent_ips'] && (($tr_cfg['limit_seed_ips'] && $seeder) || ($tr_cfg['limit_leech_ips'] && !$seeder)))
- {
- $sql = "SELECT COUNT(DISTINCT ip) AS ips
- FROM ". BB_BT_TRACKER ."
+ // Limit concurrent IPs
+ if ($tr_cfg['limit_concurrent_ips'] && (($tr_cfg['limit_seed_ips'] && $seeder) || ($tr_cfg['limit_leech_ips'] && !$seeder))) {
+ $sql = "SELECT COUNT(DISTINCT ip) AS ips
+ FROM " . BB_BT_TRACKER . "
WHERE topic_id = $topic_id
AND user_id = $user_id
AND seeder = $seeder
AND ip != '$ip_sql'";
- if (!$seeder && $tr_cfg['leech_expire_factor'])
- {
- $sql .= " AND update_time > ". (TIMENOW - 60*$tr_cfg['leech_expire_factor']);
- }
- $sql .= " GROUP BY topic_id";
+ if (!$seeder && $tr_cfg['leech_expire_factor']) {
+ $sql .= " AND update_time > " . (TIMENOW - 60 * $tr_cfg['leech_expire_factor']);
+ }
+ $sql .= " GROUP BY topic_id";
- if ($row = DB()->fetch_row($sql))
- {
- if ($seeder && $tr_cfg['limit_seed_ips'] && $row['ips'] >= $tr_cfg['limit_seed_ips'])
- {
- msg_die('You can seed only from '. $tr_cfg['limit_seed_ips'] ." IP's");
- }
- elseif (!$seeder && $tr_cfg['limit_leech_ips'] && $row['ips'] >= $tr_cfg['limit_leech_ips'])
- {
- msg_die('You can leech only from '. $tr_cfg['limit_leech_ips'] ." IP's");
- }
- }
- }
- }
+ if ($row = DB()->fetch_row($sql)) {
+ if ($seeder && $tr_cfg['limit_seed_ips'] && $row['ips'] >= $tr_cfg['limit_seed_ips']) {
+ msg_die('You can seed only from ' . $tr_cfg['limit_seed_ips'] . " IP's");
+ } elseif (!$seeder && $tr_cfg['limit_leech_ips'] && $row['ips'] >= $tr_cfg['limit_leech_ips']) {
+ msg_die('You can leech only from ' . $tr_cfg['limit_leech_ips'] . " IP's");
+ }
+ }
+ }
+ }
}
// Up/Down speed
$speed_up = $speed_down = 0;
-if ($lp_info && $lp_info['update_time'] < TIMENOW)
-{
- if ($uploaded > $lp_info['uploaded'])
- {
- $speed_up = ceil(($uploaded - $lp_info['uploaded']) / (TIMENOW - $lp_info['update_time']));
- }
- if ($downloaded > $lp_info['downloaded'])
- {
- $speed_down = ceil(($downloaded - $lp_info['downloaded']) / (TIMENOW - $lp_info['update_time']));
- }
+if ($lp_info && $lp_info['update_time'] < TIMENOW) {
+ if ($uploaded > $lp_info['uploaded']) {
+ $speed_up = ceil(($uploaded - $lp_info['uploaded']) / (TIMENOW - $lp_info['update_time']));
+ }
+ if ($downloaded > $lp_info['downloaded']) {
+ $speed_down = ceil(($downloaded - $lp_info['downloaded']) / (TIMENOW - $lp_info['update_time']));
+ }
}
// Up/Down addition
@@ -350,156 +332,152 @@ $up_add = ($lp_info && $uploaded > $lp_info['uploaded']) ? $uploaded - $lp_info[
$down_add = ($lp_info && $downloaded > $lp_info['downloaded']) ? $downloaded - $lp_info['downloaded'] : 0;
// Gold/Silver releases
-if ($tr_cfg['gold_silver_enabled'] && $down_add)
-{
- if ($tor_type == TOR_TYPE_GOLD)
- {
- $down_add = 0;
- }
- // Silver releases
- elseif ($tor_type == TOR_TYPE_SILVER)
- {
- $down_add = ceil($down_add/2);
- }
+if ($tr_cfg['gold_silver_enabled'] && $down_add) {
+ if ($tor_type == TOR_TYPE_GOLD) {
+ $down_add = 0;
+ } // Silver releases
+ elseif ($tor_type == TOR_TYPE_SILVER) {
+ $down_add = ceil($down_add / 2);
+ }
}
// Insert/update peer info
$peer_info_updated = false;
$update_time = ($stopped) ? 0 : TIMENOW;
-if ($lp_info)
-{
- $sql = "UPDATE ". BB_BT_TRACKER ." SET update_time = $update_time";
+if ($lp_info) {
+ $sql = "UPDATE " . BB_BT_TRACKER . " SET update_time = $update_time";
- $sql .= ", seeder = $seeder";
- $sql .= ($releaser != $lp_info['releaser']) ? ", releaser = $releaser" : '';
+ $sql .= ", seeder = $seeder";
+ $sql .= ($releaser != $lp_info['releaser']) ? ", releaser = $releaser" : '';
- $sql .= ($tor_type != $lp_info['tor_type']) ? ", tor_type = $tor_type" : '';
+ $sql .= ($tor_type != $lp_info['tor_type']) ? ", tor_type = $tor_type" : '';
- $sql .= ($uploaded != $lp_info['uploaded']) ? ", uploaded = $uploaded" : '';
- $sql .= ($downloaded != $lp_info['downloaded']) ? ", downloaded = $downloaded" : '';
- $sql .= ", remain = $left";
+ $sql .= ($uploaded != $lp_info['uploaded']) ? ", uploaded = $uploaded" : '';
+ $sql .= ($downloaded != $lp_info['downloaded']) ? ", downloaded = $downloaded" : '';
+ $sql .= ", remain = $left";
- $sql .= ($up_add) ? ", up_add = up_add + $up_add" : '';
- $sql .= ($down_add) ? ", down_add = down_add + $down_add" : '';
+ $sql .= ($up_add) ? ", up_add = up_add + $up_add" : '';
+ $sql .= ($down_add) ? ", down_add = down_add + $down_add" : '';
- $sql .= ", speed_up = $speed_up";
- $sql .= ", speed_down = $speed_down";
+ $sql .= ", speed_up = $speed_up";
+ $sql .= ", speed_down = $speed_down";
- $sql .= " WHERE peer_hash = '$peer_hash'";
- $sql .= " LIMIT 1";
+ $sql .= " WHERE peer_hash = '$peer_hash'";
+ $sql .= " LIMIT 1";
- DB()->query($sql);
+ DB()->query($sql);
- $peer_info_updated = DB()->affected_rows();
+ $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)
-{
- $columns = 'peer_hash, topic_id, user_id, ip, port, seeder, releaser, tor_type, uploaded, downloaded, remain, speed_up, speed_down, up_add, down_add, update_time';
- $values = "'$peer_hash', $topic_id, $user_id, '$ip_sql', $port, $seeder, $releaser, $tor_type, $uploaded, $downloaded, $left, $speed_up, $speed_down, $up_add, $down_add, $update_time";
+if (!$lp_info || !$peer_info_updated) {
+ $columns = 'peer_hash, topic_id, user_id, ip, port, seeder, releaser, tor_type, uploaded, downloaded, remain, speed_up, speed_down, up_add, down_add, update_time';
+ $values = "'$peer_hash', $topic_id, $user_id, '$ip_sql', $port, $seeder, $releaser, $tor_type, $uploaded, $downloaded, $left, $speed_up, $speed_down, $up_add, $down_add, $update_time";
- DB()->query("REPLACE INTO ". BB_BT_TRACKER ." ($columns) VALUES ($values)");
+ 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
-if ($stopped)
-{
- silent_exit();
+if ($stopped) {
+ silent_exit();
}
// Store peer info in cache
$lp_info = array(
- 'downloaded' => (float) $downloaded,
- 'releaser' => (int) $releaser,
- 'seeder' => (int) $seeder,
- 'topic_id' => (int) $topic_id,
- 'update_time' => (int) TIMENOW,
- 'uploaded' => (float) $uploaded,
- 'user_id' => (int) $user_id,
- 'tor_type' => (int) $tor_type,
+ 'downloaded' => (float)$downloaded,
+ 'releaser' => (int)$releaser,
+ 'seeder' => (int)$seeder,
+ 'topic_id' => (int)$topic_id,
+ 'update_time' => (int)TIMENOW,
+ 'uploaded' => (float)$uploaded,
+ 'user_id' => (int)$user_id,
+ 'tor_type' => (int)$tor_type,
);
$lp_info_cached = CACHE('tr_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('tr_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
- $numwant = (int) $tr_cfg['numwant'];
- $compact_mode = ($tr_cfg['compact_mode'] || !empty($compact));
+if (!$output) {
+ // Retrieve peers
+ $numwant = (int)$tr_cfg['numwant'];
+ $compact_mode = ($tr_cfg['compact_mode'] || !empty($compact));
- $rowset = DB()->fetch_rowset("
+ $rowset = DB()->fetch_rowset("
SELECT ip, port
- FROM ". BB_BT_TRACKER ."
+ FROM " . BB_BT_TRACKER . "
WHERE topic_id = $topic_id
ORDER BY RAND()
LIMIT $numwant
");
- if ($compact_mode)
- {
- $peers = '';
+ if ($compact_mode) {
+ $peers = '';
- foreach ($rowset as $peer)
- {
- $peers .= pack('Nn', ip2long(decode_ip($peer['ip'])), $peer['port']);
- }
- }
- else
- {
- $peers = array();
+ foreach ($rowset as $peer) {
+ $peers .= pack('Nn', ip2long(decode_ip($peer['ip'])), $peer['port']);
+ }
+ } else {
+ $peers = array();
- foreach ($rowset as $peer)
- {
- $peers[] = array(
- 'ip' => decode_ip($peer['ip']),
- 'port' => intval($peer['port']),
- );
- }
- }
+ foreach ($rowset as $peer) {
+ $peers[] = array(
+ 'ip' => decode_ip($peer['ip']),
+ 'port' => intval($peer['port']),
+ );
+ }
+ }
- $seeders = 0;
- $leechers = 0;
+ $seeders = 0;
+ $leechers = 0;
- if ($tr_cfg['scrape'])
- {
- $row = DB()->fetch_row("
+ if ($tr_cfg['scrape']) {
+ $row = DB()->fetch_row("
SELECT seeders, leechers
- FROM ". BB_BT_TRACKER_SNAP ."
+ FROM " . BB_BT_TRACKER_SNAP . "
WHERE topic_id = $topic_id
LIMIT 1
");
- $seeders = $row['seeders'];
- $leechers = $row['leechers'];
- }
+ $seeders = $row['seeders'];
+ $leechers = $row['leechers'];
+ }
- $output = array(
- 'interval' => (int) $announce_interval,
- 'min interval' => (int) $announce_interval,
- 'peers' => $peers,
- 'complete' => (int) $seeders,
- 'incomplete' => (int) $leechers,
- );
+ $output = array(
+ 'interval' => (int)$announce_interval,
+ 'min interval' => (int)$announce_interval,
+ 'peers' => $peers,
+ 'complete' => (int)$seeders,
+ 'incomplete' => (int)$leechers,
+ );
- $peers_list_cached = CACHE('tr_cache')->set(PEERS_LIST_PREFIX . $topic_id, $output, PEERS_LIST_EXPIRE);
+ $peers_list_cached = CACHE('tr_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
echo bencode($output);
tracker_exit();
-exit;
\ No newline at end of file
+exit;
diff --git a/bt/includes/init_tr.php b/bt/includes/init_tr.php
index 12e2cd139..29f4fa902 100644
--- a/bt/includes/init_tr.php
+++ b/bt/includes/init_tr.php
@@ -1,489 +1,495 @@
sql_inittime*100/$gen_time);
- $sql_total_perc = round($DBS->sql_timetotal*100/$gen_time);
+ if (DBG_LOG && DBG_TRACKER) {
+ if ($gen_time = utime() - TIMESTART) {
+ $sql_init_perc = round($DBS->sql_inittime * 100 / $gen_time);
+ $sql_total_perc = round($DBS->sql_timetotal * 100 / $gen_time);
- $str = array();
- $str[] = substr(TIMENOW, -4, 4);
- $str[] = sprintf('%.4f', $gen_time);
- $str[] = sprintf('%.4f'. LOG_SEPR .'%02d%%', $DBS->sql_inittime, $sql_init_perc);
- $str[] = sprintf('%.4f'. LOG_SEPR .'%02d%%', $DBS->sql_timetotal, $sql_total_perc);
- $str[] = $DBS->num_queries;
- $str[] = sprintf('%.1f', sys('la'));
- $str = join(LOG_SEPR, $str) . LOG_LF;
- dbg_log($str, '!!gentime');
- }
- }
- exit;
+ $str = array();
+ $str[] = substr(TIMENOW, -4, 4);
+ $str[] = sprintf('%.4f', $gen_time);
+ $str[] = sprintf('%.4f' . LOG_SEPR . '%02d%%', $DBS->sql_inittime, $sql_init_perc);
+ $str[] = sprintf('%.4f' . LOG_SEPR . '%02d%%', $DBS->sql_timetotal, $sql_total_perc);
+ $str[] = $DBS->num_queries;
+ $str[] = sprintf('%.1f', sys('la'));
+ $str = join(LOG_SEPR, $str) . LOG_LF;
+ dbg_log($str, '!!gentime');
+ }
+ }
+ exit;
}
-function silent_exit ()
+function silent_exit()
{
- while (@ob_end_clean());
+ while (@ob_end_clean()) ;
- tracker_exit();
+ tracker_exit();
}
-function error_exit ($msg = '')
+function error_exit($msg = '')
{
- if (DBG_LOG) dbg_log(' ', '!err-'. clean_filename($msg));
+ if (DBG_LOG) {
+ dbg_log(' ', '!err-' . clean_filename($msg));
+ }
- silent_exit();
+ silent_exit();
- echo bencode(array('failure reason' => str_compact($msg)));
+ echo bencode(array('failure reason' => str_compact($msg)));
- tracker_exit();
+ tracker_exit();
}
// Database
class sql_db
{
- 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 $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 $locked = false;
+ public $locked = false;
- 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;
+ 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;
- public $dbg = array();
- public $dbg_id = 0;
- public $dbg_enabled = false;
- public $cur_query = null;
+ public $dbg = array();
+ public $dbg_id = 0;
+ public $dbg_enabled = false;
+ public $cur_query = null;
- public $DBS = array();
+ public $DBS = array();
- /**
- * Constructor
- */
- function __construct ($cfg_values)
- {
- global $DBS;
+ /**
+ * Constructor
+ */
+ public function __construct($cfg_values)
+ {
+ global $DBS;
- $this->cfg = array_combine($this->cfg_keys, $cfg_values);
- $this->dbg_enabled = sql_dbg_enabled();
- $this->slow_time = SQL_SLOW_QUERY_TIME;
+ $this->cfg = array_combine($this->cfg_keys, $cfg_values);
+ $this->dbg_enabled = sql_dbg_enabled();
+ $this->slow_time = SQL_SLOW_QUERY_TIME;
- $this->DBS['num_queries'] =& $DBS->num_queries;
- $this->DBS['sql_inittime'] =& $DBS->sql_inittime;
- $this->DBS['sql_timetotal'] =& $DBS->sql_timetotal;
- }
+ $this->DBS['num_queries'] =& $DBS->num_queries;
+ $this->DBS['sql_inittime'] =& $DBS->sql_inittime;
+ $this->DBS['sql_timetotal'] =& $DBS->sql_timetotal;
+ }
- /**
- * Initialize connection
- */
- function init ()
- {
- // Connect to server
- $this->link = $this->connect();
+ /**
+ * Initialize connection
+ */
+ public function init()
+ {
+ // Connect to server
+ $this->link = $this->connect();
- // Select database
- $this->selected_db = $this->select_db();
+ // Select database
+ $this->selected_db = $this->select_db();
- // Set charset
- if ($this->cfg['charset'] && !@mysql_set_charset($this->cfg['charset'], $this->link))
- {
- if (!$this->sql_query("SET NAMES {$this->cfg['charset']}"))
- {
- error_exit("Could not set charset {$this->cfg['charset']}");
- }
- }
+ // Set charset
+ if ($this->cfg['charset'] && !@mysql_set_charset($this->cfg['charset'], $this->link)) {
+ if (!$this->sql_query("SET NAMES {$this->cfg['charset']}")) {
+ error_exit("Could not set charset {$this->cfg['charset']}");
+ }
+ }
- $this->num_queries = 0;
- $this->sql_inittime = $this->sql_timetotal;
- $this->DBS['sql_inittime'] += $this->sql_inittime;
- }
+ $this->num_queries = 0;
+ $this->sql_inittime = $this->sql_timetotal;
+ $this->DBS['sql_inittime'] += $this->sql_inittime;
+ }
- /**
- * Open connection
- */
- function connect ()
- {
- $this->cur_query = 'connect';
- $this->debug('start');
+ /**
+ * Open connection
+ */
+ public function connect()
+ {
+ $this->cur_query = 'connect';
+ $this->debug('start');
- $connect_type = ($this->cfg['persist']) ? 'mysql_pconnect' : 'mysql_connect';
+ $connect_type = ($this->cfg['persist']) ? 'mysql_pconnect' : 'mysql_connect';
- if (!$link = $connect_type($this->cfg['dbhost'], $this->cfg['dbuser'], $this->cfg['dbpasswd']))
- {
- $this->log_error();
- }
+ if (!$link = $connect_type($this->cfg['dbhost'], $this->cfg['dbuser'], $this->cfg['dbpasswd'])) {
+ $this->log_error();
+ }
- register_shutdown_function(array(&$this, 'close'));
+ register_shutdown_function(array(&$this, 'close'));
- $this->debug('end');
- $this->cur_query = null;
+ $this->debug('end');
+ $this->cur_query = null;
# if (DBG_LOG) dbg_log(' ', 'DB-connect'. ($link ? '' : '-FAIL'));
- if (!$link)
- {
- if (function_exists('dummy_exit'))
- {
- dummy_exit(mt_rand(1200, 2400));
- }
- else
- {
- die;
- }
- }
+ if (!$link) {
+ if (function_exists('dummy_exit')) {
+ dummy_exit(mt_rand(1200, 2400));
+ } else {
+ die;
+ }
+ }
- return $link;
- }
+ return $link;
+ }
- /**
- * Select database
- */
- function select_db ()
- {
- $this->cur_query = 'select db';
- $this->debug('start');
+ /**
+ * Select database
+ */
+ public function select_db()
+ {
+ $this->cur_query = 'select db';
+ $this->debug('start');
- if (!mysql_select_db($this->cfg['dbname'], $this->link))
- {
- $this->log_error();
- error_exit("Could not select database '{$this->cfg['dbname']}'");
- }
+ if (!mysql_select_db($this->cfg['dbname'], $this->link)) {
+ $this->log_error();
+ error_exit("Could not select database '{$this->cfg['dbname']}'");
+ }
- $this->debug('end');
- $this->cur_query = null;
+ $this->debug('end');
+ $this->cur_query = null;
- return $this->cfg['dbname'];
- }
+ return $this->cfg['dbname'];
+ }
- /**
- * Base query method
- */
- function sql_query ($query)
- {
- if (!is_resource($this->link))
- {
- $this->init();
- }
- $this->cur_query = $query;
- $this->debug('start');
+ /**
+ * Base query method
+ */
+ public function sql_query($query)
+ {
+ if (!is_resource($this->link)) {
+ $this->init();
+ }
+ $this->cur_query = $query;
+ $this->debug('start');
- if (!$this->result = mysql_query($query, $this->link))
- {
- $this->log_error();
- }
+ if (!$this->result = mysql_query($query, $this->link)) {
+ $this->log_error();
+ }
- $this->debug('end');
- $this->cur_query = null;
+ $this->debug('end');
+ $this->cur_query = null;
- $this->num_queries++;
- $this->DBS['num_queries']++;
+ $this->num_queries++;
+ $this->DBS['num_queries']++;
- return $this->result;
- }
+ return $this->result;
+ }
- /**
- * Execute query WRAPPER (with error handling)
- */
- function query ($query)
- {
- if (!$result = $this->sql_query($query))
- {
- $this->trigger_error();
- }
+ /**
+ * Execute query WRAPPER (with error handling)
+ */
+ public function query($query)
+ {
+ if (!$result = $this->sql_query($query)) {
+ $this->trigger_error();
+ }
- return $result;
- }
+ return $result;
+ }
- /**
- * Return number of rows
- */
- function num_rows ($result = false)
- {
- $num_rows = false;
+ /**
+ * Return number of rows
+ */
+ public function num_rows($result = false)
+ {
+ $num_rows = false;
- if ($result OR $result = $this->result)
- {
- $num_rows = is_resource($result) ? mysql_num_rows($result) : false;
- }
+ if ($result or $result = $this->result) {
+ $num_rows = is_resource($result) ? mysql_num_rows($result) : false;
+ }
- return $num_rows;
- }
+ return $num_rows;
+ }
- /**
- * Return number of affected rows
- */
- function affected_rows ()
- {
- return is_resource($this->link) ? mysql_affected_rows($this->link) : -1;
- }
+ /**
+ * Return number of affected rows
+ */
+ public function affected_rows()
+ {
+ return is_resource($this->link) ? mysql_affected_rows($this->link) : -1;
+ }
- /**
- * Fetch current row
- */
- function sql_fetchrow ($result)
- {
- return is_resource($result) ? mysql_fetch_assoc($result) : false;
- }
+ /**
+ * Fetch current row
+ */
+ public function sql_fetchrow($result)
+ {
+ return is_resource($result) ? mysql_fetch_assoc($result) : false;
+ }
- /**
- * Alias of sql_fetchrow()
- */
- function fetch_next ($result)
- {
- return $this->sql_fetchrow($result);
- }
+ /**
+ * Alias of sql_fetchrow()
+ */
+ public function fetch_next($result)
+ {
+ return $this->sql_fetchrow($result);
+ }
- /**
- * Fetch row WRAPPER (with error handling)
- */
- function fetch_row ($query)
- {
- if (!$result = $this->sql_query($query))
- {
- $this->trigger_error();
- }
+ /**
+ * Fetch row WRAPPER (with error handling)
+ */
+ public function fetch_row($query)
+ {
+ if (!$result = $this->sql_query($query)) {
+ $this->trigger_error();
+ }
- return $this->sql_fetchrow($result);
- }
+ return $this->sql_fetchrow($result);
+ }
- /**
- * Fetch all rows
- */
- function sql_fetchrowset ($result)
- {
- $rowset = array();
+ /**
+ * Fetch all rows
+ */
+ public function sql_fetchrowset($result)
+ {
+ $rowset = array();
- while ($row = mysql_fetch_assoc($result))
- {
- $rowset[] = $row;
- }
+ while ($row = mysql_fetch_assoc($result)) {
+ $rowset[] = $row;
+ }
- return $rowset;
- }
+ return $rowset;
+ }
- /**
- * Fetch all rows WRAPPER (with error handling)
- */
- function fetch_rowset ($query)
- {
- if (!$result = $this->sql_query($query))
- {
- $this->trigger_error();
- }
+ /**
+ * Fetch all rows WRAPPER (with error handling)
+ */
+ public function fetch_rowset($query)
+ {
+ if (!$result = $this->sql_query($query)) {
+ $this->trigger_error();
+ }
- return $this->sql_fetchrowset($result);
- }
+ return $this->sql_fetchrowset($result);
+ }
- /**
- * Escape string used in sql query
- */
- function escape ($v, $check_type = false)
- {
- if (!is_resource($this->link))
- {
- $this->init();
- }
- if (!$check_type)
- {
- return mysql_real_escape_string($v);
- }
+ /**
+ * Escape string used in sql query
+ */
+ public function escape($v, $check_type = false)
+ {
+ if (!is_resource($this->link)) {
+ $this->init();
+ }
+ if (!$check_type) {
+ return mysql_real_escape_string($v);
+ }
- switch (true)
- {
- case is_string ($v): return "'". mysql_real_escape_string($v) ."'";
- case is_int ($v): return "$v";
- case is_bool ($v): return ($v) ? '1' : '0';
- case is_float ($v): return "'$v'";
- case is_null ($v): return 'NULL';
- }
- // if $v has unsuitable type
- $this->trigger_error(__FUNCTION__ .' - wrong params');
- }
+ switch (true) {
+ case is_string($v):
+ return "'" . mysql_real_escape_string($v) . "'";
+ case is_int($v):
+ return "$v";
+ case is_bool($v):
+ return ($v) ? '1' : '0';
+ case is_float($v):
+ return "'$v'";
+ case is_null($v):
+ return 'NULL';
+ }
+ // if $v has unsuitable type
+ $this->trigger_error(__FUNCTION__ . ' - wrong params');
+ }
- /**
- * Return sql error array
- */
- function sql_error ()
- {
- $return_ary = array(
- 'code' => '',
- 'message' => 'not connected',
- );
+ /**
+ * Return sql error array
+ */
+ public function sql_error()
+ {
+ $return_ary = array(
+ 'code' => '',
+ 'message' => 'not connected',
+ );
- if (is_resource($this->link))
- {
- $return_ary = array(
- 'code' => mysql_errno($this->link),
- 'message' => mysql_error($this->link),
- );
- }
+ if (is_resource($this->link)) {
+ $return_ary = array(
+ 'code' => mysql_errno($this->link),
+ 'message' => mysql_error($this->link),
+ );
+ }
- return $return_ary;
- }
+ return $return_ary;
+ }
- /**
- * Close sql connection
- */
- function close ()
- {
- if (is_resource($this->link))
- {
- mysql_close($this->link);
- }
+ /**
+ * Close sql connection
+ */
+ public function close()
+ {
+ if (is_resource($this->link)) {
+ mysql_close($this->link);
+ }
- $this->link = $this->selected_db = null;
+ $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 ()
- {
- $info = array();
+ /**
+ * Get info about last query
+ */
+ public function query_info()
+ {
+ $info = array();
- if ($num = $this->num_rows($this->result))
- {
- $info[] = "$num rows";
- }
+ if ($num = $this->num_rows($this->result)) {
+ $info[] = "$num rows";
+ }
- if (is_resource($this->link) AND $ext = mysql_info($this->link))
- {
- $info[] = "$ext";
- }
- elseif (!$num && ($aff = $this->affected_rows($this->result) AND $aff != -1))
- {
- $info[] = "$aff rows";
- }
+ if (is_resource($this->link) and $ext = mysql_info($this->link)) {
+ $info[] = "$ext";
+ } elseif (!$num && ($aff = $this->affected_rows($this->result) and $aff != -1)) {
+ $info[] = "$aff rows";
+ }
- return join(', ', $info);
- }
+ return join(', ', $info);
+ }
- /**
- * Store debug info
- */
- function debug ($mode)
- {
- if (!SQL_DEBUG) return;
+ /**
+ * Store debug info
+ */
+ public function debug($mode)
+ {
+ if (!SQL_DEBUG) {
+ return;
+ }
- if ($mode == 'start')
- {
- if (SQL_CALC_QUERY_TIME || DBG_LOG || SQL_LOG_SLOW_QUERIES)
- {
- $this->sql_starttime = utime();
- $this->sql_last_time = 0;
- }
- }
- elseif ($mode == 'end')
- {
- if (SQL_CALC_QUERY_TIME || DBG_LOG || SQL_LOG_SLOW_QUERIES)
- {
- $this->sql_last_time = utime() - $this->sql_starttime;
- $this->sql_timetotal += $this->sql_last_time;
- $this->DBS['sql_timetotal'] += $this->sql_last_time;
+ if ($mode == 'start') {
+ if (SQL_CALC_QUERY_TIME || DBG_LOG || SQL_LOG_SLOW_QUERIES) {
+ $this->sql_starttime = utime();
+ $this->sql_last_time = 0;
+ }
+ } elseif ($mode == 'end') {
+ if (SQL_CALC_QUERY_TIME || DBG_LOG || SQL_LOG_SLOW_QUERIES) {
+ $this->sql_last_time = utime() - $this->sql_starttime;
+ $this->sql_timetotal += $this->sql_last_time;
+ $this->DBS['sql_timetotal'] += $this->sql_last_time;
- if (SQL_LOG_SLOW_QUERIES && $this->sql_last_time > $this->slow_time)
- {
- $msg = date('m-d H:i:s') . LOG_SEPR;
- $msg .= sprintf('%03d', round($this->sql_last_time));
- $msg .= LOG_SEPR . sprintf('%.1f', sys('la'));
- $msg .= LOG_SEPR . str_compact($this->cur_query);
- $msg .= LOG_SEPR .' # '. $this->query_info();
- $msg .= LOG_SEPR . $this->debug_find_source();
- bb_log($msg . LOG_LF, 'sql_slow_tr');
- }
- }
- }
- return;
- }
+ if (SQL_LOG_SLOW_QUERIES && $this->sql_last_time > $this->slow_time) {
+ $msg = date('m-d H:i:s') . LOG_SEPR;
+ $msg .= sprintf('%03d', round($this->sql_last_time));
+ $msg .= LOG_SEPR . sprintf('%.1f', sys('la'));
+ $msg .= LOG_SEPR . str_compact($this->cur_query);
+ $msg .= LOG_SEPR . ' # ' . $this->query_info();
+ $msg .= LOG_SEPR . $this->debug_find_source();
+ bb_log($msg . LOG_LF, 'sql_slow_tr');
+ }
+ }
+ }
+ return;
+ }
- /**
- * Trigger error
- */
- function trigger_error ($msg = '')
- {
- if (error_reporting())
- {
- if (!$msg) $msg = 'DB Error';
+ /**
+ * Trigger error
+ */
+ public function trigger_error($msg = '')
+ {
+ if (error_reporting()) {
+ if (!$msg) {
+ $msg = 'DB Error';
+ }
- if (DBG_TRACKER === true)
- {
- $err = $this->sql_error();
- $msg .= trim(sprintf(' #%06d %s', $err['code'], $err['message']));
- }
- else
- {
- $msg .= " [". $this->debug_find_source() ."]";
- }
+ if (DBG_TRACKER === true) {
+ $err = $this->sql_error();
+ $msg .= trim(sprintf(' #%06d %s', $err['code'], $err['message']));
+ } else {
+ $msg .= " [" . $this->debug_find_source() . "]";
+ }
- error_exit($msg);
- }
- }
+ error_exit($msg);
+ }
+ }
- /**
- * Find caller source
- */
- function debug_find_source ()
- {
- $source = '';
- $backtrace = debug_backtrace();
+ /**
+ * Find caller source
+ */
+ public function debug_find_source()
+ {
+ $source = '';
+ $backtrace = debug_backtrace();
- foreach ($backtrace as $trace)
- {
- if ($trace['file'] !== __FILE__)
- {
- $source = str_replace(BB_PATH, '', $trace['file']) .'('. $trace['line'] .')';
- break;
- }
- }
+ foreach ($backtrace as $trace) {
+ if ($trace['file'] !== __FILE__) {
+ $source = str_replace(BB_PATH, '', $trace['file']) . '(' . $trace['line'] . ')';
+ break;
+ }
+ }
- return $source;
- }
+ return $source;
+ }
- /**
- * Log error
- */
- function log_error ()
- {
- if (!SQL_LOG_ERRORS) return;
- if (!error_reporting()) return;
+ /**
+ * Log error
+ */
+ public function log_error()
+ {
+ if (!SQL_LOG_ERRORS) {
+ return;
+ }
+ if (!error_reporting()) {
+ return;
+ }
- $msg = array();
- $err = $this->sql_error();
- $msg[] = str_compact(sprintf('#%06d %s', $err['code'], $err['message']));
- $msg[] = '';
- $msg[] = str_compact($this->cur_query);
- $msg[] = '';
- $msg[] = 'Source : '. $this->debug_find_source();
- $msg[] = 'IP : '. @$_SERVER['REMOTE_ADDR'];
- $msg[] = 'Date : '. date('Y-m-d H:i:s');
- $msg[] = 'Agent : '. @$_SERVER['HTTP_USER_AGENT'];
- $msg[] = 'Req_URI : '. @$_SERVER['REQUEST_URI'];
- $msg[] = 'Referer : '. @$_SERVER['HTTP_REFERER'];
- $msg[] = 'Method : '. @$_SERVER['REQUEST_METHOD'];
- $msg[] = 'Request : '. trim(print_r($_REQUEST, true)) . str_repeat('_', 78) . LOG_LF;
- $msg[] = '';
- bb_log($msg, 'sql_error_tr');
- }
+ $msg = array();
+ $err = $this->sql_error();
+ $msg[] = str_compact(sprintf('#%06d %s', $err['code'], $err['message']));
+ $msg[] = '';
+ $msg[] = str_compact($this->cur_query);
+ $msg[] = '';
+ $msg[] = 'Source : ' . $this->debug_find_source();
+ $msg[] = 'IP : ' . @$_SERVER['REMOTE_ADDR'];
+ $msg[] = 'Date : ' . date('Y-m-d H:i:s');
+ $msg[] = 'Agent : ' . @$_SERVER['HTTP_USER_AGENT'];
+ $msg[] = 'Req_URI : ' . @$_SERVER['REQUEST_URI'];
+ $msg[] = 'Referer : ' . @$_SERVER['HTTP_REFERER'];
+ $msg[] = 'Method : ' . @$_SERVER['REQUEST_METHOD'];
+ $msg[] = 'Request : ' . trim(print_r($_REQUEST, true)) . str_repeat('_', 78) . LOG_LF;
+ $msg[] = '';
+ bb_log($msg, 'sql_error_tr');
+ }
}
diff --git a/bt/index.php b/bt/index.php
index 7e44c5d1d..91bcd590d 100644
--- a/bt/index.php
+++ b/bt/index.php
@@ -1,3 +1,26 @@
(int) 1800,
- 'failure reason' => (string) $msg,
- 'warning message' => (string) $msg,
- ));
+ $output = bencode(array(
+ 'min interval' => (int)1800,
+ 'failure reason' => (string)$msg,
+ 'warning message' => (string)$msg,
+ ));
- die($output);
+ die($output);
}
define('TR_ROOT', './');
@@ -39,19 +64,19 @@ $info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
$row = DB()->fetch_row("
SELECT tor.complete_count, snap.seeders, snap.leechers
- FROM ". BB_BT_TORRENTS ." tor
- LEFT JOIN ". BB_BT_TRACKER_SNAP ." snap ON (snap.topic_id = tor.topic_id)
+ FROM " . BB_BT_TORRENTS . " tor
+ LEFT JOIN " . BB_BT_TRACKER_SNAP . " snap ON (snap.topic_id = tor.topic_id)
WHERE tor.info_hash = '$info_hash_sql'
LIMIT 1
");
$output['files'][$info_hash] = array(
- 'complete' => (int) $row['seeders'],
- 'downloaded' => (int) $row['complete_count'],
- 'incomplete' => (int) $row['leechers'],
+ 'complete' => (int)$row['seeders'],
+ 'downloaded' => (int)$row['complete_count'],
+ 'incomplete' => (int)$row['leechers'],
);
echo bencode($output);
tracker_exit();
-exit;
\ No newline at end of file
+exit;
diff --git a/callseed.php b/callseed.php
index 0db99f1cd..dce73885b 100644
--- a/callseed.php
+++ b/callseed.php
@@ -1,4 +1,27 @@
session_start(array('req_login' => true));
-$topic_id = (int) request_var('t', 0);
-$t_data = topic_info($topic_id);
+$topic_id = (int)request_var('t', 0);
+$t_data = topic_info($topic_id);
$forum_id = $t_data['forum_id'];
set_die_append_msg($forum_id, $topic_id);
-if ($t_data['seeders'] > 2)
-{
- bb_die(sprintf($lang['CALLSEED_HAVE_SEED'], $t_data['seeders']));
-}
-elseif ($t_data['call_seed_time'] > (TIMENOW - 86400))
-{
- $time_left = delta_time($t_data['call_seed_time'] + 86400, TIMENOW, 'days');
- bb_die(sprintf($lang['CALLSEED_MSG_SPAM'], $time_left));
+if ($t_data['seeders'] > 2) {
+ bb_die(sprintf($lang['CALLSEED_HAVE_SEED'], $t_data['seeders']));
+} elseif ($t_data['call_seed_time'] > (TIMENOW - 86400)) {
+ $time_left = delta_time($t_data['call_seed_time'] + 86400, TIMENOW, 'days');
+ bb_die(sprintf($lang['CALLSEED_MSG_SPAM'], $time_left));
}
$ban_user_id = array();
-$sql = DB()->fetch_rowset("SELECT ban_userid FROM ". BB_BANLIST ." WHERE ban_userid != 0");
+$sql = DB()->fetch_rowset("SELECT ban_userid FROM " . BB_BANLIST . " WHERE ban_userid != 0");
-foreach ($sql as $row)
-{
- $ban_user_id[] = ','. $row['ban_userid'];
+foreach ($sql as $row) {
+ $ban_user_id[] = ',' . $row['ban_userid'];
}
$ban_user_id = join('', $ban_user_id);
$user_list = DB()->fetch_rowset("
SELECT DISTINCT dl.user_id, u.user_opt, tr.user_id as active_dl
- FROM ". BB_BT_DLSTATUS ." dl
- LEFT JOIN ". BB_USERS ." u ON(u.user_id = dl.user_id)
- LEFT JOIN ". BB_BT_TRACKER ." tr ON(tr.user_id = dl.user_id)
+ FROM " . BB_BT_DLSTATUS . " dl
+ LEFT JOIN " . BB_USERS . " u ON(u.user_id = dl.user_id)
+ LEFT JOIN " . BB_BT_TRACKER . " tr ON(tr.user_id = dl.user_id)
WHERE dl.topic_id = $topic_id
- AND dl.user_status IN (". DL_STATUS_COMPLETE.", ". DL_STATUS_DOWN.")
- AND dl.user_id NOT IN ({$userdata['user_id']}, ". EXCLUDED_USERS_CSV . $ban_user_id .")
+ AND dl.user_status IN (" . DL_STATUS_COMPLETE . ", " . DL_STATUS_DOWN . ")
+ AND dl.user_id NOT IN ({$userdata['user_id']}, " . EXCLUDED_USERS_CSV . $ban_user_id . ")
AND u.user_active = 1
GROUP BY dl.user_id
");
@@ -49,46 +68,42 @@ $user_list = DB()->fetch_rowset("
$subject = sprintf($lang['CALLSEED_SUBJECT'], $t_data['topic_title']);
$message = sprintf($lang['CALLSEED_TEXT'], make_url(TOPIC_URL . $topic_id), $t_data['topic_title'], make_url(DOWNLOAD_URL . $t_data['attach_id']));
-if ($user_list)
-{
- foreach ($user_list as $row)
- {
- if (!empty($row['active_dl'])) continue;
+if ($user_list) {
+ foreach ($user_list as $row) {
+ if (!empty($row['active_dl'])) {
+ continue;
+ }
- if (bf($row['user_opt'], 'user_opt', 'user_callseed'))
- {
- send_pm($row['user_id'], $subject, $message, BOT_UID);
- }
- }
-}
-else
-{
- send_pm($t_data['poster_id'], $subject, $message, BOT_UID);
+ if (bf($row['user_opt'], 'user_opt', 'user_callseed')) {
+ send_pm($row['user_id'], $subject, $message, BOT_UID);
+ }
+ }
+} else {
+ send_pm($t_data['poster_id'], $subject, $message, BOT_UID);
}
-DB()->query("UPDATE ". BB_BT_TORRENTS ." SET call_seed_time = ". TIMENOW ." WHERE topic_id = $topic_id LIMIT 1");
+DB()->query("UPDATE " . BB_BT_TORRENTS . " SET call_seed_time = " . TIMENOW . " WHERE topic_id = $topic_id LIMIT 1");
meta_refresh(TOPIC_URL . $topic_id);
bb_die($lang['CALLSEED_MSG_OK']);
-function topic_info ($topic_id)
+function topic_info($topic_id)
{
- global $lang;
+ global $lang;
- $sql = "
+ $sql = "
SELECT
tor.poster_id, tor.forum_id, tor.attach_id, tor.call_seed_time,
t.topic_title, sn.seeders
- FROM ". BB_BT_TORRENTS ." tor
- LEFT JOIN ". BB_TOPICS ." t USING(topic_id)
- LEFT JOIN ". BB_BT_TRACKER_SNAP ." sn USING(topic_id)
+ FROM " . BB_BT_TORRENTS . " tor
+ LEFT JOIN " . BB_TOPICS . " t USING(topic_id)
+ LEFT JOIN " . BB_BT_TRACKER_SNAP . " sn USING(topic_id)
WHERE tor.topic_id = $topic_id
";
- if (!$torrent = DB()->fetch_row($sql))
- {
- bb_die($lang['TOPIC_POST_NOT_EXIST']);
- }
+ if (!$torrent = DB()->fetch_row($sql)) {
+ bb_die($lang['TOPIC_POST_NOT_EXIST']);
+ }
- return $torrent;
+ return $torrent;
}
diff --git a/common.php b/common.php
index b1e961d7c..462007360 100644
--- a/common.php
+++ b/common.php
@@ -1,18 +1,55 @@
true));
$loader->register();
@@ -38,29 +76,29 @@ unset($server_protocol, $server_port);
define('DBG_USER', (isset($_COOKIE[COOKIE_DBG])));
// Board/Tracker shared constants and functions
-define('BB_BT_TORRENTS', 'bb_bt_torrents');
-define('BB_BT_TRACKER', 'bb_bt_tracker');
+define('BB_BT_TORRENTS', 'bb_bt_torrents');
+define('BB_BT_TRACKER', 'bb_bt_tracker');
define('BB_BT_TRACKER_SNAP', 'bb_bt_tracker_snap');
-define('BB_BT_USERS', 'bb_bt_users');
+define('BB_BT_USERS', 'bb_bt_users');
define('BT_AUTH_KEY_LENGTH', 10);
-define('PEER_HASH_PREFIX', 'peer_');
-define('PEERS_LIST_PREFIX', 'peers_list_');
-define('PEER_HASH_EXPIRE', round($bb_cfg['announce_interval'] * (0.85 * $tr_cfg['expire_factor']))); // sec
-define('PEERS_LIST_EXPIRE', round($bb_cfg['announce_interval'] * 0.7)); // sec
+define('PEER_HASH_PREFIX', 'peer_');
+define('PEERS_LIST_PREFIX', 'peers_list_');
+define('PEER_HASH_EXPIRE', round($bb_cfg['announce_interval'] * (0.85 * $tr_cfg['expire_factor']))); // sec
+define('PEERS_LIST_EXPIRE', round($bb_cfg['announce_interval'] * 0.7)); // sec
define('DL_STATUS_RELEASER', -1);
-define('DL_STATUS_DOWN', 0);
-define('DL_STATUS_COMPLETE', 1);
-define('DL_STATUS_CANCEL', 3);
-define('DL_STATUS_WILL', 4);
+define('DL_STATUS_DOWN', 0);
+define('DL_STATUS_COMPLETE', 1);
+define('DL_STATUS_CANCEL', 3);
+define('DL_STATUS_WILL', 4);
-define('TOR_TYPE_GOLD', 1);
-define('TOR_TYPE_SILVER', 2);
+define('TOR_TYPE_GOLD', 1);
+define('TOR_TYPE_SILVER', 2);
define('GUEST_UID', -1);
-define('BOT_UID', -746);
+define('BOT_UID', -746);
/**
* Database
@@ -69,10 +107,10 @@ define('BOT_UID', -746);
require(CORE_DIR . 'dbs.php');
$DBS = new DBS($bb_cfg);
-function DB ($db_alias = 'db1')
+function DB($db_alias = 'db1')
{
- global $DBS;
- return $DBS->get_db_obj($db_alias);
+ global $DBS;
+ return $DBS->get_db_obj($db_alias);
}
/**
@@ -87,10 +125,10 @@ require(INC_DIR . 'datastore/common.php');
require(CORE_DIR . 'caches.php');
$CACHES = new CACHES($bb_cfg);
-function CACHE ($cache_name)
+function CACHE($cache_name)
{
- global $CACHES;
- return $CACHES->get_cache_obj($cache_name);
+ global $CACHES;
+ return $CACHES->get_cache_obj($cache_name);
}
// Common cache classes
@@ -102,8 +140,8 @@ require(INC_DIR . 'cache/xcache.php');
require(INC_DIR . 'cache/file.php');
/**
-* Datastore
-*/
+ * Datastore
+ */
// Common datastore classes
require(INC_DIR . 'datastore/memcache.php');
require(INC_DIR . 'datastore/sqlite.php');
@@ -113,398 +151,354 @@ require(INC_DIR . 'datastore/xcache.php');
require(INC_DIR . 'datastore/file.php');
// Initialize datastore
-switch ($bb_cfg['datastore_type'])
-{
- case 'memcache':
- $datastore = new datastore_memcache($bb_cfg['cache']['memcache'], $bb_cfg['cache']['prefix']);
- break;
+switch ($bb_cfg['datastore_type']) {
+ case 'memcache':
+ $datastore = new datastore_memcache($bb_cfg['cache']['memcache'], $bb_cfg['cache']['prefix']);
+ break;
- case 'sqlite':
- $default_cfg = array(
- 'db_file_path' => $bb_cfg['cache']['db_dir'] .'datastore.sqlite.db',
- 'pconnect' => true,
- 'con_required' => true,
- );
- $datastore = new datastore_sqlite($default_cfg, $bb_cfg['cache']['prefix']);
- break;
+ case 'sqlite':
+ $default_cfg = array(
+ 'db_file_path' => $bb_cfg['cache']['db_dir'] . 'datastore.sqlite.db',
+ 'pconnect' => true,
+ 'con_required' => true,
+ );
+ $datastore = new datastore_sqlite($default_cfg, $bb_cfg['cache']['prefix']);
+ break;
- case 'redis':
- $datastore = new datastore_redis($bb_cfg['cache']['redis'], $bb_cfg['cache']['prefix']);
- break;
+ case 'redis':
+ $datastore = new datastore_redis($bb_cfg['cache']['redis'], $bb_cfg['cache']['prefix']);
+ break;
- case 'apc':
- $datastore = new datastore_apc($bb_cfg['cache']['prefix']);
- break;
+ case 'apc':
+ $datastore = new datastore_apc($bb_cfg['cache']['prefix']);
+ break;
- case 'xcache':
- $datastore = new datastore_xcache($bb_cfg['cache']['prefix']);
- break;
+ case 'xcache':
+ $datastore = new datastore_xcache($bb_cfg['cache']['prefix']);
+ break;
- case 'filecache':
- default: $datastore = new datastore_file($bb_cfg['cache']['db_dir'] . 'datastore/', $bb_cfg['cache']['prefix']);
+ case 'filecache':
+ default:
+ $datastore = new datastore_file($bb_cfg['cache']['db_dir'] . 'datastore/', $bb_cfg['cache']['prefix']);
}
-function sql_dbg_enabled ()
+function sql_dbg_enabled()
{
- return (SQL_DEBUG && DBG_USER && !empty($_COOKIE['sql_log']));
+ return (SQL_DEBUG && DBG_USER && !empty($_COOKIE['sql_log']));
}
-function short_query ($sql, $esc_html = false)
+function short_query($sql, $esc_html = false)
{
- $max_len = 100;
- $sql = str_compact($sql);
+ $max_len = 100;
+ $sql = str_compact($sql);
- if (!empty($_COOKIE['sql_log_full']))
- {
- if (mb_strlen($sql, 'UTF-8') > $max_len)
- {
- $sql = mb_substr($sql, 0, 50) .' [...cut...] '. mb_substr($sql, -50);
- }
- }
+ if (!empty($_COOKIE['sql_log_full'])) {
+ if (mb_strlen($sql, 'UTF-8') > $max_len) {
+ $sql = mb_substr($sql, 0, 50) . ' [...cut...] ' . mb_substr($sql, -50);
+ }
+ }
- return ($esc_html) ? htmlCHR($sql, true) : $sql;
+ return ($esc_html) ? htmlCHR($sql, true) : $sql;
}
// Functions
-function utime ()
+function utime()
{
- return array_sum(explode(' ', microtime()));
+ return array_sum(explode(' ', microtime()));
}
-function bb_log ($msg, $file_name)
+function bb_log($msg, $file_name)
{
- if (is_array($msg))
- {
- $msg = join(LOG_LF, $msg);
- }
- $file_name .= (LOG_EXT) ? '.'. LOG_EXT : '';
- return file_write($msg, LOG_DIR . $file_name);
+ if (is_array($msg)) {
+ $msg = join(LOG_LF, $msg);
+ }
+ $file_name .= (LOG_EXT) ? '.' . LOG_EXT : '';
+ return file_write($msg, LOG_DIR . $file_name);
}
-function file_write ($str, $file, $max_size = LOG_MAX_SIZE, $lock = true, $replace_content = false)
+function file_write($str, $file, $max_size = LOG_MAX_SIZE, $lock = true, $replace_content = false)
{
- $bytes_written = false;
+ $bytes_written = false;
- if ($max_size && @filesize($file) >= $max_size)
- {
- $old_name = $file; $ext = '';
- if (preg_match('#^(.+)(\.[^\\/]+)$#', $file, $matches))
- {
- $old_name = $matches[1]; $ext = $matches[2];
- }
- $new_name = $old_name .'_[old]_'. date('Y-m-d_H-i-s_') . getmypid() . $ext;
- clearstatcache();
- if (@file_exists($file) && @filesize($file) >= $max_size && !@file_exists($new_name))
- {
- @rename($file, $new_name);
- }
- }
- if (!$fp = @fopen($file, 'ab'))
- {
- if ($dir_created = bb_mkdir(dirname($file)))
- {
- $fp = @fopen($file, 'ab');
- }
- }
- if ($fp)
- {
- if ($lock)
- {
- @flock($fp, LOCK_EX);
- }
- if ($replace_content)
- {
- @ftruncate($fp, 0);
- @fseek($fp, 0, SEEK_SET);
- }
- $bytes_written = @fwrite($fp, $str);
- @fclose($fp);
- }
+ if ($max_size && @filesize($file) >= $max_size) {
+ $old_name = $file;
+ $ext = '';
+ if (preg_match('#^(.+)(\.[^\\/]+)$#', $file, $matches)) {
+ $old_name = $matches[1];
+ $ext = $matches[2];
+ }
+ $new_name = $old_name . '_[old]_' . date('Y-m-d_H-i-s_') . getmypid() . $ext;
+ clearstatcache();
+ if (@file_exists($file) && @filesize($file) >= $max_size && !@file_exists($new_name)) {
+ @rename($file, $new_name);
+ }
+ }
+ if (!$fp = @fopen($file, 'ab')) {
+ if ($dir_created = bb_mkdir(dirname($file))) {
+ $fp = @fopen($file, 'ab');
+ }
+ }
+ if ($fp) {
+ if ($lock) {
+ @flock($fp, LOCK_EX);
+ }
+ if ($replace_content) {
+ @ftruncate($fp, 0);
+ @fseek($fp, 0, SEEK_SET);
+ }
+ $bytes_written = @fwrite($fp, $str);
+ @fclose($fp);
+ }
- return $bytes_written;
+ return $bytes_written;
}
-function bb_mkdir ($path, $mode = 0777)
+function bb_mkdir($path, $mode = 0777)
{
- $old_um = umask(0);
- $dir = mkdir_rec($path, $mode);
- umask($old_um);
- return $dir;
+ $old_um = umask(0);
+ $dir = mkdir_rec($path, $mode);
+ umask($old_um);
+ return $dir;
}
-function mkdir_rec ($path, $mode)
+function mkdir_rec($path, $mode)
{
- if (is_dir($path))
- {
- return ($path !== '.' && $path !== '..') ? is_writable($path) : false;
- }
- else
- {
- return (mkdir_rec(dirname($path), $mode)) ? @mkdir($path, $mode) : false;
- }
+ if (is_dir($path)) {
+ return ($path !== '.' && $path !== '..') ? is_writable($path) : false;
+ } else {
+ return (mkdir_rec(dirname($path), $mode)) ? @mkdir($path, $mode) : false;
+ }
}
-function verify_id ($id, $length)
+function verify_id($id, $length)
{
- return (is_string($id) && preg_match('#^[a-zA-Z0-9]{'. $length .'}$#', $id));
+ return (is_string($id) && preg_match('#^[a-zA-Z0-9]{' . $length . '}$#', $id));
}
-function clean_filename ($fname)
+function clean_filename($fname)
{
- static $s = array('\\', '/', ':', '*', '?', '"', '<', '>', '|', ' ');
- return str_replace($s, '_', str_compact($fname));
+ static $s = array('\\', '/', ':', '*', '?', '"', '<', '>', '|', ' ');
+ return str_replace($s, '_', str_compact($fname));
}
-function encode_ip ($ip)
+function encode_ip($ip)
{
- $d = explode('.', $ip);
- return sprintf('%02x%02x%02x%02x', $d[0], $d[1], $d[2], $d[3]);
+ $d = explode('.', $ip);
+ return sprintf('%02x%02x%02x%02x', $d[0], $d[1], $d[2], $d[3]);
}
-function decode_ip ($ip)
+function decode_ip($ip)
{
- return long2ip("0x{$ip}");
+ return long2ip("0x{$ip}");
}
-function ip2int ($ip)
+function ip2int($ip)
{
- return (float) sprintf('%u', ip2long($ip)); // для совместимости с 32 битными системами
+ return (float)sprintf('%u', ip2long($ip)); // для совместимости с 32 битными системами
}
// long2ip( mask_ip_int(ip2int('1.2.3.4'), 24) ) = '1.2.3.255'
-function mask_ip_int ($ip, $mask)
+function mask_ip_int($ip, $mask)
{
- $ip_int = is_numeric($ip) ? $ip : ip2int($ip);
- $ip_masked = $ip_int | ((1 << (32 - $mask)) - 1);
- return (float) sprintf('%u', $ip_masked);
+ $ip_int = is_numeric($ip) ? $ip : ip2int($ip);
+ $ip_masked = $ip_int | ((1 << (32 - $mask)) - 1);
+ return (float)sprintf('%u', $ip_masked);
}
-function bb_crc32 ($str)
+function bb_crc32($str)
{
- return (float) sprintf('%u', crc32($str));
+ return (float)sprintf('%u', crc32($str));
}
-function hexhex ($value)
+function hexhex($value)
{
- return dechex(hexdec($value));
+ return dechex(hexdec($value));
}
-function verify_ip ($ip)
+function verify_ip($ip)
{
- return preg_match('#^(\d{1,3}\.){3}\d{1,3}$#', $ip);
+ return preg_match('#^(\d{1,3}\.){3}\d{1,3}$#', $ip);
}
-function str_compact ($str)
+function str_compact($str)
{
- return preg_replace('#\s+#u', ' ', trim($str));
+ return preg_replace('#\s+#u', ' ', trim($str));
}
-function make_rand_str ($len = 10)
+function make_rand_str($len = 10)
{
- $str = '';
- while (strlen($str) < $len)
- {
- $str .= str_shuffle(preg_replace('#[^0-9a-zA-Z]#', '', password_hash(uniqid(mt_rand(), true), PASSWORD_BCRYPT)));
- }
- return substr($str, 0, $len);
+ $str = '';
+ while (strlen($str) < $len) {
+ $str .= str_shuffle(preg_replace('#[^0-9a-zA-Z]#', '', password_hash(uniqid(mt_rand(), true), PASSWORD_BCRYPT)));
+ }
+ return substr($str, 0, $len);
}
// bencode: based on OpenTracker
-function bencode ($var)
+function bencode($var)
{
- if (is_string($var))
- {
- return strlen($var) .':'. $var;
- }
- else if (is_int($var))
- {
- return 'i'. $var .'e';
- }
- else if (is_float($var))
- {
- return 'i'. sprintf('%.0f', $var) .'e';
- }
- else if (is_array($var))
- {
- if (count($var) == 0)
- {
- return 'de';
- }
- else
- {
- $assoc = false;
+ if (is_string($var)) {
+ return strlen($var) . ':' . $var;
+ } elseif (is_int($var)) {
+ return 'i' . $var . 'e';
+ } elseif (is_float($var)) {
+ return 'i' . sprintf('%.0f', $var) . 'e';
+ } elseif (is_array($var)) {
+ if (count($var) == 0) {
+ return 'de';
+ } else {
+ $assoc = false;
- foreach ($var as $key => $val)
- {
- if (!is_int($key))
- {
- $assoc = true;
- break;
- }
- }
+ foreach ($var as $key => $val) {
+ if (!is_int($key)) {
+ $assoc = true;
+ break;
+ }
+ }
- if ($assoc)
- {
- ksort($var, SORT_REGULAR);
- $ret = 'd';
+ if ($assoc) {
+ ksort($var, SORT_REGULAR);
+ $ret = 'd';
- foreach ($var as $key => $val)
- {
- $ret .= bencode($key) . bencode($val);
- }
- return $ret .'e';
- }
- else
- {
- $ret = 'l';
+ foreach ($var as $key => $val) {
+ $ret .= bencode($key) . bencode($val);
+ }
+ return $ret . 'e';
+ } else {
+ $ret = 'l';
- foreach ($var as $val)
- {
- $ret .= bencode($val);
- }
- return $ret .'e';
- }
- }
- }
- else
- {
- trigger_error('bencode error: wrong data type', E_USER_ERROR);
- }
+ foreach ($var as $val) {
+ $ret .= bencode($val);
+ }
+ return $ret . 'e';
+ }
+ }
+ } else {
+ trigger_error('bencode error: wrong data type', E_USER_ERROR);
+ }
}
-function array_deep (&$var, $fn, $one_dimensional = false, $array_only = false)
+function array_deep(&$var, $fn, $one_dimensional = false, $array_only = false)
{
- if (is_array($var))
- {
- foreach ($var as $k => $v)
- {
- if (is_array($v))
- {
- if ($one_dimensional)
- {
- unset($var[$k]);
- }
- else if ($array_only)
- {
- $var[$k] = $fn($v);
- }
- else
- {
- array_deep($var[$k], $fn);
- }
- }
- else if (!$array_only)
- {
- $var[$k] = $fn($v);
- }
- }
- }
- else if (!$array_only)
- {
- $var = $fn($var);
- }
+ if (is_array($var)) {
+ foreach ($var as $k => $v) {
+ if (is_array($v)) {
+ if ($one_dimensional) {
+ unset($var[$k]);
+ } elseif ($array_only) {
+ $var[$k] = $fn($v);
+ } else {
+ array_deep($var[$k], $fn);
+ }
+ } elseif (!$array_only) {
+ $var[$k] = $fn($v);
+ }
+ }
+ } elseif (!$array_only) {
+ $var = $fn($var);
+ }
}
-function hide_bb_path ($path)
+function hide_bb_path($path)
{
- return ltrim(str_replace(BB_PATH, '', $path), '/\\');
+ return ltrim(str_replace(BB_PATH, '', $path), '/\\');
}
-function sys ($param)
+function sys($param)
{
- switch ($param)
- {
- case 'la':
- return function_exists('sys_getloadavg') ? join(' ', sys_getloadavg()) : 0;
- break;
- case 'mem':
- return function_exists('memory_get_usage') ? memory_get_usage() : 0;
- break;
- case 'mem_peak':
- return function_exists('memory_get_peak_usage') ? memory_get_peak_usage() : 0;
- break;
- default:
- trigger_error("invalid param: $param", E_USER_ERROR);
- }
+ switch ($param) {
+ case 'la':
+ return function_exists('sys_getloadavg') ? join(' ', sys_getloadavg()) : 0;
+ break;
+ case 'mem':
+ return function_exists('memory_get_usage') ? memory_get_usage() : 0;
+ break;
+ case 'mem_peak':
+ return function_exists('memory_get_peak_usage') ? memory_get_peak_usage() : 0;
+ break;
+ default:
+ trigger_error("invalid param: $param", E_USER_ERROR);
+ }
}
-function ver_compare ($version1, $operator, $version2)
+function ver_compare($version1, $operator, $version2)
{
- return version_compare($version1, $version2, $operator);
+ return version_compare($version1, $version2, $operator);
}
-function dbg_log ($str, $file)
+function dbg_log($str, $file)
{
- $dir = LOG_DIR . (defined('IN_TRACKER') ? 'dbg_tr/' : 'dbg_bb/') . date('m-d_H') .'/';
- return file_write($str, $dir . $file, false, false);
+ $dir = LOG_DIR . (defined('IN_TRACKER') ? 'dbg_tr/' : 'dbg_bb/') . date('m-d_H') . '/';
+ return file_write($str, $dir . $file, false, false);
}
-function log_get ($file = '', $prepend_str = false)
+function log_get($file = '', $prepend_str = false)
{
- log_request($file, $prepend_str, false);
+ log_request($file, $prepend_str, false);
}
-function log_post ($file = '', $prepend_str = false)
+function log_post($file = '', $prepend_str = false)
{
- log_request($file, $prepend_str, true);
+ log_request($file, $prepend_str, true);
}
-function log_request ($file = '', $prepend_str = false, $add_post = true)
+function log_request($file = '', $prepend_str = false, $add_post = true)
{
- global $user;
+ global $user;
- $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);
- $str[] = sprintf('%-15s', $_SERVER['REMOTE_ADDR']);
+ $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);
+ }
+ $str[] = sprintf('%-15s', $_SERVER['REMOTE_ADDR']);
- if (isset($_SERVER['REQUEST_URI'])) {
- $str[] = $_SERVER['REQUEST_URI'];
- }
- if (isset($_SERVER['HTTP_USER_AGENT'])) {
- $str[] = $_SERVER['HTTP_USER_AGENT'];
- }
- if (isset($_SERVER['HTTP_REFERER'])) {
- $str[] = $_SERVER['HTTP_REFERER'];
- }
+ if (isset($_SERVER['REQUEST_URI'])) {
+ $str[] = $_SERVER['REQUEST_URI'];
+ }
+ if (isset($_SERVER['HTTP_USER_AGENT'])) {
+ $str[] = $_SERVER['HTTP_USER_AGENT'];
+ }
+ if (isset($_SERVER['HTTP_REFERER'])) {
+ $str[] = $_SERVER['HTTP_REFERER'];
+ }
- if (!empty($_POST) && $add_post) $str[] = "post: ". str_compact(urldecode(http_build_query($_POST)));
- $str = join("\t", $str) . "\n";
- bb_log($str, $file);
+ if (!empty($_POST) && $add_post) {
+ $str[] = "post: " . str_compact(urldecode(http_build_query($_POST)));
+ }
+ $str = join("\t", $str) . "\n";
+ bb_log($str, $file);
}
// Board init
-if (defined('IN_FORUM'))
-{
- require(INC_DIR .'init_bb.php');
-}
-// Tracker init
-else if (defined('IN_TRACKER'))
-{
- define('DUMMY_PEER', pack('Nn', ip2long($_SERVER['REMOTE_ADDR']), !empty($_GET['port']) ? intval($_GET['port']) : mt_rand(1000, 65000)));
-
- function dummy_exit ($interval = 1800)
- {
- $output = bencode(array(
- 'interval' => (int) $interval,
- 'min interval' => (int) $interval,
- 'peers' => (string) DUMMY_PEER,
- ));
-
- die($output);
- }
-
- header('Content-Type: text/plain');
- header('Pragma: no-cache');
-
- if (!defined('IN_ADMIN'))
- {
- // Exit if tracker is disabled via ON/OFF trigger
- if (file_exists(BB_DISABLED))
- {
- dummy_exit(mt_rand(60, 2400));
- }
- }
+if (defined('IN_FORUM')) {
+ require(INC_DIR . 'init_bb.php');
+} // Tracker init
+elseif (defined('IN_TRACKER')) {
+ define('DUMMY_PEER', pack('Nn', ip2long($_SERVER['REMOTE_ADDR']), !empty($_GET['port']) ? intval($_GET['port']) : mt_rand(1000, 65000)));
+
+ function dummy_exit($interval = 1800)
+ {
+ $output = bencode(array(
+ 'interval' => (int)$interval,
+ 'min interval' => (int)$interval,
+ 'peers' => (string)DUMMY_PEER,
+ ));
+
+ die($output);
+ }
+
+ header('Content-Type: text/plain');
+ header('Pragma: no-cache');
+
+ if (!defined('IN_ADMIN')) {
+ // Exit if tracker is disabled via ON/OFF trigger
+ if (file_exists(BB_DISABLED)) {
+ dummy_exit(mt_rand(60, 2400));
+ }
+ }
}
diff --git a/cron.php b/cron.php
index d500aeb14..191fafe90 100644
--- a/cron.php
+++ b/cron.php
@@ -1,6 +1,29 @@
-
-
-
+
+
+
\ No newline at end of file
diff --git a/dl.php b/dl.php
index c46645bb7..6c0097307 100644
--- a/dl.php
+++ b/dl.php
@@ -1,14 +1,37 @@
enqueue(array(
- 'attach_extensions',
+ 'attach_extensions',
));
$download_id = request_var('id', 0);
@@ -17,62 +40,53 @@ $thumbnail = request_var('thumb', 0);
// Send file to browser
function send_file_to_browser($attachment, $upload_dir)
{
- global $bb_cfg, $lang, $userdata;
+ global $bb_cfg, $lang, $userdata;
- $filename = ($upload_dir == '') ? $attachment['physical_filename'] : $upload_dir . '/' . $attachment['physical_filename'];
+ $filename = ($upload_dir == '') ? $attachment['physical_filename'] : $upload_dir . '/' . $attachment['physical_filename'];
- $gotit = false;
+ $gotit = false;
- if (@!file_exists(@amod_realpath($filename)))
- {
- bb_die($lang['ERROR_NO_ATTACHMENT'] . " " . $filename. " " .$lang['TOR_NOT_FOUND']);
- }
- else
- {
- $gotit = true;
- }
+ if (@!file_exists(@amod_realpath($filename))) {
+ bb_die($lang['ERROR_NO_ATTACHMENT'] . " " . $filename . " " . $lang['TOR_NOT_FOUND']);
+ } else {
+ $gotit = true;
+ }
- // Correct the mime type - we force application/octet-stream for all files, except images
- // Please do not change this, it is a security precaution
- if (!strstr($attachment['mimetype'], 'image'))
- {
- $attachment['mimetype'] = 'application/octet-stream';
- }
+ // Correct the mime type - we force application/octet-stream for all files, except images
+ // Please do not change this, it is a security precaution
+ if (!strstr($attachment['mimetype'], 'image')) {
+ $attachment['mimetype'] = 'application/octet-stream';
+ }
- //bt
- if (!(isset($_GET['original']) && !IS_USER))
- {
- include(INC_DIR .'functions_torrent.php');
- send_torrent_with_passkey($filename);
- }
+ //bt
+ if (!(isset($_GET['original']) && !IS_USER)) {
+ include(INC_DIR . 'functions_torrent.php');
+ send_torrent_with_passkey($filename);
+ }
- // Now the tricky part... let's dance
- header('Pragma: public');
- $real_filename = clean_filename(basename($attachment['real_filename']));
- $mimetype = $attachment['mimetype'].';';
- $charset = "charset={$bb_cfg['lang'][$userdata['user_lang']]['encoding']};";
+ // Now the tricky part... let's dance
+ header('Pragma: public');
+ $real_filename = clean_filename(basename($attachment['real_filename']));
+ $mimetype = $attachment['mimetype'] . ';';
+ $charset = "charset={$bb_cfg['lang'][$userdata['user_lang']]['encoding']};";
- // Send out the Headers
- header("Content-Type: $mimetype $charset name=\"$real_filename\"");
- header("Content-Disposition: inline; filename=\"$real_filename\"");
- unset($real_filename);
+ // Send out the Headers
+ header("Content-Type: $mimetype $charset name=\"$real_filename\"");
+ header("Content-Disposition: inline; filename=\"$real_filename\"");
+ unset($real_filename);
- // Now send the File Contents to the Browser
- if ($gotit)
- {
- $size = @filesize($filename);
- if ($size)
- {
- header("Content-length: $size");
- }
- readfile($filename);
- }
- else
- {
- bb_die($lang['ERROR_NO_ATTACHMENT'] . " " . $filename. " " .$lang['TOR_NOT_FOUND']);
- }
+ // Now send the File Contents to the Browser
+ if ($gotit) {
+ $size = @filesize($filename);
+ if ($size) {
+ header("Content-length: $size");
+ }
+ readfile($filename);
+ } else {
+ bb_die($lang['ERROR_NO_ATTACHMENT'] . " " . $filename . " " . $lang['TOR_NOT_FOUND']);
+ }
- exit;
+ exit;
}
//
@@ -82,26 +96,22 @@ $user->session_start();
set_die_append_msg();
-if (!$download_id)
-{
- bb_die($lang['NO_ATTACHMENT_SELECTED']);
+if (!$download_id) {
+ bb_die($lang['NO_ATTACHMENT_SELECTED']);
}
-if ($attach_config['disable_mod'] && !IS_ADMIN)
-{
- bb_die($lang['ATTACHMENT_FEATURE_DISABLED']);
+if ($attach_config['disable_mod'] && !IS_ADMIN) {
+ bb_die($lang['ATTACHMENT_FEATURE_DISABLED']);
}
-$sql = 'SELECT * FROM ' . BB_ATTACHMENTS_DESC . ' WHERE attach_id = ' . (int) $download_id;
+$sql = 'SELECT * FROM ' . BB_ATTACHMENTS_DESC . ' WHERE attach_id = ' . (int)$download_id;
-if (!($result = DB()->sql_query($sql)))
-{
- bb_die('Could not query attachment information #1');
+if (!($result = DB()->sql_query($sql))) {
+ bb_die('Could not query attachment information #1');
}
-if (!($attachment = DB()->sql_fetchrow($result)))
-{
- bb_die($lang['ERROR_NO_ATTACHMENT']);
+if (!($attachment = DB()->sql_fetchrow($result))) {
+ bb_die($lang['ERROR_NO_ATTACHMENT']);
}
$attachment['physical_filename'] = basename($attachment['physical_filename']);
@@ -111,48 +121,42 @@ DB()->sql_freeresult($result);
// get forum_id for attachment authorization or private message authorization
$authorised = false;
-$sql = 'SELECT * FROM ' . BB_ATTACHMENTS . ' WHERE attach_id = ' . (int) $attachment['attach_id'];
+$sql = 'SELECT * FROM ' . BB_ATTACHMENTS . ' WHERE attach_id = ' . (int)$attachment['attach_id'];
-if (!($result = DB()->sql_query($sql)))
-{
- bb_die('Could not query attachment information #2');
+if (!($result = DB()->sql_query($sql))) {
+ bb_die('Could not query attachment information #2');
}
$auth_pages = DB()->sql_fetchrowset($result);
$num_auth_pages = DB()->num_rows($result);
-for ($i = 0; $i < $num_auth_pages && $authorised == false; $i++)
-{
- $auth_pages[$i]['post_id'] = intval($auth_pages[$i]['post_id']);
+for ($i = 0; $i < $num_auth_pages && $authorised == false; $i++) {
+ $auth_pages[$i]['post_id'] = intval($auth_pages[$i]['post_id']);
- if ($auth_pages[$i]['post_id'] != 0)
- {
- $sql = 'SELECT forum_id, topic_id FROM ' . BB_POSTS . ' WHERE post_id = ' . (int) $auth_pages[$i]['post_id'];
+ if ($auth_pages[$i]['post_id'] != 0) {
+ $sql = 'SELECT forum_id, topic_id FROM ' . BB_POSTS . ' WHERE post_id = ' . (int)$auth_pages[$i]['post_id'];
- if (!($result = DB()->sql_query($sql)))
- {
- bb_die('Could not query post information');
- }
+ if (!($result = DB()->sql_query($sql))) {
+ bb_die('Could not query post information');
+ }
- $row = DB()->sql_fetchrow($result);
+ $row = DB()->sql_fetchrow($result);
- $topic_id = $row['topic_id'];
- $forum_id = $row['forum_id'];
+ $topic_id = $row['topic_id'];
+ $forum_id = $row['forum_id'];
- $is_auth = array();
- $is_auth = auth(AUTH_ALL, $forum_id, $userdata);
- set_die_append_msg($forum_id, $topic_id);
+ $is_auth = array();
+ $is_auth = auth(AUTH_ALL, $forum_id, $userdata);
+ set_die_append_msg($forum_id, $topic_id);
- if ($is_auth['auth_download'])
- {
- $authorised = TRUE;
- }
- }
+ if ($is_auth['auth_download']) {
+ $authorised = true;
+ }
+ }
}
-if (!$authorised)
-{
- bb_die($lang['SORRY_AUTH_VIEW_ATTACH']);
+if (!$authorised) {
+ bb_die($lang['SORRY_AUTH_VIEW_ATTACH']);
}
$datastore->rm('cat_forums');
@@ -163,67 +167,58 @@ $datastore->rm('cat_forums');
$rows = get_extension_informations();
$num_rows = count($rows);
-for ($i = 0; $i < $num_rows; $i++)
-{
- $extension = strtolower(trim($rows[$i]['extension']));
- $allowed_extensions[] = $extension;
- $download_mode[$extension] = $rows[$i]['download_mode'];
+for ($i = 0; $i < $num_rows; $i++) {
+ $extension = strtolower(trim($rows[$i]['extension']));
+ $allowed_extensions[] = $extension;
+ $download_mode[$extension] = $rows[$i]['download_mode'];
}
// Disallowed
-if (!in_array($attachment['extension'], $allowed_extensions) && !IS_ADMIN)
-{
- bb_die(sprintf($lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension']));
+if (!in_array($attachment['extension'], $allowed_extensions) && !IS_ADMIN) {
+ bb_die(sprintf($lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension']));
}
$download_mode = intval($download_mode[$attachment['extension']]);
-if ($thumbnail)
-{
- $attachment['physical_filename'] = THUMB_DIR . '/t_' . $attachment['physical_filename'];
+if ($thumbnail) {
+ $attachment['physical_filename'] = THUMB_DIR . '/t_' . $attachment['physical_filename'];
}
// Update download count
-if (!$thumbnail)
-{
- $sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . ' SET download_count = download_count + 1 WHERE attach_id = ' . (int) $attachment['attach_id'];
+if (!$thumbnail) {
+ $sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . ' SET download_count = download_count + 1 WHERE attach_id = ' . (int)$attachment['attach_id'];
- if (!DB()->sql_query($sql))
- {
- bb_die('Could not update attachment download count');
- }
+ if (!DB()->sql_query($sql)) {
+ bb_die('Could not update attachment download count');
+ }
}
// Determine the 'presenting'-method
-if ($download_mode == PHYSICAL_LINK)
-{
- $url = make_url($upload_dir . '/' . $attachment['physical_filename']);
- header('Location: ' . $url);
- exit;
+if ($download_mode == PHYSICAL_LINK) {
+ $url = make_url($upload_dir . '/' . $attachment['physical_filename']);
+ header('Location: ' . $url);
+ exit;
+} else {
+ if (IS_GUEST && !bb_captcha('check')) {
+ global $template;
+
+ $redirect_url = isset($_POST['redirect_url']) ? $_POST['redirect_url'] : (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/');
+ $message = '';
+
+ $template->assign_vars(array(
+ 'ERROR_MESSAGE' => $message,
+ ));
+
+ require(PAGE_HEADER);
+ require(PAGE_FOOTER);
+ }
+
+ send_file_to_browser($attachment, $upload_dir);
+ exit;
}
-else
-{
- if (IS_GUEST && !bb_captcha('check'))
- {
- global $template;
-
- $redirect_url = isset($_POST['redirect_url']) ? $_POST['redirect_url'] : (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/');
- $message = '';
-
- $template->assign_vars(array(
- 'ERROR_MESSAGE' => $message,
- ));
-
- require(PAGE_HEADER);
- require(PAGE_FOOTER);
- }
-
- send_file_to_browser($attachment, $upload_dir);
- exit;
-}
\ No newline at end of file
diff --git a/dl_list.php b/dl_list.php
index d4db8fd9c..1be83ddd7 100644
--- a/dl_list.php
+++ b/dl_list.php
@@ -1,56 +1,66 @@
session_start();
set_die_append_msg();
// Check if user logged in
-if (!$userdata['session_logged_in'])
-{
- redirect(LOGIN_URL . "?redirect=$redirect_type&$redirect");
+if (!$userdata['session_logged_in']) {
+ redirect(LOGIN_URL . "?redirect=$redirect_type&$redirect");
}
// Check if user did not confirm
-if (isset($_POST['cancel']) && $_POST['cancel'])
-{
- redirect("$redirect_type?$redirect");
+if (isset($_POST['cancel']) && $_POST['cancel']) {
+ redirect("$redirect_type?$redirect");
}
// Delete DL-list
-if ($mode == 'dl_delete' && $topic_id)
-{
- if (!IS_ADMIN)
- {
- $sql = "SELECT forum_id FROM ". BB_TOPICS ." WHERE topic_id = $topic_id LIMIT 1";
+if ($mode == 'dl_delete' && $topic_id) {
+ if (!IS_ADMIN) {
+ $sql = "SELECT forum_id FROM " . BB_TOPICS . " WHERE topic_id = $topic_id LIMIT 1";
- if (!$row = DB()->sql_fetchrow(DB()->sql_query($sql)))
- {
- bb_die('Could not obtain forum_id for this topic');
- }
+ if (!$row = DB()->sql_fetchrow(DB()->sql_query($sql))) {
+ bb_die('Could not obtain forum_id for this topic');
+ }
- $is_auth = auth(AUTH_ALL, $row['forum_id'], $userdata);
+ $is_auth = auth(AUTH_ALL, $row['forum_id'], $userdata);
- if (!$is_auth['auth_mod'])
- {
- bb_die($lang['NOT_MODERATOR']);
- }
- }
+ if (!$is_auth['auth_mod']) {
+ bb_die($lang['NOT_MODERATOR']);
+ }
+ }
- if (!$confirmed)
- {
- $hidden_fields = array(
- 't' => $topic_id,
- 'mode' => 'dl_delete',
- );
+ if (!$confirmed) {
+ $hidden_fields = array(
+ 't' => $topic_id,
+ 'mode' => 'dl_delete',
+ );
- print_confirmation(array(
- 'QUESTION' => $lang['DL_LIST_DEL_CONFIRM'],
- 'FORM_ACTION' => 'dl_list.php',
- 'HIDDEN_FIELDS' => build_hidden_fields($hidden_fields),
- ));
- }
+ print_confirmation(array(
+ 'QUESTION' => $lang['DL_LIST_DEL_CONFIRM'],
+ 'FORM_ACTION' => 'dl_list.php',
+ 'HIDDEN_FIELDS' => build_hidden_fields($hidden_fields),
+ ));
+ }
- clear_dl_list($topic_id);
- redirect("$redirect_type?$redirect");
+ clear_dl_list($topic_id);
+ redirect("$redirect_type?$redirect");
}
// Update DL status
$req_topics_ary = $topics_ary = array();
// Get topics selected by user
-if ($mode == 'set_topics_dl_status')
-{
- if (!isset($_POST['dl_topics_id_list']) || !is_array($_POST['dl_topics_id_list']))
- {
- bb_die($lang['NONE_SELECTED']);
- }
+if ($mode == 'set_topics_dl_status') {
+ if (!isset($_POST['dl_topics_id_list']) || !is_array($_POST['dl_topics_id_list'])) {
+ bb_die($lang['NONE_SELECTED']);
+ }
- foreach ($_POST['dl_topics_id_list'] as $topic_id)
- {
- $req_topics_ary[] = (int) $topic_id;
- }
-}
-elseif ($mode == 'set_dl_status')
-{
- $req_topics_ary[] = (int) $topic_id;
+ foreach ($_POST['dl_topics_id_list'] as $topic_id) {
+ $req_topics_ary[] = (int)$topic_id;
+ }
+} elseif ($mode == 'set_dl_status') {
+ $req_topics_ary[] = (int)$topic_id;
}
// Get existing topics
-if ($req_topics_sql = join(',', $req_topics_ary))
-{
- $sql = "SELECT topic_id FROM ". BB_TOPICS ." WHERE topic_id IN($req_topics_sql)";
+if ($req_topics_sql = join(',', $req_topics_ary)) {
+ $sql = "SELECT topic_id FROM " . BB_TOPICS . " WHERE topic_id IN($req_topics_sql)";
- foreach (DB()->fetch_rowset($sql) as $row)
- {
- $topics_ary[] = $row['topic_id'];
- }
+ foreach (DB()->fetch_rowset($sql) as $row) {
+ $topics_ary[] = $row['topic_id'];
+ }
}
-if ($topics_ary && ($mode == 'set_dl_status' || $mode == 'set_topics_dl_status'))
-{
- $new_dlstatus_ary = array();
+if ($topics_ary && ($mode == 'set_dl_status' || $mode == 'set_topics_dl_status')) {
+ $new_dlstatus_ary = array();
- foreach ($topics_ary as $topic_id)
- {
- $new_dlstatus_ary[] = array(
- 'user_id' => (int) $user->id,
- 'topic_id' => (int) $topic_id,
- 'user_status' => (int) $new_dl_status,
- );
- }
- $new_dlstatus_sql = DB()->build_array('MULTI_INSERT', $new_dlstatus_ary);
+ foreach ($topics_ary as $topic_id) {
+ $new_dlstatus_ary[] = array(
+ 'user_id' => (int)$user->id,
+ 'topic_id' => (int)$topic_id,
+ 'user_status' => (int)$new_dl_status,
+ );
+ }
+ $new_dlstatus_sql = DB()->build_array('MULTI_INSERT', $new_dlstatus_ary);
- DB()->query("REPLACE INTO ". BB_BT_DLSTATUS ." $new_dlstatus_sql");
+ DB()->query("REPLACE INTO " . BB_BT_DLSTATUS . " $new_dlstatus_sql");
- redirect("$redirect_type?$redirect");
+ redirect("$redirect_type?$redirect");
}
-redirect("index.php");
\ No newline at end of file
+redirect("index.php");
diff --git a/feed.php b/feed.php
index 454c6dd56..986398301 100644
--- a/feed.php
+++ b/feed.php
@@ -1,68 +1,85 @@
session_start(array('req_login' => true));
$mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : '';
$type = isset($_POST['type']) ? $_POST['type'] : '';
-$id = isset($_POST['id']) ? $_POST['id'] : 0;
+$id = isset($_POST['id']) ? $_POST['id'] : 0;
$timecheck = TIMENOW - 600;
-if (!$mode) bb_simple_die($lang['ATOM_NO_MODE']);
-
-if ($mode == 'get_feed_url' && ($type == 'f' || $type == 'u') && $id >= 0)
-{
- if ($type == 'f')
- {
- // Check if the user has actually sent a forum ID
- $sql = "SELECT allow_reg_tracker, forum_name FROM ". BB_FORUMS ." WHERE forum_id = $id LIMIT 1";
- if (!$forum_data = DB()->fetch_row($sql))
- {
- if ($id == 0)
- {
- $forum_data = array();
- }
- else bb_simple_die($lang['ATOM_ERROR'].' #1');
- }
- if (file_exists($bb_cfg['atom']['path'] .'/f/'. $id .'.atom') && filemtime($bb_cfg['atom']['path'] .'/f/'. $id .'.atom') > $timecheck)
- {
- redirect($bb_cfg['atom']['url'] .'/f/'. $id .'.atom');
- }
- else
- {
- require_once(INC_DIR .'functions_atom.php');
- if (update_forum_feed($id, $forum_data)) redirect($bb_cfg['atom']['url'] .'/f/'. $id .'.atom');
- else bb_simple_die($lang['ATOM_NO_FORUM']);
- }
- }
- if ($type == 'u')
- {
- // Check if the user has actually sent a user ID
- if ($id < 1)
- {
- bb_simple_die($lang['ATOM_ERROR'].' #2');
- }
- if (!$username = get_username($id))
- {
- bb_simple_die($lang['ATOM_ERROR'].' #3');
- }
- if (file_exists($bb_cfg['atom']['path'] .'/u/'. floor($id/5000) .'/'. ($id % 100) .'/'. $id .'.atom') && filemtime($bb_cfg['atom']['path'] .'/u/'. floor($id/5000) .'/'. ($id % 100) .'/'. $id .'.atom') > $timecheck)
- {
- redirect($bb_cfg['atom']['url'] .'/u/'. floor($id/5000) .'/'. ($id % 100) .'/'. $id .'.atom');
- }
- else
- {
- require_once(INC_DIR .'functions_atom.php');
- if (update_user_feed($id, $username)) redirect($bb_cfg['atom']['url'] .'/u/'. floor($id/5000) .'/'. ($id % 100) .'/'. $id .'.atom');
- else bb_simple_die($lang['ATOM_NO_USER']);
- }
- }
+if (!$mode) {
+ bb_simple_die($lang['ATOM_NO_MODE']);
+}
+
+if ($mode == 'get_feed_url' && ($type == 'f' || $type == 'u') && $id >= 0) {
+ if ($type == 'f') {
+ // Check if the user has actually sent a forum ID
+ $sql = "SELECT allow_reg_tracker, forum_name FROM " . BB_FORUMS . " WHERE forum_id = $id LIMIT 1";
+ if (!$forum_data = DB()->fetch_row($sql)) {
+ if ($id == 0) {
+ $forum_data = array();
+ } else {
+ bb_simple_die($lang['ATOM_ERROR'] . ' #1');
+ }
+ }
+ if (file_exists($bb_cfg['atom']['path'] . '/f/' . $id . '.atom') && filemtime($bb_cfg['atom']['path'] . '/f/' . $id . '.atom') > $timecheck) {
+ redirect($bb_cfg['atom']['url'] . '/f/' . $id . '.atom');
+ } else {
+ require_once(INC_DIR . 'functions_atom.php');
+ if (update_forum_feed($id, $forum_data)) {
+ redirect($bb_cfg['atom']['url'] . '/f/' . $id . '.atom');
+ } else {
+ bb_simple_die($lang['ATOM_NO_FORUM']);
+ }
+ }
+ }
+ if ($type == 'u') {
+ // Check if the user has actually sent a user ID
+ if ($id < 1) {
+ bb_simple_die($lang['ATOM_ERROR'] . ' #2');
+ }
+ if (!$username = get_username($id)) {
+ bb_simple_die($lang['ATOM_ERROR'] . ' #3');
+ }
+ if (file_exists($bb_cfg['atom']['path'] . '/u/' . floor($id / 5000) . '/' . ($id % 100) . '/' . $id . '.atom') && filemtime($bb_cfg['atom']['path'] . '/u/' . floor($id / 5000) . '/' . ($id % 100) . '/' . $id . '.atom') > $timecheck) {
+ redirect($bb_cfg['atom']['url'] . '/u/' . floor($id / 5000) . '/' . ($id % 100) . '/' . $id . '.atom');
+ } else {
+ require_once(INC_DIR . 'functions_atom.php');
+ if (update_user_feed($id, $username)) {
+ redirect($bb_cfg['atom']['url'] . '/u/' . floor($id / 5000) . '/' . ($id % 100) . '/' . $id . '.atom');
+ } else {
+ bb_simple_die($lang['ATOM_NO_USER']);
+ }
+ }
+ }
+} else {
+ bb_simple_die($lang['ATOM_ERROR'] . ' #4');
}
-else
-{
- bb_simple_die($lang['ATOM_ERROR'].' #4');
-}
\ No newline at end of file
diff --git a/group.php b/group.php
index 38778d453..33a548b7e 100644
--- a/group.php
+++ b/group.php
@@ -1,11 +1,34 @@
'. $lang['SEND_PM_TXTB'] .'' : ' ';
- $avatar = get_avatar($row['user_id'], $row['avatar_ext_id'], !bf($row['user_opt'], 'user_opt', 'dis_avatar'), '', 50, 50);
+ $from = (!empty($row['user_from'])) ? $row['user_from'] : '';
+ $joined = bb_date($row['user_regdate']);
+ $user_time = (!empty($row['user_time'])) ? bb_date($row['user_time']) : $lang['NONE'];
+ $posts = ($row['user_posts']) ? $row['user_posts'] : 0;
+ $pm = ($bb_cfg['text_buttons']) ? '' . $lang['SEND_PM_TXTB'] . ' ' : ' ';
+ $avatar = get_avatar($row['user_id'], $row['avatar_ext_id'], !bf($row['user_opt'], 'user_opt', 'dis_avatar'), '', 50, 50);
- if (bf($row['user_opt'], 'user_opt', 'user_viewemail') || $group_mod)
- {
- $email_uri = ($bb_cfg['board_email_form']) ? ("profile.php?mode=email&". POST_USERS_URL ."=".$row['user_id']) : 'mailto:'. $row['user_email'];
- $email = ''. $row['user_email'] .' ';
- }
- else $email = '';
+ if (bf($row['user_opt'], 'user_opt', 'user_viewemail') || $group_mod) {
+ $email_uri = ($bb_cfg['board_email_form']) ? ("profile.php?mode=email&" . POST_USERS_URL . "=" . $row['user_id']) : 'mailto:' . $row['user_email'];
+ $email = '' . $row['user_email'] . ' ';
+ } else {
+ $email = '';
+ }
- if ($row['user_website'])
- {
- $www = ($bb_cfg['text_buttons']) ? ''. $lang['VISIT_WEBSITE_TXTB'] .' ' : ' ';
- }
- else $www = '';
+ if ($row['user_website']) {
+ $www = ($bb_cfg['text_buttons']) ? '' . $lang['VISIT_WEBSITE_TXTB'] . ' ' : ' ';
+ } else {
+ $www = '';
+ }
- return;
+ return;
}
$user->session_start(array('req_login' => true));
set_die_append_msg();
-$group_id = isset($_REQUEST[POST_GROUPS_URL]) ? intval($_REQUEST[POST_GROUPS_URL]) : null;
-$start = isset($_REQUEST['start']) ? abs(intval($_REQUEST['start'])) : 0;
-$per_page = $bb_cfg['group_members_per_page'];
-$view_mode = isset($_REQUEST['view']) ? (string) $_REQUEST['view'] : null;
+$group_id = isset($_REQUEST[POST_GROUPS_URL]) ? intval($_REQUEST[POST_GROUPS_URL]) : null;
+$start = isset($_REQUEST['start']) ? abs(intval($_REQUEST['start'])) : 0;
+$per_page = $bb_cfg['group_members_per_page'];
+$view_mode = isset($_REQUEST['view']) ? (string)$_REQUEST['view'] : null;
$rel_limit = 50;
$group_info = array();
$is_moderator = false;
-if ($group_id)
-{
- if (!$group_info = get_group_data($group_id))
- {
- bb_die($lang['GROUP_NOT_EXIST']);
- }
- if (!$group_info['group_id'] || !$group_info['group_moderator'] || !$group_info['moderator_name'])
- {
- bb_die("Invalid group data [group_id: $group_id]");
- }
- $is_moderator = ($userdata['user_id'] == $group_info['group_moderator'] || IS_ADMIN);
+if ($group_id) {
+ if (!$group_info = get_group_data($group_id)) {
+ bb_die($lang['GROUP_NOT_EXIST']);
+ }
+ if (!$group_info['group_id'] || !$group_info['group_moderator'] || !$group_info['moderator_name']) {
+ bb_die("Invalid group data [group_id: $group_id]");
+ }
+ $is_moderator = ($userdata['user_id'] == $group_info['group_moderator'] || IS_ADMIN);
}
-if (!$group_id)
-{
- // Show the main screen where the user can select a group.
- $groups = array();
- $pending = 10;
- $member = 20;
+if (!$group_id) {
+ // Show the main screen where the user can select a group.
+ $groups = array();
+ $pending = 10;
+ $member = 20;
- $sql = "
+ $sql = "
SELECT
g.group_name, g.group_description, g.group_id, g.group_type, g.release_group,
IF(ug.user_id IS NOT NULL, IF(ug.user_pending = 1, $pending, $member), 0) AS membership,
@@ -80,16 +99,16 @@ if (!$group_id)
IF(g.group_moderator = ug.user_id, 1, 0) AS is_group_mod,
COUNT(ug2.user_id) AS members, SUM(ug2.user_pending) AS candidates
FROM
- ". BB_GROUPS ." g
+ " . BB_GROUPS . " g
LEFT JOIN
- ". BB_USER_GROUP ." ug ON
+ " . BB_USER_GROUP . " ug ON
ug.group_id = g.group_id
- AND ug.user_id = ". $userdata['user_id'] ."
+ AND ug.user_id = " . $userdata['user_id'] . "
LEFT JOIN
- ". BB_USER_GROUP ." ug2 ON
+ " . BB_USER_GROUP . " ug2 ON
ug2.group_id = g.group_id
LEFT JOIN
- ". BB_USERS ." u ON g.group_moderator = u.user_id
+ " . BB_USERS . " u ON g.group_moderator = u.user_id
WHERE
g.group_single_user = 0
GROUP BY g.group_id
@@ -100,597 +119,516 @@ if (!$group_id)
g.group_name ASC
";
- foreach (DB()->fetch_rowset($sql) as $row)
- {
- if ($row['is_group_mod'])
- {
- $type = 'MOD';
- }
- else if ($row['membership'] == $member)
- {
- $type = 'MEMBER';
- }
- else if ($row['membership'] == $pending)
- {
- $type = 'PENDING';
- }
- else if ($row['group_type'] == GROUP_OPEN)
- {
- $type = 'OPEN';
- }
- else if ($row['group_type'] == GROUP_CLOSED)
- {
- $type = 'CLOSED';
- }
- else if ($row['group_type'] == GROUP_HIDDEN && IS_ADMIN)
- {
- $type = 'HIDDEN';
- }
- else
- {
- continue;
- }
+ foreach (DB()->fetch_rowset($sql) as $row) {
+ if ($row['is_group_mod']) {
+ $type = 'MOD';
+ } elseif ($row['membership'] == $member) {
+ $type = 'MEMBER';
+ } elseif ($row['membership'] == $pending) {
+ $type = 'PENDING';
+ } elseif ($row['group_type'] == GROUP_OPEN) {
+ $type = 'OPEN';
+ } elseif ($row['group_type'] == GROUP_CLOSED) {
+ $type = 'CLOSED';
+ } elseif ($row['group_type'] == GROUP_HIDDEN && IS_ADMIN) {
+ $type = 'HIDDEN';
+ } else {
+ continue;
+ }
- $data = array('id' => $row['group_id'], 'm' => ($row['members'] - $row['candidates']), 'c' => $row['candidates'], 'rg' => $row['release_group']);
+ $data = array('id' => $row['group_id'], 'm' => ($row['members'] - $row['candidates']), 'c' => $row['candidates'], 'rg' => $row['release_group']);
- $groups[$type][$row['group_name']] = $data;
- }
+ $groups[$type][$row['group_name']] = $data;
+ }
- function build_group($params)
- {
- global $lang;
+ function build_group($params)
+ {
+ global $lang;
- $options = '';
- foreach ($params as $name => $data)
- {
- $text = htmlCHR(str_short(rtrim($name), HTML_SELECT_MAX_LENGTH));
+ $options = '';
+ foreach ($params as $name => $data) {
+ $text = htmlCHR(str_short(rtrim($name), HTML_SELECT_MAX_LENGTH));
- $members = ($data['m']) ? $lang['MEMBERS_IN_GROUP'] .': '. $data['m'] : $lang['NO_GROUP_MEMBERS'];
- $candidates = ($data['c']) ? $lang['PENDING_MEMBERS'] .': '. $data['c'] : $lang['NO_PENDING_GROUP_MEMBERS'];
+ $members = ($data['m']) ? $lang['MEMBERS_IN_GROUP'] . ': ' . $data['m'] : $lang['NO_GROUP_MEMBERS'];
+ $candidates = ($data['c']) ? $lang['PENDING_MEMBERS'] . ': ' . $data['c'] : $lang['NO_PENDING_GROUP_MEMBERS'];
- $options .= ''. $text .' ';
- $options .= ($data['rg']) ? ''. $lang['RELEASE_GROUP'] .' ' : '';
- $options .= ''. $members .' ';
- if (IS_AM)
- {
- $options .= ''. $candidates .' ';
- }
- $options .= ' ';
- }
- return $options;
- }
+ $options .= '' . $text . ' ';
+ $options .= ($data['rg']) ? '' . $lang['RELEASE_GROUP'] . ' ' : '';
+ $options .= '' . $members . ' ';
+ if (IS_AM) {
+ $options .= '' . $candidates . ' ';
+ }
+ $options .= ' ';
+ }
+ return $options;
+ }
- if ($groups)
- {
- $s_hidden_fields = '';
+ if ($groups) {
+ $s_hidden_fields = '';
- foreach ($groups as $type => $grp)
- {
- $template->assign_block_vars('groups', array(
- 'MEMBERSHIP' => $lang["GROUP_MEMBER_{$type}"],
- 'GROUP_SELECT' => build_group($grp),
- ));
- }
+ foreach ($groups as $type => $grp) {
+ $template->assign_block_vars('groups', array(
+ 'MEMBERSHIP' => $lang["GROUP_MEMBER_{$type}"],
+ 'GROUP_SELECT' => build_group($grp),
+ ));
+ }
- $template->assign_vars(array(
- 'SELECT_GROUP' => true,
- 'PAGE_TITLE' => $lang['GROUP_CONTROL_PANEL'],
- 'S_USERGROUP_ACTION' => 'group.php',
- 'S_HIDDEN_FIELDS' => $s_hidden_fields,
- ));
- }
- else
- {
- if(IS_ADMIN)
- {
- redirect('admin/admin_groups.php');
- }
- else bb_die($lang['NO_GROUPS_EXIST']);
- }
-}
-else if (isset($_POST['joingroup']) && $_POST['joingroup'])
-{
- if ($group_info['group_type'] != GROUP_OPEN)
- {
- bb_die($lang['THIS_CLOSED_GROUP']);
- }
+ $template->assign_vars(array(
+ 'SELECT_GROUP' => true,
+ 'PAGE_TITLE' => $lang['GROUP_CONTROL_PANEL'],
+ 'S_USERGROUP_ACTION' => 'group.php',
+ 'S_HIDDEN_FIELDS' => $s_hidden_fields,
+ ));
+ } else {
+ if (IS_ADMIN) {
+ redirect('admin/admin_groups.php');
+ } else {
+ bb_die($lang['NO_GROUPS_EXIST']);
+ }
+ }
+} elseif (isset($_POST['joingroup']) && $_POST['joingroup']) {
+ if ($group_info['group_type'] != GROUP_OPEN) {
+ bb_die($lang['THIS_CLOSED_GROUP']);
+ }
- $sql = "SELECT g.group_id, g.group_name, ug.user_id, u.user_email, u.username, u.user_lang
- FROM ". BB_GROUPS ." g
- LEFT JOIN ". BB_USERS ." u ON(u.user_id = g.group_moderator)
- LEFT JOIN ". BB_USER_GROUP ." ug ON(ug.group_id = g.group_id AND ug.user_id = {$userdata['user_id']})
+ $sql = "SELECT g.group_id, g.group_name, ug.user_id, u.user_email, u.username, u.user_lang
+ FROM " . BB_GROUPS . " g
+ LEFT JOIN " . BB_USERS . " u ON(u.user_id = g.group_moderator)
+ LEFT JOIN " . BB_USER_GROUP . " ug ON(ug.group_id = g.group_id AND ug.user_id = {$userdata['user_id']})
WHERE g.group_id = $group_id
AND group_single_user = 0
- AND g.group_type = ". GROUP_OPEN ."
+ AND g.group_type = " . GROUP_OPEN . "
LIMIT 1";
- $row = $moderator = DB()->fetch_row($sql);
+ $row = $moderator = DB()->fetch_row($sql);
- if (!$row['group_id'])
- {
- bb_die($lang['NO_GROUPS_EXIST']);
- }
- if ($row['user_id'])
- {
- set_die_append_msg(false, false, $group_id);
- bb_die($lang['ALREADY_MEMBER_GROUP']);
- }
+ if (!$row['group_id']) {
+ bb_die($lang['NO_GROUPS_EXIST']);
+ }
+ if ($row['user_id']) {
+ set_die_append_msg(false, false, $group_id);
+ bb_die($lang['ALREADY_MEMBER_GROUP']);
+ }
- add_user_into_group($group_id, $userdata['user_id'], 1, TIMENOW);
+ add_user_into_group($group_id, $userdata['user_id'], 1, TIMENOW);
- if ($bb_cfg['group_send_email'])
- {
- require(CLASS_DIR .'emailer.php');
- $emailer = new emailer($bb_cfg['smtp_delivery']);
+ if ($bb_cfg['group_send_email']) {
+ require(CLASS_DIR . 'emailer.php');
+ $emailer = new emailer($bb_cfg['smtp_delivery']);
- $emailer->from($bb_cfg['sitename'] ." <{$bb_cfg['board_email']}>");
- $emailer->email_address($moderator['username'] ." <{$moderator['user_email']}>");
+ $emailer->from($bb_cfg['sitename'] . " <{$bb_cfg['board_email']}>");
+ $emailer->email_address($moderator['username'] . " <{$moderator['user_email']}>");
- $emailer->use_template('group_request', $moderator['user_lang']);
+ $emailer->use_template('group_request', $moderator['user_lang']);
- $emailer->assign_vars(array(
- 'USER' => $userdata['username'],
- 'SITENAME' => $bb_cfg['sitename'],
- 'GROUP_MODERATOR' => $moderator['username'],
- 'U_GROUP' => make_url(GROUP_URL . $group_id),
- ));
+ $emailer->assign_vars(array(
+ 'USER' => $userdata['username'],
+ 'SITENAME' => $bb_cfg['sitename'],
+ 'GROUP_MODERATOR' => $moderator['username'],
+ 'U_GROUP' => make_url(GROUP_URL . $group_id),
+ ));
- $emailer->send();
- $emailer->reset();
- }
+ $emailer->send();
+ $emailer->reset();
+ }
- set_die_append_msg(false, false, $group_id);
- bb_die($lang['GROUP_JOINED']);
-}
-else if (!empty($_POST['unsub']) || !empty($_POST['unsubpending']))
-{
- delete_user_group($group_id, $userdata['user_id']);
+ set_die_append_msg(false, false, $group_id);
+ bb_die($lang['GROUP_JOINED']);
+} elseif (!empty($_POST['unsub']) || !empty($_POST['unsubpending'])) {
+ delete_user_group($group_id, $userdata['user_id']);
- set_die_append_msg(false, false, $group_id);
- bb_die($lang['UNSUB_SUCCESS']);
-}
-else
-{
- // Handle Additions, removals, approvals and denials
- $group_moderator = $group_info['group_moderator'];
+ set_die_append_msg(false, false, $group_id);
+ bb_die($lang['UNSUB_SUCCESS']);
+} else {
+ // Handle Additions, removals, approvals and denials
+ $group_moderator = $group_info['group_moderator'];
- if (!empty($_POST['add']) || !empty($_POST['remove']) || !empty($_POST['approve']) || !empty($_POST['deny']))
- {
- if (!$is_moderator)
- {
- bb_die($lang['NOT_GROUP_MODERATOR']);
- }
+ if (!empty($_POST['add']) || !empty($_POST['remove']) || !empty($_POST['approve']) || !empty($_POST['deny'])) {
+ if (!$is_moderator) {
+ bb_die($lang['NOT_GROUP_MODERATOR']);
+ }
- if (!empty($_POST['add']))
- {
- if (isset($_POST['username']) && !($row = get_userdata($_POST['username'], true)))
- {
- bb_die($lang['COULD_NOT_ADD_USER']);
- }
+ if (!empty($_POST['add'])) {
+ if (isset($_POST['username']) && !($row = get_userdata($_POST['username'], true))) {
+ bb_die($lang['COULD_NOT_ADD_USER']);
+ }
- add_user_into_group($group_id, $row['user_id']);
+ add_user_into_group($group_id, $row['user_id']);
- if ($bb_cfg['group_send_email'])
- {
- require(CLASS_DIR .'emailer.php');
- $emailer = new emailer($bb_cfg['smtp_delivery']);
+ if ($bb_cfg['group_send_email']) {
+ require(CLASS_DIR . 'emailer.php');
+ $emailer = new emailer($bb_cfg['smtp_delivery']);
- $emailer->from($bb_cfg['sitename'] ." <{$bb_cfg['board_email']}>");
- $emailer->email_address($row['username'] ." <{$row['user_email']}>");
+ $emailer->from($bb_cfg['sitename'] . " <{$bb_cfg['board_email']}>");
+ $emailer->email_address($row['username'] . " <{$row['user_email']}>");
- $emailer->use_template('group_added', $row['user_lang']);
+ $emailer->use_template('group_added', $row['user_lang']);
- $emailer->assign_vars(array(
- 'SITENAME' => $bb_cfg['sitename'],
- 'GROUP_NAME' => $group_info['group_name'],
- 'U_GROUP' => make_url(GROUP_URL . $group_id),
- ));
+ $emailer->assign_vars(array(
+ 'SITENAME' => $bb_cfg['sitename'],
+ 'GROUP_NAME' => $group_info['group_name'],
+ 'U_GROUP' => make_url(GROUP_URL . $group_id),
+ ));
- $emailer->send();
- $emailer->reset();
- }
- }
- else
- {
- if (((!empty($_POST['approve']) || !empty($_POST['deny'])) && !empty($_POST['pending_members'])) || (!empty($_POST['remove']) && !empty($_POST['members'])))
- {
- $members = (!empty($_POST['approve']) || !empty($_POST['deny'])) ? $_POST['pending_members'] : $_POST['members'];
+ $emailer->send();
+ $emailer->reset();
+ }
+ } else {
+ if (((!empty($_POST['approve']) || !empty($_POST['deny'])) && !empty($_POST['pending_members'])) || (!empty($_POST['remove']) && !empty($_POST['members']))) {
+ $members = (!empty($_POST['approve']) || !empty($_POST['deny'])) ? $_POST['pending_members'] : $_POST['members'];
- $sql_in = array();
- foreach ($members as $members_id)
- {
- $sql_in[] = (int) $members_id;
- }
- if (!$sql_in = join(',', $sql_in))
- {
- bb_die($lang['NONE_SELECTED']);
- }
+ $sql_in = array();
+ foreach ($members as $members_id) {
+ $sql_in[] = (int)$members_id;
+ }
+ if (!$sql_in = join(',', $sql_in)) {
+ bb_die($lang['NONE_SELECTED']);
+ }
- if (!empty($_POST['approve']))
- {
- DB()->query("
- UPDATE ". BB_USER_GROUP ." SET
+ if (!empty($_POST['approve'])) {
+ DB()->query("
+ UPDATE " . BB_USER_GROUP . " SET
user_pending = 0
WHERE user_id IN($sql_in)
AND group_id = $group_id
");
- update_user_level($sql_in);
- }
- else if (!empty($_POST['deny']) || !empty($_POST['remove']))
- {
- DB()->query("
- DELETE FROM ". BB_USER_GROUP ."
+ update_user_level($sql_in);
+ } elseif (!empty($_POST['deny']) || !empty($_POST['remove'])) {
+ DB()->query("
+ DELETE FROM " . BB_USER_GROUP . "
WHERE user_id IN($sql_in)
AND group_id = $group_id
");
- if (!empty($_POST['remove']))
- {
- update_user_level($sql_in);
- }
- }
- // Email users when they are approved
- if (!empty($_POST['approve']) && $bb_cfg['group_send_email'])
- {
- $sql_select = "SELECT username, user_email, user_lang
- FROM ". BB_USERS ."
+ if (!empty($_POST['remove'])) {
+ update_user_level($sql_in);
+ }
+ }
+ // Email users when they are approved
+ if (!empty($_POST['approve']) && $bb_cfg['group_send_email']) {
+ $sql_select = "SELECT username, user_email, user_lang
+ FROM " . BB_USERS . "
WHERE user_id IN($sql_in)";
- if (!$result = DB()->sql_query($sql_select))
- {
- bb_die('Could not get user email information');
- }
+ if (!$result = DB()->sql_query($sql_select)) {
+ bb_die('Could not get user email information');
+ }
- require(CLASS_DIR .'emailer.php');
- $emailer = new emailer($bb_cfg['smtp_delivery']);
+ require(CLASS_DIR . 'emailer.php');
+ $emailer = new emailer($bb_cfg['smtp_delivery']);
- $emailer->from($bb_cfg['sitename'] ." <{$bb_cfg['board_email']}>");
+ $emailer->from($bb_cfg['sitename'] . " <{$bb_cfg['board_email']}>");
- foreach (DB()->fetch_rowset($sql_select) as $row)
- {
- $emailer->use_template('group_approved', $row['user_lang']);
- $emailer->email_address($row['username'] ." <{$row['user_email']}>");
- }
+ foreach (DB()->fetch_rowset($sql_select) as $row) {
+ $emailer->use_template('group_approved', $row['user_lang']);
+ $emailer->email_address($row['username'] . " <{$row['user_email']}>");
+ }
- $emailer->assign_vars(array(
- 'SITENAME' => $bb_cfg['sitename'],
- 'GROUP_NAME' => $group_info['group_name'],
- 'U_GROUP' => make_url(GROUP_URL . $group_id),
- ));
+ $emailer->assign_vars(array(
+ 'SITENAME' => $bb_cfg['sitename'],
+ 'GROUP_NAME' => $group_info['group_name'],
+ 'U_GROUP' => make_url(GROUP_URL . $group_id),
+ ));
- $emailer->send();
- $emailer->reset();
- }
- }
- }
- }
- // END approve or deny
+ $emailer->send();
+ $emailer->reset();
+ }
+ }
+ }
+ }
+ // END approve or deny
- // Get moderator details for this group
- $group_moderator = DB()->fetch_row("
+ // Get moderator details for this group
+ $group_moderator = DB()->fetch_row("
SELECT *
- FROM ". BB_USERS ."
- WHERE user_id = ". $group_info['group_moderator'] ."
+ FROM " . BB_USERS . "
+ WHERE user_id = " . $group_info['group_moderator'] . "
");
- // Current user membership
- $is_group_member = $is_group_pending_member = false;
+ // Current user membership
+ $is_group_member = $is_group_pending_member = false;
- $sql = "SELECT user_pending
- FROM ". BB_USER_GROUP ."
+ $sql = "SELECT user_pending
+ FROM " . BB_USER_GROUP . "
WHERE group_id = $group_id
- AND user_id = ". $userdata['user_id'] ."
+ AND user_id = " . $userdata['user_id'] . "
LIMIT 1";
- if ($row = DB()->fetch_row($sql))
- {
- if ($row['user_pending'] == 0)
- {
- $is_group_member = true;
- }
- else
- {
- $is_group_pending_member = true;
- }
- }
+ if ($row = DB()->fetch_row($sql)) {
+ if ($row['user_pending'] == 0) {
+ $is_group_member = true;
+ } else {
+ $is_group_pending_member = true;
+ }
+ }
- if ($userdata['user_id'] == $group_moderator['user_id'])
- {
- $group_details = $lang['ARE_GROUP_MODERATOR'];
- $s_hidden_fields = ' ';
- }
- else if ($is_group_member || $is_group_pending_member)
- {
- $template->assign_vars(array(
- 'SHOW_UNSUBSCRIBE_CONTROLS' => true,
- 'CONTROL_NAME' => ($is_group_member) ? 'unsub' : 'unsubpending',
- ));
- $group_details = ($is_group_pending_member) ? $lang['PENDING_THIS_GROUP'] : $lang['MEMBER_THIS_GROUP'];
- $s_hidden_fields = ' ';
- }
- else if (IS_GUEST)
- {
- $group_details = $lang['LOGIN_TO_JOIN'];
- $s_hidden_fields = '';
- }
- else
- {
- if ($group_info['group_type'] == GROUP_OPEN)
- {
- $template->assign_var('SHOW_SUBSCRIBE_CONTROLS');
+ if ($userdata['user_id'] == $group_moderator['user_id']) {
+ $group_details = $lang['ARE_GROUP_MODERATOR'];
+ $s_hidden_fields = ' ';
+ } elseif ($is_group_member || $is_group_pending_member) {
+ $template->assign_vars(array(
+ 'SHOW_UNSUBSCRIBE_CONTROLS' => true,
+ 'CONTROL_NAME' => ($is_group_member) ? 'unsub' : 'unsubpending',
+ ));
+ $group_details = ($is_group_pending_member) ? $lang['PENDING_THIS_GROUP'] : $lang['MEMBER_THIS_GROUP'];
+ $s_hidden_fields = ' ';
+ } elseif (IS_GUEST) {
+ $group_details = $lang['LOGIN_TO_JOIN'];
+ $s_hidden_fields = '';
+ } else {
+ if ($group_info['group_type'] == GROUP_OPEN) {
+ $template->assign_var('SHOW_SUBSCRIBE_CONTROLS');
- $group_details = $lang['THIS_OPEN_GROUP'];
- $s_hidden_fields = ' ';
- }
- else if ($group_info['group_type'] == GROUP_CLOSED)
- {
- $group_details = $lang['THIS_CLOSED_GROUP'];
- $s_hidden_fields = '';
- }
- else if ($group_info['group_type'] == GROUP_HIDDEN)
- {
- $group_details = $lang['THIS_HIDDEN_GROUP'];
- $s_hidden_fields = '';
- }
- }
+ $group_details = $lang['THIS_OPEN_GROUP'];
+ $s_hidden_fields = ' ';
+ } elseif ($group_info['group_type'] == GROUP_CLOSED) {
+ $group_details = $lang['THIS_CLOSED_GROUP'];
+ $s_hidden_fields = '';
+ } elseif ($group_info['group_type'] == GROUP_HIDDEN) {
+ $group_details = $lang['THIS_HIDDEN_GROUP'];
+ $s_hidden_fields = '';
+ }
+ }
- // Add the moderator
- $username = $group_moderator['username'];
- $user_id = $group_moderator['user_id'];
+ // Add the moderator
+ $username = $group_moderator['username'];
+ $user_id = $group_moderator['user_id'];
- generate_user_info($group_moderator, $bb_cfg['default_dateformat'], $is_moderator, $from, $posts, $joined, $pm, $email, $www, $user_time, $avatar);
+ generate_user_info($group_moderator, $bb_cfg['default_dateformat'], $is_moderator, $from, $posts, $joined, $pm, $email, $www, $user_time, $avatar);
- $group_type = '';
- if ($group_info['group_type'] == GROUP_OPEN)
- {
- $group_type = $lang['GROUP_OPEN'];
- }
- elseif ($group_info['group_type'] == GROUP_CLOSED)
- {
- $group_type = $lang['GROUP_CLOSED'];
- }
- elseif ($group_info['group_type'] == GROUP_HIDDEN)
- {
- $group_type = $lang['GROUP_HIDDEN'];
- }
+ $group_type = '';
+ if ($group_info['group_type'] == GROUP_OPEN) {
+ $group_type = $lang['GROUP_OPEN'];
+ } elseif ($group_info['group_type'] == GROUP_CLOSED) {
+ $group_type = $lang['GROUP_CLOSED'];
+ } elseif ($group_info['group_type'] == GROUP_HIDDEN) {
+ $group_type = $lang['GROUP_HIDDEN'];
+ }
- $i = 0;
- $template->assign_vars(array(
- 'ROW_NUMBER' => $i + ($start + 1),
- 'GROUP_INFO' => true,
- 'PAGE_TITLE' => $lang['GROUP_CONTROL_PANEL'],
- 'GROUP_NAME' => htmlCHR($group_info['group_name']),
- 'GROUP_DESCRIPTION' => bbcode2html($group_info['group_description']),
- 'GROUP_SIGNATURE' => bbcode2html($group_info['group_signature']),
- 'GROUP_AVATAR' => get_avatar(GROUP_AVATAR_MASK . $group_id, $group_info['avatar_ext_id'], true),
- 'GROUP_DETAILS' => $group_details,
- 'GROUP_TIME' => (!empty($group_info['group_time'])) ? sprintf('%s (%s) ', bb_date($group_info['group_time']), delta_time($group_info['group_time'])) : $lang['NONE'],
- 'MOD_USER' => profile_url($group_moderator),
- 'MOD_AVATAR' => $avatar,
- 'MOD_FROM' => $from,
- 'MOD_JOINED' => $joined,
- 'MOD_POSTS' => $posts,
- 'MOD_PM' => $pm,
- 'MOD_EMAIL' => $email,
- 'MOD_WWW' => $www,
- 'MOD_TIME' => (!empty($group_info['mod_time'])) ? bb_date($group_info['mod_time']) : $lang['NONE'],
- 'U_SEARCH_USER' => "search.php?mode=searchuser",
- 'U_SEARCH_RELEASES' => "tracker.php?srg=$group_id",
- 'U_GROUP_RELEASES' => "group.php?view=releases&". POST_GROUPS_URL ."=$group_id",
- 'U_GROUP_MEMBERS' => "group.php?view=members&". POST_GROUPS_URL ."=$group_id",
- 'U_GROUP_CONFIG' => "group_edit.php?g=$group_id",
- 'RELEASE_GROUP' => ($group_info['release_group']) ? true : false,
- 'GROUP_TYPE' => $group_type,
+ $i = 0;
+ $template->assign_vars(array(
+ 'ROW_NUMBER' => $i + ($start + 1),
+ 'GROUP_INFO' => true,
+ 'PAGE_TITLE' => $lang['GROUP_CONTROL_PANEL'],
+ 'GROUP_NAME' => htmlCHR($group_info['group_name']),
+ 'GROUP_DESCRIPTION' => bbcode2html($group_info['group_description']),
+ 'GROUP_SIGNATURE' => bbcode2html($group_info['group_signature']),
+ 'GROUP_AVATAR' => get_avatar(GROUP_AVATAR_MASK . $group_id, $group_info['avatar_ext_id'], true),
+ 'GROUP_DETAILS' => $group_details,
+ 'GROUP_TIME' => (!empty($group_info['group_time'])) ? sprintf('%s (%s) ', bb_date($group_info['group_time']), delta_time($group_info['group_time'])) : $lang['NONE'],
+ 'MOD_USER' => profile_url($group_moderator),
+ 'MOD_AVATAR' => $avatar,
+ 'MOD_FROM' => $from,
+ 'MOD_JOINED' => $joined,
+ 'MOD_POSTS' => $posts,
+ 'MOD_PM' => $pm,
+ 'MOD_EMAIL' => $email,
+ 'MOD_WWW' => $www,
+ 'MOD_TIME' => (!empty($group_info['mod_time'])) ? bb_date($group_info['mod_time']) : $lang['NONE'],
+ 'U_SEARCH_USER' => "search.php?mode=searchuser",
+ 'U_SEARCH_RELEASES' => "tracker.php?srg=$group_id",
+ 'U_GROUP_RELEASES' => "group.php?view=releases&" . POST_GROUPS_URL . "=$group_id",
+ 'U_GROUP_MEMBERS' => "group.php?view=members&" . POST_GROUPS_URL . "=$group_id",
+ 'U_GROUP_CONFIG' => "group_edit.php?g=$group_id",
+ 'RELEASE_GROUP' => ($group_info['release_group']) ? true : false,
+ 'GROUP_TYPE' => $group_type,
- 'S_GROUP_OPEN_TYPE' => GROUP_OPEN,
- 'S_GROUP_CLOSED_TYPE' => GROUP_CLOSED,
- 'S_GROUP_HIDDEN_TYPE' => GROUP_HIDDEN,
- 'S_GROUP_OPEN_CHECKED' => ($group_info['group_type'] == GROUP_OPEN) ? ' checked="checked"' : '',
- 'S_GROUP_CLOSED_CHECKED' => ($group_info['group_type'] == GROUP_CLOSED) ? ' checked="checked"' : '',
- 'S_GROUP_HIDDEN_CHECKED' => ($group_info['group_type'] == GROUP_HIDDEN) ? ' checked="checked"' : '',
- 'S_HIDDEN_FIELDS' => $s_hidden_fields,
- 'S_MODE_SELECT' => $select_sort_mode,
- 'S_ORDER_SELECT' => $select_sort_order,
+ 'S_GROUP_OPEN_TYPE' => GROUP_OPEN,
+ 'S_GROUP_CLOSED_TYPE' => GROUP_CLOSED,
+ 'S_GROUP_HIDDEN_TYPE' => GROUP_HIDDEN,
+ 'S_GROUP_OPEN_CHECKED' => ($group_info['group_type'] == GROUP_OPEN) ? ' checked="checked"' : '',
+ 'S_GROUP_CLOSED_CHECKED' => ($group_info['group_type'] == GROUP_CLOSED) ? ' checked="checked"' : '',
+ 'S_GROUP_HIDDEN_CHECKED' => ($group_info['group_type'] == GROUP_HIDDEN) ? ' checked="checked"' : '',
+ 'S_HIDDEN_FIELDS' => $s_hidden_fields,
+ 'S_MODE_SELECT' => $select_sort_mode,
+ 'S_ORDER_SELECT' => $select_sort_order,
- 'S_GROUP_ACTION' => "group.php?" . POST_GROUPS_URL . "=$group_id",
- ));
+ 'S_GROUP_ACTION' => "group.php?" . POST_GROUPS_URL . "=$group_id",
+ ));
- switch ($view_mode)
- {
- case 'releases':
- // TODO Correct SQL to posts with attach and limit them, optimization
+ switch ($view_mode) {
+ case 'releases':
+ // TODO Correct SQL to posts with attach and limit them, optimization
- if (!$group_info['release_group'])
- {
- set_die_append_msg(false, false, $group_id);
- bb_die($lang['NOT_A_RELEASE_GROUP']);
- }
+ if (!$group_info['release_group']) {
+ set_die_append_msg(false, false, $group_id);
+ bb_die($lang['NOT_A_RELEASE_GROUP']);
+ }
- // Count releases for pagination
- $all_releases = DB()->fetch_rowset("
+ // Count releases for pagination
+ $all_releases = DB()->fetch_rowset("
SELECT p.topic_id, p.forum_id, p.poster_id, t.topic_title, t.topic_time, f.forum_name, u.username, u.avatar_ext_id, u.user_opt, u.user_rank
- FROM ". BB_POSTS ." p
- LEFT JOIN ". BB_TOPICS ." t ON(p.topic_id = t.topic_id)
- LEFT JOIN ". BB_FORUMS ." f ON(p.forum_id= f.forum_id)
- LEFT JOIN ". BB_USERS ." u ON(p.poster_id = u.user_id)
+ FROM " . BB_POSTS . " p
+ LEFT JOIN " . BB_TOPICS . " t ON(p.topic_id = t.topic_id)
+ LEFT JOIN " . BB_FORUMS . " f ON(p.forum_id= f.forum_id)
+ LEFT JOIN " . BB_USERS . " u ON(p.poster_id = u.user_id)
WHERE p.poster_rg_id = $group_id
ORDER BY t.topic_time DESC
LIMIT $rel_limit
");
- $count_releases = count($all_releases);
+ $count_releases = count($all_releases);
- generate_pagination(GROUP_URL . $group_id ."&view=releases", $count_releases, $per_page, $start);
+ generate_pagination(GROUP_URL . $group_id . "&view=releases", $count_releases, $per_page, $start);
- $sql = "
+ $sql = "
SELECT p.topic_id, p.forum_id, p.poster_id, t.topic_title, t.topic_time, f.forum_name, u.username, u.avatar_ext_id, u.user_opt, u.user_rank
- FROM ". BB_POSTS ." p
- LEFT JOIN ". BB_TOPICS ." t ON(p.topic_id = t.topic_id)
- LEFT JOIN ". BB_FORUMS ." f ON(p.forum_id= f.forum_id)
- LEFT JOIN ". BB_USERS ." u ON(p.poster_id = u.user_id)
+ FROM " . BB_POSTS . " p
+ LEFT JOIN " . BB_TOPICS . " t ON(p.topic_id = t.topic_id)
+ LEFT JOIN " . BB_FORUMS . " f ON(p.forum_id= f.forum_id)
+ LEFT JOIN " . BB_USERS . " u ON(p.poster_id = u.user_id)
WHERE p.poster_rg_id = $group_id
ORDER BY t.topic_time DESC
LIMIT $start, $per_page
";
- if (!$releases = DB()->fetch_rowset($sql))
- {
- set_die_append_msg(false, false, $group_id);
- bb_die($lang['NO_SEARCH_MATCH']);
- }
+ if (!$releases = DB()->fetch_rowset($sql)) {
+ set_die_append_msg(false, false, $group_id);
+ bb_die($lang['NO_SEARCH_MATCH']);
+ }
- foreach ($releases as $i => $release)
- {
- $row_class = !($i % 2) ? 'row1' : 'row2';
+ foreach ($releases as $i => $release) {
+ $row_class = !($i % 2) ? 'row1' : 'row2';
- $template->assign_block_vars('releases', array(
- 'ROW_NUMBER' => $i + ( $start + 1 ),
- 'ROW_CLASS' => $row_class,
- 'RELEASER' => profile_url(array('user_id' => $release['poster_id'], 'username' => $release['username'], 'user_rank' => $release['user_rank'])),
- 'AVATAR_IMG' => get_avatar($release['poster_id'], $release['avatar_ext_id'], !bf($release['user_opt'], 'user_opt', 'dis_avatar'), '', 50, 50),
- 'RELEASE_NAME' => sprintf('%s ', TOPIC_URL . $release['topic_id'], htmlCHR($release['topic_title'])),
- 'RELEASE_TIME' => bb_date($release['topic_time']),
- 'RELEASE_FORUM' => sprintf('%s ', FORUM_URL . $release['forum_id'], htmlCHR($release['forum_name'])),
- ));
- }
+ $template->assign_block_vars('releases', array(
+ 'ROW_NUMBER' => $i + ($start + 1),
+ 'ROW_CLASS' => $row_class,
+ 'RELEASER' => profile_url(array('user_id' => $release['poster_id'], 'username' => $release['username'], 'user_rank' => $release['user_rank'])),
+ 'AVATAR_IMG' => get_avatar($release['poster_id'], $release['avatar_ext_id'], !bf($release['user_opt'], 'user_opt', 'dis_avatar'), '', 50, 50),
+ 'RELEASE_NAME' => sprintf('%s ', TOPIC_URL . $release['topic_id'], htmlCHR($release['topic_title'])),
+ 'RELEASE_TIME' => bb_date($release['topic_time']),
+ 'RELEASE_FORUM' => sprintf('%s ', FORUM_URL . $release['forum_id'], htmlCHR($release['forum_name'])),
+ ));
+ }
- $template->assign_vars(array(
- 'RELEASES' => true,
- ));
+ $template->assign_vars(array(
+ 'RELEASES' => true,
+ ));
- break;
+ break;
- case 'members':
- default:
+ case 'members':
+ default:
- // Members
- $count_members = DB()->fetch_rowset("
+ // Members
+ $count_members = DB()->fetch_rowset("
SELECT u.username, u.user_rank, u.user_id, u.user_opt, u.user_posts, u.user_regdate, u.user_from, u.user_website, u.user_email, ug.user_pending, ug.user_time
- FROM ". BB_USER_GROUP ." ug, ". BB_USERS ." u
+ FROM " . BB_USER_GROUP . " ug, " . BB_USERS . " u
WHERE ug.group_id = $group_id
AND ug.user_pending = 0
- AND ug.user_id <> ". $group_moderator['user_id'] ."
+ AND ug.user_id <> " . $group_moderator['user_id'] . "
AND u.user_id = ug.user_id
ORDER BY u.username
");
- $count_members = count($count_members);
+ $count_members = count($count_members);
- // Get user information for this group
- $modgroup_pending_count = 0;
+ // Get user information for this group
+ $modgroup_pending_count = 0;
- // Members
- $group_members = DB()->fetch_rowset("
+ // Members
+ $group_members = DB()->fetch_rowset("
SELECT u.username, u.avatar_ext_id, u.user_rank, u.user_id, u.user_opt, u.user_posts, u.user_regdate, u.user_from, u.user_website, u.user_email, ug.user_pending, ug.user_time
- FROM ". BB_USER_GROUP ." ug, ". BB_USERS ." u
+ FROM " . BB_USER_GROUP . " ug, " . BB_USERS . " u
WHERE ug.group_id = $group_id
AND ug.user_pending = 0
- AND ug.user_id <> ". $group_moderator['user_id'] ."
+ AND ug.user_id <> " . $group_moderator['user_id'] . "
AND u.user_id = ug.user_id
ORDER BY u.username
LIMIT $start, $per_page
");
- $members_count = count($group_members);
+ $members_count = count($group_members);
- generate_pagination(GROUP_URL . $group_id, $count_members, $per_page, $start);
+ generate_pagination(GROUP_URL . $group_id, $count_members, $per_page, $start);
- // Dump out the remaining users
- foreach ($group_members as $i => $member)
- {
- $user_id = $member['user_id'];
+ // Dump out the remaining users
+ foreach ($group_members as $i => $member) {
+ $user_id = $member['user_id'];
- generate_user_info($member, $bb_cfg['default_dateformat'], $is_moderator, $from, $posts, $joined, $pm, $email, $www, $user_time, $avatar);
+ generate_user_info($member, $bb_cfg['default_dateformat'], $is_moderator, $from, $posts, $joined, $pm, $email, $www, $user_time, $avatar);
- if ($group_info['group_type'] != GROUP_HIDDEN || $is_group_member || $is_moderator)
- {
- $row_class = !($i % 2) ? 'row1' : 'row2';
+ if ($group_info['group_type'] != GROUP_HIDDEN || $is_group_member || $is_moderator) {
+ $row_class = !($i % 2) ? 'row1' : 'row2';
- $template->assign_block_vars('member', array(
- 'ROW_NUMBER' => $i + ( $start + 1 ),
- 'ROW_CLASS' => $row_class,
- 'USER' => profile_url($member),
- 'AVATAR_IMG' => $avatar,
- 'FROM' => $from,
- 'JOINED' => $joined,
- 'POSTS' => $posts,
- 'USER_ID' => $user_id,
- 'PM' => $pm,
- 'EMAIL' => $email,
- 'WWW' => $www,
- 'TIME' => $user_time,
- ));
+ $template->assign_block_vars('member', array(
+ 'ROW_NUMBER' => $i + ($start + 1),
+ 'ROW_CLASS' => $row_class,
+ 'USER' => profile_url($member),
+ 'AVATAR_IMG' => $avatar,
+ 'FROM' => $from,
+ 'JOINED' => $joined,
+ 'POSTS' => $posts,
+ 'USER_ID' => $user_id,
+ 'PM' => $pm,
+ 'EMAIL' => $email,
+ 'WWW' => $www,
+ 'TIME' => $user_time,
+ ));
- if ($is_moderator)
- {
- $template->assign_block_vars('member.switch_mod_option', array());
- }
- }
- }
+ if ($is_moderator) {
+ $template->assign_block_vars('member.switch_mod_option', array());
+ }
+ }
+ }
- // No group members
- if (!$members_count)
- {
- $template->assign_block_vars('switch_no_members', array());
- }
+ // No group members
+ if (!$members_count) {
+ $template->assign_block_vars('switch_no_members', array());
+ }
- // No group members
- if ($group_info['group_type'] == GROUP_HIDDEN && !$is_group_member && !$is_moderator)
- {
- $template->assign_block_vars('switch_hidden_group', array());
- }
+ // No group members
+ if ($group_info['group_type'] == GROUP_HIDDEN && !$is_group_member && !$is_moderator) {
+ $template->assign_block_vars('switch_hidden_group', array());
+ }
- // Pending
- if ($is_moderator)
- {
- $modgroup_pending_list = DB()->fetch_rowset("
+ // Pending
+ if ($is_moderator) {
+ $modgroup_pending_list = DB()->fetch_rowset("
SELECT u.username, u.avatar_ext_id, u.user_rank, u.user_id, u.user_opt, u.user_posts, u.user_regdate, u.user_from, u.user_website, u.user_email
- FROM ". BB_USER_GROUP ." ug, ". BB_USERS ." u
+ FROM " . BB_USER_GROUP . " ug, " . BB_USERS . " u
WHERE ug.group_id = $group_id
AND ug.user_pending = 1
AND u.user_id = ug.user_id
ORDER BY u.username
LIMIT 200
");
- $modgroup_pending_count = count($modgroup_pending_list);
- }
+ $modgroup_pending_count = count($modgroup_pending_list);
+ }
- if ($is_moderator && $modgroup_pending_list)
- {
- foreach ($modgroup_pending_list as $i => $member)
- {
- $user_id = $member['user_id'];
+ if ($is_moderator && $modgroup_pending_list) {
+ foreach ($modgroup_pending_list as $i => $member) {
+ $user_id = $member['user_id'];
- generate_user_info($member, $bb_cfg['default_dateformat'], $is_moderator, $from, $posts, $joined, $pm, $email, $www, $user_time, $avatar);
+ generate_user_info($member, $bb_cfg['default_dateformat'], $is_moderator, $from, $posts, $joined, $pm, $email, $www, $user_time, $avatar);
- $row_class = !($i % 2) ? 'row1' : 'row2';
+ $row_class = !($i % 2) ? 'row1' : 'row2';
- $user_select = ' ';
+ $user_select = ' ';
- $template->assign_block_vars('pending', array(
- 'ROW_CLASS' => $row_class,
- 'AVATAR_IMG'=> $avatar,
- 'USER' => profile_url($member),
- 'FROM' => $from,
- 'JOINED' => $joined,
- 'POSTS' => $posts,
- 'USER_ID' => $user_id,
- 'PM' => $pm,
- 'EMAIL' => $email,
- ));
- }
+ $template->assign_block_vars('pending', array(
+ 'ROW_CLASS' => $row_class,
+ 'AVATAR_IMG' => $avatar,
+ 'USER' => profile_url($member),
+ 'FROM' => $from,
+ 'JOINED' => $joined,
+ 'POSTS' => $posts,
+ 'USER_ID' => $user_id,
+ 'PM' => $pm,
+ 'EMAIL' => $email,
+ ));
+ }
- $template->assign_vars(array(
- 'PENDING_USERS' => true,
- ));
- }
+ $template->assign_vars(array(
+ 'PENDING_USERS' => true,
+ ));
+ }
- $template->assign_vars(array('MEMBERS' => true));
- }
+ $template->assign_vars(array('MEMBERS' => true));
+ }
- if ($is_moderator)
- {
- $template->assign_block_vars('switch_mod_option', array());
- $template->assign_block_vars('switch_add_member', array());
- }
+ if ($is_moderator) {
+ $template->assign_block_vars('switch_mod_option', array());
+ $template->assign_block_vars('switch_add_member', array());
+ }
}
-print_page('group.tpl');
\ No newline at end of file
+print_page('group.tpl');
diff --git a/group_edit.php b/group_edit.php
index 801e62f69..eb2f0906e 100644
--- a/group_edit.php
+++ b/group_edit.php
@@ -1,10 +1,33 @@
init($bb_cfg['group_avatars'], $_FILES['avatar']) AND $upload->store('avatar', array("user_id" => GROUP_AVATAR_MASK . $group_id, "avatar_ext_id" => $group_info['avatar_ext_id'])))
- {
- $avatar_ext_id = (int) $upload->file_ext_id;
- }
- else
- {
- bb_die(implode($upload->errors));
- }
+ if ($upload->init($bb_cfg['group_avatars'], $_FILES['avatar']) and $upload->store('avatar', array("user_id" => GROUP_AVATAR_MASK . $group_id, "avatar_ext_id" => $group_info['avatar_ext_id']))) {
+ $avatar_ext_id = (int)$upload->file_ext_id;
+ } else {
+ bb_die(implode($upload->errors));
+ }
- DB()->query("UPDATE ". BB_GROUPS ." SET avatar_ext_id = $avatar_ext_id WHERE group_id = $group_id LIMIT 1");
- }
- }
+ DB()->query("UPDATE " . BB_GROUPS . " SET avatar_ext_id = $avatar_ext_id WHERE group_id = $group_id LIMIT 1");
+ }
+ }
- $group_type = '';
- if ($group_info['group_type'] == GROUP_OPEN)
- {
- $group_type = $lang['GROUP_OPEN'];
- }
- elseif ($group_info['group_type'] == GROUP_CLOSED)
- {
- $group_type = $lang['GROUP_CLOSED'];
- }
- elseif ($group_info['group_type'] == GROUP_HIDDEN)
- {
- $group_type = $lang['GROUP_HIDDEN'];
- }
+ $group_type = '';
+ if ($group_info['group_type'] == GROUP_OPEN) {
+ $group_type = $lang['GROUP_OPEN'];
+ } elseif ($group_info['group_type'] == GROUP_CLOSED) {
+ $group_type = $lang['GROUP_CLOSED'];
+ } elseif ($group_info['group_type'] == GROUP_HIDDEN) {
+ $group_type = $lang['GROUP_HIDDEN'];
+ }
- $s_hidden_fields = ' ';
+ $s_hidden_fields = ' ';
- $template->assign_vars(array(
- 'PAGE_TITLE' => $lang['GROUP_CONTROL_PANEL'],
- 'GROUP_NAME' => htmlCHR($group_info['group_name']),
- 'GROUP_ID' => $group_id,
- 'GROUP_DESCRIPTION' => htmlCHR($group_info['group_description']),
- 'GROUP_SIGNATURE' => htmlCHR($group_info['group_signature']),
- 'U_GROUP_URL' => GROUP_URL . $group_id,
- 'RELEASE_GROUP' => ($group_info['release_group']) ? true : false,
- 'GROUP_TYPE' => $group_type,
- 'S_GROUP_OPEN_TYPE' => GROUP_OPEN,
- 'S_GROUP_CLOSED_TYPE' => GROUP_CLOSED,
- 'S_GROUP_HIDDEN_TYPE' => GROUP_HIDDEN,
- 'S_GROUP_OPEN_CHECKED' => ($group_info['group_type'] == GROUP_OPEN) ? ' checked="checked"' : '',
- 'S_GROUP_CLOSED_CHECKED' => ($group_info['group_type'] == GROUP_CLOSED) ? ' checked="checked"' : '',
- 'S_GROUP_HIDDEN_CHECKED' => ($group_info['group_type'] == GROUP_HIDDEN) ? ' checked="checked"' : '',
- 'S_HIDDEN_FIELDS' => $s_hidden_fields,
- 'S_GROUP_CONFIG_ACTION' => "group_edit.php?" . POST_GROUPS_URL . "=$group_id",
+ $template->assign_vars(array(
+ 'PAGE_TITLE' => $lang['GROUP_CONTROL_PANEL'],
+ 'GROUP_NAME' => htmlCHR($group_info['group_name']),
+ 'GROUP_ID' => $group_id,
+ 'GROUP_DESCRIPTION' => htmlCHR($group_info['group_description']),
+ 'GROUP_SIGNATURE' => htmlCHR($group_info['group_signature']),
+ 'U_GROUP_URL' => GROUP_URL . $group_id,
+ 'RELEASE_GROUP' => ($group_info['release_group']) ? true : false,
+ 'GROUP_TYPE' => $group_type,
+ 'S_GROUP_OPEN_TYPE' => GROUP_OPEN,
+ 'S_GROUP_CLOSED_TYPE' => GROUP_CLOSED,
+ 'S_GROUP_HIDDEN_TYPE' => GROUP_HIDDEN,
+ 'S_GROUP_OPEN_CHECKED' => ($group_info['group_type'] == GROUP_OPEN) ? ' checked="checked"' : '',
+ 'S_GROUP_CLOSED_CHECKED' => ($group_info['group_type'] == GROUP_CLOSED) ? ' checked="checked"' : '',
+ 'S_GROUP_HIDDEN_CHECKED' => ($group_info['group_type'] == GROUP_HIDDEN) ? ' checked="checked"' : '',
+ 'S_HIDDEN_FIELDS' => $s_hidden_fields,
+ 'S_GROUP_CONFIG_ACTION' => "group_edit.php?" . POST_GROUPS_URL . "=$group_id",
- 'AVATAR_EXPLAIN' => sprintf($lang['AVATAR_EXPLAIN'], $bb_cfg['group_avatars']['max_width'], $bb_cfg['group_avatars']['max_height'], (round($bb_cfg['group_avatars']['max_size'] / 1024))),
- 'AVATAR_IMG' => get_avatar(GROUP_AVATAR_MASK . $group_id, $group_info['avatar_ext_id']),
- ));
+ 'AVATAR_EXPLAIN' => sprintf($lang['AVATAR_EXPLAIN'], $bb_cfg['group_avatars']['max_width'], $bb_cfg['group_avatars']['max_height'], (round($bb_cfg['group_avatars']['max_size'] / 1024))),
+ 'AVATAR_IMG' => get_avatar(GROUP_AVATAR_MASK . $group_id, $group_info['avatar_ext_id']),
+ ));
- $template->set_filenames(array('body' => 'group_edit.tpl'));
- $template->assign_vars(array('PAGE_TITLE' => $lang['GROUP_CONFIGURATION']));
+ $template->set_filenames(array('body' => 'group_edit.tpl'));
+ $template->assign_vars(array('PAGE_TITLE' => $lang['GROUP_CONFIGURATION']));
- require(PAGE_HEADER);
+ require(PAGE_HEADER);
- $template->pparse('body');
+ $template->pparse('body');
- require(PAGE_FOOTER);
+ require(PAGE_FOOTER);
+} else {
+ $redirect = 'index.php';
+
+ if ($group_id) {
+ $redirect = GROUP_URL . $group_id;
+ }
+ redirect($redirect);
}
-else
-{
- $redirect = 'index.php';
-
- if ($group_id)
- {
- $redirect = GROUP_URL . $group_id;
- }
- redirect($redirect);
-}
\ No newline at end of file
diff --git a/index.php b/index.php
index 7dc7b44a9..71995e8fc 100644
--- a/index.php
+++ b/index.php
@@ -1,37 +1,58 @@
enqueue(array(
- 'stats',
- 'moderators',
+ 'stats',
+ 'moderators',
));
-if ($bb_cfg['show_latest_news'])
-{
- $datastore->enqueue('latest_news');
+if ($bb_cfg['show_latest_news']) {
+ $datastore->enqueue('latest_news');
}
-if ($bb_cfg['show_network_news'])
-{
- $datastore->enqueue('network_news');
+if ($bb_cfg['show_network_news']) {
+ $datastore->enqueue('network_news');
}
// Init userdata
$user->session_start();
// Init main vars
-$viewcat = isset($_GET['c']) ? (int) $_GET['c'] : 0;
+$viewcat = isset($_GET['c']) ? (int)$_GET['c'] : 0;
$lastvisit = (IS_GUEST) ? TIMENOW : $userdata['user_lastvisit'];
// Caching output
@@ -39,28 +60,26 @@ $req_page = 'index_page';
$req_page .= ($viewcat) ? "_c{$viewcat}" : '';
define('REQUESTED_PAGE', $req_page);
-caching_output(IS_GUEST, 'send', REQUESTED_PAGE .'_guest_'. $bb_cfg['default_lang']);
+caching_output(IS_GUEST, 'send', REQUESTED_PAGE . '_guest_' . $bb_cfg['default_lang']);
-$hide_cat_opt = isset($user->opt_js['h_cat']) ? (string) $user->opt_js['h_cat'] : 0;
+$hide_cat_opt = isset($user->opt_js['h_cat']) ? (string)$user->opt_js['h_cat'] : 0;
$hide_cat_user = array_flip(explode('-', $hide_cat_opt));
-$showhide = isset($_GET['sh']) ? (int) $_GET['sh'] : 0;
+$showhide = isset($_GET['sh']) ? (int)$_GET['sh'] : 0;
// Topics read tracks
$tracking_topics = get_tracks('topic');
$tracking_forums = get_tracks('forum');
// Statistics
-if (!$stats = $datastore->get('stats'))
-{
- $datastore->update('stats');
- $stats = $datastore->get('stats');
+if (!$stats = $datastore->get('stats')) {
+ $datastore->update('stats');
+ $stats = $datastore->get('stats');
}
// Forums data
-if (!$forums = $datastore->get('cat_forums'))
-{
- $datastore->update('cat_forums');
- $forums = $datastore->get('cat_forums');
+if (!$forums = $datastore->get('cat_forums')) {
+ $datastore->update('cat_forums');
+ $forums = $datastore->get('cat_forums');
}
$cat_title_html = $forums['cat_title_html'];
$forum_name_html = $forums['forum_name_html'];
@@ -70,9 +89,8 @@ $excluded_forums_csv = $user->get_excluded_forums(AUTH_VIEW);
$only_new = $user->opt_js['only_new'];
// Validate requested category id
-if ($viewcat AND !$viewcat =& $forums['c'][$viewcat]['cat_id'])
-{
- redirect("index.php");
+if ($viewcat and !$viewcat =& $forums['c'][$viewcat]['cat_id']) {
+ redirect("index.php");
}
// Forums
@@ -106,96 +124,78 @@ $sql = "
t.topic_id AS last_topic_id, t.topic_title AS last_topic_title,
u.user_id AS last_post_user_id, u.user_rank AS last_post_user_rank,
IF(p.poster_id = $anon, p.post_username, u.username) AS last_post_username
- FROM ". BB_CATEGORIES ." c
- INNER JOIN ". BB_FORUMS ." f ON($forums_join_sql)
- $join_p_type ". BB_POSTS ." p ON($posts_join_sql)
- $join_t_type ". BB_TOPICS ." t ON($topics_join_sql)
- LEFT JOIN ". BB_USERS ." u ON(u.user_id = p.poster_id)
+ FROM " . BB_CATEGORIES . " c
+ INNER JOIN " . BB_FORUMS . " f ON($forums_join_sql)
+ $join_p_type " . BB_POSTS . " p ON($posts_join_sql)
+ $join_t_type " . BB_TOPICS . " t ON($topics_join_sql)
+ LEFT JOIN " . BB_USERS . " u ON(u.user_id = p.poster_id)
ORDER BY c.cat_order, f.forum_order
";
$replace_in_parent = array(
- 'last_post_id',
- 'last_post_time',
- 'last_post_user_id',
- 'last_post_username',
- 'last_post_user_rank',
- 'last_topic_title',
- 'last_topic_id',
+ 'last_post_id',
+ 'last_post_time',
+ 'last_post_user_id',
+ 'last_post_username',
+ 'last_post_user_rank',
+ 'last_topic_title',
+ 'last_topic_id',
);
$cache_name = 'index_sql_' . md5($sql);
-if (!$cat_forums = CACHE('bb_cache')->get($cache_name))
-{
- $cat_forums = array();
- foreach (DB()->fetch_rowset($sql) as $row)
- {
- if (!$cat_id = $row['cat_id'] OR !$forum_id = $row['forum_id'])
- {
- continue;
- }
+if (!$cat_forums = CACHE('bb_cache')->get($cache_name)) {
+ $cat_forums = array();
+ foreach (DB()->fetch_rowset($sql) as $row) {
+ if (!$cat_id = $row['cat_id'] or !$forum_id = $row['forum_id']) {
+ continue;
+ }
- if ($parent_id = $row['forum_parent'])
- {
- if (!$parent =& $cat_forums[$cat_id]['f'][$parent_id])
- {
- $parent = $forums['f'][$parent_id];
- $parent['last_post_time'] = 0;
- }
- if ($row['last_post_time'] > $parent['last_post_time'])
- {
- foreach ($replace_in_parent as $key)
- {
- $parent[$key] = $row[$key];
- }
- }
- if ($show_subforums && $row['show_on_index'])
- {
- $parent['last_sf_id'] = $forum_id;
- }
- else
- {
- continue;
- }
- }
- else
- {
- $f =& $forums['f'][$forum_id];
- $row['forum_desc'] = $f['forum_desc'];
- $row['forum_posts'] = $f['forum_posts'];
- $row['forum_topics'] = $f['forum_topics'];
- }
- $cat_forums[$cat_id]['f'][$forum_id] = $row;
- }
- CACHE('bb_cache')->set($cache_name, $cat_forums, 180);
- unset($row, $forums);
- $datastore->rm('cat_forums');
+ if ($parent_id = $row['forum_parent']) {
+ if (!$parent =& $cat_forums[$cat_id]['f'][$parent_id]) {
+ $parent = $forums['f'][$parent_id];
+ $parent['last_post_time'] = 0;
+ }
+ if ($row['last_post_time'] > $parent['last_post_time']) {
+ foreach ($replace_in_parent as $key) {
+ $parent[$key] = $row[$key];
+ }
+ }
+ if ($show_subforums && $row['show_on_index']) {
+ $parent['last_sf_id'] = $forum_id;
+ } else {
+ continue;
+ }
+ } else {
+ $f =& $forums['f'][$forum_id];
+ $row['forum_desc'] = $f['forum_desc'];
+ $row['forum_posts'] = $f['forum_posts'];
+ $row['forum_topics'] = $f['forum_topics'];
+ }
+ $cat_forums[$cat_id]['f'][$forum_id] = $row;
+ }
+ CACHE('bb_cache')->set($cache_name, $cat_forums, 180);
+ unset($row, $forums);
+ $datastore->rm('cat_forums');
}
// Obtain list of moderators
$moderators = array();
-if (!$mod = $datastore->get('moderators'))
-{
- $datastore->update('moderators');
- $mod = $datastore->get('moderators');
+if (!$mod = $datastore->get('moderators')) {
+ $datastore->update('moderators');
+ $mod = $datastore->get('moderators');
}
-if (!empty($mod))
-{
- foreach ($mod['mod_users'] as $forum_id => $user_ids)
- {
- foreach ($user_ids as $user_id)
- {
- $moderators[$forum_id][] = ''. $mod['name_users'][$user_id] .' ';
- }
- }
- foreach ($mod['mod_groups'] as $forum_id => $group_ids)
- {
- foreach ($group_ids as $group_id)
- {
- $moderators[$forum_id][] = ''. $mod['name_groups'][$group_id] .' ';
- }
- }
+if (!empty($mod)) {
+ foreach ($mod['mod_users'] as $forum_id => $user_ids) {
+ foreach ($user_ids as $user_id) {
+ $moderators[$forum_id][] = '' . $mod['name_users'][$user_id] . ' ';
+ }
+ }
+ foreach ($mod['mod_groups'] as $forum_id => $group_ids) {
+ foreach ($group_ids as $group_id) {
+ $moderators[$forum_id][] = '' . $mod['name_groups'][$group_id] . ' ';
+ }
+ }
}
unset($mod);
@@ -203,229 +203,209 @@ $datastore->rm('moderators');
// Build index page
$forums_count = 0;
-foreach ($cat_forums as $cid => $c)
-{
- $template->assign_block_vars('h_c', array(
- 'H_C_ID' => $cid,
- 'H_C_TITLE' => $cat_title_html[$cid],
- 'H_C_CHEKED' => in_array($cid, preg_split("/[-]+/", $hide_cat_opt)) ? 'checked' : '',
- ));
+foreach ($cat_forums as $cid => $c) {
+ $template->assign_block_vars('h_c', array(
+ 'H_C_ID' => $cid,
+ 'H_C_TITLE' => $cat_title_html[$cid],
+ 'H_C_CHEKED' => in_array($cid, preg_split("/[-]+/", $hide_cat_opt)) ? 'checked' : '',
+ ));
- $template->assign_vars(array(
- 'H_C_AL_MESS' => ($hide_cat_opt && !$showhide) ? true : false,
- ));
+ $template->assign_vars(array(
+ 'H_C_AL_MESS' => ($hide_cat_opt && !$showhide) ? true : false,
+ ));
- if (!$showhide && isset($hide_cat_user[$cid]) && !$viewcat)
- {
- continue;
- }
+ if (!$showhide && isset($hide_cat_user[$cid]) && !$viewcat) {
+ continue;
+ }
- $template->assign_block_vars('c', array(
- 'CAT_ID' => $cid,
- 'CAT_TITLE' => $cat_title_html[$cid],
- 'U_VIEWCAT' => CAT_URL . $cid,
- ));
+ $template->assign_block_vars('c', array(
+ 'CAT_ID' => $cid,
+ 'CAT_TITLE' => $cat_title_html[$cid],
+ 'U_VIEWCAT' => CAT_URL . $cid,
+ ));
- foreach ($c['f'] as $fid => $f)
- {
- if (!$fname_html =& $forum_name_html[$fid])
- {
- continue;
- }
- $is_sf = $f['forum_parent'];
+ foreach ($c['f'] as $fid => $f) {
+ if (!$fname_html =& $forum_name_html[$fid]) {
+ continue;
+ }
+ $is_sf = $f['forum_parent'];
- $forums_count++;
- $new = is_unread($f['last_post_time'], $f['last_topic_id'], $f['forum_id']) ? '_new' : '';
- $folder_image = ($is_sf) ? $images["icon_minipost{$new}"] : $images["forum{$new}"];
+ $forums_count++;
+ $new = is_unread($f['last_post_time'], $f['last_topic_id'], $f['forum_id']) ? '_new' : '';
+ $folder_image = ($is_sf) ? $images["icon_minipost{$new}"] : $images["forum{$new}"];
- if ($f['forum_status'] == FORUM_LOCKED)
- {
- $folder_image = ($is_sf) ? $images['icon_minipost'] : $images['forum_locked'];
- }
+ if ($f['forum_status'] == FORUM_LOCKED) {
+ $folder_image = ($is_sf) ? $images['icon_minipost'] : $images['forum_locked'];
+ }
- if ($is_sf)
- {
- $template->assign_block_vars('c.f.sf', array(
- 'SF_ID' => $fid,
- 'SF_NAME' => $fname_html,
- 'SF_NEW' => $new ? ' new' : '',
- ));
- continue;
- }
+ if ($is_sf) {
+ $template->assign_block_vars('c.f.sf', array(
+ 'SF_ID' => $fid,
+ 'SF_NAME' => $fname_html,
+ 'SF_NEW' => $new ? ' new' : '',
+ ));
+ continue;
+ }
- $template->assign_block_vars('c.f', array(
- 'FORUM_FOLDER_IMG' => $folder_image,
- 'FORUM_ID' => $fid,
- 'FORUM_NAME' => $fname_html,
- 'FORUM_DESC' => $f['forum_desc'],
- 'POSTS' => commify($f['forum_posts']),
- 'TOPICS' => commify($f['forum_topics']),
- 'LAST_SF_ID' => isset($f['last_sf_id']) ? $f['last_sf_id'] : null,
- 'MODERATORS' => isset($moderators[$fid]) ? join(', ', $moderators[$fid]) : '',
- 'FORUM_FOLDER_ALT' => ($new) ? $lang['NEW'] : $lang['OLD'],
- ));
+ $template->assign_block_vars('c.f', array(
+ 'FORUM_FOLDER_IMG' => $folder_image,
+ 'FORUM_ID' => $fid,
+ 'FORUM_NAME' => $fname_html,
+ 'FORUM_DESC' => $f['forum_desc'],
+ 'POSTS' => commify($f['forum_posts']),
+ 'TOPICS' => commify($f['forum_topics']),
+ 'LAST_SF_ID' => isset($f['last_sf_id']) ? $f['last_sf_id'] : null,
+ 'MODERATORS' => isset($moderators[$fid]) ? join(', ', $moderators[$fid]) : '',
+ 'FORUM_FOLDER_ALT' => ($new) ? $lang['NEW'] : $lang['OLD'],
+ ));
- if ($f['last_post_id'])
- {
- $template->assign_block_vars('c.f.last', array(
- 'LAST_TOPIC_ID' => $f['last_topic_id'],
- 'LAST_TOPIC_TIP' => $f['last_topic_title'],
- 'LAST_TOPIC_TITLE' => wbr(str_short($f['last_topic_title'], $last_topic_max_len)),
- 'LAST_POST_TIME' => bb_date($f['last_post_time'], $bb_cfg['last_post_date_format']),
- 'LAST_POST_USER' => profile_url(array('username' => str_short($f['last_post_username'], 15), 'user_id' => $f['last_post_user_id'], 'user_rank' => $f['last_post_user_rank'])),
- ));
- }
- }
+ if ($f['last_post_id']) {
+ $template->assign_block_vars('c.f.last', array(
+ 'LAST_TOPIC_ID' => $f['last_topic_id'],
+ 'LAST_TOPIC_TIP' => $f['last_topic_title'],
+ 'LAST_TOPIC_TITLE' => wbr(str_short($f['last_topic_title'], $last_topic_max_len)),
+ 'LAST_POST_TIME' => bb_date($f['last_post_time'], $bb_cfg['last_post_date_format']),
+ 'LAST_POST_USER' => profile_url(array('username' => str_short($f['last_post_username'], 15), 'user_id' => $f['last_post_user_id'], 'user_rank' => $f['last_post_user_rank'])),
+ ));
+ }
+ }
}
$template->assign_vars(array(
- 'SHOW_FORUMS' => $forums_count,
- 'SHOW_MAP' => (isset($_GET['map']) && !IS_GUEST),
- 'PAGE_TITLE' => ($viewcat) ? $cat_title_html[$viewcat] : $lang['HOME'],
- 'NO_FORUMS_MSG' => ($only_new) ? $lang['NO_NEW_POSTS'] : $lang['NO_FORUMS'],
+ 'SHOW_FORUMS' => $forums_count,
+ 'SHOW_MAP' => (isset($_GET['map']) && !IS_GUEST),
+ 'PAGE_TITLE' => ($viewcat) ? $cat_title_html[$viewcat] : $lang['HOME'],
+ 'NO_FORUMS_MSG' => ($only_new) ? $lang['NO_NEW_POSTS'] : $lang['NO_FORUMS'],
- 'TOTAL_TOPICS' => sprintf($lang['POSTED_TOPICS_TOTAL'], $stats['topiccount']),
- 'TOTAL_POSTS' => sprintf($lang['POSTED_ARTICLES_TOTAL'], $stats['postcount']),
- 'TOTAL_USERS' => sprintf($lang['REGISTERED_USERS_TOTAL'], $stats['usercount']),
- 'TOTAL_GENDER' => ($bb_cfg['gender']) ? sprintf($lang['USERS_TOTAL_GENDER'], $stats['male'], $stats['female'], $stats['unselect']) : '',
- 'NEWEST_USER' => sprintf($lang['NEWEST_USER'], profile_url($stats['newestuser'])),
+ 'TOTAL_TOPICS' => sprintf($lang['POSTED_TOPICS_TOTAL'], $stats['topiccount']),
+ 'TOTAL_POSTS' => sprintf($lang['POSTED_ARTICLES_TOTAL'], $stats['postcount']),
+ 'TOTAL_USERS' => sprintf($lang['REGISTERED_USERS_TOTAL'], $stats['usercount']),
+ 'TOTAL_GENDER' => ($bb_cfg['gender']) ? sprintf($lang['USERS_TOTAL_GENDER'], $stats['male'], $stats['female'], $stats['unselect']) : '',
+ 'NEWEST_USER' => sprintf($lang['NEWEST_USER'], profile_url($stats['newestuser'])),
- // Tracker stats
- 'TORRENTS_STAT' => ($bb_cfg['tor_stats']) ? sprintf($lang['TORRENTS_STAT'], $stats['torrentcount'], humn_size($stats['size'])) : '',
- 'PEERS_STAT' => ($bb_cfg['tor_stats']) ? sprintf($lang['PEERS_STAT'], $stats['peers'], $stats['seeders'], $stats['leechers']) : '',
- 'SPEED_STAT' => ($bb_cfg['tor_stats']) ? sprintf($lang['SPEED_STAT'], humn_size($stats['speed']) .'/s') : '',
- 'SHOW_MOD_INDEX' => $bb_cfg['show_mod_index'],
- 'FORUM_IMG' => $images['forum'],
- 'FORUM_NEW_IMG' => $images['forum_new'],
- 'FORUM_LOCKED_IMG' => $images['forum_locked'],
+ // Tracker stats
+ 'TORRENTS_STAT' => ($bb_cfg['tor_stats']) ? sprintf($lang['TORRENTS_STAT'], $stats['torrentcount'], humn_size($stats['size'])) : '',
+ 'PEERS_STAT' => ($bb_cfg['tor_stats']) ? sprintf($lang['PEERS_STAT'], $stats['peers'], $stats['seeders'], $stats['leechers']) : '',
+ 'SPEED_STAT' => ($bb_cfg['tor_stats']) ? sprintf($lang['SPEED_STAT'], humn_size($stats['speed']) . '/s') : '',
+ 'SHOW_MOD_INDEX' => $bb_cfg['show_mod_index'],
+ 'FORUM_IMG' => $images['forum'],
+ 'FORUM_NEW_IMG' => $images['forum_new'],
+ 'FORUM_LOCKED_IMG' => $images['forum_locked'],
- 'SHOW_ONLY_NEW_MENU' => true,
- 'ONLY_NEW_POSTS_ON' => ($only_new == ONLY_NEW_POSTS),
- 'ONLY_NEW_TOPICS_ON' => ($only_new == ONLY_NEW_TOPICS),
+ 'SHOW_ONLY_NEW_MENU' => true,
+ 'ONLY_NEW_POSTS_ON' => ($only_new == ONLY_NEW_POSTS),
+ 'ONLY_NEW_TOPICS_ON' => ($only_new == ONLY_NEW_TOPICS),
- 'U_SEARCH_NEW' => "search.php?new=1",
- 'U_SEARCH_SELF_BY_MY' => "search.php?uid={$userdata['user_id']}&o=1",
- 'U_SEARCH_LATEST' => "search.php?search_id=latest",
- 'U_SEARCH_UNANSWERED' => "search.php?search_id=unanswered",
+ 'U_SEARCH_NEW' => "search.php?new=1",
+ 'U_SEARCH_SELF_BY_MY' => "search.php?uid={$userdata['user_id']}&o=1",
+ 'U_SEARCH_LATEST' => "search.php?search_id=latest",
+ 'U_SEARCH_UNANSWERED' => "search.php?search_id=unanswered",
- 'SHOW_LAST_TOPIC' => $show_last_topic,
+ 'SHOW_LAST_TOPIC' => $show_last_topic,
));
// Set tpl vars for bt_userdata
-if ($bb_cfg['bt_show_dl_stat_on_index'] && !IS_GUEST)
-{
- show_bt_userdata($userdata['user_id']);
+if ($bb_cfg['bt_show_dl_stat_on_index'] && !IS_GUEST) {
+ show_bt_userdata($userdata['user_id']);
}
// Latest news
-if ($bb_cfg['show_latest_news'])
-{
- if (!$latest_news = $datastore->get('latest_news'))
- {
- $datastore->update('latest_news');
- $latest_news = $datastore->get('latest_news');
- }
+if ($bb_cfg['show_latest_news']) {
+ if (!$latest_news = $datastore->get('latest_news')) {
+ $datastore->update('latest_news');
+ $latest_news = $datastore->get('latest_news');
+ }
- $template->assign_vars(array(
- 'SHOW_LATEST_NEWS' => true,
- ));
+ $template->assign_vars(array(
+ 'SHOW_LATEST_NEWS' => true,
+ ));
- foreach ($latest_news as $news)
- {
- $template->assign_block_vars('news', array(
- 'NEWS_TOPIC_ID' => $news['topic_id'],
- 'NEWS_TITLE' => str_short($news['topic_title'], $bb_cfg['max_news_title']),
- 'NEWS_TIME' => bb_date($news['topic_time'], 'd-M', false),
- 'NEWS_IS_NEW' => is_unread($news['topic_time'], $news['topic_id'], $news['forum_id']),
- ));
- }
+ foreach ($latest_news as $news) {
+ $template->assign_block_vars('news', array(
+ 'NEWS_TOPIC_ID' => $news['topic_id'],
+ 'NEWS_TITLE' => str_short($news['topic_title'], $bb_cfg['max_news_title']),
+ 'NEWS_TIME' => bb_date($news['topic_time'], 'd-M', false),
+ 'NEWS_IS_NEW' => is_unread($news['topic_time'], $news['topic_id'], $news['forum_id']),
+ ));
+ }
}
// Network news
-if ($bb_cfg['show_network_news'])
-{
- if (!$network_news = $datastore->get('network_news'))
- {
- $datastore->update('network_news');
- $network_news = $datastore->get('network_news');
- }
+if ($bb_cfg['show_network_news']) {
+ if (!$network_news = $datastore->get('network_news')) {
+ $datastore->update('network_news');
+ $network_news = $datastore->get('network_news');
+ }
- $template->assign_vars(array(
- 'SHOW_NETWORK_NEWS' => true,
- ));
+ $template->assign_vars(array(
+ 'SHOW_NETWORK_NEWS' => true,
+ ));
- foreach ($network_news as $net)
- {
- $template->assign_block_vars('net', array(
- 'NEWS_TOPIC_ID' => $net['topic_id'],
- 'NEWS_TITLE' => str_short($net['topic_title'], $bb_cfg['max_net_title']),
- 'NEWS_TIME' => bb_date($net['topic_time'], 'd-M', false),
- 'NEWS_IS_NEW' => is_unread($net['topic_time'], $net['topic_id'], $net['forum_id']),
- ));
- }
+ foreach ($network_news as $net) {
+ $template->assign_block_vars('net', array(
+ 'NEWS_TOPIC_ID' => $net['topic_id'],
+ 'NEWS_TITLE' => str_short($net['topic_title'], $bb_cfg['max_net_title']),
+ 'NEWS_TIME' => bb_date($net['topic_time'], 'd-M', false),
+ 'NEWS_IS_NEW' => is_unread($net['topic_time'], $net['topic_id'], $net['forum_id']),
+ ));
+ }
}
-if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled'])
-{
- $week_list = $today_list = array();
- $week_all = $today_all = false;
+if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled']) {
+ $week_list = $today_list = array();
+ $week_all = $today_all = false;
- if ($stats['birthday_week_list'])
- {
- shuffle($stats['birthday_week_list']);
- foreach ($stats['birthday_week_list'] as $i => $week)
- {
- if ($i >= 5)
- {
- $week_all = true;
- continue;
- }
- $week_list[] = profile_url($week) .' ('. birthday_age($week['user_birthday']-1) .') ';
- }
- $week_all = ($week_all) ? ' ... ' : '';
- $week_list = sprintf($lang['BIRTHDAY_WEEK'], $bb_cfg['birthday_check_day'], join(', ', $week_list)) . $week_all;
- }
- else $week_list = sprintf($lang['NOBIRTHDAY_WEEK'], $bb_cfg['birthday_check_day']);
+ if ($stats['birthday_week_list']) {
+ shuffle($stats['birthday_week_list']);
+ foreach ($stats['birthday_week_list'] as $i => $week) {
+ if ($i >= 5) {
+ $week_all = true;
+ continue;
+ }
+ $week_list[] = profile_url($week) . ' (' . birthday_age($week['user_birthday'] - 1) . ') ';
+ }
+ $week_all = ($week_all) ? ' ... ' : '';
+ $week_list = sprintf($lang['BIRTHDAY_WEEK'], $bb_cfg['birthday_check_day'], join(', ', $week_list)) . $week_all;
+ } else {
+ $week_list = sprintf($lang['NOBIRTHDAY_WEEK'], $bb_cfg['birthday_check_day']);
+ }
- if ($stats['birthday_today_list'])
- {
- shuffle($stats['birthday_today_list']);
- foreach ($stats['birthday_today_list'] as $i => $today)
- {
- if ($i >= 5)
- {
- $today_all = true;
- continue;
- }
- $today_list[] = profile_url($today) .' ('. birthday_age($today['user_birthday']) .') ';
- }
- $today_all = ($today_all) ? ' ... ' : '';
- $today_list = $lang['BIRTHDAY_TODAY'] . join(', ', $today_list) . $today_all;
- }
- else $today_list = $lang['NOBIRTHDAY_TODAY'];
+ if ($stats['birthday_today_list']) {
+ shuffle($stats['birthday_today_list']);
+ foreach ($stats['birthday_today_list'] as $i => $today) {
+ if ($i >= 5) {
+ $today_all = true;
+ continue;
+ }
+ $today_list[] = profile_url($today) . ' (' . birthday_age($today['user_birthday']) . ') ';
+ }
+ $today_all = ($today_all) ? ' ... ' : '';
+ $today_list = $lang['BIRTHDAY_TODAY'] . join(', ', $today_list) . $today_all;
+ } else {
+ $today_list = $lang['NOBIRTHDAY_TODAY'];
+ }
- $template->assign_vars(array(
- 'WHOSBIRTHDAY_WEEK' => $week_list,
- 'WHOSBIRTHDAY_TODAY' => $today_list,
- ));
+ $template->assign_vars(array(
+ 'WHOSBIRTHDAY_WEEK' => $week_list,
+ 'WHOSBIRTHDAY_TODAY' => $today_list,
+ ));
}
// Allow cron
-if (IS_AM)
-{
- if (file_exists(CRON_RUNNING))
- {
- if (file_exists(CRON_ALLOWED))
- {
- unlink (CRON_ALLOWED);
- }
- rename(CRON_RUNNING, CRON_ALLOWED);
- }
+if (IS_AM) {
+ if (file_exists(CRON_RUNNING)) {
+ if (file_exists(CRON_ALLOWED)) {
+ unlink(CRON_ALLOWED);
+ }
+ rename(CRON_RUNNING, CRON_ALLOWED);
+ }
}
// 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');
\ No newline at end of file
+print_page('index.tpl');
diff --git a/info.php b/info.php
index 500596c8d..b2cddacf2 100644
--- a/info.php
+++ b/info.php
@@ -1,8 +1,31 @@
session_start();
@@ -11,32 +34,31 @@ global $lang;
$info = array();
$html_dir = LANG_DIR . 'html/';
-$req_mode = !empty($_REQUEST['show']) ? (string) $_REQUEST['show'] : 'not_found';
+$req_mode = !empty($_REQUEST['show']) ? (string)$_REQUEST['show'] : 'not_found';
-switch ($req_mode)
-{
- case 'advert':
- $info['title'] = $lang['ADVERT'];
- $info['src'] = 'advert.html';
- break;
+switch ($req_mode) {
+ case 'advert':
+ $info['title'] = $lang['ADVERT'];
+ $info['src'] = 'advert.html';
+ break;
- case 'copyright_holders':
- $info['title'] = $lang['COPYRIGHT_HOLDERS'];
- $info['src'] = 'copyright_holders.html';
- break;
+ case 'copyright_holders':
+ $info['title'] = $lang['COPYRIGHT_HOLDERS'];
+ $info['src'] = 'copyright_holders.html';
+ break;
- case 'not_found':
- $info['title'] = $lang['NOT_FOUND'];
- $info['src'] = 'not_found.html';
- break;
+ case 'not_found':
+ $info['title'] = $lang['NOT_FOUND'];
+ $info['src'] = 'not_found.html';
+ break;
- case 'user_agreement':
- $info['title'] = $lang['USER_AGREEMENT'];
- $info['src'] = 'user_agreement.html';
- break;
+ case 'user_agreement':
+ $info['title'] = $lang['USER_AGREEMENT'];
+ $info['src'] = 'user_agreement.html';
+ break;
- default:
- bb_simple_die('Invalid request');
+ default:
+ bb_simple_die('Invalid request');
}
$require = file_exists($html_dir . $info['src']) ? $html_dir . $info['src'] : $html_dir . 'not_found.html';
@@ -44,28 +66,40 @@ $require = file_exists($html_dir . $info['src']) ? $html_dir . $info['src'] : $h
?>
-
-
-
+
+
+
-
+
-
-
-
-
-
-
-
[ ]
+
+
+
+
+
+
+
[ ]
+
\ No newline at end of file
diff --git a/install/other/converter/TBDevYSE_pre6/for_tbdev/announce.php b/install/other/converter/TBDevYSE_pre6/for_tbdev/announce.php
index f419ab6d9..ac21cfafb 100644
--- a/install/other/converter/TBDevYSE_pre6/for_tbdev/announce.php
+++ b/install/other/converter/TBDevYSE_pre6/for_tbdev/announce.php
@@ -1,34 +1,55 @@
-
';
-}
-else
-{
- if (!file_exists('passwords.php')) stderr($tracker_lang['error'], 'passwords.php not exists');
+} else {
+ if (!file_exists('passwords.php')) {
+ stderr($tracker_lang['error'], 'passwords.php not exists');
+ }
- include('passwords.php');
- stdhead();
- foreach ($passwords as $user)
- {
- $msg_sql = sprintf($msg, $user['username'], $user['new_passwd']);
- sql_query("INSERT INTO messages (receiver, added, subject, msg) VALUES({$user['tb_user_id']}, NOW(), ".sqlesc($subject).", ".sqlesc($msg_sql).")");
- }
- stdmsg('OK', 'Mass PM succesful');
+ include('passwords.php');
+ stdhead();
+ foreach ($passwords as $user) {
+ $msg_sql = sprintf($msg, $user['username'], $user['new_passwd']);
+ sql_query("INSERT INTO messages (receiver, added, subject, msg) VALUES({$user['tb_user_id']}, NOW(), " . sqlesc($subject) . ", " . sqlesc($msg_sql) . ")");
+ }
+ stdmsg('OK', 'Mass PM succesful');
}
-stdfoot();
\ No newline at end of file
+stdfoot();
diff --git a/install/other/converter/TBDevYSE_pre6/root/convert.php b/install/other/converter/TBDevYSE_pre6/root/convert.php
index 48192b3a2..091fa1ac4 100644
--- a/install/other/converter/TBDevYSE_pre6/root/convert.php
+++ b/install/other/converter/TBDevYSE_pre6/root/convert.php
@@ -1,8 +1,31 @@
session_start();
-if (!IS_ADMIN) die("Restricted access");
-while (@ob_end_flush());
+if (!IS_ADMIN) {
+ die("Restricted access");
+}
+while (@ob_end_flush()) ;
ob_implicit_flush();
error_reporting(E_ALL);
@ini_set('display_errors', 1);
?>
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
';
- exit;
-}
-else
-{
-
-@ini_set('memory_limit', '512M');
-@ini_set('max_execution_time', @ini_get('max_execution_time') + 1200);
+ exit;
+} else {
+ @ini_set('memory_limit', '512M');
+ @ini_set('max_execution_time', @ini_get('max_execution_time') + 1200);
// Step 1: Converting Users
-if (CONVERT_USERS)
-{
- if (CLEAN)
- {
- tp_users_cleanup();
- print_ok ("Users cleared");
- }
+ if (CONVERT_USERS) {
+ if (CLEAN) {
+ tp_users_cleanup();
+ print_ok("Users cleared");
+ }
- $max_uid = (int) get_max_val(BB_USERS, 'user_id');
- $max_uid = ($max_uid > 1) ? $max_uid : 1;
+ $max_uid = (int)get_max_val(BB_USERS, 'user_id');
+ $max_uid = ($max_uid > 1) ? $max_uid : 1;
- $users_count = (int) get_count(TB_USERS_TABLE, 'id');
- $loops = (int) ceil($users_count / C_USERS_PER_ONCE);
- $pass = array();
+ $users_count = (int)get_count(TB_USERS_TABLE, 'id');
+ $loops = (int)ceil($users_count / C_USERS_PER_ONCE);
+ $pass = array();
- switch(TR_TYPE)
- {
- case 'yse':
- $_sql = 'avatar, ';
- break;
+ switch (TR_TYPE) {
+ case 'yse':
+ $_sql = 'avatar, ';
+ break;
- default:
- $_sql = '';
- break;
- }
+ default:
+ $_sql = '';
+ break;
+ }
- for ($i = 0; $i < $loops; $i++)
- {
- $start = $i * C_USERS_PER_ONCE;
- $offset = C_USERS_PER_ONCE;
+ for ($i = 0; $i < $loops; $i++) {
+ $start = $i * C_USERS_PER_ONCE;
+ $offset = C_USERS_PER_ONCE;
- $sql = "
+ $sql = "
SELECT
id, username, email, status, UNIX_TIMESTAMP(added) AS added, UNIX_TIMESTAMP(last_access) AS last_access,
class, icq, msn, aim, yahoo, website, $_sql
uploaded, downloaded, enabled, language
- FROM ". TB_USERS_TABLE ."
+ FROM " . TB_USERS_TABLE . "
ORDER BY id
LIMIT $start, $offset";
- $users = DB()->fetch_rowset($sql);
- DB()->sql_freeresult();
+ $users = DB()->fetch_rowset($sql);
+ DB()->sql_freeresult();
- foreach ($users as $user)
- {
- $user['id'] += $max_uid;
- $user['password'] = make_rand_str(15);
- convert_user($user);
- $pass[] = array(
- 'tb_user_id' => $user['id'] - $max_uid,
- 'username' => $user['username'],
- 'new_passwd' => $user['password'],
- );
- }
- }
- $passf = fopen('./converter/passwords.php', 'w');
- $to_write = " $user['id'] - $max_uid,
+ 'username' => $user['username'],
+ 'new_passwd' => $user['password'],
+ );
+ }
+ }
+ $passf = fopen('./converter/passwords.php', 'w');
+ $to_write = " $tr_cat_id,
- "cat_title" => 'Tracker',
- );
- tp_add_category($tp_cat_data);
- set_auto_increment(BB_CATEGORIES, 'cat_id');
- unset($tp_cat_data);
+ $tp_cat_data = array(
+ "cat_id" => $tr_cat_id,
+ "cat_title" => 'Tracker',
+ );
+ tp_add_category($tp_cat_data);
+ set_auto_increment(BB_CATEGORIES, 'cat_id');
+ unset($tp_cat_data);
- $cats = $db->fetch_rowset("SELECT id, sort, name FROM ". TB_CATEGORIES_TABLE);
- DB()->sql_freeresult();
+ $cats = $db->fetch_rowset("SELECT id, sort, name FROM " . TB_CATEGORIES_TABLE);
+ DB()->sql_freeresult();
- $max_forum_id = (int) get_max_val(BB_FORUMS, 'forum_id');
+ $max_forum_id = (int)get_max_val(BB_FORUMS, 'forum_id');
- foreach ($cats as $cat)
- {
- $cat['id'] += $max_forum_id;
- $cat['cat_id'] = $tr_cat_id;
- convert_cat($cat);
- }
- set_auto_increment(BB_FORUMS, 'forum_id');
- print_ok ("Categories from TBDev converted");
- unset($cats);
+ foreach ($cats as $cat) {
+ $cat['id'] += $max_forum_id;
+ $cat['cat_id'] = $tr_cat_id;
+ convert_cat($cat);
+ }
+ set_auto_increment(BB_FORUMS, 'forum_id');
+ print_ok("Categories from TBDev converted");
+ unset($cats);
- // Start of torrents converting
- switch(TR_TYPE)
- {
- case 'yse':
- $_sql = 'image1, image2, ';
- break;
+ // Start of torrents converting
+ switch (TR_TYPE) {
+ case 'yse':
+ $_sql = 'image1, image2, ';
+ break;
- case 'sky':
- $_sql = 'poster, screenshot1, screenshot2, screenshot3, screenshot4, ';
- break;
+ case 'sky':
+ $_sql = 'poster, screenshot1, screenshot2, screenshot3, screenshot4, ';
+ break;
- default:
- $_sql = '';
- break;
- }
+ default:
+ $_sql = '';
+ break;
+ }
- $max_topic_id = (int) get_max_val(BB_TOPICS, 'topic_id');
- $max_post_id = (int) get_max_val(BB_POSTS, 'post_id');
- $max_attach_id = (int) get_max_val(BB_ATTACHMENTS, 'attach_id');
+ $max_topic_id = (int)get_max_val(BB_TOPICS, 'topic_id');
+ $max_post_id = (int)get_max_val(BB_POSTS, 'post_id');
+ $max_attach_id = (int)get_max_val(BB_ATTACHMENTS, 'attach_id');
- $torrents_count = (int) get_count(TB_TORRENTS_TABLE, 'id');
- $loops = (int) ceil($torrents_count / C_TORRENTS_PER_ONCE);
+ $torrents_count = (int)get_count(TB_TORRENTS_TABLE, 'id');
+ $loops = (int)ceil($torrents_count / C_TORRENTS_PER_ONCE);
- for ($i = 0; $i < $loops; $i++)
- {
- $start = $i * C_TORRENTS_PER_ONCE;
- $offset = C_TORRENTS_PER_ONCE;
- $sql = "
+ for ($i = 0; $i < $loops; $i++) {
+ $start = $i * C_TORRENTS_PER_ONCE;
+ $offset = C_TORRENTS_PER_ONCE;
+ $sql = "
SELECT
id, info_hash, name, filename, search_text, descr, $_sql
category, UNIX_TIMESTAMP(added) AS added, size, views,
UNIX_TIMESTAMP(last_action) AS lastseed, times_completed, owner, sticky
- FROM ". TB_TORRENTS_TABLE ."
+ FROM " . TB_TORRENTS_TABLE . "
ORDER BY id
LIMIT $start, $offset";
- $torrents = DB()->fetch_rowset($sql);
- DB()->sql_freeresult();
+ $torrents = DB()->fetch_rowset($sql);
+ DB()->sql_freeresult();
- foreach ($torrents as $torrent)
- {
- $torrent['topic_id'] = $torrent['id'] + $max_topic_id;
- $torrent['post_id'] = $torrent['id'] + $max_post_id;
- $torrent['attach_id'] = $torrent['id'] + $max_attach_id;
- $torrent['owner'] += $max_uid;
- $torrent['descr'] = append_images($torrent);
- convert_torrent($torrent);
- //print_r($torrent);
- }
- }
- set_auto_increment(BB_TOPICS, 'topic_id');
- set_auto_increment(BB_POSTS, 'post_id');
- print_ok ("Total $torrents_count torrents from TBDev converted");
- unset($torrents);
+ foreach ($torrents as $torrent) {
+ $torrent['topic_id'] = $torrent['id'] + $max_topic_id;
+ $torrent['post_id'] = $torrent['id'] + $max_post_id;
+ $torrent['attach_id'] = $torrent['id'] + $max_attach_id;
+ $torrent['owner'] += $max_uid;
+ $torrent['descr'] = append_images($torrent);
+ convert_torrent($torrent);
+ //print_r($torrent);
+ }
+ }
+ set_auto_increment(BB_TOPICS, 'topic_id');
+ set_auto_increment(BB_POSTS, 'post_id');
+ print_ok("Total $torrents_count torrents from TBDev converted");
+ unset($torrents);
- if (CONVERT_COMMENTS)
- {
- $max_post_id = (int) get_max_val(BB_POSTS, 'post_id');
- $max_topic_id = (int) get_max_val(BB_TOPICS, 'topic_id');
- $max_attach_id = (int) get_max_val(BB_ATTACHMENTS, 'attach_id');
+ if (CONVERT_COMMENTS) {
+ $max_post_id = (int)get_max_val(BB_POSTS, 'post_id');
+ $max_topic_id = (int)get_max_val(BB_TOPICS, 'topic_id');
+ $max_attach_id = (int)get_max_val(BB_ATTACHMENTS, 'attach_id');
- $comments_count = (int) get_count(TB_COMMENTS_TABLE, 'id');
- $loops = (int) ceil($comments_count / C_COMMENTS_PER_ONCE);
+ $comments_count = (int)get_count(TB_COMMENTS_TABLE, 'id');
+ $loops = (int)ceil($comments_count / C_COMMENTS_PER_ONCE);
- for ($i = 0; $i < $loops; $i++)
- {
- $start = $i * C_COMMENTS_PER_ONCE;
- $offset = C_COMMENTS_PER_ONCE;
- $sql = "
+ for ($i = 0; $i < $loops; $i++) {
+ $start = $i * C_COMMENTS_PER_ONCE;
+ $offset = C_COMMENTS_PER_ONCE;
+ $sql = "
SELECT
c.id, c.user, c.torrent, c.text, tor.category,
UNIX_TIMESTAMP(c.added) AS added, UNIX_TIMESTAMP(c.editedat) AS editedat, c.ip
- FROM ". TB_COMMENTS_TABLE ." c
- LEFT JOIN ". TB_TORRENTS_TABLE ." tor ON(tor.id = c.torrent)
+ FROM " . TB_COMMENTS_TABLE . " c
+ LEFT JOIN " . TB_TORRENTS_TABLE . " tor ON(tor.id = c.torrent)
WHERE c.torrent <> 0
ORDER BY c.id
LIMIT $start, $offset";
- $comments = DB()->fetch_rowset($sql);
- DB()->sql_freeresult();
+ $comments = DB()->fetch_rowset($sql);
+ DB()->sql_freeresult();
- foreach ($comments as $comment)
- {
- $comment['user'] += $max_uid;
- $comment['id'] += $max_post_id;
- convert_comment($comment);
- }
- }
- unset($comments);
- set_auto_increment(BB_POSTS, 'post_id');
- print_ok ("Total $comments_count comments from TBDev converted");
- }
-}
+ foreach ($comments as $comment) {
+ $comment['user'] += $max_uid;
+ $comment['id'] += $max_post_id;
+ convert_comment($comment);
+ }
+ }
+ unset($comments);
+ set_auto_increment(BB_POSTS, 'post_id');
+ print_ok("Total $comments_count comments from TBDev converted");
+ }
+ }
-?>
-
-
-Converting completed.
-
-
-
\ No newline at end of file
+ ?>
+
+
+ Converting completed.
+