mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-05 14:04:57 +02:00
1144 lines
38 KiB
PHP
1144 lines
38 KiB
PHP
<?php
|
|
/***************************************************************************
|
|
* admin_attachments.php
|
|
* -------------------
|
|
* begin : Sunday, Apr 20, 2003
|
|
* copyright : (C) 2003 The phpBB Group
|
|
* email : support@phpbb.com
|
|
*
|
|
* $Id$
|
|
*
|
|
***************************************************************************/
|
|
|
|
/***************************************************************************
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
***************************************************************************/
|
|
|
|
if (!empty($setmodules))
|
|
{
|
|
$filename = basename(__FILE__);
|
|
$module['POST']['ATTACHMENTS'] = ($auth->acl_get('a_attach')) ? $filename . $SID . '&mode=manage' : '';
|
|
|
|
return;
|
|
}
|
|
|
|
define('IN_PHPBB', 1);
|
|
// Include files
|
|
$phpbb_root_path = '../';
|
|
require($phpbb_root_path . 'extension.inc');
|
|
require('pagestart.' . $phpEx);
|
|
|
|
if (!$auth->acl_get('a_attach'))
|
|
{
|
|
trigger_error($user->lang['NO_ADMIN']);
|
|
}
|
|
|
|
$mode = (isset($_REQUEST['mode'])) ? htmlspecialchars($_REQUEST['mode']) : '';
|
|
|
|
$config_sizes = array('max_filesize' => 'size', 'attachment_quota' => 'quota_size', 'max_filesize_pm' => 'pm_size');
|
|
|
|
foreach ($config_sizes as $cfg_key => $var)
|
|
{
|
|
$$var = (isset($_REQUEST[$var])) ? htmlspecialchars($_REQUEST[$var]) : '';
|
|
}
|
|
|
|
$submit = (isset($_POST['submit'])) ? TRUE : FALSE;
|
|
$search_imagick = (isset($_POST['search_imagick'])) ? TRUE : FALSE;
|
|
|
|
$error = $notify = false;
|
|
$error_msg = $notify_msg = '';
|
|
|
|
// 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] = (isset($_POST[$config_name])) ? $_POST[$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)
|
|
{
|
|
if ($new[$config_name] >= 1048576)
|
|
{
|
|
$new[$config_name] = round($new[$config_name] / 1048576 * 100) / 100;
|
|
}
|
|
else if($new[$config_name] >= 1024)
|
|
{
|
|
$new[$config_name] = round($new[$config_name] / 1024 * 100) / 100;
|
|
}
|
|
}
|
|
|
|
if ($submit && $mode == 'manage' && $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 && $mode == 'manage')
|
|
{
|
|
// Update Extension Group Filesizes
|
|
if ($config_name == 'max_filesize')
|
|
{
|
|
$old_size = intval($default_config[$config_name]);
|
|
$new_size = intval($new[$config_name]);
|
|
|
|
if ($old_size != $new_size)
|
|
{
|
|
// See, if we have a similar value of old_size in Extension Groups. If so, update these values.
|
|
$sql = "UPDATE " . EXTENSION_GROUPS_TABLE . "
|
|
SET max_filesize = " . $new_size . "
|
|
WHERE max_filesize = " . $old_size;
|
|
$db->sql_query($sql);
|
|
}
|
|
}
|
|
|
|
set_config($config_name, stripslashes($new[$config_name]));
|
|
|
|
if (in_array($config_name, array('max_filesize', 'attachment_quota', 'max_filesize_pm')))
|
|
{
|
|
$new[$config_name] = $old;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($submit && ($mode == 'manage' || $mode == 'cats'))
|
|
{
|
|
add_log('admin', 'LOG_ATTACH_CONFIG');
|
|
$notify = TRUE;
|
|
$notify_msg = $user->lang['ATTACH_CONFIG_UPDATED'];
|
|
}
|
|
|
|
// Adjust the Upload Directory
|
|
if (!$new['allow_ftp_upload'])
|
|
{
|
|
if ( ($new['upload_dir'][0] == '/') || ( ($new['upload_dir'][0] != '/') && ($new['upload_dir'][1] == ':') ) )
|
|
{
|
|
$upload_dir = $new['upload_dir'];
|
|
}
|
|
else
|
|
{
|
|
$upload_dir = $phpbb_root_path . $new['upload_dir'];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$upload_dir = $new['download_path'];
|
|
}
|
|
|
|
switch ($mode)
|
|
{
|
|
case 'manage':
|
|
$l_title = 'ATTACHMENT_CONFIG';
|
|
break;
|
|
|
|
case 'cats':
|
|
$l_title = 'MANAGE_CATEGORIES';
|
|
break;
|
|
|
|
case 'ext_groups':
|
|
$l_title = 'EXTENSION_GROUPS_TITLE';
|
|
}
|
|
|
|
// Temporary Language Variables
|
|
|
|
adm_page_header($user->lang[$l_title]);
|
|
|
|
// Search Imagick
|
|
if ($search_imagick)
|
|
{
|
|
$imagick = '';
|
|
|
|
if (eregi('convert', $imagick))
|
|
{
|
|
continue;
|
|
}
|
|
else if ($imagick != 'none')
|
|
{
|
|
if (!eregi('WIN', PHP_OS))
|
|
{
|
|
$retval = @exec('whereis convert');
|
|
$paths = explode(' ', $retval);
|
|
|
|
if (is_array($paths))
|
|
{
|
|
foreach($paths as $path)
|
|
{
|
|
if (basename($path) == 'convert')
|
|
{
|
|
$imagick = $path;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (eregi('WIN', PHP_OS))
|
|
{
|
|
$path = 'c:/imagemagick/convert.exe';
|
|
|
|
if (@file_exists($path))
|
|
{
|
|
$imagick = $path;
|
|
}
|
|
}
|
|
}
|
|
|
|
$new['img_imagick'] = (@file_exists(trim($imagick))) ? trim($imagick) : '';
|
|
}
|
|
|
|
// Check Settings
|
|
if ($submit && $mode == 'manage')
|
|
{
|
|
$upload_dir = ( ($new['upload_dir'][0] == '/') || ($new['upload_dir'][0] != '/' && $new['upload_dir'][1] == ':') ) ? $new['upload_dir'] : $phpbb_root_path . $new['upload_dir'];
|
|
|
|
test_upload($error, $error_msg, $upload_dir, $new['ftp_path'], $new['allow_ftp_upload'], false);
|
|
}
|
|
|
|
|
|
if ($submit && $mode == 'cats')
|
|
{
|
|
$upload_dir = ( ($new['upload_dir'][0] == '/') || ($new['upload_dir'][0] != '/' && $new['upload_dir'][1] == ':') ) ? $new['upload_dir'] . '/thumbs' : $phpbb_root_path . $new['upload_dir'] . '/thumbs';
|
|
test_upload($error, $error_msg, $upload_dir, $new['ftp_path'] . '/thumbs', $new['allow_ftp_upload'], true);
|
|
}
|
|
|
|
if ($submit && $mode == 'ext_groups')
|
|
{
|
|
// Change Extension Groups ?
|
|
$group_change_list = ( isset($_POST['group_change_list']) ) ? $_POST['group_change_list'] : array();
|
|
$extension_group_list = ( isset($_POST['extension_group_list']) ) ? $_POST['extension_group_list'] : array();
|
|
$group_allowed_list = ( isset($_POST['allowed_list']) ) ? $_POST['allowed_list'] : array();
|
|
$download_mode_list = ( isset($_POST['download_mode_list']) ) ? $_POST['download_mode_list'] : array();
|
|
$category_list = ( isset($_POST['category_list']) ) ? $_POST['category_list'] : array();
|
|
$upload_icon_list = ( isset($_POST['upload_icon_list']) ) ? $_POST['upload_icon_list'] : array();
|
|
$filesize_list = ( isset($_POST['max_filesize_list']) ) ? $_POST['max_filesize_list'] : array();
|
|
$size_select_list = ( isset($_POST['size_select_list']) ) ? $_POST['size_select_list'] : array();
|
|
|
|
$allowed_list = array();
|
|
|
|
for ($i = 0; $i < count($group_allowed_list); $i++)
|
|
{
|
|
for ($j = 0; $j < count($group_change_list); $j++)
|
|
{
|
|
if ($group_allowed_list[$i] == $group_change_list[$j])
|
|
{
|
|
$allowed_list[$j] = '1';
|
|
}
|
|
}
|
|
}
|
|
|
|
for ($i = 0; $i < count($group_change_list); $i++)
|
|
{
|
|
$allowed = ( isset($allowed_list[$i]) ) ? 1 : 0;
|
|
|
|
$filesize_list[$i] = ( $size_select_list[$i] == 'kb' ) ? round($filesize_list[$i] * 1024) : ( ($size_select_list[$i] == 'mb') ? round($filesize_list[$i] * 1048576) : $filesize_list[$i] );
|
|
|
|
$group_sql = array(
|
|
'group_name' => $extension_group_list[$i],
|
|
'cat_id' => $category_list[$i],
|
|
'allow_group' => $allowed,
|
|
'download_mode' => $download_mode_list[$i],
|
|
'upload_icon' => ($upload_icon_list[$i] == 'no_image') ? '' : $upload_icon_list[$i],
|
|
'max_filesize' => $filesize_list[$i]
|
|
);
|
|
|
|
$sql = "UPDATE " . EXTENSION_GROUPS_TABLE . " SET " . $db->sql_build_array('UPDATE', $group_sql) . " WHERE group_id = " . $group_change_list[$i];
|
|
$db->sql_query($sql);
|
|
}
|
|
|
|
// Delete Extension Groups
|
|
$group_id_list = ( isset($_POST['group_id_list']) ) ? $_POST['group_id_list'] : array();
|
|
|
|
if (count($group_id_list))
|
|
{
|
|
$l_group_list = '';
|
|
|
|
$sql = "SELECT group_name
|
|
FROM " . EXTENSION_GROUPS_TABLE . "
|
|
WHERE group_id IN (" . implode(', ', $group_id_list) . ")";
|
|
$result = $db->sql_query($sql);
|
|
|
|
while ($row = $db->sql_fetchrow($result))
|
|
{
|
|
$l_group_list .= (($l_group_list != '') ? ', ' : '') . $row['group_name'];
|
|
}
|
|
$db->sql_freeresult($result);
|
|
|
|
$sql = "DELETE
|
|
FROM " . EXTENSION_GROUPS_TABLE . "
|
|
WHERE group_id IN (" . implode(', ', $group_id_list) . ")";
|
|
$db->sql_query($sql);
|
|
|
|
// Set corresponding Extensions to a pending Group
|
|
$sql = "UPDATE " . EXTENSIONS_TABLE . "
|
|
SET group_id = 0
|
|
WHERE group_id IN (" . implode(', ', $group_id_list) . ")";
|
|
$db->sql_query($sql);
|
|
|
|
add_log('admin', 'LOG_ATTACH_EXTGROUP_DEL', $l_group_list);
|
|
}
|
|
|
|
// Add Extensions Group ?
|
|
$extension_group = ( isset($_POST['add_extension_group']) ) ? trim(strip_tags($_POST['add_extension_group'])) : '';
|
|
$download_mode = ( isset($_POST['add_download_mode']) ) ? $_POST['add_download_mode'] : '';
|
|
$cat_id = ( isset($_POST['add_category']) ) ? $_POST['add_category'] : '';
|
|
$upload_icon = ( isset($_POST['add_upload_icon']) ) ? $_POST['add_upload_icon'] : '';
|
|
$filesize = ( isset($_POST['add_max_filesize']) ) ? $_POST['add_max_filesize'] : '';
|
|
$size_select = ( isset($_POST['add_size_select']) ) ? $_POST['add_size_select'] : '';
|
|
$is_allowed = ( isset($_POST['add_allowed']) ) ? 1 : 0;
|
|
$add = ( isset($_POST['add_extension_group_check']) ) ? TRUE : FALSE;
|
|
|
|
if ($extension_group != '' && $add)
|
|
{
|
|
// check Extension Group
|
|
$sql = "SELECT group_name
|
|
FROM " . EXTENSION_GROUPS_TABLE;
|
|
$result = $db->sql_query($sql);
|
|
|
|
while ($row = $db->sql_fetchrow($result))
|
|
{
|
|
if ($row['group_name'] == $extension_group)
|
|
{
|
|
$error = TRUE;
|
|
if (isset($error_msg))
|
|
{
|
|
$error_msg .= '<br />';
|
|
}
|
|
$error_msg .= sprintf($user->lang['EXTENSION_GROUP_EXIST'], $extension_group);
|
|
}
|
|
}
|
|
$db->sql_freeresult($result);
|
|
|
|
if (!$error)
|
|
{
|
|
$filesize = ($size_select == 'kb') ? round($filesize * 1024) : (($size_select == 'mb') ? round($filesize * 1048576) : $filesize);
|
|
|
|
$group_sql = array(
|
|
'group_name' => $extension_group,
|
|
'cat_id' => $cat_id,
|
|
'allow_group' => $is_allowed,
|
|
'download_mode' => $download_mode,
|
|
'upload_icon' => ($upload_icon == 'no_image') ? '' : $upload_icon,
|
|
'max_filesize' => $filesize
|
|
);
|
|
|
|
$sql = "INSERT INTO " . EXTENSION_GROUPS_TABLE . " " . $db->sql_build_array('INSERT', $group_sql);
|
|
$db->sql_query($sql);
|
|
|
|
add_log('admin', 'LOG_ATTACH_EXTGROUP_ADD', $extension_group);
|
|
}
|
|
}
|
|
|
|
$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 = strtolower(trim($row['extension']));
|
|
|
|
$extensions['_allowed_'][] = $extension;
|
|
$extensions[$extension]['display_cat'] = intval($row['cat_id']);
|
|
$extensions[$extension]['download_mode'] = intval($row['download_mode']);
|
|
$extensions[$extension]['upload_icon'] = trim($row['upload_icon']);
|
|
$extensions[$extension]['max_filesize'] = intval($row['max_filesize']);
|
|
}
|
|
$db->sql_freeresult($result);
|
|
|
|
$cache->destroy('extensions');
|
|
$cache->put('extensions', $extensions);
|
|
|
|
if (!$error)
|
|
{
|
|
$notify = true;
|
|
$notify_msg = $user->lang['EXTENSION_GROUPS_UPDATED'];
|
|
}
|
|
}
|
|
|
|
?>
|
|
|
|
<h1><?php echo $user->lang[$l_title]; ?></h1>
|
|
|
|
<p><?php echo $user->lang[$l_title . '_EXPLAIN']; ?></p>
|
|
|
|
<?php
|
|
if ($error)
|
|
{
|
|
?>
|
|
|
|
<h2 style="color:red"><?php echo $user->lang['WARNING']; ?></h2>
|
|
|
|
<p><?php echo $error_msg; ?></p>
|
|
|
|
<?php
|
|
}
|
|
else if ($notify)
|
|
{
|
|
?>
|
|
|
|
<h2 style="color:green"><?php echo $user->lang['NOTIFY']; ?></h2>
|
|
|
|
<p><?php echo $notify_msg; ?></p>
|
|
|
|
<?php
|
|
}
|
|
|
|
$modes = array('manage', 'cats', 'extensions', 'ext_groups');
|
|
|
|
$select_size_mode = size_select('size', $size);
|
|
$select_quota_size_mode = size_select('quota_size', $quota_size);
|
|
$select_pm_size_mode = size_select('pm_size', $pm_size);
|
|
|
|
?>
|
|
<form action="admin_attachments.<?php echo $phpEx . $SID . "&mode=$mode"; ?>" method="post">
|
|
<table cellspacing="1" cellpadding="0" border="0" align="center" width="100%">
|
|
<tr>
|
|
<td align="right">
|
|
<?php
|
|
for ($i = 0; $i < count($modes); $i++)
|
|
{
|
|
if ($i != 0)
|
|
{
|
|
?> | <?php
|
|
}
|
|
|
|
if ($mode != $modes[$i])
|
|
{
|
|
?><a href="admin_attachments.<?php echo $phpEx . $SID . '&mode=' . $modes[$i]; ?>"><?php
|
|
}
|
|
|
|
echo $user->lang['ATTACH_' . strtoupper($modes[$i]) . '_URL'];
|
|
|
|
if ($mode != $modes[$i])
|
|
{
|
|
?></a><?php
|
|
}
|
|
}
|
|
?> </td>
|
|
</tr>
|
|
</table>
|
|
<?php
|
|
|
|
if ($mode == 'manage')
|
|
{
|
|
|
|
$yes_no_switches = array('disable_mod', 'allow_pm_attach', 'allow_ftp_upload', 'display_order', 'ftp_pasv_mode');
|
|
|
|
for ($i = 0; $i < count($yes_no_switches); $i++)
|
|
{
|
|
eval("\$" . $yes_no_switches[$i] . "_yes = ( \$new['" . $yes_no_switches[$i] . "']) ? 'checked=\"checked\"' : '';");
|
|
eval("\$" . $yes_no_switches[$i] . "_no = ( !\$new['" . $yes_no_switches[$i] . "']) ? 'checked=\"checked\"' : '';");
|
|
}
|
|
|
|
?>
|
|
<table class="bg" cellspacing="1" cellpadding="4" border="0" align="center">
|
|
<tr>
|
|
<th align="center" colspan="2"><?php echo $user->lang['ATTACHMENT_SETTINGS']; ?></th>
|
|
</tr>
|
|
<tr>
|
|
<td class="row1" width="50%"><?php echo $user->lang['UPLOAD_DIR']; ?>:<br /><span class="gensmall"><?php echo $user->lang['UPLOAD_DIR_EXPLAIN']; ?></span></td>
|
|
<td class="row2"><input type="text" size="25" maxlength="100" name="upload_dir" class="post" value="<?php echo $new['upload_dir'] ?>" /></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="row1" width="50%"><?php echo $user->lang['DISPLAY_ORDER']; ?>:<br /><span class="gensmall"><?php echo $user->lang['DISPLAY_ORDER_EXPLAIN']; ?></span></td>
|
|
<td class="row2">
|
|
<table border=0 cellpadding=0 cellspacing=0>
|
|
<tr>
|
|
<td><input type="radio" name="display_order" value="0" <?php echo $display_order_no; ?> /> <?php echo $user->lang['DESCENDING']; ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td><input type="radio" name="display_order" value="1" <?php echo $display_order_yes; ?> /> <?php echo $user->lang['ASCENDING']; ?></td>
|
|
</tr>
|
|
</table></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="spacer" colspan="2" height="1"><img src="../images/spacer.gif" alt="" width="1" height="1" /></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="row1" width="50%"><?php echo $user->lang['ATTACH_MAX_FILESIZE']; ?>:<br /><span class="gensmall"><?php echo $user->lang['ATTACH_MAX_FILESIZE_EXPLAIN']; ?></span></td>
|
|
<td class="row2"><input type="text" size="8" maxlength="15" name="max_filesize" class="post" value="<?php echo $new['max_filesize']; ?>" /> <?php echo $select_size_mode; ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="row1" width="50%"><?php echo $user->lang['ATTACH_QUOTA']; ?>:<br /><span class="gensmall"><?php echo $user->lang['ATTACH_QUOTA_EXPLAIN']; ?></span></td>
|
|
<td class="row2"><input type="text" size="8" maxlength="15" name="attachment_quota" class="post" value="<?php echo $new['attachment_quota']; ?>" /> <?php echo $select_quota_size_mode; ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="row1" width="50%"><?php echo $user->lang['ATTACH_MAX_PM_FILESIZE']; ?>:<br /><span class="gensmall"><?php echo $user->lang['ATTACH_MAX_PM_FILESIZE_EXPLAIN']; ?></span></td>
|
|
<td class="row2"><input type="text" size="8" maxlength="15" name="max_filesize_pm" class="post" value="<?php echo $new['max_filesize_pm']; ?>" /> <?php echo $select_pm_size_mode; ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="spacer" colspan="2" height="1"><img src="../images/spacer.gif" alt="" width="1" height="1" /></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="row1" width="50%"><?php echo $user->lang['MAX_ATTACHMENTS'] ?>:<br /><span class="gensmall"><?php echo $user->lang['MAX_ATTACHMENTS_EXPLAIN']; ?></span></td>
|
|
<td class="row2"><input type="text" size="3" maxlength="3" name="max_attachments" class="post" value="<?php echo $new['max_attachments']; ?>" /></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="row1" width="50%"><?php echo $user->lang['MAX_ATTACHMENTS_PM'] ?>:<br /><span class="gensmall"><?php echo $user->lang['MAX_ATTACHMENTS_PM_EXPLAIN']; ?></span></td>
|
|
<td class="row2"><input type="text" size="3" maxlength="3" name="max_attachments_pm" class="post" value="<?php echo $new['max_attachments_pm']; ?>" /></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="spacer" colspan="2" height="1"><img src="../images/spacer.gif" alt="" width="1" height="1" /></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="row1" width="50%"><?php echo $user->lang['PM_ATTACH']; ?>:<br /><span class="gensmall"><?php echo $user->lang['PM_ATTACH_EXPLAIN']; ?></span></td>
|
|
<td class="row2"><input type="radio" name="allow_pm_attach" value="1" <?php echo $allow_pm_attach_yes; ?> /> <?php echo $user->lang['YES']; ?> <input type="radio" name="allow_pm_attach" value="0" <?php echo $allow_pm_attach_no; ?> /> <?php echo $user->lang['NO']; ?></td>
|
|
</tr>
|
|
<?php
|
|
if (!function_exists('ftp_connect'))
|
|
{
|
|
?>
|
|
|
|
<input type="hidden" name="allow_ftp_upload" value="0" />
|
|
<tr>
|
|
<td class="spacer" colspan="2" height="1"><img src="../images/spacer.gif" alt="" width="1" height="1" /></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="row1" colspan="2" align="center"><span class="gen"><?php echo $user->lang['NO_FTP_EXTENSIONS_INSTALLED']; ?></span></td>
|
|
</tr>
|
|
|
|
<?php
|
|
}
|
|
else
|
|
{
|
|
?>
|
|
|
|
<tr>
|
|
<td class="row1" width="50%"><?php echo $user->lang['FTP_UPLOAD']; ?>:<br /><span class="gensmall"><?php echo $user->lang['FTP_UPLOAD_EXPLAIN']; ?></span></td>
|
|
<td class="row2"><input type="radio" name="allow_ftp_upload" value="1" <?php echo $allow_ftp_upload_yes; ?> /> <?php echo $user->lang['YES']; ?> <input type="radio" name="allow_ftp_upload" value="0" <?php echo $allow_ftp_upload_no; ?> /> <?php echo $user->lang['NO']; ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="spacer" colspan="2" height="1"><img src="../images/spacer.gif" alt="" width="1" height="1" /></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="row1" width="50%"><?php echo $user->lang['FTP_SERVER']; ?>:<br /><span class="gensmall"><?php echo $user->lang['FTP_SERVER_EXPLAIN']; ?></span></td>
|
|
<td class="row2"><input type="text" size="20" maxlength="100" name="ftp_server" class="post" value="<?php echo $new['ftp_server']; ?>" /></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="row1" width="50%"><?php echo $user->lang['ATTACH_FTP_PATH']; ?>:<br /><span class="gensmall"><?php echo $user->lang['ATTACH_FTP_PATH_EXPLAIN']; ?></span></td>
|
|
<td class="row2"><input type="text" size="20" maxlength="100" name="ftp_path" class="post" value="<?php echo $new['ftp_path']; ?>" /></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="row1" width="50%"><?php echo $user->lang['FTP_DOWNLOAD_PATH']; ?>:<br /><span class="gensmall"><?php echo $user->lang['FTP_DOWNLOAD_PATH_EXPLAIN']; ?></span></td>
|
|
<td class="row2"><input type="text" size="20" maxlength="100" name="download_path" class="post" value="<?php echo $new['download_path']; ?>" /></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="row1" width="50%"><?php echo $user->lang['FTP_PASSIVE_MODE']; ?>:<br /><span class="gensmall"><?php echo $user->lang['FTP_PASSIVE_MODE_EXPLAIN']; ?></span></td>
|
|
<td class="row2"><input type="radio" name="ftp_pasv_mode" value="1" <?php echo $ftp_pasv_mode_yes; ?> /> <?php echo $user->lang['YES']; ?> <input type="radio" name="ftp_pasv_mode" value="0" <?php echo $ftp_pasv_mode_no; ?> /> <?php echo $user->lang['NO']; ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="row1" width="50%"><?php echo $user->lang['FTP_USER']; ?>:</td>
|
|
<td class="row2"><input type="text" size="20" maxlength="100" name="ftp_user" class="post" value="<?php echo $new['ftp_user']; ?>" /></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="row1" width="50%"><?php echo $user->lang['FTP_PASS']; ?>:</td>
|
|
<td class="row2"><input type="password" size="10" maxlength="20" name="ftp_pass" class="post" value="<?php echo $new['ftp_path']; ?>" /></td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
?>
|
|
<tr>
|
|
<td class="cat" colspan="2" align="center"><input type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" class="mainoption" /> <input type="reset" value="<?php echo $user->lang['RESET']; ?>" class="liteoption" /></td>
|
|
</tr>
|
|
</table>
|
|
<?php
|
|
}
|
|
|
|
if ($mode == 'cats')
|
|
{
|
|
$sql = "SELECT group_name, cat_id
|
|
FROM " . EXTENSION_GROUPS_TABLE . "
|
|
WHERE cat_id > 0
|
|
ORDER BY cat_id";
|
|
$result = $db->sql_query($sql);
|
|
|
|
$s_assigned_groups = array();
|
|
|
|
while ($row = $db->sql_fetchrow($result))
|
|
{
|
|
$s_assigned_groups[$row['cat_id']][] = $row['group_name'];
|
|
}
|
|
|
|
$display_inlined_yes = ($new['img_display_inlined']) ? 'checked="checked"' : '';
|
|
$display_inlined_no = (!$new['img_display_inlined']) ? 'checked="checked"' : '';
|
|
|
|
$create_thumbnail_yes = ($new['img_create_thumbnail']) ? 'checked="checked"' : '';
|
|
$create_thumbnail_no = (!$new['img_create_thumbnail']) ? 'checked="checked"' : '';
|
|
|
|
?>
|
|
<table class="bg" cellspacing="1" cellpadding="4" border="0" align="center">
|
|
<tr>
|
|
<th align="center" colspan="2"><?php echo $user->lang['SETTINGS_CAT_IMAGES']; ?></th>
|
|
</tr>
|
|
<tr>
|
|
<td class="spacer" colspan="2" height="1"><img src="../images/spacer.gif" alt="" width="1" height="1" /></td>
|
|
</tr>
|
|
<tr>
|
|
<th align="center" colspan="2"><?php echo $user->lang['ASSIGNED_GROUP']; ?>: <?php echo ( (count($s_assigned_groups[IMAGE_CAT])) ? implode(', ', $s_assigned_groups[IMAGE_CAT]) : $user->lang['NONE']); ?></th>
|
|
</tr>
|
|
<tr>
|
|
<td class="row1" width="50%"><?php echo $user->lang['DISPLAY_INLINED']; ?>:<br /><span class="gensmall"><?php echo $user->lang['DISPLAY_INLINED_EXPLAIN']; ?></span></td>
|
|
<td class="row2"><input type="radio" name="img_display_inlined" value="1" <?php echo $display_inlined_yes ?> /> <?php echo $user->lang['YES']; ?> <input type="radio" name="img_display_inlined" value="0" <?php echo $display_inlined_no ?> /> <?php echo $user->lang['NO']; ?></td>
|
|
</tr>
|
|
<?php
|
|
|
|
// Check Thumbnail Support
|
|
if ( ($new['img_imagick'] == '') && (count(get_supported_image_types()) == 0) )
|
|
{
|
|
$new['img_create_thumbnail'] = '0';
|
|
}
|
|
else
|
|
{
|
|
?>
|
|
<tr>
|
|
<td class="row1" width="50%"><?php echo $user->lang['CREATE_THUMBNAIL']; ?>:<br /><span class="gensmall"><?php echo $user->lang['CREATE_THUMBNAIL_EXPLAIN']; ?></span></td>
|
|
<td class="row2"><input type="radio" name="img_create_thumbnail" value="1" <?php echo $create_thumbnail_yes; ?> /> <?php echo $user->lang['YES']; ?> <input type="radio" name="img_create_thumbnail" value="0" <?php echo $create_thumbnail_no; ?> /> <?php echo $user->lang['NO']; ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="row1" width="50%"><?php echo $user->lang['MIN_THUMB_FILESIZE']; ?>:<br /><span class="gensmall"><?php echo $user->lang['MIN_THUMB_FILESIZE_EXPLAIN']; ?></span></td>
|
|
<td class="row2"><input type="text" size="7" maxlength="15" name="img_min_thumb_filesize" value="<?php echo $new['img_min_thumb_filesize']; ?>" class="post" /> <?php echo $user->lang['BYTES']; ?></td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
?>
|
|
<tr>
|
|
<td class="row1" width="50%"><?php echo $user->lang['IMAGICK_PATH']; ?>:<br /><span class="gensmall"><?php echo $user->lang['IMAGICK_PATH_EXPLAIN']; ?></span></td>
|
|
<td class="row2"><input type="text" size="20" maxlength="200" name="img_imagick" value="<?php echo $new['img_imagick']; ?>" class="post" /></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="row1" width="50%"><?php echo $user->lang['MAX_IMAGE_SIZE']; ?>:<br /><span class="gensmall"><?php echo $user->lang['MAX_IMAGE_SIZE_EXPLAIN']; ?></span></td>
|
|
<td class="row2"><input type="text" size="3" maxlength="4" name="img_max_width" value="<?php echo $new['img_max_width']; ?>" class="post" /> x <input type="text" size="3" maxlength="4" name="img_max_height" value="<?php echo $new['img_max_height']; ?>" class="post" /></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="row1" width="50%"><?php echo $user->lang['IMAGE_LINK_SIZE']; ?>:<br /><span class="gensmall"><?php echo $user->lang['IMAGE_LINK_SIZE_EXPLAIN']; ?></span></td>
|
|
<td class="row2"><input type="text" size="3" maxlength="4" name="img_link_width" value="<?php echo $new['img_link_width']; ?>" class="post" /> x <input type="text" size="3" maxlength="4" name="img_link_height" value="<?php echo $new['img_link_height']; ?>" class="post" /></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="cat" colspan="2" align="center"><input type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" class="mainoption" /> <input type="submit" name="search_imagick" value="<?php echo $user->lang['SEARCH_IMAGICK']; ?>" class="liteoption" /> <input type="reset" value="<?php echo $user->lang['RESET']; ?>" class="liteoption" /></td>
|
|
</tr>
|
|
</table>
|
|
|
|
<?php
|
|
}
|
|
|
|
if ($mode == 'ext_groups')
|
|
{
|
|
// $img_path = $config['upload_icons_path'];
|
|
$img_path = 'images/upload_icons';
|
|
|
|
$imglist = filelist($phpbb_root_path . $img_path, '');
|
|
|
|
$filename_list = '';
|
|
foreach ($imglist as $img)
|
|
{
|
|
$img = substr($img['path'], 1) . (($img['path'] != '') ? '/' : '') . $img['file'];
|
|
$filename_list .= '<option value="' . htmlspecialchars($img) . '">' . $img . '</option>';
|
|
}
|
|
|
|
$size = isset($_REQUEST['size']) ? intval($_REQUEST['size']) : 0;
|
|
|
|
if (!$size && !$submit)
|
|
{
|
|
$max_add_filesize = intval($config['max_filesize']);
|
|
$size = ($max_add_filesize >= 1048576) ? 'mb' : ( ($max_add_filesize >= 1024) ? 'kb' : 'b' );
|
|
}
|
|
|
|
if ($max_add_filesize >= 1048576)
|
|
{
|
|
$max_add_filesize = round($max_add_filesize / 1048576 * 100) / 100;
|
|
}
|
|
else if ( $max_add_filesize >= 1024)
|
|
{
|
|
$max_add_filesize = round($max_add_filesize / 1024 * 100) / 100;
|
|
}
|
|
|
|
$viewgroup = (!empty($_REQUEST['g'])) ? $_REQUEST['g'] : -1;
|
|
?>
|
|
|
|
<script language="javascript" type="text/javascript" defer="defer">
|
|
<!--
|
|
|
|
function update_add_image(newimage)
|
|
{
|
|
if (newimage == 'no_image')
|
|
{
|
|
document.add_image.src = '<?php echo $phpbb_root_path ?>images/spacer.gif';
|
|
}
|
|
else
|
|
{
|
|
document.add_image.src = "<?php echo $phpbb_root_path . $img_path ?>/" + newimage;
|
|
}
|
|
}
|
|
|
|
function update_image(newimage, index)
|
|
{
|
|
if (newimage == 'no_image')
|
|
{
|
|
eval('document.image_' + index + '.src = "<?php echo $phpbb_root_path ?>images/spacer.gif";');
|
|
}
|
|
else
|
|
{
|
|
eval('document.image_' + index + '.src = "<?php echo $phpbb_root_path . $img_path ?>/" + newimage;');
|
|
}
|
|
}
|
|
|
|
//-->
|
|
</script>
|
|
|
|
<table class="bg" cellspacing="1" cellpadding="4" border="0" align="center" width="100%">
|
|
<tr>
|
|
<th align="center" colspan="7"><?php echo $user->lang['EXTENSION_GROUPS_TITLE']; ?></th>
|
|
</tr>
|
|
<tr>
|
|
<td class="spacer" colspan="2" height="1"><img src="../images/spacer.gif" alt="" width="1" height="1" /></td>
|
|
</tr>
|
|
<tr>
|
|
<th> <?php echo $user->lang['EXTENSION_GROUP']; ?> </th>
|
|
<th> <?php echo $user->lang['SPECIAL_CATEGORY']; ?> </th>
|
|
<th> <?php echo $user->lang['ALLOWED']; ?> </th>
|
|
<th> <?php echo $user->lang['DOWNLOAD_MODE']; ?> </th>
|
|
<th> <?php echo $user->lang['UPLOAD_ICON']; ?> </th>
|
|
<th> <?php echo $user->lang['MAX_EXTGROUP_FILESIZE']; ?> </th>
|
|
<th> <?php echo $user->lang['ADD']; ?> </th>
|
|
</tr>
|
|
<tr>
|
|
<td class="row1" align="center" valign="middle">
|
|
<table width="100%" align="center" cellpadding="0" cellspacing="0" border="0">
|
|
<tr>
|
|
<td class="row1" align="center" valign="middle" width="10%" wrap="nowrap"> </td>
|
|
<td class="row1" align="left" valign="middle"><input type="text" size="20" maxlength="100" name="add_extension_group" class="post" value="<?php echo ((isset($submit)) ? $extension_group : '') ?>" /></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="row1" align="center" valign="middle"><?php echo category_select('add_category'); ?></td>
|
|
<td class="row1" align="center" valign="middle"><input type="checkbox" name="add_allowed" /></td>
|
|
<td class="row1" align="center" valign="middle"><?php echo download_select('add_download_mode'); ?></td>
|
|
<td class="row1" align="center" valign="middle"><select name="add_upload_icon" onChange="update_add_image(this.options[selectedIndex].value);"><option value="no_image" selected="selected"><?php echo $user->lang['NO_IMAGE']; ?></option><?php echo $filename_list ?></select> <img src="<?php echo $phpbb_root_path . 'images/spacer.gif' ?>" name="add_image" border="0" alt="" title="" /> </td>
|
|
<td class="row1" align="center" valign="middle"><input type="text" size="3" maxlength="15" name="add_max_filesize" class="post" value="<?php echo $max_add_filesize; ?>" /> <?php echo size_select('add_size_select', $size); ?></td>
|
|
<td class="row1" align="center" valign="middle"><input type="checkbox" name="add_extension_group_check" /></td>
|
|
</tr>
|
|
<tr align="right">
|
|
<td class="cat" colspan="7"><input type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" class="mainoption" /></td>
|
|
</tr>
|
|
<tr>
|
|
<th> <?php echo $user->lang['EXTENSION_GROUP']; ?> </th>
|
|
<th> <?php echo $user->lang['SPECIAL_CATEGORY']; ?> </th>
|
|
<th> <?php echo $user->lang['ALLOWED']; ?> </th>
|
|
<th> <?php echo $user->lang['DOWNLOAD_MODE']; ?> </th>
|
|
<th> <?php echo $user->lang['UPLOAD_ICON']; ?> </th>
|
|
<th> <?php echo $user->lang['MAX_EXTGROUP_FILESIZE']; ?> </th>
|
|
<th> <?php echo $user->lang['DELETE']; ?> </th>
|
|
</tr>
|
|
<?
|
|
|
|
$sql = "SELECT *
|
|
FROM " . EXTENSION_GROUPS_TABLE;
|
|
$result = $db->sql_query($sql);
|
|
|
|
while ($row = $db->sql_fetchrow($result))
|
|
{
|
|
// Format the filesize
|
|
if ($row['max_filesize'] == 0)
|
|
{
|
|
$row['max_filesize'] = intval($config['max_filesize']);
|
|
}
|
|
|
|
$size_format = ($row['max_filesize'] >= 1048576) ? 'mb' : ( ($row['max_filesize'] >= 1024) ? 'kb' : 'b' );
|
|
|
|
if ($row['max_filesize'] >= 1048576)
|
|
{
|
|
$row['max_filesize'] = round($row['max_filesize'] / 1048576 * 100) / 100;
|
|
}
|
|
else if($row['max_filesize'] >= 1024)
|
|
{
|
|
$row['max_filesize'] = round($row['max_filesize'] / 1024 * 100) / 100;
|
|
}
|
|
|
|
$s_allowed = ($row['allow_group'] == 1) ? 'checked="checked"' : '';
|
|
$edit_img = ($row['upload_icon'] != '') ? $row['upload_icon'] : '';
|
|
|
|
$filename_list = '';
|
|
$no_image_select = false;
|
|
foreach ($imglist as $img)
|
|
{
|
|
$img = substr($img['path'], 1) . (($img['path'] != '') ? '/' : '') . $img['file'];
|
|
|
|
if ($edit_img == '')
|
|
{
|
|
$no_image_select = true;
|
|
$selected = '';
|
|
}
|
|
else
|
|
{
|
|
$selected = ($edit_img == $img) ? ' selected="selected"' : '';
|
|
}
|
|
|
|
$filename_list .= '<option value="' . htmlspecialchars($img) . '"' . $selected . '>' . $img . '</option>';
|
|
}
|
|
?>
|
|
<tr>
|
|
<input type="hidden" name="group_change_list[]" value="<?php echo $row['group_id']; ?>" />
|
|
<td class="row1" align="center" valign="middle">
|
|
<table width="100%" align="center" cellpadding="0" cellspacing="0" border="0">
|
|
<tr>
|
|
<td class="row1" align="center" valign="middle" width="10%" wrap="nowrap"><b><a href="<?php echo (($viewgroup == $row['group_id']) ? "admin_attachments.$phpEx$SID&mode=ext_groups" : "admin_attachments.$phpEx$SID&mode=ext_groups&g=" . $row['group_id']); ?>" class="gen"><?php echo (($viewgroup == $row['group_id']) ? '-' : '+'); ?></a></span></b></td>
|
|
<td class="row1" align="left" valign="middle"><input type="text" size="20" maxlength="100" name="extension_group_list[]" class="post" value="<?php echo $row['group_name']; ?>" /></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="row2" align="center" valign="middle"><?php echo category_select('category_list[]', $row['group_id']); ?></td>
|
|
<td class="row1" align="center" valign="middle"><input type="checkbox" name="allowed_list[]" value="<?php echo $row['group_id']; ?>" <?php echo $s_allowed; ?> /></td>
|
|
<td class="row2" align="center" valign="middle"><?php echo download_select('download_mode_list[]', $row['group_id']); ?></td>
|
|
<td class="row1" align="center" valign="middle"><select name="upload_icon_list[]" onChange="update_image(this.options[selectedIndex].value, <?php echo $row['group_id']; ?>);"><option value="no_image"<?php echo (($no_image_select) ? ' selected="selected"' : ''); ?>><?php echo $user->lang['NO_IMAGE']; ?></option><?php echo $filename_list ?></select> <img src="<?php echo (($no_image_select) ? $phpbb_root_path . 'images/spacer.gif' : $phpbb_root_path . $img_path . '/' . $edit_img) ?>" name="image_<?php echo $row['group_id']; ?>" border="0" alt="" title="" /> </td>
|
|
<td class="row2" align="center" valign="middle"><input type="text" size="3" maxlength="15" name="max_filesize_list[]" class="post" value="<?php echo $row['max_filesize']; ?>" /> <?php echo size_select('size_select_list[]', $size_format); ?></td>
|
|
<td class="row2" align="center" valign="middle"><input type="checkbox" name="group_id_list[]" value="<?php echo $row['group_id']; ?>" /></td>
|
|
</tr>
|
|
<?
|
|
|
|
if ($viewgroup != -1 && $viewgroup == $row['group_id'])
|
|
{
|
|
$sql = "SELECT comment, extension
|
|
FROM " . EXTENSIONS_TABLE . "
|
|
WHERE group_id = " . intval($viewgroup);
|
|
$e_result = $db->sql_query($sql);
|
|
|
|
while ($e_row = $db->sql_fetchrow($e_result))
|
|
{
|
|
?>
|
|
<tr>
|
|
<td class="row2" align="center" valign="middle"><span class="postdetails"><?php echo $e_row['extension']; ?></span></td>
|
|
<td class="row2" align="center" valign="middle" colspan="6"><span class="postdetails"><?php echo $e_row['comment']; ?></span></td>
|
|
</tr>
|
|
<?
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
<tr>
|
|
<td class="cat" colspan="7" align="center"><input type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" class="mainoption" /> <input type="reset" value="<?php echo $user->lang['RESET']; ?>" class="liteoption" /></td>
|
|
</tr>
|
|
</table>
|
|
<?
|
|
|
|
}
|
|
?>
|
|
|
|
</form>
|
|
|
|
<br clear="all" />
|
|
|
|
<?php
|
|
|
|
adm_page_footer();
|
|
|
|
// Test Settings
|
|
function test_upload(&$error, &$error_msg, $upload_dir, $ftp_path, $ftp_upload_allowed, $create_directory = false)
|
|
{
|
|
global $user;
|
|
|
|
$error = FALSE;
|
|
|
|
// Does the target directory exist, is it a directory and writeable. (only test if ftp upload is disabled)
|
|
if (!$ftp_upload_allowed)
|
|
{
|
|
if ($create_directory)
|
|
{
|
|
if (!@file_exists($upload_dir))
|
|
{
|
|
@mkdir($upload_dir, 0755);
|
|
@chmod($upload_dir, 0777);
|
|
}
|
|
}
|
|
|
|
if (!@file_exists($upload_dir))
|
|
{
|
|
$error = TRUE;
|
|
$error_msg = sprintf($user->lang['DIRECTORY_DOES_NOT_EXIST'], $new['upload_dir']) . '<br />';
|
|
}
|
|
|
|
if (!$error && !is_dir($upload_dir))
|
|
{
|
|
$error = TRUE;
|
|
$error_msg = sprintf($user->lang['DIRECTORY_IS_NOT_A_DIR'], $new['upload_dir']) . '<br />';
|
|
}
|
|
|
|
if (!$error)
|
|
{
|
|
if ( !($fp = @fopen($upload_dir . '/0_000000.000', 'w')) )
|
|
{
|
|
$error = TRUE;
|
|
$error_msg = sprintf($user->lang['DIRECTORY_NOT_WRITEABLE'], $new['upload_dir']) . '<br />';
|
|
}
|
|
else
|
|
{
|
|
@fclose($fp);
|
|
@unlink($upload_dir . '/0_000000.000');
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Check FTP Settings
|
|
$server = ( empty($new['ftp_server']) ) ? 'localhost' : $new['ftp_server'];
|
|
$conn_id = @ftp_connect($server);
|
|
|
|
if (!$conn_id)
|
|
{
|
|
$error = TRUE;
|
|
$error_msg = sprintf($user->lang['FTP_ERROR_CONNECT'], $server) . '<br />';
|
|
}
|
|
|
|
$login_result = @ftp_login($conn_id, $new['ftp_user'], $new['ftp_pass']);
|
|
|
|
if (!$login_result && !$error)
|
|
{
|
|
$error = TRUE;
|
|
$error_msg = sprintf($user->lang['FTP_ERROR_LOGIN'], $new['ftp_user']) . '<br />';
|
|
}
|
|
|
|
if (!@ftp_pasv($conn_id, intval($new['ftp_pasv_mode'])))
|
|
{
|
|
$error = TRUE;
|
|
$error_msg = $user->lang['FTP_ERROR_PASV_MODE'];
|
|
}
|
|
|
|
if (!$error)
|
|
{
|
|
// Check Upload
|
|
$tmpfname = @tempnam('/tmp', 't0000');
|
|
@unlink($tmpfname); // unlink for safety on php4.0.3+
|
|
$fp = @fopen($tmpfname, 'w');
|
|
@fwrite($fp, 'test');
|
|
@fclose($fp);
|
|
|
|
if ($create_directory)
|
|
{
|
|
$result = @ftp_chdir($conn_id, $ftp_path);
|
|
|
|
if (!$result)
|
|
{
|
|
@ftp_mkdir($conn_id, $ftp_path);
|
|
}
|
|
}
|
|
|
|
$result = @ftp_chdir($conn_id, $ftp_path);
|
|
|
|
if (!$result)
|
|
{
|
|
$error = TRUE;
|
|
$error_msg = sprintf($user->lang['FTP_ERROR_PATH'], $ftp_path) . '<br />';
|
|
}
|
|
else
|
|
{
|
|
$res = @ftp_put($conn_id, 't0000', $tmpfname, FTP_ASCII);
|
|
|
|
if (!$res)
|
|
{
|
|
$error = TRUE;
|
|
$error_msg = sprintf($user->lang['FTP_ERROR_UPLOAD'], $ftp_path) . '<br />';
|
|
}
|
|
else
|
|
{
|
|
$res = @ftp_delete($conn_id, 't0000');
|
|
|
|
if (!$res)
|
|
{
|
|
$error = TRUE;
|
|
$error_msg = sprintf($user->lang['FTP_ERROR_DELETE'], $ftp_path) . '<br />';
|
|
}
|
|
}
|
|
}
|
|
|
|
@ftp_quit($conn_id);
|
|
@unlink($tmpfname);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Generate select form
|
|
function size_select($select_name, $size_compare)
|
|
{
|
|
global $user;
|
|
|
|
$size_types_text = array($user->lang['BYTES'], $user->lang['KB'], $user->lang['MB']);
|
|
$size_types = array('b', 'kb', 'mb');
|
|
|
|
$select_field = '<select name="' . $select_name . '">';
|
|
|
|
for ($i = 0; $i < count($size_types_text); $i++)
|
|
{
|
|
$selected = ($size_compare == $size_types[$i]) ? ' selected="selected"' : '';
|
|
|
|
$select_field .= '<option value="' . $size_types[$i] . '"' . $selected . '>' . $size_types_text[$i] . '</option>';
|
|
}
|
|
|
|
$select_field .= '</select>';
|
|
|
|
return ($select_field);
|
|
}
|
|
|
|
// Build Select for category items
|
|
function category_select($select_name, $group_id = -1)
|
|
{
|
|
global $db, $user;
|
|
|
|
$types = array(
|
|
NONE_CAT => $user->lang['NONE'],
|
|
IMAGE_CAT => $user->lang['CAT_IMAGES'],
|
|
WM_CAT => $user->lang['CAT_WM_FILES'],
|
|
RM_CAT => $user->lang['CAT_RM_FILES']
|
|
);
|
|
|
|
if ($group_id != -1)
|
|
{
|
|
$sql = "SELECT cat_id
|
|
FROM " . EXTENSION_GROUPS_TABLE . "
|
|
WHERE group_id = " . intval($group_id);
|
|
$result = $db->sql_query($sql);
|
|
|
|
if (!($row = $db->sql_fetchrow($result)))
|
|
{
|
|
$cat_type = NONE_CAT;
|
|
}
|
|
else
|
|
{
|
|
$cat_type = $row['cat_id'];
|
|
}
|
|
|
|
$db->sql_freeresult($result);
|
|
}
|
|
else
|
|
{
|
|
$cat_type = NONE_CAT;
|
|
}
|
|
|
|
$group_select = '<select name="' . $select_name . '">';
|
|
|
|
foreach ($types as $type => $mode)
|
|
{
|
|
$selected = ($type == $cat_type) ? ' selected="selected"' : '';
|
|
$group_select .= '<option value="' . $type . '"' . $selected . '>' . $mode . '</option>';
|
|
}
|
|
|
|
$group_select .= '</select>';
|
|
|
|
return($group_select);
|
|
}
|
|
|
|
// Build select for download modes
|
|
|
|
function download_select($select_name, $group_id = -1)
|
|
{
|
|
global $db, $user;
|
|
|
|
$types = array(
|
|
INLINE_LINK => $user->lang['MODE_INLINE'],
|
|
PHYSICAL_LINK => $user->lang['MODE_PHYSICAL']
|
|
);
|
|
|
|
if ($group_id != -1)
|
|
{
|
|
$sql = "SELECT download_mode
|
|
FROM " . EXTENSION_GROUPS_TABLE . "
|
|
WHERE group_id = " . intval($group_id);
|
|
$result = $db->sql_query($sql);
|
|
|
|
if (!($row = $db->sql_fetchrow($result)))
|
|
{
|
|
$download_mode = INLINE_LINK;
|
|
}
|
|
else
|
|
{
|
|
$download_mode = $row['download_mode'];
|
|
}
|
|
|
|
$db->sql_freeresult($result);
|
|
}
|
|
else
|
|
{
|
|
$download_mode = INLINE_LINK;
|
|
}
|
|
|
|
$group_select = '<select name="' . $select_name . '">';
|
|
|
|
foreach ($types as $type => $mode)
|
|
{
|
|
$selected = ($type == $download_mode) ? ' selected="selected"' : '';
|
|
$group_select .= '<option value="' . $type . '"' . $selected . '>' . $mode . '</option>';
|
|
}
|
|
|
|
$group_select .= '</select>';
|
|
|
|
return($group_select);
|
|
}
|
|
|
|
// Get supported Image types
|
|
function get_supported_image_types()
|
|
{
|
|
$types = array();
|
|
|
|
if (@extension_loaded('gd'))
|
|
{
|
|
if (@function_exists('imagegif'))
|
|
{
|
|
$types[] = '1';
|
|
}
|
|
if (@function_exists('imagejpeg'))
|
|
{
|
|
$types[] = '2';
|
|
}
|
|
if (@function_exists('imagepng'))
|
|
{
|
|
$types[] = '3';
|
|
}
|
|
}
|
|
|
|
return ($types);
|
|
}
|
|
|
|
function filelist($rootdir, $dir = '', $type = 'gif|jpg|png')
|
|
{
|
|
static $images = array();
|
|
|
|
$dh = opendir($rootdir . $dir);
|
|
|
|
while ($fname = readdir($dh))
|
|
{
|
|
if (is_file($rootdir . $dir . '/' . $fname) &&
|
|
preg_match('#\.' . $type . '$#i', $fname) &&
|
|
filesize($rootdir . $dir . '/' . $fname))
|
|
{
|
|
$images[] = array('path' => $dir, 'file' => $fname);
|
|
}
|
|
else if ($fname != '.' && $fname != '..' &&
|
|
!is_file($rootdir . $dir . '/' . $fname) &&
|
|
!is_link($rootdir . $dir . '/' . $fname))
|
|
{
|
|
filelist($rootdir, $dir . '/'. $fname, $type);
|
|
}
|
|
}
|
|
|
|
closedir($dh);
|
|
|
|
return $images;
|
|
}
|
|
|
|
?>
|