Oct 27 2010, 04:06 AM
adddownload.php:
PHP Code:
<?php
if(checkLogin(MEMBER_NAME, MEMBER_PASS) && checkRank(MEMBER_RANK, $pid)) {
if($submit) {
?>
<table align='center' border='0' cellspacing='0' cellpadding='0' width='450'>
<?PHP
$fileurl = $_REQUEST["fileurl"];
$downloadfile = $_REQUEST["downloadfile"]
$name1 = $_POST["name1"];
$type1 = $_POST["type1"];
$desc = $_POST["desc"];
if($fileurl == "" && $downloadfile != "" && is_numeric($type1) && $name1 != "") {
$dlfilepath = basename($_FILES['downloadfile']['name']);
$dlextensions = getDownloadCatInfo("extension", $type1);
$totalextensions = substr_count($dlextensions, ",");
$passtest = 0;
if($totalextensions > 0) {
$dl_extensions = str_replace(" ", "", $dlextensions);
$dl_extensions = explode(",", $dl_extensions);
foreach($dl_extensions as $ext) {
$countext = strlen($ext);
$startpos = 0-$countext;
$testfile = substr($dlfilepath, $startpos);
if($testfile == $ext) {
$passtest++;
}
}
}
else {
$countext = strlen($dlextensions);
$startpos = 0-$countext;
$testfile = substr($dlfilepath, $startpos);
if($textfile == $ext) {
$passtest++;
}
}
if($passtest == 0) {
$diemessage = "The download could not be added. The file must be of type: $dlextensions";
die("<script language=\"Javascript\"> alert(\"$diemessage\"); window.location.href = 'console.php?pid=$pid'; </script>");
}
$failed = 0;
if(@move_uploaded_file($_FILES['downloadfile']['tmp_name'], "downloads/".$dlfilepath)) {
?>
<tr>
<td class='main'>File Uploaded Successfully!</td>
</tr>
<?PHP
$failed = 0;
}
else {
?>
<tr>
<td class='main'>File Upload Failed!</td>
</tr>
<?PHP
$failed = 1;
}
if($failed == 1) {
?>
<tr>
<td class='main'>File Upload Failed: The file was unable to be uploaded!</td>
</tr>
<?PHP
}
else {
$filenamepath = "downloads/" . $dlfilepath;
$outsidelink = 0;
}
}
elseif($fileurl != "") {
$filenamepath = $fileurl;
$outsidelink = 1;
$failed = 0;
}
if(!is_numeric($type1) OR $name1 == "") {
$failed = 1;
}
if($failed == 0) {
$time = time();
$query =
"INSERT INTO {$dbprefix}downloads (name, description, type, poster, filename, outsidelink, adderip, dateadded) " .
"VALUES ('$name1', '$desc', '$type1', '$memid', '$filenamepath', '$outsidelink', '$ip', '$time')";
$result = mysql_query($query)
or die(mysql_error());
?>
</table>
<script language="Javascript">
alert("Success!");
window.location.href = 'console.php';
</script>
<?PHP
}
else {
?>
<tr>
<td class='main'>The download was not added to the database.</td>
</tr>
</table>
<?PHP
}
}
elseif(!$submit) {
$maxuploadsize = ini_get('upload_max_filesize')."B";
$downloadcats = getDownloads();
$dispconsolename = getConsoleInfoByID("displayname", $pid);
?>
<form action='console.php?pid=<?PHP echo($pid); ?>' method='post' enctype='multipart/form-data'>
<table align='center' border='1' cellspacing='0' cellpadding='3' width='500' bordercolor='<?PHP echo($bgcolor); ?>'>
<tr>
<td bordercolor='<?PHP echo($bordercolor); ?>' background='themes/<?PHP echo($theme); ?>/<?PHP echo($bgimage); ?>' class='titles' align='center'>
<span style="font-weight: bold;"><?PHP echo($dispconsolename); ?></span>
</td>
</tr>
<tr>
<td bordercolor='<?PHP echo($bordercolor); ?>' style='border-top-width: 0px' class='main'>
<br />
<blockquote>
<span style="font-weight: bold;">NOTE:</span>
If both the Upload File and File URL are used, the File URL will be added to the database.
It will overwrite any file with the same name.<br/>
<span style="font-weight: bold;">MAX UPLOAD SIZE: <?PHP echo($maxuploadsize); ?></span><br/><br/>
<span style="text-align: center;">
<table align='center' border='0' cellspacing='0' cellpadding='0' width='450'>
<tr>
<td class='main' width='150'>
<span style="font-weight: bold;">Upload File:</span>
</td>
<td class='main' width='300'>
<input type='file' name='downloadfile' class='form'/>
</td>
</tr>
<tr>
<td align='center' class='main'>
<br/>
<span style="font-style: italic;">OR</span>
<br/><br/>
</td>
</tr>
<tr>
<td class='main' width='150'>
<span style="font-weight: bold;">File URL:</span>
</td>
<td class='main' width='300'>
<input type='text' name='fileurl' class='form'/>
</td>
</tr>
<tr>
<td class='main' width='150'>
<span style="font-weight: bold;">Name:</span>
</td>
<td class='main' width='300'>
<input type='text' name='name1' class='form'/>
</td>
</tr>
<tr>
<td class='main' width='150'>
<span style="font-weight: bold;">Type:</span>
</td>
<td class='main' width='300'>
<select name='type1' class='form'>
<?PHP
foreach($downloadcats as $download) {
?>
<option value="<?PHP echo($download[1]); ?>"><?PHP echo($download[0]) ?></option><?PHP
}
?>
</select>
</td>
</tr>
<tr>
<td class='main' width='150' valign='top'>
<span style="font-weight: bold;">Description:</span>
</td>
<td class='main' width='300'>
<textarea name='desc' rows='4' cols='40' class='form'></textarea>
</td>
</tr>
<tr>
<td colspan='2' class='main' align='center'>
<br/>
<input type='submit' name='submit' value='Add Download'/>
</td>
</tr>
</table>
</span>
</blockquote>
</td>
</tr>
</table>
</form>
<?PHP
}
}
else {
?>
<table align='center' border='0' cellspacing='0' cellpadding='0' width='400'>
<tr>
<td class='main' align='center'>Your rank is not high enough to view this page</td>
</tr>
</table>
<?PHP
}
?>