mirror of
https://github.com/e107inc/e107.git
synced 2025-08-11 17:14:42 +02:00
Started to integrate upload options
This commit is contained in:
@@ -10,14 +10,16 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/download/handlers/adminDownload_class.php,v $
|
||||
| $Revision: 1.23 $
|
||||
| $Date: 2009-11-09 16:54:29 $
|
||||
| $Author: secretr $
|
||||
| $Revision: 1.24 $
|
||||
| $Date: 2009-11-12 21:46:13 $
|
||||
| $Author: bugrain $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
if (!e107::isInstalled('download')) { exit(); }
|
||||
|
||||
require_once(e_PLUGIN.'download/handlers/download_class.php');
|
||||
require_once(e_HANDLER.'upload_handler.php');
|
||||
require_once(e_HANDLER.'xml_class.php');
|
||||
|
||||
class adminDownload extends download
|
||||
{
|
||||
@@ -537,7 +539,7 @@ class adminDownload extends download
|
||||
$file_array[] = str_replace(e_UPLOAD,"",$val);
|
||||
}
|
||||
}
|
||||
/* if ($sql->db_Select("rbinary")) //TODO Remove me.
|
||||
/* if ($sql->db_Select("rbinary")) //TODO Remove me.
|
||||
{
|
||||
while ($row = $sql->db_Fetch())
|
||||
{
|
||||
@@ -1445,7 +1447,7 @@ class adminDownload extends download
|
||||
$ns->tablerender(DOWLAN_39, $text);
|
||||
}
|
||||
|
||||
function show_options() {
|
||||
function show_download_options() {
|
||||
global $pref, $ns;
|
||||
|
||||
require_once(e_HANDLER."form_handler.php");
|
||||
@@ -1522,8 +1524,8 @@ class adminDownload extends download
|
||||
<td>
|
||||
<select name='mirror_order' class='tbox'>".
|
||||
($pref['mirror_order'] == "0" ? "<option value='0' selected='selected'>".DOWLAN_161."</option>" : "<option value='0'>".DOWLAN_161."</option>").
|
||||
($pref['mirror_order'] == "1" ? "<option value='1' selected='selected'>".DOWLAN_162."</option>" : "<option value='1'>".DOWLAN_162."</option>").
|
||||
($pref['mirror_order'] == "2" ? "<option value='2' selected='selected'>".DOWLAN_163."</option>" : "<option value='2'>".DOWLAN_163."</option>")."
|
||||
($pref['mirror_order'] == "1" ? "<option value='1' selected='selected'>".DOWLAN_67."</option>" : "<option value='1'>".DOWLAN_67."</option>").
|
||||
($pref['mirror_order'] == "2" ? "<option value='2' selected='selected'>".DOWLAN_163."</option>" : "<option value='2'>".DOWLAN_12."</option>")."
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -1590,10 +1592,270 @@ class adminDownload extends download
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class='buttons-bar center'>
|
||||
<input class='button' type='submit' name='updateoptions' value='".DOWLAN_64."'/>
|
||||
<input class='button' type='submit' name='updatedownlaodoptions' value='".DOWLAN_64."'/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
";
|
||||
$ns->tablerender(LAN_DL_OPTIONS, $text);
|
||||
}
|
||||
|
||||
function show_upload_list() {
|
||||
global $ns, $sql, $gen, $e107, $tp;
|
||||
|
||||
$frm = new e_form(true); //enable inner tabindex counter
|
||||
$imgd = e_BASE.$IMAGES_DIRECTORY;
|
||||
$columnInfo = array(
|
||||
"checkboxes" => array("title" => "", "forced"=> TRUE, "width" => "3%", "thclass" => "center first", "toggle" => "dl_selected"),
|
||||
"upload_id" => array("title"=>DOWLAN_67, "type"=>"", "width"=>"auto", "thclass"=>"", "forced"=>true),
|
||||
"upload_date" => array("title"=>DOWLAN_78, "type"=>"", "width"=>"auto", "thclass"=>""),
|
||||
"upload_uploader" => array("title"=>DOWLAN_79, "type"=>"", "width"=>"auto", "thclass"=>""),
|
||||
"upload_name" => array("title"=>DOWLAN_12, "type"=>"", "width"=>"auto", "thclass"=>""),
|
||||
"upload_file_name" => array("title"=>DOWLAN_59, "type"=>"", "width"=>"auto", "thclass"=>""),
|
||||
"upload_size" => array("title"=>DOWLAN_66, "type"=>"", "width"=>"auto", "thclass"=>"right"),
|
||||
"options" => array("title"=>LAN_OPTIONS,"width"=>"15%", "thclass"=>"center last", "forced"=>true)
|
||||
);
|
||||
//TODO $filterColumns = ($user_pref['admin_download_disp'] ? $user_pref['admin_download_disp'] : array("download_name","download_class"));
|
||||
$filterColumns = array("upload_id","upload_date","upload_uploader","upload_name","upload_file_name","upload_size");
|
||||
$text = "
|
||||
<fieldset id='core-download-upload1'>
|
||||
<div>
|
||||
<table style='".ADMIN_WIDTH."' class='adminlist'>"
|
||||
.$frm->colGroup($columnInfo,$filterColumns)
|
||||
.$frm->thead($columnInfo,$filterColumns,"main.[FIELD].[ASC].[FROM]")."
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class='center' colspan='".(count($filterColumns)+2)."'>";
|
||||
|
||||
if (!$active_uploads = $sql->db_Select("upload", "*", "upload_active=0 ORDER BY upload_id ASC"))
|
||||
{
|
||||
$text .= DOWLAN_19.".</td></tr>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$activeUploads = $sql -> db_getList();
|
||||
|
||||
$text .= DOWLAN_80." ".($active_uploads == 1 ? DOWLAN_81 : DOWLAN_82).$active_uploads." ".($active_uploads == 1 ? DOWLAN_83 : DOWLAN_84);
|
||||
$text .= "</td></tr>";
|
||||
|
||||
foreach($activeUploads as $row)
|
||||
{
|
||||
$post_author_id = substr($row['upload_poster'], 0, strpos($row['upload_poster'], "."));
|
||||
$post_author_name = substr($row['upload_poster'], (strpos($row['upload_poster'], ".")+1));
|
||||
$poster = (!$post_author_id ? "<b>".$post_author_name."</b>" : "<a href='".e_BASE."user.php?id.".$post_author_id."'><b>".$post_author_name."</b></a>");
|
||||
$upload_datestamp = $gen->convert_date($row['upload_datestamp'], "short");
|
||||
$text .= "
|
||||
<tr>
|
||||
<td class='center'>".$frm->checkbox("dl_selected[".$row["upload_id"]."]", $row['upload_id'])."</td>
|
||||
<td class='center'>".$row['upload_id']."</td>
|
||||
<td>".$upload_datestamp."</td>
|
||||
<td>".$poster."</td>
|
||||
<td><a href='".e_SELF."?ulist.".$row['upload_id']."'>".$row['upload_name']."</a></td>
|
||||
<td>".$row['upload_file']."</td>
|
||||
<td class='right'>".$e107->parseMemorySize($row['upload_filesize'])."</td>
|
||||
<td class='center'>
|
||||
<form action='".e_SELF."?dis.{$upload_id}' id='uploadform_{$upload_id}' method='post'>
|
||||
<div>
|
||||
<a href='".e_SELF."?dlm.{$upload_id}'><img src='".e_IMAGE."admin_images/downloads_16.png' alt='".UPLAN_COPYTODLS."' title='".UPLAN_COPYTODLS."' style='border:0'/></a>
|
||||
<a href='".e_SELF."?news.{$upload_id}'><img src='".e_IMAGE."admin_images/news_16.png' alt='".DOWLAN_16."' title='".DOWLAN_16."' style='border:0'/></a>
|
||||
<input type='image' title='".LAN_DELETE."' name='updelete[upload_{$upload_id}]' src='".ADMIN_DELETE_ICON_PATH."' onclick=\"return jsconfirm('".$tp->toJS(DOWLAN_45." [ {$upload_name} ]")."') \"/>
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
</tr>";
|
||||
}
|
||||
}
|
||||
$text .= "</tbody></table></div></fieldset>";
|
||||
|
||||
$ns->tablerender(DOWLAN_22, $text);
|
||||
}
|
||||
|
||||
function show_upload_filetypes() {
|
||||
global $ns;
|
||||
|
||||
//TODO is there an e107:: copy of this
|
||||
if (!is_object($e_userclass))
|
||||
{
|
||||
$e_userclass = new user_class;
|
||||
}
|
||||
|
||||
if(!getperms("0")) exit; //TODO still needed?
|
||||
|
||||
$definition_source = DOWLAN_71;
|
||||
$source_file = '';
|
||||
$edit_upload_list = varset($_POST['upload_do_edit'], false);
|
||||
|
||||
if (isset($_POST['generate_filetypes_xml']))
|
||||
{ // Write back edited data to filetypes_.xml
|
||||
$file_text = "<e107Filetypes>\n";
|
||||
foreach ($_POST['file_class_select'] as $k => $c)
|
||||
{
|
||||
if (!isset($_POST['file_line_delete_'.$c]) && varsettrue($_POST['file_type_list'][$k]))
|
||||
{
|
||||
$file_text .= " <class name='{$c}' type='{$_POST['file_type_list'][$k]}' maxupload='".varsettrue($_POST['file_maxupload'][$k],ini_get('upload_max_filesize'))."'/>\n";
|
||||
}
|
||||
}
|
||||
$file_text .= "</e107Filetypes>";
|
||||
if ((($handle = fopen(e_UPLOAD_TEMP_DIR.e_SAVE_FILETYPES,'wt')) == FALSE)
|
||||
|| (fwrite($handle,$file_text) == FALSE)
|
||||
|| (fclose($handle) == FALSE))
|
||||
{
|
||||
$text = DOWLAN_88.e_UPLOAD_TEMP_DIR.e_SAVE_FILETYPES;
|
||||
}
|
||||
else
|
||||
{
|
||||
$text = DOWLAN_86.e_UPLOAD_TEMP_DIR.e_SAVE_FILETYPES.'<br/>'.DOWLAN_87.e_ADMIN.e_READ_FILETYPES.'<br/>';
|
||||
}
|
||||
$ns->tablerender(DOWLAN_49, $text);
|
||||
}
|
||||
|
||||
$current_perms = array();
|
||||
if (($edit_upload_list && is_readable(e_UPLOAD_TEMP_DIR.e_SAVE_FILETYPES)) || (!$edit_upload_list && is_readable(e_ADMIN.e_READ_FILETYPES)))
|
||||
{
|
||||
require_once(e_HANDLER.'xml_class.php');
|
||||
$xml = new xmlClass;
|
||||
$xml->setOptArrayTags('class');
|
||||
$source_file = $edit_upload_list ? e_UPLOAD_TEMP_DIR.e_SAVE_FILETYPES : e_ADMIN.e_READ_FILETYPES;
|
||||
$temp_vars = $xml->loadXMLfile($source_file, true, false);
|
||||
if ($temp_vars === FALSE)
|
||||
{
|
||||
echo "Error parsing XML file!";
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($temp_vars['class'] as $v1)
|
||||
{
|
||||
$v = $v1['@attributes'];
|
||||
$current_perms[$v['name']] = array('type' => $v['type'],'maxupload' => $v['maxupload']);
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (is_readable(e_ADMIN.'filetypes.php'))
|
||||
{
|
||||
$source_file = 'filetypes.php';
|
||||
$current_perms[e_UC_MEMBER] = array('type' => implode(',',array_keys(get_allowed_filetypes('filetypes.php', ''))),'maxupload' => '2M');
|
||||
if (is_readable(e_ADMIN.'admin_filetypes.php'))
|
||||
{
|
||||
$current_perms[e_UC_ADMIN] = array('type' => implode(',',array_keys(get_allowed_filetypes('admin_filetypes.php', ''))),'maxupload' => '2M');
|
||||
$source_file .= ' + admin_filetypes.php';
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // Set a default
|
||||
$current_perms[e_UC_MEMBER] = array('type' => 'zip,tar,gz,jpg,png','maxupload' => '2M');
|
||||
}
|
||||
|
||||
$frm = new e_form(true); //enable inner tabindex counter
|
||||
$columnInfo = array(
|
||||
"ftypes_userclass" => array("title"=>DOWLAN_73, "type"=>"", "width"=>"auto", "thclass"=>"", "forced"=>true),
|
||||
"ftypes_extension" => array("title"=>DOWLAN_74, "type"=>"", "width"=>"auto", "thclass"=>""),
|
||||
"ftypes_max_size" => array("title"=>DOWLAN_75, "type"=>"", "width"=>"auto", "thclass"=>""),
|
||||
"ftypes_confirm_del" => array("title"=>DOWLAN_76, "type"=>"", "width"=>"auto", "thclass"=>"last"),
|
||||
);
|
||||
$filterColumns = array("ftypes_userclass", "ftypes_extension", "ftypes_max_size", "ftypes_confirm_del");
|
||||
$text = "
|
||||
<form method='post' action='".e_SELF."?filetypes'>
|
||||
<fieldset id='core-download-upload1'>
|
||||
<div>
|
||||
<div>
|
||||
<input type='hidden' name='upload_do_edit' value='1'/><p>".
|
||||
str_replace(array('--SOURCE--', '--DEST--'),array(e_UPLOAD_TEMP_DIR.e_SAVE_FILETYPES,e_ADMIN.e_READ_FILETYPES),DOWLAN_85)
|
||||
."</p><p>".
|
||||
DOWLAN_72.$source_file."
|
||||
</p></div>
|
||||
<table style='".ADMIN_WIDTH."' class='adminlist'>"
|
||||
.$frm->colGroup($columnInfo)
|
||||
.$frm->thead($columnInfo,$filterColumns)."
|
||||
<tbody>
|
||||
";
|
||||
foreach ($current_perms as $uclass => $uinfo)
|
||||
{
|
||||
$text .= "
|
||||
<tr>
|
||||
<td>
|
||||
<select name='file_class_select[]' class='tbox'>
|
||||
".$e_userclass->vetted_tree('file_class_select',array($e_userclass,'select'), $uclass,'member,main,classes,admin')."
|
||||
</select>
|
||||
</td>
|
||||
<td><input type='text' name='file_type_list[]' value='{$uinfo['type']}' class='tbox' size='40'/></td>
|
||||
<td><input type='text' name='file_maxupload[]' value='{$uinfo['maxupload']}' class='tbox' size='10'/></td>
|
||||
<td><input type='checkbox' value='1' name='file_line_delete_{$uclass}'/></td>
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
// Now put up a box to add a new setting
|
||||
$text .= "
|
||||
<tr>
|
||||
<td colspan='".count($columnInfo)."'>".DOWLAN_90."</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><select name='file_class_select[]' class='tbox'>
|
||||
".$e_userclass->vetted_tree('file_class_select',array($e_userclass,'select'), '','member,main,classes,admin,blank')."
|
||||
</select></td>
|
||||
<td><input type='text' name='file_type_list[]' value='' class='tbox' size='40'/></td>
|
||||
<td colspan='2'><input type='text' name='file_maxupload[]' value='".ini_get('upload_max_filesize')."' class='tbox' size='10'/></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class='buttons-bar center'>
|
||||
<input class='button' type='submit' name='generate_filetypes_xml' value='".DOWLAN_77."'/>
|
||||
</div>
|
||||
</form>
|
||||
";
|
||||
|
||||
$ns->tablerender(DOWLAN_23, $text);
|
||||
}
|
||||
function show_upload_options() {
|
||||
global $pref, $ns;
|
||||
|
||||
require_once(e_HANDLER."form_handler.php");
|
||||
$frm = new e_form(true); //enable inner tabindex counter
|
||||
|
||||
$text = "
|
||||
<form method='post' action='".e_SELF."?".e_QUERY."'>
|
||||
<fieldset id='core-download-upload1'>
|
||||
<div>
|
||||
<table style='".ADMIN_WIDTH."' class='adminlist'>
|
||||
<colgroup>
|
||||
<col style='width:30%'/>
|
||||
<col style='width:70%'/>
|
||||
</colgroup>
|
||||
<tr>
|
||||
<td>".DOWLAN_26."</td>
|
||||
<td>"
|
||||
.$frm->radio_switch('upload_enabled', $pref['upload_enabled'])
|
||||
."<div class='field-help'>"
|
||||
.$frm->label(DOWLAN_51, 'upload_enabled', '1')
|
||||
."</div>"
|
||||
."</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>".DOWLAN_35."</td>
|
||||
<td>"
|
||||
.$frm->text('upload_maxfilesize', $pref['upload_maxfilesize'], '4', array('size'=>'10'))
|
||||
."<div class='field-help'>"
|
||||
.$frm->label(str_replace(array("%1", "%2"), array(ini_get('upload_max_filesize'), ini_get('post_max_size')), DOWLAN_58), 'upload_maxfilesize', '1')
|
||||
."</div>"
|
||||
."</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>".DOWLAN_61."</td>
|
||||
<td>"
|
||||
.r_userclass("upload_class", $pref['upload_class'])
|
||||
."<div class='field-help'>"
|
||||
.$frm->label(DOWLAN_60, 'upload_class', '1')
|
||||
."</div>"
|
||||
."</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class='buttons-bar center'>
|
||||
<input class='button' type='submit' name='updateuploadoptions' value='".DOWLAN_64."'/>
|
||||
</div>
|
||||
</form>
|
||||
";
|
||||
$ns->tablerender(LAN_DL_OPTIONS, $text);
|
||||
}
|
||||
|
Reference in New Issue
Block a user