<?php

/*                     Database V2.5 2003 by Trooper www.wbbcoderforum.de                */


$filename="info_db.php";

require("./global.php");
$lang->load("START");
require("./acp/lib/class_parse.php");
global $master_board_name;

$whoiswho=$db->query("SELECT * FROM bb".$n."_info_db_id WHERE db_id='1'");
while($whois=$db->fetch_array($whoiswho)){$whocan=$whois[db_whocan];$whoedit=$whois[db_whoedit];$db_maxup=$whois[db_maxup];$whodown=$whois[db_whodown];$wholink=$whois[db_wholink];$proof=$whois[db_proof];
$db_end=$whois[db_end];$db_dend=$whois[db_dend];$db_erlgrp=$whois[db_erlgrp];}
$groupids = $wbbuserdata[groupids];$time=time();
#################################################
if($noheader=="1"){$nohead="?noheader=1";}
else{$noheader=0;}
if($action=="db"){$header="$headinclude";$noheader=1;global $noheader;}
#################################################
if($action=="upsave"){
if($noheader=="1"){$header="$headinclude";}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$arrange=$whocan;
foreach ($groupids as $be){
$pos = (strstr($arrange,$be));
if ($pos=='') {$allower=0;continue;}
if ($pos<>'') {$allower=1;$hit=" $be ";break;}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

# +++++++++++++++++++++++++ guest ++++++++++++++++++++++++++ #
if($allower==1){
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

$db_data_desc=strip_tags($db_data_desc);
$db_data_link=strip_tags($db_data_link);
$db_data_name=strip_tags($db_data_name);

if(!$db_data_name){$error="- Kein Titel eingegeben! -";stripcslashes($db_data_name);stripcslashes($db_data_desc);stripcslashes($db_data_link);
header("Location: ./info_db.php?action=upload&subkatid=$subkatid&db_data_link=$db_data_link&db_data_desc=$db_data_desc&db_data_name=$db_data_name&db_data_kb=$db_data_kb&error=$error&noheader=$noheader");
exit();}

if(!$db_data_desc){$error="- Keine Description eingegeben! -";stripcslashes($db_data_name);stripcslashes($db_data_desc);stripcslashes($db_data_link);
header("Location: ./info_db.php?action=upload&subkatid=$subkatid&db_data_link=$db_data_link&db_data_desc=$db_data_desc&db_data_name=$db_data_name&db_data_kb=$db_data_kb&error=$error&noheader=$noheader");
exit();}

if(!$subkatid){$error="- Keine Rubrik ausgewählt! -";stripcslashes($db_data_name);stripcslashes($db_data_desc);stripcslashes($db_data_link);
header("Location: ./info_db.php?action=upload&db_data_link=$db_data_link&db_data_desc=$db_data_desc&db_data_name=$db_data_name&db_data_kb=$db_data_kb&error=$error&noheader=$noheader");
exit();}

if((($db_data_ext==1)||($auswahl=='0'))AND(!$db_data_kb)){$error="- Keine Dateigröße angegeben! -";stripcslashes($db_data_name);stripcslashes($db_data_desc);stripcslashes($db_data_link);
header("Location: ./info_db.php?action=upload&subkatid=$subkatid&db_data_link=$db_data_link&db_data_desc=$db_data_desc&db_data_name=$db_data_name&db_data_kb=$db_data_kb&error=$error&noheader=$noheader");
exit();}

if((($db_data_ext==1)||($auswahl=='0'))AND(!$db_data_link)){$error="- Keinen Link angegeben! -";stripcslashes($db_data_name);stripcslashes($db_data_desc);stripcslashes($db_data_link);
header("Location: ./info_db.php?action=upload&subkatid=$subkatid&db_data_link=$db_data_link&db_data_desc=$db_data_desc&db_data_name=$db_data_name&db_data_kb=$db_data_kb&error=$error&noheader=$noheader");
exit();}

$time=time();


### LINK ###

# ++++++++++++++++++++ Endungsprüfung ++++++++++++++++++++++ #
if(($db_data_ext==1)||($auswahl=='0')){
$lending=substr("$db_data_link",-3,3);
$end_ids=explode(",",$db_end);$arrz=count($end_ids);
for ($i = 1;;$i++) {if ($i > $arrz) {break;}
$be = array_shift ($end_ids);
if($lending==$be){$isnot=1;break;}
else{$isnot=0;}}
if($isnot==0){$error="- Falsche Dateiendung (<b>$lending</b>) oder keine Datei ausgewählt! -";stripcslashes($db_data_name);stripcslashes($db_data_desc);stripcslashes($db_data_link);
header("Location: ./info_db.php?action=upload&db_data_desc=$db_data_desc&db_data_name=$db_data_name&db_data_kb=$db_data_kb&error=$error&noheader=$noheader");
exit();}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

if(($db_data_ext==1)||($auswahl=='0')){
$watnu="Linked";
$db->query("INSERT INTO bb".$n."_info_db_data SET db_data_desc='".addslashes($db_data_desc)."',db_data_name='".addslashes($db_data_name)."',db_data_path='".addslashes($db_data_link)."',db_data_kb='$db_data_kb',db_data_ext='1',db_data_subkatid='$subkatid',db_uploader='$wbbuserdata[username]',db_uploaderid='$wbbuserdata[userid]',db_update='$time',db_proof_ok='$proof'");
$db->query("UPDATE bb".$n."_info_db_id SET db_count=db_count+1,db_up_date='$time' WHERE db_sub_katid='$subkatid'");

if($proof==0){
list($free_id)=$db->query_first("SELECT db_d_id FROM bb".$n."_info_db_data WHERE db_data_name='$db_data_name'");

### Hier die Empfänger-ID eintragen, welche freischaltet! ###
#############################################################
$adminid=1;
#############################################################
$db->query("INSERT INTO bb".$n."_privatemessage SET privatemessageid = '', folderid = '0', senderid = '', recipientid = '$adminid', subject = 'Download zum disconnect!', sendtime = '".time()."', message = 'Es wurde ein File zum freigeben verlinkt/upgeloadet:    <br>
<a href=\"./info_db.php?action=free&noheader=$noheader&sid=$session[hash]\">To de-energising</a>', allowsmilies = '1', allowhtml = '1', showsignature = '1', iconid = '0', view = '0', reply = '0', forward = '0', deletepm = '0', tracking = '1'");
$db->unbuffered_query("UPDATE bb".$n."_users SET pmpopup=2 WHERE userid='$adminid'");
}
}
### /LINK ###

# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$arrange=$wholink;
foreach ($groupids as $be){
$pos = (strstr($arrange,$be));
if ($pos=='') {$allower=0;continue;}
if ($pos<>'') {$allower=1;$hit=" $be ";break;}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

# +++++++++++++++++++++++++ guest ++++++++++++++++++++++++++ #
if($allower==1){
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
### Datei ###
if($db_data_ext==0){
if(!is_uploaded_file($db_file)){$error="- Upload FAILED - Its possible that Uploads are not allowed or no file selected or bad config -";stripcslashes($db_data_name);stripcslashes($db_data_desc);stripcslashes($db_data_link);
header("Location: ./info_db.php?action=upload&subkatid=$subkatid&db_data_desc=$db_data_desc&db_data_name=$db_data_name&db_data_kb=$db_data_kb&error=$error&noheader=$noheader");
exit();}

# ++++++++++++++++++++ Endungsprüfung ++++++++++++++++++++++ #
if($db_data_ext==0){
$watnu="hochgeladen";
$lending=substr("$db_file_name",-3,3);
$end_ids=explode(",",$db_dend);$arrz=count($end_ids);
for ($i = 1;;$i++) {if ($i > $arrz) {break;}
$be = array_shift ($end_ids);
if($lending==$be){$isnot=1;break;}
else{$isnot=0;}}
if($isnot==0){$error="- Wrong File (<b>$lending</b>) Or No File Selected! -";stripcslashes($db_data_name);stripcslashes($db_data_desc);stripcslashes($db_data_link);
header("Location: ./info_db.php?action=upload&db_data_desc=$db_data_desc&db_data_name=$db_data_name&db_data_kb=$db_data_kb&error=$error&noheader=$noheader");
exit();}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

$nowtime=substr("$time",-4,4);
if(is_uploaded_file($db_file)){

$filesize=$db_file_size;$dbmax=$db_maxup*1000;
if($filesize>$dbmax){$error="- File To Large - Max Size Limit: $db_maxup KB ! -";stripcslashes($db_data_name);stripcslashes($db_data_desc);stripcslashes($db_data_link);
header("Location: ./info_db.php?action=upload&db_file=$orgname&db_data_desc=$db_data_desc&db_data_name=$db_data_name&db_data_kb=$db_data_kb&error=$error&noheader=$noheader");
exit();}
$oldname=$db_file_name;
$db_file_name=$nowtime."_$db_file_name";
move_uploaded_file($db_file,"./info_db/$db_file_name");
chmod ("./info_db/$db_file_name", 0775);}
$filesize=$filesize/1000;$filesize=round($filesize,0);

$db->query("INSERT INTO bb".$n."_info_db_data SET db_data_desc='".htmlspecialchars($db_data_desc)."',db_data_name='".htmlspecialchars($db_data_name)."',db_data_nr='$db_file_name',db_data_kb='$filesize',db_data_ext='0',db_data_subkatid='$subkatid',db_uploader='$wbbuserdata[username]',
db_uploaderid='$wbbuserdata[userid]',db_update='$time',db_proof_ok='$proof'");
$db->query("UPDATE bb".$n."_info_db_id SET db_count=db_count+1,db_up_date='$time'
WHERE db_sub_katid='$subkatid'");

if($proof==0){
list($free_id)=$db->query_first("SELECT db_d_id FROM bb".$n."_info_db_data
WHERE db_data_nr='$db_file_name'");


### Hier die Empfänger-ID eintragen, welche freischaltet! ###
#############################################################
$adminid=1;
#############################################################


$db->query("INSERT INTO bb".$n."_privatemessage SET privatemessageid = '', folderid = '0', senderid = '', recipientid = '$adminid', subject = 'Download zum disconnect!', sendtime = '".time()."', message = 'Es wurde ein File zum freigeben verlinkt/upgeloadet:    <br>
<a href=\"./info_db.php?action=free&noheader=$noheader&sid=$session[hash]\">Zur Freischaltung</a>
', allowsmilies = '1', allowhtml = '1', showsignature = '1', iconid = '0', view = '0', reply = '0', forward = '0', deletepm = '0', tracking = '1'");
$db->unbuffered_query("UPDATE bb".$n."_users SET pmpopup=2 WHERE userid='$adminid'");}
}
### /Datei ###<a href=""></a>
}

list($wodann)=$db->query_first("SELECT db_subkatname FROM bb".$n."_info_db_id WHERE db_sub_katid='$subkatid'");

$hauptkatname="Database Upload";
$kats.="<table cellpadding=\"{$style['tableincellpadding']}\" cellspacing=\"{$style['tableincellspacing']}\" border=\"{$style['tableinborder']}\" width=\"800\" class=\"tableinborder\">
<tr>
<td class=\"tablecat\" align=\"left\"><span class=\"smallfont\"><b>&nbsp;File Upload</b></td></tr>
";

$kats.="
<table cellpadding=\"{$style['tableincellpadding']}\" cellspacing=\"{$style['tableincellspacing']}\" border=\"{$style['tableinborder']}\" width=\"800\" class=\"tableinborder\">
<tr>
<td class=\"tablea\" align=\"center\" width=\"100%\" colspan=\"2\"><span class=\"smallfont\">
&nbsp;
</td></tr>

<tr>
<td class=\"tablea\" align=\"center\" width=\"100%\"><span class=\"smallfont\">
Datei: <b>$oldname</b><br />
Name: <b>$db_data_name </b><br />
KBytes:  $filesize $db_data_kb<br />
in: <b>$wodann</b><br />
- Successfully $watnu! -";

if($proof==0){
$kats.="<p>The Download will be de-energised as soon as possible !";}

$kats.="</td></tr></table>";
}

eval ("\$ifooter = \"".$tpl->get("index_db_footer")."\";");
eval("\$tpl->output(\"".$tpl->get("index_db")."\");");
exit();}
#################################################
if($action=="upload"){
if($noheader=="1"){$header="$headinclude";}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$arrange=$whocan;
foreach ($groupids as $be){
$pos = (strstr($arrange,$be));
if ($pos=='') {$allower=0;continue;}
if ($pos<>'') {$allower=1;$hit=" $be ";break;}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

# +++++++++++++++++++++++++ guest ++++++++++++++++++++++++++ #
if($allower==1){$auswahl='0';
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

stripcslashes($db_data_name);stripcslashes($db_data_desc);stripcslashes($db_data_link);
$hauptkatname="Database Upload";
$kats.="<table cellpadding=\"{$style['tableincellpadding']}\" cellspacing=\"{$style['tableincellspacing']}\" border=\"{$style['tableinborder']}\" width=\"100%\" class=\"tableinborder\">
<tr>
<td class=\"tablecat\" align=\"left\"><span class=\"smallfont\"><b>&nbsp;File Upload</b></td></tr>
";

$kats.="
<table cellpadding=\"{$style['tableincellpadding']}\" cellspacing=\"{$style['tableincellspacing']}\" border=\"{$style['tableinborder']}\" width=\"100%\" class=\"tableinborder\">
<form action=\"info_db.php?action=upsave\" method=\"post\" enctype=\"multipart/form-data\">
<tr>
<td class=\"tablea\" align=\"center\" width=\"100%\" colspan=\"2\"><span class=\"smallfont\">
&nbsp;<font color=\"#FF0000\">$error</font color>
</td></tr>";

$linktext="Sie können einen <b>Link</b> angeben";

# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$arrange=$wholink;
foreach ($groupids as $be){
$pos = (strstr($arrange,$be));
if ($pos=='') {$allower=0;continue;}
if ($pos<>'') {$allower=1;$hit=" $be ";break;}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

# +++++++++++++++++++++++++ guest ++++++++++++++++++++++++++ #
if($allower==1){$auswahl='1';
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$kats.="
<tr>
<td class=\"tablea\" align=\"left\" width=\"40%\"><span class=\"smallfont\">
Do you wish to upload or link a file? (No files over 2mb can be uploaded):
</td>
<td class=\"tablea\" align=\"left\" width=\"60%\"><span class=\"smallfont\">
&nbsp;<b>File</b> -&nbsp;<input type=\"radio\" name=\"db_data_ext\" value=\"0\" checked>&nbsp;&nbsp;<input type=\"radio\" name=\"db_data_ext\" value=\"1\">&nbsp;- <b>Link</b>
</td>
</tr>";
$linktext="<b>Link</b> to file?";

}

$kats.="
<!--                                      LINK                                  -->
<tr>
<td class=\"tablea\" align=\"left\" width=\"40%\"><span class=\"smallfont\">
$linktext:<br>
(example: http://www.....)
<br>extensions supported by linking:&nbsp;&nbsp;<b>$db_end</b>&nbsp;&nbsp;
</td>
<td class=\"tablea\" align=\"left\" width=\"60%\"><span class=\"smallfont\">
<input class=\"input\" type=\"text\" name=\"db_data_link\" value=\"$db_data_link\" SIZE=64 MAXLENGTH=128>
</td>
</tr>
<!--                                     /LINK                                  -->

<tr>
<td class=\"tablea\" align=\"left\" width=\"100%\" colspan=\"2\"><span class=\"smallfont\">
&nbsp;
</td></tr>

<tr>
<td class=\"tablea\" align=\"left\" width=\"40%\"><span class=\"smallfont\">
Download Name?:
</td>
<td class=\"tablea\" align=\"left\" width=\"60%\"><span class=\"smallfont\">
<input class=\"input\" type=\"text\" name=\"db_data_name\" value=\"$db_data_name\" SIZE=32 MAXLENGTH=64>
</td>
</tr>

<tr>
<td class=\"tablea\" align=\"left\" width=\"40%\"><span class=\"smallfont\">
Input a description:<br>
</td>
<td class=\"tablea\" align=\"left\" width=\"60%\"><span class=\"smallfont\">
<textarea name=\"db_data_desc\" cols=\"64\" rows=\"10\">$db_data_desc</textarea>
</td>
</tr>

<tr>
<td class=\"tablea\" align=\"left\" width=\"40%\"><span class=\"smallfont\">
File size in MegaBytes:
</td>
<td class=\"tablea\" align=\"left\" width=\"60%\"><span class=\"smallfont\">
<input class=\"input\" type=\"text\" name=\"db_data_kb\" value=\"$db_data_kb\" SIZE=9 MAXLENGTH=11>
&nbsp;KByte
</td>
</tr>

<tr>
<td class=\"tablea\" align=\"left\" width=\"100%\" colspan=\"2\"><span class=\"smallfont\">
&nbsp;
</td></tr>";


### SubKats ###
$dbsubkatname = $db->query("SELECT db_sub_katid,db_subkatname FROM bb".$n."_info_db_id WHERE db_parent_id>0 ORDER BY db_parent_id,db_order ASC");
while($dbsdata=$db->fetch_array($dbsubkatname)) {
$katlist.="<option value=\"$dbsdata[db_sub_katid]\">$dbsdata[db_subkatname]</option>
";
}



$kats.="
<tr>
<td class=\"tablea\" align=\"left\" width=\"40%\"><span class=\"smallfont\">
Choose the category that best fits the download:
</td>
<td class=\"tablea\" align=\"left\" width=\"60%\"><span class=\"smallfont\">
<select name=\"subkatid\" size=\"1\">
<option value=\"\" size=\"\">- Select Category -</option>
$katlist
</select>
</td>
</tr>

<tr>
<td class=\"tablea\" align=\"left\" width=\"100%\" colspan=\"2\"><span class=\"smallfont\">
&nbsp;
</td></tr>";


# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$arrange=$wholink;
foreach ($groupids as $be){
$pos = (strstr($arrange,$be));
if ($pos=='') {$allower=0;continue;}
if ($pos<>'') {$allower=1;$hit=" $be ";break;}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

# +++++++++++++++++++++++++ guest ++++++++++++++++++++++++++ #
if($allower==1){$auswahl='1';
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$kats.="
<!--                            FILE UPLOAD                                   -->
<tr>
<td class=\"tablea\" align=\"left\" width=\"40%\"><span class=\"smallfont\">
Select a <b>File</b> To Upload:<br>
File types permitted include:&nbsp;&nbsp;<b>$db_dend</b>&nbsp;&nbsp;<br>If you selected to link a file then ignore this option
</td>
<td class=\"tablea\" align=\"left\" width=\"60%\"><span class=\"smallfont\">
<input name=\"db_file\"  value=\"$db_file\" type=\"file\" size=\"50\">
</td>
<!--                           /FILE UPLOAD                                   -->
";
}

$kats.="
<tr>
<td class=\"tablea\" align=\"left\" width=\"100%\" colspan=\"2\"><span class=\"smallfont\">
&nbsp;
</td></tr>

<tr>
<td class=\"tablea\" align=\"center\" width=\"100%\" colspan=\"2\"><span class=\"smallfont\">

<input type=\"hidden\" name=\"Select\" value=\"$auswahl\">
<input type=\"Submit\" name=\"ok\" value=\"finished\">
</td></tr>

<tr>
<td class=\"tablea\" align=\"center\" width=\"100%\" colspan=\"2\"><span class=\"smallfont\">
&nbsp;
</td></tr>

</td>
</tr>
";


$kats.="<p></table>";

}

eval ("\$ifooter = \"".$tpl->get("index_db_footer")."\";");
eval("\$tpl->output(\"".$tpl->get("index_db")."\");");
exit();}
#################################################
if($action=="abedit"){
if($noheader=="1"){$header="$headinclude";}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$arrange=$whoedit;
foreach ($groupids as $be){
$pos = (strstr($arrange,$be));
if ($pos=='') {$allower=0;continue;}
if ($pos<>'') {$allower=1;$hit=" $be ";break;}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

# +++++++++++++++++++++++++ guest ++++++++++++++++++++++++++ #
if($allower==1){
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

$upgedated="";

if($prooft<>'')$db->query("UPDATE bb".$n."_info_db_id SET db_proof='$prooft'");

if($dbmaxup>0)$db->query("UPDATE bb".$n."_info_db_id SET db_maxup='$dbmaxup'");

if($db_whocan>0){
$str=strlen($db_whocan);
foreach($db_whocan AS $ttitle) {$selected.="$ttitle,";}$stc=strlen($selected);$stc=$stc-1;
$selected=substr($selected,0,$stc);
$db->query("UPDATE bb".$n."_info_db_id SET db_whocan='".$selected."'");}

if($db_wholink>0){
$str=strlen($db_wholink);
foreach($db_wholink AS $ttitle) {$selected.="$ttitle,";}$stc=strlen($selected);$stc=$stc-1;
$selected=substr($selected,0,$stc);
$db->query("UPDATE bb".$n."_info_db_id SET db_wholink='".$selected."'");}

if($db_whoedit>0){
$str=strlen($db_whoedit);
foreach($db_whoedit AS $ttitle) {$selected.="$ttitle,";}$stc=strlen($selected);$stc=$stc-1;
$selected=substr($selected,0,$stc);
$db->query("UPDATE bb".$n."_info_db_id SET db_whoedit='".$selected."'");}

if($dbwhodown>0){
$str=strlen($dbwhodown);
foreach($dbwhodown AS $ttitle) {$selected.="$ttitle,";}$stc=strlen($selected);$stc=$stc-1;
$selected=substr($selected,0,$stc);
$db->query("UPDATE bb".$n."_info_db_id SET db_whodown='".$selected."'");}

if($db_updt>0){
$db->query("UPDATE bb".$n."_info_db_id SET db_count='0'");
$updc=$db->query("SELECT db_d_id,db_data_subkatid FROM bb".$n."_info_db_data ORDER BY db_d_id ASC");
while($dbu=$db->fetch_array($updc)){
$db->query("UPDATE bb".$n."_info_db_id SET db_count=db_count+1 WHERE db_sub_katid='$dbu[db_data_subkatid]'");
}
$hpdc=$db->query("SELECT db_data_subkatid,db_update FROM bb".$n."_info_db_data ORDER BY db_update DESC LIMIT 1");
while($dlsdata=$db->fetch_array($hpdc))
{$hpdlc=$dlsdata[db_update];$hpdcc=$dlsdata[db_data_subkatid];}
$hpdlf=$hpdlc-3600;
$db->query("UPDATE bb".$n."_info_db_id SET db_up_date='$hpdlf' WHERE db_up_date>'$hpdlc'");
$db->query("UPDATE bb".$n."_info_db_id SET db_up_date='$hpdlc' WHERE db_sub_katid='$hpdcc'");
$upgedated="- wurde upgedated! -";}


}
header("Location: ./info_db.php?action=bmenu&upgedated=$upgedated&noheader=$noheader");
exit();}
#################################################
if($action=="free"){
if($noheader=="1"){$header="$headinclude";}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$arrange=$whoedit;
foreach ($groupids as $be){
$pos = (strstr($arrange,$be));
if ($pos=='') {$allower=0;continue;}
if ($pos<>'') {$allower=1;$hit=" $be ";break;}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

# +++++++++++++++++++++++++ guest ++++++++++++++++++++++++++ #
if($allower==1){
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$hauptkatname="Database Admin Menü";
$kats.="<table cellpadding=\"{$style['tableincellpadding']}\" cellspacing=\"{$style['tableincellspacing']}\" border=\"{$style['tableinborder']}\" width=\"100%\" class=\"tableinborder\">
<tr>
<td class=\"tablecat\" align=\"left\"><span class=\"smallfont\"><b>&nbsp;Downloads</b> - Control</td></tr>
";

$kats.="</table><br>";

$kats.="
<table cellpadding=\"{$style['tableincellpadding']}\" cellspacing=\"{$style['tableincellspacing']}\" border=\"{$style['tableinborder']}\" width=\"100%\" class=\"tableinborder\"  colspan=\"2\"> ";

$dbkatname = $db->query("SELECT * FROM bb".$n."_info_db_data WHERE db_proof_ok=0");
while($dbkdata=$db->fetch_array($dbkatname)){
$db_data_subkatid=$dbkdata[db_data_subkatid];
if($dbkdata[db_data_nr]){$dblink="./info_db/$dbkdata[db_data_nr]";$watis="File";}
if($dbkdata[db_data_path]){$dblink="$dbkdata[db_data_path]";$watis="Link";}
list($subkatname)=$db->query_first("SELECT db_subkatname FROM bb".$n."_info_db_id WHERE db_sub_katid='$db_data_subkatid'");
$kats.="<tr>
<form action=\"info_db.php?action=freesave\" method=\"post\">
<td class=\"tablea\" align=\"left\" width=\"90%\" colspan=\"0\"><span class=\"smallfont\">
File/Link disconnect: <br />
Name: <b>$dbkdata[db_data_name]</b><br />
in: $subkatname<br />
<b>$watis</b>: <a href=\"$dblink\">$dblink</a><br />
Uploader: <a href=\"./profile.php?userid=$dbkdata[db_uploaderid]\">$dbkdata[db_uploader]</a><br /></td>
<td class=\"tablea\" align=\"left\" width=\"10%\" colspan=\"0\"><span class=\"smallfont\">
<input type=\"hidden\" name=\"db_d_id\" value=\"$dbkdata[db_d_id]\">
<input type=\"Submit\" name=\"ok\" value=\"ok\">
</td></form></tr>";
}



$kats.="<tr><td class=\"tablea\" align=\"center\" colspan=\"2\"><span class=\"smallfont\">&nbsp;</td></tr>";

$kats.="<tr><td class=\"tablea\" align=\"center\" colspan=\"2\"><span class=\"smallfont\"><a href=\"info_db.php?action=amenu&noheader=$noheader&sid=$session[hash]\"><b>Catagories/Sub-Catagories</b></a><br>
<a href=\"info_db.php?action=fileedit&noheader=$noheader&sid=$session[hash]\"><b>Downloads/Links Delete/Reorder/Regroup</b></a></td></tr>
</table>";
$kats.="</table>";
eval ("\$ifooter = \"".$tpl->get("index_db_footer")."\";");
eval("\$tpl->output(\"".$tpl->get("index_db")."\");");

exit();}
}
#################################################
if($action=="freesave"){
if($noheader=="1"){$header="$headinclude";}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$arrange=$whoedit;
foreach ($groupids as $be){
$pos = (strstr($arrange,$be));
if ($pos=='') {$allower=0;continue;}
if ($pos<>'') {$allower=1;$hit=" $be ";break;}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

# +++++++++++++++++++++++++ guest ++++++++++++++++++++++++++ #
if($allower==1){
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$db->query("UPDATE bb".$n."_info_db_data SET db_proof_ok='1' WHERE db_d_id='$db_d_id'");
header("Location: ./info_db.php?action=free&noheader=$noheader&sid=$session[hash]");
exit();
}}


#################################################
if($action=="katgrantsave"){
if($noheader=="1"){$header="$headinclude";}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$arrange=$whoedit;
foreach ($groupids as $be){
$pos = (strstr($arrange,$be));
if ($pos=='') {$allower=0;continue;}
if ($pos<>'') {$allower=1;$hit=" $be ";break;}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

# +++++++++++++++++++++++++ guest ++++++++++++++++++++++++++ #
if($allower==1){
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #


$str=strlen($db_erlgrp);
foreach($db_whocan AS $ttitle) {$selected.="$ttitle,";}$stc=strlen($selected);$stc=$stc-1;
$selected=substr($selected,0,$stc);
list($db_katid)=$db->query_first("SELECT db_katid FROM bb".$n."_info_db_id WHERE db_id='$db_id'");
$db->query("UPDATE bb".$n."_info_db_id SET db_erlgrp='".$selected."'
WHERE ((db_katid='$db_katid')||(db_parent_id='$db_katid'))");}


header("Location: ./info_db.php?action=katgrant&noheader=$noheader&sid=$session[hash]");
exit();}
#################################################
if($action=="katgrant"){
if($noheader=="1"){$header="$headinclude";}

$kats.="<tr>
<td class=\"tablea\" align=\"center\" width=\"40%\" colspan=\"3\"><span class=\"smallfont\">
- All groups must be selected that you want to give access to this Catagory -
</td></tr>";

# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$arrange=$whoedit;
foreach ($groupids as $be){
$pos = (strstr($arrange,$be));
if ($pos=='') {$allower=0;continue;}
if ($pos<>'') {$allower=1;$hit=" $be ";break;}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

# +++++++++++++++++++++++++ guest ++++++++++++++++++++++++++ #
if($allower==1){
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$hauptkatname="Database Admin Menü";

$result1 = $db->query("SELECT db_id,db_katname,db_erlgrp FROM bb".$n."_info_db_id WHERE db_katid>'0' ORDER BY db_order ASC");
while($dbdata=$db->fetch_array($result1)) {
$namkat=stripcslashes($dbdata[db_katname]);
$db_erlgrp=$dbdata[db_erlgrp];
$db_id=$dbdata[db_id];
$kats.="<tr>
<form action=\"info_db.php?action=katgrantsave&noheader=$noheader&sid=$session[hash]\" method=\"post\">
<td class=\"tablea\" align=\"left\" width=\"40%\"><span class=\"smallfont\">
<form action=\"info_db.php?action=abedit&noheader=$noheader&sid=$session[hash]\" method=\"post\">
<span class=\"smallfont\">
&nbsp;What Groups can access <b>$namkat</b>?&nbsp;
</td>";

$glist1 = "&nbsp;<u>Selected:</u><br>";
$pieces = explode (",", $db_erlgrp);
foreach($pieces as $tit){
list($resulta) = $db->query_first("SELECT title FROM bb".$n."_groups WHERE groupid='$tit'");
$glist1 .= $resulta."<br>";}

$result = $db->query("SELECT g.groupid, g.title FROM bb".$n."_groups g ORDER BY g.groupid ASC");
$grpoptions = "";
while ($grmaker = $db->fetch_array($result)){
$grpoptions .= "<option value=\"".$grmaker['groupid']."\" ";
$grpoptions .= ($grmaker['grxid']) ? " selected=\"selected\">" : ">";
$grpoptions .= $grmaker['title']."</option>";}

$kats.="
<td class=\"tablea\" align=\"left\"><span class=\"smallfont\">
&nbsp;&nbsp;Groups:&nbsp;
<select name=\"db_whocan[]\" size=\"3\" multiple=\"multiple\" class=\"smallfont\">
  $grpoptions
</select>
<center>&nbsp;&nbsp;
<input type=\"hidden\" name=\"db_id\" value=\"$db_id\">
<input type=\"Submit\" name=\"ok\" value=\"ok - Group(s) Specify\">
</form>
</td>
<td class=\"tablea\" align=\"left\"><span class=\"smallfont\">
$glist1
</td>
</tr>";

}

}
$kats.="
<tr>
<td class=\"tablea\" align=\"center\" colspan=\"3\"><span class=\"smallfont\">&nbsp;<br /><a href=\"info_db.php?action=amenu&noheader=$noheader&sid=$session[hash]\"><b>Catagories/Sub-Catagories</b></a><br>
<a href=\"info_db.php?action=fileedit&noheader=$noheader&sid=$session[hash]\"><b>Downloads/Links Delete/Reorder/Regroup</b></a><br />&nbsp;</td></tr>
</table><br>";


eval ("\$ifooter = \"".$tpl->get("index_db_footer")."\";");
eval("\$tpl->output(\"".$tpl->get("index_db")."\");");


exit();
}
#################################################
if($action=="bmenu"){
if($noheader=="1"){$header="$headinclude";}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$arrange=$whoedit;
foreach ($groupids as $be){
$pos = (strstr($arrange,$be));
if ($pos=='') {$allower=0;continue;}
if ($pos<>'') {$allower=1;$hit=" $be ";break;}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

# +++++++++++++++++++++++++ guest ++++++++++++++++++++++++++ #
if($allower==1){
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$hauptkatname="Database Admin Menü";


$kats.="<table cellpadding=\"{$style['tableincellpadding']}\" cellspacing=\"{$style['tableincellspacing']}\" border=\"{$style['tableinborder']}\" width=\"100%\" class=\"tableinborder\">
<tr>
<td class=\"tablecat\" align=\"left\"><span class=\"smallfont\"><b>&nbsp;Downloads</b> - Sonstiges</td></tr>
";

$kats.="</table><br>";

$dbkatname = $db->query("SELECT * FROM bb".$n."_info_db_id WHERE db_id=1");
while($dbkdata=$db->fetch_array($dbkatname)){
$poff=" an";
if($dbkdata[db_proof]==1){$poff=" aus";}

### Hauptkats ###
$kats.="
<table cellpadding=\"{$style['tableincellpadding']}\" cellspacing=\"{$style['tableincellspacing']}\" border=\"{$style['tableinborder']}\" width=\"100%\" class=\"tableinborder\">
<tr>
<td class=\"tablea\" align=\"left\" width=\"40%\" colspan=\"3\"><span class=\"smallfont\">
&nbsp;Existing ranks and their ID':&nbsp;
</td></tr>

<tr>
<td class=\"tablea\" align=\"left\" width=\"40%\"><span class=\"smallfont\">
<form action=\"info_db.php?action=abedit&noheader=$noheader&sid=$session[hash]\" method=\"post\">
<span class=\"smallfont\">
&nbsp;Do Downloads/Links have to be de-energised only?&nbsp;
</td>
<td class=\"tablea\" align=\"center\"><span class=\"smallfont\">

<select name=\"prooft\" size=\"\">
<option value=\"\">- Select -</option>
<option value=\"0\">-  Yes  -</option>
<option value=\"1\">- No -</option>
</select>

<input type=\"Submit\" name=\"ok\" value=\"ok\"><br>&nbsp;&nbsp; - is currently set to <b>$poff</b>
</form><p>
</td>
<td class=\"tablea\" align=\"left\"><span class=\"smallfont\">&nbsp;</td>
</tr>

<tr>
<td class=\"tablea\" align=\"left\" width=\"40%\"><span class=\"smallfont\">
<form action=\"info_db.php?action=abedit&noheader=$noheader&sid=$session[hash]\" method=\"post\">
<span class=\"smallfont\">
&nbsp;Which Group(s) May Use The Link Funtion?&nbsp;
</td>";
######
$glist1 .= "&nbsp;<u>Selected:</u><br>";
$glist2 .= "&nbsp;<u>Selected:</u><br>";
$glist3 .= "&nbsp;<u>Selected:</u><br>";
$glist4 .= "&nbsp;<u>Selected:</u><br>";
$pieces = explode (",", $whocan);
foreach($pieces as $tit){
list($resulta) = $db->query_first("SELECT title FROM bb".$n."_groups WHERE groupid='$tit'");
$glist1 .= $resulta."<br>";}
$pieces = explode (",", $wholink);
foreach($pieces as $tit){
list($resulta) = $db->query_first("SELECT title FROM bb".$n."_groups WHERE groupid='$tit'");
$glist2 .= $resulta."<br>";}
$pieces = explode (",", $whodown);
foreach($pieces as $tit){
list($resulta) = $db->query_first("SELECT title FROM bb".$n."_groups WHERE groupid='$tit'");
$glist3 .= $resulta."<br>";}
$pieces = explode (",", $whoedit);
foreach($pieces as $tit){
list($resulta) = $db->query_first("SELECT title FROM bb".$n."_groups WHERE groupid='$tit'");
$glist4 .= $resulta."<br>";}
$glist1 .= "&nbsp;<br>";
$glist2 .= "&nbsp;<br>";
$glist3 .= "&nbsp;<br>";
$glist4 .= "&nbsp;<br>";

$result = $db->query("SELECT g.groupid, g.title FROM bb".$n."_groups g ORDER BY g.groupid ASC");
$grpoptions = "";
while ($grmaker = $db->fetch_array($result)){
$grpoptions .= "<option value=\"".$grmaker['groupid']."\" ";
$grpoptions .= ($grmaker['grxid']) ? " selected=\"selected\">" : ">";
$grpoptions .= $grmaker['title']."</option>";}
######
$kats.="
<td class=\"tablea\" align=\"left\"><span class=\"smallfont\">
&nbsp;&nbsp;Groups:&nbsp;
<select name=\"db_whocan[]\" size=\"3\" multiple=\"multiple\" class=\"smallfont\">
  $grpoptions
</select>
<center>&nbsp;&nbsp;<input type=\"Submit\" name=\"ok\" value=\"ok - Group(s) Specify\">
</form>
</td>

<td class=\"tablea\" align=\"left\"><span class=\"smallfont\">
$glist1
</td>
</tr>

<tr>
<td class=\"tablea\" align=\"left\" width=\"40%\"><span class=\"smallfont\">
<form action=\"info_db.php?action=abedit&noheader=$noheader&sid=$session[hash]\" method=\"post\">
<span class=\"smallfont\">
&nbsp;Which Group(s) May Use The Upload Funtion?&nbsp;<br>
</td>
<td class=\"tablea\" align=\"left\"><span class=\"smallfont\">
&nbsp;&nbsp;Groups:&nbsp;
<select name=\"db_wholink[]\" size=\"3\" multiple=\"multiple\" class=\"smallfont\">
  $grpoptions
</select>
<center>&nbsp;&nbsp;<input type=\"Submit\" name=\"ok\" value=\"ok - Group(s) Specify\">
</form>
</td><td class=\"tablea\" align=\"left\"><span class=\"smallfont\">
$glist2
</td>
</tr>

<tr>
<td class=\"tablea\" align=\"left\" width=\"40%\"><span class=\"smallfont\">
<form action=\"info_db.php?action=abedit&noheader=$noheader&sid=$session[hash]\" method=\"post\">
<span class=\"smallfont\">
&nbsp;Which Group(s) Can Download?&nbsp;
</td>
<td class=\"tablea\" align=\"left\"><span class=\"smallfont\">
&nbsp;&nbsp;Groups:&nbsp;
<select name=\"dbwhodown[]\" size=\"3\" multiple=\"multiple\" class=\"smallfont\">
  $grpoptions
</select>
<center>&nbsp;&nbsp;<input type=\"Submit\" name=\"ok\" value=\"ok - Group(s) Specify\">
</form>
</td><td class=\"tablea\" align=\"left\"><span class=\"smallfont\">
$glist3
</td>
</tr>

<tr>
<td class=\"tablea\" align=\"left\" width=\"40%\"><span class=\"smallfont\">
<form action=\"info_db.php?action=abedit&noheader=$noheader&sid=$session[hash]\" method=\"post\">
<span class=\"smallfont\">
&nbsp;Which Group(s) Can Have Access To Admin Section?&nbsp;
</td>
<td class=\"tablea\" align=\"left\"><span class=\"smallfont\">
&nbsp;&nbsp;Groups:&nbsp;
<select name=\"db_whoedit[]\" size=\"3\" multiple=\"multiple\" class=\"smallfont\">
  $grpoptions
</select>
<center>&nbsp;&nbsp;<input type=\"Submit\" name=\"ok\" value=\"ok - Group(s) Specify\">
</form>
</td><td class=\"tablea\" align=\"left\"><span class=\"smallfont\">
$glist4
</td>
</tr>

<tr>
<td class=\"tablea\" align=\"left\" width=\"40%\"><span class=\"smallfont\">
<form action=\"info_db.php?action=abedit&noheader=$noheader&sid=$session[hash]\" method=\"post\">
<span class=\"smallfont\">
&nbsp;Maximum Upload size specify:&nbsp;
</td>
<td class=\"tablea\" align=\"left\"><span class=\"smallfont\">
&nbsp;KByte:&nbsp;
<input class=\"input\" type=\"text\" name=\"dbmaxup\" value=\"$dbkdata[db_maxup]\" SIZE=4 MAXLENGTH=11>
<input type=\"Submit\" name=\"ok\" value=\"ok\">
</form>
</td>
<td class=\"tablea\" align=\"left\"><span class=\"smallfont\">&nbsp;</td>
</tr>


<tr>
<td class=\"tablea\" align=\"left\" width=\"40%\"><span class=\"smallfont\">
<form action=\"info_db.php?action=abedit\" method=\"post\">
<span class=\"smallfont\">
&nbsp;Downloads new count over, in order to update announcement. &nbsp;<br>
&nbsp;Can be necessary, with by hand deleted files.<br>
<font color=\"#FF0000\">$upgedated</font>
</td>
<td class=\"tablea\" align=\"left\"><span class=\"smallfont\">
&nbsp;&nbsp;Count:&nbsp;
<input type=\"Checkbox\" name=\"db_updt\" value=\"1\">&nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"Submit\" name=\"ok\" value=\"ok\">&nbsp;&nbsp;&nbsp;&nbsp;
</form>
</td>
<td class=\"tablea\" align=\"left\"><span class=\"smallfont\">&nbsp;</td>
</tr>

</table>
<p>
";}


$kats.="<tr>
<td class=\"tablea\" align=\"center\" colspan=\"2\"><span class=\"smallfont\">!! In order for this to save thier has to be at least 1 catagory listed !!</td></tr>";

$kats.="
<tr>
<td class=\"tablea\" align=\"center\" colspan=\"2\"><span class=\"smallfont\"><a href=\"info_db.php?action=amenu&noheader=$noheader&sid=$session[hash]\"><b>Catagories/Sub-Catagories</b></a><br>
<a href=\"info_db.php?action=fileedit&noheader=$noheader&sid=$session[hash]\"><b>Downloads/Links Delete/Reorder/Regroup</b></a></td></tr>
</table><br>";

eval ("\$ifooter = \"".$tpl->get("index_db_footer")."\";");
eval("\$tpl->output(\"".$tpl->get("index_db")."\");");


exit();}
}
#################################################
if($action=="filesave"){
if($noheader=="1"){$header="$headinclude";}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$arrange=$whoedit;
foreach ($groupids as $be){
$pos = (strstr($arrange,$be));
if ($pos=='') {$allower=0;continue;}
if ($pos<>'') {$allower=1;$hit=" $be ";break;}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

# +++++++++++++++++++++++++ guest ++++++++++++++++++++++++++ #
if($allower==1){
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

if($db_del>'0'){
list($filenr)=$db->query_first("SELECT db_data_nr FROM bb".$n."_info_db_data
WHERE db_d_id='$db_d_id'");
$db->query("DELETE FROM bb".$n."_info_db_data WHERE db_d_id='$db_d_id'");$db_del='';
@chmod ("./info_db/$filenr", 0777);
@unlink("./info_db/$filenr");
$db->query("UPDATE bb".$n."_info_db_id SET db_count='0'");
$updc=$db->query("SELECT db_d_id,db_data_subkatid FROM bb".$n."_info_db_data ORDER BY db_d_id ASC");
while($dbu=$db->fetch_array($updc)){
$db->query("UPDATE bb".$n."_info_db_id SET db_count=db_count+1 WHERE db_sub_katid='$dbu[db_data_subkatid]'");
}
$hpdc=$db->query("SELECT db_data_subkatid,db_update FROM bb".$n."_info_db_data ORDER BY db_update DESC LIMIT 1");
while($dlsdata=$db->fetch_array($hpdc))
{$hpdlc=$dlsdata[db_update];$hpdcc=$dlsdata[db_data_subkatid];}
$hpdlf=$hpdlc-3600;
$db->query("UPDATE bb".$n."_info_db_id SET db_up_date='$hpdlf' WHERE db_up_date>'$hpdlc'");
$db->query("UPDATE bb".$n."_info_db_id SET db_up_date='$hpdlc' WHERE db_sub_katid='$hpdcc'");
}


$db->query("UPDATE bb".$n."_info_db_data SET db_data_name='".addslashes($db_data_name)."',db_data_desc='".addslashes($db_data_desc)."',db_data_subkatid='$db_data_subkatid' WHERE db_d_id='$db_d_id'");


list($db_count)=$db->query_first("SELECT count(db_d_id) FROM bb".$n."_info_db_data WHERE db_data_subkatid='$db_data_subkatid'");

$db->query("UPDATE bb".$n."_info_db_id SET db_count='$db_count' WHERE db_sub_katid='$db_data_subkatid'");
}

header("Location: ./info_db.php?action=fileedit&noheader=$noheader&sid=$session[hash]");
exit();}
#################################################
if(($action=="usersave")&&($db_uploaderid=="$wbbuserdata[userid]")){
if($noheader=="1"){$header="$headinclude";}
$error=" <font color=\"#008000\">- OK, gespeichert -</font> ";
### Link
if($link==1){
if($db_del==1){
$db->query("DELETE FROM bb".$n."_info_db_data WHERE db_d_id='$db_d_id'");
$db->query("UPDATE bb".$n."_info_db_id SET db_count=db_count-1 WHERE db_sub_katid='$db_data_subkatid'");
header("Location: ./info_db.php?&sid=$session[hash]");exit();}
# ++++++++++++++++++++ Endungsprüfung ++++++++++++++++++++++ #
$lending=substr("$db_data_path",-3,3);
$end_ids=explode(",",$db_end);$arrz=count($end_ids);
for ($i = 1;;$i++) {if ($i > $arrz) {break;}
$be = array_shift ($end_ids);
if($lending==$be){$isnot=1;break;}
else{$isnot=0;}}
if($isnot==0){$error="- Falsche Dateiendung (<b>$lending</b>) der verlinkten File! -";stripcslashes($db_data_name);stripcslashes($db_data_desc);stripcslashes($db_data_link);
header("Location: ./info_db.php?action=useredit&error=$error&noheader=$noheader&db_data_path=$db_data_path&db_d_id=$db_d_id&db_uploaderid=$db_uploaderid&sid=$session[hash]");
exit();}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$db->query("UPDATE bb".$n."_info_db_data SET
db_data_name='".addslashes($db_data_name)."',
db_data_kb='$db_data_kb',
db_data_path='".addslashes($db_data_path)."',
db_data_desc='".addslashes($db_data_desc)."'
WHERE db_d_id='$db_d_id'");
}
### Datei
if($link<>1){
if($db_del==1){
$db->query("DELETE FROM bb".$n."_info_db_data WHERE db_d_id='$db_d_id'");
$db->query("UPDATE bb".$n."_info_db_id SET db_count=db_count-1 WHERE db_sub_katid='$db_data_subkatid'");
@chmod ("./info_db/$db_data_nr", 0777);@unlink("./info_db/$db_data_nr");
header("Location: ./info_db.php?&sid=$session[hash]");exit();}
$db->query("UPDATE bb".$n."_info_db_data SET
db_data_name='".addslashes($db_data_name)."',
db_data_desc='".addslashes($db_data_desc)."'
WHERE db_d_id='$db_d_id'");
}

header("Location: ./info_db.php?action=useredit&db_uploaderid=$db_uploaderid&noheader=$noheader&db_d_id=$db_d_id&sid=$session[hash]&error=$error");
exit();}
#################################################
if($action=="userupedit"){
if($noheader=="1"){$header="$headinclude";}
if($db_uploaderid=="$wbbuserdata[userid]"){
if(!is_uploaded_file($db_file)){$error="- Upload fehlgschlagen, evtl. sind Reg.Globals auf OFF ! -";stripcslashes($db_data_name);stripcslashes($db_data_desc);stripcslashes($db_data_link);
header("Location: ./info_db.php?action=newup&error=$error&noheader=$noheader&db_data_nr=$db_data_nr&db_d_id=$db_d_id&db_uploaderid=$db_uploaderid&sid=$session[hash]");
exit();}
$db_file_name=strtolower($db_file_name);
# ++++++++++++++++++++ Endungsprüfung ++++++++++++++++++++++ #
$lending=substr("$db_file_name",-3,3);
$end_ids=explode(",",$db_dend);$arrz=count($end_ids);
for ($i = 1;;$i++) {if ($i > $arrz) {break;}
$be = array_shift ($end_ids);
if($lending==$be){$isnot=1;break;}
else{$isnot=0;}}
if($isnot==0){$error="- Falsche Dateiendung (<b>$lending</b>) oder keine File ausgewählt! -";stripcslashes($db_data_name);stripcslashes($db_data_desc);stripcslashes($db_data_link);
header("Location: ./info_db.php?action=newup&error=$error&noheader=$noheader&db_data_nr=$db_data_nr&db_d_id=$db_d_id&db_uploaderid=$db_uploaderid&sid=$session[hash]");
exit();}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #


@chmod ("./info_db/$db_data_nr", 0777);
@unlink("./info_db/$db_data_nr");

$time=time();$nowtime=substr("$time",-4,4);
if(is_uploaded_file($db_file)){
$filesize=filesize($db_file);$dbmax=$db_maxup*1000;
if($filesize>$dbmax){$error="- File zu groß - maximal $db_maxup KB ! -";
header("Location: ./info_db.php?action=newup&error=$error&noheader=$noheader&db_data_nr=$db_data_nr&db_d_id=$db_d_id&sid=$session[hash]");
exit();}
$oldname=$db_file_name;
$db_file_name=$nowtime."_$db_file_name";
move_uploaded_file($db_file,"./info_db/$db_file_name");
chmod ("./info_db/$db_file_name", 0775);}
$filesize=$filesize/1000;$filesize=round($filesize,0);

$db->query("UPDATE bb".$n."_info_db_data SET db_data_nr='$db_file_name',db_data_kb='$filesize',db_update='$time' WHERE db_d_id='$db_d_id'");

header("Location: ./info_db.php?action=useredit&noheader=$noheader&db_d_id=$db_d_id&db_uploaderid=$db_uploaderid&sid=$session[hash]");
exit();}}
#################################################
if($action=="newup"){
if($noheader=="1"){$header="$headinclude";}
if($db_uploaderid=="$wbbuserdata[userid]"){
$kats.="
<table cellpadding=\"{$style['tableincellpadding']}\" cellspacing=\"{$style['tableincellspacing']}\" border=\"{$style['tableinborder']}\" width=\"100%\" class=\"tableinborder\">
<form action=\"info_db.php?action=userupedit&sid=$session[hash]\" method=\"post\" enctype=\"multipart/form-data\">
<tr>
<td class=\"tablea\" align=\"center\" width=\"100%\" colspan=\"2\"><span class=\"smallfont\">
&nbsp;<font color=\"#FF0000\">$error</font color>
</td></tr>";


$kats.="
<!--                            FILE UPLOAD                                   -->
<tr>
<td class=\"tablea\" align=\"left\" width=\"40%\"><span class=\"smallfont\">
Laden Sie erneut eine <b>File</b> hoch (die alte wird gelöscht):<br>&nbsp;<br>
(Nur&nbsp;&nbsp;<b>$db_dend</b>&nbsp;&nbsp;sind erlaubt!)<br>&nbsp;
</td>
<td class=\"tablea\" align=\"left\" width=\"60%\"><span class=\"smallfont\">
<input name=\"db_file\" type=\"file\" size=\"50\">

<!--                           /FILE UPLOAD                                   -->
<p>
<input type=\"hidden\" name=\"db_uploaderid\" value=\"$db_uploaderid\">
<input type=\"hidden\" name=\"db_d_id\" value=\"$db_d_id\">
<input type=\"hidden\" name=\"db_data_nr\" value=\"$db_data_nr\">
<input type=\"Submit\" name=\"ok\" value=\"uploaden\"></p>
</td></tr></form></table>";

eval ("\$ifooter = \"".$tpl->get("index_db_footer")."\";");
eval("\$tpl->output(\"".$tpl->get("index_db")."\");");
exit();}}
#################################################
if($action=="useredit"){
if($noheader=="1"){$header="$headinclude";}
if($db_uploaderid=="$wbbuserdata[userid]"){
$hauptkatname="Download Edit";
### File Liste ###
$kats.="<table cellpadding=\"{$style['tableincellpadding']}\" cellspacing=\"{$style['tableincellspacing']}\" border=\"{$style['tableinborder']}\" width=\"100%\" class=\"tableinborder\">";

$dbkatname = $db->query("SELECT * FROM bb".$n."_info_db_data WHERE ((db_d_id='$db_d_id')&&(db_uploaderid='$wbbuserdata[userid]')) ORDER BY db_data_name ASC");
while($dbkdata=$db->fetch_array($dbkatname)){
list($db_subkatname)=$db->query_first("SELECT db_subkatname FROM bb".$n."_info_db_id WHERE db_sub_katid='$dbkdata[db_data_subkatid]'"); $orlink="&nbsp;<b>File</b>";
if($dbkdata[db_data_ext]==1)$orlink="&nbsp;Link";
$dbkdata[db_data_name]=stripcslashes($dbkdata[db_data_name]);
$dbkdata[db_data_desc]=stripcslashes($dbkdata[db_data_desc]);
$db_subkatname=stripcslashes($db_subkatname);
$freen="";

$kats.="
<tr>
<form action=\"info_db.php?action=usersave&noheader=$noheader&db_d_id=$db_d_id&link=$dbkdata[db_data_ext]&db_uploaderid=$dbkdata[db_uploaderid]&db_data_nr=$dbkdata[db_data_nr]&sid=$session[hash]\" method=\"post\">
<td class=\"tablea\" align=\"left\" width=\"32%\"><span class=\"smallfont\" nowrap>
 Name: <input class=\"input\" type=\"text\" name=\"db_data_name\" value=\"$dbkdata[db_data_name]\" SIZE=48 MAXLENGTH=64>";

if($dbkdata[db_data_ext]<>1){$kats.="<br>KB: $dbkdata[db_data_kb]<br>&nbsp;<br>$orlink: $dbkdata[db_data_nr]";}
if($dbkdata[db_data_ext]==1){$kats.="<br>KB: <input class=\"input\" type=\"text\" name=\"db_data_kb\" value=\"$dbkdata[db_data_kb]\" SIZE=4 MAXLENGTH=9><br>&nbsp;<br>$orlink: <input class=\"input\" type=\"text\" name=\"db_data_path\" value=\"$dbkdata[db_data_path]\" SIZE=48 MAXLENGTH=128><p>
Nur&nbsp;&nbsp;&nbsp;<b>$db_end</b>&nbsp;&nbsp;&nbsp;sind erlaubt!</p>";}

$kats.="<p>$error</p></td><td class=\"tablea\" align=\"left\" width=\"30%\"><span class=\"smallfont\" nowrap> Description:<br> <textarea name=\"db_data_desc\" rows=\"10\" cols=\"45\">$dbkdata[db_data_desc]</textarea><br>Downloads: $dbkdata[db_data_downs]</td>
<td class=\"tablea\" align=\"center\" width=\"23%\"><span class=\"smallfont\" nowrap>
in Catagory: <b>$db_subkatname</b> </td>
<td class=\"tablea\" align=\"center\" width=\"13%\"><span class=\"smallfont\" nowrap>
Delete?: <br><input type=\"Checkbox\" name=\"db_del\" value=\"1\">
<input type=\"hidden\" name=\"db_d_id\" value=\"$dbkdata[db_d_id]\">
<input type=\"hidden\" name=\"db_data_subkatid\" value=\"$dbkdata[db_data_subkatid]\">
<p>
<input type=\"Submit\" name=\"ok\" value=\"Save\"></p>
</td>
</form>
</tr>
";

if($dbkdata[db_data_ext]<>1){$kats.="
<tr><td class=\"tablea\" align=\"center\" colspan=\"4\"><span class=\"smallfont\"><a href=\"info_db.php?action=newup&noheader=$noheader&db_d_id=$db_d_id&db_uploaderid=$dbkdata[db_uploaderid]&db_data_nr=$dbkdata[db_data_nr]&sid=$session[hash]\">Nur File new uploaden</a></td></tr>
</table><br>";}

if($dbkdata[db_data_ext]==1){$kats.="
<tr><td class=\"tablea\" align=\"center\" colspan=\"4\"><span class=\"smallfont\">&nbsp;</td></tr>
</table><br>";}
}}
eval ("\$ifooter = \"".$tpl->get("index_db_footer")."\";");
eval("\$tpl->output(\"".$tpl->get("index_db")."\");");
exit();}
#################################################
if($action=="fileedit"){
if($noheader=="1"){$header="$headinclude";}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$arrange=$whoedit;
foreach ($groupids as $be){
$pos = (strstr($arrange,$be));
if ($pos=='') {$allower=0;continue;}
if ($pos<>'') {$allower=1;$hit=" $be ";break;}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

# +++++++++++++++++++++++++ guest ++++++++++++++++++++++++++ #
if($allower==1){
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$hauptkatname="Downloads Edit";
### SubKats ###
$dbsubkatname = $db->query("SELECT db_sub_katid,db_subkatname FROM bb".$n."_info_db_id WHERE db_parent_id>0 ORDER BY db_parent_id,db_order ASC");
while($dbsdata=$db->fetch_array($dbsubkatname)) {
$katlist.="<tr><td class=\"tablea\" align=\"left\"><span class=\"smallfont\" nowrap width=\"40%\">$dbsdata[db_subkatname]</td><td class=\"tablea\" align=\"left\"><span class=\"smallfont\" nowrap>&nbsp;&nbsp;ID: <b>$dbsdata[db_sub_katid]</b></td></tr>";
}

$kats.="<table cellpadding=\"{$style['tableincellpadding']}\" cellspacing=\"{$style['tableincellspacing']}\" border=\"{$style['tableinborder']}\" width=\"100%\" class=\"tableinborder\">
<tr>
<td class=\"tablecat\" align=\"left\"><span class=\"smallfont\"><b>&nbsp;Downloads</b> - Downloads</td></tr>
";
$kats.="</table><br>";

### Kat Liste ###
$kats.="
<table cellpadding=\"{$style['tableincellpadding']}\" cellspacing=\"{$style['tableincellspacing']}\" border=\"{$style['tableinborder']}\" width=\"100%\" class=\"tableinborder\">
<tr>
<td class=\"tablea\" align=\"left\"><span class=\"smallfont\" nowrap>
&nbsp;<b>Sub-Catagories and IDs:</b></td></tr>
<tr><td class=\"tablea\" align=\"left\"><span class=\"smallfont\" nowrap>
<table>$katlist</table>
</td></tr></table><br>";

$kats.="
<table cellpadding=\"{$style['tableincellpadding']}\" cellspacing=\"{$style['tableincellspacing']}\" border=\"{$style['tableinborder']}\" width=\"100%\" class=\"tableinborder\">";

$dbkatname = $db->query("SELECT * FROM bb".$n."_info_db_data ORDER BY db_data_name ASC");
while($dbkdata=$db->fetch_array($dbkatname)){
list($db_subkatname)=$db->query_first("SELECT db_subkatname FROM bb".$n."_info_db_id WHERE db_sub_katid='$dbkdata[db_data_subkatid]'"); $orlink="&nbsp;<b>File</b>";
if($dbkdata[db_data_ext]==1)$orlink="&nbsp;Link";
$dbkdata[db_data_name]=stripcslashes($dbkdata[db_data_name]);
$dbkdata[db_data_desc]=stripcslashes($dbkdata[db_data_desc]);$freen="";
if($dbkdata[db_proof_ok]==0){$freen="<a href=\"info_db.php?action=free\"><font color=\"#FF0000\">disconnect</a></font>";}
### File Liste ###
$kats.="
<tr>
<form action=\"info_db.php?action=filesave&noheader=$noheader&sid=$session[hash]\" method=\"post\">
<td class=\"tablea\" align=\"left\" width=\"32%\"><span class=\"smallfont\" nowrap>
 $orlink: <input class=\"input\" type=\"text\" name=\"db_data_name\" value=\"$dbkdata[db_data_name]\" SIZE=32 MAXLENGTH=64>&nbsp;&nbsp;KB: $dbkdata[db_data_kb]
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$freen</td>
<td class=\"tablea\" align=\"left\" width=\"30%\"><span class=\"smallfont\" nowrap>
 Description:<br> <textarea name=\"db_data_desc\" rows=\"10\" cols=\"45\">$dbkdata[db_data_desc]</textarea><br>Downloads: $dbkdata[db_data_downs]</td>
<td class=\"tablea\" align=\"left\" width=\"23%\"><span class=\"smallfont\" nowrap>
ID: <input class=\"input\" type=\"text\" name=\"db_data_subkatid\" value=\"$dbkdata[db_data_subkatid]\" SIZE=2 MAXLENGTH=3> in Catagory: $db_subkatname </td>
<td class=\"tablea\" align=\"left\" width=\"13%\"><span class=\"smallfont\" nowrap>
Delete: <input type=\"Checkbox\" name=\"db_del\" value=\"1\">
<input type=\"hidden\" name=\"db_d_id\" value=\"$dbkdata[db_d_id]\">
<input type=\"hidden\" name=\"filenr\" value=\"$dbkdata[db_filenr]\">
<input type=\"Submit\" name=\"ok\" value=\"ok\">
</td>
</form>
</tr>
";

}
$kats.="
<tr>
<td class=\"tablea\" align=\"center\" colspan=\"4\"><span class=\"smallfont\"><a href=\"info_db.php?action=amenu&noheader=$noheader&sid=$session[hash]\"><b>Catagories/Sub-Catagories</b></a><br>
<a href=\"info_db.php?action=bmenu&noheader=$noheader&sid=$session[hash]\"><b>Mis. Permissions</b></a></td></tr>
</table><br>";
}
eval ("\$ifooter = \"".$tpl->get("index_db_footer")."\";");
eval("\$tpl->output(\"".$tpl->get("index_db")."\");");
exit();}
#################################################
if($action=="newend"){
if($noheader=="1"){$header="$headinclude";}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$arrange=$whoedit;
foreach ($groupids as $be){
$pos = (strstr($arrange,$be));
if ($pos=='') {$allower=0;continue;}
if ($pos<>'') {$allower=1;$hit=" $be ";break;}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

# +++++++++++++++++++++++++ guest ++++++++++++++++++++++++++ #
if($allower==1){
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

$db->query("UPDATE bb".$n."_info_db_id SET db_end='$db_endn',db_dend='$db_dendn' WHERE db_id='1'");
header("Location: ./info_db.php?action=amenu&noheader=$noheader&sid=$session[hash]");
exit();
}}
#################################################
if($action=="katsend"){
if($noheader=="1"){$header="$headinclude";}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$arrange=$whoedit;
foreach ($groupids as $be){
$pos = (strstr($arrange,$be));
if ($pos=='') {$allower=0;continue;}
if ($pos<>'') {$allower=1;$hit=" $be ";break;}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

# +++++++++++++++++++++++++ guest ++++++++++++++++++++++++++ #
if($allower==1){
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

if($katchange==1){
$db->query("UPDATE bb".$n."_info_db_id SET db_order='$order',db_katname='".addslashes($hkatname)."' WHERE db_id='$db_id'");
$katchange='';}

if(($delkat>'0')&&($db_id>1)){
$db->query("DELETE FROM bb".$n."_info_db_id WHERE db_id='$db_id'");$delkat='';
}

if($neukatname==1){
list($howmany)=$db->query_first("SELECT count(db_katid) FROM bb".$n."_info_db_id WHERE
db_katid>'0'");$howmany=$howmany+1;
$db->query("INSERT INTO bb".$n."_info_db_id SET db_katname='".addslashes($newkatname)."',db_katid='$howmany',db_order='$neworder',db_parent_id='0',db_erlgrp='4'");
$neukatname='';
}

### subkats ###

if($subkatchange==1){
$db->query("UPDATE bb".$n."_info_db_id SET db_order='$suborders',db_subkatname='".addslashes($subkatname)."',db_desc='".addslashes($dbndesc)."',db_parent_id='$skatid' WHERE db_id='$db_id'");   $subkatchange='';
}

/*
if($skatid>'0'){
$db->query("UPDATE bb".$n."_info_db_id SET db_parent_id='$skatid' WHERE db_id='$db_id'");
$skatid='';
}
*/

if($subdelskat>'0'){
$db->query("DELETE FROM bb".$n."_info_db_id WHERE db_id='$db_id'");$subdelskat='';
}

if($newsub=="1"){
list($howmany)=$db->query_first("SELECT count(db_sub_katid) FROM bb".$n."_info_db_id WHERE
db_sub_katid>'0'");$howmany=$howmany+1;
$db->query("INSERT INTO bb".$n."_info_db_id SET db_subkatname='".addslashes($newsubkatname)."',db_sub_katid='$howmany',db_order='$newsuborder',db_parent_id='$hauptkatid',db_desc='".addslashes($dbndesc)."'"); $newsub='';
}

}
header("Location: ./info_db.php?action=amenu&noheader=$noheader&sid=$session[hash]");
exit();}
#################################################
if($action=="grantsave"){
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$arrange=$whoedit;
foreach ($groupids as $be){
$pos = (strstr($arrange,$be));
if ($pos=='') {$allower=0;continue;}
if ($pos<>'') {$allower=1;$hit=" $be ";break;}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

# +++++++++++++++++++++++++ guest ++++++++++++++++++++++++++ #
if($allower==1){
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$db_dtime=$db_dtime*60;
$db->query("UPDATE bb".$n."_info_db_id SET db_dtime='$db_dtime',db_dist='$db_dist' WHERE db_id='$db_id'");
header("Location: ./info_db.php?action=grant&noheader=$noheader&sid=$session[hash]");
}
exit();
}
#################################################
if($action=="grant"){
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$arrange=$whoedit;
foreach ($groupids as $be){
$pos = (strstr($arrange,$be));
if ($pos=='') {$allower=0;continue;}
if ($pos<>'') {$allower=1;$hit=" $be ";break;}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

# +++++++++++++++++++++++++ guest ++++++++++++++++++++++++++ #
if($allower==1){
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$katliste.="<table cellpadding=\"{$style['tableincellpadding']}\" cellspacing=\"{$style['tableincellspacing']}\" border=\"{$style['tableinborder']}\" style=\"width:100%\" class=\"tableinborder\"><tr><td class=\"tablea\" align=\"center\" colspan=\"3\"><span class=\"smallfont\" nowrap>
enter 0 to disable time limit</td></tr>";
$dbsubkatname = $db->query("SELECT * FROM bb".$n."_info_db_id WHERE db_parent_id>0 ORDER BY db_parent_id,db_order ASC");
while($dbsdata=$db->fetch_array($dbsubkatname)) {
list($dbs_katname)=$db->query_first("SELECT db_katname FROM bb".$n."_info_db_id WHERE db_katid='$dbsdata[db_parent_id]'");
$db_subkatname=stripcslashes($dbsdata[db_subkatname]);
$dbsdata[db_desc]=stripcslashes($dbsdata[db_desc]);$db_id=$dbsdata[db_id];
$db_dtime=$dbsdata[db_dtime]/60;
### Subkats ###
$katliste.="
<tr>
<form action=\"info_db.php?action=grantsave&noheader=$noheader&sid=$session[hash]\" method=\"post\">
<td class=\"tablea\" align=\"left\"><span class=\"smallfont\" nowrap>
<span class=\"smallfont\">&nbsp;Sub Catagory Name: &nbsp;&nbsp;<b>$db_subkatname</b></td>
<td class=\"tablea\" align=\"left\"><span class=\"smallfont\" nowrap>
Enable Max Number of downloads:
<input class=\"input\" type=\"text\" name=\"db_dist\" value=\"$dbsdata[db_dist]\" SIZE=3 MAXLENGTH=3></td>
<td class=\"tablea\" align=\"left\"><span class=\"smallfont\" nowrap>
Input Timeout:<br />(Number of Minutes to wait After the Download max has been reached) &nbsp;
<input class=\"input\" type=\"text\" name=\"db_dtime\" value=\"$db_dtime\" SIZE=3 MAXLENGTH=3> Minutes &nbsp;
<input type=\"hidden\" name=\"db_id\" value=\"$db_id\">
<input type=\"Submit\" name=\"ok\" value=\"ok\">
&nbsp;</b><br />in: <b>$dbs_katname</b></td> </form>
";}

$katliste.="
<tr>
<td class=\"tablea\" align=\"center\" colspan=\"3\"><span class=\"smallfont\">&nbsp;<br /><a href=\"info_db.php?action=amenu&noheader=$noheader&sid=$session[hash]\"><b>Downloads/Links Delete/Rename/Regroup</a><br />&nbsp;</tr></td>
</table>";
eval ("\$getkats = \"".$tpl->get("index_db_getkats")."\";");
eval ("\$ifooter = \"".$tpl->get("index_db_footer")."\";");
eval("\$tpl->output(\"".$tpl->get("index_db")."\");");

}
exit();
}

#################################################
if($action=="amenu"){
if($noheader=="1"){$header="$headinclude";}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$arrange=$whoedit;
foreach ($groupids as $be){
$pos = (strstr($arrange,$be));
if ($pos=='') {$allower=0;continue;}
if ($pos<>'') {$allower=1;$hit=" $be ";break;}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

# +++++++++++++++++++++++++ guest ++++++++++++++++++++++++++ #
if($allower==1){
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$hauptkatname="Database Admin Menü";
list($freecount)=$db->query_first("SELECT count(db_d_id) FROM bb".$n."_info_db_data WHERE db_proof_ok='0'");
$kats.="<table cellpadding=\"{$style['tableincellpadding']}\" cellspacing=\"{$style['tableincellspacing']}\" border=\"{$style['tableinborder']}\" width=\"100%\" class=\"tableinborder\">
<tr>
<td class=\"tablecat\" align=\"left\"><span class=\"smallfont\"><b>&nbsp;Downloads</b> - Catagories & Sub-Catagories</td></tr>
<tr>
<td class=\"tablea\" align=\"center\"><span class=\"smallfont\">When you create a Catagory you will have to set the permissions for it.</td></tr>
";

$kats.="</table><br>";

$dbkatname = $db->query("SELECT db_id,db_katid,db_katname,db_order FROM bb".$n."_info_db_id WHERE db_katid>0 ORDER BY db_order ASC");
while($dbkdata=$db->fetch_array($dbkatname)){
$ka++;$db_id=$dbkdata[db_id];
$katname=stripcslashes($dbkdata[db_katname]);
$katid=$dbkdata[db_katid];
$order=$dbkdata[db_order];
$optname .= makeoption($katid,$katname,0);

### Hauptkats ###
$katliste.="<form action=\"info_db.php?action=katsend&noheader=$noheader&sid=$session[hash]\" method=\"post\"><span class=\"smallfont\">&nbsp;Change Catagory Name: &nbsp;<input class=\"input\" type=\"text\" name=\"hkatname\" value=\"$katname\" SIZE=32 MAXLENGTH=32>&nbsp;&nbsp; Order: <input class=\"input\" type=\"text\" name=\"order\" value=\"$order\" SIZE=2 MAXLENGTH=3>
&nbsp;&nbsp;";
if($db_id>1){
$katliste.="delete: <input class=\"input\" type=\"Checkbox\" name=\"delkat\" value=\"1\">&nbsp;&nbsp;&nbsp;&nbsp;";}
else{$katliste.="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";}
$katliste.="<input type=\"hidden\" name=\"db_id\" value=\"$db_id\">
<input type=\"hidden\" name=\"katchange\" value=\"1\">";

$katliste.="<input type=\"Submit\" name=\"ok\" value=\"ok\">";


$katliste.="&nbsp;&nbsp;<b>= ID:  $katid</b>
</form>
";}


### Neue Hauptkat ###
$katliste.="<p><form action=\"info_db.php?action=katsend&noheader=$noheader&sid=$session[hash]\" method=\"post\"><span class=\"smallfont\">
Add a new Catagory: <input class=\"input\" type=\"text\" name=\"newkatname\" value=\"$newkatname\" SIZE=32 MAXLENGTH=32>&nbsp;&nbsp; Order: <input class=\"input\" type=\"text\" name=\"neworder\" value=\"$neworder\" SIZE=2 MAXLENGTH=3>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"hidden\" name=\"neukatname\" value=\"1\">
<input type=\"Submit\" name=\"ok\" value=\"new\"></form>
</td></tr>
<tr>
<td class=\"tablea\" align=\"center\"><span class=\"smallfont\">When a Sub-Catagory is deleted, all downloads in it are lost. Please regroup before deleting!</td></tr>
";


$katliste.="
<tr>
<td class=\"tablea\" align=\"left\"><span class=\"smallfont\" nowrap>";
$dbsubkatname = $db->query("SELECT db_id,db_katid,db_katname,db_order,db_subkatname,db_parent_id,db_desc FROM bb".$n."_info_db_id WHERE db_parent_id>0 ORDER BY db_parent_id,db_order ASC");
while($dbsdata=$db->fetch_array($dbsubkatname)) {
list($dbs_katname)=$db->query_first("SELECT db_katname FROM bb".$n."_info_db_id WHERE db_katid='$dbsdata[db_parent_id]'");
$db_subkatname=stripcslashes($dbsdata[db_subkatname]);
$dbsdata[db_desc]=stripcslashes($dbsdata[db_desc]);$db_id=$dbsdata[db_id];

### Subkats ###
$katliste.="
<form action=\"info_db.php?action=katsend&noheader=$noheader&sid=$session[hash]\" method=\"post\"><span class=\"smallfont\">
&nbsp;Change sub Catagory name: &nbsp;&nbsp;&nbsp;&nbsp;<input class=\"input\" type=\"text\" name=\"subkatname\" value=\"$db_subkatname\" SIZE=32 MAXLENGTH=32>&nbsp;&nbsp; Order: <input class=\"input\" type=\"text\" name=\"suborders\" value=\"$dbsdata[db_order]\" SIZE=2 MAXLENGTH=3>
&nbsp;&nbsp;delete: <input class=\"input\" type=\"Checkbox\" name=\"subdelskat\" value=\"1\">&nbsp;&nbsp;
Catagory(ID)&nbsp;<input class=\"input\" type=\"text\" name=\"skatid\" value=\"$dbsdata[db_parent_id]\" SIZE=2 MAXLENGTH=3>
&nbsp;Decription:&nbsp;
<input class=\"input\" type=\"text\" name=\"dbndesc\" value=\"$dbsdata[db_desc]\" SIZE=8 MAXLENGTH=256>
<input type=\"hidden\" name=\"subkatchange\" value=\"1\">
<input type=\"hidden\" name=\"db_id\" value=\"$db_id\">
<input type=\"Submit\" name=\"ok\" value=\"ok\">
&nbsp;</b>in&nbsp;<b>$dbs_katname</b></form>
";}

### Neue Subkat ###
$katliste.="<p>
<form action=\"info_db.php?action=katsend&noheader=$noheader&sid=$session[hash]\" method=\"post\"><span class=\"smallfont\">
New sub Catagory:<input class=\"input\" type=\"text\" name=\"newsubkatname\" value=\"$newsubkatname\" SIZE=32 MAXLENGTH=32>
&nbsp;&nbsp;Order: <input class=\"input\" type=\"text\" name=\"newsuborder\" value=\"$newsuborder\" SIZE=2 MAXLENGTH=3>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Catagory to be listed under (ID Number):&nbsp;
<input class=\"input\" type=\"text\" name=\"hauptkatid\" value=\"$hauptkatid\" SIZE=2 MAXLENGTH=3>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;Description:
<input class=\"input\" type=\"text\" name=\"dbndesc\" value=\"$dbndesc\" SIZE=148 MAXLENGTH=256>
&nbsp;&nbsp;
<input type=\"hidden\" name=\"newsub\" value=\"1\">
<input type=\"Submit\" name=\"new\" value=\"new\"></form><p>

<form action=\"info_db.php?action=newend&noheader=$noheader&sid=$session[hash]\" method=\"post\"><span class=\"smallfont\">
 Allow these file types to be uploaded: <input class=\"input\" type=\"text\" name=\"db_dendn\" value=\"$db_dend\" SIZE=38 MAXLENGTH=128>
&nbsp;&nbsp;&nbsp;&nbsp; Allow these file types to be linked: <input class=\"input\" type=\"text\" name=\"db_endn\" value=\"$db_end\" SIZE=46 MAXLENGTH=128>&nbsp;&nbsp;
<input type=\"Submit\" name=\"ok\" value=\"ok\"></form>

<br>&nbsp;</p>
</td></tr>
<tr>
<td class=\"tablea\" align=\"center\"><span class=\"smallfont\"><a href=\"info_db.php?action=fileedit&noheader=$noheader&sid=$session[hash]\"><b>Downloads/Links Delete/Reorder/Regroup</a><br /><a href=\"info_db.php?action=free&noheader=$noheader&sid=$session[hash]\">disconnect ($freecount)</a>
<br /><a href=\"info_db.php?action=grant&noheader=$noheader&sid=$session[hash]\">Download restrictions</b></a>
<br />
<a href=\"info_db.php?action=katgrant&noheader=$noheader&sid=$session[hash]\"><b>Catagory Permissions</b></a>
<br />
<a href=\"info_db.php?action=bmenu&noheader=$noheader&sid=$session[hash]\"><b>Mis. Permissions</b></a></td></tr>
</table>";



eval ("\$getkats = \"".$tpl->get("index_db_getkats")."\";");
eval ("\$ifooter = \"".$tpl->get("index_db_footer")."\";");
eval("\$tpl->output(\"".$tpl->get("index_db")."\");");


exit();}
}
#################################################
if($action=="kat"){
if($noheader=="1"){$header="$headinclude";}
list($dbnew) = $db->query_first("SELECT db_d_id FROM bb".$n."_info_db_data ORDER BY db_update DESC LIMIT 1");
$dbkatname = $db->query("SELECT db_parent_id,db_subkatname FROM bb".$n."_info_db_id
WHERE db_sub_katid=$subkatid");
while($dbkdata=$db->fetch_array($dbkatname)) {
$subkatname=$dbkdata[db_subkatname];$subkatname=stripcslashes($subkatname);
list($hauptkatname) = $db->query_first("SELECT db_katname FROM bb".$n."_info_db_id WHERE db_katid=$dbkdata[db_parent_id]");$hauptkatname=stripcslashes($hauptkatname);
}

$kats.="<table cellpadding=\"{$style['tableincellpadding']}\" cellspacing=\"{$style['tableincellspacing']}\" border=\"{$style['tableinborder']}\" style=\"width:100%\" class=\"tableinborder\">
<tr>
<td class=\"tablecat\" align=\"left\" colspan=\"4\"><span class=\"normalfont\"><b>&nbsp;$subkatname</b></td></tr>";

if($proof==0){$wenndann="AND db_proof_ok=1";}

$result = $db->query("SELECT * FROM bb".$n."_info_db_data WHERE db_data_subkatid=$subkatid $wenndann ORDER BY db_data_name ASC");
while($dbdata=$db->fetch_array($result)) {$new="";$db_data_name=stripslashes($dbdata[db_data_name]);
if($dbdata[db_d_id]==$dbnew){$new=" <font color=\"#FF0000\"> <sup>new</sup> </font color> ";}
$dbdata[db_update]=formatdate($wbbuserdata['dateformat'],$dbdata[db_update],1);
$kats.="<tr><td class=\"tablea\" align=\"left\" width=\"40%\">&nbsp;&nbsp;<a href=\"./info_db.php?action=file&fileid=$dbdata[db_d_id]&subkatid=$subkatid&noheader=$noheader&sid=$session[hash]\"><span class=\"smallfont\">$db_data_name</a> $new</td>
<td class=\"tablea\" align=\"center\" width=\"20%\">&nbsp;&nbsp;<span class=\"smallfont\">Uploader: $dbdata[db_uploader]</td>
<td class=\"tablea\" align=\"center\" width=\"20%\">&nbsp;&nbsp;<span class=\"smallfont\">When: $dbdata[db_update]</td>
<td class=\"tablea\" align=\"center\" width=\"20%\">&nbsp;&nbsp;<span class=\"smallfont\">Downloads: $dbdata[db_data_downs]</td>
</tr>
";

}
$kats.="</table><br>";

eval ("\$ifooter = \"".$tpl->get("index_db_footer")."\";");
eval("\$tpl->output(\"".$tpl->get("index_db")."\");");
exit();}
################################### downcount ###
if($action=="downcount"){$hauptkatname="File - Download";
if($noheader=="1"){$header="$headinclude";}
$db->query("UPDATE bb".$n."_info_db_data SET db_data_downs=db_data_downs+1 WHERE db_d_id = '$fileid'");
$dfilename=stripslashes($dfilename);
$dfilename=stripslashes($dfilename);
$kats.="
<tr>
<td class=\"tablea\" align=\"center\" width=\"90%\" height=\"50\"> </td>
</tr>
<tr>
<td class=\"tablea\" align=\"center\" width=\"90%\"><span class=\"smallfont\">

<a href=\"info_db.php?action=downnow&fileid=$fileid&noheader=$noheader&sid=$session[hash]\" target=\"blank\">Download: <b> $dfilename</b></a>

</td>
</tr>
<tr>
<td class=\"tablea\" align=\"center\" width=\"90%\" height=\"50\"> </td>
</tr>
<tr>
<td class=\"tablea\" align=\"center\" width=\"90%\"><span class=\"smallfont\">
<a href=\"./info_db.php?&noheader=$noheader&sid=$session[hash]\"><b>Go Back</b></a></td>
</tr>
";
list($subkatid)=$db->query_first("SELECT db_data_subkatid FROM bb".$n."_info_db_data WHERE db_d_id = '$fileid'");
$db->query("UPDATE bb".$n."_info_db_id SET db_danz=db_danz+1 WHERE db_sub_katid='$subkatid'");
eval ("\$ifooter = \"".$tpl->get("index_db_footer")."\";");
eval("\$tpl->output(\"".$tpl->get("index_db")."\");");
exit();}
#################################################
if($action=="downnow"){
if($noheader=="1"){$header="$headinclude";}
$result = $db->query("SELECT * FROM bb".$n."_info_db_data WHERE db_d_id=$fileid");
while($dbdata=$db->fetch_array($result)) {
$filenr=$dbdata[db_data_nr];$normpath="./info_db/";
if($dbdata[db_data_ext]==1){$filenr=stripcslashes($dbdata[db_data_path]);$normpath="";}

header("Location: $normpath$filenr");

}

exit();}
#################################################
if($action=="file"){
if($noheader=="1"){$header="$headinclude";}
list($dbnew) = $db->query_first("SELECT db_d_id FROM bb".$n."_info_db_data ORDER BY db_update DESC LIMIT 1");
$dbkatname = $db->query("SELECT * FROM bb".$n."_info_db_id WHERE db_sub_katid='$subkatid'");
while($dbkdata=$db->fetch_array($dbkatname)) {
$subkatname=$dbkdata[db_subkatname];$db_parent_id=$dbkdata[db_parent_id];
}
$subkatname=stripcslashes($subkatname);
list($hauptkatname)=$db->query_first("SELECT db_katname FROM bb".$n."_info_db_id WHERE db_katid='$db_parent_id'");
$hauptkatname=stripcslashes($hauptkatname);

$nowtime=time();

$db_dtime=$whois[db_dtime];$db_ntime=$whois[db_ntime];$db_danz=$whois[db_danz];$db_dist=$whois[db_dist];$db_erlgrp=$whois[db_erlgrp];$nowtime=time();

$kats.="<table cellpadding=\"{$style['tableincellpadding']}\" cellspacing=\"{$style['tableincellspacing']}\" border=\"{$style['tableinborder']}\" style=\"width:100%\" class=\"tableinborder\">
<tr>
<td class=\"tablecat\" align=\"left\" colspan=\"4\"><span class=\"normalfont\"><b>&nbsp;<a href=\"./info_db.php?action=kat&subkatid=$subkatid&noheader=$noheader\">$subkatname</a></b></td></tr>";



$result = $db->query("SELECT * FROM bb".$n."_info_db_data WHERE db_d_id=$fileid");
while($dbdata=$db->fetch_array($result)) {$new="";
$filenr=$dbdata[db_data_nr];$normpath="./info_db/";
$db_uploaderid=$dbdata[db_uploaderid];$db_d_id=$dbdata[db_d_id];
/*
### Automatisches "anhängen" eines Support-Forums, muss manuell eingestellt werden! ####
if($dbdata[db_data_subkatid]==1)$supforum="<br /> <a href=\"./board.php?boardid=19&sid=$session[hash]\">- Supportforum -</a>";
if($dbdata[db_data_subkatid]==2)$supforum="<br /> <a href=\"./board.php?boardid=19&sid=$session[hash]\">- Supportforum -</a>";
if($dbdata[db_data_subkatid]==3)$supforum="<br /> <a href=\"./board.php?boardid=15&sid=$session[hash]\">- Supportforum -</a>";
if($dbdata[db_data_subkatid]==4)$supforum="<br /> <a href=\"./board.php?boardid=15&sid=$session[hash]\">- Supportforum -</a>";
if($dbdata[db_data_subkatid]==5)$supforum="<br /> <a href=\"./board.php?boardid=68&sid=$session[hash]\">- Supportforum -</a>";
if($dbdata[db_data_subkatid]==6)$supforum="<br /> <a href=\"./board.php?boardid=68&sid=$session[hash]\">- Supportforum -</a>";
########################################################################################
*/

$parse = new parse($docensor,75,1);
$dbdata[db_data_desc]=$parse->doparse($dbdata[db_data_desc],1,1,1,1);
$dbdata[db_data_name]=stripcslashes($dbdata[db_data_name]);
$db_data_desc=stripcslashes($dbdata[db_data_desc]);
$db_data_desc=nl2br($db_data_desc);
$db_data_desc.=$supforum;
if($dbdata[db_data_ext]==1){$filenr=stripcslashes($dbdata[db_data_path]);$normpath="";}

if($dbdata[db_d_id]==$dbnew){$new=" <font color=\"#FF0000\"> <sup>new</sup> </font color> ";}
$dbdata[db_update]=formatdate($wbbuserdata['dateformat'],$dbdata[db_update],1);
$kats.="<tr><td class=\"tablea\" align=\"left\" width=\"40%\">&nbsp;&nbsp;<span class=\"smallfont\"><b>$dbdata[db_data_name]</b> $new</td>
<td class=\"tablea\" align=\"center\" width=\"20%\">&nbsp;&nbsp;<span class=\"smallfont\">Uploader: $dbdata[db_uploader]</td>
<td class=\"tablea\" align=\"center\" width=\"20%\">&nbsp;&nbsp;<span class=\"smallfont\">When: $dbdata[db_update]</td>
<td class=\"tablea\" align=\"center\" width=\"20%\">&nbsp;&nbsp;<span class=\"smallfont\">Downloads: $dbdata[db_data_downs]</td>
</tr>
<tr>
<td class=\"tablea\" align=\"left\" width=\"20%\" colspan=\"2\">&nbsp;&nbsp;<span class=\"smallfont\">Description:<p><ul>$db_data_desc</ul></td>
<td class=\"tablea\" align=\"center\" width=\"20%\">&nbsp;&nbsp;<span class=\"smallfont\">KByte: $dbdata[db_data_kb]</td>
<td class=\"tablea\" align=\"center\" width=\"20%\">&nbsp;&nbsp;<span class=\"smallfont\">";

$dbkatname = $db->query("SELECT * FROM bb".$n."_info_db_id WHERE db_sub_katid='$subkatid'");
while($dbkdata=$db->fetch_array($dbkatname)) {
$db_dtime=$dbkdata[db_dtime];
$db_ntime=$dbkdata[db_ntime];
$db_danz=$dbkdata[db_danz];
$db_dist=$dbkdata[db_dist];
}

# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$arrange=$whodown;
foreach ($groupids as $be){
$pos = (strstr($arrange,$be));
if ($pos=='') {$allower=0;continue;}
if ($pos<>'') {$allower=1;$hit=" $be ";break;}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

# +++++++++++++++++++++++++ DTime ++++++++++++++++++++++++++ #
if($db_dist>0){$nowtime=time();
$nextd=($db_ntime-$nowtime)/60;
$nextd=round($nextd,1);
$solltime=($nowtime+$db_dtime);$zsperr=$db_dtime/60;
$danzeiger="Downloader bisher: $db_danz<br />Max Downloader: $db_dist<br />Zeitsperre: $zsperr Minuten";
if(($db_danz>=$db_dist)&&($db_ntime<$nowtime)){
$db->query("UPDATE bb".$n."_info_db_id SET db_ntime='$solltime',db_danz='0' WHERE db_sub_katid='$subkatid'");$dgrand=0;}
if(($db_danz<$db_dist)&&($db_ntime<$nowtime)){$dgrand=1;}}
else{$dgrand=1;}
# +++++++++++++++++++++++++ -DTime +++++++++++++++++++++++++ #
if(($allower==1)&&($wbbuserdata[userid]>0)&&($dgrand==0)){
$kats.="
<span class=\"normalfont\"><center><font color=\"#FF0000\">Kein Download für die nächsten $nextd Minuten möglich!</font><br />Max. Downloader: $db_dist</center></span>";}
if(($allower==1)&&($wbbuserdata[userid]>0)&&($dgrand==1)){
$kats.="<a href=\"./info_db.php?action=downcount&fileid=$fileid&subkatid=$subkatid&dfilename=$dbdata[db_data_name]&noheader=$noheader\"><b>Download</b></a><p />$danzeiger";}

if(($allower==0)||($wbbuserdata[userid]==0)&&($dgrand==0))
{$kats.="<span class=\"smallfont\">Kein Download für Ihre<br>Usergruppe möglich</br></span>";}

# +++++++++++++++++++++++++ /DTime +++++++++++++++++++++++++ #

$kats.="</td></tr>";


$kats.="</td></tr>";
$nextd="";
$kats.="</table><br>";
### useredit ###
if($db_uploaderid==$wbbuserdata[userid]){
$kats.="<table cellpadding=\"{$style['tableincellpadding']}\" cellspacing=\"{$style['tableincellspacing']}\" border=\"{$style['tableinborder']}\" style=\"width:100%\" class=\"tableinborder\">
<tr>
<td class=\"tablecat\" align=\"center\"><span class=\"normalfont\"><b>&nbsp;<a href=\"./info_db.php?action=useredit&db_uploaderid=$db_uploaderid&subkatid=$subkatid&db_d_id=$db_d_id&noheader=$noheader\">Edit</a></b></td></tr>
</table><br>";
}}
###############
eval ("\$ifooter = \"".$tpl->get("index_db_footer")."\";");
eval("\$tpl->output(\"".$tpl->get("index_db")."\");");
exit();}
#################################################


#################################################
### Hauptseite ##################################
#################################################

if($noheader=="1"){$header="$headinclude";}

if($section=="search"){
$minwordlength='3';$maxwordlength='128';$thit=" nix";
if($fsearch=='1'){
$full="||((db_proof_ok='1')&&(db_data_desc LIKE '%".addslashes(htmlspecialchars($searchword))."%'))";
   $searchword=trim($searchword);}
   if(strlen($searchword)<$minwordlength || strlen($searchword)>$maxwordlength)
   {$findword="Fehler! Eingabelänge korrigieren!";$break=1;}
   if($searchword=="") {$findword="Fehler! Keine Eingabe!";$break=1;}
   $searchword=preg_replace("/[\/:;'\"\(\)\[\]?!#{}%\-+\\\\]/s","",$searchword);
   $searchword=str_replace("*","%",$searchword);
   if($break<>1) {
$result=$db->query("SELECT db_d_id,db_data_subkatid,db_data_name,db_data_desc FROM bb".$n."_info_db_data WHERE ((db_proof_ok='1')&&(db_data_name LIKE '%".addslashes(htmlspecialchars($searchword))."%'))$full
ORDER BY db_data_name");
while ($serg=$db->fetch_array($result)){
$db_d_id=$serg[db_d_id];
$db_data_subkatid=$serg[db_data_subkatid];
$db_data_name=$serg[db_data_name];
list($katname)=$db->query_first("SELECT db_subkatname FROM bb".$n."_info_db_id WHERE db_sub_katid='$db_data_subkatid'");
$ergebnis=$db->query("SELECT db_subkatname,db_erlgrp FROM bb".$n."_info_db_id WHERE db_sub_katid='$db_data_subkatid'");
while($dberl=$db->fetch_array($ergebnis)){$db_erlgrp=$dberl[db_erlgrp];$katname=$dberl[db_subkatname];}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$arrange=$db_erlgrp;
foreach ($groupids as $be){
$pos = (strstr($arrange,$be));
if ($pos=='') {$allower=0;continue;}
if ($pos<>'') {$allower=1;$hit=" $be ";break;}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
if($allower==1){
$katname=stripcslashes($katname);
$db_data_desc=substr($serg[db_data_desc],0,250);
$db_data_desc=stripcslashes($db_data_desc);
$parse = new parse($docensor,75,1);
$db_data_desc=$parse->doparse($db_data_desc,1,1,1,1);
if(strlen($db_data_desc)>245){$db_data_desc .= ".....(<i>Text gekürzt</i> )";}$sze++;
$loesung .= "<tr><td class=\"tablea\" align=\"center\" width=\"25%\"><span class=\"smallfont\">&nbsp;&nbsp; Results&nbsp;<b>$sze</b>&nbsp;in:&nbsp;&nbsp;&nbsp;&nbsp;<b>$katname</b></td><td class=\"tablea\" align=\"left\"><span class=\"smallfont\"><a href=\"info_db.php?action=file&fileid=$db_d_id&subkatid=$db_data_subkatid&noheader=$noheader&sid=$session[hash]\"><b>$db_data_name</b></a><br />$db_data_desc</td></tr>";
$findword=$searchword;}
if($allower<>'1'){$loesung .= "";}}
if($loesung=="")$findword="- Sorry, nix gefunden! -";}}
$uploader="";$adminsee="";

# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$arrange=$whocan;$arrange.=$wholink;
foreach ($groupids as $be){
$pos = (strstr($arrange,$be));
if ($pos=='') {$allower=0;continue;}
if ($pos<>'') {$allower=1;$hit=" $be ";break;}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

# +++++++++++++++++++++++++ guest ++++++++++++++++++++++++++ #
if($allower==1){
$uploader="<b><a href=\"./info_db.php?action=upload&noheader=$noheader\"><img src=\"{$style['imagefolder']}/top_databaseup.gif\" border=\"0\" alt=\"Upload\" title=\"Upload\" /></a></b>";}

# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$arrange=$whoedit;
foreach ($groupids as $be){
$pos = (strstr($arrange,$be));
if ($pos=='') {$allower=0;continue;}
if ($pos<>'') {$allower=1;$hit=" $be ";break;}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #

# +++++++++++++++++++++++++ guest ++++++++++++++++++++++++++ #
if(($allower==1)||(substr($groupids,0,1)==1)){
$adminsee=" <b><a href=\"./info_db.php?action=amenu&noheader=$noheader\"><img src=\"{$style['imagefolder']}/top_databaseacp.gif\" border=\"0\" alt=\"Database-Admin\" title=\"Database-Admin\" /></a></b>";}

if(!$wbbuserdata['userid']){$uploader="";$adminsee="";}

$newbuttons=" $uploader $adminsee ";

list($dbnew) = $db->query_first("SELECT db_sub_katid FROM bb".$n."_info_db_id ORDER BY db_up_date DESC LIMIT 1");$hauptkatname="Datenbank";

$result = $db->query("SELECT db_katid,db_katname,db_erlgrp FROM bb".$n."_info_db_id WHERE db_katid>0 ORDER BY db_order ASC");
while($dbdata=$db->fetch_array($result)) {
$dbdata[db_katname]=stripcslashes($dbdata[db_katname]);$db_erlgrp=$dbdata[db_erlgrp];

# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
$arrange=$db_erlgrp;
foreach ($groupids as $be){
$pos = (strstr($arrange,$be));
if ($pos=='') {$allower=0;continue;}
if ($pos<>'') {$allower=1;$hit=" $be ";break;}}
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
if($allower==1){

if($dbdata[db_katid]>0) {
$kats.="<table cellpadding=\"{$style['tableincellpadding']}\" cellspacing=\"{$style['tableincellspacing']}\" border=\"{$style['tableinborder']}\" style=\"width:100%\" class=\"tableinborder\">";

$kats.="<tr>
<td class=\"tablecat\" align=\"left\" colspan=\"2\"><span class=\"normalfont\"><b>&nbsp;$dbdata[db_katname]</b></td></tr>";
$subkat = $db->query("SELECT db_parent_id,db_subkatname,db_desc,db_count,db_sub_katid FROM bb".$n."_info_db_id WHERE db_parent_id='$dbdata[db_katid]' ORDER BY db_order");
while($dbdata1=$db->fetch_array($subkat)){$new="";
$dbdata1[db_subkatname]=stripcslashes($dbdata1[db_subkatname]);
$dbdata1[db_desc]=stripcslashes($dbdata1[db_desc]);
$kats.="<tr><td class=\"tablea\" align=\"left\">";
if($dbdata1[db_sub_katid]==$dbnew){$new=" <font color=\"#FF0000\"> <sup>new</sup> </font color> ";}
$kats.="<span class=\"smallfont\">&nbsp;&nbsp;<b><a href=\"info_db.php?action=kat&subkatid=$dbdata1[db_sub_katid]&noheader=$noheader\">$dbdata1[db_subkatname]</a></b>$new
<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"smallfont\">$dbdata1[db_desc]</font></td>
<td class=\"tablea\" align=\"center\" width=\"15%\">
<span class=\"smallfont\">Downloads: $dbdata1[db_count]</td>
</tr>";}$kats.="</table><br />&nbsp;";}
}
}

$kats.="<table cellpadding=\"{$style['tableincellpadding']}\" cellspacing=\"{$style['tableincellspacing']}\" border=\"{$style['tableinborder']}\" style=\"width:100%\" class=\"tableinborder\"><tr><td class=\"tabletitle\" align=\"left\" colspan=\"2\" height=\"14\"><span class=\"smallfont\">&nbsp;</td></tr>
<tr>
<td class=\"tablea\" align=\"left\" width=\"25%\"><span class=\"smallfont\">
&nbsp;&nbsp; Downloads Search: </td>
<td class=\"tablea\" align=\"center\"><span class=\"smallfont\">
<form action=\"info_db.php?section=search\" method=\"post\" enctype=\"multipart/form-data\">
search words have to contain between 3 and 20 characters: &nbsp;&nbsp;
<input class=\"input\" type=\"text\" name=\"searchword\" value=\"$findword\" SIZE=32 MAXLENGTH=128>
<input type=\"hidden\" name=\"noheader\" value=\"$noheader\"> &nbsp;&nbsp;&nbsp;
<input type=\"Submit\" name=\"ok\" value=\"Search\">&nbsp;&nbsp;&nbsp;<input type=\"Checkbox\" name=\"fsearch\" value=\"1\">&nbsp;Full Text Search
</form>
</td>
</tr>";

$kats.= $loesung;

$kats.="</table><br />&nbsp;";

list($dbcount)=$db->query_first("SELECT sum(db_count) FROM bb".$n."_info_db_id");
$kats.="<table cellpadding=\"{$style['tableincellpadding']}\" cellspacing=\"{$style['tableincellspacing']}\" border=\"{$style['tableinborder']}\" style=\"width:100%\" class=\"tableinborder\"><tr><td class=\"tabletitle\" align=\"left\" colspan=\"2\" height=\"14\"><span class=\"smallfont\">&nbsp;</td></tr>
<tr>
<td class=\"tableb\" align=\"left\" colspan=\"2\"><span class=\"normalfont\">
<i><b>Statistics</b></i></td>
</tr>
<tr>
<td class=\"tablea\" align=\"left\" colspan=\"2\"><span class=\"smallfont\">
&nbsp;</td>
</tr>
<tr>
<td class=\"tableb\" align=\"left\" colspan=\"2\"><span class=\"normalfont\">
<i>The 5 Newest Downloads:</i></td>
</tr>";

$dbnews = $db->query("SELECT db_data_name,db_data_subkatid,db_d_id,db_update,bb".$n."_info_db_id.db_subkatname FROM bb".$n."_info_db_data,bb".$n."_info_db_id WHERE db_proof_ok='1'
AND(db_data_subkatid = bb".$n."_info_db_id.db_sub_katid)
GROUP BY db_d_id
ORDER BY db_update
DESC LIMIT 5");
while($dbndata=$db->fetch_array($dbnews)) {
$hackname=$dbndata[db_data_name];$hackname=stripcslashes($hackname);
$katid=$dbndata[db_data_subkatid];
$hackid=$dbndata[db_d_id];
$hackdate=formatdate($wbbuserdata['dateformat'],$dbndata[db_update],1);
$subkatname=$dbndata[db_subkatname];$subkatname=stripcslashes($subkatname);
$kats.="<tr>
<td class=\"tablea\" align=\"left\"><span class=\"smallfont\">
<a href=\"./info_db.php?action=file&fileid=$hackid&subkatid=$katid&noheader=$noheader\">$hackname</a></td>
<td class=\"tablea\" align=\"center\" width=\"15%\"><span class=\"smallfont\">
in:&nbsp;<b>$subkatname</b>&nbsp;&nbsp;$hackdate</td>
</tr>";
}

$kats.="<tr>
<td class=\"tableb\" align=\"left\" colspan=\"2\"><span class=\"normalfont\">
&nbsp;</td>
</tr>";

$kats.="
<tr>
<td class=\"tablea\" align=\"left\"><span class=\"smallfont\">
Total Files For Download:</td>
<td class=\"tablea\" align=\"center\" width=\"15%\"><span class=\"smallfont\">
<b>$dbcount</b></td>
</tr>

<tr>
<td class=\"tablea\" align=\"left\" colspan=\"2\"><span class=\"smallfont\">
&nbsp;</td>
</tr>

<tr>
<td class=\"tableb\" align=\"left\" colspan=\"2\"><span class=\"normalfont\">
<i>Top 5 Downloads:</i></td>
</tr>";

$result2 = $db->query("SELECT db_d_id,db_data_name,db_uploaderid,db_uploader,db_data_subkatid,db_data_downs,bb".$n."_info_db_id.db_subkatname
FROM bb".$n."_info_db_data,bb".$n."_info_db_id
WHERE bb".$n."_info_db_id.db_sub_katid=bb".$n."_info_db_data.db_data_subkatid
ORDER BY db_data_downs DESC LIMIT 5");
while($dbdata2=$db->fetch_array($result2)) {
$dbdata2[db_subkatname]=stripcslashes($dbdata2[db_subkatname]);
$kats.="
<tr>
<td class=\"tablea\" align=\"left\"><span class=\"smallfont\">
<a href=\"info_db.php?action=file&noheader=$noheader&fileid=$dbdata2[db_d_id]&subkatid=$dbdata2[db_data_subkatid]\"><b>$dbdata2[db_data_name]</b></a>
</td>
<td class=\"tablea\" align=\"center\" width=\"25%\"><span class=\"smallfont\">
Been downloaded $dbdata2[db_data_downs] times</td>
</tr>";
}
$kats.="
</table><p>";


$kats.="</table>";

eval ("\$ifooter = \"".$tpl->get("index_db_footer")."\";");
eval("\$tpl->output(\"".$tpl->get("index_db")."\");");


/*                     Database V2.5 2003 by Trooper www.wbbcoderforum.de                */
?>