Merge pull request #229 from diolektor/enhancement-code

Static code analyzer cherry picked from #228
This commit is contained in:
Yuriy Pikhtarev 2017-05-09 20:10:30 +03:00 committed by GitHub
commit 0aae80ba8e
169 changed files with 770 additions and 787 deletions

View file

@ -333,7 +333,7 @@ if ($view === 'attachments') {
// Are we called from Username ?
if ($user_based) {
$sql = "SELECT username FROM " . BB_USERS . " WHERE user_id = " . intval($uid);
$sql = "SELECT username FROM " . BB_USERS . " WHERE user_id = " . (int)$uid;
if (!($result = DB()->sql_query($sql))) {
bb_die('Error getting username');
@ -343,7 +343,7 @@ if ($view === 'attachments') {
DB()->sql_freeresult($result);
$username = $row['username'];
$s_hidden = '<input type="hidden" name="u_id" value="' . intval($uid) . '" />';
$s_hidden = '<input type="hidden" name="u_id" value="' . (int)$uid . '" />';
$template->assign_block_vars('switch_user_based', array());
@ -354,7 +354,7 @@ if ($view === 'attachments') {
$sql = "SELECT attach_id
FROM " . BB_ATTACHMENTS . "
WHERE user_id_1 = " . intval($uid) . "
WHERE user_id_1 = " . (int)$uid . "
GROUP BY attach_id";
if (!($result = DB()->sql_query($sql))) {
@ -374,7 +374,7 @@ if ($view === 'attachments') {
$attach_id = array();
for ($j = 0; $j < $num_attach_ids; $j++) {
$attach_id[] = intval($attach_ids[$j]['attach_id']);
$attach_id[] = (int)$attach_ids[$j]['attach_id'];
}
$sql = "SELECT a.*
@ -394,13 +394,13 @@ if ($view === 'attachments') {
$attachments = search_attachments($order_by, $total_rows);
}
if (sizeof($attachments) > 0) {
if (count($attachments) > 0) {
for ($i = 0, $iMax = count($attachments); $i < $iMax; $i++) {
$delete_box = '<input type="checkbox" name="delete_id_list[]" value="' . intval($attachments[$i]['attach_id']) . '" />';
$delete_box = '<input type="checkbox" name="delete_id_list[]" value="' . (int)$attachments[$i]['attach_id'] . '" />';
for ($j = 0, $iMax = count($delete_id_list); $j < $iMax; $j++) {
if ($delete_id_list[$j] == $attachments[$i]['attach_id']) {
$delete_box = '<input type="checkbox" name="delete_id_list[]" value="' . intval($attachments[$i]['attach_id']) . '" checked="checked" />';
$delete_box = '<input type="checkbox" name="delete_id_list[]" value="' . (int)$attachments[$i]['attach_id'] . '" checked="checked" />';
break;
}
}
@ -413,7 +413,7 @@ if ($view === 'attachments') {
$sql = "SELECT *
FROM " . BB_ATTACHMENTS . "
WHERE attach_id = " . intval($attachments[$i]['attach_id']);
WHERE attach_id = " . (int)$attachments[$i]['attach_id'];
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query attachments #3');
@ -427,7 +427,7 @@ if ($view === 'attachments') {
if ($ids[$j]['post_id'] != 0) {
$sql = "SELECT t.topic_title
FROM " . BB_TOPICS . " t, " . BB_POSTS . " p
WHERE p.post_id = " . intval($ids[$j]['post_id']) . " AND p.topic_id = t.topic_id
WHERE p.post_id = " . (int)$ids[$j]['post_id'] . " AND p.topic_id = t.topic_id
GROUP BY t.topic_id, t.topic_title";
if (!($result = DB()->sql_query($sql))) {
@ -452,7 +452,7 @@ if ($view === 'attachments') {
$post_titles = implode('<br />', $post_titles);
$hidden_field = '<input type="hidden" name="attach_id_list[]" value="' . intval($attachments[$i]['attach_id']) . '" />';
$hidden_field = '<input type="hidden" name="attach_id_list[]" value="' . (int)$attachments[$i]['attach_id'] . '" />';
$template->assign_block_vars('attachrow', array(
'ROW_NUMBER' => $i + (@$_GET['start'] + 1),

View file

@ -30,7 +30,7 @@ if (!empty($setmodules)) {
$module['ATTACHMENTS']['QUOTA_LIMITS'] = $filename . '?mode=quota';
return;
}
require('./pagestart.php');
require __DIR__ . '/pagestart.php';
$error = false;
@ -220,7 +220,7 @@ if ($check_upload) {
}
if (!$error) {
if (!($fp = @fopen($upload_dir . '/0_000000.000', 'w'))) {
if (!($fp = @fopen($upload_dir . '/0_000000.000', 'wb'))) {
$error = true;
$error_msg = sprintf($lang['DIRECTORY_NOT_WRITEABLE'], $attach_config['upload_dir']) . '<br />';
} else {
@ -248,8 +248,8 @@ if ($mode == 'manage') {
'S_FILESIZE' => $select_size_mode,
'S_FILESIZE_QUOTA' => $select_quota_size_mode,
'S_FILESIZE_PM' => $select_pm_size_mode,
'S_DEFAULT_UPLOAD_LIMIT' => default_quota_limit_select('default_upload_quota', intval(trim($new_attach['default_upload_quota']))),
'S_DEFAULT_PM_LIMIT' => default_quota_limit_select('default_pm_quota', intval(trim($new_attach['default_pm_quota']))),
'S_DEFAULT_UPLOAD_LIMIT' => default_quota_limit_select('default_upload_quota', (int)trim($new_attach['default_upload_quota'])),
'S_DEFAULT_PM_LIMIT' => default_quota_limit_select('default_pm_quota', (int)trim($new_attach['default_pm_quota'])),
'UPLOAD_DIR' => $new_attach['upload_dir'],
'ATTACHMENT_IMG_PATH' => $new_attach['upload_img'],
@ -288,7 +288,7 @@ if ($mode == 'cats') {
$row = DB()->sql_fetchrowset($result);
DB()->sql_freeresult($result);
for ($i = 0; $i < sizeof($row); $i++) {
for ($i = 0, $iMax = count($row); $i < $iMax; $i++) {
if ($row[$i]['cat_id'] == IMAGE_CAT) {
$s_assigned_group_images[] = $row[$i]['group_name'];
}
@ -375,7 +375,7 @@ if ($check_image_cat) {
}
if (!$error) {
if (!($fp = @fopen($upload_dir . '/0_000000.000', 'w'))) {
if (!($fp = @fopen($upload_dir . '/0_000000.000', 'wb'))) {
$error = true;
$error_msg = sprintf($lang['DIRECTORY_NOT_WRITEABLE'], $upload_dir) . '<br />';
} else {
@ -399,7 +399,7 @@ if ($submit && $mode == 'quota') {
$allowed_list = array();
for ($i = 0; $i < sizeof($quota_change_list); $i++) {
for ($i = 0, $iMax = count($quota_change_list); $i < $iMax; $i++) {
$filesize_list[$i] = ($size_select_list[$i] == 'kb') ? round($filesize_list[$i] * 1024) : (($size_select_list[$i] == 'mb') ? round($filesize_list[$i] * 1048576) : $filesize_list[$i]);
$sql = 'UPDATE ' . BB_QUOTA_LIMITS . "
@ -504,7 +504,7 @@ if ($mode == 'quota') {
$rows = DB()->sql_fetchrowset($result);
DB()->sql_freeresult($result);
for ($i = 0; $i < sizeof($rows); $i++) {
for ($i = 0, $iMax = count($rows); $i < $iMax; $i++) {
$size_format = ($rows[$i]['quota_limit'] >= 1048576) ? 'mb' : (($rows[$i]['quota_limit'] >= 1024) ? 'kb' : 'b');
if ($rows[$i]['quota_limit'] >= 1048576) {

View file

@ -54,7 +54,7 @@ if (isset($_POST['add_name'])) {
bb_die($message);
} elseif (isset($_POST['delete_name'])) {
$disallowed_id = (isset($_POST['disallowed_id'])) ? intval($_POST['disallowed_id']) : intval($_GET['disallowed_id']);
$disallowed_id = (isset($_POST['disallowed_id'])) ? (int)$_POST['disallowed_id'] : (int)$_GET['disallowed_id'];
$sql = "DELETE FROM " . BB_DISALLOW . " WHERE disallow_id = $disallowed_id";
$result = DB()->sql_query($sql);
@ -87,7 +87,7 @@ $disallow_select = '<select name="disallowed_id">';
if (count($disallowed) <= 0) {
$disallow_select .= '<option value="">' . $lang['NO_DISALLOWED'] . '</option>';
} else {
for ($i = 0; $i < count($disallowed); $i++) {
for ($i = 0, $iMax = count($disallowed); $i < $iMax; $i++) {
$disallow_select .= '<option value="' . $disallowed[$i]['disallow_id'] . '">' . $disallowed[$i]['disallow_username'] . '</option>';
}
}

View file

@ -29,7 +29,8 @@ if (!empty($setmodules)) {
$module['ATTACHMENTS']['EXTENSION_GROUP_MANAGE'] = $filename . '?mode=groups';
return;
}
require('./pagestart.php');
require __DIR__ . '/pagestart.php';
function update_attach_extensions()
{
@ -83,9 +84,9 @@ if ($submit && $mode == 'extensions') {
// Generate correct Change List
$extensions = array();
for ($i = 0; $i < sizeof($extension_change_list); $i++) {
for ($i = 0, $iMax = count($extension_change_list); $i < $iMax; $i++) {
$extensions['_' . $extension_change_list[$i]]['comment'] = $extension_explain_list[$i];
$extensions['_' . $extension_change_list[$i]]['group_id'] = intval($group_select_list[$i]);
$extensions['_' . $extension_change_list[$i]]['group_id'] = (int)$group_select_list[$i];
}
$sql = 'SELECT * FROM ' . BB_EXTENSIONS . ' ORDER BY ext_id';
@ -98,8 +99,8 @@ if ($submit && $mode == 'extensions') {
DB()->sql_freeresult($result);
if ($num_rows > 0) {
for ($i = 0; $i < sizeof($extension_row); $i++) {
if ($extension_row[$i]['comment'] != $extensions['_' . $extension_row[$i]['ext_id']]['comment'] || intval($extension_row[$i]['group_id']) != intval($extensions['_' . $extension_row[$i]['ext_id']]['group_id'])) {
for ($i = 0, $iMax = count($extension_row); $i < $iMax; $i++) {
if ($extension_row[$i]['comment'] != $extensions['_' . $extension_row[$i]['ext_id']]['comment'] || (int)$extension_row[$i]['group_id'] != (int)$extensions['_' . $extension_row[$i]['ext_id']]['group_id']) {
$sql_ary = array(
'comment' => (string)$extensions['_' . $extension_row[$i]['ext_id']]['comment'],
'group_id' => (int)$extensions['_' . $extension_row[$i]['ext_id']]['group_id']
@ -250,15 +251,15 @@ if ($submit && $mode == 'groups') {
$allowed_list = array();
for ($i = 0; $i < sizeof($group_allowed_list); $i++) {
for ($j = 0; $j < sizeof($group_change_list); $j++) {
for ($i = 0, $iMax = count($group_allowed_list); $i < $iMax; $i++) {
for ($j = 0, $jMax = count($group_change_list); $j < $iMax; $j++) {
if ($group_allowed_list[$i] == $group_change_list[$j]) {
$allowed_list[$j] = 1;
}
}
}
for ($i = 0; $i < sizeof($group_change_list); $i++) {
for ($i = 0, $iMax = count($group_change_list); $i < $iMax; $i++) {
$allowed = (isset($allowed_list[$i])) ? 1 : 0;
$filesize_list[$i] = ($size_select_list[$i] == 'kb') ? round($filesize_list[$i] * 1024) : (($size_select_list[$i] == 'mb') ? round($filesize_list[$i] * 1048576) : $filesize_list[$i]);
@ -471,7 +472,7 @@ if (@$add_forum && $e_mode == 'perm' && $group) {
$add_forums_list = get_var('entries', array(0));
$add_all_forums = false;
for ($i = 0; $i < sizeof($add_forums_list); $i++) {
for ($i = 0, $iMax = count($add_forums_list); $i < $iMax; $i++) {
if ($add_forums_list[$i] == 0) {
$add_all_forums = true;
}
@ -489,7 +490,7 @@ if (@$add_forum && $e_mode == 'perm' && $group) {
if (!$add_all_forums) {
$sql = 'SELECT forum_permissions
FROM ' . BB_EXTENSION_GROUPS . '
WHERE group_id = ' . intval($group) . '
WHERE group_id = ' . (int)$group . '
LIMIT 1';
if (!($result = DB()->sql_query($sql))) {
@ -506,7 +507,7 @@ if (@$add_forum && $e_mode == 'perm' && $group) {
}
// Generate array for Auth_Pack, do not add doubled forums
for ($i = 0; $i < sizeof($add_forums_list); $i++) {
for ($i = 0, $iMax = count($add_forums_list); $i < $iMax; $i++) {
if (!in_array($add_forums_list[$i], $auth_p)) {
$auth_p[] = $add_forums_list[$i];
}
@ -529,7 +530,7 @@ if (@$delete_forum && $e_mode == 'perm' && $group) {
// Get the current Forums
$sql = 'SELECT forum_permissions
FROM ' . BB_EXTENSION_GROUPS . '
WHERE group_id = ' . intval($group) . '
WHERE group_id = ' . (int)$group . '
LIMIT 1';
if (!($result = DB()->sql_query($sql))) {
@ -543,13 +544,13 @@ if (@$delete_forum && $e_mode == 'perm' && $group) {
$auth_p = array();
// Generate array for Auth_Pack, delete the chosen ones
for ($i = 0; $i < sizeof($auth_p2); $i++) {
for ($i = 0, $iMax = count($auth_p2); $i < $iMax; $i++) {
if (!in_array($auth_p2[$i], $delete_forums_list)) {
$auth_p[] = $auth_p2[$i];
}
}
$auth_bitstream = (sizeof($auth_p) > 0) ? auth_pack($auth_p) : '';
$auth_bitstream = (count($auth_p) > 0) ? auth_pack($auth_p) : '';
$sql = 'UPDATE ' . BB_EXTENSION_GROUPS . " SET forum_permissions = '" . attach_mod_sql_escape($auth_bitstream) . "' WHERE group_id = " . (int)$group;
@ -562,7 +563,7 @@ if (@$delete_forum && $e_mode == 'perm' && $group) {
if ($e_mode == 'perm' && $group) {
$sql = 'SELECT group_name, forum_permissions
FROM ' . BB_EXTENSION_GROUPS . '
WHERE group_id = ' . intval($group) . '
WHERE group_id = ' . (int)$group . '
LIMIT 1';
if (!($result = DB()->sql_query($sql))) {
@ -596,7 +597,7 @@ if ($e_mode == 'perm' && $group) {
}
}
for ($i = 0; $i < sizeof($forum_perm); $i++) {
for ($i = 0, $iMax = count($forum_perm); $i < $iMax; $i++) {
$template->assign_block_vars('allow_option_values', array(
'VALUE' => $forum_perm[$i]['forum_id'],
'OPTION' => htmlCHR($forum_perm[$i]['forum_name']))
@ -618,7 +619,7 @@ if ($e_mode == 'perm' && $group) {
}
while ($row = DB()->sql_fetchrow($result)) {
$forum_option_values[intval($row['forum_id'])] = $row['forum_name'];
$forum_option_values[(int)$row['forum_id']] = $row['forum_name'];
}
DB()->sql_freeresult($result);
@ -675,7 +676,7 @@ if ($e_mode == 'perm' && $group) {
$message .= ($message == '') ? $forum_name : '<br />' . $forum_name;
}
if (sizeof($empty_perm_forums) > 0) {
if (count($empty_perm_forums) > 0) {
$template->assign_vars(array('ERROR_MESSAGE' => $lang['NOTE_ADMIN_EMPTY_GROUP_PERMISSIONS'] . $message));
}
}

View file

@ -27,7 +27,8 @@ if (!empty($setmodules)) {
$module['FORUMS']['PRUNE'] = basename(__FILE__);
return;
}
require('./pagestart.php');
require __DIR__ . '/pagestart.php';
$all_forums = -1;
$pruned_total = 0;
@ -37,12 +38,12 @@ if (isset($_REQUEST['submit'])) {
if (!$var =& $_REQUEST['f'] or !$f_selected = get_id_ary($var)) {
bb_die('Forum not selected');
}
if (!$var =& $_REQUEST['prunedays'] or !$prunedays = abs(intval($var))) {
if (!$var =& $_REQUEST['prunedays'] or !$prunedays = abs((int)$var)) {
bb_die($lang['NOT_DAYS']);
}
$prunetime = TIMENOW - 86400 * $prunedays;
$forum_csv = in_array($all_forums, $f_selected) ? $all_forums : join(',', $f_selected);
$forum_csv = in_array($all_forums, $f_selected) ? $all_forums : implode(',', $f_selected);
$where_sql = ($forum_csv != $all_forums) ? "WHERE forum_id IN($forum_csv)" : '';

View file

@ -27,7 +27,8 @@ if (!empty($setmodules)) {
$module['FORUMS']['PERMISSIONS'] = basename(__FILE__);
return;
}
require('./pagestart.php');
require __DIR__ . '/pagestart.php';
$forum_auth_fields = array(
'auth_view',
@ -89,7 +90,7 @@ if (@$_REQUEST[POST_FORUM_URL]) {
}
if (isset($_GET['adv'])) {
$adv = intval($_GET['adv']);
$adv = (int)$_GET['adv'];
} else {
unset($adv);
}
@ -102,9 +103,9 @@ if (isset($_POST['submit'])) {
if (!empty($forum_id)) {
if (isset($_POST['simpleauth'])) {
$simple_ary = $simple_auth_ary[intval($_POST['simpleauth'])];
$simple_ary = $simple_auth_ary[(int)$_POST['simpleauth']];
for ($i = 0; $i < count($simple_ary); $i++) {
for ($i = 0, $iMax = count($simple_ary); $i < $iMax; $i++) {
$sql .= (($sql != '') ? ', ' : '') . $forum_auth_fields[$i] . ' = ' . $simple_ary[$i];
}
@ -112,8 +113,8 @@ if (isset($_POST['submit'])) {
$sql = "UPDATE " . BB_FORUMS . " SET $sql WHERE forum_id = $forum_id";
}
} else {
for ($i = 0; $i < count($forum_auth_fields); $i++) {
$value = intval($_POST[$forum_auth_fields[$i]]);
for ($i = 0, $iMax = count($forum_auth_fields); $i < $iMax; $i++) {
$value = (int)$_POST[$forum_auth_fields[$i]];
if ($forum_auth_fields[$i] == 'auth_vote') {
if ($_POST['auth_vote'] == AUTH_ALL) {
@ -162,7 +163,7 @@ if (empty($forum_id)) {
@reset($simple_auth_ary);
while (list($key, $auth_levels) = each($simple_auth_ary)) {
$matched = 1;
for ($k = 0; $k < count($auth_levels); $k++) {
for ($k = 0, $kMax = count($auth_levels); $k < $iMax; $k++) {
$matched_type = $key;
if ($forum_rows[0][$forum_auth_fields[$k]] != $auth_levels[$k]) {
@ -188,7 +189,7 @@ if (empty($forum_id)) {
if (empty($adv)) {
$simple_auth = '<select name="simpleauth">';
for ($j = 0; $j < count($simple_auth_types); $j++) {
for ($j = 0, $jMax = count($simple_auth_types); $j < $iMax; $j++) {
$selected = ($matched_type == $j) ? ' selected="selected"' : '';
$simple_auth .= '<option value="' . $j . '"' . $selected . '>' . $simple_auth_types[$j] . '</option>';
}
@ -206,10 +207,10 @@ if (empty($forum_id)) {
// Output values of individual
// fields
//
for ($j = 0; $j < count($forum_auth_fields); $j++) {
for ($j = 0, $jMax = count($forum_auth_fields); $j < $iMax; $j++) {
$custom_auth[$j] = '&nbsp;<select name="' . $forum_auth_fields[$j] . '">';
for ($k = 0; $k < count($forum_auth_levels); $k++) {
for ($k = 0, $kMax = count($forum_auth_levels); $k < $iMax; $k++) {
$selected = ($forum_rows[0][$forum_auth_fields[$j]] == $forum_auth_const[$k]) ? ' selected="selected"' : '';
$custom_auth[$j] .= '<option value="' . $forum_auth_const[$k] . '"' . $selected . '>' . $lang['FORUM_' . strtoupper($forum_auth_levels[$k])] . '</OPTION>';
}

View file

@ -27,7 +27,8 @@ if (!empty($setmodules)) {
$module['FORUMS']['PERMISSIONS_LIST'] = basename(__FILE__);
return;
}
require('./pagestart.php');
require __DIR__ . '/pagestart.php';
// View Read Post Reply Edit Delete Sticky Announce Vote Poll PostAttach Download
$simple_auth_ary = array(
@ -81,7 +82,7 @@ $forum_auth_levels = array('ALL', 'REG', 'PRIVATE', 'MOD', 'ADMIN');
$forum_auth_const = array(AUTH_ALL, AUTH_REG, AUTH_ACL, AUTH_MOD, AUTH_ADMIN);
if (isset($_GET[POST_FORUM_URL]) || isset($_POST[POST_FORUM_URL])) {
$forum_id = (isset($_POST[POST_FORUM_URL])) ? intval($_POST[POST_FORUM_URL]) : intval($_GET[POST_FORUM_URL]);
$forum_id = (isset($_POST[POST_FORUM_URL])) ? (int)$_POST[POST_FORUM_URL] : (int)$_GET[POST_FORUM_URL];
$forum_sql = "AND forum_id = $forum_id";
} else {
unset($forum_id);
@ -89,7 +90,7 @@ if (isset($_GET[POST_FORUM_URL]) || isset($_POST[POST_FORUM_URL])) {
}
if (isset($_GET[POST_CAT_URL]) || isset($_POST[POST_CAT_URL])) {
$cat_id = (isset($_POST[POST_CAT_URL])) ? intval($_POST[POST_CAT_URL]) : intval($_GET[POST_CAT_URL]);
$cat_id = (isset($_POST[POST_CAT_URL])) ? (int)$_POST[POST_CAT_URL] : (int)$_GET[POST_CAT_URL];
$cat_sql = "AND c.cat_id = $cat_id";
} else {
unset($cat_id);
@ -97,7 +98,7 @@ if (isset($_GET[POST_CAT_URL]) || isset($_POST[POST_CAT_URL])) {
}
if (isset($_GET['adv'])) {
$adv = intval($_GET['adv']);
$adv = (int)$_GET['adv'];
} else {
unset($adv);
}
@ -110,9 +111,9 @@ if (isset($_POST['submit'])) {
if (!empty($forum_id)) {
if (isset($_POST['simpleauth'])) {
$simple_ary = $simple_auth_ary[intval($_POST['simpleauth'])];
$simple_ary = $simple_auth_ary[(int)$_POST['simpleauth']];
for ($i = 0; $i < count($simple_ary); $i++) {
for ($i = 0, $iMax = count($simple_ary); $i < $iMax; $i++) {
$sql .= (($sql != '') ? ', ' : '') . $forum_auth_fields[$i] . ' = ' . $simple_ary[$i];
}
@ -120,8 +121,8 @@ if (isset($_POST['submit'])) {
$sql = "UPDATE " . BB_FORUMS . " SET $sql WHERE forum_id = $forum_id";
}
} else {
for ($i = 0; $i < count($forum_auth_fields); $i++) {
$value = intval($_POST[$forum_auth_fields[$i]]);
for ($i = 0, $iMax = count($forum_auth_fields); $i < $iMax; $i++) {
$value = (int)$_POST[$forum_auth_fields[$i]];
if ($forum_auth_fields[$i] == 'auth_vote') {
if ($_POST['auth_vote'] == AUTH_ALL) {
@ -144,8 +145,8 @@ if (isset($_POST['submit'])) {
$forum_sql = '';
$adv = 0;
} elseif (!empty($cat_id)) {
for ($i = 0; $i < count($forum_auth_fields); $i++) {
$value = intval($_POST[$forum_auth_fields[$i]]);
for ($i = 0, $iMax = count($forum_auth_fields); $i < $iMax; $i++) {
$value = (int)$_POST[$forum_auth_fields[$i]];
if ($forum_auth_fields[$i] == 'auth_vote') {
if ($_POST['auth_vote'] == AUTH_ALL) {
@ -198,7 +199,7 @@ if (empty($forum_id) && empty($cat_id)) {
'S_COLUMN_SPAN' => count($forum_auth_fields) + 1,
));
for ($i = 0; $i < count($forum_auth_fields); $i++) {
for ($i = 0, $iMax = count($forum_auth_fields); $i < $iMax; $i++) {
$template->assign_block_vars('forum_auth_titles', array(
'CELL_TITLE' => $field_names[$forum_auth_fields[$i]],
));
@ -223,7 +224,7 @@ if (empty($forum_id) && empty($cat_id)) {
'CAT_URL' => 'admin_forumauth_list.php' . '?' . POST_CAT_URL . '=' . $category_rows[$i]['cat_id'])
);
for ($j = 0; $j < count($forum_rows); $j++) {
for ($j = 0, $jMax = count($forum_rows); $j < $iMax; $j++) {
if ($cat_id == $forum_rows[$j]['cat_id']) {
$template->assign_block_vars('cat_row.forum_row', array(
'ROW_CLASS' => !($j % 2) ? 'row4' : 'row5',
@ -231,9 +232,9 @@ if (empty($forum_id) && empty($cat_id)) {
'IS_SUBFORUM' => $forum_rows[$j]['forum_parent'],
));
for ($k = 0; $k < count($forum_auth_fields); $k++) {
for ($k = 0, $kMax = count($forum_auth_fields); $k < $iMax; $k++) {
$item_auth_value = $forum_rows[$j][$forum_auth_fields[$k]];
for ($l = 0; $l < count($forum_auth_const); $l++) {
for ($l = 0, $lMax = count($forum_auth_const); $l < $iMax; $l++) {
if ($item_auth_value == $forum_auth_const[$l]) {
$item_auth_level = $forum_auth_levels[$l];
break;
@ -257,7 +258,7 @@ if (empty($forum_id) && empty($cat_id)) {
// first display the current details for all forums
// in the category
//
for ($i = 0; $i < count($forum_auth_fields); $i++) {
for ($i = 0, $iMax = count($forum_auth_fields); $i < $iMax; $i++) {
$template->assign_block_vars('forum_auth_titles', array(
'CELL_TITLE' => $field_names[$forum_auth_fields[$i]],
));
@ -282,7 +283,7 @@ if (empty($forum_id) && empty($cat_id)) {
'CAT_URL' => 'admin_forumauth_list.php?' . POST_CAT_URL . '=' . $cat_id)
);
for ($j = 0; $j < count($forum_rows); $j++) {
for ($j = 0, $jMax = count($forum_rows); $j < $iMax; $j++) {
if ($cat_id == $forum_rows[$j]['cat_id']) {
$template->assign_block_vars('cat_row.forum_row', array(
'ROW_CLASS' => !($j % 2) ? 'row4' : 'row5',
@ -290,9 +291,9 @@ if (empty($forum_id) && empty($cat_id)) {
'IS_SUBFORUM' => $forum_rows[$j]['forum_parent'],
));
for ($k = 0; $k < count($forum_auth_fields); $k++) {
for ($k = 0, $kMax = count($forum_auth_fields); $k < $iMax; $k++) {
$item_auth_value = $forum_rows[$j][$forum_auth_fields[$k]];
for ($l = 0; $l < count($forum_auth_const); $l++) {
for ($l = 0, $lMax = count($forum_auth_const); $l < $iMax; $l++) {
if ($item_auth_value == $forum_auth_const[$l]) {
$item_auth_level = $forum_auth_levels[$l];
break;
@ -310,10 +311,10 @@ if (empty($forum_id) && empty($cat_id)) {
// next generate the information to allow the permissions to be changed
// note: we always read from the first forum in the category
//
for ($j = 0; $j < count($forum_auth_fields); $j++) {
for ($j = 0, $jMax = count($forum_auth_fields); $j < $iMax; $j++) {
$custom_auth[$j] = '<select name="' . $forum_auth_fields[$j] . '">';
for ($k = 0; $k < count($forum_auth_levels); $k++) {
for ($k = 0, $kMax = count($forum_auth_levels); $k < $iMax; $k++) {
$selected = (!empty($forum_rows) && $forum_rows[0][$forum_auth_fields[$j]] == $forum_auth_const[$k]) ? ' selected="selected"' : '';
$custom_auth[$j] .= '<option value="' . $forum_auth_const[$k] . '"' . $selected . '>' . $lang['FORUM_' . $forum_auth_levels[$k]] . '</option>';
}

View file

@ -85,7 +85,7 @@ if ($mode) {
$newmode = 'modforum';
$buttonvalue = $lang['UPDATE'];
$forum_id = intval($_GET[POST_FORUM_URL]);
$forum_id = (int)$_GET[POST_FORUM_URL];
$row = get_info('forum', $forum_id);
@ -121,7 +121,7 @@ if ($mode) {
}
if (isset($_REQUEST['forum_parent'])) {
$forum_parent = intval($_REQUEST['forum_parent']);
$forum_parent = (int)$_REQUEST['forum_parent'];
if ($parent = get_forum_data($forum_parent)) {
$cat_id = $parent['cat_id'];
@ -179,18 +179,18 @@ if ($mode) {
//
// Create a forum in the DB
//
$cat_id = intval($_POST[POST_CAT_URL]);
$cat_id = (int)$_POST[POST_CAT_URL];
$forum_name = (string)$_POST['forumname'];
$forum_desc = (string)$_POST['forumdesc'];
$forum_status = intval($_POST['forumstatus']);
$forum_status = (int)$_POST['forumstatus'];
$prune_days = intval($_POST['prune_days']);
$prune_days = (int)$_POST['prune_days'];
$forum_parent = ($_POST['forum_parent'] != -1) ? intval($_POST['forum_parent']) : 0;
$show_on_index = ($forum_parent) ? intval($_POST['show_on_index']) : 1;
$forum_parent = ($_POST['forum_parent'] != -1) ? (int)$_POST['forum_parent'] : 0;
$show_on_index = ($forum_parent) ? (int)$_POST['show_on_index'] : 1;
$forum_display_sort = intval($_POST['forum_display_sort']);
$forum_display_order = intval($_POST['forum_display_order']);
$forum_display_sort = (int)$_POST['forum_display_sort'];
$forum_display_order = (int)$_POST['forum_display_order'];
$forum_tpl_id = (int)$_POST['forum_tpl_select'];
$allow_reg_tracker = (int)$_POST['allow_reg_tracker'];
@ -207,7 +207,7 @@ if ($mode) {
}
$cat_id = $parent['cat_id'];
$forum_parent = ($parent['forum_parent']) ? $parent['forum_parent'] : $parent['forum_id'];
$forum_parent = ($parent['forum_parent']) ?: $parent['forum_id'];
$forum_order = $parent['forum_order'] + 5;
} else {
$max_order = get_max_forum_order($cat_id);
@ -242,18 +242,18 @@ if ($mode) {
//
// Modify a forum in the DB
//
$cat_id = intval($_POST[POST_CAT_URL]);
$forum_id = intval($_POST[POST_FORUM_URL]);
$cat_id = (int)$_POST[POST_CAT_URL];
$forum_id = (int)$_POST[POST_FORUM_URL];
$forum_name = (string)$_POST['forumname'];
$forum_desc = (string)$_POST['forumdesc'];
$forum_status = intval($_POST['forumstatus']);
$prune_days = intval($_POST['prune_days']);
$forum_status = (int)$_POST['forumstatus'];
$prune_days = (int)$_POST['prune_days'];
$forum_parent = ($_POST['forum_parent'] != -1) ? intval($_POST['forum_parent']) : 0;
$show_on_index = ($forum_parent) ? intval($_POST['show_on_index']) : 1;
$forum_parent = ($_POST['forum_parent'] != -1) ? (int)$_POST['forum_parent'] : 0;
$show_on_index = ($forum_parent) ? (int)$_POST['show_on_index'] : 1;
$forum_display_order = intval($_POST['forum_display_order']);
$forum_display_sort = intval($_POST['forum_display_sort']);
$forum_display_order = (int)$_POST['forum_display_order'];
$forum_display_sort = (int)$_POST['forum_display_sort'];
$forum_tpl_id = (int)$_POST['forum_tpl_select'];
$allow_reg_tracker = (int)$_POST['allow_reg_tracker'];
$allow_porno_topic = (int)$_POST['allow_porno_topic'];
@ -273,7 +273,7 @@ if ($mode) {
}
$cat_id = $parent['cat_id'];
$forum_parent = ($parent['forum_parent']) ? $parent['forum_parent'] : $parent['forum_id'];
$forum_parent = ($parent['forum_parent']) ?: $parent['forum_id'];
$forum_order = $parent['forum_order'] + 5;
if ($forum_id == $forum_parent) {
@ -565,8 +565,8 @@ if ($mode) {
case 'forum_order':
// Change order of forums
$move = intval($_GET['move']);
$forum_id = intval($_GET[POST_FORUM_URL]);
$move = (int)$_GET['move'];
$forum_id = (int)$_GET[POST_FORUM_URL];
$forum_info = get_info('forum', $forum_id);
renumber_order('forum', $forum_info['cat_id']);
@ -652,7 +652,7 @@ if ($mode) {
break;
case 'forum_sync':
sync('forum', intval($_GET['f']));
sync('forum', (int)$_GET['f']);
$datastore->update('cat_forums');
CACHE('bb_cache')->rm();
@ -746,7 +746,7 @@ if (!$mode || $show_main_page) {
'FORUM_DESC' => htmlCHR($forum_rows[$j]['forum_desc']),
'NUM_TOPICS' => $forum_rows[$j]['forum_topics'],
'NUM_POSTS' => $forum_rows[$j]['forum_posts'],
'PRUNE_DAYS' => ($forum_rows[$j]['prune_days']) ? $forum_rows[$j]['prune_days'] : '-',
'PRUNE_DAYS' => ($forum_rows[$j]['prune_days']) ?: '-',
'ORDER' => $forum_rows[$j]['forum_order'],
'FORUM_ID' => $forum_rows[$j]['forum_id'],
@ -910,7 +910,7 @@ function get_cat_forums($cat_id = false)
$forums = array();
$where_sql = '';
if ($cat_id = intval($cat_id)) {
if ($cat_id = (int)$cat_id) {
$where_sql = "AND f.cat_id = $cat_id";
}
@ -960,7 +960,7 @@ function get_prev_root_forum_id($forums, $curr_forum_order)
if (isset($forums[$i]) && !$forums[$i]['forum_parent']) {
return $forums[$i]['forum_id'];
}
$i = $i - 10;
$i -= 10;
}
return false;
@ -975,7 +975,7 @@ function get_next_root_forum_id($forums, $curr_forum_order)
if (isset($forums[$i]) && !$forums[$i]['forum_parent']) {
return $forums[$i]['forum_id'];
}
$i = $i + 10;
$i += 10;
}
return false;
@ -1082,7 +1082,7 @@ function get_max_forum_order($cat_id)
WHERE cat_id = $cat_id
");
return intval($row['max_forum_order']);
return (int)$row['max_forum_order'];
}
function check_name_dup($mode, $name, $die_on_error = true)

View file

@ -30,8 +30,8 @@ if (!empty($setmodules)) {
require __DIR__ . '/pagestart.php';
require INC_DIR . '/functions_group.php';
$group_id = isset($_REQUEST[POST_GROUPS_URL]) ? intval($_REQUEST[POST_GROUPS_URL]) : 0;
$mode = isset($_REQUEST['mode']) ? strval($_REQUEST['mode']) : '';
$group_id = isset($_REQUEST[POST_GROUPS_URL]) ? (int)$_REQUEST[POST_GROUPS_URL] : 0;
$mode = isset($_REQUEST['mode']) ? (string)$_REQUEST['mode'] : '';
attachment_quota_settings('group', isset($_POST['group_update']), $mode);
@ -100,8 +100,8 @@ if (!empty($_POST['edit']) || !empty($_POST['new'])) {
bb_die($message);
} else {
$group_type = isset($_POST['group_type']) ? intval($_POST['group_type']) : GROUP_OPEN;
$release_group = isset($_POST['release_group']) ? intval($_POST['release_group']) : 0;
$group_type = isset($_POST['group_type']) ? (int)$_POST['group_type'] : GROUP_OPEN;
$release_group = isset($_POST['release_group']) ? (int)$_POST['release_group'] : 0;
$group_name = isset($_POST['group_name']) ? trim($_POST['group_name']) : '';
$group_desc = isset($_POST['group_description']) ? trim($_POST['group_description']) : '';
$group_moderator = isset($_POST['username']) ? $_POST['username'] : '';

View file

@ -27,7 +27,8 @@ if (!empty($setmodules)) {
$module['USERS']['ACTIONS_LOG'] = basename(__FILE__);
return;
}
require('./pagestart.php');
require __DIR__ . '/pagestart.php';
$datastore->enqueue(array(
'moderators',
@ -94,7 +95,7 @@ $f_data = $forums['f'];
unset($forums);
// Start
$start = isset($_REQUEST['start']) ? abs(intval($_REQUEST['start'])) : 0;
$start = isset($_REQUEST['start']) ? abs((int)$_REQUEST['start']) : 0;
// Type
$type_selected = array($def_types);
@ -106,7 +107,7 @@ if ($var =& $_REQUEST[$type_key]) {
if (in_array($all_types, $type_selected)) {
$type_selected = array($all_types);
}
$type_csv = join(',', $type_selected);
$type_csv = implode(',', $type_selected);
$url = ($type_csv != $def_types) ? url_arg($url, $type_key, $type_csv) : $url;
}
@ -120,7 +121,7 @@ if ($var =& $_REQUEST[$user_key]) {
if (in_array($all_users, $user_selected)) {
$user_selected = array($all_users);
}
$user_csv = join(',', $user_selected);
$user_csv = implode(',', $user_selected);
$url = ($user_csv != $def_users) ? url_arg($url, $user_key, $user_csv) : $url;
}
@ -134,7 +135,7 @@ if ($var =& $_REQUEST[$forum_key]) {
if (in_array($all_forums, $forum_selected)) {
$forum_selected = array($all_forums);
}
$forum_csv = join(',', $forum_selected);
$forum_csv = implode(',', $forum_selected);
$url = ($forum_csv != $def_forums) ? url_arg($url, $forum_key, $forum_csv) : $url;
}
@ -144,7 +145,7 @@ $topic_csv = '';
if ($var =& $_REQUEST[$topic_key]) {
$topic_selected = get_id_ary($var);
$topic_csv = join(',', $topic_selected);
$topic_csv = implode(',', $topic_selected);
$url = ($topic_csv) ? url_arg($url, $topic_key, $topic_csv) : $url;
}
@ -164,7 +165,7 @@ $datetime_val = $def_datetime;
$daysback_val = $def_days;
if ($var =& $_REQUEST[$daysback_key] && $var != $def_days) {
$daysback_val = max(intval($var), 1);
$daysback_val = max((int)$var, 1);
$url = url_arg($url, $daysback_key, $daysback_val);
}
if ($var =& $_REQUEST[$datetime_key] && $var != $def_datetime) {

View file

@ -27,7 +27,8 @@ if (!empty($setmodules)) {
$module['MODS']['MASS_EMAIL'] = basename(__FILE__);
return;
}
require('./pagestart.php');
require __DIR__ . '/pagestart.php';
@set_time_limit(1200);
@ -54,7 +55,7 @@ if (isset($_POST['submit'])) {
foreach ($sql as $row) {
$user_id_sql[] = ',' . $row['ban_userid'];
}
$user_id_sql = join('', $user_id_sql);
$user_id_sql = implode('', $user_id_sql);
if ($group_id != -1) {
$user_list = DB()->fetch_rowset("
@ -113,7 +114,7 @@ $template->assign_vars(array(
'MESSAGE' => $message,
'SUBJECT' => $subject,
'ERROR_MESSAGE' => ($errors) ? join('<br />', array_unique($errors)) : '',
'ERROR_MESSAGE' => ($errors) ? implode('<br />', array_unique($errors)) : '',
'S_USER_ACTION' => 'admin_mass_email.php',
'S_GROUP_SELECT' => build_select(POST_GROUPS_URL, $groups),

View file

@ -27,6 +27,7 @@ if (!empty($setmodules)) {
$module['GENERAL']['PHP_INFO'] = basename(__FILE__);
return;
}
require('./pagestart.php');
require __DIR__ . '/pagestart.php';
phpinfo();

View file

@ -27,7 +27,8 @@ if (!empty($setmodules)) {
$module['USERS']['RANKS'] = basename(__FILE__);
return;
}
require('./pagestart.php');
require __DIR__ . '/pagestart.php';
$_POST['special_rank'] = 1;
$_POST['min_posts'] = -1;
@ -52,7 +53,7 @@ if ($mode != '') {
//
// They want to add a new rank, show the form.
//
$rank_id = (isset($_GET['id'])) ? intval($_GET['id']) : 0;
$rank_id = (isset($_GET['id'])) ? (int)$_GET['id'] : 0;
$s_hidden_fields = '';
@ -96,11 +97,11 @@ if ($mode != '') {
// Ok, they sent us our info, let's update it.
//
$rank_id = (isset($_POST['id'])) ? intval($_POST['id']) : 0;
$rank_id = (isset($_POST['id'])) ? (int)$_POST['id'] : 0;
$rank_title = (isset($_POST['title'])) ? trim($_POST['title']) : '';
$rank_style = (isset($_POST['style'])) ? trim($_POST['style']) : '';
$special_rank = ($_POST['special_rank'] == 1) ? true : 0;
$min_posts = (isset($_POST['min_posts'])) ? intval($_POST['min_posts']) : -1;
$min_posts = (isset($_POST['min_posts'])) ? (int)$_POST['min_posts'] : -1;
$rank_image = ((isset($_POST['rank_image']))) ? trim($_POST['rank_image']) : '';
if ($rank_title == '') {
@ -159,7 +160,7 @@ if ($mode != '') {
//
if (isset($_POST['id']) || isset($_GET['id'])) {
$rank_id = (isset($_POST['id'])) ? intval($_POST['id']) : intval($_GET['id']);
$rank_id = (isset($_POST['id'])) ? (int)$_POST['id'] : (int)$_GET['id'];
} else {
$rank_id = 0;
}

View file

@ -70,7 +70,7 @@ if (isset($_REQUEST['cancel_button'])) {
}
// from which post to start processing
$start = abs(intval(@$_REQUEST['start']));
$start = abs((int)(@$_REQUEST['start']));
// get the total number of posts in the db
$total_posts = get_total_posts();
@ -86,7 +86,7 @@ $session_posts_processed = ($mode == 'refresh') ? get_processed_posts('session')
$total_posts_processing = $total_posts - $total_posts_processed;
// how many posts to process in this session
if ($session_posts_processing = @intval($_REQUEST['session_posts_processing'])) {
if ($session_posts_processing = @(int)$_REQUEST['session_posts_processing']) {
if ($mode == 'submit') {
// check if we passed over total_posts just after submitting
if ($session_posts_processing + $total_posts_processed > $total_posts) {
@ -115,21 +115,10 @@ if (isset($_REQUEST['time_limit'])) {
$time_limit = $def_time_limit;
$time_limit_explain = $lang['TIME_LIMIT_EXPLAIN'];
// check for safe mode timeout
if (ini_get('safe_mode')) {
// get execution time
$max_execution_time = ini_get('max_execution_time');
$time_limit_explain .= '<br />' . sprintf($lang['TIME_LIMIT_EXPLAIN_SAFE'], $max_execution_time);
if ($time_limit > $max_execution_time) {
$time_limit = $max_execution_time;
}
}
// check for webserver timeout (IE returns null)
if (isset($_SERVER["HTTP_KEEP_ALIVE"])) {
// get webserver timeout
$webserver_timeout = intval($_SERVER["HTTP_KEEP_ALIVE"]);
$webserver_timeout = (int)$_SERVER["HTTP_KEEP_ALIVE"];
$time_limit_explain .= '<br />' . sprintf($lang['TIME_LIMIT_EXPLAIN_WEBSERVER'], $webserver_timeout);
if ($time_limit > $webserver_timeout) {
@ -207,7 +196,7 @@ if ($mode == 'submit' || $mode == 'refresh') {
}
// find how much time the last cycle took
$last_cycle_time = intval(TIMENOW - $start_time);
$last_cycle_time = (int)(TIMENOW - $start_time);
// check if we had any data
if ($num_rows != 0) {

View file

@ -27,7 +27,8 @@ if (!empty($setmodules)) {
$module['GENERAL']['SMILIES'] = basename(__FILE__);
return;
}
require('./pagestart.php');
require __DIR__ . '/pagestart.php';
// Check to see what mode we should operate in
if (isset($_POST['mode']) || isset($_GET['mode'])) {
@ -78,7 +79,7 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack'])) {
$cur_smilies = DB()->sql_fetchrowset($result);
for ($i = 0; $i < count($cur_smilies); $i++) {
for ($i = 0, $iMax = count($cur_smilies); $i < $iMax; $i++) {
$k = $cur_smilies[$i]['code'];
$smiles[$k] = 1;
}
@ -90,10 +91,10 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack'])) {
bb_die('Could not read smiley pak file');
}
for ($i = 0; $i < count($fcontents); $i++) {
for ($i = 0, $iMax = count($fcontents); $i < $iMax; $i++) {
$smile_data = explode($delimeter, trim(addslashes($fcontents[$i])));
for ($j = 2; $j < count($smile_data); $j++) {
for ($j = 2, $jMax = count($smile_data); $j < $iMax; $j++) {
// Replace > and < with the proper html_entities for matching
$smile_data[$j] = str_replace('<', '&lt;', $smile_data[$j]);
$smile_data[$j] = str_replace('>', '&gt;', $smile_data[$j]);
@ -155,7 +156,7 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack'])) {
$resultset = DB()->sql_fetchrowset($result);
$smile_pak = '';
for ($i = 0; $i < count($resultset); $i++) {
for ($i = 0, $iMax = count($resultset); $i < $iMax; $i++) {
$smile_pak .= $resultset[$i]['smile_url'] . $delimeter;
$smile_pak .= $resultset[$i]['emoticon'] . $delimeter;
$smile_pak .= $resultset[$i]['code'] . "\n";
@ -172,7 +173,7 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack'])) {
bb_die(sprintf($lang['EXPORT_SMILES'], '<a href="admin_smilies.php?export_pack=send">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_SMILEADMIN'], '<a href="admin_smilies.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
} elseif (isset($_POST['add']) || isset($_GET['add'])) {
$filename_list = '';
for ($i = 0; $i < count($smiley_images); $i++) {
for ($i = 0, $iMax = count($smiley_images); $i < $iMax; $i++) {
$filename_list .= '<option value="' . $smiley_images[$i] . '">' . $smiley_images[$i] . '</option>';
}
@ -190,7 +191,7 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack'])) {
switch ($mode) {
case 'delete':
$smiley_id = (!empty($_POST['id'])) ? $_POST['id'] : $_GET['id'];
$smiley_id = intval($smiley_id);
$smiley_id = (int)$smiley_id;
$sql = "DELETE FROM " . BB_SMILIES . " WHERE smilies_id = " . $smiley_id;
$result = DB()->sql_query($sql);
@ -204,7 +205,7 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack'])) {
case 'edit':
$smiley_id = (!empty($_POST['id'])) ? $_POST['id'] : $_GET['id'];
$smiley_id = intval($smiley_id);
$smiley_id = (int)$smiley_id;
$sql = "SELECT * FROM " . BB_SMILIES . " WHERE smilies_id = " . $smiley_id;
$result = DB()->sql_query($sql);
@ -214,7 +215,7 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack'])) {
$smile_data = DB()->sql_fetchrow($result);
$filename_list = '';
for ($i = 0; $i < count($smiley_images); $i++) {
for ($i = 0, $iMax = count($smiley_images); $i < $iMax; $i++) {
if ($smiley_images[$i] == $smile_data['smile_url']) {
$smiley_selected = 'selected="selected"';
$smiley_edit_img = $smiley_images[$i];
@ -244,7 +245,7 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack'])) {
$smile_url = (isset($_POST['smile_url'])) ? trim($_POST['smile_url']) : trim($_GET['smile_url']);
$smile_url = bb_ltrim(basename($smile_url), "'");
$smile_emotion = (isset($_POST['smile_emotion'])) ? trim($_POST['smile_emotion']) : trim($_GET['smile_emotion']);
$smile_id = (isset($_POST['smile_id'])) ? intval($_POST['smile_id']) : intval($_GET['smile_id']);
$smile_id = (isset($_POST['smile_id'])) ? (int)$_POST['smile_id'] : (int)$_GET['smile_id'];
// If no code was entered complain
if ($smile_code == '' || $smile_url == '') {
@ -313,7 +314,7 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack'])) {
));
// Loop throuh the rows of smilies setting block vars for the template
for ($i = 0; $i < count($smilies); $i++) {
for ($i = 0, $iMax = count($smilies); $i < $iMax; $i++) {
// Replace htmlentites for < and > with actual character
$smilies[$i]['code'] = str_replace('&lt;', '<', $smilies[$i]['code']);
$smilies[$i]['code'] = str_replace('&gt;', '>', $smilies[$i]['code']);

View file

@ -38,7 +38,7 @@ if (isset($_POST['post']) && $bb_cfg['terms'] != $_POST['message']) {
$template->assign_vars(array(
'S_ACTION' => 'admin_terms.php',
'EXT_LINK_NW' => $bb_cfg['ext_link_new_win'],
'MESSAGE' => ($bb_cfg['terms']) ? $bb_cfg['terms'] : '',
'MESSAGE' => ($bb_cfg['terms']) ?: '',
'PREVIEW_HTML' => (isset($_REQUEST['preview'])) ? bbcode2html($_POST['message']) : '',
));

View file

@ -82,7 +82,7 @@ if ($submit && $mode == 'user') {
$group_id = create_user_group($user_id);
}
if (!$group_id || !$user_id || is_null($this_user_level)) {
if (!$group_id || !$user_id || null === $this_user_level) {
trigger_error('data missing', E_USER_ERROR);
}

View file

@ -27,7 +27,8 @@ if (!empty($setmodules)) {
$module['USERS']['BAN_MANAGEMENT'] = basename(__FILE__);
return;
}
require('./pagestart.php');
require __DIR__ . '/pagestart.php';
if (isset($_POST['submit'])) {
$user_bansql = '';
@ -48,7 +49,7 @@ if (isset($_POST['submit'])) {
if (isset($_POST['ban_ip'])) {
$ip_list_temp = explode(',', $_POST['ban_ip']);
for ($i = 0; $i < count($ip_list_temp); $i++) {
for ($i = 0, $iMax = count($ip_list_temp); $i < $iMax; $i++) {
if (preg_match('/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})[ ]*\-[ ]*([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/', trim($ip_list_temp[$i]), $ip_range_explode)) {
$ip_1_counter = $ip_range_explode[1];
$ip_1_end = $ip_range_explode[5];
@ -99,7 +100,7 @@ if (isset($_POST['submit'])) {
} elseif (preg_match('/^([\w\-_]\.?){2,}$/is', trim($ip_list_temp[$i]))) {
$ip = gethostbynamel(trim($ip_list_temp[$i]));
for ($j = 0; $j < count($ip); $j++) {
for ($j = 0, $jMax = count($ip); $j < $iMax; $j++) {
if (!empty($ip[$j])) {
$ip_list[] = encode_ip($ip[$j]);
}
@ -114,7 +115,7 @@ if (isset($_POST['submit'])) {
if (isset($_POST['ban_email'])) {
$email_list_temp = explode(',', $_POST['ban_email']);
for ($i = 0; $i < count($email_list_temp); $i++) {
for ($i = 0, $iMax = count($email_list_temp); $i < $iMax; $i++) {
if (preg_match('/^(([a-z0-9&\'\.\-_\+])|(\*))+@(([a-z0-9\-])|(\*))+\.([a-z0-9\-]+\.)*?[a-z]+$/is', trim($email_list_temp[$i]))) {
$email_list[] = trim($email_list_temp[$i]);
}
@ -130,9 +131,9 @@ if (isset($_POST['submit'])) {
DB()->sql_freeresult($result);
$kill_session_sql = '';
for ($i = 0; $i < count($user_list); $i++) {
for ($i = 0, $iMax = count($user_list); $i < $iMax; $i++) {
$in_banlist = false;
for ($j = 0; $j < count($current_banlist); $j++) {
for ($j = 0, $jMax = count($current_banlist); $j < $iMax; $j++) {
if ($user_list[$i] == $current_banlist[$j]['ban_userid']) {
$in_banlist = true;
}
@ -148,9 +149,9 @@ if (isset($_POST['submit'])) {
}
}
for ($i = 0; $i < count($ip_list); $i++) {
for ($i = 0, $iMax = count($ip_list); $i < $iMax; $i++) {
$in_banlist = false;
for ($j = 0; $j < count($current_banlist); $j++) {
for ($j = 0, $jMax = count($current_banlist); $j < $iMax; $j++) {
if ($ip_list[$i] == $current_banlist[$j]['ban_ip']) {
$in_banlist = true;
}
@ -180,9 +181,9 @@ if (isset($_POST['submit'])) {
}
}
for ($i = 0; $i < count($email_list); $i++) {
for ($i = 0, $iMax = count($email_list); $i < $iMax; $i++) {
$in_banlist = false;
for ($j = 0; $j < count($current_banlist); $j++) {
for ($j = 0, $jMax = count($current_banlist); $j < $iMax; $j++) {
if ($email_list[$i] == $current_banlist[$j]['ban_email']) {
$in_banlist = true;
}
@ -201,9 +202,9 @@ if (isset($_POST['submit'])) {
if (isset($_POST['unban_user'])) {
$user_list = $_POST['unban_user'];
for ($i = 0; $i < count($user_list); $i++) {
for ($i = 0, $iMax = count($user_list); $i < $iMax; $i++) {
if ($user_list[$i] != -1) {
$where_sql .= (($where_sql != '') ? ', ' : '') . intval($user_list[$i]);
$where_sql .= (($where_sql != '') ? ', ' : '') . (int)$user_list[$i];
}
}
}
@ -211,7 +212,7 @@ if (isset($_POST['submit'])) {
if (isset($_POST['unban_ip'])) {
$ip_list = $_POST['unban_ip'];
for ($i = 0; $i < count($ip_list); $i++) {
for ($i = 0, $iMax = count($ip_list); $i < $iMax; $i++) {
if ($ip_list[$i] != -1) {
$where_sql .= (($where_sql != '') ? ', ' : '') . DB()->escape($ip_list[$i]);
}
@ -221,7 +222,7 @@ if (isset($_POST['submit'])) {
if (isset($_POST['unban_email'])) {
$email_list = $_POST['unban_email'];
for ($i = 0; $i < count($email_list); $i++) {
for ($i = 0, $iMax = count($email_list); $i < $iMax; $i++) {
if ($email_list[$i] != -1) {
$where_sql .= (($where_sql != '') ? ', ' : '') . DB()->escape($email_list[$i]);
}
@ -259,7 +260,7 @@ if (isset($_POST['submit'])) {
DB()->sql_freeresult($result);
$select_userlist = '';
for ($i = 0; $i < count($user_list); $i++) {
for ($i = 0, $iMax = count($user_list); $i < $iMax; $i++) {
$select_userlist .= '<option value="' . $user_list[$i]['ban_id'] . '">' . $user_list[$i]['username'] . '</option>';
$userban_count++;
}
@ -281,7 +282,7 @@ if (isset($_POST['submit'])) {
$select_iplist = '';
$select_emaillist = '';
for ($i = 0; $i < count($banlist); $i++) {
for ($i = 0, $iMax = count($banlist); $i < $iMax; $i++) {
$ban_id = $banlist[$i]['ban_id'];
if (!empty($banlist[$i]['ban_ip'])) {

View file

@ -271,7 +271,7 @@ if (!isset($_REQUEST['dosearch'])) {
$username = preg_replace('/\*/', '%', trim(strip_tags(strtolower($username))));
if (strstr($username, '%')) {
if (false !== strpos($username, '%')) {
$op = 'LIKE';
} else {
$op = '=';
@ -292,7 +292,7 @@ if (!isset($_REQUEST['dosearch'])) {
$email = preg_replace('/\*/', '%', trim(strip_tags(strtolower($email))));
if (strstr($email, '%')) {
if (false !== strpos($email, '%')) {
$op = 'LIKE';
} else {
$op = '=';
@ -437,25 +437,25 @@ if (!isset($_REQUEST['dosearch'])) {
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));
$date_type = strtolower(trim($date_type));
if ($date_type != 'before' && $date_type != 'after') {
bb_die($lang['SEARCH_INVALID_DATE']);
}
$date_day = intval($date_day);
$date_day = (int)$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);
$date_month = (int)$date_month;
if (!preg_match('/^(0?[1-9]|1[0-2])$/', $date_month)) {
bb_die($lang['SEARCH_INVALID_MONTH']);
}
$date_year = intval($date_year);
$date_year = (int)$date_year;
if (!preg_match('/^(20[0-9]{2}|19[0-9]{2})$/', $date_year)) {
bb_die($lang['SEARCH_INVALID_YEAR']);
@ -476,7 +476,7 @@ if (!isset($_REQUEST['dosearch'])) {
break;
case 'search_group':
$group_id = intval($group_id);
$group_id = (int)$group_id;
$base_url .= '&search_group=true&group_id=' . rawurlencode($group_id);
@ -511,7 +511,7 @@ if (!isset($_REQUEST['dosearch'])) {
break;
case 'search_rank':
$rank_id = intval($rank_id);
$rank_id = (int)$rank_id;
$base_url .= '&search_rank=true&rank_id=' . rawurlencode($rank_id);
@ -543,14 +543,14 @@ if (!isset($_REQUEST['dosearch'])) {
break;
case 'search_postcount':
$postcount_type = trim(strtolower($postcount_type));
$postcount_value = trim(strtolower($postcount_value));
$postcount_type = strtolower(trim($postcount_type));
$postcount_value = strtolower(trim($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);
$postcount_value = (int)$postcount_value;
$text = sprintf($lang['SEARCH_FOR_POSTCOUNT_GREATER'], $postcount_value);
@ -563,7 +563,7 @@ if (!isset($_REQUEST['dosearch'])) {
AND u.user_id <> " . GUEST_UID;
break;
case 'lesser':
$postcount_value = intval($postcount_value);
$postcount_value = (int)$postcount_value;
$text = sprintf($lang['SEARCH_FOR_POSTCOUNT_LESSER'], $postcount_value);
@ -577,11 +577,11 @@ if (!isset($_REQUEST['dosearch'])) {
break;
case 'equals':
// looking for a -
if (strstr($postcount_value, '-')) {
if (false !== strpos($postcount_value, '-')) {
$range = preg_split('/[-\s]+/', $postcount_value);
$range_begin = intval($range[0]);
$range_end = intval($range[1]);
$range_begin = (int)$range[0];
$range_end = (int)$range[1];
if ($range_begin > $range_end) {
bb_die($lang['SEARCH_INVALID_POSTCOUNT']);
@ -599,7 +599,7 @@ if (!isset($_REQUEST['dosearch'])) {
AND u.user_posts <= $range_end
AND u.user_id <> " . GUEST_UID;
} else {
$postcount_value = intval($postcount_value);
$postcount_value = (int)$postcount_value;
$text = sprintf($lang['SEARCH_FOR_POSTCOUNT_EQUALS'], $postcount_value);
@ -624,7 +624,7 @@ if (!isset($_REQUEST['dosearch'])) {
$userfield_value = preg_replace('/\*/', '%', trim(strip_tags(strtolower($userfield_value))));
if (strstr($userfield_value, '%')) {
if (false !== strpos($userfield_value, '%')) {
$op = 'LIKE';
} else {
$op = '=';
@ -634,7 +634,7 @@ if (!isset($_REQUEST['dosearch'])) {
bb_die($lang['SEARCH_INVALID_USERFIELD']);
}
$userfield_type = trim(strtolower($userfield_type));
$userfield_type = strtolower(trim($userfield_type));
switch ($userfield_type) {
case 'icq':
@ -679,8 +679,8 @@ if (!isset($_REQUEST['dosearch'])) {
break;
case 'search_lastvisited':
$lastvisited_type = trim(strtolower($lastvisited_type));
$lastvisited_days = intval($lastvisited_days);
$lastvisited_type = strtolower(trim($lastvisited_type));
$lastvisited_days = (int)$lastvisited_days;
$base_url .= '&search_lastvisited=true&lastvisited_type=' . rawurlencode(stripslashes($lastvisited_type)) . '&lastvisited_days=' . rawurlencode($lastvisited_days);
@ -718,7 +718,7 @@ if (!isset($_REQUEST['dosearch'])) {
case 'search_language':
$base_url .= '&search_language=true&language_type=' . rawurlencode(stripslashes($language_type));
$language_type = trim(strtolower(stripslashes($language_type)));
$language_type = strtolower(trim(stripslashes($language_type)));
if ($language_type == '') {
bb_die($lang['SEARCH_INVALID_LANGUAGE']);
@ -739,7 +739,7 @@ if (!isset($_REQUEST['dosearch'])) {
$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 = (int)$timezone_type;
$total_sql .= "SELECT COUNT(user_id) AS total
FROM " . BB_USERS . "
@ -752,7 +752,7 @@ if (!isset($_REQUEST['dosearch'])) {
case 'search_moderators':
$base_url .= '&search_moderators=true&moderators_forum=' . rawurlencode(stripslashes($moderators_forum));
$moderators_forum = intval($moderators_forum);
$moderators_forum = (int)$moderators_forum;
$sql = "SELECT forum_name FROM " . BB_FORUMS . " WHERE forum_id = " . $moderators_forum;
@ -789,7 +789,7 @@ if (!isset($_REQUEST['dosearch'])) {
case 'search_misc':
default:
$misc = trim(strtolower($misc));
$misc = strtolower(trim($misc));
$base_url .= '&search_misc=true&misc=' . rawurlencode(stripslashes($misc));
@ -888,7 +888,7 @@ if (!isset($_REQUEST['dosearch'])) {
$select_sql .= " $order";
$page = (isset($_GET['page'])) ? intval($_GET['page']) : intval(trim(@$_POST['page']));
$page = (isset($_GET['page'])) ? (int)$_GET['page'] : (int)trim(@$_POST['page']);
if ($page < 1) {
$page = 1;
@ -904,7 +904,7 @@ if (!isset($_REQUEST['dosearch'])) {
$select_sql .= " $limit";
if (!is_null($total_sql)) {
if (null !== $total_sql) {
if (!$result = DB()->sql_query($total_sql)) {
bb_die('Could not count users');
}
@ -970,7 +970,7 @@ if (!isset($_REQUEST['dosearch'])) {
$banned[$row['user_id']] = true;
}
for ($i = 0; $i < count($rowset); $i++) {
for ($i = 0, $iMax = count($rowset); $i < $iMax; $i++) {
$row_class = !($i % 2) ? 'row1' : 'row2';
$template->assign_block_vars('userrow', array(

View file

@ -27,7 +27,8 @@ if (!empty($setmodules)) {
$module['GENERAL']['WORD_CENSOR'] = basename(__FILE__);
return;
}
require('./pagestart.php');
require __DIR__ . '/pagestart.php';
if (!$bb_cfg['use_word_censor']) {
bb_die('Word censor disabled <br /><br /> ($bb_cfg[\'use_word_censor\'] in config.php)');
@ -44,7 +45,7 @@ if (isset($_POST['add'])) {
if ($mode != '') {
if ($mode == 'edit' || $mode == 'add') {
$word_id = intval(request_var('id', 0));
$word_id = (int)request_var('id', 0);
$s_hidden_fields = $word = $replacement = '';
@ -72,7 +73,7 @@ if ($mode != '') {
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
} elseif ($mode == 'save') {
$word_id = intval(request_var('id', 0));
$word_id = (int)request_var('id', 0);
$word = trim(request_var('word', ''));
$replacement = trim(request_var('replacement', ''));
@ -100,7 +101,7 @@ if ($mode != '') {
bb_die($message);
} elseif ($mode == 'delete') {
$word_id = intval(request_var('id', 0));
$word_id = (int)request_var('id', 0);
if ($word_id) {
$sql = "DELETE FROM " . BB_WORDS . " WHERE word_id = $word_id";

View file

@ -23,7 +23,7 @@
* SOFTWARE.
*/
require('./pagestart.php');
require __DIR__ . '/pagestart.php';
// Generate relevant output
if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
@ -104,11 +104,11 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
$avatar_dir_size = $lang['NOT_AVAILABLE'];
}
if (intval($posts_per_day) > $total_posts) {
if ((int)$posts_per_day > $total_posts) {
$posts_per_day = $total_posts;
}
if (intval($topics_per_day) > $total_topics) {
if ((int)$topics_per_day > $total_topics) {
$topics_per_day = $total_topics;
}
@ -130,7 +130,7 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
$tabledata_ary = DB()->sql_fetchrowset($result);
$dbsize = 0;
for ($i = 0; $i < count($tabledata_ary); $i++) {
for ($i = 0, $iMax = count($tabledata_ary); $i < $iMax; $i++) {
if (@$tabledata_ary[$i]['Type'] != 'MRG_MYISAM') {
$dbsize += $tabledata_ary[$i]['Data_length'] + $tabledata_ary[$i]['Index_length'];
}
@ -192,7 +192,7 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
if (count($onlinerow_reg)) {
$registered_users = $hidden_users = 0;
for ($i = 0, $cnt = count($onlinerow_reg); $i < $cnt; $i++) {
for ($i = 0, $iMax = count($onlinerow_reg); $i < $iMax; $i++) {
if (!in_array($onlinerow_reg[$i]['user_id'], $reg_userid_ary)) {
$reg_userid_ary[] = $onlinerow_reg[$i]['user_id'];
@ -226,7 +226,7 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
if (count($onlinerow_guest)) {
$guest_users = 0;
for ($i = 0; $i < count($onlinerow_guest); $i++) {
for ($i = 0, $iMax = count($onlinerow_guest); $i < $iMax; $i++) {
$guest_userip_ary[] = $onlinerow_guest[$i]['session_ip'];
$guest_users++;
@ -263,7 +263,7 @@ print_page('index.tpl', 'admin');
// Functions
function inarray($needle, $haystack)
{
for ($i = 0; $i < sizeof($haystack); $i++) {
for ($i = 0, $iMax = count($haystack); $i < $iMax; $i++) {
if ($haystack[$i] == $needle) {
return true;
}

View file

@ -36,7 +36,7 @@ if (!IS_ADMIN) {
$peers_in_last_minutes = array(30, 15, 5, 1);
$peers_in_last_sec_limit = 300;
$announce_interval = intval($bb_cfg['announce_interval']);
$announce_interval = (int)$bb_cfg['announce_interval'];
$stat = array();
define('TMP_TRACKER_TABLE', 'tmp_tracker');
@ -131,11 +131,11 @@ echo "\n
</td></tr>
\n";
echo "\n<tr><td align=center> peers: in last " . join(' / ', $peers_in_last_minutes) . " min</td>\n";
echo "\n<td align=center>" . join(' / ', $peers_in_last_min) . "</td></tr>\n";
echo "\n<tr><td align=center> peers: in last " . implode(' / ', $peers_in_last_minutes) . " min</td>\n";
echo "\n<td align=center>" . implode(' / ', $peers_in_last_min) . "</td></tr>\n";
echo "\n<tr><td align=center> peers in last $peers_in_last_sec_limit sec <br /> [ per second, DESC order --> ] <br /> last peer: $stat[last_peer_time] seconds ago <br /> " . date("j M H:i:s [T O]") . " </td>\n";
echo '<td align=center style="font-size: 13px; font-family: \'Courier New\',Courier,monospace;"><pre> ' . join(' ', $peers_in_last_sec) . "</pre></td></tr>\n";
echo '<td align=center style="font-size: 13px; font-family: \'Courier New\',Courier,monospace;"><pre> ' . implode(' ', $peers_in_last_sec) . "</pre></td></tr>\n";
echo '</table>';

View file

@ -129,7 +129,7 @@ class ajax_common
'index_data' => array('guest'),
);
public $action = null;
public $action;
/**
* Constructor

View file

@ -188,8 +188,7 @@ function msg_die($msg)
}
// Start announcer
define('TR_ROOT', './');
require(TR_ROOT . 'includes/init_tr.php');
require __DIR__ . '/includes/init_tr.php';
$seeder = ($left == 0) ? 1 : 0;
$stopped = ($event === 'stopped');
@ -438,7 +437,7 @@ if (!$output) {
foreach ($rowset as $peer) {
$peers[] = array(
'ip' => decode_ip($peer['ip']),
'port' => intval($peer['port']),
'port' => (int)$peer['port'],
);
}
}

View file

@ -53,7 +53,7 @@ function tracker_exit()
$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;
$str = implode(LOG_SEPR, $str) . LOG_LF;
dbg_log($str, '!!gentime');
}
}

View file

@ -59,8 +59,7 @@ function msg_die($msg)
die($output);
}
define('TR_ROOT', './');
require(TR_ROOT . 'includes/init_tr.php');
require __DIR__ . '/includes/init_tr.php';
$info_hash_sql = rtrim(DB()->escape($info_hash), ' ');

View file

@ -51,7 +51,7 @@ $sql = DB()->fetch_rowset("SELECT ban_userid FROM " . BB_BANLIST . " WHERE ban_u
foreach ($sql as $row) {
$ban_user_id[] = ',' . $row['ban_userid'];
}
$ban_user_id = join('', $ban_user_id);
$ban_user_id = implode('', $ban_user_id);
$user_list = DB()->fetch_rowset("
SELECT DISTINCT dl.user_id, u.user_opt, tr.user_id as active_dl

View file

@ -213,7 +213,7 @@ function utime()
function bb_log($msg, $file_name)
{
if (is_array($msg)) {
$msg = join(LOG_LF, $msg);
$msg = implode(LOG_LF, $msg);
}
$file_name .= (LOG_EXT) ? '.' . LOG_EXT : '';
return file_write($msg, LOG_DIR . '/' . $file_name);
@ -268,9 +268,9 @@ 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;
}
return (mkdir_rec(dirname($path), $mode)) ? @mkdir($path, $mode) : false;
}
function verify_id($id, $length)
@ -342,14 +342,17 @@ function bencode($var)
{
if (is_string($var)) {
return strlen($var) . ':' . $var;
} elseif (is_int($var)) {
}
if (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) {
@ -367,15 +370,14 @@ function bencode($var)
$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);
}
@ -411,7 +413,7 @@ function sys($param)
{
switch ($param) {
case 'la':
return function_exists('sys_getloadavg') ? join(' ', sys_getloadavg()) : 0;
return function_exists('sys_getloadavg') ? implode(' ', sys_getloadavg()) : 0;
break;
case 'mem':
return function_exists('memory_get_usage') ? memory_get_usage() : 0;
@ -449,7 +451,7 @@ function log_request($file = '', $prepend_str = false, $add_post = true)
{
global $user;
$file = ($file) ? $file : 'req/' . date('m-d');
$file = ($file) ?: 'req/' . date('m-d');
$str = array();
$str[] = date('m-d H:i:s');
if ($prepend_str !== false) {
@ -473,7 +475,7 @@ function log_request($file = '', $prepend_str = false, $add_post = true)
if (!empty($_POST) && $add_post) {
$str[] = "post: " . str_compact(urldecode(http_build_query($_POST)));
}
$str = join("\t", $str) . "\n";
$str = implode("\t", $str) . "\n";
bb_log($str, $file);
}
@ -482,7 +484,7 @@ 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)));
define('DUMMY_PEER', pack('Nn', ip2long($_SERVER['REMOTE_ADDR']), !empty($_GET['port']) ? (int) $_GET['port'] : mt_rand(1000, 65000)));
function dummy_exit($interval = 1800)
{

View file

@ -24,6 +24,6 @@
*/
define('START_CRON', true);
define('BB_ROOT', dirname(__FILE__) . '/');
define('BB_ROOT', __DIR__ . '/');
require __DIR__ . '/common.php';

6
dl.php
View file

@ -54,7 +54,7 @@ function send_file_to_browser($attachment, $upload_dir)
// 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')) {
if (false === strpos($attachment['mimetype'], 'image')) {
$attachment['mimetype'] = 'application/octet-stream';
}
@ -131,7 +131,7 @@ $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']);
$auth_pages[$i]['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'];
@ -178,7 +178,7 @@ 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']]);
$download_mode = (int)$download_mode[$attachment['extension']];
if ($thumbnail) {
$attachment['physical_filename'] = THUMB_DIR . '/t_' . $attachment['physical_filename'];

View file

@ -57,10 +57,10 @@ $full_url = isset($_POST['full_url']) ? str_replace('&amp;', '&', htmlspecialcha
if (isset($_POST['redirect_type']) && $_POST['redirect_type'] == 'search') {
$redirect_type = "search.php";
$redirect = ($full_url) ? $full_url : "$dl_key=1";
$redirect = ($full_url) ?: "$dl_key=1";
} else {
$redirect_type = (!$topic_id) ? "viewforum.php" : "viewtopic.php";
$redirect = ($full_url) ? $full_url : ((!$topic_id) ? POST_FORUM_URL . "=$forum_id" : POST_TOPIC_URL . "=$topic_id");
$redirect = ($full_url) ?: ((!$topic_id) ? POST_FORUM_URL . "=$forum_id" : POST_TOPIC_URL . "=$topic_id");
}
// Start session management
@ -128,7 +128,7 @@ if ($mode == 'set_topics_dl_status') {
}
// Get existing topics
if ($req_topics_sql = join(',', $req_topics_ary)) {
if ($req_topics_sql = implode(',', $req_topics_ary)) {
$sql = "SELECT topic_id FROM " . BB_TOPICS . " WHERE topic_id IN($req_topics_sql)";
foreach (DB()->fetch_rowset($sql) as $row) {

View file

@ -42,7 +42,7 @@ function generate_user_info(&$row, $date_format, $group_mod, &$from, &$posts, &$
$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;
$posts = ($row['user_posts']) ?: 0;
$pm = ($bb_cfg['text_buttons']) ? '<a class="txtb" href="' . (PM_URL . "?mode=post&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '">' . $lang['SEND_PM_TXTB'] . '</a>' : '<a href="' . (PM_URL . "?mode=post&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '"><img src="' . $images['icon_pm'] . '" alt="' . $lang['SEND_PRIVATE_MESSAGE'] . '" title="' . $lang['SEND_PRIVATE_MESSAGE'] . '" border="0" /></a>';
$avatar = get_avatar($row['user_id'], $row['avatar_ext_id'], !bf($row['user_opt'], 'user_opt', 'dis_avatar'), '', 50, 50);
@ -66,8 +66,8 @@ $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;
$group_id = isset($_REQUEST[POST_GROUPS_URL]) ? (int)$_REQUEST[POST_GROUPS_URL] : null;
$start = isset($_REQUEST['start']) ? abs((int)$_REQUEST['start']) : 0;
$per_page = $bb_cfg['group_members_per_page'];
$view_mode = isset($_REQUEST['view']) ? (string)$_REQUEST['view'] : null;
$rel_limit = 50;
@ -281,7 +281,7 @@ if (!$group_id) {
foreach ($members as $members_id) {
$sql_in[] = (int)$members_id;
}
if (!$sql_in = join(',', $sql_in)) {
if (!$sql_in = implode(',', $sql_in)) {
bb_die($lang['NONE_SELECTED']);
}

View file

@ -34,7 +34,7 @@ $page_cfg['include_bbcode_js'] = true;
// Start session management
$user->session_start(array('req_login' => true));
$group_id = isset($_REQUEST[POST_GROUPS_URL]) ? intval($_REQUEST[POST_GROUPS_URL]) : null;
$group_id = isset($_REQUEST[POST_GROUPS_URL]) ? (int)$_REQUEST[POST_GROUPS_URL] : null;
$group_info = array();
$is_moderator = false;

View file

@ -211,7 +211,7 @@ foreach ($cat_forums as $cid => $c) {
));
$template->assign_vars(array(
'H_C_AL_MESS' => ($hide_cat_opt && !$showhide) ? true : false,
'H_C_AL_MESS' => ($hide_cat_opt && !$showhide),
));
if (!$showhide && isset($hide_cat_user[$cid]) && !$viewcat) {
@ -255,7 +255,7 @@ foreach ($cat_forums as $cid => $c) {
'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]) : '',
'MODERATORS' => isset($moderators[$fid]) ? implode(', ', $moderators[$fid]) : '',
'FORUM_FOLDER_ALT' => ($new) ? $lang['NEW'] : $lang['OLD'],
));
@ -365,7 +365,7 @@ if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled']) {
$week_list[] = profile_url($week) . ' <span class="small">(' . birthday_age($week['user_birthday'] - 1) . ')</span>';
}
$week_all = ($week_all) ? '&nbsp;<a class="txtb" href="#" onclick="ajax.exec({action: \'index_data\', mode: \'birthday_week\'}); return false;" title="' . $lang['ALL'] . '">...</a>' : '';
$week_list = sprintf($lang['BIRTHDAY_WEEK'], $bb_cfg['birthday_check_day'], join(', ', $week_list)) . $week_all;
$week_list = sprintf($lang['BIRTHDAY_WEEK'], $bb_cfg['birthday_check_day'], implode(', ', $week_list)) . $week_all;
} else {
$week_list = sprintf($lang['NOBIRTHDAY_WEEK'], $bb_cfg['birthday_check_day']);
}
@ -380,7 +380,7 @@ if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled']) {
$today_list[] = profile_url($today) . ' <span class="small">(' . birthday_age($today['user_birthday']) . ')</span>';
}
$today_all = ($today_all) ? '&nbsp;<a class="txtb" href="#" onclick="ajax.exec({action: \'index_data\', mode: \'birthday_today\'}); return false;" title="' . $lang['ALL'] . '">...</a>' : '';
$today_list = $lang['BIRTHDAY_TODAY'] . join(', ', $today_list) . $today_all;
$today_list = $lang['BIRTHDAY_TODAY'] . implode(', ', $today_list) . $today_all;
} else {
$today_list = $lang['NOBIRTHDAY_TODAY'];
}

View file

@ -80,7 +80,7 @@ if ($confirm) {
DB()->query("UPDATE " . BB_USERS . " SET avatar_ext_id = {$upload->file_ext_id} WHERE user_id = {$row['user_id']} LIMIT 1");
$avatars_ok++;
} else {
echo "{$row['user_id']}: ", join("\n{$row['user_id']}: ", $upload->errors), "\n";
echo "{$row['user_id']}: ", implode("\n{$row['user_id']}: ", $upload->errors), "\n";
$avatars_err++;
}
}

View file

@ -30,9 +30,9 @@ if (!defined('IN_AJAX')) {
global $datastore, $lang;
$ranks = $datastore->get('ranks');
$rank_id = intval($this->request['rank_id']);
$rank_id = (int)$this->request['rank_id'];
if (!$user_id = intval($this->request['user_id']) or !$profiledata = get_userdata($user_id)) {
if (!$user_id = (int)$this->request['user_id'] or !$profiledata = get_userdata($user_id)) {
$this->ajax_die("invalid user_id: $user_id");
}

View file

@ -29,7 +29,7 @@ if (!defined('IN_AJAX')) {
global $bb_cfg, $userdata, $lang;
if (!$group_id = intval($this->request['group_id']) or !$group_info = get_group_data($group_id)) {
if (!$group_id = (int)$this->request['group_id'] or !$group_info = get_group_data($group_id)) {
$this->ajax_die($lang['NO_GROUP_ID_SPECIFIED']);
}
if (!$mode = (string)$this->request['mode']) {

View file

@ -29,7 +29,7 @@ if (!defined('IN_AJAX')) {
global $bb_cfg, $lang;
if (!$user_id = intval($this->request['user_id']) or !$profiledata = get_userdata($user_id)) {
if (!$user_id = (int)$this->request['user_id'] or !$profiledata = get_userdata($user_id)) {
$this->ajax_die($lang['NO_USER_ID_SPECIFIED']);
}
if (!$field = (string)$this->request['field']) {

View file

@ -29,7 +29,7 @@ if (!defined('IN_AJAX')) {
global $lang, $user;
if (!$user_id = intval($this->request['user_id']) or !$profiledata = get_userdata($user_id)) {
if (!$user_id = (int)$this->request['user_id'] or !$profiledata = get_userdata($user_id)) {
$this->ajax_die("invalid user_id: $user_id");
}
@ -71,7 +71,7 @@ switch ($mode) {
}
}
if ($html) {
$this->response['group_list_html'] = '<ul><li>' . join('</li><li>', $html) . '</li></ul>';
$this->response['group_list_html'] = '<ul><li>' . implode('</li><li>', $html) . '</li></ul>';
} else {
$this->response['group_list_html'] = $lang['GROUP_LIST_HIDDEN'];
}

View file

@ -43,7 +43,7 @@ switch ($mode) {
foreach ($stats['birthday_week_list'] as $week) {
$html[] = profile_url($week) . ' <span class="small">(' . birthday_age($week['user_birthday']) . ')</span>';
}
$html = sprintf($lang['BIRTHDAY_WEEK'], $bb_cfg['birthday_check_day'], join(', ', $html));
$html = sprintf($lang['BIRTHDAY_WEEK'], $bb_cfg['birthday_check_day'], implode(', ', $html));
} else {
$html = sprintf($lang['NOBIRTHDAY_WEEK'], $bb_cfg['birthday_check_day']);
}
@ -59,7 +59,7 @@ switch ($mode) {
foreach ($stats['birthday_today_list'] as $today) {
$html[] = profile_url($today) . ' <span class="small">(' . birthday_age($today['user_birthday']) . ')</span>';
}
$html = $lang['BIRTHDAY_TODAY'] . join(', ', $html);
$html = $lang['BIRTHDAY_TODAY'] . implode(', ', $html);
} else {
$html = $lang['NOBIRTHDAY_TODAY'];
}
@ -88,7 +88,7 @@ switch ($mode) {
}
$html = ':&nbsp;';
$html .= ($moderators) ? join(', ', $moderators) : $lang['NONE'];
$html .= ($moderators) ? implode(', ', $moderators) : $lang['NONE'];
unset($moderators, $mod);
$datastore->rm('moderators');
break;

View file

@ -103,7 +103,7 @@ switch ($mode) {
$this->response['val']['tpl-last-edit-tst'] = $tpl_data['tpl_last_edit_tm'];
$this->response['html']['tpl-name-old-save'] = $tpl_data['tpl_name'];
$this->response['html']['tpl-last-edit-time'] = bb_date($tpl_data['tpl_last_edit_tm'], 'd-M-y H:i');
$this->response['html']['tpl-last-edit-by'] = get_username(intval($tpl_data['tpl_last_edit_by']));
$this->response['html']['tpl-last-edit-by'] = get_username((int)$tpl_data['tpl_last_edit_by']);
$this->response['tpl_rules_href'] = POST_URL . $tpl_data['tpl_rules_post_id'] . '#' . $tpl_data['tpl_rules_post_id'];
break;
@ -137,7 +137,7 @@ switch ($mode) {
// сохранение изменений
case 'save':
if ($tpl_data['tpl_last_edit_tm'] > $this->request['tpl_l_ed_tst'] && $tpl_data['tpl_last_edit_by'] != $userdata['user_id']) {
$last_edit_by_username = get_username(intval($tpl_data['tpl_last_edit_by']));
$last_edit_by_username = get_username((int)$tpl_data['tpl_last_edit_by']);
$msg = "Изменения не были сохранены!\n\n";
$msg .= 'Шаблон был отредактирован: ' . html_entity_decode($last_edit_by_username) . ', ' . delta_time($tpl_data['tpl_last_edit_tm']) . " назад\n\n";
$this->ajax_die($msg);

View file

@ -46,11 +46,11 @@ function init_complete_extensions_data()
}
$allowed_extensions = array();
for ($i = 0, $size = sizeof($extension_informations); $i < $size; $i++) {
for ($i = 0, $size = count($extension_informations); $i < $size; $i++) {
$extension = strtolower(trim($extension_informations[$i]['extension']));
$allowed_extensions[] = $extension;
$display_categories[$extension] = intval($extension_informations[$i]['cat_id']);
$download_modes[$extension] = intval($extension_informations[$i]['download_mode']);
$display_categories[$extension] = (int)$extension_informations[$i]['cat_id'];
$download_modes[$extension] = (int)$extension_informations[$i]['download_mode'];
$upload_icons[$extension] = trim($extension_informations[$i]['upload_icon']);
}
}
@ -74,7 +74,7 @@ function init_display_template($template_var, $replacement, $filename = 'viewtop
$filename_2 = $template->files[$template_var];
$str = implode('', @file($filename_2));
$str = file_get_contents($filename_2);
if (empty($str)) {
die("Template->loadfile(): File $filename_2 for handle $template_var is empty");
}
@ -83,7 +83,7 @@ function init_display_template($template_var, $replacement, $filename = 'viewtop
}
$complete_filename = $filename;
if (substr($complete_filename, 0, 1) != '/') {
if ($complete_filename[0] != '/') {
$complete_filename = $template->root . '/' . $complete_filename;
}
@ -91,7 +91,7 @@ function init_display_template($template_var, $replacement, $filename = 'viewtop
die("Template->make_filename(): Error - file $complete_filename does not exist");
}
$content = implode('', file($complete_filename));
$content = file_get_contents($complete_filename);
if (empty($content)) {
die('Template->loadfile(): File ' . $complete_filename . ' is empty');
}
@ -107,7 +107,7 @@ function display_post_attachments($post_id, $switch_attachment)
{
global $attach_config, $is_auth;
if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod'])) {
if ((int)$switch_attachment == 0 || (int)$attach_config['disable_mod']) {
return;
}
@ -127,7 +127,7 @@ function init_display_post_attachments($switch_attachment)
$switch_attachment = $forum_row['topic_attachment'];
}
if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod']) || (!($is_auth['auth_download'] && $is_auth['auth_view']))) {
if ((int)$switch_attachment == 0 || (int)$attach_config['disable_mod'] || (!($is_auth['auth_download'] && $is_auth['auth_view']))) {
init_display_template('body', '{postrow.ATTACHMENTS}', 'viewtopic_attach_guest.tpl');
return;
}
@ -140,12 +140,12 @@ function init_display_post_attachments($switch_attachment)
}
}
if (sizeof($post_id_array) == 0) {
if (count($post_id_array) == 0) {
return;
}
$rows = get_attachments_from_post($post_id_array);
$num_rows = sizeof($rows);
$num_rows = count($rows);
if ($num_rows == 0) {
return;
@ -183,7 +183,7 @@ function display_attachments($post_id)
{
global $template, $upload_dir, $userdata, $allowed_extensions, $display_categories, $download_modes, $lang, $attachments, $upload_icons, $attach_config;
$num_attachments = @sizeof($attachments['_' . $post_id]);
$num_attachments = @count($attachments['_' . $post_id]);
if ($num_attachments == 0) {
return;
@ -227,14 +227,14 @@ function display_attachments($post_id)
$thumbnail = false;
$link = false;
if (@intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT && intval($attach_config['img_display_inlined'])) {
if (intval($attach_config['img_link_width']) != 0 || intval($attach_config['img_link_height']) != 0) {
if (@(int)$display_categories[$attachments['_' . $post_id][$i]['extension']] == IMAGE_CAT && (int)$attach_config['img_display_inlined']) {
if ((int)$attach_config['img_link_width'] != 0 || (int)$attach_config['img_link_height'] != 0) {
list($width, $height) = image_getdimension($filename);
if ($width == 0 && $height == 0) {
$image = true;
} else {
if ($width <= intval($attach_config['img_link_width']) && $height <= intval($attach_config['img_link_height'])) {
if ($width <= (int)$attach_config['img_link_width'] && $height <= (int)$attach_config['img_link_height']) {
$image = true;
}
}
@ -243,7 +243,7 @@ function display_attachments($post_id)
}
}
if (@intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT && $attachments['_' . $post_id][$i]['thumbnail'] == 1) {
if (@(int)$display_categories[$attachments['_' . $post_id][$i]['extension']] == IMAGE_CAT && $attachments['_' . $post_id][$i]['thumbnail'] == 1) {
$thumbnail = true;
$image = false;
}
@ -304,7 +304,7 @@ function display_attachments($post_id)
if ($link && ($attachments['_' . $post_id][$i]['extension'] === TORRENT_EXT)) {
include ATTACH_DIR . '/displaying_torrent.php';
} elseif ($link) {
$target_blank = ((@intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT)) ? 'target="_blank"' : '';
$target_blank = ((@(int)$display_categories[$attachments['_' . $post_id][$i]['extension']] == IMAGE_CAT)) ? 'target="_blank"' : '';
// display attachment
$template->assign_block_vars('postrow.attach.attachrow', array(

View file

@ -94,7 +94,7 @@ $tor_auth_del = ($tor_auth && $tor_reged);
$tracker_link = ($tor_reged) ? $lang['BT_REG_YES'] : $lang['BT_REG_NO'];
$download_link = DOWNLOAD_URL . $attach_id;
$description = ($comment) ? $comment : preg_replace("#.torrent$#i", '', $display_name);
$description = ($comment) ?: preg_replace("#.torrent$#i", '', $display_name);
if ($tor_auth_reg || $tor_auth_del) {
$reg_tor_url = '<a class="txtb" href="#" onclick="ajax.exec({ action: \'change_torrent\', attach_id : ' . $attach_id . ', type: \'reg\'}); return false;">' . $lang['BT_REG_ON_TRACKER'] . '</a>';
@ -155,7 +155,7 @@ if ($tor_auth) {
}
if ($tor_reged && $tor_info) {
$tor_size = ($tor_info['size']) ? $tor_info['size'] : 0;
$tor_size = ($tor_info['size']) ?: 0;
$tor_id = $tor_info['topic_id'];
$tor_type = $tor_info['tor_type'];
@ -297,7 +297,6 @@ if ($tor_reged && $tor_info) {
FROM " . BB_BT_TRACKER . " tr, " . BB_USERS . " u
WHERE tr.topic_id = $tor_id
AND u.user_id = tr.user_id
GROUP BY tr.ip, tr.user_id, tr.port, tr.seeder
ORDER BY u.username
LIMIT $show_peers_limit";
} else {
@ -308,7 +307,6 @@ if ($tor_reged && $tor_info) {
FROM " . BB_BT_TRACKER . " tr
LEFT JOIN " . BB_USERS . " u ON u.user_id = tr.user_id
WHERE tr.topic_id = $tor_id
GROUP BY tr.ip, tr.user_id, tr.port, tr.seeder
ORDER BY $full_mode_order $full_mode_sort_dir
LIMIT $show_peers_limit";
}
@ -334,7 +332,7 @@ if ($tor_reged && $tor_info) {
$sp_up_tot[$x] += $peer['speed_up'];
$sp_down_tot[$x] += $peer['speed_down'];
$guest = ($peer['user_id'] == GUEST_UID || is_null($peer['username']));
$guest = ($peer['user_id'] == GUEST_UID || null === $peer['username']);
$p_max_up = $peer['uploaded'];
$p_max_down = $peer['downloaded'];
@ -498,14 +496,14 @@ if ($tor_reged && $tor_info) {
$seeders[strlen($seeders) - 9] = ' ';
$template->assign_vars(array(
'SEED_LIST' => $seeders,
'SEED_COUNT' => ($seed_count) ? $seed_count : 0,
'SEED_COUNT' => ($seed_count) ?: 0,
));
}
if ($s_mode != 'full' && $leechers) {
$leechers[strlen($leechers) - 9] = ' ';
$template->assign_vars(array(
'LEECH_LIST' => $leechers,
'LEECH_COUNT' => ($leech_count) ? $leech_count : 0,
'LEECH_COUNT' => ($leech_count) ?: 0,
));
}
}

View file

@ -106,7 +106,7 @@ function process_quota_settings($mode, $id, $quota_type, $quota_limit_id = 0)
*/
function sort_multi_array($sort_array, $key, $sort_order, $pre_string_sort = 0)
{
$last_element = sizeof($sort_array) - 1;
$last_element = count($sort_array) - 1;
if (!$pre_string_sort) {
$string_sort = (!is_numeric(@$sort_array[$last_element - 1][$key])) ? true : false;
@ -121,17 +121,13 @@ function sort_multi_array($sort_array, $key, $sort_order, $pre_string_sort = 0)
// do checks based on key
$switch = false;
if (!$string_sort) {
if (
($sort_order == 'DESC' && intval(@$sort_array[$j][$key]) < intval(@$sort_array[$j + 1][$key])) ||
($sort_order == 'ASC' && intval(@$sort_array[$j][$key]) > intval(@$sort_array[$j + 1][$key]))
) {
if (($sort_order == 'DESC' && intval(@$sort_array[$j][$key]) < intval(@$sort_array[$j + 1][$key])) ||
($sort_order == 'ASC' && intval(@$sort_array[$j][$key]) > intval(@$sort_array[$j + 1][$key]))) {
$switch = true;
}
} else {
if (
($sort_order == 'DESC' && strcasecmp(@$sort_array[$j][$key], @$sort_array[$j + 1][$key]) < 0) ||
($sort_order == 'ASC' && strcasecmp(@$sort_array[$j][$key], @$sort_array[$j + 1][$key]) > 0)
) {
if (($sort_order == 'DESC' && strcasecmp(@$sort_array[$j][$key], @$sort_array[$j + 1][$key]) < 0) ||
($sort_order == 'ASC' && strcasecmp(@$sort_array[$j][$key], @$sort_array[$j + 1][$key]) > 0)) {
$switch = true;
}
}
@ -209,7 +205,7 @@ function search_attachments($order_by, &$total_rows)
$matching_userids = '';
if ($row = DB()->sql_fetchrow($result)) {
do {
$matching_userids .= (($matching_userids != '') ? ', ' : '') . intval($row['user_id']);
$matching_userids .= (($matching_userids != '') ? ', ' : '') . $row['user_id'];
} while ($row = DB()->sql_fetchrow($result));
DB()->sql_freeresult($result);
@ -260,13 +256,13 @@ function search_attachments($order_by, &$total_rows)
// Search Forum
$search_forum = get_var('search_forum', '');
if ($search_forum) {
$where_sql[] = ' (p.forum_id = ' . intval($search_forum) . ') ';
$where_sql[] = ' (p.forum_id = ' . (int)$search_forum . ') ';
}
$sql = 'SELECT a.*, t.post_id, p.post_time, p.topic_id
FROM ' . BB_ATTACHMENTS . ' t, ' . BB_ATTACHMENTS_DESC . ' a, ' . BB_POSTS . ' p WHERE ';
if (sizeof($where_sql) > 0) {
if (count($where_sql) > 0) {
$sql .= implode('AND', $where_sql) . ' AND ';
}
@ -309,7 +305,7 @@ function search_attachments($order_by, &$total_rows)
function limit_array($array, $start, $pagelimit)
{
// array from start - start+pagelimit
$limit = (sizeof($array) < ($start + $pagelimit)) ? sizeof($array) : $start + $pagelimit;
$limit = (count($array) < ($start + $pagelimit)) ? count($array) : $start + $pagelimit;
$limit_array = [];

View file

@ -49,7 +49,9 @@ function base64_pack($number)
if ($number > 4096) {
return;
} elseif ($number < $base) {
}
if ($number < $base) {
return $chars[$number];
}
@ -81,7 +83,7 @@ function base64_unpack($string)
for ($i = 1; $i <= $length; $i++) {
$pos = $length - $i;
$operand = strpos($chars, substr($string, $pos, 1));
$operand = strpos($chars, $string[$pos]);
$exponent = pow($base, $i - 1);
$decValue = $operand * $exponent;
$number += $decValue;
@ -101,8 +103,8 @@ function auth_pack($auth_array)
$one_char = $two_char = false;
$auth_cache = '';
for ($i = 0; $i < sizeof($auth_array); $i++) {
$val = base64_pack(intval($auth_array[$i]));
for ($i = 0, $iMax = count($auth_array); $i < $iMax; $i++) {
$val = base64_pack((int)$auth_array[$i]);
if (strlen($val) == 1 && !$one_char) {
$auth_cache .= $one_char_encoding;
$one_char = true;
@ -129,11 +131,13 @@ function auth_unpack($auth_cache)
$auth_len = 1;
for ($pos = 0; $pos < strlen($auth_cache); $pos += $auth_len) {
$forum_auth = substr($auth_cache, $pos, 1);
$forum_auth = $auth_cache[$pos];
if ($forum_auth == $one_char_encoding) {
$auth_len = 1;
continue;
} elseif ($forum_auth == $two_char_encoding) {
}
if ($forum_auth == $two_char_encoding) {
$auth_len = 2;
$pos--;
continue;
@ -141,7 +145,7 @@ function auth_unpack($auth_cache)
$forum_auth = substr($auth_cache, $pos, $auth_len);
$forum_id = base64_unpack($forum_auth);
$auth[] = intval($forum_id);
$auth[] = (int)$forum_id;
}
return $auth;
}
@ -162,11 +166,13 @@ function is_forum_authed($auth_cache, $check_forum_id)
$auth_len = 1;
for ($pos = 0; $pos < strlen($auth_cache); $pos += $auth_len) {
$forum_auth = substr($auth_cache, $pos, 1);
$forum_auth = $auth_cache[$pos];
if ($forum_auth == $one_char_encoding) {
$auth_len = 1;
continue;
} elseif ($forum_auth == $two_char_encoding) {
}
if ($forum_auth == $two_char_encoding) {
$auth_len = 2;
$pos--;
continue;
@ -196,9 +202,7 @@ function unlink_attach($filename, $mode = false)
$filename = $upload_dir . '/' . $filename;
}
$deleted = @unlink($filename);
return $deleted;
return @unlink($filename);
}
/**
@ -212,9 +216,9 @@ function attachment_exists($filename)
if (!@file_exists(@amod_realpath($upload_dir . '/' . $filename))) {
return false;
} else {
return true;
}
return true;
}
/**
@ -228,9 +232,9 @@ function thumbnail_exists($filename)
if (!@file_exists(@amod_realpath($upload_dir . '/' . THUMB_DIR . '/t_' . $filename))) {
return false;
} else {
return true;
}
return true;
}
/**
@ -255,7 +259,7 @@ function physical_filename_already_stored($filename)
$num_rows = DB()->num_rows($result);
DB()->sql_freeresult($result);
return ($num_rows == 0) ? false : true;
return $num_rows != 0;
}
/**
@ -272,7 +276,7 @@ function get_attachments_from_post($post_id_array)
return $attachments;
}
$post_id = intval($post_id_array);
$post_id = (int)$post_id_array;
$post_id_array = array();
$post_id_array[] = $post_id;
@ -284,7 +288,7 @@ function get_attachments_from_post($post_id_array)
return $attachments;
}
$display_order = (intval($attach_config['display_order']) == 0) ? 'DESC' : 'ASC';
$display_order = ((int)$attach_config['display_order'] == 0) ? 'DESC' : 'ASC';
$sql = 'SELECT a.post_id, d.*
FROM ' . BB_ATTACHMENTS . ' a, ' . BB_ATTACHMENTS_DESC . " d
@ -312,7 +316,7 @@ function get_attachments_from_post($post_id_array)
*/
function get_total_attach_filesize($attach_ids)
{
if (!is_array($attach_ids) || !sizeof($attach_ids)) {
if (!is_array($attach_ids) || !count($attach_ids)) {
return 0;
}
@ -352,7 +356,7 @@ function get_extension_informations()
function attachment_sync_topic($topics)
{
if (is_array($topics)) {
$topics = join(',', $topics);
$topics = implode(',', $topics);
}
$posts_without_attach = $topics_without_attach = array();
@ -368,7 +372,7 @@ function attachment_sync_topic($topics)
foreach ($rowset as $row) {
$posts_without_attach[] = $row['post_id'];
}
if ($posts_sql = join(',', $posts_without_attach)) {
if ($posts_sql = implode(',', $posts_without_attach)) {
DB()->query("UPDATE " . BB_POSTS . " SET post_attachment = 0 WHERE post_id IN($posts_sql)");
}
}
@ -395,7 +399,7 @@ function attachment_sync_topic($topics)
foreach ($rowset as $row) {
$topics_without_attach[] = $row['topic_id'];
}
if ($topics_sql = join(',', $topics_without_attach)) {
if ($topics_sql = implode(',', $topics_without_attach)) {
DB()->query("UPDATE " . BB_TOPICS . " SET topic_attachment = 0 WHERE topic_id IN($topics_sql)");
}
}
@ -406,7 +410,7 @@ function attachment_sync_topic($topics)
*/
function get_extension($filename)
{
if (!stristr($filename, '.')) {
if (false === strstr($filename, '.')) {
return '';
}
$extension = strrchr(strtolower($filename), '.');
@ -414,9 +418,9 @@ function get_extension($filename)
$extension = strtolower(trim($extension));
if (is_array($extension)) {
return '';
} else {
return $extension;
}
return $extension;
}
/**
@ -454,11 +458,7 @@ function user_in_group($user_id, $group_id)
$num_rows = DB()->num_rows($result);
DB()->sql_freeresult($result);
if ($num_rows == 0) {
return false;
}
return true;
return !($num_rows == 0);
}
/**
@ -501,11 +501,9 @@ function _set_var(&$result, $var, $type, $multibyte = false)
*/
function get_var($var_name, $default, $multibyte = false)
{
if (
!isset($_REQUEST[$var_name]) ||
if (!isset($_REQUEST[$var_name]) ||
(is_array($_REQUEST[$var_name]) && !is_array($default)) ||
(is_array($default) && !is_array($_REQUEST[$var_name]))
) {
(is_array($default) && !is_array($_REQUEST[$var_name]))) {
return (is_array($default)) ? [] : $default;
}
@ -550,9 +548,9 @@ function attach_mod_sql_escape($text)
{
if (function_exists('mysqli_real_escape_string')) {
return DB()->escape_string($text);
} else {
return str_replace("'", "''", str_replace('\\', '\\\\', $text));
}
return str_replace("'", "''", str_replace('\\', '\\\\', $text));
}
/**
@ -573,14 +571,14 @@ function attach_mod_sql_build_array($query, $assoc_ary = false)
foreach ($assoc_ary as $key => $var) {
$fields[] = $key;
if (is_null($var)) {
if (null === $var) {
$values[] = 'NULL';
} elseif (is_string($var)) {
$values[] = "'" . attach_mod_sql_escape($var) . "'";
} elseif (is_array($var) && is_string($var[0])) {
$values[] = $var[0];
} else {
$values[] = (is_bool($var)) ? intval($var) : $var;
$values[] = (is_bool($var)) ? (int)$var : $var;
}
}
@ -590,12 +588,12 @@ function attach_mod_sql_build_array($query, $assoc_ary = false)
foreach ($assoc_ary as $id => $sql_ary) {
$values = array();
foreach ($sql_ary as $key => $var) {
if (is_null($var)) {
if (null === $var) {
$values[] = 'NULL';
} elseif (is_string($var)) {
$values[] = "'" . attach_mod_sql_escape($var) . "'";
} else {
$values[] = (is_bool($var)) ? intval($var) : $var;
$values[] = (is_bool($var)) ? (int)$var : $var;
}
}
$ary[] = '(' . implode(', ', $values) . ')';
@ -605,12 +603,12 @@ function attach_mod_sql_build_array($query, $assoc_ary = false)
} elseif ($query == 'UPDATE' || $query == 'SELECT') {
$values = array();
foreach ($assoc_ary as $key => $var) {
if (is_null($var)) {
if (null === $var) {
$values[] = "$key = NULL";
} elseif (is_string($var)) {
$values[] = "$key = '" . attach_mod_sql_escape($var) . "'";
} else {
$values[] = (is_bool($var)) ? "$key = " . intval($var) : "$key = $var";
$values[] = (is_bool($var)) ? "$key = " . (int)$var : "$key = $var";
}
}
$query = implode(($query == 'UPDATE') ? ', ' : ' AND ', $values);

View file

@ -41,12 +41,12 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
$post_id_array = array();
if (!is_array($attach_id_array)) {
if (strstr($attach_id_array, ', ')) {
if (false !== strpos($attach_id_array, ', ')) {
$attach_id_array = explode(', ', $attach_id_array);
} elseif (strstr($attach_id_array, ',')) {
$attach_id_array = explode(',', $attach_id_array);
} else {
$attach_id = intval($attach_id_array);
$attach_id = (int)$attach_id_array;
$attach_id_array = array();
$attach_id_array[] = $attach_id;
}
@ -72,7 +72,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
}
while ($row = DB()->sql_fetchrow($result)) {
$post_id_array[] = intval($row[$p_id]);
$post_id_array[] = (int)$row[$p_id];
}
DB()->sql_freeresult($result);
}
@ -82,19 +82,19 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
return;
}
if (strstr($post_id_array, ', ')) {
if (false !== strpos($post_id_array, ', ')) {
$post_id_array = explode(', ', $post_id_array);
} elseif (strstr($post_id_array, ',')) {
$post_id_array = explode(',', $post_id_array);
} else {
$post_id = intval($post_id_array);
$post_id = (int)$post_id_array;
$post_id_array = array();
$post_id_array[] = $post_id;
}
}
if (!sizeof($post_id_array)) {
if (!count($post_id_array)) {
return;
}
@ -127,25 +127,25 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
}
if (!is_array($attach_id_array)) {
if (strstr($attach_id_array, ', ')) {
if (false !== strpos($attach_id_array, ', ')) {
$attach_id_array = explode(', ', $attach_id_array);
} elseif (strstr($attach_id_array, ',')) {
$attach_id_array = explode(',', $attach_id_array);
} else {
$attach_id = intval($attach_id_array);
$attach_id = (int)$attach_id_array;
$attach_id_array = array();
$attach_id_array[] = $attach_id;
}
}
if (!sizeof($attach_id_array)) {
if (!count($attach_id_array)) {
return;
}
$sql_id = 'post_id';
if (sizeof($post_id_array) && sizeof($attach_id_array)) {
if (count($post_id_array) && count($attach_id_array)) {
$sql = 'DELETE FROM ' . BB_ATTACHMENTS . '
WHERE attach_id IN (' . implode(', ', $attach_id_array) . ")
AND $sql_id IN (" . implode(', ', $post_id_array) . ')';
@ -187,7 +187,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
}
//bt end
for ($i = 0; $i < sizeof($attach_id_array); $i++) {
for ($i = 0, $iMax = count($attach_id_array); $i < $iMax; $i++) {
$sql = 'SELECT attach_id
FROM ' . BB_ATTACHMENTS . '
WHERE attach_id = ' . (int)$attach_id_array[$i];
@ -218,7 +218,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
for ($j = 0; $j < $num_attach; $j++) {
unlink_attach($attachments[$j]['physical_filename']);
if (intval($attachments[$j]['thumbnail']) == 1) {
if ((int)$attachments[$j]['thumbnail'] == 1) {
unlink_attach($attachments[$j]['physical_filename'], MODE_THUMBNAIL);
}
@ -236,7 +236,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
}
// Now Sync the Topic/PM
if (sizeof($post_id_array)) {
if (count($post_id_array)) {
$sql = 'SELECT topic_id
FROM ' . BB_POSTS . '
WHERE post_id IN (' . implode(', ', $post_id_array) . ')

View file

@ -49,9 +49,7 @@ function read_word($fp)
{
$data = fread($fp, 2);
$value = ord($data[1]) * 256 + ord($data[0]);
return $value;
return ord($data[1]) * 256 + ord($data[0]);
}
/**
@ -61,9 +59,7 @@ function read_byte($fp)
{
$data = fread($fp, 1);
$value = ord($data);
return $value;
return ord($data);
}
/**
@ -179,7 +175,7 @@ function image_getdimension($file)
$tmp_str = fread($fp, 4);
$w1 = read_word($fp);
if (intval($w1) < 16) {
if ((int)$w1 < 16) {
$error = true;
}
@ -187,7 +183,7 @@ function image_getdimension($file)
$tmp_str = fread($fp, 4);
if ($tmp_str == 'JFIF') {
$o_byte = fread($fp, 1);
if (intval($o_byte) != 0) {
if ((int)$o_byte != 0) {
$error = true;
}

View file

@ -30,7 +30,7 @@ function attach_build_auth_levels($is_auth, &$s_auth_can)
{
global $lang, $attach_config;
if (intval($attach_config['disable_mod'])) {
if ((int)$attach_config['disable_mod']) {
return;
}

View file

@ -50,7 +50,7 @@ function group_select($select_name, $default_group = 0)
$group_name[$num_rows]['group_id'] = 0;
$group_name[$num_rows]['group_name'] = $lang['NOT_ASSIGNED'];
for ($i = 0; $i < sizeof($group_name); $i++) {
for ($i = 0, $iMax = count($group_name); $i < $iMax; $i++) {
if (!$default_group) {
$selected = ($i == 0) ? ' selected="selected"' : '';
} else {
@ -93,7 +93,7 @@ function download_select($select_name, $group_id = 0)
$group_select = '<select name="' . $select_name . '">';
for ($i = 0; $i < sizeof($types_download); $i++) {
for ($i = 0, $iMax = count($types_download); $i < $iMax; $i++) {
if (!$group_id) {
$selected = ($types_download[$i] == INLINE_LINK) ? ' selected="selected"' : '';
} else {
@ -138,14 +138,14 @@ function category_select($select_name, $group_id = 0)
$types = array(NONE_CAT);
$modes = array('none');
for ($i = 0; $i < sizeof($types_category); $i++) {
for ($i = 0, $iMax = count($types_category); $i < $iMax; $i++) {
$types[] = $types_category[$i];
$modes[] = $modes_category[$i];
}
$group_select = '<select name="' . $select_name . '" style="width:100px">';
for ($i = 0; $i < sizeof($types); $i++) {
for ($i = 0, $iMax = count($types); $i < $iMax; $i++) {
if (!$group_id) {
$selected = ($types[$i] == NONE_CAT) ? ' selected="selected"' : '';
} else {
@ -172,7 +172,7 @@ function size_select($select_name, $size_compare)
$select_field = '<select name="' . $select_name . '">';
for ($i = 0; $i < sizeof($size_types_text); $i++) {
for ($i = 0, $iMax = count($size_types_text); $i < $iMax; $i++) {
$selected = ($size_compare == $size_types[$i]) ? ' selected="selected"' : '';
$select_field .= '<option value="' . $size_types[$i] . '"' . $selected . '>' . $size_types_text[$i] . '</option>';
}
@ -204,7 +204,7 @@ function quota_limit_select($select_name, $default_quota = 0)
}
DB()->sql_freeresult($result);
for ($i = 0; $i < sizeof($quota_name); $i++) {
for ($i = 0, $iMax = count($quota_name); $i < $iMax; $i++) {
$selected = ($quota_name[$i]['quota_limit_id'] == $default_quota) ? ' selected="selected"' : '';
$quota_select .= '<option value="' . $quota_name[$i]['quota_limit_id'] . '"' . $selected . '>' . $quota_name[$i]['quota_desc'] . '</option>';
}
@ -235,7 +235,7 @@ function default_quota_limit_select($select_name, $default_quota = 0)
}
DB()->sql_freeresult($result);
for ($i = 0; $i < sizeof($quota_name); $i++) {
for ($i = 0, $iMax = count($quota_name); $i < $iMax; $i++) {
$selected = ($quota_name[$i]['quota_limit_id'] == $default_quota) ? ' selected="selected"' : '';
$quota_select .= '<option value="' . $quota_name[$i]['quota_limit_id'] . '"' . $selected . '>' . $quota_name[$i]['quota_desc'] . '</option>';
}

View file

@ -778,7 +778,7 @@ class attach_parent
$row = DB()->sql_fetchrow($result);
DB()->sql_freeresult($result);
$allowed_filesize = $row['max_filesize'] ? $row['max_filesize'] : $attach_config['max_filesize'];
$allowed_filesize = $row['max_filesize'] ?: $attach_config['max_filesize'];
$cat_id = (int) $row['cat_id'];
$auth_cache = trim($row['forum_permissions']);

View file

@ -256,7 +256,7 @@ function strip_quotes($text)
if ($stacksize == 0) {
$newtext .= substr($text, $substr_pos, $pos - $substr_pos);
}
array_push($stack, $pos);
$stack[] = $pos;
} else {
// pop off the latest opened tag
if ($stacksize) {
@ -394,20 +394,20 @@ function add_search_words($post_id, $post_message, $topic_title = '', $only_retu
if ($only_return_words || $bb_cfg['search_engine_type'] == 'sphinx') {
return join("\n", $words);
} else {
}
DB()->query("DELETE FROM " . BB_POSTS_SEARCH . " WHERE post_id = $post_id");
if ($words_sql = DB()->escape(join("\n", $words))) {
if ($words_sql = DB()->escape(implode("\n", $words))) {
DB()->query("REPLACE INTO " . BB_POSTS_SEARCH . " (post_id, search_words) VALUES ($post_id, '$words_sql')");
}
}
}
class bbcode
{
public $tpl = array(); // шаблоны для замены тегов
public $smilies = null; // смайлы
public $found_spam = null; // найденные спам "слова"
public $smilies; // смайлы
public $found_spam; // найденные спам "слова"
public $del_words = array(); // см. get_words_rate()
public $tidy_cfg = array(
'drop-empty-paras' => false,
@ -524,7 +524,7 @@ class bbcode
global $bb_cfg;
$text = " $text ";
$text = $this->clean_up($text);
$text = static::clean_up($text);
$text = $this->spam_filter($text);
// Tag parse
@ -593,7 +593,7 @@ class bbcode
if (!$bb_cfg['spam_filter_file_path']) {
return $text;
}
if (is_null($spam_words)) {
if (null === $spam_words) {
$spam_words = file_get_contents($bb_cfg['spam_filter_file_path']);
$spam_words = strtolower($spam_words);
$spam_words = explode("\n", $spam_words);
@ -738,7 +738,7 @@ class bbcode
{
global $datastore;
if (is_null($this->smilies)) {
if (null === $this->smilies) {
$this->smilies = $datastore->get('smile_replacements');
}
if ($this->smilies) {

View file

@ -31,7 +31,7 @@ class cache_apc extends cache_common
{
public $used = true;
public $engine = 'APC';
public $prefix = null;
public $prefix;
public function __construct($prefix = null)
{

View file

@ -67,7 +67,7 @@ class cache_common
public $dbg = array();
public $dbg_id = 0;
public $dbg_enabled = false;
public $cur_query = null;
public $cur_query;
public function debug($mode, $cur_query = null)
{

View file

@ -31,8 +31,8 @@ class cache_file extends cache_common
{
public $used = true;
public $engine = 'Filecache';
public $dir = null;
public $prefix = null;
public $dir;
public $prefix;
public function __construct($dir, $prefix = null)
{

View file

@ -31,9 +31,9 @@ class cache_memcache extends cache_common
{
public $used = true;
public $engine = 'Memcache';
public $cfg = null;
public $prefix = null;
public $memcache = null;
public $cfg;
public $prefix;
public $memcache;
public $connected = false;
public function __construct($cfg, $prefix = null)

View file

@ -31,9 +31,9 @@ class cache_redis extends cache_common
{
public $used = true;
public $engine = 'Redis';
public $cfg = null;
public $redis = null;
public $prefix = null;
public $cfg;
public $redis;
public $prefix;
public $connected = false;
public function __construct($cfg, $prefix = null)

View file

@ -30,8 +30,8 @@ if (!defined('BB_ROOT')) {
class cache_sqlite extends cache_common
{
public $used = true;
public $db = null;
public $prefix = null;
public $db;
public $prefix;
public $cfg = array(
'db_file_path' => '/path/to/cache.db.sqlite',
'table_name' => 'cache',
@ -70,7 +70,7 @@ class cache_sqlite extends cache_common
$rowset = $this->db->fetch_rowset("
SELECT cache_name, cache_value
FROM " . $this->cfg['table_name'] . "
WHERE cache_name IN('$this->prefix_sql" . join("','$this->prefix_sql", $name_sql) . "') AND cache_expire_time > " . TIMENOW . "
WHERE cache_name IN('$this->prefix_sql" . implode("','$this->prefix_sql", $name_sql) . "') AND cache_expire_time > " . TIMENOW . "
LIMIT " . count($name) . "
");
@ -137,7 +137,7 @@ class sqlite_common extends cache_common
'shard_val' => 0, # для string - кол. начальных символов, для int - делитель (будет использован остаток от деления)
);
public $engine = 'SQLite';
public $dbh = null;
public $dbh;
public $connected = false;
public $shard_val = false;

View file

@ -31,7 +31,7 @@ class cache_xcache extends cache_common
{
public $used = true;
public $engine = 'XCache';
public $prefix = null;
public $prefix;
public function __construct($prefix = null)
{

View file

@ -2956,7 +2956,7 @@ class Text_LangCorrect
*/
#0a. английский --> русский:
if (substr($word, 1, 1) === '.' #оптимизация
if ($word[1] === '.' #оптимизация
&& preg_match('/^ ( ' . $this->en_similar_uc . '\. #первый инициал
(?:' . $this->en_similar_uc . '\.)? #второй инициал (необязательно)
) #1 инициалы
@ -2973,7 +2973,7 @@ class Text_LangCorrect
}
#0b. русский --> английский:
if (substr($word, 2, 1) === '.' #оптимизация
if ($word[2] === '.' #оптимизация
&& preg_match('/^ ( ' . $this->ru_similar_uc . '\. #первый инициал
(?:' . $this->ru_similar_uc . '\.)? #второй инициал (необязательно)
) #1 инициалы
@ -3175,7 +3175,7 @@ class Text_LangCorrect
$ss = ' ' . $ss;
} #beginning of word
elseif ($pos === $limit - 1) {
$ss = $ss . ' ';
$ss .= ' ';
} #ending of word
if (array_key_exists($ss, $this->bigrams)) {
return true;

View file

@ -130,7 +130,7 @@ class emailer
}
}
if (!($fd = @fopen($tpl_file, 'r'))) {
if (!($fd = @fopen($tpl_file, 'rb'))) {
bb_die('Failed opening template file :: ' . $tpl_file);
}
@ -198,7 +198,7 @@ class emailer
// Build header
$type = ($email_format == 'html') ? 'html' : 'plain';
$this->extra_headers = (($this->reply_to != '') ? "Reply-to: $this->reply_to\n" : '') . (($this->from != '') ? "From: $this->from\n" : "From: " . $bb_cfg['board_email'] . "\n") . "Return-Path: " . $bb_cfg['board_email'] . "\nMessage-ID: <" . md5(uniqid(TIMENOW)) . "@" . $bb_cfg['server_name'] . ">\nMIME-Version: 1.0\nContent-type: text/$type; charset=" . $this->encoding . "\nContent-transfer-encoding: 8bit\nDate: " . date('r', TIMENOW) . "\nX-Priority: 0\nX-MSMail-Priority: Normal\nX-Mailer: Microsoft Office Outlook, Build 11.0.5510\nX-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441\nX-Sender: " . $bb_cfg['board_email'] . "\n" . $this->extra_headers . (($cc != '') ? "Cc: $cc\n" : '') . (($bcc != '') ? "Bcc: $bcc\n" : '');
$this->extra_headers = (($this->reply_to != '') ? "Reply-to: $this->reply_to\n" : '') . (($this->from != '') ? "From: $this->from\n" : "From: " . $bb_cfg['board_email'] . "\n") . "Return-Path: " . $bb_cfg['board_email'] . "\nMessage-ID: <" . md5(uniqid(TIMENOW, true)) . "@" . $bb_cfg['server_name'] . ">\nMIME-Version: 1.0\nContent-type: text/$type; charset=" . $this->encoding . "\nContent-transfer-encoding: 8bit\nDate: " . date('r', TIMENOW) . "\nX-Priority: 0\nX-MSMail-Priority: Normal\nX-Mailer: Microsoft Office Outlook, Build 11.0.5510\nX-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441\nX-Sender: " . $bb_cfg['board_email'] . "\n" . $this->extra_headers . (($cc != '') ? "Cc: $cc\n" : '') . (($bcc != '') ? "Bcc: $bcc\n" : '');
// Send message
if ($this->use_smtp) {

View file

@ -170,7 +170,7 @@ class ReflectionTypeHint
// Dummy frame before call_user_func*() frames.
if (!isset($t['file']) && $next) {
$t['over_function'] = $trace[$i + 1]['function'];
$t = $t + $trace[$i + 1];
$t += $trace[$i + 1];
$trace[$i + 1] = null; // skip call_user_func on next iteration
}

View file

@ -123,8 +123,8 @@ class sitemap
$this->priority = $this->topic_priority;
if ($page) {
$page = $page - 1;
$page = $page * 40000;
--$page;
$page *= 40000;
$this->limit = " LIMIT {$page},40000";
} else {
if ($this->limit < 1) {

View file

@ -2275,7 +2275,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s)) {
if (null === $s) {
return $s;
}
@ -2324,7 +2324,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s)) {
if (null === $s) {
return $s;
}
@ -2568,7 +2568,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s)) {
if (null === $s) {
return $s;
}
return preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F]+/sSX', '', $s);
@ -2602,7 +2602,7 @@ class utf8
if (is_string($data)) {
return ltrim($data, "\x00..\x7f") === '';
}
if (is_scalar($data) || is_null($data)) {
if (is_scalar($data) || null === $data) {
return true;
} #~ null, integer, float, boolean
return false; #object or resource
@ -2650,7 +2650,7 @@ class utf8
}
return true;
}
if (is_scalar($data) || is_null($data)) {
if (is_scalar($data) || null === $data) {
return true;
} #~ null, integer, float, boolean
return false; #object or resource
@ -2792,7 +2792,7 @@ class utf8
}#foreach
return true;
}
if (is_scalar($data) || is_null($data)) {
if (is_scalar($data) || null === $data) {
return true;
} #~ null, integer, float, boolean
return false; #object or resource
@ -2912,7 +2912,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s1) || is_null($s2)) {
if (null === $s1 || null === $s2) {
return null;
}
if (!function_exists('collator_create')) {
@ -2945,7 +2945,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s1) || is_null($s2)) {
if (null === $s1 || null === $s2) {
return null;
}
return self::strcmp(self::substr($s1, 0, $length), self::substr($s2, 0, $length));
@ -2966,7 +2966,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s1) || is_null($s2)) {
if (null === $s1 || null === $s2) {
return null;
}
return self::strcmp(self::lowercase($s1), self::lowercase($s2));
@ -2984,7 +2984,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s)) {
if (null === $s) {
return $s;
}
@ -3021,7 +3021,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($a)) {
if (null === $a) {
return $a;
}
@ -3062,7 +3062,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($char)) {
if (null === $char) {
return $char;
}
@ -3104,7 +3104,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($cp)) {
if (null === $cp) {
return $cp;
}
@ -3148,12 +3148,12 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s)) {
if (null === $s) {
return $s;
}
$length = intval($length);
$glue = strval($glue);
$length = (int)$length;
$glue = (string)$glue;
if ($length < 1) {
$length = 76;
}
@ -3433,7 +3433,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s)) {
if (null === $s) {
return $s;
}
@ -3491,7 +3491,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($subject)) {
if (null === $subject) {
return null;
}
@ -3537,7 +3537,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s)) {
if (null === $s) {
return $s;
}
@ -3628,11 +3628,11 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s)) {
if (null === $s) {
return $s;
}
$length = ($length === null) ? 1 : intval($length);
$length = ($length === null) ? 1 : (int)$length;
if ($length < 1) {
return false;
}
@ -3665,7 +3665,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s)) {
if (null === $s) {
return $s;
}
@ -3718,7 +3718,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s)) {
if (null === $s) {
return $s;
}
@ -3753,7 +3753,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s)) {
if (null === $s) {
return $s;
}
@ -3766,7 +3766,7 @@ class utf8
#optimization block (speed improve)
#{{{
$ascii_int = intval(self::is_ascii($s)) + intval(self::is_ascii($needle));
$ascii_int = (int)self::is_ascii($s) + (int)self::is_ascii($needle);
if ($ascii_int === 1) {
return false;
}
@ -3797,7 +3797,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s)) {
if (null === $s) {
return $s;
}
@ -3832,7 +3832,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s)) {
if (null === $s) {
return $s;
}
@ -3881,7 +3881,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s)) {
if (null === $s) {
return $s;
}
@ -3905,7 +3905,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s)) {
if (null === $s) {
return $s;
}
@ -3933,7 +3933,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s)) {
if (null === $s) {
return $s;
}
@ -3995,7 +3995,7 @@ class utf8
},
$data);
}
if (is_scalar($data) || is_null($data)) {
if (is_scalar($data) || null === $data) {
return $data;
} #~ null, integer, float, boolean
return false; #object or resource
@ -4102,7 +4102,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s)) {
if (null === $s) {
return $s;
}
@ -4130,7 +4130,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s)) {
if (null === $s) {
return $s;
}
if ($charlist === null || self::is_ascii($charlist)) {
@ -4149,7 +4149,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s)) {
if (null === $s) {
return $s;
}
if ($charlist === null || self::is_ascii($charlist)) {
@ -4168,7 +4168,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s)) {
if (null === $s) {
return $s;
}
if ($charlist === null || self::is_ascii($charlist)) {
@ -4205,7 +4205,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s)) {
if (null === $s) {
return $s;
}
@ -4224,13 +4224,13 @@ class utf8
if ($type == STR_PAD_LEFT) {
$repeat_num = ceil($pad_len / $pad_str_len);
return self::substr(str_repeat($pad_str, $repeat_num), 0, intval(floor($pad_len))) . $s;
return self::substr(str_repeat($pad_str, $repeat_num), 0, (int)floor($pad_len)) . $s;
}
if ($type == STR_PAD_BOTH) {
$pad_len /= 2;
$pad_amount_left = intval(floor($pad_len));
$pad_amount_right = intval(ceil($pad_len));
$pad_amount_left = (int)floor($pad_len);
$pad_amount_right = (int)ceil($pad_len);
$repeat_times_left = ceil($pad_amount_left / $pad_str_len);
$repeat_times_right = ceil($pad_amount_right / $pad_str_len);
@ -4412,7 +4412,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) {
return false;
}
if (is_null($s)) {
if (null === $s) {
return $s;
}
if (is_array($from)) {

View file

@ -34,10 +34,10 @@ class sql_db
{
public $cfg = [];
public $cfg_keys = ['dbhost', 'dbname', 'dbuser', 'dbpasswd', 'charset', 'persist'];
private $link = null;
public $result = null;
private $link;
public $result;
public $db_server = '';
public $selected_db = null;
public $selected_db;
public $inited = false;
public $locked = false;
@ -53,7 +53,7 @@ class sql_db
public $dbg = [];
public $dbg_id = 0;
public $dbg_enabled = false;
public $cur_query = null;
public $cur_query;
public $do_explain = false;
public $explain_hold = '';
@ -412,7 +412,7 @@ class sql_db
return ($v) ? '1' : '0';
case is_float($v):
return "'$v'";
case is_null($v):
case null === $v:
return 'NULL';
}
// if $v has unsuitable type
@ -461,34 +461,34 @@ class sql_db
$fields[] = $field;
$values[] = $this->escape($val, $check_type, $dont_escape);
}
$fields = join(', ', $fields);
$values = join(', ', $values);
$fields = implode(', ', $fields);
$values = implode(', ', $values);
$query = "($fields)\nVALUES\n($values)";
} elseif ($query_type == 'INSERT_SELECT') {
foreach ($input_ary as $field => $val) {
$fields[] = $field;
$values[] = $this->escape($val, $check_type, $dont_escape);
}
$fields = join(', ', $fields);
$values = join(', ', $values);
$fields = implode(', ', $fields);
$values = implode(', ', $values);
$query = "($fields)\nSELECT\n$values";
} elseif ($query_type == 'MULTI_INSERT') {
foreach ($input_ary as $id => $sql_ary) {
foreach ($sql_ary as $field => $val) {
$values[] = $this->escape($val, $check_type, $dont_escape);
}
$ary[] = '(' . join(', ', $values) . ')';
$ary[] = '(' . implode(', ', $values) . ')';
$values = [];
}
$fields = join(', ', array_keys($input_ary[0]));
$values = join(",\n", $ary);
$fields = implode(', ', array_keys($input_ary[0]));
$values = implode(",\n", $ary);
$query = "($fields)\nVALUES\n$values";
} elseif ($query_type == 'SELECT' || $query_type == 'UPDATE') {
foreach ($input_ary as $field => $val) {
$ary[] = "$field = " . $this->escape($val, $check_type, $dont_escape);
}
$glue = ($query_type == 'SELECT') ? "\nAND " : ",\n";
$query = join($glue, $ary);
$query = implode($glue, $ary);
}
if (!$query) {
@ -529,31 +529,31 @@ class sql_db
foreach ($sql_ary as $clause => $ary) {
switch ($clause) {
case 'SELECT':
$sql .= ($ary) ? ' SELECT ' . join(' ', $sql_ary['select_options']) . ' ' . join(', ', $ary) : '';
$sql .= ($ary) ? ' SELECT ' . implode(' ', $sql_ary['select_options']) . ' ' . implode(', ', $ary) : '';
break;
case 'FROM':
$sql .= ($ary) ? ' FROM ' . join(', ', $ary) : '';
$sql .= ($ary) ? ' FROM ' . implode(', ', $ary) : '';
break;
case 'INNER JOIN':
$sql .= ($ary) ? ' INNER JOIN ' . join(' INNER JOIN ', $ary) : '';
$sql .= ($ary) ? ' INNER JOIN ' . implode(' INNER JOIN ', $ary) : '';
break;
case 'LEFT JOIN':
$sql .= ($ary) ? ' LEFT JOIN ' . join(' LEFT JOIN ', $ary) : '';
$sql .= ($ary) ? ' LEFT JOIN ' . implode(' LEFT JOIN ', $ary) : '';
break;
case 'WHERE':
$sql .= ($ary) ? ' WHERE ' . join(' AND ', $ary) : '';
$sql .= ($ary) ? ' WHERE ' . implode(' AND ', $ary) : '';
break;
case 'GROUP BY':
$sql .= ($ary) ? ' GROUP BY ' . join(', ', $ary) : '';
$sql .= ($ary) ? ' GROUP BY ' . implode(', ', $ary) : '';
break;
case 'HAVING':
$sql .= ($ary) ? ' HAVING ' . join(' AND ', $ary) : '';
$sql .= ($ary) ? ' HAVING ' . implode(' AND ', $ary) : '';
break;
case 'ORDER BY':
$sql .= ($ary) ? ' ORDER BY ' . join(', ', $ary) : '';
$sql .= ($ary) ? ' ORDER BY ' . implode(', ', $ary) : '';
break;
case 'LIMIT':
$sql .= ($ary) ? ' LIMIT ' . join(', ', $ary) : '';
$sql .= ($ary) ? ' LIMIT ' . implode(', ', $ary) : '';
break;
}
}
@ -643,7 +643,7 @@ class sql_db
foreach ((array)$tables as $table_name) {
$tables_sql[] = "$table_name $lock_type";
}
if ($tables_sql = join(', ', $tables_sql)) {
if ($tables_sql = implode(', ', $tables_sql)) {
$this->locked = $this->sql_query("LOCK TABLES $tables_sql");
}
@ -913,7 +913,7 @@ class sql_db
$msg[] = sprintf('%05d', getmypid());
$msg[] = $this->db_server;
$msg[] = short_query($this->cur_query);
$msg = join(LOG_SEPR, $msg);
$msg = implode(LOG_SEPR, $msg);
$msg .= ($info = $this->query_info()) ? ' # ' . $info : '';
$msg .= ' # ' . $this->debug_find_source() . ' ';
$msg .= defined('IN_CRON') ? 'cron' : basename($_SERVER['REQUEST_URI']);
@ -1010,14 +1010,14 @@ class sql_db
$dbg = $this->dbg[$id];
$this->explain_out .= '
<table width="98%" cellpadding="0" cellspacing="0" class="bodyline row2 bCenter" style="border-bottom: 0px;">
<table width="98%" cellpadding="0" cellspacing="0" class="bodyline row2 bCenter" style="border-bottom: 0;">
<tr>
<th style="height: 22px; cursor: pointer;" align="left">&nbsp;' . $dbg['src'] . '&nbsp; [' . sprintf('%.4f', $dbg['time']) . ' s]&nbsp; <i>' . $dbg['info'] . '</i></th>
<th style="height: 22px; cursor: pointer;" align="right" title="Copy to clipboard" onclick="$.copyToClipboard( $(\'#' . $htid . '\').text() );">' . "$this->db_server.$this->selected_db" . ' :: Query #' . ($this->num_queries + 1) . '&nbsp;</th>
</tr>
<tr><td colspan="2">' . $this->explain_hold . '</td></tr>
</table>
<div class="sqlLog"><div id="' . $htid . '" class="sqlLogRow sqlExplain" style="padding: 0px;">' . short_query($dbg['sql'], true) . '&nbsp;&nbsp;</div></div>
<div class="sqlLog"><div id="' . $htid . '" class="sqlLogRow sqlExplain" style="padding: 0;">' . short_query($dbg['sql'], true) . '&nbsp;&nbsp;</div></div>
<br />';
break;

View file

@ -73,7 +73,7 @@ foreach ($cron_jobs as $job) {
$msg[] = sprintf('%-4s', round(sys('la'), 1));
$msg[] = sprintf('%05d', getmypid());
$msg[] = $job['cron_title'];
$msg = join(LOG_SEPR, $msg);
$msg = implode(LOG_SEPR, $msg);
bb_log($msg . LOG_LF, CRON_LOG_DIR . '/' . CRON_LOG_FILE);
}
@ -97,12 +97,12 @@ foreach ($cron_jobs as $job) {
$msg[] = sprintf('%-4s', round(sys('la'), 1));
$msg[] = sprintf('%05d', getmypid());
$msg[] = round(utime() - $cron_start_time) . '/' . round(utime() - TIMESTART) . ' sec';
$msg = join(LOG_SEPR, $msg);
$msg = implode(LOG_SEPR, $msg);
$msg .= LOG_LF . '------=-------=----------=------=-------=----------';
bb_log($msg . LOG_LF, CRON_LOG_DIR . '/' . CRON_LOG_FILE);
if ($cron_runtime_log) {
$runtime_log_file = ($job['log_file']) ? $job['log_file'] : $job['cron_script'];
$runtime_log_file = ($job['log_file']) ?: $job['cron_script'];
bb_log($cron_runtime_log . LOG_LF, CRON_LOG_DIR . '/' . basename($runtime_log_file));
}
}

View file

@ -66,13 +66,13 @@ if ($dir = @opendir($attach_dir)) {
$f_len += strlen($f) + 5;
if ($f_len > $db_max_packet) {
$files = join(',', $files);
$files = implode(',', $files);
DB()->query("INSERT INTO $tmp_attach_tbl VALUES $files");
$files = array();
$f_len = 0;
}
}
if ($files = join(',', $files)) {
if ($files = implode(',', $files)) {
DB()->query("INSERT INTO $tmp_attach_tbl VALUES $files");
}
closedir($dir);
@ -154,7 +154,7 @@ if ($check_attachments) {
$orphan_db_attach[] = $row['attach_id'];
}
// Delete all orphan attachments
if ($orphans_sql = join(',', $orphan_db_attach)) {
if ($orphans_sql = implode(',', $orphan_db_attach)) {
if ($fix_errors) {
DB()->query("DELETE FROM " . BB_ATTACHMENTS_DESC . " WHERE attach_id IN($orphans_sql)");
DB()->query("DELETE FROM " . BB_ATTACHMENTS . " WHERE attach_id IN($orphans_sql)");
@ -172,7 +172,7 @@ if ($check_attachments) {
$orphan_tor[] = $row['topic_id'];
}
// Delete all orphan torrents
if ($orphans_sql = join(',', $orphan_tor)) {
if ($orphans_sql = implode(',', $orphan_tor)) {
if ($fix_errors) {
DB()->query("DELETE FROM " . BB_BT_TORRENTS . " WHERE topic_id IN($orphans_sql)");
}
@ -188,7 +188,7 @@ if ($check_attachments) {
foreach (DB()->fetch_rowset($sql) as $row) {
$posts_without_attach[] = $row['post_id'];
}
if ($posts_sql = join(',', $posts_without_attach)) {
if ($posts_sql = implode(',', $posts_without_attach)) {
if ($fix_errors) {
DB()->query("UPDATE " . BB_POSTS . " SET post_attachment = 0 WHERE post_id IN($posts_sql)");
}
@ -204,7 +204,7 @@ if ($check_attachments) {
foreach (DB()->fetch_rowset($sql) as $row) {
$topics_without_attach[] = $row['topic_id'];
}
if ($topics_sql = join(',', $topics_without_attach)) {
if ($topics_sql = implode(',', $topics_without_attach)) {
if ($fix_errors) {
DB()->query("UPDATE " . BB_TOPICS . " SET topic_attachment = 0 WHERE topic_id IN($topics_sql)");
}

View file

@ -64,6 +64,6 @@ if ($poll_max_days = (int)$bb_cfg['poll_max_days']) {
DB()->query("UPDATE " . BB_USERS . " SET user_newpasswd = '' WHERE user_lastvisit < " . (TIMENOW - 7 * 86400));
// Чистка кеша постов
if ($posts_days = intval($bb_cfg['posts_cache_days_keep'])) {
if ($posts_days = (int)$bb_cfg['posts_cache_days_keep']) {
DB()->query("DELETE FROM " . BB_POSTS_HTML . " WHERE post_html_time < DATE_SUB(NOW(), INTERVAL $posts_days DAY)");
}

View file

@ -47,7 +47,7 @@ foreach ($keeping_dlstat as $dl_status => $days_to_keep) {
}
}
if ($delete_dlstat_sql = join(') OR (', $delete_dlstat_sql)) {
if ($delete_dlstat_sql = implode(') OR (', $delete_dlstat_sql)) {
DB()->query("DELETE QUICK FROM " . BB_BT_DLSTATUS . " WHERE ($delete_dlstat_sql)");
}
@ -67,7 +67,7 @@ DB()->query("
");
// Tor-Stats cleanup
if ($torstat_days_keep = intval($bb_cfg['torstat_days_keep'])) {
if ($torstat_days_keep = (int)$bb_cfg['torstat_days_keep']) {
DB()->query("DELETE QUICK FROM " . BB_BT_TORSTAT . " WHERE last_modified_torstat < DATE_SUB(NOW(), INTERVAL $torstat_days_keep DAY)");
}

View file

@ -36,7 +36,7 @@ while (true) {
$prune_users = $not_activated_users = $not_active_users = array();
if ($not_activated_days = intval($bb_cfg['user_not_activated_days_keep'])) {
if ($not_activated_days = (int)$bb_cfg['user_not_activated_days_keep']) {
$sql = DB()->fetch_rowset("SELECT user_id FROM " . BB_USERS . "
WHERE user_level = 0
AND user_lastvisit = 0
@ -50,7 +50,7 @@ while (true) {
}
}
if ($not_active_days = intval($bb_cfg['user_not_active_days_keep'])) {
if ($not_active_days = (int)$bb_cfg['user_not_active_days_keep']) {
$sql = DB()->fetch_rowset("SELECT user_id FROM " . BB_USERS . "
WHERE user_level = 0
AND user_posts = 0

View file

@ -27,10 +27,10 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__));
}
$user_session_expire_time = TIMENOW - intval($bb_cfg['user_session_duration']);
$admin_session_expire_time = TIMENOW - intval($bb_cfg['admin_session_duration']);
$user_session_expire_time = TIMENOW - (int)$bb_cfg['user_session_duration'];
$admin_session_expire_time = TIMENOW - (int)$bb_cfg['admin_session_duration'];
$user_session_gc_time = $user_session_expire_time - intval($bb_cfg['user_session_gc_ttl']);
$user_session_gc_time = $user_session_expire_time - (int)$bb_cfg['user_session_gc_ttl'];
$admin_session_gc_time = $admin_session_expire_time;
// ############################ Tables LOCKED ################################

View file

@ -81,8 +81,8 @@ DB()->query("
// Clean peers table
if ($tr_cfg['autoclean']) {
$announce_interval = max(intval($bb_cfg['announce_interval']), 60);
$expire_factor = max(floatval($tr_cfg['expire_factor']), 1);
$announce_interval = max((int)$bb_cfg['announce_interval'], 60);
$expire_factor = max((float)$tr_cfg['expire_factor'], 1);
$peer_expire_time = TIMENOW - floor($announce_interval * $expire_factor);
DB()->query("DELETE FROM " . BB_BT_TRACKER . " WHERE update_time < $peer_expire_time");

View file

@ -47,8 +47,8 @@ foreach (DB()->fetch_rowset($sql) as $row) {
$topics_sql[] = $row['topic_id'];
$attach_sql[] = $row['attach_id'];
}
$dead_tor_sql = join(',', $topics_sql);
$attach_sql = join(',', $attach_sql);
$dead_tor_sql = implode(',', $topics_sql);
$attach_sql = implode(',', $attach_sql);
if ($dead_tor_sql && $attach_sql) {
// Delete torstat

View file

@ -73,7 +73,7 @@ while (true) {
}
foreach (DB()->fetch_rowset($sql) as $row) {
$val[] = join(',', $row);
$val[] = implode(',', $row);
}
if ($val) {
@ -81,13 +81,13 @@ while (true) {
DB()->query("
REPLACE INTO " . NEW_BB_BT_TRACKER_SNAP . "
(topic_id, seeders, leechers, speed_up, speed_down)
VALUES(" . join('),(', $val) . ")
VALUES(" . implode('),(', $val) . ")
");
} else {
DB()->query("
INSERT INTO " . BB_BT_TRACKER_SNAP . "
(topic_id, speed_up, speed_down)
VALUES(" . join('),(', $val) . ")
VALUES(" . implode('),(', $val) . ")
ON DUPLICATE KEY UPDATE speed_up = VALUES(speed_up), speed_down = VALUES(speed_down)
");
}
@ -179,7 +179,7 @@ if ($bb_cfg['torhelp_enabled']) {
$online_users_ary[] = $row['uid'];
}
if ($online_users_csv = join(',', $online_users_ary)) {
if ($online_users_csv = implode(',', $online_users_ary)) {
DB()->query("
INSERT INTO " . NEW_BB_BT_TORHELP . " (user_id, topic_id_csv)
SELECT

View file

@ -30,7 +30,7 @@ if (!defined('BB_ROOT')) {
class datastore_apc extends datastore_common
{
public $engine = 'APC';
public $prefix = null;
public $prefix;
public function __construct($prefix = null)
{

View file

@ -113,9 +113,9 @@ foreach (DB()->fetch_rowset($sql) as $row) {
$data['c'][$row['cat_id']]['forums'][] = $fid;
}
foreach ($data['not_auth_forums'] as $key => $val) {
$data['not_auth_forums'][$key] = join(',', $val);
$data['not_auth_forums'][$key] = implode(',', $val);
}
$data['tracker_forums'] = join(',', $data['tracker_forums']);
$data['tracker_forums'] = implode(',', $data['tracker_forums']);
$this->store('cat_forums', $data);

View file

@ -149,7 +149,7 @@ class datastore_common
public $dbg = array();
public $dbg_id = 0;
public $dbg_enabled = false;
public $cur_query = null;
public $cur_query;
public function debug($mode, $cur_query = null)
{

View file

@ -29,8 +29,8 @@ if (!defined('BB_ROOT')) {
class datastore_file extends datastore_common
{
public $dir = null;
public $prefix = null;
public $dir;
public $prefix;
public $engine = 'Filecache';
public function __construct($dir, $prefix = null)

View file

@ -29,11 +29,11 @@ if (!defined('BB_ROOT')) {
class datastore_memcache extends datastore_common
{
public $cfg = null;
public $memcache = null;
public $cfg;
public $memcache;
public $connected = false;
public $engine = 'Memcache';
public $prefix = null;
public $prefix;
public function __construct($cfg, $prefix = null)
{

View file

@ -29,9 +29,9 @@ if (!defined('BB_ROOT')) {
class datastore_redis extends datastore_common
{
public $cfg = null;
public $redis = null;
public $prefix = null;
public $cfg;
public $redis;
public $prefix;
public $connected = false;
public $engine = 'Redis';

View file

@ -30,8 +30,8 @@ if (!defined('BB_ROOT')) {
class datastore_sqlite extends datastore_common
{
public $engine = 'SQLite';
public $db = null;
public $prefix = null;
public $db;
public $prefix;
public $cfg = array(
'db_file_path' => '/path/to/datastore.db.sqlite',
'table_name' => 'datastore',
@ -79,7 +79,7 @@ class datastore_sqlite extends datastore_common
$prefix_sql = SQLite3::escapeString($this->prefix);
array_deep($items, 'SQLite3::escapeString');
$items_list = $prefix_sql . join("','$prefix_sql", $items);
$items_list = $prefix_sql . implode("','$prefix_sql", $items);
$rowset = $this->db->fetch_rowset("SELECT ds_title, ds_data FROM " . $this->cfg['table_name'] . " WHERE ds_title IN ('$items_list')");

View file

@ -29,7 +29,7 @@ if (!defined('BB_ROOT')) {
class datastore_xcache extends datastore_common
{
public $prefix = null;
public $prefix;
public $engine = 'XCache';
public function __construct($prefix = null)

View file

@ -72,7 +72,7 @@ function get_tracks($type)
trigger_error(__FUNCTION__ . ": invalid type '$type'", E_USER_ERROR);
}
$tracks = !empty($_COOKIE[$c_name]) ? @unserialize($_COOKIE[$c_name]) : false;
return ($tracks) ? $tracks : array();
return ($tracks) ?: array();
}
function set_tracks($cookie_name, &$tracking_ary, $tracks = null, $val = TIMENOW)
@ -348,7 +348,7 @@ function setbit(&$int, $bit_num, $on)
forum auth levels, this will prevent the auth function having to do its own
lookup
*/
function auth($type, $forum_id, $ug_data, $f_access = array(), $group_perm = UG_PERM_BOTH)
function auth($type, $forum_id, $ug_data, array $f_access = array(), $group_perm = UG_PERM_BOTH)
{
global $lang, $bf, $datastore;
@ -583,7 +583,7 @@ class Date_Delta
break;
}
}
return join(' ', $parts);
return implode(' ', $parts);
}
// returns the associative array with date deltas.
@ -676,7 +676,7 @@ class html_common
{
public $options = '';
public $attr = array();
public $cur_attr = null;
public $cur_attr;
public $max_length = HTML_SELECT_MAX_LENGTH;
public $selected = array();
@ -838,12 +838,12 @@ function declension($int, $expressions, $format = '%1$s %2$s')
if (count($expressions) < 3) {
$expressions[2] = $expressions[1];
}
$count = intval($int) % 100;
$count = (int)$int % 100;
if ($count >= 5 && $count <= 20) {
$result = $expressions['2'];
} else {
$count = $count % 10;
$count %= 10;
if ($count == 1) {
$result = $expressions['0'];
} elseif ($count >= 2 && $count <= 4) {
@ -870,10 +870,10 @@ function url_arg($url, $arg, $value, $amp = '&amp;')
// заменяем параметр, если он существует
if (preg_match("/((\?|&|&amp;)$arg=)[^&]*/s", $url, $m)) {
$cur = $m[0];
$new = is_null($value) ? '' : $m[1] . urlencode($value);
$new = null === $value ? '' : $m[1] . urlencode($value);
$url = str_replace($cur, $new, $url);
} // добавляем параметр
elseif (!is_null($value)) {
elseif (null !== $value) {
$div = (strpos($url, '?') !== false) ? $amp : '?';
$url = $url . $div . $arg . '=' . urlencode($value);
}
@ -901,12 +901,12 @@ function humn_size($size, $rounder = null, $min = null, $space = '&nbsp;')
$rnd = $rounders[0];
if ($min == 'KB' && $size < 1024) {
$size = $size / 1024;
$size /= 1024;
$ext = 'KB';
$rounder = 1;
} else {
for ($i = 1, $cnt = count($sizes); ($i < $cnt && $size >= 1024); $i++) {
$size = $size / 1024;
$size /= 1024;
$ext = $sizes[$i];
$rnd = $rounders[$i];
}
@ -969,7 +969,7 @@ function select_get_val($key, &$val, $options_ary, $default, $num = true)
if (isset($_REQUEST[$key]) && is_string($_REQUEST[$key])) {
if (isset($options_ary[$_REQUEST[$key]])) {
$val = ($num) ? intval($_REQUEST[$key]) : $_REQUEST[$key];
$val = ($num) ? (int)$_REQUEST[$key] : $_REQUEST[$key];
}
} elseif (isset($previous_settings[$key])) {
$val = $previous_settings[$key];
@ -1100,7 +1100,7 @@ function str_short($text, $max_length, $space = ' ')
if ($max_length && mb_strlen($text, 'UTF-8') > $max_length) {
$text = mb_substr($text, 0, $max_length, 'UTF-8');
if ($last_space_pos = $max_length - intval(strpos(strrev($text), $space))) {
if ($last_space_pos = $max_length - (int)strpos(strrev($text), $space)) {
if ($last_space_pos > round($max_length * 3 / 4)) {
$last_space_pos--;
$text = mb_substr($text, 0, $last_space_pos, 'UTF-8');
@ -1158,7 +1158,7 @@ function show_bt_userdata($user_id)
'USER_RATIO' => get_bt_ratio($btu),
'MIN_DL_FOR_RATIO' => humn_size(MIN_DL_FOR_RATIO),
'MIN_DL_BYTES' => MIN_DL_FOR_RATIO,
'AUTH_KEY' => ($btu['auth_key']) ? $btu['auth_key'] : $lang['NONE'],
'AUTH_KEY' => ($btu['auth_key']) ?: $lang['NONE'],
'TD_DL' => humn_size($btu['down_today']),
'TD_UL' => humn_size($btu['up_today']),
@ -1300,7 +1300,7 @@ function get_userdata($u, $force_name = false, $allow_guest = false)
return false;
}
if (intval($u) == GUEST_UID && $allow_guest) {
if ((int)$u == GUEST_UID && $allow_guest) {
if ($u_data = CACHE('bb_cache')->get('guest_userdata')) {
return $u_data;
}
@ -1357,10 +1357,10 @@ function get_forum_select($mode = 'guest', $name = POST_FORUM_URL, $selected = n
$not_auth_forums_fary = array_flip($mode);
$mode = 'not_auth_forums';
}
if (is_null($max_length)) {
if (null === $max_length) {
$max_length = HTML_SELECT_MAX_LENGTH;
}
$select = is_null($all_forums_option) ? array() : array($lang['ALL_AVAILABLE'] => $all_forums_option);
$select = null === $all_forums_option ? array() : array($lang['ALL_AVAILABLE'] => $all_forums_option);
if (!$forums = $datastore->get('cat_forums')) {
$datastore->update('cat_forums');
$forums = $datastore->get('cat_forums');
@ -1442,9 +1442,7 @@ function setup_style()
require TEMPLATES_DIR . '/' . $tpl_dir_name . '/tpl_config.php';
$theme = array('template_name' => $tpl_dir_name);
return $theme;
return array('template_name' => $tpl_dir_name);
}
// Create date / time with format and friendly date
@ -1725,7 +1723,7 @@ function bb_realpath($path)
function login_redirect($url = '')
{
redirect(LOGIN_URL . '?redirect=' . (($url) ? $url : (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/')));
redirect(LOGIN_URL . '?redirect=' . (($url) ?: (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/')));
}
function meta_refresh($url, $time = 5)
@ -1743,7 +1741,7 @@ function redirect($url)
trigger_error("Headers already sent in $filename($linenum)", E_USER_ERROR);
}
if (strstr(urldecode($url), "\n") || strstr(urldecode($url), "\r") || strstr(urldecode($url), ';url')) {
if (false !== strpos(urldecode($url), "\n") || false !== strpos(urldecode($url), "\r") || false !== strpos(urldecode($url), ';url')) {
bb_die('Tried to redirect to potentially insecure url');
}
@ -1792,7 +1790,7 @@ function get_forum_display_sort_option($selected_row = 0, $action = 'list', $lis
// build list
if ($action == 'list') {
for ($i = 0; $i < count($listrow['lang_key']); $i++) {
for ($i = 0, $iMax = count($listrow['lang_key']); $i < $iMax; $i++) {
$selected = ($i == $selected_row) ? ' selected="selected"' : '';
$l_value = (isset($lang[$listrow['lang_key'][$i]])) ? $lang[$listrow['lang_key'][$i]] : $listrow['lang_key'][$i];
$res .= '<option value="' . $i . '"' . $selected . '>' . $l_value . '</option>';
@ -1917,7 +1915,7 @@ function get_id_csv($ids)
{
$ids = array_values((array)$ids);
array_deep($ids, 'intval', 'one-dimensional');
return (string)join(',', $ids);
return (string)implode(',', $ids);
}
// $ids - array(id1,id2,..) or (string) id1,id2,..
@ -1975,7 +1973,7 @@ class log_action
}
}
public function mod($type_name, $args = array())
public function mod($type_name, array $args = array())
{
global $userdata;
@ -2023,7 +2021,7 @@ class log_action
DB()->query("INSERT INTO " . BB_LOG . " $sql_args");
}
public function admin($type_name, $args = array())
public function admin($type_name, array $args = array())
{
$this->mod($type_name, $args);
}
@ -2034,7 +2032,7 @@ function get_topic_icon($topic, $is_unread = null)
global $bb_cfg, $images;
$t_hot = ($topic['topic_replies'] >= $bb_cfg['hot_threshold']);
$is_unread = is_null($is_unread) ? is_unread($topic['topic_last_post_time'], $topic['topic_id'], $topic['forum_id']) : $is_unread;
$is_unread = null === $is_unread ? is_unread($topic['topic_last_post_time'], $topic['topic_id'], $topic['forum_id']) : $is_unread;
if ($topic['topic_status'] == TOPIC_MOVED) {
$folder_image = $images['folder'];
@ -2237,9 +2235,9 @@ function init_sphinx()
if (!isset($sphinx)) {
$sphinx = \Sphinx\SphinxClient::create();
$sphinx->SetConnectTimeout(5);
$sphinx->SetRankingMode($sphinx::SPH_RANK_NONE);
$sphinx->SetMatchMode($sphinx::SPH_MATCH_BOOLEAN);
$sphinx->setConnectTimeout(5);
$sphinx->setRankingMode($sphinx::SPH_RANK_NONE);
$sphinx->setMatchMode($sphinx::SPH_MATCH_BOOLEAN);
}
return $sphinx;
@ -2251,13 +2249,13 @@ function log_sphinx_error($err_type, $err_msg, $query = '')
'negation on top level',
'Query word length is less than min prefix length',
);
if (!count($ignore_err_txt) || !preg_match('#' . join('|', $ignore_err_txt) . '#i', $err_msg)) {
if (!count($ignore_err_txt) || !preg_match('#' . implode('|', $ignore_err_txt) . '#i', $err_msg)) {
$orig_query = strtr($_REQUEST['nm'], array("\n" => '\n'));
bb_log(date('m-d H:i:s') . " | $err_type | $err_msg | $orig_query | $query" . LOG_LF, 'sphinx_error');
}
}
function get_title_match_topics($title_match_sql, $forum_ids = array())
function get_title_match_topics($title_match_sql, array $forum_ids = array())
{
global $bb_cfg, $sphinx, $userdata, $title_match, $lang;
@ -2272,28 +2270,28 @@ function get_title_match_topics($title_match_sql, $forum_ids = array())
$where = ($title_match) ? 'topics' : 'posts';
$sphinx->SetServer($bb_cfg['sphinx_topic_titles_host'], $bb_cfg['sphinx_topic_titles_port']);
$sphinx->setServer($bb_cfg['sphinx_topic_titles_host'], $bb_cfg['sphinx_topic_titles_port']);
if ($forum_ids) {
$sphinx->SetFilter('forum_id', $forum_ids, false);
$sphinx->setFilter('forum_id', $forum_ids, false);
}
if (preg_match('#^"[^"]+"$#u', $title_match_sql)) {
$sphinx->SetMatchMode($sphinx::SPH_MATCH_PHRASE);
$sphinx->setMatchMode($sphinx::SPH_MATCH_PHRASE);
}
if ($result = $sphinx->Query($title_match_sql, $where, $userdata['username'] . ' (' . CLIENT_IP . ')')) {
if ($result = $sphinx->query($title_match_sql, $where, $userdata['username'] . ' (' . CLIENT_IP . ')')) {
if (!empty($result['matches'])) {
$where_ids = array_keys($result['matches']);
}
} elseif ($error = $sphinx->GetLastError()) {
} elseif ($error = $sphinx->getLastError()) {
if (strpos($error, 'errno=110')) {
bb_die($lang['SEARCH_ERROR']);
}
log_sphinx_error('ERR', $error, $title_match_sql);
}
if ($warning = $sphinx->GetLastWarning()) {
if ($warning = $sphinx->getLastWarning()) {
log_sphinx_error('wrn', $warning, $title_match_sql);
}
} elseif ($bb_cfg['search_engine_type'] == 'mysql') {
$where_forum = ($forum_ids) ? "AND forum_id IN(" . join(',', $forum_ids) . ")" : '';
$where_forum = ($forum_ids) ? "AND forum_id IN(" . implode(',', $forum_ids) . ")" : '';
$search_bool_mode = ($bb_cfg['allow_search_in_bool_mode']) ? ' IN BOOLEAN MODE' : '';
if ($title_match) {

View file

@ -58,7 +58,7 @@ function sync($type, $id)
// начальное обнуление значений
$forum_ary = explode(',', $forum_csv);
DB()->query("REPLACE INTO $tmp_sync_forums (forum_id) VALUES(" . join('),(', $forum_ary) . ")");
DB()->query("REPLACE INTO $tmp_sync_forums (forum_id) VALUES(" . implode('),(', $forum_ary) . ")");
DB()->query("
REPLACE INTO $tmp_sync_forums
@ -761,5 +761,5 @@ function get_usernames_for_log($user_id)
}
}
return join(', ', $users_log_msg);
return implode(', ', $users_log_msg);
}

View file

@ -43,11 +43,11 @@ function update_table_bool($table_name, $key, $field_name, $field_def_val)
$in_sql = array();
foreach ($_POST[$field_name] as $i => $val) {
$in_sql[] = intval($val);
$in_sql[] = (int)$val;
}
// Update status
if ($in_sql = join(',', $in_sql)) {
if ($in_sql = implode(',', $in_sql)) {
$sql = "UPDATE $table_name
SET $field_name = 1
WHERE $key IN($in_sql)";
@ -109,7 +109,7 @@ function update_config_table($table_name, $default_cfg, $cfg, $type)
} elseif ($type == 'bool') {
$config_value = ($_POST[$config_name]) ? 1 : 0;
} elseif ($type == 'num') {
$config_value = abs(intval($_POST[$config_name]));
$config_value = abs((int)$_POST[$config_name]);
} else {
return;
}

View file

@ -211,7 +211,7 @@ function create_atom($file_path, $mode, $id, $title, $topics)
}
$atom .= "</feed>";
@unlink($file_path);
$fp = fopen($file_path, "w");
$fp = fopen($file_path, 'wb');
fwrite($fp, $atom);
fclose($fp);
return true;

View file

@ -70,7 +70,7 @@ function get_sql_log_html($db_obj, $log_name)
. '<span style="letter-spacing: -1px;">' . $time . ' </span>'
. '<span title="Copy to clipboard" onclick="$.copyToClipboard( $(\'#' . $id . '\').text() );" style="color: gray; letter-spacing: -1px;">' . $perc . '</span>'
. ' '
. '<span style="letter-spacing: 0px;" id="' . $id . '">' . $sql . '</span>'
. '<span style="letter-spacing: 0;" id="' . $id . '">' . $sql . '</span>'
. '<span style="color: gray"> # ' . $info . ' </span>'
. '</div>'
. "\n";

View file

@ -32,7 +32,7 @@ function update_user_level($user_id)
global $datastore;
if (is_array($user_id)) {
$user_id = join(',', $user_id);
$user_id = implode(',', $user_id);
}
$user_groups_in = ($user_id !== 'all') ? "AND ug.user_id IN($user_id)" : '';
$users_in = ($user_id !== 'all') ? "AND u.user_id IN($user_id)" : '';
@ -203,7 +203,7 @@ function store_permissions($group_id, $auth_ary)
function update_user_permissions($user_id = 'all')
{
if (is_array($user_id)) {
$user_id = join(',', $user_id);
$user_id = implode(',', $user_id);
}
$delete_in = ($user_id !== 'all') ? " WHERE user_id IN($user_id)" : '';
$users_in = ($user_id !== 'all') ? "AND ug.user_id IN($user_id)" : '';

View file

@ -318,7 +318,7 @@ function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topi
foreach ($sql as $row) {
$user_id_sql[] = ',' . $row['ban_userid'];
}
$user_id_sql = join('', $user_id_sql);
$user_id_sql = implode('', $user_id_sql);
$watch_list = DB()->fetch_rowset("SELECT u.username, u.user_id, u.user_email, u.user_lang
FROM " . BB_TOPICS_WATCH . " tw, " . BB_USERS . " u
@ -362,7 +362,7 @@ function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topi
$update_watched_sql[] = $row['user_id'];
}
$update_watched_sql = join(',', $update_watched_sql);
$update_watched_sql = implode(',', $update_watched_sql);
}
if ($update_watched_sql) {

View file

@ -31,7 +31,7 @@ function get_torrent_info($attach_id)
{
global $lang;
$attach_id = intval($attach_id);
$attach_id = (int)$attach_id;
$sql = "
SELECT
@ -162,7 +162,7 @@ function delete_torrent($attach_id, $mode = '')
{
global $lang, $reg_mode, $topic_id;
$attach_id = intval($attach_id);
$attach_id = (int)$attach_id;
$reg_mode = $mode;
if (!$torrent = get_torrent_info($attach_id)) {
@ -223,7 +223,7 @@ function change_tor_type($attach_id, $tor_status_gold)
}
$topic_id = $torrent['topic_id'];
$tor_status_gold = intval($tor_status_gold);
$tor_status_gold = (int)$tor_status_gold;
$info_hash = null;
DB()->query("UPDATE " . BB_BT_TORRENTS . " SET tor_type = $tor_status_gold WHERE topic_id = $topic_id LIMIT 1");
@ -241,7 +241,7 @@ function tracker_register($attach_id, $mode = '', $tor_status = TOR_NOT_APPROVED
{
global $bb_cfg, $lang, $reg_mode, $tr_cfg;
$attach_id = intval($attach_id);
$attach_id = (int)$attach_id;
$reg_mode = $mode;
if (!$torrent = get_torrent_info($attach_id)) {
@ -286,7 +286,7 @@ function tracker_register($attach_id, $mode = '', $tor_status = TOR_NOT_APPROVED
if ($bb_cfg['bt_disable_dht']) {
$tor['info']['private'] = (int)1;
$fp = fopen($filename, 'w+');
$fp = fopen($filename, 'wb+');
fwrite($fp, bencode($tor));
fclose($fp);
}
@ -462,7 +462,7 @@ function send_torrent_with_passkey($filename)
bb_die('This is not a bencoded file');
}
$announce = $bb_cfg['ocelot']['enabled'] ? strval($bb_cfg['ocelot']['url'] . $passkey_val . "/announce") : strval($ann_url . "?$passkey_key=$passkey_val");
$announce = $bb_cfg['ocelot']['enabled'] ? (string)($bb_cfg['ocelot']['url'] . $passkey_val . "/announce") : (string)($ann_url . "?$passkey_key=$passkey_val");
// Replace original announce url with tracker default
if ($bb_cfg['bt_replace_ann_url'] || !isset($tor['announce'])) {
@ -494,13 +494,13 @@ function send_torrent_with_passkey($filename)
$publisher_name = $bb_cfg['server_name'];
$publisher_url = make_url(TOPIC_URL . $topic_id);
$tor['publisher'] = strval($publisher_name);
$tor['publisher'] = (string)$publisher_name;
unset($tor['publisher.utf-8']);
$tor['publisher-url'] = strval($publisher_url);
$tor['publisher-url'] = (string)$publisher_url;
unset($tor['publisher-url.utf-8']);
$tor['comment'] = strval($publisher_url);
$tor['comment'] = (string)$publisher_url;
unset($tor['comment.utf-8']);
// Send torrent
@ -624,11 +624,7 @@ function ocelot_update_tracker($action, $updates)
$max_attempts = 3;
$err = false;
if (ocelot_send_request($get, $max_attempts, $err) === false) {
return false;
}
return true;
return !(ocelot_send_request($get, $max_attempts, $err) === false);
}
function ocelot_send_request($get, $max_attempts = 1, &$err = false)

View file

@ -129,13 +129,15 @@ class upload_common
return true;
}
public function store($mode = '', $params = array())
public function store($mode = '', array $params = array())
{
if ($mode == 'avatar') {
delete_avatar($params['user_id'], $params['avatar_ext_id']);
$file_path = get_avatar_path($params['user_id'], $this->file_ext_id);
return $this->_move($file_path);
} elseif ($mode == 'attach') {
}
if ($mode == 'attach') {
$file_path = get_attach_path($params['topic_id']);
return $this->_move($file_path);
} else {

View file

@ -71,7 +71,7 @@ function validate_username($username, $check_ban_and_taken = true)
foreach (DB()->fetch_rowset("SELECT disallow_username FROM " . BB_DISALLOW . " ORDER BY NULL") as $row) {
$banned_names[] = str_replace('\*', '.*?', preg_quote($row['disallow_username'], '#u'));
}
if ($banned_names_exp = join('|', $banned_names)) {
if ($banned_names_exp = implode('|', $banned_names)) {
if (preg_match("#^($banned_names_exp)$#iu", $username)) {
return $lang['USERNAME_DISALLOWED'];
}
@ -99,7 +99,7 @@ function validate_email($email, $check_ban_and_taken = true)
foreach (DB()->fetch_rowset("SELECT ban_email FROM " . BB_BANLIST . " ORDER BY NULL") as $row) {
$banned_emails[] = str_replace('\*', '.*?', preg_quote($row['ban_email'], '#'));
}
if ($banned_emails_exp = join('|', $banned_emails)) {
if ($banned_emails_exp = implode('|', $banned_emails)) {
if (preg_match("#^($banned_emails_exp)$#i", $email)) {
return sprintf($lang['EMAIL_BANNED'], $email);
}

View file

@ -26,7 +26,7 @@
if (!defined('BB_ROOT')) {
die(basename(__FILE__));
}
if (PHP_VERSION < '5.3') {
if (version_compare(PHP_VERSION, '5.3', '<')) {
die('TorrentPier requires PHP version 5.3+. Your PHP version ' . PHP_VERSION);
}
if (!defined('BB_SCRIPT')) {
@ -378,7 +378,7 @@ define('SELECT', 6);
if (!empty($banned_user_agents)) {
foreach ($banned_user_agents as $agent) {
if (strstr(USER_AGENT, $agent)) {
if (false !== strpos(USER_AGENT, $agent)) {
$filename = 'Download files by using browser';
$output = '@';
header('Content-Type: text/plain');

View file

@ -94,7 +94,7 @@ foreach (DB()->fetch_rowset($sql) as $u) {
$stat[] = "t:<span style=\"color: #1E90FF\">$t</span>";
}
$ulist[$level][] = ($stat) ? "$name<span class=\"ou_stat\" style=\"color: #707070\" title=\"{$u['session_ip']}\"> [<b>" . join(', ', $stat) . '</b>]</span>' : $name;
$ulist[$level][] = ($stat) ? "$name<span class=\"ou_stat\" style=\"color: #707070\" title=\"{$u['session_ip']}\"> [<b>" . implode(', ', $stat) . '</b>]</span>' : $name;
} else {
$guests_online = $u['ips'];
$users_cnt['guest'] = $guests_online;
@ -111,18 +111,18 @@ if ($ulist) {
if (count($users) > 200) {
$style = 'margin: 3px 0; padding: 2px 4px; border: 1px inset; height: 200px; overflow: auto;';
$block[] = "<div style=\"$style\">\n" . join(",\n", $users) . "</div>\n";
$block[] = "<div style=\"$style\">\n" . implode(",\n", $users) . "</div>\n";
$short[] = '<a href="index.php?online_full=1#online">' . $lang['USERS'] . ': ' . count($users) . '</a>';
} else {
$inline[] = join(",\n", $users);
$short[] = join(",\n", $users);
$inline[] = implode(",\n", $users);
$short[] = implode(",\n", $users);
}
$logged_online += count($users);
}
$online['userlist'] = join(",\n", $inline) . join("\n", $block);
$online_short['userlist'] = join(",\n", $short);
$online['userlist'] = implode(",\n", $inline) . implode("\n", $block);
$online_short['userlist'] = implode(",\n", $short);
}
if (!$online['userlist']) {

View file

@ -124,7 +124,7 @@ function fixSqlLog() {
echo '</div><!-- / sqlLogHead -->';
if ($sql_log) {
echo '<div class="sqlLog" id="sqlLog">' . ($sql_log ? $sql_log : '') . '</div><!-- / sqlLog --><br clear="all" />';
echo '<div class="sqlLog" id="sqlLog">' . ($sql_log ?: '') . '</div><!-- / sqlLog --><br clear="all" />';
}
?>
<script type="text/javascript">

View file

@ -153,7 +153,7 @@ $template->assign_vars(array(
'FULL_URL' => FULL_URL,
'CURRENT_TIME' => sprintf($lang['CURRENT_TIME'], bb_date(TIMENOW, $bb_cfg['last_visit_date_format'], false)),
'S_TIMEZONE' => preg_replace('/\(.*?\)/', '', sprintf($lang['ALL_TIMES'], $lang['TZ'][str_replace(',', '.', floatval($bb_cfg['board_timezone']))])),
'S_TIMEZONE' => preg_replace('/\(.*?\)/', '', sprintf($lang['ALL_TIMES'], $lang['TZ'][str_replace(',', '.', (float)$bb_cfg['board_timezone'])])),
'BOARD_TIMEZONE' => $bb_cfg['board_timezone'],
'PM_INFO' => $pm_info,
@ -248,7 +248,7 @@ if (!empty($page_cfg['show_torhelp'][BB_SCRIPT]) && !empty($userdata['torhelp'])
}
$template->assign_vars(array(
'TORHELP_TOPICS' => join("</li>\n<li>", $torhelp_topics),
'TORHELP_TOPICS' => implode("</li>\n<li>", $torhelp_topics),
));
}
}

View file

@ -90,7 +90,7 @@ if ($edit_tpl_mode) {
'TPL_COMMENT' => $tpl_data['tpl_comment'],
'TPL_RULES_POST_ID' => $tpl_data['tpl_rules_post_id'],
'TPL_LAST_EDIT_TIME' => bb_date($tpl_data['tpl_last_edit_tm'], 'd-M-y H:i'),
'TPL_LAST_EDIT_USER' => get_username(intval($tpl_data['tpl_last_edit_by'])),
'TPL_LAST_EDIT_USER' => get_username((int)$tpl_data['tpl_last_edit_by']),
'TPL_LAST_EDIT_TIMESTAMP' => $tpl_data['tpl_last_edit_tm'],
));
}

View file

@ -85,7 +85,7 @@ class user_common
/**
* Shortcuts
*/
public $id = null;
public $id;
/**
* Misc
@ -103,7 +103,7 @@ class user_common
/**
* Start session (restore existent session or create new)
*/
public function session_start($cfg = array())
public function session_start(array $cfg = array())
{
global $bb_cfg;
@ -183,7 +183,7 @@ class user_common
$login = false;
$user_id = ($bb_cfg['allow_autologin'] && $this->sessiondata['uk'] && $this->sessiondata['uid']) ? $this->sessiondata['uid'] : GUEST_UID;
if ($userdata = get_userdata(intval($user_id), false, true)) {
if ($userdata = get_userdata((int)$user_id, false, true)) {
if ($userdata['user_id'] != GUEST_UID && $userdata['user_active']) {
if (verify_id($this->sessiondata['uk'], LOGIN_KEY_LENGTH) && $this->verify_autologin_id($userdata, true, false)) {
$login = ($userdata['autologin_id'] && $this->sessiondata['uk'] === $userdata['autologin_id']);
@ -431,7 +431,7 @@ class user_common
}
// user_id
if (!empty($sd_resv['uid'])) {
$this->sessiondata['uid'] = intval($sd_resv['uid']);
$this->sessiondata['uid'] = (int)$sd_resv['uid'];
}
// sid
if (!empty($sd_resv['sid']) && verify_id($sd_resv['sid'], SID_LENGTH)) {
@ -676,7 +676,7 @@ class user_common
}
}
return join(',', $not_auth_forums);
return implode(',', $not_auth_forums);
}
/**
@ -709,7 +709,7 @@ class user_common
switch ($return_as) {
case 'csv':
return join(',', $excluded);
return implode(',', $excluded);
case 'array':
return $excluded;
case 'flip':

View file

@ -32,7 +32,7 @@ define('SMTP_INCLUDED', 1);
function server_parse($socket, $response, $line = __LINE__)
{
$server_response = '';
while (substr($server_response, 3, 1) != ' ') {
while ($server_response[3] != ' ') {
if (!($server_response = fgets($socket, 256))) {
bb_die('Could not get mail server response codes');
}
@ -53,13 +53,13 @@ function smtpmail($mail_to, $subject, $message, $headers = '')
if ($headers != '') {
if (is_array($headers)) {
if (sizeof($headers) > 1) {
$headers = join("\n", $headers);
if (count($headers) > 1) {
$headers = implode("\n", $headers);
} else {
$headers = $headers[0];
}
}
$headers = chop($headers);
$headers = rtrim($headers);
// Make sure there are no bare linefeeds in the headers
$headers = preg_replace('#(?<!\r)\n#si', "\r\n", $headers);
@ -81,7 +81,7 @@ function smtpmail($mail_to, $subject, $message, $headers = '')
$headers .= ($header != '') ? $header . "\r\n" : '';
}
$headers = chop($headers);
$headers = rtrim($headers);
$cc = explode(', ', $cc);
$bcc = explode(', ', $bcc);
}
@ -106,31 +106,31 @@ function smtpmail($mail_to, $subject, $message, $headers = '')
// Do we want to use AUTH?, send RFC2554 EHLO, else send RFC821 HELO
// This improved as provided by SirSir to accomodate
if (!empty($bb_cfg['smtp_username']) && !empty($bb_cfg['smtp_password'])) {
fputs($socket, "EHLO " . $bb_cfg['smtp_host'] . "\r\n");
fwrite($socket, "EHLO " . $bb_cfg['smtp_host'] . "\r\n");
server_parse($socket, "250", __LINE__);
fputs($socket, "AUTH LOGIN\r\n");
fwrite($socket, "AUTH LOGIN\r\n");
server_parse($socket, "334", __LINE__);
fputs($socket, base64_encode($bb_cfg['smtp_username']) . "\r\n");
fwrite($socket, base64_encode($bb_cfg['smtp_username']) . "\r\n");
server_parse($socket, "334", __LINE__);
fputs($socket, base64_encode($bb_cfg['smtp_password']) . "\r\n");
fwrite($socket, base64_encode($bb_cfg['smtp_password']) . "\r\n");
server_parse($socket, "235", __LINE__);
} else {
fputs($socket, "HELO " . $bb_cfg['smtp_host'] . "\r\n");
fwrite($socket, "HELO " . $bb_cfg['smtp_host'] . "\r\n");
server_parse($socket, "250", __LINE__);
}
// From this point onward most server response codes should be 250
// Specify who the mail is from....
fputs($socket, "MAIL FROM: <" . $bb_cfg['board_email'] . ">\r\n");
fwrite($socket, "MAIL FROM: <" . $bb_cfg['board_email'] . ">\r\n");
server_parse($socket, "250", __LINE__);
// Add an additional bit of error checking to the To field.
$mail_to = (trim($mail_to) == '') ? 'Undisclosed-recipients:;' : trim($mail_to);
if (preg_match('#[^ ]+\@[^ ]+#', $mail_to)) {
fputs($socket, "RCPT TO: <$mail_to>\r\n");
fwrite($socket, "RCPT TO: <$mail_to>\r\n");
server_parse($socket, "250", __LINE__);
}
@ -140,7 +140,7 @@ function smtpmail($mail_to, $subject, $message, $headers = '')
// Add an additional bit of error checking to bcc header...
$bcc_address = trim($bcc_address);
if (preg_match('#[^ ]+\@[^ ]+#', $bcc_address)) {
fputs($socket, "RCPT TO: <$bcc_address>\r\n");
fwrite($socket, "RCPT TO: <$bcc_address>\r\n");
server_parse($socket, "250", __LINE__);
}
}
@ -150,35 +150,35 @@ function smtpmail($mail_to, $subject, $message, $headers = '')
// Add an additional bit of error checking to cc header
$cc_address = trim($cc_address);
if (preg_match('#[^ ]+\@[^ ]+#', $cc_address)) {
fputs($socket, "RCPT TO: <$cc_address>\r\n");
fwrite($socket, "RCPT TO: <$cc_address>\r\n");
server_parse($socket, "250", __LINE__);
}
}
// Ok now we tell the server we are ready to start sending data
fputs($socket, "DATA\r\n");
fwrite($socket, "DATA\r\n");
// This is the last response code we look for until the end of the message.
server_parse($socket, "354", __LINE__);
// Send the Subject Line...
fputs($socket, "Subject: $subject\r\n");
fwrite($socket, "Subject: $subject\r\n");
// Now the To Header.
fputs($socket, "To: $mail_to\r\n");
fwrite($socket, "To: $mail_to\r\n");
// Now any custom headers....
fputs($socket, "$headers\r\n\r\n");
fwrite($socket, "$headers\r\n\r\n");
// Ok now we are ready for the message...
fputs($socket, "$message\r\n");
fwrite($socket, "$message\r\n");
// Ok the all the ingredients are mixed in let's cook this puppy...
fputs($socket, ".\r\n");
fwrite($socket, ".\r\n");
server_parse($socket, "250", __LINE__);
// Now tell the server we are done and close the socket...
fputs($socket, "QUIT\r\n");
fwrite($socket, "QUIT\r\n");
fclose($socket);
return true;

View file

@ -173,7 +173,7 @@ class template
$filename = $this->replace[$filename];
}
// Check if it's an absolute or relative path.
if ((substr($filename, 0, 1) !== '/') && (substr($filename, 1, 1) !== ':')) {
if (($filename[0] !== '/') && ($filename[1] !== ':')) {
return $this->root . '/' . $filename;
} else {
return $filename;
@ -393,15 +393,15 @@ class template
*/
public function assign_block_vars($blockname, $vararray)
{
if (strstr($blockname, '.')) {
if (false !== strpos($blockname, '.')) {
// Nested block.
$blocks = explode('.', $blockname);
$blockcount = sizeof($blocks) - 1;
$blockcount = count($blocks) - 1;
$str = &$this->_tpldata;
for ($i = 0; $i < $blockcount; $i++) {
$str = &$str[$blocks[$i] . '.'];
$str = &$str[sizeof($str) - 1];
$str = &$str[count($str) - 1];
}
// Now we add the block that we're actually assigning to.
// We're adding a new iteration to this block with the given
@ -517,7 +517,7 @@ class template
{
// Get an array of the blocks involved.
$blocks = explode('.', $blockname);
$blockcount = sizeof($blocks) - 1;
$blockcount = count($blocks) - 1;
if ($include_last_iterator) {
return '$' . $blocks[$blockcount] . '_item';
} else {
@ -686,7 +686,7 @@ class template
} else {
// This block is nested.
// Generate a namespace string for this block.
$namespace = join('.', $block_names);
$namespace = implode('.', $block_names);
// strip leading period from root level..
$namespace = substr($namespace, 2);
// Get a reference to the data array for this block that depends on the
@ -774,7 +774,7 @@ class template
if (!$count_if) {
$keyword_type = XS_TAG_IF;
}
$str = $this->compile_tag_if($params_str, $keyword_type == XS_TAG_IF ? false : true);
$str = $this->compile_tag_if($params_str, $keyword_type != XS_TAG_IF);
if ($str) {
$compiled[] = '<?php ' . $str . ' ?>';
if ($keyword_type == XS_TAG_IF) {
@ -806,7 +806,7 @@ class template
$code_header = '';
$code_footer = '';
return $code_header . join('', $compiled) . $code_footer;
return $code_header . implode('', $compiled) . $code_footer;
}
/*
@ -821,7 +821,7 @@ class template
// This one will handle varrefs WITH namespaces
$varrefs = array();
preg_match_all('#\{(([a-z0-9\-_]+?\.)+)([a-z0-9\-_]+?)\}#is', $code, $varrefs);
$varcount = sizeof($varrefs[1]);
$varcount = count($varrefs[1]);
$search = array();
$replace = array();
for ($i = 0; $i < $varcount; $i++) {
@ -907,12 +907,12 @@ class template
break;
case '(':
array_push($is_arg_stack, $i);
$is_arg_stack[] = $i;
break;
case 'is':
$is_arg_start = ($tokens[$i - 1] == ')') ? array_pop($is_arg_stack) : $i - 1;
$is_arg = join(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start));
$is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start));
$new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i + 1));
@ -948,9 +948,9 @@ class template
}
if ($elseif) {
$code = '} elseif (' . join(' ', $tokens) . ') {';
$code = '} elseif (' . implode(' ', $tokens) . ') {';
} else {
$code = 'if (' . join(' ', $tokens) . ') {';
$code = 'if (' . implode(' ', $tokens) . ') {';
}
return $code;

View file

@ -33,7 +33,7 @@ if (empty($_GET['u']) || empty($_GET['act_key'])) {
$sql = "SELECT user_active, user_id, username, user_email, user_newpasswd, user_lang, user_actkey
FROM " . BB_USERS . "
WHERE user_id = " . intval($_GET[POST_USERS_URL]);
WHERE user_id = " . (int)$_GET[POST_USERS_URL];
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not obtain user information');
}

Some files were not shown because too many files have changed in this diff Show more