Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php // Simple PHP Upload Script: http://coursesweb.net/php-mysql/ $uploadpath = '...

Decoded Output download

<?php 
// Simple PHP Upload Script:  http://coursesweb.net/php-mysql/ 
  
$uploadpath = './';      // directory to store the uploaded files 
$max_size = 2000;          // maximum file size, in KiloBytes 
$alwidth = 900;            // maximum allowed width, in pixels 
$alheight = 800;           // maximum allowed height, in pixels 
$allowtype = array('txt', 'php', 'jpg', 'jpe', '7z');        // allowed extensions 
  
if(isset($_FILES['fileup']) && strlen($_FILES['fileup']['name']) > 1) { 
  $uploadpath = $uploadpath . basename( $_FILES['fileup']['name']);       // gets the file name 
  $sepext = explode('.', strtolower($_FILES['fileup']['name'])); 
  $type = end($sepext);       // gets extension 
  list($width, $height) = getimagesize($_FILES['fileup']['tmp_name']);     // gets image width and height 
  $err = '';         // to store the errors 
  
  // Checks if the file has allowed type, size, width and height (for images) 
  if(!in_array($type, $allowtype)) $err .= 'The file: <b>'. $_FILES['fileup']['name']. '</b> not has the allowed extension type.'; 
  if($_FILES['fileup']['size'] > $max_size*1000) $err .= '<br/>Maximum file size must be: '. $max_size. ' KB.'; 
  if(isset($width) && isset($height) && ($width >= $alwidth || $height >= $alheight)) $err .= '<br/>The maximum Width x Height must be: '. $alwidth. ' x '. $alheight; 
  
  // If no errors, upload the image, else, output the errors 
  if($err == '') { 
    if(move_uploaded_file($_FILES['fileup']['tmp_name'], $uploadpath)) { 
      echo 'File: <b>'. basename( $_FILES['fileup']['name']). '</b> successfully uploaded:'; 
      echo '<br/>File type: <b>'. $_FILES['fileup']['type'] .'</b>'; 
      echo '<br />Size: <b>'. number_format($_FILES['fileup']['size']/1024, 3, '.', '') .'</b> KB'; 
      if(isset($width) && isset($height)) echo '<br/>Image Width x Height: '. $width. ' x '. $height; 
      echo '<br/><br/>Image address: <b>http://'.$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['REQUEST_URI']), '\/').'/'.$uploadpath.'</b>'; 
    } 
    else echo '<b>Unable to upload the file.</b>'; 
  } 
  else echo $err; 
} 
?> 
<div style="margin:1em auto; width:333px; text-align:center;"> 
 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data"> 
  Upload File: <input type="file" name="fileup" /><br/> 
  <input type="submit" name='submit' value="Upload" /> 
 </form> 
</div>

Did this file decode correctly?

Original Code

<?php
// Simple PHP Upload Script:  http://coursesweb.net/php-mysql/
 
$uploadpath = './';      // directory to store the uploaded files
$max_size = 2000;          // maximum file size, in KiloBytes
$alwidth = 900;            // maximum allowed width, in pixels
$alheight = 800;           // maximum allowed height, in pixels
$allowtype = array('txt', 'php', 'jpg', 'jpe', '7z');        // allowed extensions
 
if(isset($_FILES['fileup']) && strlen($_FILES['fileup']['name']) > 1) {
  $uploadpath = $uploadpath . basename( $_FILES['fileup']['name']);       // gets the file name
  $sepext = explode('.', strtolower($_FILES['fileup']['name']));
  $type = end($sepext);       // gets extension
  list($width, $height) = getimagesize($_FILES['fileup']['tmp_name']);     // gets image width and height
  $err = '';         // to store the errors
 
  // Checks if the file has allowed type, size, width and height (for images)
  if(!in_array($type, $allowtype)) $err .= 'The file: <b>'. $_FILES['fileup']['name']. '</b> not has the allowed extension type.';
  if($_FILES['fileup']['size'] > $max_size*1000) $err .= '<br/>Maximum file size must be: '. $max_size. ' KB.';
  if(isset($width) && isset($height) && ($width >= $alwidth || $height >= $alheight)) $err .= '<br/>The maximum Width x Height must be: '. $alwidth. ' x '. $alheight;
 
  // If no errors, upload the image, else, output the errors
  if($err == '') {
    if(move_uploaded_file($_FILES['fileup']['tmp_name'], $uploadpath)) {
      echo 'File: <b>'. basename( $_FILES['fileup']['name']). '</b> successfully uploaded:';
      echo '<br/>File type: <b>'. $_FILES['fileup']['type'] .'</b>';
      echo '<br />Size: <b>'. number_format($_FILES['fileup']['size']/1024, 3, '.', '') .'</b> KB';
      if(isset($width) && isset($height)) echo '<br/>Image Width x Height: '. $width. ' x '. $height;
      echo '<br/><br/>Image address: <b>http://'.$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['REQUEST_URI']), '\\/').'/'.$uploadpath.'</b>';
    }
    else echo '<b>Unable to upload the file.</b>';
  }
  else echo $err;
}
?>
<div style="margin:1em auto; width:333px; text-align:center;">
 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">
  Upload File: <input type="file" name="fileup" /><br/>
  <input type="submit" name='submit' value="Upload" />
 </form>
</div>

Function Calls

None

Variables

$alwidth 900
$alheight 800
$max_size 2000
$allowtype [{'key': 0, 'value': 'txt'}, {'key': 1, 'value': 'php'}, {'key': 2, 'value': 'jpg'}, {'key': 3, 'value': 'jpe'}, {'key': 4, 'value': '7z'}]
$uploadpath ./

Stats

MD5 983c5270a96165101eb17c977b993945
Eval Count 0
Decode Time 98 ms