';
$adminactions.= ' ';
if(isfileadmin($userID)) {
$adminactions.=' | |
';
$rubrics=safe_query("SELECT * FROM ".PREFIX."files_categorys ORDER BY name");
while($dr=mysql_fetch_array($rubrics)) {
$filecats.='';
}
$access='';
$bg1=BG_1;
if(!isset($filecats)) redirect('index.php?site=files', 'You have to create a file-category first!', '3');
else {
echo $adminactions;
eval ("\$files_new = \"".gettemplate("files_new")."\";");
echo $files_new;
}
}
else redirect("index.php?site=files", "no access!", "3");
}
elseif($action=="edit") {
$fileID = $_GET['fileID'];
if($fileID) {
if(isfileadmin($userID)) {
// ADMINACTIONS
$adminactions ='
';
$rubrics=safe_query("SELECT * FROM ".PREFIX."files_categorys ORDER BY name");
while($cat=mysql_fetch_array($rubrics)) {
$filecats.='';
}
$file=mysql_fetch_array(safe_query("SELECT * FROM ".PREFIX."files WHERE fileID='$fileID'"));
$filecats=str_replace('value="'.$file[filecatID].'"', 'value="'.$file[filecatID].'" selected', $filecats);
$accessmenu='';
$access=str_replace('value="'.$file[accesslevel].'"', 'value="'.$file[accesslevel].'" selected', $accessmenu);
$sizeinfo = strtolower(detectfilesize($file[filesize]));
$sizeinfo = explode(" ",$sizeinfo);
$filesize=$sizeinfo[0];
$unit = '';
switch($sizeinfo[1]) {
case 'byte': $unit=str_replace('value="b"','value="b" selected',$unit); break;
case 'kb': $unit=str_replace('value="kb"','value="kb" selected',$unit); break;
case 'mb': $unit=str_replace('value="mb"','value="mb" selected',$unit); break;
case 'gb': $unit=str_replace('value="gb"','value="gb" selected',$unit); break;
}
if(eregi('http://', $file[file])) $extern=$file[file];
// FILE-MIRRORS (remember: the primary mirror is still the uploaded or external file!)
$mirrors = $file['mirrors'];
if($mirrors) {
if(!eregi("||", $mirrors)) {
$secondarymirror = explode("||", $mirrors);
$mirror2=$secondarymirror[0];
$mirror3=$secondarymirror[1];
} else $mirror2=$mirrors;
}
// display
$bg1=BG_1;
$bg2=BG_2;
$border=BORDER;
$pagebg=PAGEBG;
eval ("\$files_edit = \"".gettemplate("files_edit")."\";");
echo $files_edit;
} else redirect("index.php?site=files", "no access!", "3");
} else redirect("index.php", "Can't edit files without fileID.", "3");
}
elseif($_GET['cat']) {
$accesslevel = 1;
if(isclanmember($userID)) $accesslevel = 2;
// ADMINACTIONS
if(isfileadmin($userID) AND $publicadmin) {
$adminactions='';
}
// CATEGORY
$catID=$_GET['cat'];
$cat=mysql_fetch_array(safe_query("SELECT * FROM ".PREFIX."files_categorys WHERE filecatID='".$catID."'"));
$category=$cat['name'];
$level=1;
if(isclanmember($userID)) $level=2;
$files=safe_query("SELECT * FROM ".PREFIX."files WHERE filecatID='".$cat['filecatID']."' AND accesslevel<=$level ORDER BY filename");
if(mysql_num_rows($files)) {
$bg1 = BG_1;
$bg2 = BG_2;
$border = BORDER;
$pagebg = PAGEBG;
$bgcat = BGCAT;
echo $adminactions.'
';
unset($adminactions);
eval ("\$files_category_list = \"".gettemplate("files_category_list_head")."\";");
echo $files_category_list;
$n=0;
while($file = mysql_fetch_array($files)) {
$n++;
if($n%2) {
$bg1 = BG_1;
$bg2 = BG_2;
} else {
$bg1 = BG_4;
$bg2 = BG_3;
}
$fileid = $file['fileID'];
$filename = ''.$file['filename'].'';
$fileinfo = cleartext($file['info']);
$filesize = $file['filesize'];
$fileload = $file['downloads'];
$filevotes = $file['votes'];
$filevotes ? $filevotes = ', '.$filevotes.' votes' : $filevotes = ', unrated';
$filedate = date("d.M.Y - H:i", $file['date']);
$traffic = $filesize * $fileload;
$rating = $file['rating'];
// adminactions
if(isfileadmin($userID) AND $publicadmin) {
$adminactions = '';
$adminactions .= ' ';
$adminactions .= ' ';
$adminactions .= ' |
';
}
// RATING
$rating = $file['rating'];
$rating ? $rating = $rating.' / 10' : $rating='0 / 10';
$ratings=array(0,0,0,0,0,0,0,0,0,0);
for($i=0; $i<$file['rating']; $i++) {
$ratings[$i]=1;
}
$ratingpic='';
foreach($ratings as $pic) {
$ratingpic.='';
}
if(!$userID AND $file[accesslevel]>=1) $link='(R)';
else $link = '';
eval ("\$files_category_list = \"".gettemplate("files_category_list")."\";");
echo $files_category_list;
}
eval ("\$files_category_list = \"".gettemplate("files_category_list_foot")."\";");
echo $files_category_list;
} else redirect("index.php?site=files", "Can't display category without catID", "3");
}
elseif($_GET['file']) {
// ADMINACTIONS
if(isfileadmin($userID) AND $publicadmin) {
$adminactions='
';
}
// FILE-INFORMATION
$file=mysql_fetch_array(safe_query("SELECT * FROM ".PREFIX."files WHERE fileID='".$_GET['file']."'"));
if($file[accesslevel]==2 AND !isclanmember($userID)) die('No access');
$fileID=$file[fileID];
$filename = $file['filename'];
$fileinfo = cleartext($file['info']);
$filesize = $file['filesize']; if(!$filesize) $filesize=0;
$downloads = $file['downloads']; if(!$downloads) $downloads=0;
$filevotes = $file['votes'];
$filevotes ? $filevotes = ', '.$filevotes.' votes' : $filevotes = ', unrated';
$traffic = detectfilesize($filesize * $downloads);
$filesize = detectfilesize($file['filesize']);
$reportlink = 'report dead link';
$date = date("d.m.Y", $file['date']);
// FILE-AUTHOR
$uploader = cleartext('[flag]'.getcountry($file['poster']).'[/flag]').' '.getnickname($file['poster']).'';
// FILE-CATEGORY
$cat=mysql_fetch_array(safe_query("SELECT * FROM ".PREFIX."files_categorys WHERE filecatID='".$file['filecatID']."'"));
$category = ''.$cat['name'].'';
// FILE-MIRRORS (remember: the primary mirror is still the uploaded or external file!)
$mirrors = $file['mirrors'];
if($mirrors) {
if(eregi("||", $mirrors)) {
$secondarymirror = explode("||", $mirrors);
$mirrorlist = '• download via mirror #2
• download via mirror #3';
} else $mirrorlist = '• download via mirror #2';
} else $mirrorlist = 'no mirrors';
if($file[accesslevel] AND !$userID) $mirrorlist = 'please login';
// RATING
$rating = $file['rating'];
$rating ? $rating = $rating.' / 10' : $rating='0 / 10';
$ratings=array(0,0,0,0,0,0,0,0,0,0);
for($i=0; $i<$file['rating']; $i++) {
$ratings[$i]=1;
}
$ratingpic='';
foreach($ratings as $pic) {
$ratingpic.='';
}
if($loggedin) {
$getfiles=safe_query("SELECT files FROM ".PREFIX."user WHERE userID='$userID'");
$found=false;
if(mysql_num_rows($getfiles)) {
$ga=mysql_fetch_array($getfiles);
if($ga[files]!="") {
$string=$ga[files];
$array=explode(":", $string);
$anzarray=count($array);
for($i=0; $i<$anzarray; $i++) {
if($array[$i]==$file[fileID]) $found=true;
}
}
}
if($found) $rateform="You have already rated.";
else {
$rateform='';
}
} else $rateform = 'Rate: You have to register or login!';
// DISPLAY
$bg1=BG_1;
$bg2=BG_2;
$border=BORDER;
$pagebg=PAGEBG;
// ADMINTOOLS
if(isfileadmin($userID)) {
$admintools = ' |
';
$admintools .= ' ';
$admintools .= ' ';
$admintools .= ' |
';
}
$accesslevel = 0;
if($userID) $accesslevel = 1;
if(isclanmember($userID)) $accesslevel = 2;
if($file[accesslevel] <= $accesslevel) $link = ' Download '.$filename.' now ';
else $link='Download for registered users only!
Login | Register';
eval ("\$files_display = \"".gettemplate("files_display")."\";");
echo $files_display;
}
elseif($action=="statistic") {
// EXTENDED STATS
}
elseif($action=="report") {
// DEAD-LINK TICKET SYSTEM
$mode = 'deadlink';
$type = 'files';
$id = $_GET['link'];
$referer=$_SERVER['HTTP_REFERER'];
// display
$bg1 = BG_1;
$bg2 = BG_2;
$bghead = BGHEAD;
$border = BORDER;
$pagebg = PAGEBG;
if($id) {
$type = 'files';
if(!$userID) {
$CAPCLASS = new Captcha;
$captcha = $CAPCLASS->create_captcha();
$hash = $CAPCLASS->get_hash();
$CAPCLASS->clear_oldcaptcha();
$captcha_form = $captcha.'
';
}
eval("\$report_deadlink = \"".gettemplate("report_deadlink")."\";");
echo $report_deadlink;
} else redirect("index.php?site=files", "Can't report dead link without fileID", "3");
}
else {
$accesslevel = 1;
if(isclanmember($userID)) $accesslevel = 2;
if(isfileadmin($userID) AND $publicadmin) {
$adminactions='
';
}
// STATS
// categories in database
$catQry=safe_query("SELECT * FROM ".PREFIX."files_categorys ORDER BY name");
$totalcats=mysql_num_rows($catQry);
if($totalcats) {
// files in database
$fileQry=safe_query("SELECT * FROM ".PREFIX."files");
$totalfiles=mysql_num_rows($fileQry);
if($totalfiles) {
// total traffic caused by downloads
while($file=mysql_fetch_array($fileQry)) {
$filesize = $file['filesize'];
$fileload = $file['downloads'];
$hddspace += $filesize;
$traffic += $filesize * $fileload;
$rating = $file['rating'];
}
$traffic = detectfilesize($traffic);
$hddspace = detectfilesize($hddspace);
// last uploaded file
$filedata=mysql_fetch_array(safe_query("SELECT * FROM ".PREFIX."files WHERE accesslevel<=$accesslevel ORDER BY date DESC LIMIT 0,1"));
$filename=$filedata['filename'];
if(strlen($filename) > 12) {
$filename =substr($filename, 0, 12);
$filename.='...';
}
$lastfile=''.$filename.'';
} else {
$traffic='n/a';
$hddspace='n/a';
$lastfile='n/a';
}
// FILE-TOP 5
$top5qry=safe_query("SELECT * FROM ".PREFIX."files WHERE accesslevel<=$accesslevel ORDER BY downloads DESC LIMIT 0,5");
$top5='
• TOP 5 Downloads |
|
';
$n=1;
while($file=mysql_fetch_array($top5qry)) {
$n%2 ? $bg=BG_1 : $bg=BG_2;
$filename=$file['filename'];
if(strlen($filename) > 12) {
$filename =substr($filename, 0, 12);
$filename.='...';
}
$filename=''.$filename.'';
if($file['downloads'] != '0') {
$top5.='
'.$n.'. |
'.$filename.' |
'.$file[downloads].' |
';
}
$n++;
}
$top5.='
';
// FILE-OVERVIEW
$pagebg=PAGEBG;
$border=BORDER;
$bg1=BG_1;
$bg2=BG_2;
eval ("\$files_stats = \"".gettemplate("files_stats")."\";");
eval ("\$files_overview = \"".gettemplate("files_overview_head")."\";");
echo $files_overview;
unset($traffic);
unset($size);
// FILE-CATEGORIES
if($totalcats) {
$i=0;
while($cat = mysql_fetch_array($catQry)) {
if($i%2) {
$bg1=BG_1;
$bg2=BG_2;
}
else {
$bg1=BG_3;
$bg2=BG_4;
}
// cat-information
$catID = $cat['filecatID'];
$catname = ''.$cat['name'].'';
$caticon = $cat['icon'];
$iconfolder = './images/download-rubrics/';
if(is_file($iconfolder.$caticon)) $caticon='';
else $caticon='';
// get all files associated to the catID
$catFileQry = safe_query("SELECT * FROM ".PREFIX."files WHERE filecatID='".$catID."' AND accesslevel<=$accesslevel ORDER BY fileID DESC");
$catFileTotal = mysql_num_rows($catFileQry);
if($catFileTotal) {
$i++;
while($file = mysql_fetch_array($catFileQry)) {
$filename = $file['name'];
$filesize = $file['filesize'];
$fileload = $file['downloads'];
$traffic += $filesize * $fileload;
$downloads += $fileload;
$size += $file['filesize'];
}
$size = detectfilesize($size);
$traffic = detectfilesize($traffic);
// last uploaded file in category
$filedata=mysql_fetch_array(safe_query("SELECT * FROM ".PREFIX."files WHERE filecatID='".$cat['filecatID']."' ORDER BY date DESC LIMIT 0,1"));
$filename=$filedata['filename'];
if(strlen($filename) > 12) {
$filename =substr($filename, 0, 12);
$filename.='...';
}
$lastfile_cat=''.$filename.'';
// output
eval ("\$files_category = \"".gettemplate("files_category")."\";");
echo $files_category;
unset($traffic); unset($downloads);
}
}
}
eval ("\$files_overview = \"".gettemplate("files_overview_foot")."\";");
echo $files_overview;
} else echo 'no categories and files.';
}
?>