<?php
if (!defined('SECURED'))
{
die("Unknown Error!");
}
include 'includes/func_formatsize.php';
title('Download file');
div('Download file','b');
if($ver=='wml')
{
echo'Downloading files is only possible in <a href="'.$_SERVER['PHP_SELF'].'?mode=upload&id='.$category['id'].'&xhtml&'.SID.'">xHTML</a> version.<br/>';
}
else
{
if(!empty($_GET['id']))
{
$id=intval($_GET['id']);
list($refcat, $cat_name)=mysql_fetch_row(mysql_query("select `parent`,`name` from `categorys` where id=".$id));
if(!$refcat)
{
echo'Unknown error';
footer();
exit;
}
list($refcat_name, $acc_ext) = mysql_fetch_row(mysql_query("SELECT `name`,`acc_ext` FROM `categorys` WHERE `id`=".$refcat));
$acc_ext = explode('|',strtolower(str_replace(array("\n","\r","\t",' '), '', $acc_ext)));
div("» <b>$refcat_name</b>/<b>$cat_name</b>",'g');
if(!isset($_POST['upl_type']))
{
echo'<div class="a">';
if(!isset($_GET['pravila'])){
echo'<a href="'.$_SERVER['PHP_SELF'].'?mode=upload&id='.$id.'&pravila&'.$rand.'&'.SID.'"><b>Upload Policy</b></a><br/>';}
if(isset($_GET['pravila'])){
echo'<b>Upload Policy</b><br/>1. All fields are required. <br/>
2. Files that are no longer treatment '.($config['max_keep']/3600/24).' days are removed automatically.<br/>
3. It is strictly forbidden to pour it into the exchanger files containing child pornography, bestiality, inciting inter-ethnic conflicts, contrary to the laws of Russia!<br/>
4. Administration has the right to delete any file without notice to the person zalivshego it in the exchanger<br/>';
}
echo'Extensions permitted to download in this category: <b>'.strtoupper(str_replace('|',', ',implode('|',$acc_ext))).'</b>';
echo'</div>';
if(isset($_GET['operamini'])) echo'» <a href="'.$_SERVER['PHP_SELF'].'?mode=upload&id='.$id.'&'.$rand.'&'.SID.'">Normal download</a>';
else echo'» <a href="'.$_SERVER['PHP_SELF'].'?mode=upload&id='.$id.'&operamini&'.$rand.'&'.SID.'">Downloading with Opera Mini</a>';
echo $separator;
echo'<form enctype="multipart/form-data" action="'.$_SERVER['PHP_SELF'].'?mode=upload&id='.$id.'&'.SID.'" method="post">
• <b>Form Downloads:</b><br/>
» Description:<br/>
<textarea name="info" cols="15" rows="3"></textarea><br/>
';
echo'» Your name (or nickname): ';
if(!$sid)
{
echo'<br/><input type="text" name="nickname"/><br/>';
}
else
{
echo'<b>'.$login.'</b><br/>';
}
echo'» File (not more '.formatsize($config['max_filesize']).'):<br/>';
if(isset($_GET['operamini']))
{
echo'<input type="text" name="file"/><br/>
<a href="op:fileselect">Browse ...</a><br/>
<input name="upl_type" type="hidden" value="2"/>';
}
else
{
echo'<input type="file" name="file"/><br/>
<input name="upl_type" type="hidden" value="1"/>';
}
echo'
<input type="submit" name="submit" value="Load"/>
</form>';
echo $separator;
}
else
{
$uploaded=false;
if(!$sid)
{
$nickname = val($_POST['nickname']);
list($check_if_exists)=mysql_fetch_array(mysql_query("select id from users where login='".$nickname."';"));
if(mysql_affected_rows()!=0) $error.='You may not use this nickname to add the files, because it is registered!<br/>';
else $nickname="0|$nickname";
}
else $nickname = $user['id']."|$login";
if($error)
{
echo $error;
echo '<a href="'.$_SERVER['PHP_SELF'].'?mode=upload&id='.$id.'&'.$rand.'&'.SID.'">Back</a>'.$separator;
footer();
exit;
}
switch($_POST['upl_type'])
{
default:
require 'includes/fileupload-class.php';
$destination = 'files/'.$refcat.'/'.$id;
$my_uploader = &new uploader('ru');
$my_uploader->max_filesize($config['max_filesize']);
$my_uploader->accepted_extensions($acc_ext);
if ($my_uploader->upload('file', '', ''))
{
$my_uploader->save_file($destination, 2);
}
if ($my_uploader->error)
{
echo $my_uploader->error.'<br/>';
echo '<a href="'.$_SERVER['PHP_SELF'].'?mode=upload&id='.$id.'&'.$rand.'&'.SID.'">Back</a>'.$separator;
}
else
{
$uploaded=true;
$file_path=$destination.'/'.$my_uploader->file['name'];
}
break;
case 2:
include 'includes/inc_om_upload.php';
list($uploaded_state,$msg)=om_upload($_POST['file'],$destination,$config['max_filesize'],$acc_ext);
if($uploaded_state==true)
{
$uploaded=true;
$file_path=$destination.'/'.$msg;
}
else
{
echo $msg.'<br/>';
echo '<a href="'.$_SERVER['PHP_SELF'].'?mode=upload&id='.$id.'&'.$rand.'&'.SID.'">Back</a>'.$separator;
}
break;
}
if($uploaded==true)
{
include"includes/func_translit.php";
include"includes/inc_make_jad.php";
include"includes/inc_make_preview.php";
$ext=strtolower(pathinfo($file_path,PATHINFO_EXTENSION));
//screenshot for video or pictures
if(in_array($ext,$extensions['video']) || in_array($ext,$extensions['pics']))
{
$screenshot = make_preview($file_path,$destination);
}
else $screenshot='';
//jad file for java file
if($ext=='jar')
{
$jad = make_jad($file_path,$destination,'http://'.$config['fs_path'].'/'.$file_path);
}
else $jad='';
//recording copyrights in id3 music files
if(in_array($ext,$extensions['audio']))
{
$siteurl=str_replace('http://', null, $config['url']);
include'includes/inc_mp3_class.php';
$id3 = new MP3_Id();
$result = $id3->read($file_path);
$id3->setTag('name', $siteurl);
$id3->setTag('artists', $siteurl);
$id3->setTag('album', $siteurl);
$id3->setTag('comment', $config['url']);
$result = $id3->write();
}
$info = val($_POST['info']);
if($_POST['tr_info']==1) $info = tr($info);
if(empty($info)) $info='[No description]';
mysql_query("UPDATE `users` SET `upl_files` = `upl_files` + 1, `upl_files_size` = `upl_files_size` + ".filesize($file_path)." WHERE `id`=".$user['id']);
mysql_query("INSERT INTO `files` ( `id` , `cat` , `refcat` , `filename` , `desc` , `screen` , `jad` , `downloads` , `uploaded` , `author` , `ip` , `soft` ) VALUES (0, '$id', '$refcat', '$file_path', '$info', '$screenshot', '$jad', '0', '".time()."', '$nickname', '$ip', '$agent');");
echo "File successfully downloaded, entitled <b>".basename($file_path)."</b>!<br/>";
echo '<a href="'.$_SERVER['PHP_SELF'].'?mode=file&id='.mysql_insert_id().'&'.SID.'">Go to file</a><br/>';
echo '<a href="'.$_SERVER['PHP_SELF'].'?mode=upload&id='.$id.'&'.$rand.'&'.SID.'">Download more!</a>'.$separator;
unset($_SESSION['ref']);
}
}
echo '» <a href="'.$_SERVER['PHP_SELF'].'?mode=cat&id='.$id.'&'.SID.'">'.$cat_name.'</a><br/>';
echo '» <a href="'.$_SERVER['PHP_SELF'].'?mode=cat&id='.$refcat.'&'.SID.'">'.$refcat_name.'</a><br/>';
}
else
{
if(!empty($_GET['cid']))
{
$cid=intval($_GET['cid']);
list($this_cat_name)=mysql_fetch_array(mysql_query("select name from categorys where id='".$cid."';"));
echo'<img src="images/up.gif" alt="[UP]"/> <b><a href="'.$_SERVER['PHP_SELF'].'?mode=upload&'.SID.'">'.$this_cat_name.'</a></b>';
echo $separator;
echo'Choose a subcategory:<br/>';
$q=mysql_query("select * from categorys where parent='".$cid."' order by position;");
while($category=mysql_fetch_array($q))
{
$text='<img src="images/dir.gif" alt="[DIR]"/> ';
if($category['adult']==1) $text.='[18+]';
$text.='<b><a href="'.$_SERVER['PHP_SELF'].'?mode=upload&id='.$category['id'].'&'.SID.'">'.$category['name'].'</a></b><br/>';
echo $text;
}
}
else
{
echo'Select a category:<br/>';
$q=mysql_query("select * from categorys where parent='0' order by position;");
while($category=mysql_fetch_array($q))
{
$text='<img src="images/dir.gif" alt="[DIR]"/> ';
$text.='<b><a href="'.$_SERVER['PHP_SELF'].'?mode=upload&cid='.$category['id'].'&'.SID.'">'.$category['name'].'</a></b><br/>';
echo $text;
}
}
}
}
echo $separator.$goback;
?>