db_Select("upload", "*", "upload_id='".intval($id)."'");
$row = $sql -> db_Fetch();
if (preg_match("#Binary (.*?)/#", $row['upload_file'], $match))
{
$sql -> db_Delete("rbinary", "binary_id='".$tp -> toDB($match[1])."'");
}
else if ($row['upload_file'] && file_exists(e_UPLOAD.$row['upload_file']))
{
unlink(e_UPLOAD.$row['upload_file']);
}
if (preg_match("#Binary (.*?)/#", $row['upload_ss'], $match))
{
$sql -> db_Delete("rbinary", "binary_id='".$tp -> toDB($match[1])."'");
}
else if ($row['upload_ss'] && file_exists(e_FILE."public/".$row['upload_ss']))
{
unlink(e_UPLOAD.$row['upload_ss']);
}
$message = ($sql->db_Delete("upload", "upload_id='".intval($id)."'")) ? UPLLAN_1 : LAN_DELETED_FAILED;
$admin_log->log_event('UPLOAD_01',$row['upload_file'],E_LOG_INFORMATIVE,'');
}
if ($action == "dlm")
{
header("location: ".e_ADMIN."download.php?dlm.".$id);
exit;
}
if ($action == "news")
{
header("location: ".e_ADMIN."newspost.php?create.upload.".$id);
exit;
}
if ($action == "dl")
{
$id = str_replace("%20", " ", $id);
if (preg_match("/Binary\s(.*?)\/.*/", $id, $result))
{
$bid = $result[1];
$result = @mysql_query("SELECT * FROM ".MPREFIX."rbinary WHERE binary_id='$bid' ");
$binary_data = @mysql_result($result, 0, "binary_data");
$binary_filetype = @mysql_result($result, 0, "binary_filetype");
$binary_name = @mysql_result($result, 0, "binary_name");
header("Content-type: ".$binary_filetype);
header("Content-length: ".$download_filesize);
header("Content-Disposition: attachment; filename=".$binary_name);
header("Content-Description: PHP Generated Data");
echo $binary_data;
exit;
}
else
{
header("location:".e_UPLOAD.str_replace("dl.", "", e_QUERY));
exit;
}
}
require_once(e_HANDLER.'upload_handler.php');
require_once("auth.php");
require_once(e_HANDLER.'userclass_class.php');
$gen = new convert;
require_once(e_HANDLER.'form_handler.php');
$rs = new form;
// Need the userclass object for class selectors
if (!is_object($e_userclass)) { $e_userclass = new user_class; }
if (isset($_POST['optionsubmit']))
{
$temp = array();
$temp['upload_storagetype'] = $_POST['upload_storagetype'];
$temp['upload_maxfilesize'] = $_POST['upload_maxfilesize'];
$temp['upload_class'] = $_POST['upload_class'];
$temp['upload_enabled'] = (FILE_UPLOADS ? $_POST['upload_enabled'] : 0);
if ($temp['upload_enabled'] && !$sql->db_Select("links", "*", "link_url='upload.php' "))
{
$sql->db_Insert("links", "0, '".UPLLAN_44."', 'upload.php', '', '', 1,0,0,0,0");
}
if (!$temp['upload_enabled'] && $sql->db_Select("links", "*", "link_url='upload.php' "))
{
$sql->db_Delete("links", "link_url='upload.php' ");
}
if ($admin_log->logArrayDiffs($temp, $pref, 'UPLOAD_02'))
{
save_prefs(); // Only save if changes
$message = UPLLAN_2;
}
else
{
$message = UPLLAN_4;
}
}
if (isset($message))
{
require_once(e_HANDLER.'message_handler.php');
message_handler("ADMIN_MESSAGE", $message);
}
if (!FILE_UPLOADS)
{
message_handler("ADMIN_MESSAGE", UPLLAN_41);
}
switch ($action)
{
case 'filetypes' :
if(!getperms('0')) exit;
$definition_source = UPLLAN_58;
$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 = "\n";
foreach ($_POST['file_class_select'] as $k => $c)
{
if (!isset($_POST['file_line_delete_'.$c]) && varsettrue($_POST['file_type_list'][$k]))
{
// echo "Key: {$k} Class: {$c} Delete: {$_POST['file_line_delete'][$k]} List: {$_POST['file_type_list'][$k]} Size: {$_POST['file_maxupload'][$k]}
";
$file_text .= " \n";
}
}
$file_text .= "\n";
if ((($handle = fopen(e_UPLOAD_TEMP_DIR.e_SAVE_FILETYPES,'wt')) == FALSE)
|| (fwrite($handle,$file_text) == FALSE)
|| (fclose($handle) == FALSE))
{
$text = UPLLAN_61.e_UPLOAD_TEMP_DIR.e_SAVE_FILETYPES;
}
else
{
$text = '';
$text .= '
'.UPLLAN_59.e_UPLOAD_TEMP_DIR.e_SAVE_FILETYPES.'. '.UPLLAN_60.e_ADMIN.e_READ_FILETYPES.'
';
}
$ns->tablerender(UPLLAN_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)))
{
$xml = e107::getXml();
$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
{
// echo "
";
// var_dump($temp_vars);
// echo "
";
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');
}
$text = "";
$ns->tablerender(UPLLAN_49, $text);
break;
case 'options' :
if(!getperms('0')) exit;
$text = "";
$ns->tablerender(LAN_OPTIONS, $text);
break;
case 'view' :
$sql->db_Select('upload', '*', "upload_id='{$id}'");
$row = $sql->db_Fetch();
extract($row);
$post_author_id = substr($upload_poster, 0, strpos($upload_poster, "."));
$post_author_name = substr($upload_poster, (strpos($upload_poster, ".")+1));
$poster = (!$post_author_id ? "".$post_author_name."" : "".$post_author_name."");
$upload_datestamp = $gen->convert_date($upload_datestamp, "long");
$text = "";
$ns->tablerender(UPLLAN_18, $text);
// Intentionally fall through into list mode
case 'list' :
default :
$imgd = e_BASE.$IMAGES_DIRECTORY;
$text = "
".UPLLAN_22." |
".LAN_DATE." |
".UPLLAN_5." |
".UPLLAN_23." |
".UPLLAN_8." |
".UPLLAN_35." |
".UPLLAN_42." |
";
$text .= "\n
";
}
else
{
$activeUploads = $sql -> db_getList();
$text .= UPLLAN_20." ".($active_uploads == 1 ? UPLAN_IS : UPLAN_ARE).$active_uploads." ".($active_uploads == 1 ? UPLLAN_21 : UPLLAN_27)." ...";
$text .= "";
foreach($activeUploads as $row)
{
extract($row);
$post_author_id = substr($upload_poster, 0, strpos($upload_poster, "."));
$post_author_name = substr($upload_poster, (strpos($upload_poster, ".")+1));
$poster = (!$post_author_id ? "".$post_author_name."" : "".$post_author_name."");
$upload_datestamp = $gen->convert_date($upload_datestamp, "short");
$text .= "
";
}
}
$text .= "
\n
";
$ns->tablerender(UPLLAN_43, $text);
} // end - switch($action)
function upload_adminmenu()
{
$action = (e_QUERY) ? e_QUERY : "list";
$var['list']['text'] = UPLLAN_51;
$var['list']['link'] = e_SELF."?list";
$var['list']['perm'] = "V";
if(getperms("0"))
{
$var['filetypes']['text'] = UPLLAN_49;
$var['filetypes']['link'] = e_SELF."?filetypes";
$var['filetypes']['perm'] = "0";
$var['options']['text'] = UPLLAN_50;
$var['options']['link'] = e_SELF."?options";
$var['options']['perm'] = "0";
}
show_admin_menu(UPLLAN_43, $action, $var);
}
require_once("footer.php");
?>