mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 18:48:21 -07:00
Реформат в PSR-2 + добавление заголовков лицензии MIT в файлы
This commit is contained in:
parent
a04df19607
commit
3730bed000
207 changed files with 44327 additions and 43119 deletions
|
@ -1,82 +1,97 @@
|
|||
<?php
|
||||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2005-2017 TorrentPier
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
if (!defined('IN_FORUM')) die("Hacking attempt");
|
||||
if (!defined('IN_FORUM')) {
|
||||
die("Hacking attempt");
|
||||
}
|
||||
|
||||
require(ATTACH_DIR .'includes/functions_includes.php');
|
||||
require(ATTACH_DIR .'includes/functions_attach.php');
|
||||
require(ATTACH_DIR .'includes/functions_delete.php');
|
||||
require(ATTACH_DIR .'includes/functions_thumbs.php');
|
||||
require(ATTACH_DIR .'includes/functions_filetypes.php');
|
||||
require(ATTACH_DIR . 'includes/functions_includes.php');
|
||||
require(ATTACH_DIR . 'includes/functions_attach.php');
|
||||
require(ATTACH_DIR . 'includes/functions_delete.php');
|
||||
require(ATTACH_DIR . 'includes/functions_thumbs.php');
|
||||
require(ATTACH_DIR . 'includes/functions_filetypes.php');
|
||||
|
||||
if (defined('ATTACH_INSTALL'))
|
||||
{
|
||||
return;
|
||||
if (defined('ATTACH_INSTALL')) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* wrapper function for determining the correct language directory
|
||||
*/
|
||||
* wrapper function for determining the correct language directory
|
||||
*/
|
||||
function attach_mod_get_lang($language_file)
|
||||
{
|
||||
global $attach_config, $bb_cfg;
|
||||
global $attach_config, $bb_cfg;
|
||||
|
||||
$language = $bb_cfg['default_lang'];
|
||||
if (!file_exists(LANG_ROOT_DIR ."$language/$language_file.php"))
|
||||
{
|
||||
$language = $attach_config['board_lang'];
|
||||
$language = $bb_cfg['default_lang'];
|
||||
if (!file_exists(LANG_ROOT_DIR . "$language/$language_file.php")) {
|
||||
$language = $attach_config['board_lang'];
|
||||
|
||||
if (!file_exists(LANG_ROOT_DIR ."$language/$language_file.php"))
|
||||
{
|
||||
bb_die('Attachment mod language file does not exist: language/' . $language . '/' . $language_file . '.php');
|
||||
}
|
||||
else
|
||||
{
|
||||
return $language;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return $language;
|
||||
}
|
||||
if (!file_exists(LANG_ROOT_DIR . "$language/$language_file.php")) {
|
||||
bb_die('Attachment mod language file does not exist: language/' . $language . '/' . $language_file . '.php');
|
||||
} else {
|
||||
return $language;
|
||||
}
|
||||
} else {
|
||||
return $language;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get attachment mod configuration
|
||||
*/
|
||||
* Get attachment mod configuration
|
||||
*/
|
||||
function get_config()
|
||||
{
|
||||
global $bb_cfg;
|
||||
global $bb_cfg;
|
||||
|
||||
$attach_config = array();
|
||||
$attach_config = array();
|
||||
|
||||
$sql = 'SELECT * FROM ' . BB_ATTACH_CONFIG;
|
||||
$sql = 'SELECT * FROM ' . BB_ATTACH_CONFIG;
|
||||
|
||||
if (!($result = DB()->sql_query($sql)))
|
||||
{
|
||||
bb_die('Could not query attachment information');
|
||||
}
|
||||
if (!($result = DB()->sql_query($sql))) {
|
||||
bb_die('Could not query attachment information');
|
||||
}
|
||||
|
||||
while ($row = DB()->sql_fetchrow($result))
|
||||
{
|
||||
$attach_config[$row['config_name']] = trim($row['config_value']);
|
||||
}
|
||||
while ($row = DB()->sql_fetchrow($result)) {
|
||||
$attach_config[$row['config_name']] = trim($row['config_value']);
|
||||
}
|
||||
|
||||
// We assign the original default board language here, because it gets overwritten later with the users default language
|
||||
$attach_config['board_lang'] = trim($bb_cfg['default_lang']);
|
||||
// We assign the original default board language here, because it gets overwritten later with the users default language
|
||||
$attach_config['board_lang'] = trim($bb_cfg['default_lang']);
|
||||
|
||||
return $attach_config;
|
||||
return $attach_config;
|
||||
}
|
||||
|
||||
// Get Attachment Config
|
||||
$attach_config = array();
|
||||
|
||||
if (!$attach_config = CACHE('bb_cache')->get('attach_config'))
|
||||
{
|
||||
$attach_config = get_config();
|
||||
CACHE('bb_cache')->set('attach_config', $attach_config, 86400);
|
||||
if (!$attach_config = CACHE('bb_cache')->get('attach_config')) {
|
||||
$attach_config = get_config();
|
||||
CACHE('bb_cache')->set('attach_config', $attach_config, 86400);
|
||||
}
|
||||
|
||||
include(ATTACH_DIR .'displaying.php');
|
||||
include(ATTACH_DIR .'posting_attachments.php');
|
||||
include(ATTACH_DIR . 'displaying.php');
|
||||
include(ATTACH_DIR . 'posting_attachments.php');
|
||||
|
||||
$upload_dir = $attach_config['upload_dir'];
|
||||
$upload_dir = $attach_config['upload_dir'];
|
||||
|
|
|
@ -1,6 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2005-2017 TorrentPier
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
if (!defined('IN_FORUM')) die("Hacking attempt");
|
||||
if (!defined('IN_FORUM')) {
|
||||
die("Hacking attempt");
|
||||
}
|
||||
|
||||
$allowed_extensions = array();
|
||||
$display_categories = array();
|
||||
|
@ -9,338 +34,289 @@ $upload_icons = array();
|
|||
$attachments = array();
|
||||
|
||||
/**
|
||||
* Create needed arrays for Extension Assignments
|
||||
*/
|
||||
* Create needed arrays for Extension Assignments
|
||||
*/
|
||||
function init_complete_extensions_data()
|
||||
{
|
||||
global $allowed_extensions, $display_categories, $download_modes, $upload_icons;
|
||||
global $allowed_extensions, $display_categories, $download_modes, $upload_icons;
|
||||
|
||||
if (!$extension_informations = get_extension_informations())
|
||||
{
|
||||
$extension_informations = $GLOBALS['datastore']->update('attach_extensions'); //get_extension_informations()
|
||||
$extension_informations = get_extension_informations();
|
||||
}
|
||||
$allowed_extensions = array();
|
||||
if (!$extension_informations = get_extension_informations()) {
|
||||
$extension_informations = $GLOBALS['datastore']->update('attach_extensions'); //get_extension_informations()
|
||||
$extension_informations = get_extension_informations();
|
||||
}
|
||||
$allowed_extensions = array();
|
||||
|
||||
for ($i = 0, $size = sizeof($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']);
|
||||
$upload_icons[$extension] = trim($extension_informations[$i]['upload_icon']);
|
||||
}
|
||||
for ($i = 0, $size = sizeof($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']);
|
||||
$upload_icons[$extension] = trim($extension_informations[$i]['upload_icon']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writing Data into plain Template Vars
|
||||
*/
|
||||
* Writing Data into plain Template Vars
|
||||
*/
|
||||
function init_display_template($template_var, $replacement, $filename = 'viewtopic_attach.tpl')
|
||||
{
|
||||
global $template;
|
||||
global $template;
|
||||
|
||||
// This function is adapted from the old template class
|
||||
// I wish i had the functions from the 3.x one. :D (This class rocks, can't await to use it in Mods)
|
||||
// This function is adapted from the old template class
|
||||
// I wish i had the functions from the 3.x one. :D (This class rocks, can't await to use it in Mods)
|
||||
|
||||
// Handle Attachment Informations
|
||||
if (!isset($template->uncompiled_code[$template_var]) && empty($template->uncompiled_code[$template_var]))
|
||||
{
|
||||
// If we don't have a file assigned to this handle, die.
|
||||
if (!isset($template->files[$template_var]))
|
||||
{
|
||||
die("Template->loadfile(): No file specified for handle $template_var");
|
||||
}
|
||||
// Handle Attachment Informations
|
||||
if (!isset($template->uncompiled_code[$template_var]) && empty($template->uncompiled_code[$template_var])) {
|
||||
// If we don't have a file assigned to this handle, die.
|
||||
if (!isset($template->files[$template_var])) {
|
||||
die("Template->loadfile(): No file specified for handle $template_var");
|
||||
}
|
||||
|
||||
$filename_2 = $template->files[$template_var];
|
||||
$filename_2 = $template->files[$template_var];
|
||||
|
||||
$str = implode('', @file($filename_2));
|
||||
if (empty($str))
|
||||
{
|
||||
die("Template->loadfile(): File $filename_2 for handle $template_var is empty");
|
||||
}
|
||||
$str = implode('', @file($filename_2));
|
||||
if (empty($str)) {
|
||||
die("Template->loadfile(): File $filename_2 for handle $template_var is empty");
|
||||
}
|
||||
|
||||
$template->uncompiled_code[$template_var] = $str;
|
||||
}
|
||||
$template->uncompiled_code[$template_var] = $str;
|
||||
}
|
||||
|
||||
$complete_filename = $filename;
|
||||
if (substr($complete_filename, 0, 1) != '/')
|
||||
{
|
||||
$complete_filename = $template->root . '/' . $complete_filename;
|
||||
}
|
||||
$complete_filename = $filename;
|
||||
if (substr($complete_filename, 0, 1) != '/') {
|
||||
$complete_filename = $template->root . '/' . $complete_filename;
|
||||
}
|
||||
|
||||
if (!file_exists($complete_filename))
|
||||
{
|
||||
die("Template->make_filename(): Error - file $complete_filename does not exist");
|
||||
}
|
||||
if (!file_exists($complete_filename)) {
|
||||
die("Template->make_filename(): Error - file $complete_filename does not exist");
|
||||
}
|
||||
|
||||
$content = implode('', file($complete_filename));
|
||||
if (empty($content))
|
||||
{
|
||||
die('Template->loadfile(): File ' . $complete_filename . ' is empty');
|
||||
}
|
||||
$content = implode('', file($complete_filename));
|
||||
if (empty($content)) {
|
||||
die('Template->loadfile(): File ' . $complete_filename . ' is empty');
|
||||
}
|
||||
|
||||
// replace $replacement with uncompiled code in $filename
|
||||
$template->uncompiled_code[$template_var] = str_replace($replacement, $content, $template->uncompiled_code[$template_var]);
|
||||
// replace $replacement with uncompiled code in $filename
|
||||
$template->uncompiled_code[$template_var] = str_replace($replacement, $content, $template->uncompiled_code[$template_var]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Attachments in Posts
|
||||
*/
|
||||
* Display Attachments in Posts
|
||||
*/
|
||||
function display_post_attachments($post_id, $switch_attachment)
|
||||
{
|
||||
global $attach_config, $is_auth;
|
||||
global $attach_config, $is_auth;
|
||||
|
||||
if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod']))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($is_auth['auth_download'] && $is_auth['auth_view'])
|
||||
{
|
||||
display_attachments($post_id);
|
||||
}
|
||||
if ($is_auth['auth_download'] && $is_auth['auth_view']) {
|
||||
display_attachments($post_id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes some templating variables for displaying Attachments in Posts
|
||||
*/
|
||||
* Initializes some templating variables for displaying Attachments in Posts
|
||||
*/
|
||||
function init_display_post_attachments($switch_attachment)
|
||||
{
|
||||
global $attach_config, $is_auth, $template, $lang, $postrow, $total_posts, $attachments, $forum_row, $t_data;
|
||||
global $attach_config, $is_auth, $template, $lang, $postrow, $total_posts, $attachments, $forum_row, $t_data;
|
||||
|
||||
if (empty($t_data) && !empty($forum_row))
|
||||
{
|
||||
$switch_attachment = $forum_row['topic_attachment'];
|
||||
}
|
||||
if (empty($t_data) && !empty($forum_row)) {
|
||||
$switch_attachment = $forum_row['topic_attachment'];
|
||||
}
|
||||
|
||||
if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod']) || (!($is_auth['auth_download'] && $is_auth['auth_view'])))
|
||||
{
|
||||
init_display_template('body', '{postrow.ATTACHMENTS}', 'viewtopic_attach_guest.tpl');
|
||||
return;
|
||||
}
|
||||
if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod']) || (!($is_auth['auth_download'] && $is_auth['auth_view']))) {
|
||||
init_display_template('body', '{postrow.ATTACHMENTS}', 'viewtopic_attach_guest.tpl');
|
||||
return;
|
||||
}
|
||||
|
||||
$post_id_array = array();
|
||||
$post_id_array = array();
|
||||
|
||||
for ($i = 0; $i < $total_posts; $i++)
|
||||
{
|
||||
if ($postrow[$i]['post_attachment'] == 1)
|
||||
{
|
||||
$post_id_array[] = (int) $postrow[$i]['post_id'];
|
||||
}
|
||||
}
|
||||
for ($i = 0; $i < $total_posts; $i++) {
|
||||
if ($postrow[$i]['post_attachment'] == 1) {
|
||||
$post_id_array[] = (int)$postrow[$i]['post_id'];
|
||||
}
|
||||
}
|
||||
|
||||
if (sizeof($post_id_array) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (sizeof($post_id_array) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$rows = get_attachments_from_post($post_id_array);
|
||||
$num_rows = sizeof($rows);
|
||||
$rows = get_attachments_from_post($post_id_array);
|
||||
$num_rows = sizeof($rows);
|
||||
|
||||
if ($num_rows == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ($num_rows == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@reset($attachments);
|
||||
@reset($attachments);
|
||||
|
||||
for ($i = 0; $i < $num_rows; $i++)
|
||||
{
|
||||
$attachments['_' . $rows[$i]['post_id']][] = $rows[$i];
|
||||
//bt
|
||||
if ($rows[$i]['tracker_status'])
|
||||
{
|
||||
if (defined('TORRENT_POST'))
|
||||
{
|
||||
bb_die('Multiple registered torrents in one topic<br /><br />first torrent found in post_id = '. TORRENT_POST .'<br />current post_id = '. $rows[$i]['post_id'] .'<br /><br />attachments info:<br /><pre style="text-align: left;">'. print_r($rows, TRUE) .'</pre>');
|
||||
}
|
||||
define('TORRENT_POST', $rows[$i]['post_id']);
|
||||
}
|
||||
//bt end
|
||||
}
|
||||
for ($i = 0; $i < $num_rows; $i++) {
|
||||
$attachments['_' . $rows[$i]['post_id']][] = $rows[$i];
|
||||
//bt
|
||||
if ($rows[$i]['tracker_status']) {
|
||||
if (defined('TORRENT_POST')) {
|
||||
bb_die('Multiple registered torrents in one topic<br /><br />first torrent found in post_id = ' . TORRENT_POST . '<br />current post_id = ' . $rows[$i]['post_id'] . '<br /><br />attachments info:<br /><pre style="text-align: left;">' . print_r($rows, true) . '</pre>');
|
||||
}
|
||||
define('TORRENT_POST', $rows[$i]['post_id']);
|
||||
}
|
||||
//bt end
|
||||
}
|
||||
|
||||
init_display_template('body', '{postrow.ATTACHMENTS}');
|
||||
init_display_template('body', '{postrow.ATTACHMENTS}');
|
||||
|
||||
init_complete_extensions_data();
|
||||
init_complete_extensions_data();
|
||||
}
|
||||
|
||||
/**
|
||||
* END ATTACHMENT DISPLAY IN POSTS
|
||||
*/
|
||||
* END ATTACHMENT DISPLAY IN POSTS
|
||||
*/
|
||||
|
||||
/**
|
||||
* Assign Variables and Definitions based on the fetched Attachments - internal
|
||||
* used by all displaying functions, the Data was collected before, it's only dependend on the template used. :)
|
||||
* before this function is usable, init_display_attachments have to be called for specific pages (pm, posting, review etc...)
|
||||
*/
|
||||
* Assign Variables and Definitions based on the fetched Attachments - internal
|
||||
* used by all displaying functions, the Data was collected before, it's only dependend on the template used. :)
|
||||
* before this function is usable, init_display_attachments have to be called for specific pages (pm, posting, review etc...)
|
||||
*/
|
||||
function display_attachments($post_id)
|
||||
{
|
||||
global $template, $upload_dir, $userdata, $allowed_extensions, $display_categories, $download_modes, $lang, $attachments, $upload_icons, $attach_config;
|
||||
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 = @sizeof($attachments['_' . $post_id]);
|
||||
|
||||
if ($num_attachments == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ($num_attachments == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$template->assign_block_vars('postrow.attach', array());
|
||||
$template->assign_block_vars('postrow.attach', array());
|
||||
|
||||
for ($i = 0; $i < $num_attachments; $i++)
|
||||
{
|
||||
// Some basic things...
|
||||
$filename = $upload_dir . '/' . basename($attachments['_' . $post_id][$i]['physical_filename']);
|
||||
$thumbnail_filename = $upload_dir . '/' . THUMB_DIR . '/t_' . basename($attachments['_' . $post_id][$i]['physical_filename']);
|
||||
for ($i = 0; $i < $num_attachments; $i++) {
|
||||
// Some basic things...
|
||||
$filename = $upload_dir . '/' . basename($attachments['_' . $post_id][$i]['physical_filename']);
|
||||
$thumbnail_filename = $upload_dir . '/' . THUMB_DIR . '/t_' . basename($attachments['_' . $post_id][$i]['physical_filename']);
|
||||
|
||||
$upload_image = '';
|
||||
$upload_image = '';
|
||||
|
||||
if ($attach_config['upload_img'] && empty($upload_icons[$attachments['_' . $post_id][$i]['extension']]))
|
||||
{
|
||||
$upload_image = '<img src="' . $attach_config['upload_img'] . '" alt="" border="0" />';
|
||||
}
|
||||
else if (trim($upload_icons[$attachments['_' . $post_id][$i]['extension']]) != '')
|
||||
{
|
||||
$upload_image = '<img src="' . $upload_icons[$attachments['_' . $post_id][$i]['extension']] . '" alt="" border="0" />';
|
||||
}
|
||||
if ($attach_config['upload_img'] && empty($upload_icons[$attachments['_' . $post_id][$i]['extension']])) {
|
||||
$upload_image = '<img src="' . $attach_config['upload_img'] . '" alt="" border="0" />';
|
||||
} elseif (trim($upload_icons[$attachments['_' . $post_id][$i]['extension']]) != '') {
|
||||
$upload_image = '<img src="' . $upload_icons[$attachments['_' . $post_id][$i]['extension']] . '" alt="" border="0" />';
|
||||
}
|
||||
|
||||
$filesize = humn_size($attachments['_' . $post_id][$i]['filesize']);
|
||||
$filesize = humn_size($attachments['_' . $post_id][$i]['filesize']);
|
||||
|
||||
$display_name = htmlspecialchars($attachments['_' . $post_id][$i]['real_filename']);
|
||||
$comment = htmlspecialchars($attachments['_' . $post_id][$i]['comment']);
|
||||
$comment = str_replace("\n", '<br />', $comment);
|
||||
$display_name = htmlspecialchars($attachments['_' . $post_id][$i]['real_filename']);
|
||||
$comment = htmlspecialchars($attachments['_' . $post_id][$i]['comment']);
|
||||
$comment = str_replace("\n", '<br />', $comment);
|
||||
|
||||
$denied = false;
|
||||
$denied = false;
|
||||
|
||||
// Admin is allowed to view forbidden Attachments, but the error-message is displayed too to inform the Admin
|
||||
if (!in_array($attachments['_' . $post_id][$i]['extension'], $allowed_extensions))
|
||||
{
|
||||
$denied = true;
|
||||
// Admin is allowed to view forbidden Attachments, but the error-message is displayed too to inform the Admin
|
||||
if (!in_array($attachments['_' . $post_id][$i]['extension'], $allowed_extensions)) {
|
||||
$denied = true;
|
||||
|
||||
$template->assign_block_vars('postrow.attach.denyrow', array(
|
||||
'L_DENIED' => sprintf($lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachments['_' . $post_id][$i]['extension']))
|
||||
);
|
||||
}
|
||||
$template->assign_block_vars('postrow.attach.denyrow', array(
|
||||
'L_DENIED' => sprintf($lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachments['_' . $post_id][$i]['extension']))
|
||||
);
|
||||
}
|
||||
|
||||
if (!$denied || IS_ADMIN)
|
||||
{
|
||||
// define category
|
||||
$image = FALSE;
|
||||
$thumbnail = FALSE;
|
||||
$link = FALSE;
|
||||
if (!$denied || IS_ADMIN) {
|
||||
// define category
|
||||
$image = false;
|
||||
$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)
|
||||
{
|
||||
list($width, $height) = image_getdimension($filename);
|
||||
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) {
|
||||
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']))
|
||||
{
|
||||
$image = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$image = TRUE;
|
||||
}
|
||||
}
|
||||
if ($width == 0 && $height == 0) {
|
||||
$image = true;
|
||||
} else {
|
||||
if ($width <= intval($attach_config['img_link_width']) && $height <= intval($attach_config['img_link_height'])) {
|
||||
$image = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$image = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (@intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT && $attachments['_' . $post_id][$i]['thumbnail'] == 1)
|
||||
{
|
||||
$thumbnail = TRUE;
|
||||
$image = FALSE;
|
||||
}
|
||||
if (@intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT && $attachments['_' . $post_id][$i]['thumbnail'] == 1) {
|
||||
$thumbnail = true;
|
||||
$image = false;
|
||||
}
|
||||
|
||||
if (!$image && !$thumbnail)
|
||||
{
|
||||
$link = TRUE;
|
||||
}
|
||||
if (!$image && !$thumbnail) {
|
||||
$link = true;
|
||||
}
|
||||
|
||||
if ($image)
|
||||
{
|
||||
// Images
|
||||
if ($attach_config['upload_dir'][0] == '/' || ( $attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':'))
|
||||
{
|
||||
$img_source = BB_ROOT . DOWNLOAD_URL . $attachments['_' . $post_id][$i]['attach_id'];
|
||||
$download_link = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$img_source = $filename;
|
||||
$download_link = FALSE;
|
||||
}
|
||||
if ($image) {
|
||||
// Images
|
||||
if ($attach_config['upload_dir'][0] == '/' || ($attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':')) {
|
||||
$img_source = BB_ROOT . DOWNLOAD_URL . $attachments['_' . $post_id][$i]['attach_id'];
|
||||
$download_link = true;
|
||||
} else {
|
||||
$img_source = $filename;
|
||||
$download_link = false;
|
||||
}
|
||||
|
||||
$template->assign_block_vars('postrow.attach.cat_images', array(
|
||||
'DOWNLOAD_NAME' => $display_name,
|
||||
'S_UPLOAD_IMAGE' => $upload_image,
|
||||
'IMG_SRC' => $img_source,
|
||||
'FILESIZE' => $filesize,
|
||||
'COMMENT' => $comment,
|
||||
));
|
||||
$template->assign_block_vars('postrow.attach.cat_images', array(
|
||||
'DOWNLOAD_NAME' => $display_name,
|
||||
'S_UPLOAD_IMAGE' => $upload_image,
|
||||
'IMG_SRC' => $img_source,
|
||||
'FILESIZE' => $filesize,
|
||||
'COMMENT' => $comment,
|
||||
));
|
||||
|
||||
// Directly Viewed Image ... update the download count
|
||||
if (!$download_link)
|
||||
{
|
||||
$sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . '
|
||||
// Directly Viewed Image ... update the download count
|
||||
if (!$download_link) {
|
||||
$sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . '
|
||||
SET download_count = download_count + 1
|
||||
WHERE attach_id = ' . (int) $attachments['_' . $post_id][$i]['attach_id'];
|
||||
WHERE attach_id = ' . (int)$attachments['_' . $post_id][$i]['attach_id'];
|
||||
|
||||
if (!(DB()->sql_query($sql)))
|
||||
{
|
||||
bb_die('Could not update attachment download count');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(DB()->sql_query($sql))) {
|
||||
bb_die('Could not update attachment download count');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($thumbnail)
|
||||
{
|
||||
// Images, but display Thumbnail
|
||||
if ($attach_config['upload_dir'][0] == '/' || ( $attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':'))
|
||||
{
|
||||
$thumb_source = BB_ROOT . DOWNLOAD_URL . $attachments['_' . $post_id][$i]['attach_id'] . '&thumb=1';
|
||||
}
|
||||
else
|
||||
{
|
||||
$thumb_source = $thumbnail_filename;
|
||||
}
|
||||
if ($thumbnail) {
|
||||
// Images, but display Thumbnail
|
||||
if ($attach_config['upload_dir'][0] == '/' || ($attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':')) {
|
||||
$thumb_source = BB_ROOT . DOWNLOAD_URL . $attachments['_' . $post_id][$i]['attach_id'] . '&thumb=1';
|
||||
} else {
|
||||
$thumb_source = $thumbnail_filename;
|
||||
}
|
||||
|
||||
$template->assign_block_vars('postrow.attach.cat_thumb_images', array(
|
||||
'DOWNLOAD_NAME' => $display_name,
|
||||
'S_UPLOAD_IMAGE' => $upload_image,
|
||||
'IMG_SRC' => BB_ROOT . DOWNLOAD_URL . $attachments['_' . $post_id][$i]['attach_id'],
|
||||
'IMG_THUMB_SRC' => $thumb_source,
|
||||
'FILESIZE' => $filesize,
|
||||
'COMMENT' => $comment,
|
||||
));
|
||||
}
|
||||
$template->assign_block_vars('postrow.attach.cat_thumb_images', array(
|
||||
'DOWNLOAD_NAME' => $display_name,
|
||||
'S_UPLOAD_IMAGE' => $upload_image,
|
||||
'IMG_SRC' => BB_ROOT . DOWNLOAD_URL . $attachments['_' . $post_id][$i]['attach_id'],
|
||||
'IMG_THUMB_SRC' => $thumb_source,
|
||||
'FILESIZE' => $filesize,
|
||||
'COMMENT' => $comment,
|
||||
));
|
||||
}
|
||||
|
||||
// bt
|
||||
if ($link && ($attachments['_'. $post_id][$i]['extension'] === TORRENT_EXT))
|
||||
{
|
||||
include(ATTACH_DIR .'displaying_torrent.php');
|
||||
}
|
||||
else if ($link)
|
||||
{
|
||||
$target_blank = ( (@intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT) ) ? 'target="_blank"' : '';
|
||||
// bt
|
||||
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"' : '';
|
||||
|
||||
// display attachment
|
||||
$template->assign_block_vars('postrow.attach.attachrow', array(
|
||||
'U_DOWNLOAD_LINK' => BB_ROOT . DOWNLOAD_URL . $attachments['_' . $post_id][$i]['attach_id'],
|
||||
'S_UPLOAD_IMAGE' => $upload_image,
|
||||
'DOWNLOAD_NAME' => $display_name,
|
||||
'FILESIZE' => $filesize,
|
||||
'COMMENT' => $comment,
|
||||
'TARGET_BLANK' => $target_blank,
|
||||
'DOWNLOAD_COUNT' => sprintf($lang['DOWNLOAD_NUMBER'], $attachments['_' . $post_id][$i]['download_count']),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// display attachment
|
||||
$template->assign_block_vars('postrow.attach.attachrow', array(
|
||||
'U_DOWNLOAD_LINK' => BB_ROOT . DOWNLOAD_URL . $attachments['_' . $post_id][$i]['attach_id'],
|
||||
'S_UPLOAD_IMAGE' => $upload_image,
|
||||
'DOWNLOAD_NAME' => $display_name,
|
||||
'FILESIZE' => $filesize,
|
||||
'COMMENT' => $comment,
|
||||
'TARGET_BLANK' => $target_blank,
|
||||
'DOWNLOAD_COUNT' => sprintf($lang['DOWNLOAD_NUMBER'], $attachments['_' . $post_id][$i]['download_count']),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,191 +1,177 @@
|
|||
<?php
|
||||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2005-2017 TorrentPier
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* All Attachment Functions only needed in Admin
|
||||
*/
|
||||
* All Attachment Functions only needed in Admin
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set/Change Quotas
|
||||
*/
|
||||
* Set/Change Quotas
|
||||
*/
|
||||
function process_quota_settings($mode, $id, $quota_type, $quota_limit_id = 0)
|
||||
{
|
||||
$id = (int) $id;
|
||||
$quota_type = (int) $quota_type;
|
||||
$quota_limit_id = (int) $quota_limit_id;
|
||||
$id = (int)$id;
|
||||
$quota_type = (int)$quota_type;
|
||||
$quota_limit_id = (int)$quota_limit_id;
|
||||
|
||||
if ($mode == 'user')
|
||||
{
|
||||
if (!$quota_limit_id)
|
||||
{
|
||||
$sql = 'DELETE FROM ' . BB_QUOTA . "
|
||||
if ($mode == 'user') {
|
||||
if (!$quota_limit_id) {
|
||||
$sql = 'DELETE FROM ' . BB_QUOTA . "
|
||||
WHERE user_id = $id
|
||||
AND quota_type = $quota_type";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check if user is already entered
|
||||
$sql = 'SELECT user_id
|
||||
} else {
|
||||
// Check if user is already entered
|
||||
$sql = 'SELECT user_id
|
||||
FROM ' . BB_QUOTA . "
|
||||
WHERE user_id = $id
|
||||
AND quota_type = $quota_type";
|
||||
|
||||
if( !($result = DB()->sql_query($sql)) )
|
||||
{
|
||||
bb_die('Could not get entry #1');
|
||||
}
|
||||
if (!($result = DB()->sql_query($sql))) {
|
||||
bb_die('Could not get entry #1');
|
||||
}
|
||||
|
||||
if (DB()->num_rows($result) == 0)
|
||||
{
|
||||
$sql_ary = array(
|
||||
'user_id' => (int) $id,
|
||||
'group_id' => 0,
|
||||
'quota_type' => (int) $quota_type,
|
||||
'quota_limit_id'=> (int) $quota_limit_id
|
||||
);
|
||||
if (DB()->num_rows($result) == 0) {
|
||||
$sql_ary = array(
|
||||
'user_id' => (int)$id,
|
||||
'group_id' => 0,
|
||||
'quota_type' => (int)$quota_type,
|
||||
'quota_limit_id' => (int)$quota_limit_id
|
||||
);
|
||||
|
||||
$sql = 'INSERT INTO ' . BB_QUOTA . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'UPDATE ' . BB_QUOTA . "
|
||||
$sql = 'INSERT INTO ' . BB_QUOTA . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
|
||||
} else {
|
||||
$sql = 'UPDATE ' . BB_QUOTA . "
|
||||
SET quota_limit_id = $quota_limit_id
|
||||
WHERE user_id = $id
|
||||
AND quota_type = $quota_type";
|
||||
}
|
||||
DB()->sql_freeresult($result);
|
||||
}
|
||||
}
|
||||
DB()->sql_freeresult($result);
|
||||
}
|
||||
|
||||
if (!($result = DB()->sql_query($sql)))
|
||||
{
|
||||
bb_die('Unable to update quota settings');
|
||||
}
|
||||
|
||||
}
|
||||
else if ($mode == 'group')
|
||||
{
|
||||
if (!$quota_limit_id)
|
||||
{
|
||||
$sql = 'DELETE FROM ' . BB_QUOTA . "
|
||||
if (!($result = DB()->sql_query($sql))) {
|
||||
bb_die('Unable to update quota settings');
|
||||
}
|
||||
} elseif ($mode == 'group') {
|
||||
if (!$quota_limit_id) {
|
||||
$sql = 'DELETE FROM ' . BB_QUOTA . "
|
||||
WHERE group_id = $id
|
||||
AND quota_type = $quota_type";
|
||||
|
||||
if (!($result = DB()->sql_query($sql)))
|
||||
{
|
||||
bb_die('Unable to delete quota settings');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check if user is already entered
|
||||
$sql = 'SELECT group_id
|
||||
if (!($result = DB()->sql_query($sql))) {
|
||||
bb_die('Unable to delete quota settings');
|
||||
}
|
||||
} else {
|
||||
// Check if user is already entered
|
||||
$sql = 'SELECT group_id
|
||||
FROM ' . BB_QUOTA . "
|
||||
WHERE group_id = $id
|
||||
AND quota_type = $quota_type";
|
||||
|
||||
if (!($result = DB()->sql_query($sql)))
|
||||
{
|
||||
bb_die('Could not get entry #2');
|
||||
}
|
||||
if (!($result = DB()->sql_query($sql))) {
|
||||
bb_die('Could not get entry #2');
|
||||
}
|
||||
|
||||
if (DB()->num_rows($result) == 0)
|
||||
{
|
||||
$sql = 'INSERT INTO ' . BB_QUOTA . " (user_id, group_id, quota_type, quota_limit_id)
|
||||
if (DB()->num_rows($result) == 0) {
|
||||
$sql = 'INSERT INTO ' . BB_QUOTA . " (user_id, group_id, quota_type, quota_limit_id)
|
||||
VALUES (0, $id, $quota_type, $quota_limit_id)";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'UPDATE ' . BB_QUOTA . " SET quota_limit_id = $quota_limit_id
|
||||
} else {
|
||||
$sql = 'UPDATE ' . BB_QUOTA . " SET quota_limit_id = $quota_limit_id
|
||||
WHERE group_id = $id AND quota_type = $quota_type";
|
||||
}
|
||||
}
|
||||
|
||||
if (!DB()->sql_query($sql))
|
||||
{
|
||||
bb_die('Unable to update quota settings');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!DB()->sql_query($sql)) {
|
||||
bb_die('Unable to update quota settings');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sort multi-dimensional Array
|
||||
*/
|
||||
function sort_multi_array ($sort_array, $key, $sort_order, $pre_string_sort = 0)
|
||||
* sort multi-dimensional Array
|
||||
*/
|
||||
function sort_multi_array($sort_array, $key, $sort_order, $pre_string_sort = 0)
|
||||
{
|
||||
$last_element = sizeof($sort_array) - 1;
|
||||
$last_element = sizeof($sort_array) - 1;
|
||||
|
||||
if (!$pre_string_sort)
|
||||
{
|
||||
$string_sort = (!is_numeric(@$sort_array[$last_element-1][$key]) ) ? true : false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$string_sort = $pre_string_sort;
|
||||
}
|
||||
if (!$pre_string_sort) {
|
||||
$string_sort = (!is_numeric(@$sort_array[$last_element - 1][$key])) ? true : false;
|
||||
} else {
|
||||
$string_sort = $pre_string_sort;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $last_element; $i++)
|
||||
{
|
||||
$num_iterations = $last_element - $i;
|
||||
for ($i = 0; $i < $last_element; $i++) {
|
||||
$num_iterations = $last_element - $i;
|
||||
|
||||
for ($j = 0; $j < $num_iterations; $j++)
|
||||
{
|
||||
$next = 0;
|
||||
for ($j = 0; $j < $num_iterations; $j++) {
|
||||
$next = 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])))
|
||||
{
|
||||
$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))
|
||||
{
|
||||
$switch = true;
|
||||
}
|
||||
}
|
||||
// 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]))) {
|
||||
$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)) {
|
||||
$switch = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($switch)
|
||||
{
|
||||
$temp = $sort_array[$j];
|
||||
$sort_array[$j] = $sort_array[$j + 1];
|
||||
$sort_array[$j + 1] = $temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($switch) {
|
||||
$temp = $sort_array[$j];
|
||||
$sort_array[$j] = $sort_array[$j + 1];
|
||||
$sort_array[$j + 1] = $temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $sort_array;
|
||||
return $sort_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the filesize of the upload directory in human readable format
|
||||
*/
|
||||
* Returns the filesize of the upload directory in human readable format
|
||||
*/
|
||||
function get_formatted_dirsize()
|
||||
{
|
||||
global $attach_config, $upload_dir, $lang;
|
||||
global $attach_config, $upload_dir, $lang;
|
||||
|
||||
$upload_dir_size = 0;
|
||||
$upload_dir_size = 0;
|
||||
|
||||
if ($dirname = @opendir($upload_dir))
|
||||
{
|
||||
while ($file = @readdir($dirname))
|
||||
{
|
||||
if ($file != 'index.php' && $file != '.htaccess' && !is_dir($upload_dir . '/' . $file) && !is_link($upload_dir . '/' . $file))
|
||||
{
|
||||
$upload_dir_size += @filesize($upload_dir . '/' . $file);
|
||||
}
|
||||
}
|
||||
@closedir($dirname);
|
||||
}
|
||||
else
|
||||
{
|
||||
$upload_dir_size = $lang['NOT_AVAILABLE'];
|
||||
return $upload_dir_size;
|
||||
}
|
||||
if ($dirname = @opendir($upload_dir)) {
|
||||
while ($file = @readdir($dirname)) {
|
||||
if ($file != 'index.php' && $file != '.htaccess' && !is_dir($upload_dir . '/' . $file) && !is_link($upload_dir . '/' . $file)) {
|
||||
$upload_dir_size += @filesize($upload_dir . '/' . $file);
|
||||
}
|
||||
}
|
||||
@closedir($dirname);
|
||||
} else {
|
||||
$upload_dir_size = $lang['NOT_AVAILABLE'];
|
||||
return $upload_dir_size;
|
||||
}
|
||||
|
||||
return humn_size($upload_dir_size);
|
||||
return humn_size($upload_dir_size);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -193,161 +179,136 @@ function get_formatted_dirsize()
|
|||
*/
|
||||
function search_attachments($order_by, &$total_rows)
|
||||
{
|
||||
global $lang;
|
||||
global $lang;
|
||||
|
||||
$where_sql = array();
|
||||
$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');
|
||||
// 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], '');
|
||||
}
|
||||
for ($i = 0; $i < sizeof($search_vars); $i++) {
|
||||
$$search_vars[$i] = get_var($search_vars[$i], '');
|
||||
}
|
||||
|
||||
// Author name search
|
||||
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));
|
||||
// Author name search
|
||||
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));
|
||||
|
||||
// Prepare for directly going into sql query
|
||||
$search_author = str_replace('*', '%', attach_mod_sql_escape($search_author));
|
||||
// Prepare for directly going into sql query
|
||||
$search_author = str_replace('*', '%', attach_mod_sql_escape($search_author));
|
||||
|
||||
// We need the post_id's, because we want to query the Attachment Table
|
||||
$sql = 'SELECT user_id FROM ' . BB_USERS . " WHERE username LIKE '$search_author'";
|
||||
// We need the post_id's, because we want to query the Attachment Table
|
||||
$sql = 'SELECT user_id FROM ' . BB_USERS . " WHERE username LIKE '$search_author'";
|
||||
|
||||
if (!($result = DB()->sql_query($sql)))
|
||||
{
|
||||
bb_die('Could not obtain list of matching users (searching for: ' . $search_author . ')');
|
||||
}
|
||||
if (!($result = DB()->sql_query($sql))) {
|
||||
bb_die('Could not obtain list of matching users (searching for: ' . $search_author . ')');
|
||||
}
|
||||
|
||||
$matching_userids = '';
|
||||
if ( $row = DB()->sql_fetchrow($result) )
|
||||
{
|
||||
do
|
||||
{
|
||||
$matching_userids .= (($matching_userids != '') ? ', ' : '') . intval($row['user_id']);
|
||||
}
|
||||
while ($row = DB()->sql_fetchrow($result));
|
||||
$matching_userids = '';
|
||||
if ($row = DB()->sql_fetchrow($result)) {
|
||||
do {
|
||||
$matching_userids .= (($matching_userids != '') ? ', ' : '') . intval($row['user_id']);
|
||||
} while ($row = DB()->sql_fetchrow($result));
|
||||
|
||||
DB()->sql_freeresult($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
bb_die($lang['NO_ATTACH_SEARCH_MATCH']);
|
||||
}
|
||||
DB()->sql_freeresult($result);
|
||||
} else {
|
||||
bb_die($lang['NO_ATTACH_SEARCH_MATCH']);
|
||||
}
|
||||
|
||||
$where_sql[] = ' (t.user_id_1 IN (' . $matching_userids . ')) ';
|
||||
}
|
||||
$where_sql[] = ' (t.user_id_1 IN (' . $matching_userids . ')) ';
|
||||
}
|
||||
|
||||
// Search Keyword
|
||||
if ($search_keyword_fname != '')
|
||||
{
|
||||
$match_word = str_replace('*', '%', $search_keyword_fname);
|
||||
$where_sql[] = " (a.real_filename LIKE '" . attach_mod_sql_escape($match_word) . "') ";
|
||||
}
|
||||
// Search Keyword
|
||||
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 != '')
|
||||
{
|
||||
$match_word = str_replace('*', '%', $search_keyword_comment);
|
||||
$where_sql[] = " (a.comment LIKE '" . attach_mod_sql_escape($match_word) . "') ";
|
||||
}
|
||||
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 . ') ';
|
||||
}
|
||||
else if ($search_count_greater != '')
|
||||
{
|
||||
$where_sql[] = ' (a.download_count > ' . (int) $search_count_greater . ') ';
|
||||
}
|
||||
}
|
||||
// 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 Filesize
|
||||
if ($search_size_smaller != '' || $search_size_greater != '')
|
||||
{
|
||||
if ($search_size_smaller != '')
|
||||
{
|
||||
$where_sql[] = ' (a.filesize < ' . (int) $search_size_smaller . ') ';
|
||||
}
|
||||
else if ($search_size_greater != '')
|
||||
{
|
||||
$where_sql[] = ' (a.filesize > ' . (int) $search_size_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 Attachment Time
|
||||
if ($search_days_greater != '')
|
||||
{
|
||||
$where_sql[] = ' (a.filetime < ' . ( TIMENOW - ((int) $search_days_greater * 86400)) . ') ';
|
||||
}
|
||||
// Search Attachment Time
|
||||
if ($search_days_greater != '') {
|
||||
$where_sql[] = ' (a.filetime < ' . (TIMENOW - ((int)$search_days_greater * 86400)) . ') ';
|
||||
}
|
||||
|
||||
// Search Forum
|
||||
if ($search_forum)
|
||||
{
|
||||
$where_sql[] = ' (p.forum_id = ' . intval($search_forum) . ') ';
|
||||
}
|
||||
// Search Forum
|
||||
if ($search_forum) {
|
||||
$where_sql[] = ' (p.forum_id = ' . intval($search_forum) . ') ';
|
||||
}
|
||||
|
||||
// Search Cat... nope... sorry :(
|
||||
// Search Cat... nope... sorry :(
|
||||
|
||||
$sql = 'SELECT a.*, t.post_id, p.post_time, p.topic_id
|
||||
$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)
|
||||
{
|
||||
$sql .= implode('AND', $where_sql) . ' AND ';
|
||||
}
|
||||
if (sizeof($where_sql) > 0) {
|
||||
$sql .= implode('AND', $where_sql) . ' AND ';
|
||||
}
|
||||
|
||||
$sql .= 't.post_id = p.post_id AND a.attach_id = t.attach_id ';
|
||||
$sql .= 't.post_id = p.post_id AND a.attach_id = t.attach_id ';
|
||||
|
||||
$total_rows_sql = $sql;
|
||||
$total_rows_sql = $sql;
|
||||
|
||||
$sql .= $order_by;
|
||||
$sql .= $order_by;
|
||||
|
||||
if (!($result = DB()->sql_query($sql)))
|
||||
{
|
||||
bb_die('Could not query attachments #1');
|
||||
}
|
||||
if (!($result = DB()->sql_query($sql))) {
|
||||
bb_die('Could not query attachments #1');
|
||||
}
|
||||
|
||||
$attachments = DB()->sql_fetchrowset($result);
|
||||
$num_attach = DB()->num_rows($result);
|
||||
DB()->sql_freeresult($result);
|
||||
$attachments = DB()->sql_fetchrowset($result);
|
||||
$num_attach = DB()->num_rows($result);
|
||||
DB()->sql_freeresult($result);
|
||||
|
||||
if ($num_attach == 0)
|
||||
{
|
||||
bb_die($lang['NO_ATTACH_SEARCH_MATCH']);
|
||||
}
|
||||
if ($num_attach == 0) {
|
||||
bb_die($lang['NO_ATTACH_SEARCH_MATCH']);
|
||||
}
|
||||
|
||||
if (!($result = DB()->sql_query($total_rows_sql)))
|
||||
{
|
||||
bb_die('Could not query attachments #2');
|
||||
}
|
||||
if (!($result = DB()->sql_query($total_rows_sql))) {
|
||||
bb_die('Could not query attachments #2');
|
||||
}
|
||||
|
||||
$total_rows = DB()->num_rows($result);
|
||||
DB()->sql_freeresult($result);
|
||||
$total_rows = DB()->num_rows($result);
|
||||
DB()->sql_freeresult($result);
|
||||
|
||||
return $attachments;
|
||||
return $attachments;
|
||||
}
|
||||
|
||||
/**
|
||||
* perform LIMIT statement on arrays
|
||||
*/
|
||||
* perform LIMIT statement on arrays
|
||||
*/
|
||||
function limit_array($array, $start, $pagelimit)
|
||||
{
|
||||
// array from start - start+pagelimit
|
||||
$limit = (sizeof($array) < ($start + $pagelimit)) ? sizeof($array) : $start + $pagelimit;
|
||||
// array from start - start+pagelimit
|
||||
$limit = (sizeof($array) < ($start + $pagelimit)) ? sizeof($array) : $start + $pagelimit;
|
||||
|
||||
$limit_array = array();
|
||||
$limit_array = array();
|
||||
|
||||
for ($i = $start; $i < $limit; $i++)
|
||||
{
|
||||
$limit_array[] = $array[$i];
|
||||
}
|
||||
for ($i = $start; $i < $limit; $i++) {
|
||||
$limit_array[] = $array[$i];
|
||||
}
|
||||
|
||||
return $limit_array;
|
||||
}
|
||||
return $limit_array;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,284 +1,256 @@
|
|||
<?php
|
||||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2005-2017 TorrentPier
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* All Attachment Functions processing the Deletion Process
|
||||
*/
|
||||
* All Attachment Functions processing the Deletion Process
|
||||
*/
|
||||
|
||||
/**
|
||||
* Delete Attachment(s) from post(s) (intern)
|
||||
*/
|
||||
* Delete Attachment(s) from post(s) (intern)
|
||||
*/
|
||||
function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0, $user_id = 0)
|
||||
{
|
||||
global $bb_cfg;
|
||||
global $bb_cfg;
|
||||
|
||||
// Generate Array, if it's not an array
|
||||
if ($post_id_array === 0 && $attach_id_array === 0 && $page === 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Generate Array, if it's not an array
|
||||
if ($post_id_array === 0 && $attach_id_array === 0 && $page === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($post_id_array === 0 && $attach_id_array !== 0)
|
||||
{
|
||||
$post_id_array = array();
|
||||
if ($post_id_array === 0 && $attach_id_array !== 0) {
|
||||
$post_id_array = array();
|
||||
|
||||
if (!is_array($attach_id_array))
|
||||
{
|
||||
if (strstr($attach_id_array, ', '))
|
||||
{
|
||||
$attach_id_array = explode(', ', $attach_id_array);
|
||||
}
|
||||
else if (strstr($attach_id_array, ','))
|
||||
{
|
||||
$attach_id_array = explode(',', $attach_id_array);
|
||||
}
|
||||
else
|
||||
{
|
||||
$attach_id = intval($attach_id_array);
|
||||
$attach_id_array = array();
|
||||
$attach_id_array[] = $attach_id;
|
||||
}
|
||||
}
|
||||
if (!is_array($attach_id_array)) {
|
||||
if (strstr($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_array = array();
|
||||
$attach_id_array[] = $attach_id;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the post_ids to fill the array
|
||||
$p_id = 'post_id';
|
||||
// Get the post_ids to fill the array
|
||||
$p_id = 'post_id';
|
||||
|
||||
$sql = "SELECT $p_id
|
||||
$sql = "SELECT $p_id
|
||||
FROM " . BB_ATTACHMENTS . '
|
||||
WHERE attach_id IN (' . implode(', ', $attach_id_array) . ")
|
||||
GROUP BY $p_id";
|
||||
|
||||
if (!($result = DB()->sql_query($sql)))
|
||||
{
|
||||
bb_die('Could not select ids');
|
||||
}
|
||||
if (!($result = DB()->sql_query($sql))) {
|
||||
bb_die('Could not select ids');
|
||||
}
|
||||
|
||||
$num_post_list = DB()->num_rows($result);
|
||||
$num_post_list = DB()->num_rows($result);
|
||||
|
||||
if ($num_post_list == 0)
|
||||
{
|
||||
DB()->sql_freeresult($result);
|
||||
return;
|
||||
}
|
||||
if ($num_post_list == 0) {
|
||||
DB()->sql_freeresult($result);
|
||||
return;
|
||||
}
|
||||
|
||||
while ($row = DB()->sql_fetchrow($result))
|
||||
{
|
||||
$post_id_array[] = intval($row[$p_id]);
|
||||
}
|
||||
DB()->sql_freeresult($result);
|
||||
}
|
||||
while ($row = DB()->sql_fetchrow($result)) {
|
||||
$post_id_array[] = intval($row[$p_id]);
|
||||
}
|
||||
DB()->sql_freeresult($result);
|
||||
}
|
||||
|
||||
if (!is_array($post_id_array))
|
||||
{
|
||||
if (trim($post_id_array) == '')
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!is_array($post_id_array)) {
|
||||
if (trim($post_id_array) == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (strstr($post_id_array, ', '))
|
||||
{
|
||||
$post_id_array = explode(', ', $post_id_array);
|
||||
}
|
||||
else if (strstr($post_id_array, ','))
|
||||
{
|
||||
$post_id_array = explode(',', $post_id_array);
|
||||
}
|
||||
else
|
||||
{
|
||||
$post_id = intval($post_id_array);
|
||||
if (strstr($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_array = array();
|
||||
$post_id_array[] = $post_id;
|
||||
}
|
||||
}
|
||||
$post_id_array = array();
|
||||
$post_id_array[] = $post_id;
|
||||
}
|
||||
}
|
||||
|
||||
if (!sizeof($post_id_array))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!sizeof($post_id_array)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// First of all, determine the post id and attach_id
|
||||
if ($attach_id_array === 0)
|
||||
{
|
||||
$attach_id_array = array();
|
||||
// First of all, determine the post id and attach_id
|
||||
if ($attach_id_array === 0) {
|
||||
$attach_id_array = array();
|
||||
|
||||
// Get the attach_ids to fill the array
|
||||
$whereclause = 'WHERE post_id IN (' . implode(', ', $post_id_array) . ')';
|
||||
// Get the attach_ids to fill the array
|
||||
$whereclause = 'WHERE post_id IN (' . implode(', ', $post_id_array) . ')';
|
||||
|
||||
$sql = 'SELECT attach_id
|
||||
$sql = 'SELECT attach_id
|
||||
FROM ' . BB_ATTACHMENTS . " $whereclause
|
||||
GROUP BY attach_id";
|
||||
|
||||
if (!($result = DB()->sql_query($sql)))
|
||||
{
|
||||
bb_die('Could not select attachment id #1');
|
||||
}
|
||||
if (!($result = DB()->sql_query($sql))) {
|
||||
bb_die('Could not select attachment id #1');
|
||||
}
|
||||
|
||||
$num_attach_list = DB()->num_rows($result);
|
||||
$num_attach_list = DB()->num_rows($result);
|
||||
|
||||
if ($num_attach_list == 0)
|
||||
{
|
||||
DB()->sql_freeresult($result);
|
||||
return;
|
||||
}
|
||||
if ($num_attach_list == 0) {
|
||||
DB()->sql_freeresult($result);
|
||||
return;
|
||||
}
|
||||
|
||||
while ($row = DB()->sql_fetchrow($result))
|
||||
{
|
||||
$attach_id_array[] = (int) $row['attach_id'];
|
||||
}
|
||||
DB()->sql_freeresult($result);
|
||||
}
|
||||
while ($row = DB()->sql_fetchrow($result)) {
|
||||
$attach_id_array[] = (int)$row['attach_id'];
|
||||
}
|
||||
DB()->sql_freeresult($result);
|
||||
}
|
||||
|
||||
if (!is_array($attach_id_array))
|
||||
{
|
||||
if (strstr($attach_id_array, ', '))
|
||||
{
|
||||
$attach_id_array = explode(', ', $attach_id_array);
|
||||
}
|
||||
else if (strstr($attach_id_array, ','))
|
||||
{
|
||||
$attach_id_array = explode(',', $attach_id_array);
|
||||
}
|
||||
else
|
||||
{
|
||||
$attach_id = intval($attach_id_array);
|
||||
if (!is_array($attach_id_array)) {
|
||||
if (strstr($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_array = array();
|
||||
$attach_id_array[] = $attach_id;
|
||||
}
|
||||
}
|
||||
$attach_id_array = array();
|
||||
$attach_id_array[] = $attach_id;
|
||||
}
|
||||
}
|
||||
|
||||
if (!sizeof($attach_id_array))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!sizeof($attach_id_array)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sql_id = 'post_id';
|
||||
$sql_id = 'post_id';
|
||||
|
||||
if (sizeof($post_id_array) && sizeof($attach_id_array))
|
||||
{
|
||||
$sql = 'DELETE FROM ' . BB_ATTACHMENTS . '
|
||||
if (sizeof($post_id_array) && sizeof($attach_id_array)) {
|
||||
$sql = 'DELETE FROM ' . BB_ATTACHMENTS . '
|
||||
WHERE attach_id IN (' . implode(', ', $attach_id_array) . ")
|
||||
AND $sql_id IN (" . implode(', ', $post_id_array) . ')';
|
||||
|
||||
if (!(DB()->sql_query($sql)))
|
||||
{
|
||||
bb_die($lang['ERROR_DELETED_ATTACHMENTS']);
|
||||
}
|
||||
if (!(DB()->sql_query($sql))) {
|
||||
bb_die($lang['ERROR_DELETED_ATTACHMENTS']);
|
||||
}
|
||||
|
||||
//bt
|
||||
if ($sql_id == 'post_id')
|
||||
{
|
||||
$sql = "SELECT topic_id FROM ". BB_BT_TORRENTS ." WHERE attach_id IN(". implode(',', $attach_id_array) .")";
|
||||
//bt
|
||||
if ($sql_id == 'post_id') {
|
||||
$sql = "SELECT topic_id FROM " . BB_BT_TORRENTS . " WHERE attach_id IN(" . implode(',', $attach_id_array) . ")";
|
||||
|
||||
if (!$result = DB()->sql_query($sql))
|
||||
{
|
||||
bb_die($lang['ERROR_DELETED_ATTACHMENTS']);
|
||||
}
|
||||
if (!$result = DB()->sql_query($sql)) {
|
||||
bb_die($lang['ERROR_DELETED_ATTACHMENTS']);
|
||||
}
|
||||
|
||||
$torrents_sql = array();
|
||||
$torrents_sql = array();
|
||||
|
||||
while ($row = DB()->sql_fetchrow($result))
|
||||
{
|
||||
$torrents_sql[] = $row['topic_id'];
|
||||
}
|
||||
while ($row = DB()->sql_fetchrow($result)) {
|
||||
$torrents_sql[] = $row['topic_id'];
|
||||
}
|
||||
|
||||
if ($torrents_sql = implode(',', $torrents_sql))
|
||||
{
|
||||
// Remove peers from tracker
|
||||
$sql = "DELETE FROM ". BB_BT_TRACKER ."
|
||||
if ($torrents_sql = implode(',', $torrents_sql)) {
|
||||
// Remove peers from tracker
|
||||
$sql = "DELETE FROM " . BB_BT_TRACKER . "
|
||||
WHERE topic_id IN($torrents_sql)";
|
||||
|
||||
if (!DB()->sql_query($sql))
|
||||
{
|
||||
bb_die('Could not delete peers');
|
||||
}
|
||||
}
|
||||
// Delete torrents
|
||||
$sql = "DELETE FROM ". BB_BT_TORRENTS ."
|
||||
WHERE attach_id IN(". implode(',', $attach_id_array) .")";
|
||||
if (!DB()->sql_query($sql)) {
|
||||
bb_die('Could not delete peers');
|
||||
}
|
||||
}
|
||||
// Delete torrents
|
||||
$sql = "DELETE FROM " . BB_BT_TORRENTS . "
|
||||
WHERE attach_id IN(" . implode(',', $attach_id_array) . ")";
|
||||
|
||||
if (!DB()->sql_query($sql))
|
||||
{
|
||||
bb_die($lang['ERROR_DELETED_ATTACHMENTS']);
|
||||
}
|
||||
}
|
||||
//bt end
|
||||
if (!DB()->sql_query($sql)) {
|
||||
bb_die($lang['ERROR_DELETED_ATTACHMENTS']);
|
||||
}
|
||||
}
|
||||
//bt end
|
||||
|
||||
for ($i = 0; $i < sizeof($attach_id_array); $i++)
|
||||
{
|
||||
$sql = 'SELECT attach_id
|
||||
for ($i = 0; $i < sizeof($attach_id_array); $i++) {
|
||||
$sql = 'SELECT attach_id
|
||||
FROM ' . BB_ATTACHMENTS . '
|
||||
WHERE attach_id = ' . (int) $attach_id_array[$i];
|
||||
WHERE attach_id = ' . (int)$attach_id_array[$i];
|
||||
|
||||
if (!($result = DB()->sql_query($sql)))
|
||||
{
|
||||
bb_die('Could not select Attachment id #2');
|
||||
}
|
||||
if (!($result = DB()->sql_query($sql))) {
|
||||
bb_die('Could not select Attachment id #2');
|
||||
}
|
||||
|
||||
$num_rows = DB()->num_rows($result);
|
||||
DB()->sql_freeresult($result);
|
||||
$num_rows = DB()->num_rows($result);
|
||||
DB()->sql_freeresult($result);
|
||||
|
||||
if ($num_rows == 0)
|
||||
{
|
||||
$sql = 'SELECT attach_id, physical_filename, thumbnail
|
||||
if ($num_rows == 0) {
|
||||
$sql = 'SELECT attach_id, physical_filename, thumbnail
|
||||
FROM ' . BB_ATTACHMENTS_DESC . '
|
||||
WHERE attach_id = ' . (int) $attach_id_array[$i];
|
||||
WHERE attach_id = ' . (int)$attach_id_array[$i];
|
||||
|
||||
if (!($result = DB()->sql_query($sql)))
|
||||
{
|
||||
bb_die('Could not query attach description table');
|
||||
}
|
||||
$num_rows = DB()->num_rows($result);
|
||||
if (!($result = DB()->sql_query($sql))) {
|
||||
bb_die('Could not query attach description table');
|
||||
}
|
||||
$num_rows = DB()->num_rows($result);
|
||||
|
||||
if ($num_rows != 0)
|
||||
{
|
||||
$num_attach = $num_rows;
|
||||
$attachments = DB()->sql_fetchrowset($result);
|
||||
DB()->sql_freeresult($result);
|
||||
if ($num_rows != 0) {
|
||||
$num_attach = $num_rows;
|
||||
$attachments = DB()->sql_fetchrowset($result);
|
||||
DB()->sql_freeresult($result);
|
||||
|
||||
// delete attachments
|
||||
for ($j = 0; $j < $num_attach; $j++)
|
||||
{
|
||||
unlink_attach($attachments[$j]['physical_filename']);
|
||||
// delete attachments
|
||||
for ($j = 0; $j < $num_attach; $j++) {
|
||||
unlink_attach($attachments[$j]['physical_filename']);
|
||||
|
||||
if (intval($attachments[$j]['thumbnail']) == 1)
|
||||
{
|
||||
unlink_attach($attachments[$j]['physical_filename'], MODE_THUMBNAIL);
|
||||
}
|
||||
if (intval($attachments[$j]['thumbnail']) == 1) {
|
||||
unlink_attach($attachments[$j]['physical_filename'], MODE_THUMBNAIL);
|
||||
}
|
||||
|
||||
$sql = 'DELETE FROM ' . BB_ATTACHMENTS_DESC . ' WHERE attach_id = ' . (int) $attachments[$j]['attach_id'];
|
||||
$sql = 'DELETE FROM ' . BB_ATTACHMENTS_DESC . ' WHERE attach_id = ' . (int)$attachments[$j]['attach_id'];
|
||||
|
||||
if (!(DB()->sql_query($sql)))
|
||||
{
|
||||
bb_die($lang['ERROR_DELETED_ATTACHMENTS']);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DB()->sql_freeresult($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(DB()->sql_query($sql))) {
|
||||
bb_die($lang['ERROR_DELETED_ATTACHMENTS']);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DB()->sql_freeresult($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now Sync the Topic/PM
|
||||
if (sizeof($post_id_array))
|
||||
{
|
||||
$sql = 'SELECT topic_id
|
||||
// Now Sync the Topic/PM
|
||||
if (sizeof($post_id_array)) {
|
||||
$sql = 'SELECT topic_id
|
||||
FROM ' . BB_POSTS . '
|
||||
WHERE post_id IN (' . implode(', ', $post_id_array) . ')
|
||||
GROUP BY topic_id';
|
||||
|
||||
if (!($result = DB()->sql_query($sql)))
|
||||
{
|
||||
bb_die('Could not select topic id');
|
||||
}
|
||||
if (!($result = DB()->sql_query($sql))) {
|
||||
bb_die('Could not select topic id');
|
||||
}
|
||||
|
||||
while ($row = DB()->sql_fetchrow($result))
|
||||
{
|
||||
attachment_sync_topic($row['topic_id']);
|
||||
}
|
||||
DB()->sql_freeresult($result);
|
||||
}
|
||||
}
|
||||
while ($row = DB()->sql_fetchrow($result)) {
|
||||
attachment_sync_topic($row['topic_id']);
|
||||
}
|
||||
DB()->sql_freeresult($result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,293 +1,274 @@
|
|||
<?php
|
||||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2005-2017 TorrentPier
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* All Attachment Functions needed to determine Special Files/Dimensions
|
||||
*/
|
||||
* All Attachment Functions needed to determine Special Files/Dimensions
|
||||
*/
|
||||
|
||||
/**
|
||||
* Read Long Int (4 Bytes) from File
|
||||
*/
|
||||
* Read Long Int (4 Bytes) from File
|
||||
*/
|
||||
function read_longint($fp)
|
||||
{
|
||||
$data = fread($fp, 4);
|
||||
$data = fread($fp, 4);
|
||||
|
||||
$value = ord($data[0]) + (ord($data[1])<<8)+(ord($data[2])<<16)+(ord($data[3])<<24);
|
||||
if ($value >= 4294967294)
|
||||
{
|
||||
$value -= 4294967296;
|
||||
}
|
||||
$value = ord($data[0]) + (ord($data[1]) << 8) + (ord($data[2]) << 16) + (ord($data[3]) << 24);
|
||||
if ($value >= 4294967294) {
|
||||
$value -= 4294967296;
|
||||
}
|
||||
|
||||
return $value;
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Word (2 Bytes) from File - Note: It's an Intel Word
|
||||
*/
|
||||
* Read Word (2 Bytes) from File - Note: It's an Intel Word
|
||||
*/
|
||||
function read_word($fp)
|
||||
{
|
||||
$data = fread($fp, 2);
|
||||
$data = fread($fp, 2);
|
||||
|
||||
$value = ord($data[1]) * 256 + ord($data[0]);
|
||||
$value = ord($data[1]) * 256 + ord($data[0]);
|
||||
|
||||
return $value;
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Byte
|
||||
*/
|
||||
* Read Byte
|
||||
*/
|
||||
function read_byte($fp)
|
||||
{
|
||||
$data = fread($fp, 1);
|
||||
$data = fread($fp, 1);
|
||||
|
||||
$value = ord($data);
|
||||
$value = ord($data);
|
||||
|
||||
return $value;
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image Dimensions
|
||||
*/
|
||||
* Get Image Dimensions
|
||||
*/
|
||||
function image_getdimension($file)
|
||||
{
|
||||
$size = @getimagesize($file);
|
||||
|
||||
$size = @getimagesize($file);
|
||||
if ($size[0] != 0 || $size[1] != 0) {
|
||||
return $size;
|
||||
}
|
||||
|
||||
if ($size[0] != 0 || $size[1] != 0)
|
||||
{
|
||||
return $size;
|
||||
}
|
||||
// Try to get the Dimension manually, depending on the mimetype
|
||||
$fp = @fopen($file, 'rb');
|
||||
if (!$fp) {
|
||||
return $size;
|
||||
}
|
||||
|
||||
// Try to get the Dimension manually, depending on the mimetype
|
||||
$fp = @fopen($file, 'rb');
|
||||
if (!$fp)
|
||||
{
|
||||
return $size;
|
||||
}
|
||||
$error = false;
|
||||
|
||||
$error = FALSE;
|
||||
// BMP - IMAGE
|
||||
|
||||
// BMP - IMAGE
|
||||
$tmp_str = fread($fp, 2);
|
||||
if ($tmp_str == 'BM') {
|
||||
$length = read_longint($fp);
|
||||
|
||||
$tmp_str = fread($fp, 2);
|
||||
if ($tmp_str == 'BM')
|
||||
{
|
||||
$length = read_longint($fp);
|
||||
if ($length <= 6) {
|
||||
$error = true;
|
||||
}
|
||||
|
||||
if ($length <= 6)
|
||||
{
|
||||
$error = true;
|
||||
}
|
||||
if (!$error) {
|
||||
$i = read_longint($fp);
|
||||
if ($i != 0) {
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$i = read_longint($fp);
|
||||
if ( $i != 0)
|
||||
{
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
if (!$error) {
|
||||
$i = read_longint($fp);
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$i = read_longint($fp);
|
||||
if ($i != 0x3E && $i != 0x76 && $i != 0x436 && $i != 0x36) {
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($i != 0x3E && $i != 0x76 && $i != 0x436 && $i != 0x36)
|
||||
{
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
if (!$error) {
|
||||
$tmp_str = fread($fp, 4);
|
||||
$width = read_longint($fp);
|
||||
$height = read_longint($fp);
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$tmp_str = fread($fp, 4);
|
||||
$width = read_longint($fp);
|
||||
$height = read_longint($fp);
|
||||
if ($width > 3000 || $height > 3000) {
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error = true;
|
||||
}
|
||||
|
||||
if ($width > 3000 || $height > 3000)
|
||||
{
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = true;
|
||||
}
|
||||
if (!$error) {
|
||||
fclose($fp);
|
||||
return array(
|
||||
$width,
|
||||
$height,
|
||||
6
|
||||
);
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
fclose($fp);
|
||||
return array(
|
||||
$width,
|
||||
$height,
|
||||
6
|
||||
);
|
||||
}
|
||||
$error = false;
|
||||
fclose($fp);
|
||||
|
||||
$error = false;
|
||||
fclose($fp);
|
||||
// GIF - IMAGE
|
||||
|
||||
// GIF - IMAGE
|
||||
$fp = @fopen($file, 'rb');
|
||||
|
||||
$fp = @fopen($file, 'rb');
|
||||
$tmp_str = fread($fp, 3);
|
||||
|
||||
$tmp_str = fread($fp, 3);
|
||||
if ($tmp_str == 'GIF') {
|
||||
$tmp_str = fread($fp, 3);
|
||||
$width = read_word($fp);
|
||||
$height = read_word($fp);
|
||||
|
||||
if ($tmp_str == 'GIF')
|
||||
{
|
||||
$tmp_str = fread($fp, 3);
|
||||
$width = read_word($fp);
|
||||
$height = read_word($fp);
|
||||
$info_byte = fread($fp, 1);
|
||||
$info_byte = ord($info_byte);
|
||||
if (($info_byte & 0x80) != 0x80 && ($info_byte & 0x80) != 0) {
|
||||
$error = true;
|
||||
}
|
||||
|
||||
$info_byte = fread($fp, 1);
|
||||
$info_byte = ord($info_byte);
|
||||
if (($info_byte & 0x80) != 0x80 && ($info_byte & 0x80) != 0)
|
||||
{
|
||||
$error = true;
|
||||
}
|
||||
if (!$error) {
|
||||
if (($info_byte & 8) != 0) {
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error = true;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (($info_byte & 8) != 0)
|
||||
{
|
||||
$error = true;
|
||||
}
|
||||
if (!$error) {
|
||||
fclose($fp);
|
||||
return array(
|
||||
$width,
|
||||
$height,
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = true;
|
||||
}
|
||||
$error = false;
|
||||
fclose($fp);
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
fclose($fp);
|
||||
return array(
|
||||
$width,
|
||||
$height,
|
||||
1
|
||||
);
|
||||
}
|
||||
// JPG - IMAGE
|
||||
$fp = @fopen($file, 'rb');
|
||||
|
||||
$error = false;
|
||||
fclose($fp);
|
||||
$tmp_str = fread($fp, 4);
|
||||
$w1 = read_word($fp);
|
||||
|
||||
// JPG - IMAGE
|
||||
$fp = @fopen($file, 'rb');
|
||||
if (intval($w1) < 16) {
|
||||
$error = true;
|
||||
}
|
||||
|
||||
$tmp_str = fread($fp, 4);
|
||||
$w1 = read_word($fp);
|
||||
if (!$error) {
|
||||
$tmp_str = fread($fp, 4);
|
||||
if ($tmp_str == 'JFIF') {
|
||||
$o_byte = fread($fp, 1);
|
||||
if (intval($o_byte) != 0) {
|
||||
$error = true;
|
||||
}
|
||||
|
||||
if (intval($w1) < 16)
|
||||
{
|
||||
$error = true;
|
||||
}
|
||||
if (!$error) {
|
||||
$str = fread($fp, 2);
|
||||
$b = read_byte($fp);
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$tmp_str = fread($fp, 4);
|
||||
if ($tmp_str == 'JFIF')
|
||||
{
|
||||
$o_byte = fread($fp, 1);
|
||||
if (intval($o_byte) != 0)
|
||||
{
|
||||
$error = true;
|
||||
}
|
||||
if ($b != 0 && $b != 1 && $b != 2) {
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$str = fread($fp, 2);
|
||||
$b = read_byte($fp);
|
||||
if (!$error) {
|
||||
$width = read_word($fp);
|
||||
$height = read_word($fp);
|
||||
|
||||
if ($b != 0 && $b != 1 && $b != 2)
|
||||
{
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
if ($width <= 0 || $height <= 0) {
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error = true;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$width = read_word($fp);
|
||||
$height = read_word($fp);
|
||||
if (!$error) {
|
||||
fclose($fp);
|
||||
return array(
|
||||
$width,
|
||||
$height,
|
||||
2
|
||||
);
|
||||
}
|
||||
|
||||
if ($width <= 0 || $height <= 0)
|
||||
{
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = true;
|
||||
}
|
||||
$error = false;
|
||||
fclose($fp);
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
fclose($fp);
|
||||
return array(
|
||||
$width,
|
||||
$height,
|
||||
2
|
||||
);
|
||||
}
|
||||
// PCX - IMAGE
|
||||
|
||||
$error = false;
|
||||
fclose($fp);
|
||||
$fp = @fopen($file, 'rb');
|
||||
|
||||
// PCX - IMAGE
|
||||
$tmp_str = fread($fp, 3);
|
||||
|
||||
$fp = @fopen($file, 'rb');
|
||||
if ((ord($tmp_str[0]) == 10) && (ord($tmp_str[1]) == 0 || ord($tmp_str[1]) == 2 || ord($tmp_str[1]) == 3 || ord($tmp_str[1]) == 4 || ord($tmp_str[1]) == 5) && (ord($tmp_str[2]) == 1)) {
|
||||
$b = fread($fp, 1);
|
||||
|
||||
$tmp_str = fread($fp, 3);
|
||||
if (ord($b) != 1 && ord($b) != 2 && ord($b) != 4 && ord($b) != 8 && ord($b) != 24) {
|
||||
$error = true;
|
||||
}
|
||||
|
||||
if ((ord($tmp_str[0]) == 10) && (ord($tmp_str[1]) == 0 || ord($tmp_str[1]) == 2 || ord($tmp_str[1]) == 3 || ord($tmp_str[1]) == 4 || ord($tmp_str[1]) == 5) && (ord($tmp_str[2]) == 1))
|
||||
{
|
||||
$b = fread($fp, 1);
|
||||
if (!$error) {
|
||||
$xmin = read_word($fp);
|
||||
$ymin = read_word($fp);
|
||||
$xmax = read_word($fp);
|
||||
$ymax = read_word($fp);
|
||||
$tmp_str = fread($fp, 52);
|
||||
|
||||
if (ord($b) != 1 && ord($b) != 2 && ord($b) != 4 && ord($b) != 8 && ord($b) != 24)
|
||||
{
|
||||
$error = true;
|
||||
}
|
||||
$b = fread($fp, 1);
|
||||
if ($b != 0) {
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$xmin = read_word($fp);
|
||||
$ymin = read_word($fp);
|
||||
$xmax = read_word($fp);
|
||||
$ymax = read_word($fp);
|
||||
$tmp_str = fread($fp, 52);
|
||||
if (!$error) {
|
||||
$width = $xmax - $xmin + 1;
|
||||
$height = $ymax - $ymin + 1;
|
||||
}
|
||||
} else {
|
||||
$error = true;
|
||||
}
|
||||
|
||||
$b = fread($fp, 1);
|
||||
if ($b != 0)
|
||||
{
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
if (!$error) {
|
||||
fclose($fp);
|
||||
return array(
|
||||
$width,
|
||||
$height,
|
||||
7
|
||||
);
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$width = $xmax - $xmin + 1;
|
||||
$height = $ymax - $ymin + 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = true;
|
||||
}
|
||||
fclose($fp);
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
fclose($fp);
|
||||
return array(
|
||||
$width,
|
||||
$height,
|
||||
7
|
||||
);
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
|
||||
return $size;
|
||||
}
|
||||
return $size;
|
||||
}
|
||||
|
|
|
@ -1,204 +1,187 @@
|
|||
<?php
|
||||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2005-2017 TorrentPier
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Setup s_auth_can in viewforum and viewtopic (viewtopic.php/viewforum.php)
|
||||
*/
|
||||
* Setup s_auth_can in viewforum and viewtopic (viewtopic.php/viewforum.php)
|
||||
*/
|
||||
function attach_build_auth_levels($is_auth, &$s_auth_can)
|
||||
{
|
||||
global $lang, $attach_config;
|
||||
global $lang, $attach_config;
|
||||
|
||||
if (intval($attach_config['disable_mod']))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (intval($attach_config['disable_mod'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If you want to have the rules window link within the forum view too, comment out the two lines, and comment the third line
|
||||
$s_auth_can .= (($is_auth['auth_attachments']) ? $lang['RULES_ATTACH_CAN'] : $lang['RULES_ATTACH_CANNOT'] ) . '<br />';
|
||||
$s_auth_can .= (($is_auth['auth_download']) ? $lang['RULES_DOWNLOAD_CAN'] : $lang['RULES_DOWNLOAD_CANNOT'] ) . '<br />';
|
||||
// If you want to have the rules window link within the forum view too, comment out the two lines, and comment the third line
|
||||
$s_auth_can .= (($is_auth['auth_attachments']) ? $lang['RULES_ATTACH_CAN'] : $lang['RULES_ATTACH_CANNOT']) . '<br />';
|
||||
$s_auth_can .= (($is_auth['auth_download']) ? $lang['RULES_DOWNLOAD_CAN'] : $lang['RULES_DOWNLOAD_CANNOT']) . '<br />';
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from admin_users.php and admin_groups.php in order to process Quota Settings (admin/admin_users.php:admin/admin_groups.php)
|
||||
*/
|
||||
* Called from admin_users.php and admin_groups.php in order to process Quota Settings (admin/admin_users.php:admin/admin_groups.php)
|
||||
*/
|
||||
function attachment_quota_settings($admin_mode, $submit = false, $mode)
|
||||
{
|
||||
global $template, $lang, $attach_config;
|
||||
global $template, $lang, $attach_config;
|
||||
|
||||
if ($attach_config['upload_dir'][0] == '/' || ($attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':'))
|
||||
{
|
||||
$upload_dir = $attach_config['upload_dir'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$upload_dir = BB_ROOT . $attach_config['upload_dir'];
|
||||
}
|
||||
if ($attach_config['upload_dir'][0] == '/' || ($attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':')) {
|
||||
$upload_dir = $attach_config['upload_dir'];
|
||||
} else {
|
||||
$upload_dir = BB_ROOT . $attach_config['upload_dir'];
|
||||
}
|
||||
|
||||
include(ATTACH_DIR .'includes/functions_selects.php');
|
||||
if (!function_exists("process_quota_settings"))
|
||||
include(ATTACH_DIR . 'includes/functions_admin.php');
|
||||
include(ATTACH_DIR . 'includes/functions_selects.php');
|
||||
if (!function_exists("process_quota_settings")) {
|
||||
include(ATTACH_DIR . 'includes/functions_admin.php');
|
||||
}
|
||||
|
||||
$user_id = 0;
|
||||
$user_id = 0;
|
||||
|
||||
if ($admin_mode == 'user')
|
||||
{
|
||||
// We overwrite submit here... to be sure
|
||||
$submit = (isset($_POST['submit'])) ? true : false;
|
||||
if ($admin_mode == 'user') {
|
||||
// We overwrite submit here... to be sure
|
||||
$submit = (isset($_POST['submit'])) ? true : false;
|
||||
|
||||
if (!$submit && $mode != 'save')
|
||||
{
|
||||
$user_id = get_var(POST_USERS_URL, 0);
|
||||
$u_name = get_var('username', '');
|
||||
if (!$submit && $mode != 'save') {
|
||||
$user_id = get_var(POST_USERS_URL, 0);
|
||||
$u_name = get_var('username', '');
|
||||
|
||||
if (!$user_id && !$u_name)
|
||||
{
|
||||
bb_die($lang['NO_USER_ID_SPECIFIED'] );
|
||||
}
|
||||
if (!$user_id && !$u_name) {
|
||||
bb_die($lang['NO_USER_ID_SPECIFIED']);
|
||||
}
|
||||
|
||||
if ($user_id)
|
||||
{
|
||||
$this_userdata['user_id'] = $user_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get userdata is handling the sanitizing of username
|
||||
$this_userdata = get_userdata($_POST['username'], true);
|
||||
}
|
||||
if ($user_id) {
|
||||
$this_userdata['user_id'] = $user_id;
|
||||
} else {
|
||||
// Get userdata is handling the sanitizing of username
|
||||
$this_userdata = get_userdata($_POST['username'], true);
|
||||
}
|
||||
|
||||
$user_id = (int) $this_userdata['user_id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$user_id = get_var('id', 0);
|
||||
$user_id = (int)$this_userdata['user_id'];
|
||||
} else {
|
||||
$user_id = get_var('id', 0);
|
||||
|
||||
if (!$user_id)
|
||||
{
|
||||
bb_die($lang['NO_USER_ID_SPECIFIED'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$user_id) {
|
||||
bb_die($lang['NO_USER_ID_SPECIFIED']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($admin_mode == 'user' && !$submit && $mode != 'save')
|
||||
{
|
||||
// Show the contents
|
||||
$sql = 'SELECT quota_limit_id, quota_type FROM ' . BB_QUOTA . ' WHERE user_id = ' . (int) $user_id;
|
||||
if ($admin_mode == 'user' && !$submit && $mode != 'save') {
|
||||
// Show the contents
|
||||
$sql = 'SELECT quota_limit_id, quota_type FROM ' . BB_QUOTA . ' WHERE user_id = ' . (int)$user_id;
|
||||
|
||||
if (!($result = DB()->sql_query($sql)))
|
||||
{
|
||||
bb_die('Unable to get quota settings #1');
|
||||
}
|
||||
if (!($result = DB()->sql_query($sql))) {
|
||||
bb_die('Unable to get quota settings #1');
|
||||
}
|
||||
|
||||
$pm_quota = $upload_quota = 0;
|
||||
$pm_quota = $upload_quota = 0;
|
||||
|
||||
if ($row = DB()->sql_fetchrow($result))
|
||||
{
|
||||
do
|
||||
{
|
||||
if ($row['quota_type'] == QUOTA_UPLOAD_LIMIT)
|
||||
{
|
||||
$upload_quota = $row['quota_limit_id'];
|
||||
}
|
||||
else if ($row['quota_type'] == QUOTA_PM_LIMIT)
|
||||
{
|
||||
$pm_quota = $row['quota_limit_id'];
|
||||
}
|
||||
}
|
||||
while ($row = DB()->sql_fetchrow($result));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set Default Quota Limit
|
||||
$upload_quota = $attach_config['default_upload_quota'];
|
||||
$pm_quota = $attach_config['default_pm_quota'];
|
||||
if ($row = DB()->sql_fetchrow($result)) {
|
||||
do {
|
||||
if ($row['quota_type'] == QUOTA_UPLOAD_LIMIT) {
|
||||
$upload_quota = $row['quota_limit_id'];
|
||||
} elseif ($row['quota_type'] == QUOTA_PM_LIMIT) {
|
||||
$pm_quota = $row['quota_limit_id'];
|
||||
}
|
||||
} while ($row = DB()->sql_fetchrow($result));
|
||||
} else {
|
||||
// Set Default Quota Limit
|
||||
$upload_quota = $attach_config['default_upload_quota'];
|
||||
$pm_quota = $attach_config['default_pm_quota'];
|
||||
}
|
||||
DB()->sql_freeresult($result);
|
||||
|
||||
}
|
||||
DB()->sql_freeresult($result);
|
||||
$template->assign_vars(array(
|
||||
'S_SELECT_UPLOAD_QUOTA' => quota_limit_select('user_upload_quota', $upload_quota),
|
||||
'S_SELECT_PM_QUOTA' => quota_limit_select('user_pm_quota', $pm_quota),
|
||||
));
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_SELECT_UPLOAD_QUOTA' => quota_limit_select('user_upload_quota', $upload_quota),
|
||||
'S_SELECT_PM_QUOTA' => quota_limit_select('user_pm_quota', $pm_quota),
|
||||
));
|
||||
}
|
||||
if ($admin_mode == 'user' && $submit && @$_POST['delete_user']) {
|
||||
process_quota_settings($admin_mode, $user_id, QUOTA_UPLOAD_LIMIT, 0);
|
||||
process_quota_settings($admin_mode, $user_id, QUOTA_PM_LIMIT, 0);
|
||||
} elseif ($admin_mode == 'user' && $submit && $mode == 'save') {
|
||||
// Get the contents
|
||||
$upload_quota = get_var('user_upload_quota', 0);
|
||||
$pm_quota = get_var('user_pm_quota', 0);
|
||||
|
||||
if ($admin_mode == 'user' && $submit && @$_POST['delete_user'])
|
||||
{
|
||||
process_quota_settings($admin_mode, $user_id, QUOTA_UPLOAD_LIMIT, 0);
|
||||
process_quota_settings($admin_mode, $user_id, QUOTA_PM_LIMIT, 0);
|
||||
}
|
||||
else if ($admin_mode == 'user' && $submit && $mode == 'save')
|
||||
{
|
||||
// Get the contents
|
||||
$upload_quota = get_var('user_upload_quota', 0);
|
||||
$pm_quota = get_var('user_pm_quota', 0);
|
||||
process_quota_settings($admin_mode, $user_id, QUOTA_UPLOAD_LIMIT, $upload_quota);
|
||||
process_quota_settings($admin_mode, $user_id, QUOTA_PM_LIMIT, $pm_quota);
|
||||
}
|
||||
|
||||
process_quota_settings($admin_mode, $user_id, QUOTA_UPLOAD_LIMIT, $upload_quota);
|
||||
process_quota_settings($admin_mode, $user_id, QUOTA_PM_LIMIT, $pm_quota);
|
||||
}
|
||||
if ($admin_mode == 'group' && $mode == 'newgroup') {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($admin_mode == 'group' && $mode == 'newgroup')
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ($admin_mode == 'group' && !$submit && isset($_POST['edit'])) {
|
||||
// Get group id again
|
||||
$group_id = get_var(POST_GROUPS_URL, 0);
|
||||
|
||||
if ($admin_mode == 'group' && !$submit && isset($_POST['edit']))
|
||||
{
|
||||
// Get group id again
|
||||
$group_id = get_var(POST_GROUPS_URL, 0);
|
||||
// Show the contents
|
||||
$sql = 'SELECT quota_limit_id, quota_type FROM ' . BB_QUOTA . ' WHERE group_id = ' . (int)$group_id;
|
||||
|
||||
// Show the contents
|
||||
$sql = 'SELECT quota_limit_id, quota_type FROM ' . BB_QUOTA . ' WHERE group_id = ' . (int) $group_id;
|
||||
if (!($result = DB()->sql_query($sql))) {
|
||||
bb_die('Unable to get quota settings #2');
|
||||
}
|
||||
|
||||
if (!($result = DB()->sql_query($sql)))
|
||||
{
|
||||
bb_die('Unable to get quota settings #2');
|
||||
}
|
||||
$pm_quota = $upload_quota = 0;
|
||||
|
||||
$pm_quota = $upload_quota = 0;
|
||||
if ($row = DB()->sql_fetchrow($result)) {
|
||||
do {
|
||||
if ($row['quota_type'] == QUOTA_UPLOAD_LIMIT) {
|
||||
$upload_quota = $row['quota_limit_id'];
|
||||
} elseif ($row['quota_type'] == QUOTA_PM_LIMIT) {
|
||||
$pm_quota = $row['quota_limit_id'];
|
||||
}
|
||||
} while ($row = DB()->sql_fetchrow($result));
|
||||
} else {
|
||||
// Set Default Quota Limit
|
||||
$upload_quota = $attach_config['default_upload_quota'];
|
||||
$pm_quota = $attach_config['default_pm_quota'];
|
||||
}
|
||||
DB()->sql_freeresult($result);
|
||||
|
||||
if ($row = DB()->sql_fetchrow($result))
|
||||
{
|
||||
do
|
||||
{
|
||||
if ($row['quota_type'] == QUOTA_UPLOAD_LIMIT)
|
||||
{
|
||||
$upload_quota = $row['quota_limit_id'];
|
||||
}
|
||||
else if ($row['quota_type'] == QUOTA_PM_LIMIT)
|
||||
{
|
||||
$pm_quota = $row['quota_limit_id'];
|
||||
}
|
||||
}
|
||||
while ($row = DB()->sql_fetchrow($result));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set Default Quota Limit
|
||||
$upload_quota = $attach_config['default_upload_quota'];
|
||||
$pm_quota = $attach_config['default_pm_quota'];
|
||||
}
|
||||
DB()->sql_freeresult($result);
|
||||
$template->assign_vars(array(
|
||||
'S_SELECT_UPLOAD_QUOTA' => quota_limit_select('group_upload_quota', $upload_quota),
|
||||
'S_SELECT_PM_QUOTA' => quota_limit_select('group_pm_quota', $pm_quota),
|
||||
));
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_SELECT_UPLOAD_QUOTA' => quota_limit_select('group_upload_quota', $upload_quota),
|
||||
'S_SELECT_PM_QUOTA' => quota_limit_select('group_pm_quota', $pm_quota),
|
||||
));
|
||||
}
|
||||
if ($admin_mode == 'group' && $submit && isset($_POST['group_delete'])) {
|
||||
$group_id = get_var(POST_GROUPS_URL, 0);
|
||||
|
||||
if ($admin_mode == 'group' && $submit && isset($_POST['group_delete']))
|
||||
{
|
||||
$group_id = get_var(POST_GROUPS_URL, 0);
|
||||
process_quota_settings($admin_mode, $group_id, QUOTA_UPLOAD_LIMIT, 0);
|
||||
process_quota_settings($admin_mode, $group_id, QUOTA_PM_LIMIT, 0);
|
||||
} elseif ($admin_mode == 'group' && $submit) {
|
||||
$group_id = get_var(POST_GROUPS_URL, 0);
|
||||
|
||||
process_quota_settings($admin_mode, $group_id, QUOTA_UPLOAD_LIMIT, 0);
|
||||
process_quota_settings($admin_mode, $group_id, QUOTA_PM_LIMIT, 0);
|
||||
}
|
||||
else if ($admin_mode == 'group' && $submit)
|
||||
{
|
||||
$group_id = get_var(POST_GROUPS_URL, 0);
|
||||
// Get the contents
|
||||
$upload_quota = get_var('group_upload_quota', 0);
|
||||
$pm_quota = get_var('group_pm_quota', 0);
|
||||
|
||||
// Get the contents
|
||||
$upload_quota = get_var('group_upload_quota', 0);
|
||||
$pm_quota = get_var('group_pm_quota', 0);
|
||||
|
||||
process_quota_settings($admin_mode, $group_id, QUOTA_UPLOAD_LIMIT, $upload_quota);
|
||||
process_quota_settings($admin_mode, $group_id, QUOTA_PM_LIMIT, $pm_quota);
|
||||
}
|
||||
}
|
||||
process_quota_settings($admin_mode, $group_id, QUOTA_UPLOAD_LIMIT, $upload_quota);
|
||||
process_quota_settings($admin_mode, $group_id, QUOTA_PM_LIMIT, $pm_quota);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,251 +1,245 @@
|
|||
<?php
|
||||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2005-2017 TorrentPier
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Functions to build select boxes ;)
|
||||
*/
|
||||
* Functions to build select boxes ;)
|
||||
*/
|
||||
|
||||
/**
|
||||
* select group
|
||||
*/
|
||||
* select group
|
||||
*/
|
||||
function group_select($select_name, $default_group = 0)
|
||||
{
|
||||
global $lang;
|
||||
global $lang;
|
||||
|
||||
$sql = 'SELECT group_id, group_name FROM ' . BB_EXTENSION_GROUPS . ' ORDER BY group_name';
|
||||
$sql = 'SELECT group_id, group_name FROM ' . BB_EXTENSION_GROUPS . ' ORDER BY group_name';
|
||||
|
||||
if (!($result = DB()->sql_query($sql)))
|
||||
{
|
||||
bb_die('Could not query extension groups table #1');
|
||||
}
|
||||
if (!($result = DB()->sql_query($sql))) {
|
||||
bb_die('Could not query extension groups table #1');
|
||||
}
|
||||
|
||||
$group_select = '<select name="' . $select_name . '">';
|
||||
$group_select = '<select name="' . $select_name . '">';
|
||||
|
||||
$group_name = DB()->sql_fetchrowset($result);
|
||||
$num_rows = DB()->num_rows($result);
|
||||
DB()->sql_freeresult($result);
|
||||
$group_name = DB()->sql_fetchrowset($result);
|
||||
$num_rows = DB()->num_rows($result);
|
||||
DB()->sql_freeresult($result);
|
||||
|
||||
if ($num_rows > 0)
|
||||
{
|
||||
$group_name[$num_rows]['group_id'] = 0;
|
||||
$group_name[$num_rows]['group_name'] = $lang['NOT_ASSIGNED'];
|
||||
if ($num_rows > 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++)
|
||||
{
|
||||
if (!$default_group)
|
||||
{
|
||||
$selected = ($i == 0) ? ' selected="selected"' : '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$selected = ($group_name[$i]['group_id'] == $default_group) ? ' selected="selected"' : '';
|
||||
}
|
||||
for ($i = 0; $i < sizeof($group_name); $i++) {
|
||||
if (!$default_group) {
|
||||
$selected = ($i == 0) ? ' selected="selected"' : '';
|
||||
} else {
|
||||
$selected = ($group_name[$i]['group_id'] == $default_group) ? ' selected="selected"' : '';
|
||||
}
|
||||
|
||||
$group_select .= '<option value="' . $group_name[$i]['group_id'] . '"' . $selected . '>' . $group_name[$i]['group_name'] . '</option>';
|
||||
}
|
||||
}
|
||||
$group_select .= '<option value="' . $group_name[$i]['group_id'] . '"' . $selected . '>' . $group_name[$i]['group_name'] . '</option>';
|
||||
}
|
||||
}
|
||||
|
||||
$group_select .= '</select>';
|
||||
$group_select .= '</select>';
|
||||
|
||||
return $group_select;
|
||||
return $group_select;
|
||||
}
|
||||
|
||||
/**
|
||||
* select download mode
|
||||
*/
|
||||
* select download mode
|
||||
*/
|
||||
function download_select($select_name, $group_id = 0)
|
||||
{
|
||||
global $types_download, $modes_download;
|
||||
global $types_download, $modes_download;
|
||||
|
||||
if ($group_id)
|
||||
{
|
||||
$sql = 'SELECT download_mode
|
||||
if ($group_id) {
|
||||
$sql = 'SELECT download_mode
|
||||
FROM ' . BB_EXTENSION_GROUPS . '
|
||||
WHERE group_id = ' . (int) $group_id;
|
||||
WHERE group_id = ' . (int)$group_id;
|
||||
|
||||
if (!($result = DB()->sql_query($sql)))
|
||||
{
|
||||
bb_die('Could not query extension groups table #2');
|
||||
}
|
||||
$row = DB()->sql_fetchrow($result);
|
||||
DB()->sql_freeresult($result);
|
||||
if (!($result = DB()->sql_query($sql))) {
|
||||
bb_die('Could not query extension groups table #2');
|
||||
}
|
||||
$row = DB()->sql_fetchrow($result);
|
||||
DB()->sql_freeresult($result);
|
||||
|
||||
if (!isset($row['download_mode']))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
if (!isset($row['download_mode'])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$download_mode = $row['download_mode'];
|
||||
}
|
||||
$download_mode = $row['download_mode'];
|
||||
}
|
||||
|
||||
$group_select = '<select name="' . $select_name . '">';
|
||||
$group_select = '<select name="' . $select_name . '">';
|
||||
|
||||
for ($i = 0; $i < sizeof($types_download); $i++)
|
||||
{
|
||||
if (!$group_id)
|
||||
{
|
||||
$selected = ($types_download[$i] == INLINE_LINK) ? ' selected="selected"' : '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$selected = ($row['download_mode'] == $types_download[$i]) ? ' selected="selected"' : '';
|
||||
}
|
||||
for ($i = 0; $i < sizeof($types_download); $i++) {
|
||||
if (!$group_id) {
|
||||
$selected = ($types_download[$i] == INLINE_LINK) ? ' selected="selected"' : '';
|
||||
} else {
|
||||
$selected = ($row['download_mode'] == $types_download[$i]) ? ' selected="selected"' : '';
|
||||
}
|
||||
|
||||
$group_select .= '<option value="' . $types_download[$i] . '"' . $selected . '>' . $modes_download[$i] . '</option>';
|
||||
}
|
||||
$group_select .= '<option value="' . $types_download[$i] . '"' . $selected . '>' . $modes_download[$i] . '</option>';
|
||||
}
|
||||
|
||||
$group_select .= '</select>';
|
||||
$group_select .= '</select>';
|
||||
|
||||
return $group_select;
|
||||
return $group_select;
|
||||
}
|
||||
|
||||
/**
|
||||
* select category types
|
||||
*/
|
||||
* select category types
|
||||
*/
|
||||
function category_select($select_name, $group_id = 0)
|
||||
{
|
||||
global $types_category, $modes_category;
|
||||
global $types_category, $modes_category;
|
||||
|
||||
$sql = 'SELECT group_id, cat_id FROM ' . BB_EXTENSION_GROUPS;
|
||||
$sql = 'SELECT group_id, cat_id FROM ' . BB_EXTENSION_GROUPS;
|
||||
|
||||
if (!($result = DB()->sql_query($sql)))
|
||||
{
|
||||
bb_die('Could not select category');
|
||||
}
|
||||
if (!($result = DB()->sql_query($sql))) {
|
||||
bb_die('Could not select category');
|
||||
}
|
||||
|
||||
$rows = DB()->sql_fetchrowset($result);
|
||||
$num_rows = DB()->num_rows($result);
|
||||
DB()->sql_freeresult($result);
|
||||
$rows = DB()->sql_fetchrowset($result);
|
||||
$num_rows = DB()->num_rows($result);
|
||||
DB()->sql_freeresult($result);
|
||||
|
||||
$type_category = 0;
|
||||
$type_category = 0;
|
||||
|
||||
if ($num_rows > 0)
|
||||
{
|
||||
for ($i = 0; $i < $num_rows; $i++)
|
||||
{
|
||||
if ($group_id == $rows[$i]['group_id'])
|
||||
{
|
||||
$category_type = $rows[$i]['cat_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($num_rows > 0) {
|
||||
for ($i = 0; $i < $num_rows; $i++) {
|
||||
if ($group_id == $rows[$i]['group_id']) {
|
||||
$category_type = $rows[$i]['cat_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$types = array(NONE_CAT);
|
||||
$modes = array('none');
|
||||
$types = array(NONE_CAT);
|
||||
$modes = array('none');
|
||||
|
||||
for ($i = 0; $i < sizeof($types_category); $i++)
|
||||
{
|
||||
$types[] = $types_category[$i];
|
||||
$modes[] = $modes_category[$i];
|
||||
}
|
||||
for ($i = 0; $i < sizeof($types_category); $i++) {
|
||||
$types[] = $types_category[$i];
|
||||
$modes[] = $modes_category[$i];
|
||||
}
|
||||
|
||||
$group_select = '<select name="' . $select_name . '" style="width:100px">';
|
||||
$group_select = '<select name="' . $select_name . '" style="width:100px">';
|
||||
|
||||
for ($i = 0; $i < sizeof($types); $i++)
|
||||
{
|
||||
if (!$group_id)
|
||||
{
|
||||
$selected = ($types[$i] == NONE_CAT) ? ' selected="selected"' : '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$selected = ($types[$i] == $category_type) ? ' selected="selected"' : '';
|
||||
}
|
||||
for ($i = 0; $i < sizeof($types); $i++) {
|
||||
if (!$group_id) {
|
||||
$selected = ($types[$i] == NONE_CAT) ? ' selected="selected"' : '';
|
||||
} else {
|
||||
$selected = ($types[$i] == $category_type) ? ' selected="selected"' : '';
|
||||
}
|
||||
|
||||
$group_select .= '<option value="' . $types[$i] . '"' . $selected . '>' . $modes[$i] . '</option>';
|
||||
}
|
||||
$group_select .= '<option value="' . $types[$i] . '"' . $selected . '>' . $modes[$i] . '</option>';
|
||||
}
|
||||
|
||||
$group_select .= '</select>';
|
||||
$group_select .= '</select>';
|
||||
|
||||
return $group_select;
|
||||
return $group_select;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select size mode
|
||||
*/
|
||||
* Select size mode
|
||||
*/
|
||||
function size_select($select_name, $size_compare)
|
||||
{
|
||||
global $lang;
|
||||
global $lang;
|
||||
|
||||
$size_types_text = array($lang['BYTES'], $lang['KB'], $lang['MB']);
|
||||
$size_types = array('b', 'kb', 'mb');
|
||||
$size_types_text = array($lang['BYTES'], $lang['KB'], $lang['MB']);
|
||||
$size_types = array('b', 'kb', 'mb');
|
||||
|
||||
$select_field = '<select name="' . $select_name . '">';
|
||||
$select_field = '<select name="' . $select_name . '">';
|
||||
|
||||
for ($i = 0; $i < sizeof($size_types_text); $i++)
|
||||
{
|
||||
$selected = ($size_compare == $size_types[$i]) ? ' selected="selected"' : '';
|
||||
$select_field .= '<option value="' . $size_types[$i] . '"' . $selected . '>' . $size_types_text[$i] . '</option>';
|
||||
}
|
||||
for ($i = 0; $i < sizeof($size_types_text); $i++) {
|
||||
$selected = ($size_compare == $size_types[$i]) ? ' selected="selected"' : '';
|
||||
$select_field .= '<option value="' . $size_types[$i] . '"' . $selected . '>' . $size_types_text[$i] . '</option>';
|
||||
}
|
||||
|
||||
$select_field .= '</select>';
|
||||
$select_field .= '</select>';
|
||||
|
||||
return $select_field;
|
||||
return $select_field;
|
||||
}
|
||||
|
||||
/**
|
||||
* select quota limit
|
||||
*/
|
||||
* select quota limit
|
||||
*/
|
||||
function quota_limit_select($select_name, $default_quota = 0)
|
||||
{
|
||||
global $lang;
|
||||
global $lang;
|
||||
|
||||
$sql = 'SELECT quota_limit_id, quota_desc FROM ' . BB_QUOTA_LIMITS . ' ORDER BY quota_limit ASC';
|
||||
$sql = 'SELECT quota_limit_id, quota_desc FROM ' . BB_QUOTA_LIMITS . ' ORDER BY quota_limit ASC';
|
||||
|
||||
if (!($result = DB()->sql_query($sql)))
|
||||
{
|
||||
bb_die('Could not query quota limits table #1');
|
||||
}
|
||||
if (!($result = DB()->sql_query($sql))) {
|
||||
bb_die('Could not query quota limits table #1');
|
||||
}
|
||||
|
||||
$quota_select = '<select name="' . $select_name . '">';
|
||||
$quota_name[0]['quota_limit_id'] = 0;
|
||||
$quota_name[0]['quota_desc'] = $lang['NOT_ASSIGNED'];
|
||||
$quota_select = '<select name="' . $select_name . '">';
|
||||
$quota_name[0]['quota_limit_id'] = 0;
|
||||
$quota_name[0]['quota_desc'] = $lang['NOT_ASSIGNED'];
|
||||
|
||||
while ($row = DB()->sql_fetchrow($result))
|
||||
{
|
||||
$quota_name[] = $row;
|
||||
}
|
||||
DB()->sql_freeresult($result);
|
||||
while ($row = DB()->sql_fetchrow($result)) {
|
||||
$quota_name[] = $row;
|
||||
}
|
||||
DB()->sql_freeresult($result);
|
||||
|
||||
for ($i = 0; $i < sizeof($quota_name); $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>';
|
||||
}
|
||||
$quota_select .= '</select>';
|
||||
for ($i = 0; $i < sizeof($quota_name); $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>';
|
||||
}
|
||||
$quota_select .= '</select>';
|
||||
|
||||
return $quota_select;
|
||||
return $quota_select;
|
||||
}
|
||||
|
||||
/**
|
||||
* select default quota limit
|
||||
*/
|
||||
* select default quota limit
|
||||
*/
|
||||
function default_quota_limit_select($select_name, $default_quota = 0)
|
||||
{
|
||||
global $lang;
|
||||
global $lang;
|
||||
|
||||
$sql = 'SELECT quota_limit_id, quota_desc FROM ' . BB_QUOTA_LIMITS . ' ORDER BY quota_limit ASC';
|
||||
$sql = 'SELECT quota_limit_id, quota_desc FROM ' . BB_QUOTA_LIMITS . ' ORDER BY quota_limit ASC';
|
||||
|
||||
if (!($result = DB()->sql_query($sql)))
|
||||
{
|
||||
bb_die('Could not query quota limits table #2');
|
||||
}
|
||||
if (!($result = DB()->sql_query($sql))) {
|
||||
bb_die('Could not query quota limits table #2');
|
||||
}
|
||||
|
||||
$quota_select = '<select name="' . $select_name . '">';
|
||||
$quota_name[0]['quota_limit_id'] = 0;
|
||||
$quota_name[0]['quota_desc'] = $lang['NO_QUOTA_LIMIT'];
|
||||
$quota_select = '<select name="' . $select_name . '">';
|
||||
$quota_name[0]['quota_limit_id'] = 0;
|
||||
$quota_name[0]['quota_desc'] = $lang['NO_QUOTA_LIMIT'];
|
||||
|
||||
while ($row = DB()->sql_fetchrow($result))
|
||||
{
|
||||
$quota_name[] = $row;
|
||||
}
|
||||
DB()->sql_freeresult($result);
|
||||
while ($row = DB()->sql_fetchrow($result)) {
|
||||
$quota_name[] = $row;
|
||||
}
|
||||
DB()->sql_freeresult($result);
|
||||
|
||||
for ($i = 0; $i < sizeof($quota_name); $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>';
|
||||
}
|
||||
$quota_select .= '</select>';
|
||||
for ($i = 0; $i < sizeof($quota_name); $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>';
|
||||
}
|
||||
$quota_select .= '</select>';
|
||||
|
||||
return $quota_select;
|
||||
}
|
||||
return $quota_select;
|
||||
}
|
||||
|
|
|
@ -1,189 +1,194 @@
|
|||
<?php
|
||||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2005-2017 TorrentPier
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
if (!defined('IN_FORUM')) die("Hacking attempt");
|
||||
if (!defined('IN_FORUM')) {
|
||||
die("Hacking attempt");
|
||||
}
|
||||
|
||||
$imagick = '';
|
||||
|
||||
/**
|
||||
* Calculate the needed size for Thumbnail
|
||||
*/
|
||||
* Calculate the needed size for Thumbnail
|
||||
*/
|
||||
function get_img_size_format($width, $height)
|
||||
{
|
||||
// Maximum Width the Image can take
|
||||
$max_width = 400;
|
||||
// Maximum Width the Image can take
|
||||
$max_width = 400;
|
||||
|
||||
if ($width > $height)
|
||||
{
|
||||
return array(
|
||||
round($width * ($max_width / $width)),
|
||||
round($height * ($max_width / $width))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return array(
|
||||
round($width * ($max_width / $height)),
|
||||
round($height * ($max_width / $height))
|
||||
);
|
||||
}
|
||||
if ($width > $height) {
|
||||
return array(
|
||||
round($width * ($max_width / $width)),
|
||||
round($height * ($max_width / $width))
|
||||
);
|
||||
} else {
|
||||
return array(
|
||||
round($width * ($max_width / $height)),
|
||||
round($height * ($max_width / $height))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if imagick is present
|
||||
*/
|
||||
* Check if imagick is present
|
||||
*/
|
||||
function is_imagick()
|
||||
{
|
||||
global $imagick, $attach_config;
|
||||
global $imagick, $attach_config;
|
||||
|
||||
if ($attach_config['img_imagick'] != '')
|
||||
{
|
||||
$imagick = $attach_config['img_imagick'];
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ($attach_config['img_imagick'] != '') {
|
||||
$imagick = $attach_config['img_imagick'];
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get supported image types
|
||||
*/
|
||||
* Get supported image types
|
||||
*/
|
||||
function get_supported_image_types($type)
|
||||
{
|
||||
if (@extension_loaded('gd'))
|
||||
{
|
||||
$format = imagetypes();
|
||||
$new_type = 0;
|
||||
if (@extension_loaded('gd')) {
|
||||
$format = imagetypes();
|
||||
$new_type = 0;
|
||||
|
||||
switch ($type)
|
||||
{
|
||||
case 1:
|
||||
$new_type = ($format & IMG_GIF) ? IMG_GIF : 0;
|
||||
break;
|
||||
case 2:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
$new_type = ($format & IMG_JPG) ? IMG_JPG : 0;
|
||||
break;
|
||||
case 3:
|
||||
$new_type = ($format & IMG_PNG) ? IMG_PNG : 0;
|
||||
break;
|
||||
case 6:
|
||||
case 15:
|
||||
$new_type = ($format & IMG_WBMP) ? IMG_WBMP : 0;
|
||||
break;
|
||||
}
|
||||
switch ($type) {
|
||||
case 1:
|
||||
$new_type = ($format & IMG_GIF) ? IMG_GIF : 0;
|
||||
break;
|
||||
case 2:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
$new_type = ($format & IMG_JPG) ? IMG_JPG : 0;
|
||||
break;
|
||||
case 3:
|
||||
$new_type = ($format & IMG_PNG) ? IMG_PNG : 0;
|
||||
break;
|
||||
case 6:
|
||||
case 15:
|
||||
$new_type = ($format & IMG_WBMP) ? IMG_WBMP : 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return array(
|
||||
'gd' => ($new_type) ? true : false,
|
||||
'format' => $new_type,
|
||||
'version' => (function_exists('imagecreatetruecolor')) ? 2 : 1
|
||||
);
|
||||
}
|
||||
return array(
|
||||
'gd' => ($new_type) ? true : false,
|
||||
'format' => $new_type,
|
||||
'version' => (function_exists('imagecreatetruecolor')) ? 2 : 1
|
||||
);
|
||||
}
|
||||
|
||||
return array('gd' => false);
|
||||
return array('gd' => false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create thumbnail
|
||||
*/
|
||||
* Create thumbnail
|
||||
*/
|
||||
function create_thumbnail($source, $new_file, $mimetype)
|
||||
{
|
||||
global $attach_config, $imagick;
|
||||
global $attach_config, $imagick;
|
||||
|
||||
$source = amod_realpath($source);
|
||||
$min_filesize = (int) $attach_config['img_min_thumb_filesize'];
|
||||
$img_filesize = (@file_exists($source)) ? @filesize($source) : false;
|
||||
$source = amod_realpath($source);
|
||||
$min_filesize = (int)$attach_config['img_min_thumb_filesize'];
|
||||
$img_filesize = (@file_exists($source)) ? @filesize($source) : false;
|
||||
|
||||
if (!$img_filesize || $img_filesize <= $min_filesize)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!$img_filesize || $img_filesize <= $min_filesize) {
|
||||
return false;
|
||||
}
|
||||
|
||||
list($width, $height, $type, ) = getimagesize($source);
|
||||
list($width, $height, $type,) = getimagesize($source);
|
||||
|
||||
if (!$width || !$height)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!$width || !$height) {
|
||||
return false;
|
||||
}
|
||||
|
||||
list($new_width, $new_height) = get_img_size_format($width, $height);
|
||||
list($new_width, $new_height) = get_img_size_format($width, $height);
|
||||
|
||||
$tmp_path = $old_file = '';
|
||||
$tmp_path = $old_file = '';
|
||||
|
||||
$used_imagick = false;
|
||||
$used_imagick = false;
|
||||
|
||||
if (is_imagick())
|
||||
{
|
||||
passthru($imagick . ' -quality 85 -antialias -sample ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" +profile "*" "' . str_replace('\\', '/', $new_file) . '"');
|
||||
if (@file_exists($new_file))
|
||||
{
|
||||
$used_imagick = true;
|
||||
}
|
||||
}
|
||||
if (is_imagick()) {
|
||||
passthru($imagick . ' -quality 85 -antialias -sample ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" +profile "*" "' . str_replace('\\', '/', $new_file) . '"');
|
||||
if (@file_exists($new_file)) {
|
||||
$used_imagick = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$used_imagick)
|
||||
{
|
||||
$type = get_supported_image_types($type);
|
||||
if (!$used_imagick) {
|
||||
$type = get_supported_image_types($type);
|
||||
|
||||
if ($type['gd'])
|
||||
{
|
||||
switch ($type['format'])
|
||||
{
|
||||
case IMG_GIF:
|
||||
$image = imagecreatefromgif($source);
|
||||
break;
|
||||
case IMG_JPG:
|
||||
$image = imagecreatefromjpeg($source);
|
||||
break;
|
||||
case IMG_PNG:
|
||||
$image = imagecreatefrompng($source);
|
||||
break;
|
||||
case IMG_WBMP:
|
||||
$image = imagecreatefromwbmp($source);
|
||||
break;
|
||||
}
|
||||
if ($type['gd']) {
|
||||
switch ($type['format']) {
|
||||
case IMG_GIF:
|
||||
$image = imagecreatefromgif($source);
|
||||
break;
|
||||
case IMG_JPG:
|
||||
$image = imagecreatefromjpeg($source);
|
||||
break;
|
||||
case IMG_PNG:
|
||||
$image = imagecreatefrompng($source);
|
||||
break;
|
||||
case IMG_WBMP:
|
||||
$image = imagecreatefromwbmp($source);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($type['version'] == 1 || !$attach_config['use_gd2'])
|
||||
{
|
||||
$new_image = imagecreate($new_width, $new_height);
|
||||
imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
|
||||
}
|
||||
else
|
||||
{
|
||||
$new_image = imagecreatetruecolor($new_width, $new_height);
|
||||
imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
|
||||
}
|
||||
if ($type['version'] == 1 || !$attach_config['use_gd2']) {
|
||||
$new_image = imagecreate($new_width, $new_height);
|
||||
imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
|
||||
} else {
|
||||
$new_image = imagecreatetruecolor($new_width, $new_height);
|
||||
imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
|
||||
}
|
||||
|
||||
switch ($type['format'])
|
||||
{
|
||||
case IMG_GIF:
|
||||
imagegif($new_image, $new_file);
|
||||
break;
|
||||
case IMG_JPG:
|
||||
imagejpeg($new_image, $new_file, 90);
|
||||
break;
|
||||
case IMG_PNG:
|
||||
imagepng($new_image, $new_file);
|
||||
break;
|
||||
case IMG_WBMP:
|
||||
imagewbmp($new_image, $new_file);
|
||||
break;
|
||||
}
|
||||
switch ($type['format']) {
|
||||
case IMG_GIF:
|
||||
imagegif($new_image, $new_file);
|
||||
break;
|
||||
case IMG_JPG:
|
||||
imagejpeg($new_image, $new_file, 90);
|
||||
break;
|
||||
case IMG_PNG:
|
||||
imagepng($new_image, $new_file);
|
||||
break;
|
||||
case IMG_WBMP:
|
||||
imagewbmp($new_image, $new_file);
|
||||
break;
|
||||
}
|
||||
|
||||
imagedestroy($new_image);
|
||||
}
|
||||
}
|
||||
imagedestroy($new_image);
|
||||
}
|
||||
}
|
||||
|
||||
if (!@file_exists($new_file))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!@file_exists($new_file)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@chmod($new_file, 0664);
|
||||
@chmod($new_file, 0664);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue