acl_get('a_attach')) ? "$filename$SID&mode=attach" : '';
$module['POST']['ATTACHMENTS'] = ($auth->acl_get('a_attach')) ? "$filename$SID&mode=ext_groups" : '';
return;
}
define('IN_PHPBB', 1);
// Include files
$phpbb_root_path = './../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require('pagestart.' . $phpEx);
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
$user->add_lang(array('posting', 'viewtopic'));
if (!$auth->acl_get('a_attach'))
{
trigger_error($user->lang['NO_ADMIN']);
}
$mode = request_var('mode', '');
$submit = (isset($_POST['submit'])) ? true : false;
$error = $notify = array();
switch ($mode)
{
case 'attach':
$l_title = 'ATTACHMENT_SETTINGS';
break;
case 'extensions':
$l_title = 'MANAGE_EXTENSIONS';
break;
case 'ext_groups':
$l_title = 'EXTENSION_GROUPS_TITLE';
break;
case 'orphan':
$l_title = 'ORPHAN_ATTACHMENTS';
break;
default:
trigger_error('NO_MODE');
}
if ($mode == 'attach')
{
$config_sizes = array('max_filesize' => 'size', 'attachment_quota' => 'quota_size', 'max_filesize_pm' => 'pm_size');
foreach ($config_sizes as $cfg_key => $var)
{
$$var = request_var($var, '');
}
// Pull all config data
$sql = 'SELECT *
FROM ' . CONFIG_TABLE;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$config_name = $row['config_name'];
$config_value = $row['config_value'];
$default_config[$config_name] = $config_value;
$new[$config_name] = request_var($config_name, $default_config[$config_name]);
foreach ($config_sizes as $cfg_key => $var)
{
if (empty($$var) && !$submit && $config_name == $cfg_key)
{
$$var = (intval($default_config[$config_name]) >= 1048576) ? 'mb' : ((intval($default_config[$config_name]) >= 1024) ? 'kb' : 'b');
}
if (!$submit && $config_name == $cfg_key)
{
$new[$config_name] = ($new[$config_name] >= 1048576) ? round($new[$config_name] / 1048576 * 100) / 100 : (($new[$config_name] >= 1024) ? round($new[$config_name] / 1024 * 100) / 100 : $new[$config_name]);
}
if ($submit && $config_name == $cfg_key)
{
$old = $new[$config_name];
$new[$config_name] = ($$var == 'kb') ? round($new[$config_name] * 1024) : (($$var == 'mb') ? round($new[$config_name] * 1048576) : $new[$config_name]);
}
}
if ($submit)
{
set_config($config_name, $new[$config_name]);
if (in_array($config_name, array('max_filesize', 'attachment_quota', 'max_filesize_pm')))
{
$new[$config_name] = $old;
}
}
}
perform_site_list();
if ($submit)
{
add_log('admin', 'LOG_' . strtoupper($mode) . '_CONFIG');
// Check Settings
test_upload($error, $new['upload_dir'], false);
if (!sizeof($error))
{
trigger_error($user->lang['CONFIG_UPDATED']);
}
}
}
adm_page_header($user->lang[$l_title]);
if ($submit && $mode == 'extensions')
{
// Change Extensions ?
$extension_change_list = (isset($_POST['extension_change_list'])) ? array_map('intval', $_POST['extension_change_list']) : array();
$group_select_list = (isset($_POST['group_select'])) ? array_map('intval', $_POST['group_select']) : array();
// Generate correct Change List
$extensions = array();
for ($i = 0; $i < count($extension_change_list); $i++)
{
$extensions[$extension_change_list[$i]]['group_id'] = $group_select_list[$i];
}
$sql = 'SELECT *
FROM ' . EXTENSIONS_TABLE . '
ORDER BY extension_id';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
if ($row['group_id'] != $extensions[$row['extension_id']]['group_id'])
{
$sql = 'UPDATE ' . EXTENSIONS_TABLE . '
SET group_id = ' . (int) $extensions[$row['extension_id']]['group_id'] . '
WHERE extension_id = ' . $row['extension_id'];
$db->sql_query($sql);
add_log('admin', 'LOG_ATTACH_EXT_UPDATE', $row['extension']);
}
}
$db->sql_freeresult($result);
// Delete Extension ?
$extension_id_list = (isset($_POST['extension_id_list'])) ? array_map('intval', $_POST['extension_id_list']) : array();
if (sizeof($extension_id_list))
{
$sql = 'SELECT extension
FROM ' . EXTENSIONS_TABLE . '
WHERE extension_id IN (' . implode(', ', $extension_id_list) . ')';
$result = $db->sql_query($sql);
$extension_list = '';
while ($row = $db->sql_fetchrow($result))
{
$extension_list .= ($extension_list == '') ? $row['extension'] : ', ' . $row['extension'];
}
$db->sql_freeresult($result);
$sql = 'DELETE
FROM ' . EXTENSIONS_TABLE . '
WHERE extension_id IN (' . implode(', ', $extension_id_list) . ')';
$db->sql_query($sql);
add_log('admin', 'LOG_ATTACH_EXT_DEL', $extension_list);
}
// Add Extension ?
$add_extension = strtolower(request_var('add_extension', ''));
$add_extension_group = request_var('add_group_select', 0);
$add = (isset($_POST['add_extension_check'])) ? true : false;
if ($add_extension != '' && $add)
{
if (!sizeof($error))
{
$sql = 'SELECT extension_id
FROM ' . EXTENSIONS_TABLE . "
WHERE extension = '" . $db->sql_escape($add_extension) . "'";
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
$error[] = sprintf($user->lang['EXTENSION_EXIST'], $add_extension);
}
$db->sql_freeresult($result);
if (!sizeof($error))
{
$sql_ary = array(
'group_id' => $add_extension_group,
'extension' => $add_extension
);
$db->sql_query('INSERT INTO ' . EXTENSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
add_log('admin', 'LOG_ATTACH_EXT_ADD', $add_extension);
}
}
}
if (!sizeof($error))
{
$notify[] = $user->lang['EXTENSIONS_UPDATED'];
}
}
if ($submit && $mode == 'ext_groups')
{
$action = request_var('action', '');
$group_id = request_var('g', 0);
if ($action != 'add' && $action != 'edit')
{
trigger_error('WRONG_MODE');
}
if (!$group_id && $action == 'edit')
{
trigger_error('NO_EXT_GROUP_SPECIFIED');
}
if ($group_id)
{
$sql = 'SELECT * FROM ' . EXTENSION_GROUPS_TABLE . "
WHERE group_id = $group_id";
$result = $db->sql_query($sql);
$ext_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
}
else
{
$ext_row = array();
}
$group_name = request_var('group_name', '');
$new_group_name = ($action == 'add') ? $group_name : (($ext_row['group_name'] != $group_name) ? $group_name : '');
if (!$group_name)
{
$error[] = $user->lang['NO_EXT_GROUP_NAME'];
}
// Check New Group Name
if ($new_group_name)
{
$sql = 'SELECT group_id
FROM ' . EXTENSION_GROUPS_TABLE . "
WHERE LOWER(group_name) = '" . strtolower($new_group_name) . "'";
$result = $db->sql_query($sql);
if ($db->sql_fetchrow($result))
{
$error[] = sprintf($user->lang['EXTENSION_GROUP_EXIST'], $new_group_name);
}
$db->sql_freeresult($result);
}
if (!sizeof($error))
{
// Ok, build the update/insert array
$upload_icon = request_var('upload_icon', 'no_image');
$size_select = request_var('size_select', 'b');
$forum_select = request_var('forum_select', false);
$allowed_forums = isset($_REQUEST['allowed_forums']) ? array_map('intval', array_values($_REQUEST['allowed_forums'])) : array();
$allow_in_pm = isset($_REQUEST['allow_in_pm']) ? true : false;
$max_filesize = request_var('max_filesize', 0);
$max_filesize = ($size_select == 'kb') ? round($max_filesize * 1024) : (($size_select == 'mb') ? round($max_filesize * 1048576) : $max_filesize);
if ($max_filesize == $config['max_filesize'])
{
$max_filesize = 0;
}
if (!sizeof($allowed_forums))
{
$forum_select = false;
}
$group_ary = array(
'group_name' => $group_name,
'cat_id' => request_var('special_category', ATTACHMENT_CATEGORY_NONE),
'allow_group' => (isset($_REQUEST['allow_group'])) ? 1 : 0,
'download_mode' => request_var('download_mode', INLINE_LINK),
'upload_icon' => ($upload_icon == 'no_image') ? '' : $upload_icon,
'max_filesize' => $max_filesize,
'allowed_forums'=> ($forum_select) ? serialize($allowed_forums) : '',
'allow_in_pm' => ($allow_in_pm) ? 1 : 0
);
$sql = ($action == 'add') ? 'INSERT INTO ' . EXTENSION_GROUPS_TABLE . ' ' : 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' SET ';
$sql .= $db->sql_build_array((($action == 'add') ? 'INSERT' : 'UPDATE'), $group_ary);
$sql .= ($action == 'edit') ? " WHERE group_id = $group_id" : '';
$db->sql_query($sql);
if ($action == 'add')
{
$group_id = $db->sql_nextid();
}
add_log('admin', 'LOG_ATTACH_EXTGROUP_' . strtoupper($action), $group_name);
}
$extension_list = isset($_REQUEST['extensions']) ? array_map('intval', array_values($_REQUEST['extensions'])) : array();
if ($action == 'edit' && sizeof($extension_list))
{
$sql = 'UPDATE ' . EXTENSIONS_TABLE . "
SET group_id = 0
WHERE group_id = $group_id";
$db->sql_query($sql);
}
if (sizeof($extension_list))
{
$sql = 'UPDATE ' . EXTENSIONS_TABLE . "
SET group_id = $group_id
WHERE extension_id IN (" . implode(', ', $extension_list) . ")";
$db->sql_query($sql);
}
rewrite_extensions();
if (!sizeof($error))
{
$notify[] = $user->lang['SUCCESS_EXTENSION_GROUP_' . strtoupper($action)];
}
}
?>
lang[$l_title]; ?>
lang[$l_title . '_EXPLAIN']; ?>
lang['LOG_ATTACH_ORPHAN_DEL'], implode(', ', $delete_files)));
$notify[] = sprintf($user->lang['LOG_ATTACH_ORPHAN_DEL'], implode(', ', $delete_files));
}
$upload_list = array();
foreach ($add_files as $file)
{
if (!in_array($file, $delete_files) && $post_ids[$file])
{
$upload_list[$post_ids[$file]] = $file;
}
}
unset($add_files);
if (sizeof($upload_list))
{
?>
lang['UPLOADING_FILES']; ?>
sql_query($sql);
$forum_names = array();
while ($row = $db->sql_fetchrow($result))
{
$forum_names[$row['forum_id']] = $row['forum_name'];
}
$db->sql_freeresult($result);
$sql = 'SELECT forum_id, topic_id, post_id
FROM ' . POSTS_TABLE . '
WHERE post_id IN (' . implode(', ', array_keys($upload_list)) . ')';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
echo sprintf($user->lang['UPLOADING_FILE_TO'], $upload_list[$row['post_id']], $row['post_id']) . '
';
if (!$auth->acl_gets('f_attach', 'u_attach', $row['forum_id']))
{
echo '' . sprintf($user->lang['UPLOAD_DENIED_FORUM'], $forum_names[$row['forum_id']]) . '
';
}
else
{
upload_file($row['post_id'], $row['topic_id'], $row['forum_id'], $config['upload_dir'], $upload_list[$row['post_id']]);
}
}
unset($message_parser);
}
}
if (sizeof($error))
{
?>
lang['WARNING']; ?>
', $error); ?>
lang['NOTIFY']; ?>
', $notify); ?>
';
foreach ($modes as $_mode)
{
$s_select_mode .= '';
}
$s_select_mode .= '';
?>
$user->lang['NONE'],
ATTACHMENT_CATEGORY_IMAGE => $user->lang['CAT_IMAGES'],
ATTACHMENT_CATEGORY_WM => $user->lang['CAT_WM_FILES'],
ATTACHMENT_CATEGORY_RM => $user->lang['CAT_RM_FILES']
);
if ($group_id)
{
$sql = 'SELECT cat_id
FROM ' . EXTENSION_GROUPS_TABLE . '
WHERE group_id = ' . intval($group_id);
$result = $db->sql_query($sql);
$cat_type = (!($row = $db->sql_fetchrow($result))) ? ATTACHMENT_CATEGORY_NONE : $row['cat_id'];
$db->sql_freeresult($result);
}
else
{
$cat_type = ATTACHMENT_CATEGORY_NONE;
}
$group_select = '';
return $group_select;
}
// Extension group select
function group_select($select_name, $default_group = '-1')
{
global $db, $user;
$group_select = '';
return $group_select;
}
// Build select for download modes
function download_select($select_name, $group_id = false)
{
global $db, $user;
$types = array(
INLINE_LINK => $user->lang['MODE_INLINE'],
PHYSICAL_LINK => $user->lang['MODE_PHYSICAL']
);
if ($group_id)
{
$sql = "SELECT download_mode
FROM " . EXTENSION_GROUPS_TABLE . "
WHERE group_id = " . intval($group_id);
$result = $db->sql_query($sql);
$download_mode = (!($row = $db->sql_fetchrow($result))) ? INLINE_LINK : $row['download_mode'];
$db->sql_freeresult($result);
}
else
{
$download_mode = INLINE_LINK;
}
$group_select = '';
return $group_select;
}
// Upload already uploaded file... huh? are you kidding?
function upload_file($post_id, $topic_id, $forum_id, $upload_dir, $filename)
{
global $message_parser, $db, $user, $phpbb_root_path;
$message_parser->attachment_data = array();
$message_parser->filename_data['filecomment'] = '';
$message_parser->filename_data['filename'] = $phpbb_root_path . $upload_dir . '/' . basename($filename);
$filedata = upload_attachment($forum_id, $filename, true, $phpbb_root_path . $upload_dir . '/' . basename($filename));
if ($filedata['post_attach'] && !sizeof($filedata['error']))
{
$message_parser->attachment_data = array(
'post_msg_id' => $post_id,
'poster_id' => $user->data['user_id'],
'topic_id' => $topic_id,
'in_message' => 0,
'physical_filename' => $filedata['destination_filename'],
'real_filename' => $filedata['filename'],
'comment' => $message_parser->filename_data['filecomment'],
'extension' => $filedata['extension'],
'mimetype' => $filedata['mimetype'],
'filesize' => $filedata['filesize'],
'filetime' => $filedata['filetime'],
'thumbnail' => $filedata['thumbnail']
);
$message_parser->filename_data['filecomment'] = '';
$filedata['post_attach'] = FALSE;
// Submit Attachment
$attach_sql = $message_parser->attachment_data;
$db->sql_transaction();
$sql = 'INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . $db->sql_build_array('INSERT', $attach_sql);
$db->sql_query($sql);
$sql = 'UPDATE ' . POSTS_TABLE . "
SET post_attachment = 1
WHERE post_id = $post_id";
$db->sql_query($sql);
$sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_attachment = 1
WHERE topic_id = $topic_id";
$db->sql_query($sql);
$db->sql_transaction('commit');
add_log('admin', sprintf($user->lang['LOG_ATTACH_FILEUPLOAD'], $post_id, $filename));
echo '' . $user->lang['SUCCESSFULLY_UPLOADED'] . '
';
}
else if (sizeof($filedata['error']))
{
echo '' . sprintf($user->lang['ADMIN_UPLOAD_ERROR'], implode("
\t", $filedata['error'])) . '
';
}
}
// Search Imagick
function search_imagemagick()
{
$imagick = '';
$exe = ((defined('PHP_OS')) && (preg_match('#win#i', PHP_OS))) ? '.exe' : '';
if (empty($_ENV['MAGICK_HOME']))
{
$locations = array('C:/WINDOWS/', 'C:/WINNT/', 'C:/WINDOWS/SYSTEM/', 'C:/WINNT/SYSTEM/', 'C:/WINDOWS/SYSTEM32/', 'C:/WINNT/SYSTEM32/', '/usr/bin/', '/usr/sbin/', '/usr/local/bin/', '/usr/local/sbin/', '/opt/', '/usr/imagemagick/', '/usr/bin/imagemagick/');
foreach ($locations as $location)
{
if (@is_readable($location . 'mogrify' . $exe) && @filesize($location . 'mogrify' . $exe) > 3000)
{
$imagick = str_replace('\\', '/', $location);
continue;
}
}
}
else
{
$imagick = str_replace('\\', '/', $_ENV['MAGICK_HOME']);
}
return $imagick;
}
// Test Settings
function test_upload(&$error, $upload_dir, $create_directory = false)
{
global $user, $phpbb_root_path;
// Does the target directory exist, is it a directory and writeable.
if ($create_directory)
{
if (!file_exists($phpbb_root_path . $upload_dir))
{
@mkdir($phpbb_root_path . $upload_dir, 0777);
@chmod($phpbb_root_path . $upload_dir, 0777);
}
}
if (!file_exists($phpbb_root_path . $upload_dir))
{
$error[] = sprintf($user->lang['NO_UPLOAD_DIR'], $upload_dir);
return;
}
if (!is_dir($phpbb_root_path . $upload_dir))
{
$error[] = sprintf($user->lang['UPLOAD_NOT_DIR'], $upload_dir);
return;
}
if (!is_writable($phpbb_root_path . $upload_dir))
{
$error[] = sprintf($user->lang['NO_WRITE_UPLOAD'], $upload_dir);
return;
}
}
function perform_site_list()
{
global $db, $user;
if (isset($_REQUEST['securesubmit']))
{
// Grab the list of entries
$ips = request_var('ips', '');
$ip_list = array_unique(explode("\n", $ips));
$ip_list_log = implode(', ', $ip_list);
$ip_exclude = (!empty($_POST['ipexclude'])) ? 1 : 0;
$iplist = array();
$hostlist = array();
foreach ($ip_list as $item)
{
if (preg_match('#^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})[ ]*\-[ ]*([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$#', trim($item), $ip_range_explode))
{
// Don't ask about all this, just don't ask ... !
$ip_1_counter = $ip_range_explode[1];
$ip_1_end = $ip_range_explode[5];
while ($ip_1_counter <= $ip_1_end)
{
$ip_2_counter = ($ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[2] : 0;
$ip_2_end = ($ip_1_counter < $ip_1_end) ? 254 : $ip_range_explode[6];
if($ip_2_counter == 0 && $ip_2_end == 254)
{
$ip_2_counter = 256;
$ip_2_fragment = 256;
$iplist[] = "'$ip_1_counter.*'";
}
while ($ip_2_counter <= $ip_2_end)
{
$ip_3_counter = ($ip_2_counter == $ip_range_explode[2] && $ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[3] : 0;
$ip_3_end = ($ip_2_counter < $ip_2_end || $ip_1_counter < $ip_1_end) ? 254 : $ip_range_explode[7];
if ($ip_3_counter == 0 && $ip_3_end == 254)
{
$ip_3_counter = 256;
$ip_3_fragment = 256;
$iplist[] = "'$ip_1_counter.$ip_2_counter.*'";
}
while ($ip_3_counter <= $ip_3_end)
{
$ip_4_counter = ($ip_3_counter == $ip_range_explode[3] && $ip_2_counter == $ip_range_explode[2] && $ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[4] : 0;
$ip_4_end = ($ip_3_counter < $ip_3_end || $ip_2_counter < $ip_2_end) ? 254 : $ip_range_explode[8];
if ($ip_4_counter == 0 && $ip_4_end == 254)
{
$ip_4_counter = 256;
$ip_4_fragment = 256;
$iplist[] = "'$ip_1_counter.$ip_2_counter.$ip_3_counter.*'";
}
while ($ip_4_counter <= $ip_4_end)
{
$iplist[] = "'$ip_1_counter.$ip_2_counter.$ip_3_counter.$ip_4_counter'";
$ip_4_counter++;
}
$ip_3_counter++;
}
$ip_2_counter++;
}
$ip_1_counter++;
}
}
else if (preg_match('#^([0-9]{1,3})\.([0-9\*]{1,3})\.([0-9\*]{1,3})\.([0-9\*]{1,3})$#', trim($item)) || preg_match('#^[a-f0-9:]+\*?$#i', trim($item)))
{
$iplist[] = "'" . trim($item) . "'";
}
else if (preg_match('#^([\w\-_]\.?){2,}$#is', trim($item)))
{
$hostlist[] = "'" . trim($item) . "'";
}
else if (preg_match("#^([a-z0-9\-\*\._/]+?)$#is", trim($item)))
{
$hostlist[] = "'" . trim($item) . "'";
}
}
$sql = 'SELECT site_ip, site_hostname
FROM ' . SITELIST_TABLE . "
WHERE ip_exclude = $ip_exclude";
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
$iplist_tmp = array();
$hostlist_tmp = array();
do
{
if ($row['site_ip'])
{
$iplist_tmp[] = "'" . $row['site_ip'] . "'";
}
else if ($row['site_hostname'])
{
$hostlist_tmp[] = "'" . $row['site_hostname'] . "'";
}
break;
}
while ($row = $db->sql_fetchrow($result));
$iplist = array_unique(array_diff($iplist, $iplist_tmp));
$hostlist = array_unique(array_diff($hostlist, $hostlist_tmp));
unset($iplist_tmp);
unset($hostlist_tmp);
}
if (sizeof($iplist))
{
foreach ($iplist as $ip_entry)
{
$sql = 'INSERT INTO ' . SITELIST_TABLE . " (site_ip, ip_exclude)
VALUES ($ip_entry, $ip_exclude)";
$db->sql_query($sql);
}
}
if (sizeof($hostlist))
{
foreach ($hostlist as $host_entry)
{
$sql = 'INSERT INTO ' . SITELIST_TABLE . " (site_hostname, ip_exclude)
VALUES ($host_entry, $ip_exclude)";
$db->sql_query($sql);
}
}
if (!empty($ip_list_log))
{
// Update log
$log_entry = ($ip_exclude) ? 'LOG_DOWNLOAD_EXCLUDE_IP' : 'LOG_DOWNLOAD_IP';
add_log('admin', $log_entry, $ip_list_log);
}
trigger_error($user->lang['SECURE_DOWNLOAD_UPDATE_SUCCESS']);
}
else if (isset($_POST['unsecuresubmit']))
{
$unip_sql = implode(', ', array_map('intval', $_POST['unip']));
if ($unip_sql != '')
{
$l_unip_list = '';
// Grab details of ips for logging information later
$sql = 'SELECT site_ip, site_hostname
FROM ' . SITELIST_TABLE . "
WHERE site_id IN ($unip_sql)";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$l_unip_list .= (($l_unip_list != '') ? ', ' : '') . (($row['site_ip']) ? $row['site_ip'] : $row['site_hostname']);
}
$sql = 'DELETE FROM ' . SITELIST_TABLE . "
WHERE site_id IN ($unip_sql)";
$db->sql_query($sql);
add_log('admin', 'LOG_DOWNLOAD_REMOVE_IP', $l_unip_list);
}
trigger_error($user->lang['SECURE_DOWNLOAD_UPDATE_SUCCESS']);
}
}
// Re-Write extensions cache file
function rewrite_extensions()
{
global $db, $cache;
$sql = 'SELECT e.extension, g.*
FROM ' . EXTENSIONS_TABLE . ' e, ' . EXTENSION_GROUPS_TABLE . ' g
WHERE e.group_id = g.group_id
AND g.allow_group = 1';
$result = $db->sql_query($sql);
$extensions = array();
while ($row = $db->sql_fetchrow($result))
{
$extension = $row['extension'];
$extensions[$extension]['display_cat'] = (int) $row['cat_id'];
$extensions[$extension]['download_mode']= (int) $row['download_mode'];
$extensions[$extension]['upload_icon'] = (string) $row['upload_icon'];
$extensions[$extension]['max_filesize'] = (int) $row['max_filesize'];
$allowed_forums = ($row['allowed_forums']) ? unserialize(trim($row['allowed_forums'])) : array();
if ($row['allow_in_pm'])
{
$allowed_forums = array_merge($allowed_forums, array(0));
}
// Store allowed extensions forum wise
$extensions['_allowed_'][$extension] = (!sizeof($allowed_forums)) ? 0 : $allowed_forums;
}
$db->sql_freeresult($result);
$cache->destroy('extensions');
$cache->put('extensions', $extensions);
}
?>