root / branches / phpBB-3_0_0 / phpBB / includes / acp / acp_attachments.php
History | View | Annotate | Download (45 kB)
| 1 | 5303 | acydburn | <?php
|
|---|---|---|---|
| 2 | 8147 | acydburn | /**
|
| 3 | 5303 | acydburn | * |
| 4 | 5303 | acydburn | * @package acp |
| 5 | 5303 | acydburn | * @version $Id$ |
| 6 | 8147 | acydburn | * @copyright (c) 2005 phpBB Group |
| 7 | 8147 | acydburn | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
| 8 | 5303 | acydburn | * |
| 9 | 5303 | acydburn | */ |
| 10 | 5303 | acydburn | |
| 11 | 5303 | acydburn | /**
|
| 12 | 8147 | acydburn | * @ignore |
| 13 | 8147 | acydburn | */ |
| 14 | 8147 | acydburn | if (!defined('IN_PHPBB')) |
| 15 | 8147 | acydburn | {
|
| 16 | 8147 | acydburn | exit;
|
| 17 | 8147 | acydburn | } |
| 18 | 8147 | acydburn | |
| 19 | 8147 | acydburn | /**
|
| 20 | 5303 | acydburn | * @package acp |
| 21 | 5303 | acydburn | */ |
| 22 | 5303 | acydburn | class acp_attachments |
| 23 | 5303 | acydburn | {
|
| 24 | 5558 | acydburn | var $u_action; |
| 25 | 5902 | acydburn | var $new_config; |
| 26 | 8350 | acydburn | |
| 27 | 5303 | acydburn | function main($id, $mode) |
| 28 | 5303 | acydburn | {
|
| 29 | 5527 | acydburn | global $db, $user, $auth, $template, $cache; |
| 30 | 6015 | acydburn | global $config, $phpbb_admin_path, $phpbb_root_path, $phpEx; |
| 31 | 5303 | acydburn | |
| 32 | 5303 | acydburn | $user->add_lang(array('posting', 'viewtopic', 'acp/attachments')); |
| 33 | 5303 | acydburn | |
| 34 | 5303 | acydburn | $error = $notify = array(); |
| 35 | 5303 | acydburn | $submit = (isset($_POST['submit'])) ? true : false; |
| 36 | 5303 | acydburn | $action = request_var('action', ''); |
| 37 | 5303 | acydburn | |
| 38 | 8120 | kellanved | $form_key = 'acp_attach'; |
| 39 | 8120 | kellanved | add_form_key($form_key);
|
| 40 | 8120 | kellanved | |
| 41 | 8120 | kellanved | if ($submit && !check_form_key($form_key)) |
| 42 | 8120 | kellanved | {
|
| 43 | 8120 | kellanved | trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); |
| 44 | 8120 | kellanved | } |
| 45 | 8120 | kellanved | |
| 46 | 5303 | acydburn | switch ($mode) |
| 47 | 5303 | acydburn | {
|
| 48 | 5303 | acydburn | case 'attach': |
| 49 | 5303 | acydburn | $l_title = 'ACP_ATTACHMENT_SETTINGS'; |
| 50 | 5303 | acydburn | break;
|
| 51 | 5303 | acydburn | |
| 52 | 5303 | acydburn | case 'extensions': |
| 53 | 5303 | acydburn | $l_title = 'ACP_MANAGE_EXTENSIONS'; |
| 54 | 5303 | acydburn | break;
|
| 55 | 5303 | acydburn | |
| 56 | 5303 | acydburn | case 'ext_groups': |
| 57 | 5303 | acydburn | $l_title = 'ACP_EXTENSION_GROUPS'; |
| 58 | 5303 | acydburn | break;
|
| 59 | 8350 | acydburn | |
| 60 | 5303 | acydburn | case 'orphan': |
| 61 | 5303 | acydburn | $l_title = 'ACP_ORPHAN_ATTACHMENTS'; |
| 62 | 5303 | acydburn | break;
|
| 63 | 5303 | acydburn | |
| 64 | 5303 | acydburn | default:
|
| 65 | 6320 | acydburn | trigger_error('NO_MODE', E_USER_ERROR); |
| 66 | 6320 | acydburn | break;
|
| 67 | 5303 | acydburn | } |
| 68 | 5303 | acydburn | |
| 69 | 5303 | acydburn | $this->tpl_name = 'acp_attachments'; |
| 70 | 5310 | acydburn | $this->page_title = $l_title; |
| 71 | 5303 | acydburn | |
| 72 | 5303 | acydburn | $template->assign_vars(array( |
| 73 | 5303 | acydburn | 'L_TITLE' => $user->lang[$l_title], |
| 74 | 5303 | acydburn | 'L_TITLE_EXPLAIN' => $user->lang[$l_title . '_EXPLAIN'], |
| 75 | 6816 | acydburn | 'U_ACTION' => $this->u_action) |
| 76 | 5303 | acydburn | ); |
| 77 | 5303 | acydburn | |
| 78 | 5303 | acydburn | switch ($mode) |
| 79 | 5303 | acydburn | {
|
| 80 | 5303 | acydburn | case 'attach': |
| 81 | 5303 | acydburn | |
| 82 | 5303 | acydburn | include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); |
| 83 | 5303 | acydburn | |
| 84 | 5902 | acydburn | $sql = 'SELECT group_name, cat_id |
| 85 | 5902 | acydburn | FROM ' . EXTENSION_GROUPS_TABLE . ' |
| 86 | 5902 | acydburn | WHERE cat_id > 0 |
| 87 | 5902 | acydburn | ORDER BY cat_id';
|
| 88 | 5303 | acydburn | $result = $db->sql_query($sql); |
| 89 | 5303 | acydburn | |
| 90 | 5902 | acydburn | $s_assigned_groups = array(); |
| 91 | 5303 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 92 | 5303 | acydburn | {
|
| 93 | 10613 | git-gate | $row['group_name'] = (isset($user->lang['EXT_GROUP_' . $row['group_name']])) ? $user->lang['EXT_GROUP_' . $row['group_name']] : $row['group_name']; |
| 94 | 5902 | acydburn | $s_assigned_groups[$row['cat_id']][] = $row['group_name']; |
| 95 | 5902 | acydburn | } |
| 96 | 5902 | acydburn | $db->sql_freeresult($result); |
| 97 | 5303 | acydburn | |
| 98 | 7808 | acydburn | $l_legend_cat_images = $user->lang['SETTINGS_CAT_IMAGES'] . ' [' . $user->lang['ASSIGNED_GROUP'] . ': ' . ((!empty($s_assigned_groups[ATTACHMENT_CATEGORY_IMAGE])) ? implode(', ', $s_assigned_groups[ATTACHMENT_CATEGORY_IMAGE]) : $user->lang['NO_EXT_GROUP']) . ']'; |
| 99 | 5303 | acydburn | |
| 100 | 5902 | acydburn | $display_vars = array( |
| 101 | 5902 | acydburn | 'title' => 'ACP_ATTACHMENT_SETTINGS', |
| 102 | 5902 | acydburn | 'vars' => array( |
| 103 | 8495 | acydburn | 'legend1' => 'ACP_ATTACHMENT_SETTINGS', |
| 104 | 5902 | acydburn | |
| 105 | 8495 | acydburn | 'img_max_width' => array('lang' => 'MAX_IMAGE_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,), |
| 106 | 8495 | acydburn | 'img_max_height' => array('lang' => 'MAX_IMAGE_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,), |
| 107 | 8495 | acydburn | 'img_link_width' => array('lang' => 'IMAGE_LINK_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,), |
| 108 | 8495 | acydburn | 'img_link_height' => array('lang' => 'IMAGE_LINK_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,), |
| 109 | 8495 | acydburn | |
| 110 | 6367 | acydburn | 'allow_attachments' => array('lang' => 'ALLOW_ATTACHMENTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), |
| 111 | 6367 | acydburn | 'allow_pm_attach' => array('lang' => 'ALLOW_PM_ATTACHMENTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), |
| 112 | 6436 | acydburn | 'upload_path' => array('lang' => 'UPLOAD_DIR', 'validate' => 'wpath', 'type' => 'text:25:100', 'explain' => true), |
| 113 | 6367 | acydburn | 'display_order' => array('lang' => 'DISPLAY_ORDER', 'validate' => 'bool', 'type' => 'custom', 'method' => 'display_order', 'explain' => true), |
| 114 | 6698 | acydburn | 'attachment_quota' => array('lang' => 'ATTACH_QUOTA', 'validate' => 'string', 'type' => 'custom', 'method' => 'max_filesize', 'explain' => true), |
| 115 | 6698 | acydburn | 'max_filesize' => array('lang' => 'ATTACH_MAX_FILESIZE', 'validate' => 'string', 'type' => 'custom', 'method' => 'max_filesize', 'explain' => true), |
| 116 | 6698 | acydburn | 'max_filesize_pm' => array('lang' => 'ATTACH_MAX_PM_FILESIZE','validate' => 'string', 'type' => 'custom', 'method' => 'max_filesize', 'explain' => true), |
| 117 | 6367 | acydburn | 'max_attachments' => array('lang' => 'MAX_ATTACHMENTS', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => false), |
| 118 | 6367 | acydburn | 'max_attachments_pm' => array('lang' => 'MAX_ATTACHMENTS_PM', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => false), |
| 119 | 6367 | acydburn | 'secure_downloads' => array('lang' => 'SECURE_DOWNLOADS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), |
| 120 | 6367 | acydburn | 'secure_allow_deny' => array('lang' => 'SECURE_ALLOW_DENY', 'validate' => 'int', 'type' => 'custom', 'method' => 'select_allow_deny', 'explain' => true), |
| 121 | 8555 | Kellanved | 'secure_allow_empty_referer' => array('lang' => 'SECURE_EMPTY_REFERRER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), |
| 122 | 8555 | Kellanved | 'check_attachment_content' => array('lang' => 'CHECK_CONTENT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), |
| 123 | 5902 | acydburn | |
| 124 | 8555 | Kellanved | |
| 125 | 5902 | acydburn | 'legend2' => $l_legend_cat_images, |
| 126 | 6367 | acydburn | 'img_display_inlined' => array('lang' => 'DISPLAY_INLINED', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), |
| 127 | 6367 | acydburn | 'img_create_thumbnail' => array('lang' => 'CREATE_THUMBNAIL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), |
| 128 | 10441 | nickvergessen | 'img_max_thumb_width' => array('lang' => 'MAX_THUMB_WIDTH', 'validate' => 'int', 'type' => 'text:7:15', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), |
| 129 | 6367 | acydburn | 'img_min_thumb_filesize' => array('lang' => 'MIN_THUMB_FILESIZE', 'validate' => 'int', 'type' => 'text:7:15', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']), |
| 130 | 6367 | acydburn | 'img_imagick' => array('lang' => 'IMAGICK_PATH', 'validate' => 'string', 'type' => 'text:20:200', 'explain' => true, 'append' => ' <span>[ <a href="' . $this->u_action . '&action=imgmagick">' . $user->lang['SEARCH_IMAGICK'] . '</a> ]</span>'), |
| 131 | 10441 | nickvergessen | 'img_max' => array('lang' => 'MAX_IMAGE_SIZE', 'validate' => 'int', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), |
| 132 | 10441 | nickvergessen | 'img_link' => array('lang' => 'IMAGE_LINK_SIZE', 'validate' => 'int', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), |
| 133 | 5902 | acydburn | ) |
| 134 | 5902 | acydburn | ); |
| 135 | 5902 | acydburn | |
| 136 | 5902 | acydburn | $this->new_config = $config; |
| 137 | 5902 | acydburn | $cfg_array = (isset($_REQUEST['config'])) ? request_var('config', array('' => '')) : $this->new_config; |
| 138 | 6367 | acydburn | $error = array(); |
| 139 | 5902 | acydburn | |
| 140 | 6367 | acydburn | // We validate the complete config if whished
|
| 141 | 6367 | acydburn | validate_config_vars($display_vars['vars'], $cfg_array, $error); |
| 142 | 6367 | acydburn | |
| 143 | 6367 | acydburn | // Do not write values if there is an error
|
| 144 | 6367 | acydburn | if (sizeof($error)) |
| 145 | 6367 | acydburn | {
|
| 146 | 6367 | acydburn | $submit = false; |
| 147 | 6367 | acydburn | } |
| 148 | 6367 | acydburn | |
| 149 | 5902 | acydburn | // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
|
| 150 | 5902 | acydburn | foreach ($display_vars['vars'] as $config_name => $null) |
| 151 | 5902 | acydburn | {
|
| 152 | 5902 | acydburn | if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) |
| 153 | 5303 | acydburn | {
|
| 154 | 5902 | acydburn | continue;
|
| 155 | 5902 | acydburn | } |
| 156 | 5303 | acydburn | |
| 157 | 5902 | acydburn | $this->new_config[$config_name] = $config_value = $cfg_array[$config_name]; |
| 158 | 5303 | acydburn | |
| 159 | 5931 | acydburn | if (in_array($config_name, array('attachment_quota', 'max_filesize', 'max_filesize_pm'))) |
| 160 | 5902 | acydburn | {
|
| 161 | 5902 | acydburn | $size_var = request_var($config_name, ''); |
| 162 | 8529 | acydburn | $this->new_config[$config_name] = $config_value = ($size_var == 'kb') ? round($config_value * 1024) : (($size_var == 'mb') ? round($config_value * 1048576) : $config_value); |
| 163 | 5902 | acydburn | } |
| 164 | 5303 | acydburn | |
| 165 | 5303 | acydburn | if ($submit) |
| 166 | 5303 | acydburn | {
|
| 167 | 5902 | acydburn | set_config($config_name, $config_value); |
| 168 | 5303 | acydburn | } |
| 169 | 5303 | acydburn | } |
| 170 | 5303 | acydburn | |
| 171 | 5303 | acydburn | $this->perform_site_list();
|
| 172 | 5303 | acydburn | |
| 173 | 5303 | acydburn | if ($submit) |
| 174 | 5303 | acydburn | {
|
| 175 | 5310 | acydburn | add_log('admin', 'LOG_CONFIG_ATTACH'); |
| 176 | 5303 | acydburn | |
| 177 | 5303 | acydburn | // Check Settings
|
| 178 | 5902 | acydburn | $this->test_upload($error, $this->new_config['upload_path'], false); |
| 179 | 5303 | acydburn | |
| 180 | 5303 | acydburn | if (!sizeof($error)) |
| 181 | 5303 | acydburn | {
|
| 182 | 5558 | acydburn | trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); |
| 183 | 5303 | acydburn | } |
| 184 | 5303 | acydburn | } |
| 185 | 5303 | acydburn | |
| 186 | 5303 | acydburn | $template->assign_var('S_ATTACHMENT_SETTINGS', true); |
| 187 | 5902 | acydburn | |
| 188 | 5303 | acydburn | if ($action == 'imgmagick') |
| 189 | 5303 | acydburn | {
|
| 190 | 5902 | acydburn | $this->new_config['img_imagick'] = $this->search_imagemagick(); |
| 191 | 5303 | acydburn | } |
| 192 | 5303 | acydburn | |
| 193 | 5303 | acydburn | // We strip eventually manual added convert program, we only want the patch
|
| 194 | 8310 | acydburn | if ($this->new_config['img_imagick']) |
| 195 | 8310 | acydburn | {
|
| 196 | 8310 | acydburn | // Change path separator
|
| 197 | 8314 | acydburn | $this->new_config['img_imagick'] = str_replace('\\', '/', $this->new_config['img_imagick']); |
| 198 | 8310 | acydburn | $this->new_config['img_imagick'] = str_replace(array('convert', '.exe'), array('', ''), $this->new_config['img_imagick']); |
| 199 | 5303 | acydburn | |
| 200 | 8310 | acydburn | // Check for trailing slash
|
| 201 | 8314 | acydburn | if (substr($this->new_config['img_imagick'], -1) !== '/') |
| 202 | 8310 | acydburn | {
|
| 203 | 8314 | acydburn | $this->new_config['img_imagick'] .= '/'; |
| 204 | 8310 | acydburn | } |
| 205 | 8310 | acydburn | } |
| 206 | 8310 | acydburn | |
| 207 | 5303 | acydburn | $supported_types = get_supported_image_types();
|
| 208 | 5303 | acydburn | |
| 209 | 5303 | acydburn | // Check Thumbnail Support
|
| 210 | 5902 | acydburn | if (!$this->new_config['img_imagick'] && (!isset($supported_types['format']) || !sizeof($supported_types['format']))) |
| 211 | 5303 | acydburn | {
|
| 212 | 5902 | acydburn | $this->new_config['img_create_thumbnail'] = 0; |
| 213 | 5303 | acydburn | } |
| 214 | 5303 | acydburn | |
| 215 | 5303 | acydburn | $template->assign_vars(array( |
| 216 | 5558 | acydburn | 'U_SEARCH_IMAGICK' => $this->u_action . '&action=imgmagick', |
| 217 | 6816 | acydburn | 'S_THUMBNAIL_SUPPORT' => (!$this->new_config['img_imagick'] && (!isset($supported_types['format']) || !sizeof($supported_types['format']))) ? false : true) |
| 218 | 5303 | acydburn | ); |
| 219 | 5303 | acydburn | |
| 220 | 5303 | acydburn | // Secure Download Options - Same procedure as with banning
|
| 221 | 5902 | acydburn | $allow_deny = ($this->new_config['secure_allow_deny']) ? 'ALLOWED' : 'DISALLOWED'; |
| 222 | 8350 | acydburn | |
| 223 | 5303 | acydburn | $sql = 'SELECT * |
| 224 | 5303 | acydburn | FROM ' . SITELIST_TABLE; |
| 225 | 5303 | acydburn | $result = $db->sql_query($sql); |
| 226 | 5303 | acydburn | |
| 227 | 5303 | acydburn | $defined_ips = ''; |
| 228 | 5303 | acydburn | $ips = array(); |
| 229 | 5303 | acydburn | |
| 230 | 5303 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 231 | 5303 | acydburn | {
|
| 232 | 5303 | acydburn | $value = ($row['site_ip']) ? $row['site_ip'] : $row['site_hostname']; |
| 233 | 5303 | acydburn | if ($value) |
| 234 | 5303 | acydburn | {
|
| 235 | 6930 | acydburn | $defined_ips .= '<option' . (($row['ip_exclude']) ? ' class="sep"' : '') . ' value="' . $row['site_id'] . '">' . $value . '</option>'; |
| 236 | 5303 | acydburn | $ips[$row['site_id']] = $value; |
| 237 | 5303 | acydburn | } |
| 238 | 5303 | acydburn | } |
| 239 | 5303 | acydburn | $db->sql_freeresult($result); |
| 240 | 5303 | acydburn | |
| 241 | 5303 | acydburn | $template->assign_vars(array( |
| 242 | 5902 | acydburn | 'S_SECURE_DOWNLOADS' => $this->new_config['secure_downloads'], |
| 243 | 5303 | acydburn | 'S_DEFINED_IPS' => ($defined_ips != '') ? true : false, |
| 244 | 6367 | acydburn | 'S_WARNING' => (sizeof($error)) ? true : false, |
| 245 | 5303 | acydburn | |
| 246 | 6367 | acydburn | 'WARNING_MSG' => implode('<br />', $error), |
| 247 | 5303 | acydburn | 'DEFINED_IPS' => $defined_ips, |
| 248 | 5303 | acydburn | |
| 249 | 5303 | acydburn | 'L_SECURE_TITLE' => $user->lang['DEFINE_' . $allow_deny . '_IPS'], |
| 250 | 5303 | acydburn | 'L_IP_EXCLUDE' => $user->lang['EXCLUDE_FROM_' . $allow_deny . '_IP'], |
| 251 | 6816 | acydburn | 'L_REMOVE_IPS' => $user->lang['REMOVE_' . $allow_deny . '_IPS']) |
| 252 | 5303 | acydburn | ); |
| 253 | 5303 | acydburn | |
| 254 | 5902 | acydburn | // Output relevant options
|
| 255 | 5902 | acydburn | foreach ($display_vars['vars'] as $config_key => $vars) |
| 256 | 5902 | acydburn | {
|
| 257 | 5902 | acydburn | if (!is_array($vars) && strpos($config_key, 'legend') === false) |
| 258 | 5902 | acydburn | {
|
| 259 | 5902 | acydburn | continue;
|
| 260 | 5902 | acydburn | } |
| 261 | 5902 | acydburn | |
| 262 | 5902 | acydburn | if (strpos($config_key, 'legend') !== false) |
| 263 | 5902 | acydburn | {
|
| 264 | 5902 | acydburn | $template->assign_block_vars('options', array( |
| 265 | 5902 | acydburn | 'S_LEGEND' => true, |
| 266 | 5902 | acydburn | 'LEGEND' => (isset($user->lang[$vars])) ? $user->lang[$vars] : $vars) |
| 267 | 5902 | acydburn | ); |
| 268 | 5902 | acydburn | |
| 269 | 5902 | acydburn | continue;
|
| 270 | 5902 | acydburn | } |
| 271 | 5902 | acydburn | |
| 272 | 5902 | acydburn | $type = explode(':', $vars['type']); |
| 273 | 5902 | acydburn | |
| 274 | 5902 | acydburn | $l_explain = ''; |
| 275 | 5902 | acydburn | if ($vars['explain'] && isset($vars['lang_explain'])) |
| 276 | 5902 | acydburn | {
|
| 277 | 5902 | acydburn | $l_explain = (isset($user->lang[$vars['lang_explain']])) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain']; |
| 278 | 5902 | acydburn | } |
| 279 | 5902 | acydburn | else if ($vars['explain']) |
| 280 | 5902 | acydburn | {
|
| 281 | 5902 | acydburn | $l_explain = (isset($user->lang[$vars['lang'] . '_EXPLAIN'])) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : ''; |
| 282 | 5902 | acydburn | } |
| 283 | 8763 | acydburn | |
| 284 | 8497 | Kellanved | $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars); |
| 285 | 8497 | Kellanved | if (empty($content)) |
| 286 | 8497 | Kellanved | {
|
| 287 | 8497 | Kellanved | continue;
|
| 288 | 8497 | Kellanved | } |
| 289 | 5902 | acydburn | |
| 290 | 5902 | acydburn | $template->assign_block_vars('options', array( |
| 291 | 5902 | acydburn | 'KEY' => $config_key, |
| 292 | 5902 | acydburn | 'TITLE' => $user->lang[$vars['lang']], |
| 293 | 5902 | acydburn | 'S_EXPLAIN' => $vars['explain'], |
| 294 | 5902 | acydburn | 'TITLE_EXPLAIN' => $l_explain, |
| 295 | 8497 | Kellanved | 'CONTENT' => $content, |
| 296 | 5902 | acydburn | ) |
| 297 | 5902 | acydburn | ); |
| 298 | 8350 | acydburn | |
| 299 | 5902 | acydburn | unset($display_vars['vars'][$config_key]); |
| 300 | 5902 | acydburn | } |
| 301 | 5902 | acydburn | |
| 302 | 5303 | acydburn | break;
|
| 303 | 5303 | acydburn | |
| 304 | 5303 | acydburn | case 'extensions': |
| 305 | 5303 | acydburn | |
| 306 | 5303 | acydburn | if ($submit || isset($_POST['add_extension_check'])) |
| 307 | 5303 | acydburn | {
|
| 308 | 5303 | acydburn | if ($submit) |
| 309 | 5303 | acydburn | {
|
| 310 | 5303 | acydburn | // Change Extensions ?
|
| 311 | 6816 | acydburn | $extension_change_list = request_var('extension_change_list', array(0)); |
| 312 | 6816 | acydburn | $group_select_list = request_var('group_select', array(0)); |
| 313 | 5303 | acydburn | |
| 314 | 5303 | acydburn | // Generate correct Change List
|
| 315 | 5303 | acydburn | $extensions = array(); |
| 316 | 5303 | acydburn | |
| 317 | 5303 | acydburn | for ($i = 0, $size = sizeof($extension_change_list); $i < $size; $i++) |
| 318 | 5303 | acydburn | {
|
| 319 | 5303 | acydburn | $extensions[$extension_change_list[$i]]['group_id'] = $group_select_list[$i]; |
| 320 | 5303 | acydburn | } |
| 321 | 5303 | acydburn | |
| 322 | 5303 | acydburn | $sql = 'SELECT * |
| 323 | 5303 | acydburn | FROM ' . EXTENSIONS_TABLE . ' |
| 324 | 5303 | acydburn | ORDER BY extension_id';
|
| 325 | 5303 | acydburn | $result = $db->sql_query($sql); |
| 326 | 5303 | acydburn | |
| 327 | 5303 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 328 | 5303 | acydburn | {
|
| 329 | 5303 | acydburn | if ($row['group_id'] != $extensions[$row['extension_id']]['group_id']) |
| 330 | 5303 | acydburn | {
|
| 331 | 8147 | acydburn | $sql = 'UPDATE ' . EXTENSIONS_TABLE . ' |
| 332 | 5303 | acydburn | SET group_id = ' . (int) $extensions[$row['extension_id']]['group_id'] . ' |
| 333 | 5303 | acydburn | WHERE extension_id = ' . $row['extension_id']; |
| 334 | 6816 | acydburn | $db->sql_query($sql); |
| 335 | 6073 | acydburn | |
| 336 | 5303 | acydburn | add_log('admin', 'LOG_ATTACH_EXT_UPDATE', $row['extension']); |
| 337 | 5303 | acydburn | } |
| 338 | 5303 | acydburn | } |
| 339 | 5303 | acydburn | $db->sql_freeresult($result); |
| 340 | 5303 | acydburn | |
| 341 | 5622 | acydburn | // Delete Extension?
|
| 342 | 6816 | acydburn | $extension_id_list = request_var('extension_id_list', array(0)); |
| 343 | 5303 | acydburn | |
| 344 | 5303 | acydburn | if (sizeof($extension_id_list)) |
| 345 | 5303 | acydburn | {
|
| 346 | 8147 | acydburn | $sql = 'SELECT extension |
| 347 | 5303 | acydburn | FROM ' . EXTENSIONS_TABLE . ' |
| 348 | 6271 | acydburn | WHERE ' . $db->sql_in_set('extension_id', $extension_id_list); |
| 349 | 5303 | acydburn | $result = $db->sql_query($sql); |
| 350 | 8350 | acydburn | |
| 351 | 5303 | acydburn | $extension_list = ''; |
| 352 | 5303 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 353 | 5303 | acydburn | {
|
| 354 | 5303 | acydburn | $extension_list .= ($extension_list == '') ? $row['extension'] : ', ' . $row['extension']; |
| 355 | 5303 | acydburn | } |
| 356 | 5303 | acydburn | $db->sql_freeresult($result); |
| 357 | 5303 | acydburn | |
| 358 | 8147 | acydburn | $sql = 'DELETE |
| 359 | 5303 | acydburn | FROM ' . EXTENSIONS_TABLE . ' |
| 360 | 6271 | acydburn | WHERE ' . $db->sql_in_set('extension_id', $extension_id_list); |
| 361 | 5303 | acydburn | $db->sql_query($sql); |
| 362 | 5303 | acydburn | |
| 363 | 5303 | acydburn | add_log('admin', 'LOG_ATTACH_EXT_DEL', $extension_list); |
| 364 | 5303 | acydburn | } |
| 365 | 5303 | acydburn | } |
| 366 | 6073 | acydburn | |
| 367 | 5622 | acydburn | // Add Extension?
|
| 368 | 5303 | acydburn | $add_extension = strtolower(request_var('add_extension', '')); |
| 369 | 5303 | acydburn | $add_extension_group = request_var('add_group_select', 0); |
| 370 | 5303 | acydburn | $add = (isset($_POST['add_extension_check'])) ? true : false; |
| 371 | 5303 | acydburn | |
| 372 | 6816 | acydburn | if ($add_extension && $add) |
| 373 | 5303 | acydburn | {
|
| 374 | 5303 | acydburn | if (!sizeof($error)) |
| 375 | 5303 | acydburn | {
|
| 376 | 5303 | acydburn | $sql = 'SELECT extension_id |
| 377 | 5303 | acydburn | FROM ' . EXTENSIONS_TABLE . " |
| 378 | 5303 | acydburn | WHERE extension = '" . $db->sql_escape($add_extension) . "'"; |
| 379 | 5303 | acydburn | $result = $db->sql_query($sql); |
| 380 | 8350 | acydburn | |
| 381 | 5303 | acydburn | if ($row = $db->sql_fetchrow($result)) |
| 382 | 5303 | acydburn | {
|
| 383 | 5303 | acydburn | $error[] = sprintf($user->lang['EXTENSION_EXIST'], $add_extension); |
| 384 | 5303 | acydburn | } |
| 385 | 5303 | acydburn | $db->sql_freeresult($result); |
| 386 | 5303 | acydburn | |
| 387 | 5303 | acydburn | if (!sizeof($error)) |
| 388 | 5303 | acydburn | {
|
| 389 | 5303 | acydburn | $sql_ary = array( |
| 390 | 5303 | acydburn | 'group_id' => $add_extension_group, |
| 391 | 5303 | acydburn | 'extension' => $add_extension |
| 392 | 5303 | acydburn | ); |
| 393 | 6816 | acydburn | |
| 394 | 5303 | acydburn | $db->sql_query('INSERT INTO ' . EXTENSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); |
| 395 | 5303 | acydburn | add_log('admin', 'LOG_ATTACH_EXT_ADD', $add_extension); |
| 396 | 5303 | acydburn | } |
| 397 | 5303 | acydburn | } |
| 398 | 5303 | acydburn | } |
| 399 | 5303 | acydburn | |
| 400 | 5303 | acydburn | if (!sizeof($error)) |
| 401 | 5303 | acydburn | {
|
| 402 | 5303 | acydburn | $notify[] = $user->lang['EXTENSIONS_UPDATED']; |
| 403 | 5303 | acydburn | } |
| 404 | 6816 | acydburn | |
| 405 | 5303 | acydburn | $cache->destroy('_extensions'); |
| 406 | 5303 | acydburn | } |
| 407 | 5303 | acydburn | |
| 408 | 5303 | acydburn | $template->assign_vars(array( |
| 409 | 5303 | acydburn | 'S_EXTENSIONS' => true, |
| 410 | 5303 | acydburn | 'ADD_EXTENSION' => (isset($add_extension)) ? $add_extension : '', |
| 411 | 5303 | acydburn | 'GROUP_SELECT_OPTIONS' => (isset($_POST['add_extension_check'])) ? $this->group_select('add_group_select', $add_extension_group, 'extension_group') : $this->group_select('add_group_select', false, 'extension_group')) |
| 412 | 5303 | acydburn | ); |
| 413 | 5303 | acydburn | |
| 414 | 8147 | acydburn | $sql = 'SELECT * |
| 415 | 8147 | acydburn | FROM ' . EXTENSIONS_TABLE . ' |
| 416 | 5303 | acydburn | ORDER BY group_id, extension';
|
| 417 | 5303 | acydburn | $result = $db->sql_query($sql); |
| 418 | 5303 | acydburn | |
| 419 | 5303 | acydburn | if ($row = $db->sql_fetchrow($result)) |
| 420 | 5303 | acydburn | {
|
| 421 | 5303 | acydburn | $old_group_id = $row['group_id']; |
| 422 | 5303 | acydburn | do
|
| 423 | 5303 | acydburn | {
|
| 424 | 5303 | acydburn | $s_spacer = false; |
| 425 | 5303 | acydburn | |
| 426 | 5303 | acydburn | $current_group_id = $row['group_id']; |
| 427 | 5303 | acydburn | if ($old_group_id != $current_group_id) |
| 428 | 5303 | acydburn | {
|
| 429 | 5303 | acydburn | $s_spacer = true; |
| 430 | 5303 | acydburn | $old_group_id = $current_group_id; |
| 431 | 5303 | acydburn | } |
| 432 | 5303 | acydburn | |
| 433 | 5303 | acydburn | $template->assign_block_vars('extensions', array( |
| 434 | 5303 | acydburn | 'S_SPACER' => $s_spacer, |
| 435 | 5303 | acydburn | 'EXTENSION_ID' => $row['extension_id'], |
| 436 | 5303 | acydburn | 'EXTENSION' => $row['extension'], |
| 437 | 5303 | acydburn | 'GROUP_OPTIONS' => $this->group_select('group_select[]', $row['group_id'])) |
| 438 | 5303 | acydburn | ); |
| 439 | 5303 | acydburn | } |
| 440 | 5303 | acydburn | while ($row = $db->sql_fetchrow($result)); |
| 441 | 5303 | acydburn | } |
| 442 | 5303 | acydburn | $db->sql_freeresult($result); |
| 443 | 5303 | acydburn | |
| 444 | 5303 | acydburn | break;
|
| 445 | 5303 | acydburn | |
| 446 | 5303 | acydburn | case 'ext_groups': |
| 447 | 5303 | acydburn | |
| 448 | 5303 | acydburn | $template->assign_var('S_EXTENSION_GROUPS', true); |
| 449 | 5303 | acydburn | |
| 450 | 5303 | acydburn | if ($submit) |
| 451 | 5303 | acydburn | {
|
| 452 | 5303 | acydburn | $action = request_var('action', ''); |
| 453 | 5303 | acydburn | $group_id = request_var('g', 0); |
| 454 | 6073 | acydburn | |
| 455 | 5303 | acydburn | if ($action != 'add' && $action != 'edit') |
| 456 | 5303 | acydburn | {
|
| 457 | 6428 | acydburn | trigger_error('NO_MODE', E_USER_ERROR); |
| 458 | 5303 | acydburn | } |
| 459 | 5303 | acydburn | |
| 460 | 5303 | acydburn | if (!$group_id && $action == 'edit') |
| 461 | 5303 | acydburn | {
|
| 462 | 6428 | acydburn | trigger_error($user->lang['NO_EXT_GROUP_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING); |
| 463 | 5303 | acydburn | } |
| 464 | 5303 | acydburn | |
| 465 | 5303 | acydburn | if ($group_id) |
| 466 | 5303 | acydburn | {
|
| 467 | 6831 | acydburn | $sql = 'SELECT * |
| 468 | 6831 | acydburn | FROM ' . EXTENSION_GROUPS_TABLE . " |
| 469 | 5303 | acydburn | WHERE group_id = $group_id"; |
| 470 | 5303 | acydburn | $result = $db->sql_query($sql); |
| 471 | 5303 | acydburn | $ext_row = $db->sql_fetchrow($result); |
| 472 | 5303 | acydburn | $db->sql_freeresult($result); |
| 473 | 6831 | acydburn | |
| 474 | 6831 | acydburn | if (!$ext_row) |
| 475 | 6831 | acydburn | {
|
| 476 | 6831 | acydburn | trigger_error($user->lang['NO_EXT_GROUP_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING); |
| 477 | 6831 | acydburn | } |
| 478 | 5303 | acydburn | } |
| 479 | 5303 | acydburn | else
|
| 480 | 5303 | acydburn | {
|
| 481 | 5303 | acydburn | $ext_row = array(); |
| 482 | 5303 | acydburn | } |
| 483 | 5303 | acydburn | |
| 484 | 7920 | acydburn | $group_name = utf8_normalize_nfc(request_var('group_name', '', true)); |
| 485 | 5303 | acydburn | $new_group_name = ($action == 'add') ? $group_name : (($ext_row['group_name'] != $group_name) ? $group_name : ''); |
| 486 | 5303 | acydburn | |
| 487 | 5303 | acydburn | if (!$group_name) |
| 488 | 5303 | acydburn | {
|
| 489 | 5303 | acydburn | $error[] = $user->lang['NO_EXT_GROUP_NAME']; |
| 490 | 5303 | acydburn | } |
| 491 | 5303 | acydburn | |
| 492 | 5303 | acydburn | // Check New Group Name
|
| 493 | 5303 | acydburn | if ($new_group_name) |
| 494 | 5303 | acydburn | {
|
| 495 | 8147 | acydburn | $sql = 'SELECT group_id |
| 496 | 5303 | acydburn | FROM ' . EXTENSION_GROUPS_TABLE . " |
| 497 | 6452 | acydburn | WHERE LOWER(group_name) = '" . $db->sql_escape(utf8_strtolower($new_group_name)) . "'"; |
| 498 | 10613 | git-gate | if ($group_id) |
| 499 | 10613 | git-gate | {
|
| 500 | 10613 | git-gate | $sql .= ' AND group_id <> ' . $group_id; |
| 501 | 10613 | git-gate | } |
| 502 | 5303 | acydburn | $result = $db->sql_query($sql); |
| 503 | 6073 | acydburn | |
| 504 | 5303 | acydburn | if ($db->sql_fetchrow($result)) |
| 505 | 5303 | acydburn | {
|
| 506 | 5303 | acydburn | $error[] = sprintf($user->lang['EXTENSION_GROUP_EXIST'], $new_group_name); |
| 507 | 5303 | acydburn | } |
| 508 | 5303 | acydburn | $db->sql_freeresult($result); |
| 509 | 5303 | acydburn | } |
| 510 | 5303 | acydburn | |
| 511 | 5303 | acydburn | if (!sizeof($error)) |
| 512 | 5303 | acydburn | {
|
| 513 | 5303 | acydburn | // Ok, build the update/insert array
|
| 514 | 5303 | acydburn | $upload_icon = request_var('upload_icon', 'no_image'); |
| 515 | 5303 | acydburn | $size_select = request_var('size_select', 'b'); |
| 516 | 5303 | acydburn | $forum_select = request_var('forum_select', false); |
| 517 | 6816 | acydburn | $allowed_forums = request_var('allowed_forums', array(0)); |
| 518 | 6816 | acydburn | $allow_in_pm = (isset($_POST['allow_in_pm'])) ? true : false; |
| 519 | 5303 | acydburn | $max_filesize = request_var('max_filesize', 0); |
| 520 | 8529 | acydburn | $max_filesize = ($size_select == 'kb') ? round($max_filesize * 1024) : (($size_select == 'mb') ? round($max_filesize * 1048576) : $max_filesize); |
| 521 | 6816 | acydburn | $allow_group = (isset($_POST['allow_group'])) ? true : false; |
| 522 | 5303 | acydburn | |
| 523 | 5303 | acydburn | if ($max_filesize == $config['max_filesize']) |
| 524 | 5303 | acydburn | {
|
| 525 | 5303 | acydburn | $max_filesize = 0; |
| 526 | 6073 | acydburn | } |
| 527 | 5303 | acydburn | |
| 528 | 5303 | acydburn | if (!sizeof($allowed_forums)) |
| 529 | 5303 | acydburn | {
|
| 530 | 5303 | acydburn | $forum_select = false; |
| 531 | 5303 | acydburn | } |
| 532 | 5303 | acydburn | |
| 533 | 5303 | acydburn | $group_ary = array( |
| 534 | 5303 | acydburn | 'group_name' => $group_name, |
| 535 | 5303 | acydburn | 'cat_id' => request_var('special_category', ATTACHMENT_CATEGORY_NONE), |
| 536 | 6816 | acydburn | 'allow_group' => ($allow_group) ? 1 : 0, |
| 537 | 5303 | acydburn | 'upload_icon' => ($upload_icon == 'no_image') ? '' : $upload_icon, |
| 538 | 5303 | acydburn | 'max_filesize' => $max_filesize, |
| 539 | 5303 | acydburn | 'allowed_forums'=> ($forum_select) ? serialize($allowed_forums) : '', |
| 540 | 6816 | acydburn | 'allow_in_pm' => ($allow_in_pm) ? 1 : 0, |
| 541 | 5303 | acydburn | ); |
| 542 | 5303 | acydburn | |
| 543 | 6831 | acydburn | if ($action == 'add') |
| 544 | 6831 | acydburn | {
|
| 545 | 6831 | acydburn | $group_ary['download_mode'] = INLINE_LINK; |
| 546 | 6831 | acydburn | } |
| 547 | 6831 | acydburn | |
| 548 | 5303 | acydburn | $sql = ($action == 'add') ? 'INSERT INTO ' . EXTENSION_GROUPS_TABLE . ' ' : 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' SET '; |
| 549 | 5303 | acydburn | $sql .= $db->sql_build_array((($action == 'add') ? 'INSERT' : 'UPDATE'), $group_ary); |
| 550 | 5303 | acydburn | $sql .= ($action == 'edit') ? " WHERE group_id = $group_id" : ''; |
| 551 | 5303 | acydburn | |
| 552 | 5303 | acydburn | $db->sql_query($sql); |
| 553 | 6073 | acydburn | |
| 554 | 5303 | acydburn | if ($action == 'add') |
| 555 | 5303 | acydburn | {
|
| 556 | 5303 | acydburn | $group_id = $db->sql_nextid(); |
| 557 | 5303 | acydburn | } |
| 558 | 5303 | acydburn | |
| 559 | 10613 | git-gate | $group_name = (isset($user->lang['EXT_GROUP_' . $group_name])) ? $user->lang['EXT_GROUP_' . $group_name] : $group_name; |
| 560 | 5303 | acydburn | add_log('admin', 'LOG_ATTACH_EXTGROUP_' . strtoupper($action), $group_name); |
| 561 | 5303 | acydburn | } |
| 562 | 5303 | acydburn | |
| 563 | 6816 | acydburn | $extension_list = request_var('extensions', array(0)); |
| 564 | 5303 | acydburn | |
| 565 | 5303 | acydburn | if ($action == 'edit' && sizeof($extension_list)) |
| 566 | 5303 | acydburn | {
|
| 567 | 5303 | acydburn | $sql = 'UPDATE ' . EXTENSIONS_TABLE . " |
| 568 | 5303 | acydburn | SET group_id = 0 |
| 569 | 5303 | acydburn | WHERE group_id = $group_id"; |
| 570 | 5303 | acydburn | $db->sql_query($sql); |
| 571 | 5303 | acydburn | } |
| 572 | 5303 | acydburn | |
| 573 | 5303 | acydburn | if (sizeof($extension_list)) |
| 574 | 5303 | acydburn | {
|
| 575 | 8147 | acydburn | $sql = 'UPDATE ' . EXTENSIONS_TABLE . " |
| 576 | 5303 | acydburn | SET group_id = $group_id |
| 577 | 6271 | acydburn | WHERE " . $db->sql_in_set('extension_id', $extension_list); |
| 578 | 5303 | acydburn | $db->sql_query($sql); |
| 579 | 5303 | acydburn | } |
| 580 | 5303 | acydburn | |
| 581 | 6831 | acydburn | $cache->destroy('_extensions'); |
| 582 | 5303 | acydburn | |
| 583 | 5303 | acydburn | if (!sizeof($error)) |
| 584 | 5303 | acydburn | {
|
| 585 | 5303 | acydburn | $notify[] = $user->lang['SUCCESS_EXTENSION_GROUP_' . strtoupper($action)]; |
| 586 | 5303 | acydburn | } |
| 587 | 5303 | acydburn | } |
| 588 | 6816 | acydburn | |
| 589 | 5303 | acydburn | $cat_lang = array( |
| 590 | 6511 | acydburn | ATTACHMENT_CATEGORY_NONE => $user->lang['NO_FILE_CAT'], |
| 591 | 6511 | acydburn | ATTACHMENT_CATEGORY_IMAGE => $user->lang['CAT_IMAGES'], |
| 592 | 6511 | acydburn | ATTACHMENT_CATEGORY_WM => $user->lang['CAT_WM_FILES'], |
| 593 | 6511 | acydburn | ATTACHMENT_CATEGORY_RM => $user->lang['CAT_RM_FILES'], |
| 594 | 6511 | acydburn | ATTACHMENT_CATEGORY_FLASH => $user->lang['CAT_FLASH_FILES'], |
| 595 | 6511 | acydburn | ATTACHMENT_CATEGORY_QUICKTIME => $user->lang['CAT_QUICKTIME_FILES'], |
| 596 | 5303 | acydburn | ); |
| 597 | 5303 | acydburn | |
| 598 | 5303 | acydburn | $group_id = request_var('g', 0); |
| 599 | 5303 | acydburn | $action = (isset($_POST['add'])) ? 'add' : $action; |
| 600 | 5303 | acydburn | |
| 601 | 5303 | acydburn | switch ($action) |
| 602 | 5303 | acydburn | {
|
| 603 | 5303 | acydburn | case 'delete': |
| 604 | 5303 | acydburn | |
| 605 | 5303 | acydburn | if (confirm_box(true)) |
| 606 | 5303 | acydburn | {
|
| 607 | 8147 | acydburn | $sql = 'SELECT group_name |
| 608 | 5303 | acydburn | FROM ' . EXTENSION_GROUPS_TABLE . " |
| 609 | 5303 | acydburn | WHERE group_id = $group_id"; |
| 610 | 5303 | acydburn | $result = $db->sql_query($sql); |
| 611 | 5699 | acydburn | $group_name = (string) $db->sql_fetchfield('group_name'); |
| 612 | 5303 | acydburn | $db->sql_freeresult($result); |
| 613 | 5303 | acydburn | |
| 614 | 8147 | acydburn | $sql = 'DELETE |
| 615 | 8147 | acydburn | FROM ' . EXTENSION_GROUPS_TABLE . " |
| 616 | 5303 | acydburn | WHERE group_id = $group_id"; |
| 617 | 5303 | acydburn | $db->sql_query($sql); |
| 618 | 5303 | acydburn | |
| 619 | 5303 | acydburn | // Set corresponding Extensions to a pending Group
|
| 620 | 5303 | acydburn | $sql = 'UPDATE ' . EXTENSIONS_TABLE . " |
| 621 | 5303 | acydburn | SET group_id = 0 |
| 622 | 5303 | acydburn | WHERE group_id = $group_id"; |
| 623 | 5303 | acydburn | $db->sql_query($sql); |
| 624 | 8350 | acydburn | |
| 625 | 5303 | acydburn | add_log('admin', 'LOG_ATTACH_EXTGROUP_DEL', $group_name); |
| 626 | 5303 | acydburn | |
| 627 | 6831 | acydburn | $cache->destroy('_extensions'); |
| 628 | 5303 | acydburn | |
| 629 | 5558 | acydburn | trigger_error($user->lang['EXTENSION_GROUP_DELETED'] . adm_back_link($this->u_action)); |
| 630 | 5303 | acydburn | } |
| 631 | 5303 | acydburn | else
|
| 632 | 5303 | acydburn | {
|
| 633 | 5303 | acydburn | confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( |
| 634 | 5303 | acydburn | 'i' => $id, |
| 635 | 5303 | acydburn | 'mode' => $mode, |
| 636 | 5303 | acydburn | 'group_id' => $group_id, |
| 637 | 5303 | acydburn | 'action' => 'delete', |
| 638 | 5303 | acydburn | ))); |
| 639 | 5303 | acydburn | } |
| 640 | 5303 | acydburn | |
| 641 | 5303 | acydburn | break;
|
| 642 | 5303 | acydburn | |
| 643 | 5303 | acydburn | case 'edit': |
| 644 | 6816 | acydburn | |
| 645 | 5303 | acydburn | if (!$group_id) |
| 646 | 5303 | acydburn | {
|
| 647 | 6428 | acydburn | trigger_error($user->lang['NO_EXT_GROUP_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING); |
| 648 | 5303 | acydburn | } |
| 649 | 5303 | acydburn | |
| 650 | 6073 | acydburn | $sql = 'SELECT * |
| 651 | 6073 | acydburn | FROM ' . EXTENSION_GROUPS_TABLE . " |
| 652 | 5303 | acydburn | WHERE group_id = $group_id"; |
| 653 | 5303 | acydburn | $result = $db->sql_query($sql); |
| 654 | 5303 | acydburn | $ext_group_row = $db->sql_fetchrow($result); |
| 655 | 5303 | acydburn | $db->sql_freeresult($result); |
| 656 | 5303 | acydburn | |
| 657 | 5303 | acydburn | $forum_ids = (!$ext_group_row['allowed_forums']) ? array() : unserialize(trim($ext_group_row['allowed_forums'])); |
| 658 | 5303 | acydburn | |
| 659 | 6073 | acydburn | // no break;
|
| 660 | 6073 | acydburn | |
| 661 | 5303 | acydburn | case 'add': |
| 662 | 6816 | acydburn | |
| 663 | 5303 | acydburn | if ($action == 'add') |
| 664 | 5303 | acydburn | {
|
| 665 | 5303 | acydburn | $ext_group_row = array( |
| 666 | 7920 | acydburn | 'group_name' => utf8_normalize_nfc(request_var('group_name', '', true)), |
| 667 | 5303 | acydburn | 'cat_id' => 0, |
| 668 | 5303 | acydburn | 'allow_group' => 1, |
| 669 | 5303 | acydburn | 'allow_in_pm' => 1, |
| 670 | 5303 | acydburn | 'upload_icon' => '', |
| 671 | 5303 | acydburn | 'max_filesize' => 0, |
| 672 | 5303 | acydburn | ); |
| 673 | 6816 | acydburn | |
| 674 | 5303 | acydburn | $forum_ids = array(); |
| 675 | 5303 | acydburn | } |
| 676 | 5303 | acydburn | |
| 677 | 5303 | acydburn | $extensions = array(); |
| 678 | 5303 | acydburn | |
| 679 | 6073 | acydburn | $sql = 'SELECT * |
| 680 | 6073 | acydburn | FROM ' . EXTENSIONS_TABLE . " |
| 681 | 6073 | acydburn | WHERE group_id = $group_id |
| 682 | 6073 | acydburn | OR group_id = 0 |
| 683 | 5303 | acydburn | ORDER BY extension";
|
| 684 | 5303 | acydburn | $result = $db->sql_query($sql); |
| 685 | 5303 | acydburn | $extensions = $db->sql_fetchrowset($result); |
| 686 | 5303 | acydburn | $db->sql_freeresult($result); |
| 687 | 5303 | acydburn | |
| 688 | 5303 | acydburn | if ($ext_group_row['max_filesize'] == 0) |
| 689 | 5303 | acydburn | {
|
| 690 | 5303 | acydburn | $ext_group_row['max_filesize'] = (int) $config['max_filesize']; |
| 691 | 5303 | acydburn | } |
| 692 | 5303 | acydburn | |
| 693 | 9748 | bantu | $max_filesize = get_formatted_filesize($ext_group_row['max_filesize'], false, array('mb', 'kb', 'b')); |
| 694 | 9748 | bantu | $size_format = $max_filesize['si_identifier']; |
| 695 | 9748 | bantu | $ext_group_row['max_filesize'] = $max_filesize['value']; |
| 696 | 5303 | acydburn | |
| 697 | 5303 | acydburn | $img_path = $config['upload_icons_path']; |
| 698 | 5303 | acydburn | |
| 699 | 6165 | acydburn | $filename_list = ''; |
| 700 | 6165 | acydburn | $no_image_select = false; |
| 701 | 6165 | acydburn | |
| 702 | 5303 | acydburn | $imglist = filelist($phpbb_root_path . $img_path); |
| 703 | 5303 | acydburn | |
| 704 | 9565 | bantu | if (!empty($imglist[''])) |
| 705 | 5303 | acydburn | {
|
| 706 | 6165 | acydburn | $imglist = array_values($imglist); |
| 707 | 6165 | acydburn | $imglist = $imglist[0]; |
| 708 | 6165 | acydburn | |
| 709 | 6165 | acydburn | foreach ($imglist as $key => $img) |
| 710 | 5303 | acydburn | {
|
| 711 | 6165 | acydburn | if (!$ext_group_row['upload_icon']) |
| 712 | 6165 | acydburn | {
|
| 713 | 6165 | acydburn | $no_image_select = true; |
| 714 | 6165 | acydburn | $selected = ''; |
| 715 | 6165 | acydburn | } |
| 716 | 6165 | acydburn | else
|
| 717 | 6165 | acydburn | {
|
| 718 | 6165 | acydburn | $selected = ($ext_group_row['upload_icon'] == $img) ? ' selected="selected"' : ''; |
| 719 | 6165 | acydburn | } |
| 720 | 6165 | acydburn | |
| 721 | 6880 | davidmj | if (strlen($img) > 255) |
| 722 | 6880 | davidmj | {
|
| 723 | 6880 | davidmj | continue;
|
| 724 | 6880 | davidmj | } |
| 725 | 6880 | davidmj | |
| 726 | 6165 | acydburn | $filename_list .= '<option value="' . htmlspecialchars($img) . '"' . $selected . '>' . htmlspecialchars($img) . '</option>'; |
| 727 | 5303 | acydburn | } |
| 728 | 5303 | acydburn | } |
| 729 | 5303 | acydburn | |
| 730 | 5303 | acydburn | $i = 0; |
| 731 | 5303 | acydburn | $assigned_extensions = ''; |
| 732 | 5303 | acydburn | foreach ($extensions as $num => $row) |
| 733 | 5303 | acydburn | {
|
| 734 | 5303 | acydburn | if ($row['group_id'] == $group_id && $group_id) |
| 735 | 5303 | acydburn | {
|
| 736 | 5303 | acydburn | $assigned_extensions .= ($i) ? ', ' . $row['extension'] : $row['extension']; |
| 737 | 5303 | acydburn | $i++;
|
| 738 | 5303 | acydburn | } |
| 739 | 5303 | acydburn | } |
| 740 | 5303 | acydburn | |
| 741 | 5303 | acydburn | $s_extension_options = ''; |
| 742 | 5303 | acydburn | foreach ($extensions as $row) |
| 743 | 5303 | acydburn | {
|
| 744 | 5303 | acydburn | $s_extension_options .= '<option' . ((!$row['group_id']) ? ' class="disabled"' : '') . ' value="' . $row['extension_id'] . '"' . (($row['group_id'] == $group_id && $group_id) ? ' selected="selected"' : '') . '>' . $row['extension'] . '</option>'; |
| 745 | 5303 | acydburn | } |
| 746 | 5303 | acydburn | |
| 747 | 5303 | acydburn | $template->assign_vars(array( |
| 748 | 6816 | acydburn | 'PHPBB_ROOT_PATH' => $phpbb_root_path, |
| 749 | 6816 | acydburn | 'IMG_PATH' => $img_path, |
| 750 | 6816 | acydburn | 'ACTION' => $action, |
| 751 | 6816 | acydburn | 'GROUP_ID' => $group_id, |
| 752 | 6816 | acydburn | 'GROUP_NAME' => $ext_group_row['group_name'], |
| 753 | 6816 | acydburn | 'ALLOW_GROUP' => $ext_group_row['allow_group'], |
| 754 | 6816 | acydburn | 'ALLOW_IN_PM' => $ext_group_row['allow_in_pm'], |
| 755 | 6816 | acydburn | 'UPLOAD_ICON_SRC' => $phpbb_root_path . $img_path . '/' . $ext_group_row['upload_icon'], |
| 756 | 6816 | acydburn | 'EXTGROUP_FILESIZE' => $ext_group_row['max_filesize'], |
| 757 | 5303 | acydburn | 'ASSIGNED_EXTENSIONS' => $assigned_extensions, |
| 758 | 6073 | acydburn | |
| 759 | 5486 | acydburn | 'S_CATEGORY_SELECT' => $this->category_select('special_category', $group_id, 'category'), |
| 760 | 5486 | acydburn | 'S_EXT_GROUP_SIZE_OPTIONS' => size_select_options($size_format), |
| 761 | 5486 | acydburn | 'S_EXTENSION_OPTIONS' => $s_extension_options, |
| 762 | 5486 | acydburn | 'S_FILENAME_LIST' => $filename_list, |
| 763 | 5486 | acydburn | 'S_EDIT_GROUP' => true, |
| 764 | 5486 | acydburn | 'S_NO_IMAGE' => $no_image_select, |
| 765 | 5486 | acydburn | 'S_FORUM_IDS' => (sizeof($forum_ids)) ? true : false, |
| 766 | 5303 | acydburn | |
| 767 | 6015 | acydburn | 'U_EXTENSIONS' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&mode=extensions"), |
| 768 | 6816 | acydburn | 'U_BACK' => $this->u_action, |
| 769 | 5303 | acydburn | |
| 770 | 6816 | acydburn | 'L_LEGEND' => $user->lang[strtoupper($action) . '_EXTENSION_GROUP']) |
| 771 | 5303 | acydburn | ); |
| 772 | 5303 | acydburn | |
| 773 | 5303 | acydburn | $s_forum_id_options = ''; |
| 774 | 5303 | acydburn | |
| 775 | 9041 | acydburn | /** @todo use in-built function **/
|
| 776 | 9041 | acydburn | |
| 777 | 5303 | acydburn | $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id |
| 778 | 5303 | acydburn | FROM ' . FORUMS_TABLE . ' |
| 779 | 5303 | acydburn | ORDER BY left_id ASC';
|
| 780 | 7327 | davidmj | $result = $db->sql_query($sql, 600); |
| 781 | 5303 | acydburn | |
| 782 | 5303 | acydburn | $right = $cat_right = $padding_inc = 0; |
| 783 | 5303 | acydburn | $padding = $forum_list = $holding = ''; |
| 784 | 5303 | acydburn | $padding_store = array('0' => ''); |
| 785 | 6816 | acydburn | |
| 786 | 5303 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 787 | 5303 | acydburn | {
|
| 788 | 5303 | acydburn | if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id'])) |
| 789 | 5303 | acydburn | {
|
| 790 | 5303 | acydburn | // Non-postable forum with no subforums, don't display
|
| 791 | 5303 | acydburn | continue;
|
| 792 | 5303 | acydburn | } |
| 793 | 5303 | acydburn | |
| 794 | 5303 | acydburn | if (!$auth->acl_get('f_list', $row['forum_id'])) |
| 795 | 5303 | acydburn | {
|
| 796 | 5303 | acydburn | // if the user does not have permissions to list this forum skip
|
| 797 | 5303 | acydburn | continue;
|
| 798 | 5303 | acydburn | } |
| 799 | 5303 | acydburn | |
| 800 | 5303 | acydburn | if ($row['left_id'] < $right) |
| 801 | 5303 | acydburn | {
|
| 802 | 5303 | acydburn | $padding .= ' '; |
| 803 | 5303 | acydburn | $padding_store[$row['parent_id']] = $padding; |
| 804 | 5303 | acydburn | } |
| 805 | 5303 | acydburn | else if ($row['left_id'] > $right + 1) |
| 806 | 5303 | acydburn | {
|
| 807 | 9041 | acydburn | $padding = empty($padding_store[$row['parent_id']]) ? '' : $padding_store[$row['parent_id']]; |
| 808 | 5303 | acydburn | } |
| 809 | 5303 | acydburn | |
| 810 | 5303 | acydburn | $right = $row['right_id']; |
| 811 | 5303 | acydburn | |
| 812 | 5303 | acydburn | $selected = (in_array($row['forum_id'], $forum_ids)) ? ' selected="selected"' : ''; |
| 813 | 5303 | acydburn | |
| 814 | 5303 | acydburn | if ($row['left_id'] > $cat_right) |
| 815 | 5303 | acydburn | {
|
| 816 | 7076 | naderman | // make sure we don't forget anything
|
| 817 | 7076 | naderman | $s_forum_id_options .= $holding; |
| 818 | 5303 | acydburn | $holding = ''; |
| 819 | 5303 | acydburn | } |
| 820 | 5303 | acydburn | |
| 821 | 5303 | acydburn | if ($row['right_id'] - $row['left_id'] > 1) |
| 822 | 5303 | acydburn | {
|
| 823 | 5303 | acydburn | $cat_right = max($cat_right, $row['right_id']); |
| 824 | 5303 | acydburn | |
| 825 | 7329 | vic_delfant | $holding .= '<option value="' . $row['forum_id'] . '"' . (($row['forum_type'] == FORUM_POST) ? ' class="sep"' : '') . $selected . '>' . $padding . $row['forum_name'] . '</option>'; |
| 826 | 5303 | acydburn | } |
| 827 | 5303 | acydburn | else
|
| 828 | 5303 | acydburn | {
|
| 829 | 7329 | vic_delfant | $s_forum_id_options .= $holding . '<option value="' . $row['forum_id'] . '"' . (($row['forum_type'] == FORUM_POST) ? ' class="sep"' : '') . $selected . '>' . $padding . $row['forum_name'] . '</option>'; |
| 830 | 5303 | acydburn | $holding = ''; |
| 831 | 5303 | acydburn | } |
| 832 | 5303 | acydburn | } |
| 833 | 7076 | naderman | |
| 834 | 7076 | naderman | if ($holding) |
| 835 | 7076 | naderman | {
|
| 836 | 7076 | naderman | $s_forum_id_options .= $holding; |
| 837 | 7076 | naderman | } |
| 838 | 7076 | naderman | |
| 839 | 5303 | acydburn | $db->sql_freeresult($result); |
| 840 | 5303 | acydburn | unset($padding_store); |
| 841 | 5303 | acydburn | |
| 842 | 5303 | acydburn | $template->assign_vars(array( |
| 843 | 5303 | acydburn | 'S_FORUM_ID_OPTIONS' => $s_forum_id_options) |
| 844 | 5303 | acydburn | ); |
| 845 | 5303 | acydburn | |
| 846 | 5303 | acydburn | break;
|
| 847 | 5303 | acydburn | } |
| 848 | 5303 | acydburn | |
| 849 | 5303 | acydburn | $sql = 'SELECT * |
| 850 | 5303 | acydburn | FROM ' . EXTENSION_GROUPS_TABLE . ' |
| 851 | 6816 | acydburn | ORDER BY allow_group DESC, allow_in_pm DESC, group_name';
|
| 852 | 5303 | acydburn | $result = $db->sql_query($sql); |
| 853 | 5303 | acydburn | |
| 854 | 6816 | acydburn | $old_allow_group = $old_allow_pm = 1; |
| 855 | 5303 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 856 | 5303 | acydburn | {
|
| 857 | 6816 | acydburn | $s_add_spacer = ($old_allow_group != $row['allow_group'] || $old_allow_pm != $row['allow_in_pm']) ? true : false; |
| 858 | 6073 | acydburn | |
| 859 | 5303 | acydburn | $template->assign_block_vars('groups', array( |
| 860 | 5957 | acydburn | 'S_ADD_SPACER' => $s_add_spacer, |
| 861 | 5957 | acydburn | 'S_ALLOWED_IN_PM' => ($row['allow_in_pm']) ? true : false, |
| 862 | 5957 | acydburn | 'S_GROUP_ALLOWED' => ($row['allow_group']) ? true : false, |
| 863 | 5303 | acydburn | |
| 864 | 5558 | acydburn | 'U_EDIT' => $this->u_action . "&action=edit&g={$row['group_id']}", |
| 865 | 5558 | acydburn | 'U_DELETE' => $this->u_action . "&action=delete&g={$row['group_id']}", |
| 866 | 6073 | acydburn | |
| 867 | 10613 | git-gate | 'GROUP_NAME' => (isset($user->lang['EXT_GROUP_' . $row['group_name']])) ? $user->lang['EXT_GROUP_' . $row['group_name']] : $row['group_name'], |
| 868 | 5303 | acydburn | 'CATEGORY' => $cat_lang[$row['cat_id']], |
| 869 | 5303 | acydburn | ) |
| 870 | 5303 | acydburn | ); |
| 871 | 5303 | acydburn | |
| 872 | 6816 | acydburn | $old_allow_group = $row['allow_group']; |
| 873 | 6816 | acydburn | $old_allow_pm = $row['allow_in_pm']; |
| 874 | 5303 | acydburn | } |
| 875 | 5303 | acydburn | $db->sql_freeresult($result); |
| 876 | 5303 | acydburn | |
| 877 | 5303 | acydburn | break;
|
| 878 | 5303 | acydburn | |
| 879 | 5303 | acydburn | case 'orphan': |
| 880 | 5303 | acydburn | |
| 881 | 5303 | acydburn | if ($submit) |
| 882 | 5303 | acydburn | {
|
| 883 | 5303 | acydburn | $delete_files = (isset($_POST['delete'])) ? array_keys(request_var('delete', array('' => 0))) : array(); |
| 884 | 5303 | acydburn | $add_files = (isset($_POST['add'])) ? array_keys(request_var('add', array('' => 0))) : array(); |
| 885 | 5303 | acydburn | $post_ids = request_var('post_id', array('' => 0)); |
| 886 | 5303 | acydburn | |
| 887 | 6364 | acydburn | if (sizeof($delete_files)) |
| 888 | 5303 | acydburn | {
|
| 889 | 6364 | acydburn | $sql = 'SELECT * |
| 890 | 6364 | acydburn | FROM ' . ATTACHMENTS_TABLE . ' |
| 891 | 6364 | acydburn | WHERE ' . $db->sql_in_set('attach_id', $delete_files) . ' |
| 892 | 6364 | acydburn | AND is_orphan = 1';
|
| 893 | 6364 | acydburn | $result = $db->sql_query($sql); |
| 894 | 6364 | acydburn | |
| 895 | 6364 | acydburn | $delete_files = array(); |
| 896 | 6364 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 897 | 6364 | acydburn | {
|
| 898 | 6831 | acydburn | phpbb_unlink($row['physical_filename'], 'file'); |
| 899 | 6364 | acydburn | |
| 900 | 6364 | acydburn | if ($row['thumbnail']) |
| 901 | 6364 | acydburn | {
|
| 902 | 6364 | acydburn | phpbb_unlink($row['physical_filename'], 'thumbnail'); |
| 903 | 6364 | acydburn | } |
| 904 | 6364 | acydburn | |
| 905 | 6364 | acydburn | $delete_files[$row['attach_id']] = $row['real_filename']; |
| 906 | 6364 | acydburn | } |
| 907 | 6364 | acydburn | $db->sql_freeresult($result); |
| 908 | 5303 | acydburn | } |
| 909 | 5303 | acydburn | |
| 910 | 5303 | acydburn | if (sizeof($delete_files)) |
| 911 | 5303 | acydburn | {
|
| 912 | 6364 | acydburn | $sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . ' |
| 913 | 6364 | acydburn | WHERE ' . $db->sql_in_set('attach_id', array_keys($delete_files)); |
| 914 | 6364 | acydburn | $db->sql_query($sql); |
| 915 | 6364 | acydburn | |
| 916 | 5738 | acydburn | add_log('admin', 'LOG_ATTACH_ORPHAN_DEL', implode(', ', $delete_files)); |
| 917 | 5303 | acydburn | $notify[] = sprintf($user->lang['LOG_ATTACH_ORPHAN_DEL'], implode(', ', $delete_files)); |
| 918 | 5303 | acydburn | } |
| 919 | 5303 | acydburn | |
| 920 | 5303 | acydburn | $upload_list = array(); |
| 921 | 6364 | acydburn | foreach ($add_files as $attach_id) |
| 922 | 5303 | acydburn | {
|
| 923 | 8350 | acydburn | if (!isset($delete_files[$attach_id]) && !empty($post_ids[$attach_id])) |
| 924 | 5303 | acydburn | {
|
| 925 | 6364 | acydburn | $upload_list[$attach_id] = $post_ids[$attach_id]; |
| 926 | 5303 | acydburn | } |
| 927 | 5303 | acydburn | } |
| 928 | 5303 | acydburn | unset($add_files); |
| 929 | 5303 | acydburn | |
| 930 | 5303 | acydburn | if (sizeof($upload_list)) |
| 931 | 5303 | acydburn | {
|
| 932 | 5303 | acydburn | $template->assign_var('S_UPLOADING_FILES', true); |
| 933 | 5303 | acydburn | |
| 934 | 5303 | acydburn | $sql = 'SELECT forum_id, forum_name |
| 935 | 5303 | acydburn | FROM ' . FORUMS_TABLE; |
| 936 | 5303 | acydburn | $result = $db->sql_query($sql); |
| 937 | 6364 | acydburn | |
| 938 | 5303 | acydburn | $forum_names = array(); |
| 939 | 5303 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 940 | 5303 | acydburn | {
|
| 941 | 5303 | acydburn | $forum_names[$row['forum_id']] = $row['forum_name']; |
| 942 | 5303 | acydburn | } |
| 943 | 5303 | acydburn | $db->sql_freeresult($result); |
| 944 | 5303 | acydburn | |
| 945 | 6364 | acydburn | $sql = 'SELECT forum_id, topic_id, post_id, poster_id |
| 946 | 5303 | acydburn | FROM ' . POSTS_TABLE . ' |
| 947 | 6364 | acydburn | WHERE ' . $db->sql_in_set('post_id', $upload_list); |
| 948 | 5303 | acydburn | $result = $db->sql_query($sql); |
| 949 | 5303 | acydburn | |
| 950 | 6364 | acydburn | $post_info = array(); |
| 951 | 5303 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 952 | 5303 | acydburn | {
|
| 953 | 6364 | acydburn | $post_info[$row['post_id']] = $row; |
| 954 | 6364 | acydburn | } |
| 955 | 6364 | acydburn | $db->sql_freeresult($result); |
| 956 | 5303 | acydburn | |
| 957 | 6364 | acydburn | // Select those attachments we want to change...
|
| 958 | 6364 | acydburn | $sql = 'SELECT * |
| 959 | 6364 | acydburn | FROM ' . ATTACHMENTS_TABLE . ' |
| 960 | 6364 | acydburn | WHERE ' . $db->sql_in_set('attach_id', array_keys($upload_list)) . ' |
| 961 | 6364 | acydburn | AND is_orphan = 1';
|
| 962 | 6364 | acydburn | $result = $db->sql_query($sql); |
| 963 | 6364 | acydburn | |
| 964 | 8451 | acydburn | $files_added = $space_taken = 0; |
| 965 | 6364 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 966 | 6364 | acydburn | {
|
| 967 | 6364 | acydburn | $post_row = $post_info[$upload_list[$row['attach_id']]]; |
| 968 | 6364 | acydburn | |
| 969 | 6364 | acydburn | $template->assign_block_vars('upload', array( |
| 970 | 6364 | acydburn | 'FILE_INFO' => sprintf($user->lang['UPLOADING_FILE_TO'], $row['real_filename'], $post_row['post_id']), |
| 971 | 6364 | acydburn | 'S_DENIED' => (!$auth->acl_get('f_attach', $post_row['forum_id'])) ? true : false, |
| 972 | 6364 | acydburn | 'L_DENIED' => (!$auth->acl_get('f_attach', $post_row['forum_id'])) ? sprintf($user->lang['UPLOAD_DENIED_FORUM'], $forum_names[$row['forum_id']]) : '') |
| 973 | 6364 | acydburn | ); |
| 974 | 6364 | acydburn | |
| 975 | 6364 | acydburn | if (!$auth->acl_get('f_attach', $post_row['forum_id'])) |
| 976 | 5303 | acydburn | {
|
| 977 | 6364 | acydburn | continue;
|
| 978 | 5303 | acydburn | } |
| 979 | 6073 | acydburn | |
| 980 | 6364 | acydburn | // Adjust attachment entry
|
| 981 | 6364 | acydburn | $sql_ary = array( |
| 982 | 6364 | acydburn | 'in_message' => 0, |
| 983 | 6364 | acydburn | 'is_orphan' => 0, |
| 984 | 6364 | acydburn | 'poster_id' => $post_row['poster_id'], |
| 985 | 6364 | acydburn | 'post_msg_id' => $post_row['post_id'], |
| 986 | 6364 | acydburn | 'topic_id' => $post_row['topic_id'], |
| 987 | 5303 | acydburn | ); |
| 988 | 6364 | acydburn | |
| 989 | 6364 | acydburn | $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' |
| 990 | 6364 | acydburn | SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' |
| 991 | 6364 | acydburn | WHERE attach_id = ' . $row['attach_id']; |
| 992 | 6364 | acydburn | $db->sql_query($sql); |
| 993 | 6364 | acydburn | |
| 994 | 6364 | acydburn | $sql = 'UPDATE ' . POSTS_TABLE . ' |
| 995 | 6364 | acydburn | SET post_attachment = 1 |
| 996 | 6364 | acydburn | WHERE post_id = ' . $post_row['post_id']; |
| 997 | 6364 | acydburn | $db->sql_query($sql); |
| 998 | 6364 | acydburn | |
| 999 | 6364 | acydburn | $sql = 'UPDATE ' . TOPICS_TABLE . ' |
| 1000 | 6364 | acydburn | SET topic_attachment = 1 |
| 1001 | 6364 | acydburn | WHERE topic_id = ' . $post_row['topic_id']; |
| 1002 | 6364 | acydburn | $db->sql_query($sql); |
| 1003 | 6364 | acydburn | |
| 1004 | 8451 | acydburn | $space_taken += $row['filesize']; |
| 1005 | 8451 | acydburn | $files_added++;
|
| 1006 | 8451 | acydburn | |
| 1007 | 6364 | acydburn | add_log('admin', 'LOG_ATTACH_FILEUPLOAD', $post_row['post_id'], $row['real_filename']); |
| 1008 | 5303 | acydburn | } |
| 1009 | 5303 | acydburn | $db->sql_freeresult($result); |
| 1010 | 8451 | acydburn | |
| 1011 | 8451 | acydburn | if ($files_added) |
| 1012 | 8451 | acydburn | {
|
| 1013 | 9398 | acydburn | set_config_count('upload_dir_size', $space_taken, true); |
| 1014 | 9398 | acydburn | set_config_count('num_files', $files_added, true); |
| 1015 | 8451 | acydburn | } |
| 1016 | 5303 | acydburn | } |
| 1017 | 5303 | acydburn | } |
| 1018 | 5303 | acydburn | |
| 1019 | 5303 | acydburn | $template->assign_vars(array( |
| 1020 | 5303 | acydburn | 'S_ORPHAN' => true) |
| 1021 | 5303 | acydburn | ); |
| 1022 | 6073 | acydburn | |
| 1023 | 6364 | acydburn | // Just get the files with is_orphan set and older than 3 hours
|
| 1024 | 6364 | acydburn | $sql = 'SELECT * |
| 1025 | 6364 | acydburn | FROM ' . ATTACHMENTS_TABLE . ' |
| 1026 | 6364 | acydburn | WHERE is_orphan = 1 |
| 1027 | 6364 | acydburn | AND filetime < ' . (time() - 3*60*60) . ' |
| 1028 | 6364 | acydburn | ORDER BY filetime DESC';
|
| 1029 | 5303 | acydburn | $result = $db->sql_query($sql); |
| 1030 | 5303 | acydburn | |
| 1031 | 5303 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 1032 | 5303 | acydburn | {
|
| 1033 | 5303 | acydburn | $template->assign_block_vars('orphan', array( |
| 1034 | 8389 | acydburn | 'FILESIZE' => get_formatted_filesize($row['filesize']), |
| 1035 | 6364 | acydburn | 'FILETIME' => $user->format_date($row['filetime']), |
| 1036 | 9905 | acydburn | 'REAL_FILENAME' => utf8_basename($row['real_filename']), |
| 1037 | 9905 | acydburn | 'PHYSICAL_FILENAME' => utf8_basename($row['physical_filename']), |
| 1038 | 6364 | acydburn | 'ATTACH_ID' => $row['attach_id'], |
| 1039 | 6364 | acydburn | 'POST_IDS' => (!empty($post_ids[$row['attach_id']])) ? $post_ids[$row['attach_id']] : '', |
| 1040 | 8119 | acydburn | 'U_FILE' => append_sid($phpbb_root_path . 'download/file.' . $phpEx, 'mode=view&id=' . $row['attach_id'])) |
| 1041 | 5303 | acydburn | ); |
| 1042 | 5303 | acydburn | } |
| 1043 | 6364 | acydburn | $db->sql_freeresult($result); |
| 1044 | 6364 | acydburn | |
| 1045 | 5303 | acydburn | break;
|
| 1046 | 5303 | acydburn | } |
| 1047 | 5303 | acydburn | |
| 1048 | 5303 | acydburn | if (sizeof($error)) |
| 1049 | 5303 | acydburn | {
|
| 1050 | 5303 | acydburn | $template->assign_vars(array( |
| 1051 | 5303 | acydburn | 'S_WARNING' => true, |
| 1052 | 5303 | acydburn | 'WARNING_MSG' => implode('<br />', $error)) |
| 1053 | 5303 | acydburn | ); |
| 1054 | 5303 | acydburn | } |
| 1055 | 5303 | acydburn | |
| 1056 | 5303 | acydburn | if (sizeof($notify)) |
| 1057 | 5303 | acydburn | {
|
| 1058 | 5303 | acydburn | $template->assign_vars(array( |
| 1059 | 5303 | acydburn | 'S_NOTIFY' => true, |
| 1060 | 5303 | acydburn | 'NOTIFY_MSG' => implode('<br />', $notify)) |
| 1061 | 5303 | acydburn | ); |
| 1062 | 5303 | acydburn | } |
| 1063 | 5303 | acydburn | } |
| 1064 | 5303 | acydburn | |
| 1065 | 5303 | acydburn | /**
|
| 1066 | 5303 | acydburn | * Build Select for category items |
| 1067 | 5303 | acydburn | */ |
| 1068 | 5303 | acydburn | function category_select($select_name, $group_id = false, $key = '') |
| 1069 | 5303 | acydburn | {
|
| 1070 | 5303 | acydburn | global $db, $user; |
| 1071 | 5303 | acydburn | |
| 1072 | 5303 | acydburn | $types = array( |
| 1073 | 6511 | acydburn | ATTACHMENT_CATEGORY_NONE => $user->lang['NO_FILE_CAT'], |
| 1074 | 6511 | acydburn | ATTACHMENT_CATEGORY_IMAGE => $user->lang['CAT_IMAGES'], |
| 1075 | 6511 | acydburn | ATTACHMENT_CATEGORY_WM => $user->lang['CAT_WM_FILES'], |
| 1076 | 6511 | acydburn | ATTACHMENT_CATEGORY_RM => $user->lang['CAT_RM_FILES'], |
| 1077 | 6511 | acydburn | ATTACHMENT_CATEGORY_FLASH => $user->lang['CAT_FLASH_FILES'], |
| 1078 | 6511 | acydburn | ATTACHMENT_CATEGORY_QUICKTIME => $user->lang['CAT_QUICKTIME_FILES'], |
| 1079 | 5303 | acydburn | ); |
| 1080 | 8350 | acydburn | |
| 1081 | 5303 | acydburn | if ($group_id) |
| 1082 | 5303 | acydburn | {
|
| 1083 | 5303 | acydburn | $sql = 'SELECT cat_id |
| 1084 | 5303 | acydburn | FROM ' . EXTENSION_GROUPS_TABLE . ' |
| 1085 | 5303 | acydburn | WHERE group_id = ' . (int) $group_id; |
| 1086 | 5303 | acydburn | $result = $db->sql_query($sql); |
| 1087 | 6073 | acydburn | |
| 1088 | 5303 | acydburn | $cat_type = (!($row = $db->sql_fetchrow($result))) ? ATTACHMENT_CATEGORY_NONE : $row['cat_id']; |
| 1089 | 5303 | acydburn | |
| 1090 | 5303 | acydburn | $db->sql_freeresult($result); |
| 1091 | 5303 | acydburn | } |
| 1092 | 5303 | acydburn | else
|
| 1093 | 5303 | acydburn | {
|
| 1094 | 5303 | acydburn | $cat_type = ATTACHMENT_CATEGORY_NONE; |
| 1095 | 5303 | acydburn | } |
| 1096 | 8350 | acydburn | |
| 1097 | 5303 | acydburn | $group_select = '<select name="' . $select_name . '"' . (($key) ? ' id="' . $key . '"' : '') . '>'; |
| 1098 | 5303 | acydburn | |
| 1099 | 5303 | acydburn | foreach ($types as $type => $mode) |
| 1100 | 5303 | acydburn | {
|
| 1101 | 5303 | acydburn | $selected = ($type == $cat_type) ? ' selected="selected"' : ''; |
| 1102 | 5303 | acydburn | $group_select .= '<option value="' . $type . '"' . $selected . '>' . $mode . '</option>'; |
| 1103 | 5303 | acydburn | } |
| 1104 | 5303 | acydburn | |
| 1105 | 5303 | acydburn | $group_select .= '</select>'; |
| 1106 | 5303 | acydburn | |
| 1107 | 5303 | acydburn | return $group_select; |
| 1108 | 5303 | acydburn | } |
| 1109 | 5303 | acydburn | |
| 1110 | 5303 | acydburn | /**
|
| 1111 | 5303 | acydburn | * Extension group select |
| 1112 | 5303 | acydburn | */ |
| 1113 | 5303 | acydburn | function group_select($select_name, $default_group = false, $key = '') |
| 1114 | 5303 | acydburn | {
|
| 1115 | 5303 | acydburn | global $db, $user; |
| 1116 | 8350 | acydburn | |
| 1117 | 5303 | acydburn | $group_select = '<select name="' . $select_name . '"' . (($key) ? ' id="' . $key . '"' : '') . '>'; |
| 1118 | 5303 | acydburn | |
| 1119 | 5303 | acydburn | $sql = 'SELECT group_id, group_name |
| 1120 | 5303 | acydburn | FROM ' . EXTENSION_GROUPS_TABLE . ' |
| 1121 | 5303 | acydburn | ORDER BY group_name';
|
| 1122 | 5303 | acydburn | $result = $db->sql_query($sql); |
| 1123 | 5303 | acydburn | |
| 1124 | 5303 | acydburn | $group_name = array(); |
| 1125 | 5303 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 1126 | 5303 | acydburn | {
|
| 1127 | 10613 | git-gate | $row['group_name'] = (isset($user->lang['EXT_GROUP_' . $row['group_name']])) ? $user->lang['EXT_GROUP_' . $row['group_name']] : $row['group_name']; |
| 1128 | 5303 | acydburn | $group_name[] = $row; |
| 1129 | 5303 | acydburn | } |
| 1130 | 5303 | acydburn | $db->sql_freeresult($result); |
| 1131 | 5303 | acydburn | |
| 1132 | 5303 | acydburn | $row['group_id'] = 0; |
| 1133 | 5303 | acydburn | $row['group_name'] = $user->lang['NOT_ASSIGNED']; |
| 1134 | 5303 | acydburn | $group_name[] = $row; |
| 1135 | 8350 | acydburn | |
| 1136 | 5303 | acydburn | for ($i = 0; $i < sizeof($group_name); $i++) |
| 1137 | 5303 | acydburn | {
|
| 1138 | 5303 | acydburn | if ($default_group === false) |
| 1139 | 5303 | acydburn | {
|
| 1140 | 5303 | acydburn | $selected = ($i == 0) ? ' selected="selected"' : ''; |
| 1141 | 5303 | acydburn | } |
| 1142 | 5303 | acydburn | else
|
| 1143 | 5303 | acydburn | {
|
| 1144 | 5303 | acydburn | $selected = ($group_name[$i]['group_id'] == $default_group) ? ' selected="selected"' : ''; |
| 1145 | 5303 | acydburn | } |
| 1146 | 5303 | acydburn | |
| 1147 | 5303 | acydburn | $group_select .= '<option value="' . $group_name[$i]['group_id'] . '"' . $selected . '>' . $group_name[$i]['group_name'] . '</option>'; |
| 1148 | 5303 | acydburn | } |
| 1149 | 5303 | acydburn | |
| 1150 | 5303 | acydburn | $group_select .= '</select>'; |
| 1151 | 5303 | acydburn | |
| 1152 | 5303 | acydburn | return $group_select; |
| 1153 | 5303 | acydburn | } |
| 1154 | 5303 | acydburn | |
| 1155 | 5303 | acydburn | /**
|
| 1156 | 5303 | acydburn | * Search Imagick |
| 1157 | 5303 | acydburn | */ |
| 1158 | 5303 | acydburn | function search_imagemagick() |
| 1159 | 5303 | acydburn | {
|
| 1160 | 5303 | acydburn | $imagick = ''; |
| 1161 | 6073 | acydburn | |
| 1162 | 6275 | acydburn | $exe = ((defined('PHP_OS')) && (preg_match('#^win#i', PHP_OS))) ? '.exe' : ''; |
| 1163 | 5303 | acydburn | |
| 1164 | 5625 | davidmj | $magic_home = getenv('MAGICK_HOME'); |
| 1165 | 5625 | davidmj | |
| 1166 | 5625 | davidmj | if (empty($magic_home)) |
| 1167 | 5303 | acydburn | {
|
| 1168 | 5303 | acydburn | $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/'); |
| 1169 | 8350 | acydburn | $path_locations = str_replace('\\', '/', (explode(($exe) ? ';' : ':', getenv('PATH')))); |
| 1170 | 6073 | acydburn | |
| 1171 | 5611 | davidmj | $locations = array_merge($path_locations, $locations); |
| 1172 | 5303 | acydburn | |
| 1173 | 5303 | acydburn | foreach ($locations as $location) |
| 1174 | 5303 | acydburn | {
|
| 1175 | 5611 | davidmj | // The path might not end properly, fudge it
|
| 1176 | 8310 | acydburn | if (substr($location, -1) !== '/') |
| 1177 | 5611 | davidmj | {
|
| 1178 | 5611 | davidmj | $location .= '/'; |
| 1179 | 5611 | davidmj | } |
| 1180 | 5611 | davidmj | |
| 1181 | 9041 | acydburn | if (@file_exists($location) && @is_readable($location . 'mogrify' . $exe) && @filesize($location . 'mogrify' . $exe) > 3000) |
| 1182 | 5303 | acydburn | {
|
| 1183 | 5303 | acydburn | $imagick = str_replace('\\', '/', $location); |
| 1184 | 5303 | acydburn | continue;
|
| 1185 | 5303 | acydburn | } |
| 1186 | 5303 | acydburn | } |
| 1187 | 5303 | acydburn | } |
| 1188 | 5303 | acydburn | else
|
| 1189 | 5303 | acydburn | {
|
| 1190 | 5625 | davidmj | $imagick = str_replace('\\', '/', $magic_home); |
| 1191 | 5303 | acydburn | } |
| 1192 | 5303 | acydburn | |
| 1193 | 5303 | acydburn | return $imagick; |
| 1194 | 5303 | acydburn | } |
| 1195 | 5303 | acydburn | |
| 1196 | 5303 | acydburn | /**
|
| 1197 | 5303 | acydburn | * Test Settings |
| 1198 | 5303 | acydburn | */ |
| 1199 | 5303 | acydburn | function test_upload(&$error, $upload_dir, $create_directory = false) |
| 1200 | 5303 | acydburn | {
|
| 1201 | 5303 | acydburn | global $user, $phpbb_root_path; |
| 1202 | 5303 | acydburn | |
| 1203 | 7455 | acydburn | // Does the target directory exist, is it a directory and writable.
|
| 1204 | 5303 | acydburn | if ($create_directory) |
| 1205 | 5303 | acydburn | {
|
| 1206 | 5303 | acydburn | if (!file_exists($phpbb_root_path . $upload_dir)) |
| 1207 | 5303 | acydburn | {
|
| 1208 | 5303 | acydburn | @mkdir($phpbb_root_path . $upload_dir, 0777); |
| 1209 | 8780 | acydburn | phpbb_chmod($phpbb_root_path . $upload_dir, CHMOD_READ | CHMOD_WRITE); |
| 1210 | 5303 | acydburn | } |
| 1211 | 5303 | acydburn | } |
| 1212 | 5303 | acydburn | |
| 1213 | 5303 | acydburn | if (!file_exists($phpbb_root_path . $upload_dir)) |
| 1214 | 5303 | acydburn | {
|
| 1215 | 5303 | acydburn | $error[] = sprintf($user->lang['NO_UPLOAD_DIR'], $upload_dir); |
| 1216 | 5303 | acydburn | return;
|
| 1217 | 5303 | acydburn | } |
| 1218 | 6073 | acydburn | |
| 1219 | 5303 | acydburn | if (!is_dir($phpbb_root_path . $upload_dir)) |
| 1220 | 5303 | acydburn | {
|
| 1221 | 5303 | acydburn | $error[] = sprintf($user->lang['UPLOAD_NOT_DIR'], $upload_dir); |
| 1222 | 5303 | acydburn | return;
|
| 1223 | 5303 | acydburn | } |
| 1224 | 6073 | acydburn | |
| 1225 | 10757 | git-gate | if (!phpbb_is_writable($phpbb_root_path . $upload_dir)) |
| 1226 | 5303 | acydburn | {
|
| 1227 | 5303 | acydburn | $error[] = sprintf($user->lang['NO_WRITE_UPLOAD'], $upload_dir); |
| 1228 | 5303 | acydburn | return;
|
| 1229 | 5303 | acydburn | } |
| 1230 | 5303 | acydburn | } |
| 1231 | 5303 | acydburn | |
| 1232 | 5303 | acydburn | /**
|
| 1233 | 5303 | acydburn | * Perform operations on sites for external linking |
| 1234 | 5303 | acydburn | */ |
| 1235 | 5303 | acydburn | function perform_site_list() |
| 1236 | 5303 | acydburn | {
|
| 1237 | 5303 | acydburn | global $db, $user; |
| 1238 | 5303 | acydburn | |
| 1239 | 5303 | acydburn | if (isset($_REQUEST['securesubmit'])) |
| 1240 | 5303 | acydburn | {
|
| 1241 | 5303 | acydburn | // Grab the list of entries
|
| 1242 | 5303 | acydburn | $ips = request_var('ips', ''); |
| 1243 | 5303 | acydburn | $ip_list = array_unique(explode("\n", $ips)); |
| 1244 | 5303 | acydburn | $ip_list_log = implode(', ', $ip_list); |
| 1245 | 5303 | acydburn | |
| 1246 | 5303 | acydburn | $ip_exclude = (!empty($_POST['ipexclude'])) ? 1 : 0; |
| 1247 | 5303 | acydburn | |
| 1248 | 5303 | acydburn | $iplist = array(); |
| 1249 | 5303 | acydburn | $hostlist = array(); |
| 1250 | 5303 | acydburn | |
| 1251 | 5303 | acydburn | foreach ($ip_list as $item) |
| 1252 | 5303 | acydburn | {
|
| 1253 | 5303 | acydburn | 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)) |
| 1254 | 5303 | acydburn | {
|
| 1255 | 5303 | acydburn | // Don't ask about all this, just don't ask ... !
|
| 1256 | 5303 | acydburn | $ip_1_counter = $ip_range_explode[1]; |
| 1257 | 5303 | acydburn | $ip_1_end = $ip_range_explode[5]; |
| 1258 | 5303 | acydburn | |
| 1259 | 5303 | acydburn | while ($ip_1_counter <= $ip_1_end) |
| 1260 | 5303 | acydburn | {
|
| 1261 | 5303 | acydburn | $ip_2_counter = ($ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[2] : 0; |
| 1262 | 5303 | acydburn | $ip_2_end = ($ip_1_counter < $ip_1_end) ? 254 : $ip_range_explode[6]; |
| 1263 | 5303 | acydburn | |
| 1264 | 5303 | acydburn | if ($ip_2_counter == 0 && $ip_2_end == 254) |
| 1265 | 5303 | acydburn | {
|
| 1266 | 5303 | acydburn | $ip_2_counter = 256; |
| 1267 | 5303 | acydburn | $ip_2_fragment = 256; |
| 1268 | 5303 | acydburn | |
| 1269 | 5303 | acydburn | $iplist[] = "'$ip_1_counter.*'"; |
| 1270 | 5303 | acydburn | } |
| 1271 | 5303 | acydburn | |
| 1272 | 5303 | acydburn | while ($ip_2_counter <= $ip_2_end) |
| 1273 | 5303 | acydburn | {
|
| 1274 | 5303 | acydburn | $ip_3_counter = ($ip_2_counter == $ip_range_explode[2] && $ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[3] : 0; |
| 1275 | 5303 | acydburn | $ip_3_end = ($ip_2_counter < $ip_2_end || $ip_1_counter < $ip_1_end) ? 254 : $ip_range_explode[7]; |
| 1276 | 5303 | acydburn | |
| 1277 | 5303 | acydburn | if ($ip_3_counter == 0 && $ip_3_end == 254) |
| 1278 | 5303 | acydburn | {
|
| 1279 | 5303 | acydburn | $ip_3_counter = 256; |
| 1280 | 5303 | acydburn | $ip_3_fragment = 256; |
| 1281 | 5303 | acydburn | |
| 1282 | 5303 | acydburn | $iplist[] = "'$ip_1_counter.$ip_2_counter.*'"; |
| 1283 | 5303 | acydburn | } |
| 1284 | 5303 | acydburn | |
| 1285 | 5303 | acydburn | while ($ip_3_counter <= $ip_3_end) |
| 1286 | 5303 | acydburn | {
|
| 1287 | 5303 | acydburn | $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; |
| 1288 | 5303 | acydburn | $ip_4_end = ($ip_3_counter < $ip_3_end || $ip_2_counter < $ip_2_end) ? 254 : $ip_range_explode[8]; |
| 1289 | 5303 | acydburn | |
| 1290 | 5303 | acydburn | if ($ip_4_counter == 0 && $ip_4_end == 254) |
| 1291 | 5303 | acydburn | {
|
| 1292 | 5303 | acydburn | $ip_4_counter = 256; |
| 1293 | 5303 | acydburn | $ip_4_fragment = 256; |
| 1294 | 5303 | acydburn | |
| 1295 | 5303 | acydburn | $iplist[] = "'$ip_1_counter.$ip_2_counter.$ip_3_counter.*'"; |
| 1296 | 5303 | acydburn | } |
| 1297 | 5303 | acydburn | |
| 1298 | 5303 | acydburn | while ($ip_4_counter <= $ip_4_end) |
| 1299 | 5303 | acydburn | {
|
| 1300 | 5303 | acydburn | $iplist[] = "'$ip_1_counter.$ip_2_counter.$ip_3_counter.$ip_4_counter'"; |
| 1301 | 5303 | acydburn | $ip_4_counter++;
|
| 1302 | 5303 | acydburn | } |
| 1303 | 5303 | acydburn | $ip_3_counter++;
|
| 1304 | 5303 | acydburn | } |
| 1305 | 5303 | acydburn | $ip_2_counter++;
|
| 1306 | 5303 | acydburn | } |
| 1307 | 5303 | acydburn | $ip_1_counter++;
|
| 1308 | 5303 | acydburn | } |
| 1309 | 5303 | acydburn | } |
| 1310 | 5303 | acydburn | 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))) |
| 1311 | 5303 | acydburn | {
|
| 1312 | 5303 | acydburn | $iplist[] = "'" . trim($item) . "'"; |
| 1313 | 5303 | acydburn | } |
| 1314 | 5303 | acydburn | else if (preg_match('#^([\w\-_]\.?){2,}$#is', trim($item))) |
| 1315 | 5303 | acydburn | {
|
| 1316 | 5303 | acydburn | $hostlist[] = "'" . trim($item) . "'"; |
| 1317 | 5303 | acydburn | } |
| 1318 | 5303 | acydburn | else if (preg_match("#^([a-z0-9\-\*\._/]+?)$#is", trim($item))) |
| 1319 | 5303 | acydburn | {
|
| 1320 | 5303 | acydburn | $hostlist[] = "'" . trim($item) . "'"; |
| 1321 | 5303 | acydburn | } |
| 1322 | 5303 | acydburn | } |
| 1323 | 5303 | acydburn | |
| 1324 | 5303 | acydburn | $sql = 'SELECT site_ip, site_hostname |
| 1325 | 5303 | acydburn | FROM ' . SITELIST_TABLE . " |
| 1326 | 5303 | acydburn | WHERE ip_exclude = $ip_exclude"; |
| 1327 | 5303 | acydburn | $result = $db->sql_query($sql); |
| 1328 | 5303 | acydburn | |
| 1329 | 5303 | acydburn | if ($row = $db->sql_fetchrow($result)) |
| 1330 | 5303 | acydburn | {
|
| 1331 | 5303 | acydburn | $iplist_tmp = array(); |
| 1332 | 5303 | acydburn | $hostlist_tmp = array(); |
| 1333 | 5303 | acydburn | do
|
| 1334 | 5303 | acydburn | {
|
| 1335 | 5303 | acydburn | if ($row['site_ip']) |
| 1336 | 5303 | acydburn | {
|
| 1337 | 6880 | davidmj | if (strlen($row['site_ip']) > 40) |
| 1338 | 6880 | davidmj | {
|
| 1339 | 6880 | davidmj | continue;
|
| 1340 | 6880 | davidmj | } |
| 1341 | 6880 | davidmj | |
| 1342 | 5303 | acydburn | $iplist_tmp[] = "'" . $row['site_ip'] . "'"; |
| 1343 | 5303 | acydburn | } |
| 1344 | 5303 | acydburn | else if ($row['site_hostname']) |
| 1345 | 5303 | acydburn | {
|
| 1346 | 6880 | davidmj | if (strlen($row['site_hostname']) > 255) |
| 1347 | 6880 | davidmj | {
|
| 1348 | 6880 | davidmj | continue;
|
| 1349 | 6880 | davidmj | } |
| 1350 | 6880 | davidmj | |
| 1351 | 5303 | acydburn | $hostlist_tmp[] = "'" . $row['site_hostname'] . "'"; |
| 1352 | 5303 | acydburn | } |
| 1353 | 5967 | acydburn | // break;
|
| 1354 | 5303 | acydburn | } |
| 1355 | 5303 | acydburn | while ($row = $db->sql_fetchrow($result)); |
| 1356 | 5303 | acydburn | |
| 1357 | 5303 | acydburn | $iplist = array_unique(array_diff($iplist, $iplist_tmp)); |
| 1358 | 5303 | acydburn | $hostlist = array_unique(array_diff($hostlist, $hostlist_tmp)); |
| 1359 | 5303 | acydburn | unset($iplist_tmp); |
| 1360 | 5303 | acydburn | unset($hostlist_tmp); |
| 1361 | 5303 | acydburn | } |
| 1362 | 6073 | acydburn | $db->sql_freeresult($result); |
| 1363 | 5303 | acydburn | |
| 1364 | 5303 | acydburn | if (sizeof($iplist)) |
| 1365 | 5303 | acydburn | {
|
| 1366 | 5303 | acydburn | foreach ($iplist as $ip_entry) |
| 1367 | 5303 | acydburn | {
|
| 1368 | 5303 | acydburn | $sql = 'INSERT INTO ' . SITELIST_TABLE . " (site_ip, ip_exclude) |
| 1369 | 5303 | acydburn | VALUES ($ip_entry, $ip_exclude)"; |
| 1370 | 5303 | acydburn | $db->sql_query($sql); |
| 1371 | 5303 | acydburn | } |
| 1372 | 5303 | acydburn | } |
| 1373 | 5303 | acydburn | |
| 1374 | 5303 | acydburn | if (sizeof($hostlist)) |
| 1375 | 5303 | acydburn | {
|
| 1376 | 5303 | acydburn | foreach ($hostlist as $host_entry) |
| 1377 | 5303 | acydburn | {
|
| 1378 | 5303 | acydburn | $sql = 'INSERT INTO ' . SITELIST_TABLE . " (site_hostname, ip_exclude) |
| 1379 | 5303 | acydburn | VALUES ($host_entry, $ip_exclude)"; |
| 1380 | 5303 | acydburn | $db->sql_query($sql); |
| 1381 | 5303 | acydburn | } |
| 1382 | 5303 | acydburn | } |
| 1383 | 8350 | acydburn | |
| 1384 | 5303 | acydburn | if (!empty($ip_list_log)) |
| 1385 | 5303 | acydburn | {
|
| 1386 | 5303 | acydburn | // Update log
|
| 1387 | 5303 | acydburn | $log_entry = ($ip_exclude) ? 'LOG_DOWNLOAD_EXCLUDE_IP' : 'LOG_DOWNLOAD_IP'; |
| 1388 | 5303 | acydburn | add_log('admin', $log_entry, $ip_list_log); |
| 1389 | 5303 | acydburn | } |
| 1390 | 5303 | acydburn | |
| 1391 | 6428 | acydburn | trigger_error($user->lang['SECURE_DOWNLOAD_UPDATE_SUCCESS'] . adm_back_link($this->u_action)); |
| 1392 | 5303 | acydburn | } |
| 1393 | 5303 | acydburn | else if (isset($_POST['unsecuresubmit'])) |
| 1394 | 5303 | acydburn | {
|
| 1395 | 6816 | acydburn | $unip_sql = request_var('unip', array(0)); |
| 1396 | 5303 | acydburn | |
| 1397 | 6271 | acydburn | if (sizeof($unip_sql)) |
| 1398 | 5303 | acydburn | {
|
| 1399 | 5303 | acydburn | $l_unip_list = ''; |
| 1400 | 6271 | acydburn | |
| 1401 | 5303 | acydburn | // Grab details of ips for logging information later
|
| 1402 | 5303 | acydburn | $sql = 'SELECT site_ip, site_hostname |
| 1403 | 6271 | acydburn | FROM ' . SITELIST_TABLE . ' |
| 1404 | 6271 | acydburn | WHERE ' . $db->sql_in_set('site_id', $unip_sql); |
| 1405 | 5303 | acydburn | $result = $db->sql_query($sql); |
| 1406 | 5303 | acydburn | |
| 1407 | 5303 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 1408 | 5303 | acydburn | {
|
| 1409 | 5303 | acydburn | $l_unip_list .= (($l_unip_list != '') ? ', ' : '') . (($row['site_ip']) ? $row['site_ip'] : $row['site_hostname']); |
| 1410 | 5303 | acydburn | } |
| 1411 | 6073 | acydburn | $db->sql_freeresult($result); |
| 1412 | 5303 | acydburn | |
| 1413 | 6271 | acydburn | $sql = 'DELETE FROM ' . SITELIST_TABLE . ' |
| 1414 | 6271 | acydburn | WHERE ' . $db->sql_in_set('site_id', $unip_sql); |
| 1415 | 5303 | acydburn | $db->sql_query($sql); |
| 1416 | 5303 | acydburn | |
| 1417 | 5303 | acydburn | add_log('admin', 'LOG_DOWNLOAD_REMOVE_IP', $l_unip_list); |
| 1418 | 5303 | acydburn | } |
| 1419 | 5303 | acydburn | |
| 1420 | 6428 | acydburn | trigger_error($user->lang['SECURE_DOWNLOAD_UPDATE_SUCCESS'] . adm_back_link($this->u_action)); |
| 1421 | 5303 | acydburn | } |
| 1422 | 5303 | acydburn | } |
| 1423 | 5303 | acydburn | |
| 1424 | 5303 | acydburn | /**
|
| 1425 | 5902 | acydburn | * Write display_order config field |
| 1426 | 5902 | acydburn | */ |
| 1427 | 5902 | acydburn | function display_order($value, $key = '') |
| 1428 | 5902 | acydburn | {
|
| 1429 | 5902 | acydburn | $radio_ary = array(0 => 'DESCENDING', 1 => 'ASCENDING'); |
| 1430 | 5902 | acydburn | |
| 1431 | 5902 | acydburn | return h_radio('config[display_order]', $radio_ary, $value, $key); |
| 1432 | 5902 | acydburn | } |
| 1433 | 5902 | acydburn | |
| 1434 | 5902 | acydburn | /**
|
| 1435 | 5902 | acydburn | * Adjust all three max_filesize config vars for display |
| 1436 | 5902 | acydburn | */ |
| 1437 | 5902 | acydburn | function max_filesize($value, $key = '') |
| 1438 | 5902 | acydburn | {
|
| 1439 | 5902 | acydburn | // Determine size var and adjust the value accordingly
|
| 1440 | 9748 | bantu | $filesize = get_formatted_filesize($value, false, array('mb', 'kb', 'b')); |
| 1441 | 9748 | bantu | $size_var = $filesize['si_identifier']; |
| 1442 | 9748 | bantu | $value = $filesize['value']; |
| 1443 | 5902 | acydburn | |
| 1444 | 5902 | acydburn | return '<input type="text" id="' . $key . '" size="8" maxlength="15" name="config[' . $key . ']" value="' . $value . '" /> <select name="' . $key . '">' . size_select_options($size_var) . '</select>'; |
| 1445 | 5902 | acydburn | } |
| 1446 | 5902 | acydburn | |
| 1447 | 5902 | acydburn | /**
|
| 1448 | 5902 | acydburn | * Write secure_allow_deny config field |
| 1449 | 5902 | acydburn | */ |
| 1450 | 5902 | acydburn | function select_allow_deny($value, $key = '') |
| 1451 | 5902 | acydburn | {
|
| 1452 | 5902 | acydburn | $radio_ary = array(1 => 'ORDER_ALLOW_DENY', 0 => 'ORDER_DENY_ALLOW'); |
| 1453 | 5902 | acydburn | |
| 1454 | 5902 | acydburn | return h_radio('config[' . $key . ']', $radio_ary, $value, $key); |
| 1455 | 5902 | acydburn | } |
| 1456 | 5902 | acydburn | |
| 1457 | 5303 | acydburn | } |
| 1458 | 5303 | acydburn | |
| 1459 | 8531 | acydburn | ?> |

