1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Help 500 Internal Error?

Discussion in 'PHP' started by jpinheiro, Apr 18, 2009.

  1. #1
    Ok I have this website and Script but when I visit the page I get a 500 internal error:

    http://bypassmyproxy.com/imageupload

    here is the template code

    <?php
    require_once('config.php');
    	//Setting $error so it doesn't through errors at us
    	$error = '';
    	if(isset($_POST['submit'])){
    		$fileName = $_FILES['image']['name'];
    		$fileSize = $_FILES['image']['size'];
    		$fileTemp = $_FILES['image']['tmp_name'];
    		
    		if($fileSize > $config['maxupload']*1024){
    			$error = 'The file was too big!'; 
    		}
    		else {
    			$ext = substr($fileName, strrpos($fileName, '.') + 1);
    			
    			if (($ext != "jpg") && ($ext != "jpeg") && ($ext != "png") && ($ext != "gif")){
    				$error = 'Invalid File Format!';
    			}
    			else {
    				$text = 'Congratulations, the file was successfully uploaded!</br>';
    				unset($error);
    				if (file_exists($config['imgdir'].$fileName)) {
    									
    					$fileName = uniqid($fileName).'.'.$ext;
    					
    										
    				} else {
    										
    				}
    				$finallocation = $config['imgdir'].$fileName;
    				move_uploaded_file($fileTemp, $finallocation);
    				$thumb = img_resize($finallocation, $config['maxwidth'], $config['thmdir'], $fileName); 
    				$sharelink = $config['siteurl'].$finallocation;
    				
    				$thumbLinkForum = '[url='.$sharelink.'][img]'.$config['siteurl'].$config['thmdir'].$fileName.'[/img][/url]';
    				$thumbLinkHTML = htmlspecialchars('<a href="'.$sharelink.'"><img src="'.$config['siteurl'].$config['thmdir'].$fileName.'" alt="" /></a>');
    			}
    			
    		}	
    	}
    	
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Image Uploader</title>
    <style type="text/css">
    <!--
    #content {
    	font-family: Verdana, Arial, Helvetica, sans-serif;
    	width: 500px;
    	margin-left: auto;
      	margin-right: auto;
    	text-align: center;
    	padding-top: 50px;
    }
    -->
    </style>
    
    <script type="text/javascript">
    function SelectAll(id)
    {
        document.getElementById(id).focus();
        document.getElementById(id).select();
    }
    </script>
    
    </head>
    <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    <center>
    <table id="Table_01" width="1001" height="673" border="0" cellpadding="0" cellspacing="0">
    	<tr>
    		<td colspan="14">
    			<img src="images/index_01.png" width="1000" height="21" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="1" height="21" alt=""></td>
    	</tr>
    	<tr>
    		<td rowspan="11">
    			<img src="images/index_02.png" width="21" height="651" alt=""></td>
    		<td colspan="12">
    			<img src="images/header.png" width="962" height="109" alt=""></td>
    		<td rowspan="11">
    			<img src="images/index_04.png" width="17" height="651" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="1" height="109" alt=""></td>
    	</tr>
    	<tr>
    		<td colspan="5">
    			<img src="images/index_05.png" width="221" height="2" alt=""></td>
    		<td rowspan="2">
    			<a href="#">
    				<img src="images/btn2.png" width="173" height="26" border="0" alt=""></a></td>
    		<td rowspan="2">
    			<a href="#">
    				<img src="images/btn3.png" width="173" height="26" border="0" alt=""></a></td>
    		<td rowspan="2">
    			<a href="#">
    				<img src="images/btn4.png" width="173" height="26" border="0" alt=""></a></td>
    		<td colspan="4">
    			<img src="images/index_09.png" width="222" height="2" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="1" height="2" alt=""></td>
    	</tr>
    	<tr>
    		<td colspan="2" rowspan="2">
    			<img src="images/index_10.png" width="48" height="40" alt=""></td>
    		<td colspan="3">
    			<a href="./index.php">
    				<img src="images/home.png" width="173" height="24" border="0" alt=""></a></td>
    		<td colspan="2">
    			<a href="#">
    				<img src="images/btn5.png" width="173" height="24" border="0" alt=""></a></td>
    		<td colspan="2" rowspan="5">
    			<img src="images/index_13.png" width="49" height="392" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="1" height="24" alt=""></td>
    	</tr>
    	<tr>
    		<td colspan="8">
    			<img src="images/index_14.png" width="865" height="16" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="1" height="16" alt=""></td>
    	</tr>
    	<tr>
    		<td rowspan="7">
    			<img src="images/index_15.png" width="20" height="500" alt=""></td>
    		<td width="100" height="96" colspan="2" valign="top" style="background-image: url(./images/preview.png);"><?php echo "$thumbLinkHTML"; ?> </td>
    		<td rowspan="3">
    			<img src="images/index_17.png" width="28" height="352" alt=""></td>
    		<td width="600" height="345" colspan="5" rowspan="2" valign="top">
    		<div id="content">
      <p>Image Uploader <font size="1">(JneroCorp Edits)</font></p>
      <p>
      <form action="?upload=do" method="post" enctype="multipart/form-data">
    	<label for="file">Filename:</label>
    	<input type="file" name="image" id="image" /> 
    	<input type="submit" name="submit" value="Upload" />
      </form>
      </p>
      <?php 
      	if(isset($error)){
    		echo $error;
    	}
    	else {
    		echo '<p>Share This Image!</p>';
    		echo '<p>Forums: <input type="text" value="[img]'.$sharelink.'[/img]" / id="frmlink" onClick="SelectAll(\'frmlink\');" size="50px" /></p>';
    		echo '<p>Forum Thumbnail: <input type="text" value="'.$thumbLinkForum.'" id="thumblink" onClick="SelectAll(\'thumblink\');" size="50px" /></p>';
    		echo '<p>Direct Link: <input type="text" value="'.$sharelink.'" id="htmllink" onClick="SelectAll(\'htmllink\');" size="50px" /></p>';
    		echo '<p>HTML Thumbnail: <input type="text" value="'.$thumbLinkHTML.'" id="htmlthumb" onClick="SelectAll(\'htmlthumb\');" size="50px" /></p>';
    	}
      ?>    
    </div>
    		
    		</td>
    		<td rowspan="3">
    			<img src="images/index_19.png" width="165" height="352" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="1" height="96" alt=""></td>
    	</tr>
    	<tr>
    		<td colspan="2" rowspan="2">
    			<img src="images/index_20.png" width="100" height="256" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="1" height="249" alt=""></td>
    	</tr>
    	<tr>
    		<td colspan="5">
    			<img src="images/index_21.png" width="600" height="7" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="1" height="7" alt=""></td>
    	</tr>
    	<tr>
    		<td colspan="10">
    			<img src="images/index_22.png" width="918" height="18" alt=""></td>
    		<td rowspan="4">
    			<img src="images/index_23.png" width="24" height="148" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="1" height="18" alt=""></td>
    	</tr>
    	<tr>
    		<td colspan="10">
    			<img src="images/index_24.png" width="918" height="5" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="1" height="5" alt=""></td>
    	</tr>
    	<tr>
    		<td width="918" height="83" colspan="10" valign="top">TEXT</td>
    		<td>
    			<img src="images/spacer.gif" width="1" height="83" alt=""></td>
    	</tr>
    	<tr>
    		<td colspan="10">
    			<img src="images/index_26.png" width="918" height="42" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="1" height="42" alt=""></td>
    	</tr>
    	<tr>
    		<td>
    			<img src="images/spacer.gif" width="21" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="20" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="28" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="72" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="28" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="73" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="173" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="173" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="173" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="8" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="165" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="25" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="24" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="17" height="1" alt=""></td>
    		<td></td>
    	</tr>
    </table>
    </body>
    </html>
    PHP:
    Does anyone know whats wrong?

    Thanks,
    John
     
    jpinheiro, Apr 18, 2009 IP
  2. mcfox

    mcfox Wind Maker

    Messages:
    7,526
    Likes Received:
    716
    Best Answers:
    0
    Trophy Points:
    360
    #2
    If you're getting a 500 internal server error then it isn't the php that's causing it. More likely to be .htaccess misconfiguration.
     
    mcfox, Apr 19, 2009 IP
  3. kishore415

    kishore415 Well-Known Member

    Messages:
    1,462
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    160
    #3
    it might be due to permissions on your files and folders tooo
     
    kishore415, Apr 19, 2009 IP
  4. jpinheiro

    jpinheiro Peon

    Messages:
    1,211
    Likes Received:
    15
    Best Answers:
    1
    Trophy Points:
    0
    #4
    Yes it was because index.php was chmod to 777 I changed to 666 and it all worked again


    Can anyone explain why it does this

    Thanks,
    John
     
    jpinheiro, Apr 19, 2009 IP
  5. ActiveFrost

    ActiveFrost Notable Member

    Messages:
    2,072
    Likes Received:
    63
    Best Answers:
    3
    Trophy Points:
    245
    #5
    What ? If you chmod it to 666, it will not chmod itself back to 777 automatically ! Just curious, what type of server you are using ( Linux, Windows ) ?
     
    ActiveFrost, Apr 19, 2009 IP
  6. kishore415

    kishore415 Well-Known Member

    Messages:
    1,462
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    160
    #6
    it was because of your server configuration on file permissions..they will have some rules to maintain certain permission levels to maintain security..if you cross the limits..you will end up with 500 configuratiosn errors
     
    kishore415, Apr 19, 2009 IP
    jpinheiro likes this.
  7. jpinheiro

    jpinheiro Peon

    Messages:
    1,211
    Likes Received:
    15
    Best Answers:
    1
    Trophy Points:
    0
    #7
    Thansk you for the help +reps added to kishore

    Thanks,
    John
     
    jpinheiro, Apr 19, 2009 IP
  8. mcfox

    mcfox Wind Maker

    Messages:
    7,526
    Likes Received:
    716
    Best Answers:
    0
    Trophy Points:
    360
    #8
    Does it have to have permissions set to 666? That's a security risk. You maybe want to try setting it to 644 instead. It should still do the same thing but 'public' won't have write permissions.
     
    mcfox, Apr 19, 2009 IP