phpSensei Posted November 12, 2007 Share Posted November 12, 2007 Line 144 is the last line. Parse error: syntax error, unexpected $end in /home/charles/domains/antiup.net/public_html/upload2.php on line 144 <?php //Check if any IP address's are banned include 'ban.php'; include 'php/config.php'; include 'php/opendb.php'; //Flood Protection if(isset($_POST['upload'])) { $ip = $_SERVER['REMOTE_ADDR']; $period = 10; $delete = mysql_query("DELETE FROM `posters` WHERE `date` < '".(($now = time()) - $period)."'"); $query = mysql_fetch_array(mysql_query("SELECT * FROM posters")); if($query['ip']==$ip){ echo '<span style="color:#B94A4A; text-decoration:blink; font-weight: bold; font-size: 24px;">Error. Flood Protection Has Not Expired.</span><br /><br />'; echo '<div align="center" class="smalltext">Copyright <a href="http://antistuff.net/">antistuff</a> 2007© All rights reserved.</div>'; exit; } else { // Variables $width = 0; $heigth = 0; $filePath = "files/"; $filename = $_FILES['userfile']['name']; $filesize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $tmpName = $_FILES['userfile']['temp']; $ip = $_SERVER['REMOTE_ADDR']; $Type = Array( 'Bytes', 'KB', 'MB', 'GB', 'TB', 'ZB' ); $times=0; while( $fileSize > 1024 ) { $fileSize = $fileSize / 1024; $fileSize = round($fileSize); $times++; } //Allows uppercase filetypes. $fileType = strtolower (strtoupper (strstr($fileName, '.'))); if(($fileType != '.gif')||($fileType != '.jpeg')||($fileType != '.jpg')||($fileType != '.png')||($fileType != '.zip')||($fileType != '.rar')||($fileType != '.doc')|| ($fileType != '.txt')||($fileType != '.mp3')||($fileType != '.wav')||($fileType != '.avi')||($fileType!= '.mov')||($fileType != '.swf')||($fileType != '.fla')){ echo '<span style="color:#B94A4A; text-decoration:blink; font-weight: bold; font-size: 24px;">Error. Wrong FileType.</span><br /><br />'; echo '<div align="center" class="smalltext">Copyright <a href="http://antistuff.net/">antistuff</a> 2007© All rights reserved.</div>'; exit; } elseif($filesize > 5242880){ echo '<span style="color:#B94A4A; text-decoration:blink; font-weight: bold; font-size: 24px;">Error. File Too Big.</span><br /><br />'; echo '<div align="center" class="smalltext">Copyright <a href="http://antistuff.net/">antistuff</a> 2007© All rights reserved.</div>'; exit; } elseif(file_exists("files/".$filename)){ $r_1 = rand(1,1000); $r_2 = rand(1000,2000); $r_3 = rand (3000,7000); $filename = $r1 . $r2 . $r3 . $filename ; } else { $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo '<span style="color:#B94A4A; text-decoration:blink; font-weight: bold; font-size: 24px;">Error. Try Again.</span><br /><br />'; echo '<div align="center" class="smalltext">Copyright <a href="http://antistuff.net/">antistuff</a> 2007© All rights reserved.</div>'; exit; } elseif(!get_magic_quotes_gpc()) { $filename = addslashes($filename); $filepath = addslashes($filepath); } if(($fileType == '.gif')||($fileType == '.jpeg')||($fileType == '.jpg')||($fileType == '.png')||($fileType == '.swf')){ list($width, $height, $type, $attr) = getimagesize("files/".$filename); } $date = time(); mysql_query("INSERT INTO posters (ip,date) VALUES ('$ip','$date')") or die(mysql_error()); mysql_query("INSERT INTO upload (name, size, type, ip, path, width, height) VALUES ('$fileName', '$fileSize', '$fileType', '$ip', '$filePath', '$width', '$height')") or die('Error, query failed : ' . mysql_error()); $newfilePath = str_replace(' ','%20',$filePath); $finddetails = mysql_query("SELECT * FROM upload ORDER BY id DESC LIMIT 1"); $filedetails = mysql_fetch_array($finddetails); $id2 = $filedetails['id']; echo '<span style="color:#8FC73D; text-decoration:blink; font-weight: bold; font-size: 24px;">Success</span><br />'; echo "Direct Link: <a href=". $newfilePath .">$fileName</a><br />"; if (($fileType == '.gif')|| ($fileType == '.jpeg') || ($fileType == '.jpg') || ($fileType == '.png') || ($fileType == '.mp3') || ($fileType == '.wav') || ($fileType == '.swf')){ echo "Share Link: <a href=". $websiteview . $id2 .">$fileName</a><br />"; //Size $Type = Array( 'Bytes', 'KB', 'MB', 'GB', 'TB', 'ZB' ); $times=0; while( $fileSize > 1024 ){ $fileSize = $fileSize / 1024; $fileSize = round($fileSize); $times++; } echo 'Size: '; echo $fileSize.' '.$Type[$times]; echo '<br /><br />'; } //Images display an image below information. elseif (($fileType == '.gif')||($fileType == '.jpeg')||($fileType == '.jpg')||($fileType == '.png')){ echo "<img src=". $newfilePath ."><br /><br />"; } //Swfs display an embedded Swf below information. elseif ($fileType == '.swf'){ echo "<embed src=". $newfilePath ." width=". $width ." height=". $height ."><br /><br />"; } } } ?> Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 12, 2007 Share Posted November 12, 2007 You are missing a culy bracket. Add one more at the end of the script. The first if isn't closed. } } } ?> To } } } } ?> Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 12, 2007 Share Posted November 12, 2007 indent your code (tab) always have our code like this if(){ //tab here if(){ if(){ } } } else{ //tab here } indent your code and post it back even if someone solved this thread you will always encounter this problem Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 12, 2007 Share Posted November 12, 2007 EDIT: Beat to it Indent your code and it will be much easier to see <?php //Check if any IP address's are banned include 'ban.php'; include 'php/config.php'; include 'php/opendb.php'; //Flood Protection if (isset($_POST['upload'])) { $ip = $_SERVER['REMOTE_ADDR']; $period = 10; $delete = mysql_query("DELETE FROM `posters` WHERE `date` < '".(($now = time()) - $period)."'"); $query = mysql_fetch_array(mysql_query("SELECT * FROM posters")); if ($query['ip']==$ip) { echo '<span style="color:#B94A4A; text-decoration:blink; font-weight: bold; font-size: 24px;">Error. Flood Protection Has Not Expired.</span><br /><br />'; echo '<div align="center" class="smalltext">Copyright <a href="http://antistuff.net/">antistuff</a> 2007© All rights reserved.</div>'; exit; } else { // Variables $width = 0; $heigth = 0; $filePath = "files/"; $filename = $_FILES['userfile']['name']; $filesize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $tmpName = $_FILES['userfile']['temp']; $ip = $_SERVER['REMOTE_ADDR']; $Type = Array('Bytes', 'KB', 'MB', 'GB', 'TB', 'ZB' ); $times=0; while ($fileSize > 1024 ) { $fileSize = $fileSize / 1024; $fileSize = round($fileSize); $times++; } //Allows uppercase filetypes. $fileType = strtolower(strtoupper(strstr($fileName, '.'))); if (($fileType != '.gif')||($fileType != '.jpeg')||($fileType != '.jpg')||($fileType != '.png')||($fileType != '.zip')||($fileType != '.rar')||($fileType != '.doc')|| ($fileType != '.txt')||($fileType != '.mp3')||($fileType != '.wav')||($fileType != '.avi')||($fileType!= '.mov')||($fileType != '.swf')||($fileType != '.fla')) { echo '<span style="color:#B94A4A; text-decoration:blink; font-weight: bold; font-size: 24px;">Error. Wrong FileType.</span><br /><br />'; echo '<div align="center" class="smalltext">Copyright <a href="http://antistuff.net/">antistuff</a> 2007© All rights reserved.</div>'; exit; } else if ($filesize > 5242880) { echo '<span style="color:#B94A4A; text-decoration:blink; font-weight: bold; font-size: 24px;">Error. File Too Big.</span><br /><br />'; echo '<div align="center" class="smalltext">Copyright <a href="http://antistuff.net/">antistuff</a> 2007© All rights reserved.</div>'; exit; } else if (file_exists("files/".$filename)) { $r_1 = rand(1,1000); $r_2 = rand(1000,2000); $r_3 = rand(3000,7000); $filename = $r1 . $r2 . $r3 . $filename ; } else { $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo '<span style="color:#B94A4A; text-decoration:blink; font-weight: bold; font-size: 24px;">Error. Try Again.</span><br /><br />'; echo '<div align="center" class="smalltext">Copyright <a href="http://antistuff.net/">antistuff</a> 2007© All rights reserved.</div>'; exit; } else if (!get_magic_quotes_gpc()) { $filename = addslashes($filename); $filepath = addslashes($filepath); } if (($fileType == '.gif')||($fileType == '.jpeg')||($fileType == '.jpg')||($fileType == '.png')||($fileType == '.swf')) { list($width, $height, $type, $attr) = getimagesize("files/".$filename); } $date = time(); mysql_query("INSERT INTO posters (ip,date) VALUES ('$ip','$date')") or die(mysql_error()); mysql_query("INSERT INTO upload (name, size, type, ip, path, width, height) VALUES ('$fileName', '$fileSize', '$fileType', '$ip', '$filePath', '$width', '$height')") or die('Error, query failed : ' . mysql_error()); $newfilePath = str_replace(' ','%20',$filePath); $finddetails = mysql_query("SELECT * FROM upload ORDER BY id DESC LIMIT 1"); $filedetails = mysql_fetch_array($finddetails); $id2 = $filedetails['id']; echo '<span style="color:#8FC73D; text-decoration:blink; font-weight: bold; font-size: 24px;">Success</span><br />'; echo "Direct Link: <a href=". $newfilePath .">$fileName</a><br />"; if (($fileType == '.gif')|| ($fileType == '.jpeg') || ($fileType == '.jpg') || ($fileType == '.png') || ($fileType == '.mp3') || ($fileType == '.wav') || ($fileType == '.swf')) { echo "Share Link: <a href=". $websiteview . $id2 .">$fileName</a><br />"; //Size $Type = Array('Bytes', 'KB', 'MB', 'GB', 'TB', 'ZB' ); $times=0; while ($fileSize > 1024 ) { $fileSize = $fileSize / 1024; $fileSize = round($fileSize); $times++; } echo 'Size: '; echo $fileSize.' '.$Type[$times]; echo '<br /><br />'; } //Images display an image below information. elseif (($fileType == '.gif')||($fileType == '.jpeg')||($fileType == '.jpg')||($fileType == '.png')) { echo "<img src=". $newfilePath ."><br /><br />"; } //Swfs display an embedded Swf below information. elseif ($fileType == '.swf') { echo "<embed src=". $newfilePath ." width=". $width ." height=". $height ."><br /><br />"; } } } } ?> Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 12, 2007 Share Posted November 12, 2007 Plus when you have a lot of if's and else's you can put a comment on the closing bracket especially if the closing bracket is way down the page. <?php if($i = 1) { //do stuff }//end if($i =1) ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.