diff --git a/admin/admin_attach_cp.php b/admin/admin_attach_cp.php index 773315580..c7efa9a77 100644 --- a/admin/admin_attach_cp.php +++ b/admin/admin_attach_cp.php @@ -29,8 +29,6 @@ if (!empty($setmodules)) { } require __DIR__ . '/pagestart.php'; -$total_attachments = 0; - if (($attach_config['upload_dir'][0] == '/') || (($attach_config['upload_dir'][0] != '/') && ($attach_config['upload_dir'][1] == ':'))) { $upload_dir = $attach_config['upload_dir']; } else { @@ -39,24 +37,18 @@ if (($attach_config['upload_dir'][0] == '/') || (($attach_config['upload_dir'][0 include ATTACH_DIR . '/includes/functions_selects.php'; -// Check if the language got included -if (!isset($lang['TEST_SETTINGS_SUCCESSFUL'])) { - // include_once is used within the function - include_attach_lang(); -} - // Init Variables $start = get_var('start', 0); $sort_order = get_var('order', 'ASC'); $sort_order = ($sort_order == 'ASC') ? 'ASC' : 'DESC'; $mode = get_var('mode', ''); $view = get_var('view', ''); -$uid = (isset($_POST['u_id'])) ? get_var('u_id', 0) : get_var('uid', 0); +$uid = isset($_POST['u_id']) ? get_var('u_id', 0) : get_var('uid', 0); $view = (isset($_POST['search']) && $_POST['search']) ? 'attachments' : $view; // process modes based on view -if ($view == 'username') { +if ($view === 'username') { $mode_types_text = array($lang['SORT_USERNAME'], $lang['SORT_ATTACHMENTS'], $lang['SORT_SIZE']); $mode_types = array('username', 'attachments', 'filesize'); @@ -64,7 +56,7 @@ if ($view == 'username') { $mode = 'attachments'; $sort_order = 'DESC'; } -} elseif ($view == 'attachments') { +} elseif ($view === 'attachments') { $mode_types_text = array($lang['SORT_FILENAME'], $lang['SORT_COMMENT'], $lang['SORT_EXTENSION'], $lang['SORT_SIZE'], $lang['SORT_DOWNLOADS'], $lang['SORT_POSTTIME']); $mode_types = array('real_filename', 'comment', 'extension', 'filesize', 'downloads', 'post_time'); @@ -72,7 +64,7 @@ if ($view == 'username') { $mode = 'real_filename'; $sort_order = 'ASC'; } -} elseif ($view == 'search') { +} elseif ($view === 'search') { $mode_types_text = array($lang['SORT_FILENAME'], $lang['SORT_COMMENT'], $lang['SORT_EXTENSION'], $lang['SORT_SIZE'], $lang['SORT_DOWNLOADS'], $lang['SORT_POSTTIME']); $mode_types = array('real_filename', 'comment', 'extension', 'filesize', 'downloads', 'post_time'); @@ -84,12 +76,12 @@ if ($view == 'username') { } // Pagination ? -$do_pagination = ($view != 'stats' && $view != 'search') ? true : false; +$do_pagination = ($view !== 'stats' && $view !== 'search') ? true : false; // Set Order $order_by = ''; -if ($view == 'username') { +if ($view === 'username') { switch ($mode) { case 'username': $order_by = 'ORDER BY u.username ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page']; @@ -106,7 +98,7 @@ if ($view == 'username') { $order_by = 'ORDER BY total_attachments ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page']; break; } -} elseif ($view == 'attachments') { +} elseif ($view === 'attachments') { switch ($mode) { case 'filename': $order_by = 'ORDER BY a.real_filename ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page']; @@ -140,8 +132,8 @@ $view_types = array('stats', 'search'); $select_view = ''; @@ -149,32 +141,32 @@ $select_view .= ''; if (count($mode_types_text) > 0) { $select_sort_mode = ''; } $select_sort_order = ''; -$submit_change = (isset($_POST['submit_change'])) ? true : false; -$delete = (isset($_POST['delete'])) ? true : false; +$submit_change = isset($_POST['submit_change']); +$delete = isset($_POST['delete']); $delete_id_list = get_var('delete_id_list', array(0)); $confirm = isset($_POST['confirm']); -if ($confirm && sizeof($delete_id_list) > 0) { +if ($confirm && count($delete_id_list) > 0) { $attachments = array(); delete_attachment(0, $delete_id_list); -} elseif ($delete && sizeof($delete_id_list) > 0) { +} elseif ($delete && count($delete_id_list) > 0) { // Not confirmed, show confirmation message $hidden_fields = ''; $hidden_fields .= ''; @@ -182,7 +174,7 @@ if ($confirm && sizeof($delete_id_list) > 0) { $hidden_fields .= ''; $hidden_fields .= ''; - for ($i = 0; $i < sizeof($delete_id_list); $i++) { + for ($i = 0, $iMax = count($delete_id_list); $i < $iMax; $i++) { $hidden_fields .= ''; } @@ -198,7 +190,7 @@ $template->assign_vars(array( 'S_MODE_ACTION' => 'admin_attach_cp.php', )); -if ($submit_change && $view == 'attachments') { +if ($submit_change && $view === 'attachments') { $attach_change_list = get_var('attach_id_list', array(0)); $attach_comment_list = get_var('attach_comment_list', array('')); $attach_download_count_list = get_var('attach_count_list', array(0)); @@ -206,7 +198,7 @@ if ($submit_change && $view == 'attachments') { // Generate correct Change List $attachments = array(); - for ($i = 0; $i < count($attach_change_list); $i++) { + for ($i = 0, $iMax = count($attach_change_list); $i < $iMax; $i++) { $attachments['_' . $attach_change_list[$i]]['comment'] = $attach_comment_list[$i]; $attachments['_' . $attach_change_list[$i]]['download_count'] = $attach_download_count_list[$i]; } @@ -242,23 +234,17 @@ if ($view == 'stats') { $attachment_quota = humn_size($attach_config['attachment_quota']); // number_of_attachments - $row = DB()->fetch_row(" - SELECT COUNT(*) AS total FROM " . BB_ATTACHMENTS_DESC . " - "); + $row = DB()->fetch_row("SELECT COUNT(*) AS total FROM " . BB_ATTACHMENTS_DESC); $number_of_attachments = $number_of_posts = $row['total']; $number_of_pms = 0; // number_of_topics - $row = DB()->fetch_row(" - SELECT COUNT(*) AS topics FROM " . BB_TOPICS . " WHERE topic_attachment = 1 - "); + $row = DB()->fetch_row("SELECT COUNT(*) AS topics FROM " . BB_TOPICS . " WHERE topic_attachment = 1"); $number_of_topics = $row['topics']; // number_of_users - $row = DB()->fetch_row(" - SELECT COUNT(DISTINCT user_id_1) AS users FROM " . BB_ATTACHMENTS . " WHERE post_id != 0 - "); + $row = DB()->fetch_row("SELECT COUNT(DISTINCT user_id_1) AS users FROM " . BB_ATTACHMENTS . " WHERE post_id != 0"); $number_of_users = $row['users']; $template->assign_vars(array( @@ -274,7 +260,7 @@ if ($view == 'stats') { } // Search -if ($view == 'search') { +if ($view === 'search') { // Get Forums and Categories //sf - add [, f.forum_parent] $sql = "SELECT c.cat_title, c.cat_id, f.forum_name, f.forum_id, f.forum_parent @@ -287,6 +273,7 @@ if ($view == 'search') { } $s_forums = ''; + $list_cat = []; while ($row = DB()->sql_fetchrow($result)) { //sf $s_forums .= ''; @@ -295,7 +282,8 @@ if ($view == 'search') { } } - if ($s_forums != '') { + $s_categories = ''; + if ($s_forums) { $s_forums = '' . $s_forums; // Category to search @@ -318,7 +306,7 @@ if ($view == 'search') { } // Username -if ($view == 'username') { +if ($view === 'username') { $template->assign_vars(array( 'TPL_ATTACH_USER' => true, 'S_MODE_SELECT' => $select_sort_mode, @@ -329,7 +317,7 @@ if ($view == 'username') { } // Attachments -if ($view == 'attachments') { +if ($view === 'attachments') { $user_based = ($uid) ? true : false; $search_based = (isset($_POST['search']) && $_POST['search']) ? true : false; @@ -407,10 +395,10 @@ if ($view == 'attachments') { } if (sizeof($attachments) > 0) { - for ($i = 0; $i < sizeof($attachments); $i++) { + for ($i = 0, $iMax = count($attachments); $i < $iMax; $i++) { $delete_box = ''; - for ($j = 0; $j < count($delete_id_list); $j++) { + for ($j = 0, $iMax = count($delete_id_list); $j < $iMax; $j++) { if ($delete_id_list[$j] == $attachments[$i]['attach_id']) { $delete_box = ''; break; @@ -486,7 +474,7 @@ if ($view == 'attachments') { } if (!$search_based && !$user_based) { - if ($total_attachments == 0) { + if (!$attachments) { $sql = "SELECT attach_id FROM " . BB_ATTACHMENTS_DESC; if (!($result = DB()->sql_query($sql))) { diff --git a/admin/admin_attachments.php b/admin/admin_attachments.php index dd9d3455d..e15666c83 100644 --- a/admin/admin_attachments.php +++ b/admin/admin_attachments.php @@ -42,12 +42,6 @@ if (($attach_config['upload_dir'][0] == '/') || (($attach_config['upload_dir'][0 include ATTACH_DIR . '/includes/functions_selects.php'; -// Check if the language got included -if (!isset($lang['TEST_SETTINGS_SUCCESSFUL'])) { - // include_once is used within the function - include_attach_lang(); -} - // Init Vars $mode = request_var('mode', ''); $e_mode = request_var('e_mode', ''); diff --git a/admin/admin_extensions.php b/admin/admin_extensions.php index b7a4470a5..9fc0910b0 100644 --- a/admin/admin_extensions.php +++ b/admin/admin_extensions.php @@ -46,12 +46,6 @@ if (($attach_config['upload_dir'][0] == '/') || (($attach_config['upload_dir'][0 include ATTACH_DIR . '/includes/functions_selects.php'; -// Check if the language got included -if (!isset($lang['TEST_SETTINGS_SUCCESSFUL'])) { - // include_once is used within the function - include_attach_lang(); -} - // Init Vars $types_download = array(INLINE_LINK, PHYSICAL_LINK); $modes_download = array('inline', 'physical'); diff --git a/library/attach_mod/includes/functions_admin.php b/library/attach_mod/includes/functions_admin.php index 782adbd53..623768d76 100644 --- a/library/attach_mod/includes/functions_admin.php +++ b/library/attach_mod/includes/functions_admin.php @@ -183,15 +183,9 @@ function search_attachments($order_by, &$total_rows) $where_sql = array(); - // Get submitted Vars - $search_vars = array('search_keyword_fname', 'search_keyword_comment', 'search_author', 'search_size_smaller', 'search_size_greater', 'search_count_smaller', 'search_count_greater', 'search_days_greater', 'search_forum', 'search_cat'); - - for ($i = 0; $i < sizeof($search_vars); $i++) { - $$search_vars[$i] = get_var($search_vars[$i], ''); - } - // Author name search - if ($search_author != '') { + $search_author = get_var('search_author', ''); + if ($search_author) { // Bring in line with 2.0.x expected username $search_author = addslashes(html_entity_decode($search_author)); $search_author = stripslashes(clean_username($search_author)); @@ -221,40 +215,44 @@ function search_attachments($order_by, &$total_rows) } // Search Keyword - if ($search_keyword_fname != '') { + $search_keyword_fname = get_var('search_keyword_fname', ''); + if ($search_keyword_fname) { $match_word = str_replace('*', '%', $search_keyword_fname); $where_sql[] = " (a.real_filename LIKE '" . attach_mod_sql_escape($match_word) . "') "; } - if ($search_keyword_comment != '') { + $search_keyword_comment = get_var('search_keyword_comment', ''); + if ($search_keyword_comment) { $match_word = str_replace('*', '%', $search_keyword_comment); $where_sql[] = " (a.comment LIKE '" . attach_mod_sql_escape($match_word) . "') "; } // Search Download Count - if ($search_count_smaller != '' || $search_count_greater != '') { - if ($search_count_smaller != '') { - $where_sql[] = ' (a.download_count < ' . (int)$search_count_smaller . ') '; - } elseif ($search_count_greater != '') { - $where_sql[] = ' (a.download_count > ' . (int)$search_count_greater . ') '; - } + $search_count_smaller = get_var('search_count_smaller', ''); + $search_count_greater = get_var('search_count_greater', ''); + if ($search_count_smaller != '') { + $where_sql[] = ' (a.download_count < ' . (int)$search_count_smaller . ') '; + } elseif ($search_count_greater != '') { + $where_sql[] = ' (a.download_count > ' . (int)$search_count_greater . ') '; } // Search Filesize - if ($search_size_smaller != '' || $search_size_greater != '') { - if ($search_size_smaller != '') { - $where_sql[] = ' (a.filesize < ' . (int)$search_size_smaller . ') '; - } elseif ($search_size_greater != '') { - $where_sql[] = ' (a.filesize > ' . (int)$search_size_greater . ') '; - } + $search_size_smaller = get_var('search_size_smaller', ''); + $search_size_greater = get_var('search_size_greater', ''); + if ($search_size_smaller != '') { + $where_sql[] = ' (a.filesize < ' . (int)$search_size_smaller . ') '; + } elseif ($search_size_greater != '') { + $where_sql[] = ' (a.filesize > ' . (int)$search_size_greater . ') '; } // Search Attachment Time - if ($search_days_greater != '') { + $search_days_greater = get_var('search_days_greater', ''); + if ($search_days_greater) { $where_sql[] = ' (a.filetime < ' . (TIMENOW - ((int)$search_days_greater * 86400)) . ') '; } // Search Forum + $search_forum = get_var('search_forum', ''); if ($search_forum) { $where_sql[] = ' (p.forum_id = ' . intval($search_forum) . ') '; } diff --git a/library/config.php b/library/config.php index 154bdbe07..6a4d69089 100644 --- a/library/config.php +++ b/library/config.php @@ -275,12 +275,12 @@ define('BB_PATH', dirname(__DIR__)); define('ADMIN_DIR', BB_PATH . '/admin'); define('DATA_DIR', BB_PATH . '/data'); define('INT_DATA_DIR', BB_PATH . '/internal_data'); -define('AJAX_HTML_DIR', BB_ROOT . '/internal_data/ajax_html'); +define('AJAX_HTML_DIR', BB_PATH . '/internal_data/ajax_html'); define('CACHE_DIR', BB_PATH . '/internal_data/cache'); define('LOG_DIR', BB_PATH . '/internal_data/log'); define('SITEMAP_DIR', BB_PATH . '/internal_data/sitemap'); define('TRIGGERS_DIR', BB_PATH . '/internal_data/triggers'); -define('AJAX_DIR', BB_ROOT . '/library/ajax'); +define('AJAX_DIR', BB_PATH . '/library/ajax'); define('ATTACH_DIR', BB_PATH . '/library/attach_mod'); define('CFG_DIR', BB_PATH . '/library/config'); define('INC_DIR', BB_PATH . '/library/includes'); @@ -612,12 +612,12 @@ $bb_cfg['gen_forums_allowed_ext'] = array('zip', 'rar'); // для о // Avatars $bb_cfg['avatars'] = array( 'allowed_ext' => array('gif', 'jpg', 'jpeg', 'png'), // разрешенные форматы файлов - 'bot_avatar' => 'gallery/bot.gif', // аватара бота + 'bot_avatar' => '/gallery/bot.gif', // аватара бота 'max_size' => 100 * 1024, // размер аватары в байтах 'max_height' => 100, // высота аватара в px 'max_width' => 100, // ширина аватара в px - 'no_avatar' => 'gallery/noavatar.png', // дефолтная аватара - 'upload_path' => BB_ROOT . 'data/avatars/', // путь к директории с аватарами + 'no_avatar' => '/gallery/noavatar.png', // дефолтная аватара + 'upload_path' => BB_PATH . '/data/avatars', // путь к директории с аватарами 'up_allowed' => true, // разрешить загрузку аватар ); @@ -627,8 +627,8 @@ $bb_cfg['group_avatars'] = array( 'max_size' => 300 * 1024, // размер аватары в байтах 'max_height' => 300, // высота аватара в px 'max_width' => 300, // ширина аватара в px - 'no_avatar' => 'gallery/noavatar.png', // дефолтная аватара - 'upload_path' => BB_ROOT . 'data/avatars/', // путь к директории с аватарами + 'no_avatar' => '/gallery/noavatar.png', // дефолтная аватара + 'upload_path' => BB_PATH . '/data/avatars', // путь к директории с аватарами 'up_allowed' => true, // разрешить загрузку аватар ); @@ -654,8 +654,8 @@ $bb_cfg['nofollow'] = array( ); // Local config -if (file_exists(BB_ROOT . '/library/config.local.php')) { - include_once(BB_ROOT . '/library/config.local.php'); +if (file_exists(BB_PATH . '/library/config.local.php')) { + include_once(BB_PATH . '/library/config.local.php'); } define('BB_CFG_LOADED', true);