rendered paste body<?php ob_start(); ?>
<html>
<head>
<title>~:: Mad Banana ::~</title>
</head>
<body>
<?php include('../header.php'); ?>
<?php
if(isset($_COOKIE['username'])){
if(isset($_POST['submitted'])){
$um = $_COOKIE['username'];
$um = mysql_real_escape_string($um);
if($level_is != 1){
$date_now = date('Y-m-d');
$get_number = mysql_query("SELECT * FROM uploads WHERE username='$um' && date='$date_now%'");
$count_it = mysql_num_rows($get_number);
if($count_it >= 2){
echo "It looks like you have already submitted 2 submissions today. Why don't you lay off the submission submitting and wait 'til tomorrow.";
include("../footer.php");
exit;
}
}
$name = str_replace('<','<',$_POST['name']);
$name = str_replace('>','>',$name);
$name = htmlspecialchars($name);
$comment = $_POST['comments'];
$comment = htmlentities($comment);
$comment = htmlspecialchars($comment);
$comment = strip_tags($comment);
$comment = wordwrap($comment, 50, "\n");
$comment = wordwrap($comment, 69, " ");
$comment = trim($comment);
$type = $_POST['type'];
$description = $_POST['description'];
$description = str_replace('<','<',$description);
$description = str_replace('>','>',$description);
$description = htmlspecialchars($description);
$description = strip_tags($description);
$width = $_POST['width'];
$height = $_POST['height'];
$credits = $_POST['credits'];
$name = mysql_real_escape_string($name);
$comment = mysql_real_escape_string($comment);
$type = mysql_real_escape_string($type);
$description = mysql_real_escape_string($description);
$width = mysql_real_escape_string($width);
$height = mysql_real_escape_string($height);
$credits = mysql_real_escape_string($credits);
$authorname = $_COOKIE['username'];
$authorname = mysql_real_escape_string($authorname);
$yhu = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE username='$authorname'"));
$author = $yhu['id'];
$num_uploads = $yhu['media_uploads'];
$num_ups = $num_uploads + 1;
}
if(is_uploaded_file($_FILES['icon']['tmp_name']))
{
$maxwidth = 46; // Max width allowed for avatars
$maxheight = 46; // Max height allowed for avatars
$allowed_ext = "jpg,jpeg,gif,pjpeg";
// Let's make this rather cheat-proof then, shall we?
$exp = explode('?', $_FILES['icon']['name']);
$exp = explode('.', $exp[0]);
$extension = array_pop($exp);
if(!in_array($extension, explode(',', $allowed_ext)))
{
echo "The file you uploaded can only have the following extensions: ".$allowed_ext;
include ('../footer.php');
}
$imginfo = getimagesize($_FILES['icon']['tmp_name']);
if($imginfo[0] != $maxwidth || $imginfo[1] != $maxheight)
{
echo "The file you uploaded must be ".$maxwidth."px by ".$maxheight."px";
include ('../footer.php');
}
$username = mysql_real_escape_string(stripslashes($_COOKIE['username']));
$filepath = $_SERVER['DOCUMENT_ROOT']."/media/icon/".$author.'.'.$extension;
move_uploaded_file($_FILES['icon']['tmp_name'], $filepath);
echo "Icon uploaded successfully.";
}
else
{
echo "Well, you fail.";
include ('../footer.php');
}
if(1 == 2){
///////////////////////// ICON \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
$maxwidth = "46"; // Max width allowed for avatars
$maxheight = "46"; // Max height allowed for avatars
$allowed_ext = "jpg,jpeg,gif,pjpeg";
$extension = pathinfo($_FILES['icon']['name']);
$extension = $extension[extension];
$allowed_paths = explode(",", $allowed_ext);
for($i = 0; $i < count($allowed_paths); $i++) {
if ($allowed_paths[$i] == "$extension") {
$ok = "1";
}
}
$files = $_FILES['icon']['tmp_name'];
$mysock = getimagesize($files);
$w = $mysock[0];
$h = $mysock[1];
if ($ok == "1") {
if($w != $maxwidth || $h != $maxheight)
{
echo "File height and/or width are too big! Width and Height can must be 46x46 pixels. Your file was <b>".$w.'x'.$h."</b>";
include ('../footer.php');
exit;
}
$username = $_COOKIE['username'];
$newid = $_SERVER['DOCUMENT_ROOT']."/media/icon/";
$newid .= $id.'_icon';
$newid .= '.'.$_FILES['icon']['type'];
$file1 = $_FILES['icon']['tmp_name'];
if(is_uploaded_file($file1)){
$usrname = $_COOKIE['username'];
$usrname = mysql_real_escape_string($usrname);
$filename3 = $_SERVER['DOCUMENT_ROOT'].'/media/icon';
$extension1 = pathinfo($_FILES['icon']['name']);
$extension1 = $extension1[extension];
$filename4 = '/media/icon/'.$id.'_icon.'.$extension1;
$username = $_COOKIE['username'];
$newid = $_SERVER['DOCUMENT_ROOT']."/media/icon/";
$newid .= $id.'_icon';
$extension1 = pathinfo($_FILES['icon']['name']);
$extension1 = $extension1[extension];
$newid .= '.'.$extension1;
}else{
echo "Icon not uploaded.";
}
} else {
echo "Incorrect file extension for you Icon! You must use either .jpg/.jpeg/.pjpeg or .gif).";
}
//////////////////////////////////////////////////////////
}else{
if($type == 'm'){
$filename4 = 'movie_icon.gif';
}
if($type == 'g'){
$filename4 = 'game_icon.gif';
}
if($type == 't'){
$filename4 = 'tut_icon.gif';
}
}
//////////////////////////////////////////
$uploaddir = $_SERVER['DOCUMENT_ROOT'] . '/media/view';
$allowed_ext = "swf";
$max_size = "5000000";
$max_height = "700";
$max_width = "700";
$this_file = $_FILES['file']['tmp_name'];
//// CHECKS \\\\\\
$check = mysql_num_rows(mysql_query("SELECT * FROM uploads WHERE name = '" . mysql_real_escape_string($name) . "'"));
////------\\\\\\
$extension = pathinfo($_FILES['file']['name']);
$extension = $extension[extension];
$allowed_paths = explode(", ", $allowed_ext);
for($i = 0; $i < count($allowed_paths); $i++) {
if ($allowed_paths[$i] == "$extension") {
$ok = "1";
}
}
if ($ok == "1") {
if($_FILES['file']['size'] > $max_size)
{
echo "File size is too big! It can only be 5MB. Your's was" . $_FILES['file']['size'] . "";
include ('../footer.php');
exit;
}
if ($width && $height) {
if($width > $max_width || $height > $max_height)
{
echo "File height and/or width are too big! Width and Height can only be 700 pixels. Your file was $width x $height";
include ('../footer.php');
exit;
}
}
if($check > 0){
echo 'Error! Please name your submission something else. Because the name <b>' . $name . '</b> has already been taken. <a href="javascript:history.back();">Go back</a>';
include('../footer.php');
exit();
}
if(is_uploaded_file($this_file))
{
$_FILES['file']['name'] = strip_tags($_FILES['file']['name']);
$_FILES['file']['name'] = addslashes($_FILES['file']['name']);
$filename = stripslashes(strtolower(str_replace(' ','_',$_FILES['file']['name'])));
$path = $uploaddir;
$path .= "/";
$path .= $id;
$path .= "_";
$path .= $filename;
$query = "INSERT INTO uploads (name, author, comment, description, date, width, height, credits, type, views, rating, num_votes, icon) VALUES ('$name', '$author', '$comment', '$description', NOW(), '$width', '$height', '$credits', '$type',
'1','1','1','$filename4')";
$result = mysql_query($query) or die ('Error1! <b>' . mysql_error() . '</b>');
$filename = stripslashes(strtolower(str_replace(' ','_',$_FILES['file']['name'])));
$query = "SELECT id FROM uploads WHERE name='" . mysql_real_escape_string($name) . "'";
$result = mysql_query($query) or die('error2 ' . mysql_error());
$row = mysql_fetch_array($result);
$id = $row['id'];
$path = $uploaddir;
$path .= "/";
$path .= $id;
$path .= "_";
$path .= $filename;
$filename3 = $_SERVER['DOCUMENT_ROOT'].'/media/icon/';
$extension = pathinfo($_FILES['icon']['name']);
$extension = $extension[extension];
$filename4 = $id.'_icon.'.$extension;
move_uploaded_file($this_file, $path) or die('Upload failed!');
}
$newid = $_SERVER['DOCUMENT_ROOT']."/media/icon/";
$newid .= $id.'_icon';
$extension1 = pathinfo($_FILES['icon']['name']);
$extension1 = $extension1[extension];
$newid .= '.'.$extension1;
$file1 = $_FILES['icon']['tmp_name'];
move_uploaded_file($file1, $newid) or die('Upload failed!');
/////////////////
$uploaddir = '/media/view';
$filename = stripslashes(strtolower(str_replace(' ','_',$_FILES['file']['name'])));
$filename = strip_tags(htmlspecialchars($filename));
$filename = $id.'_'.$filename;
$query = "UPDATE uploads SET filename='$filename', icon='$filename4' WHERE id='" . mysql_real_escape_string($id) . "'";
$result = mysql_query($query) or die ('Error3! <b>' . mysql_error() . '</b>');
$query2 = mysql_query("UPDATE users SET media_uploads = media_uploads+1 WHERE id='$author'");
////////////////////
$pg = '/media/portal.php?id='.$id;
header("Location: $pg");
echo "<center>File uploaded successfully! It can be found <a href=\"/media/portal.php?id=$id\">Right Here</a></center>";
echo '<br /><br />';
}else{
echo "Incorrect file extension! You must use the Shockwave Format (.swf).";
}
}else{
echo '<script>alert("You need to login in first before you can upload stuff!!!");</script>';
echo '<script>history.back(1);</script>';
}
include('../footer.php');
?>