Jump to content

[SOLVED] Auto Chmod Please Help


RossR

Recommended Posts

Hi okay im using kalleload , it working fine but when some one or me uploads a file and trys to view it they get this message "Forbidden, perhaps you need to change the file permissions for this document or upload an index page." i know this is something to do with chmoding but im not quite sure were i should add a chmod code in to the script ill post the script and maybe you could help me.

 

<?php
//===========================================================================
// KalleLoad
//===========================================================================
// Version:         1.3
// File:            index.php
// Created By:      Kalle Sommer Nielsen      ([email protected])
//===========================================================================
define('KALLELOAD_TICKET', 1);
require('./includes/templates/header.php');
if($CORE['enable_upload'] && $CORE['max_upload_size'])
{
  if(isset($_POST['progress']))
  {
   if(empty($_FILES['selector']['name']))
   {
?>
  <h2>Error</h2>
  <div class="container">
   Please select a file and re-upload! <br /> <br />
   <input type="button" onclick="location.href='./';" value=" Back " />
  </div>
<?php
   }
   elseif($_FILES['selector']['size'] > $CORE['max_upload_size'])
  
   {
?>
  <h2>Error</h2>
  <div class="container">
   The file you are trying to upload is bigger that the allowed limit! <br /> <br />
   <input type="button" onclick="location.href='./';" value=" Back " />
  </div>
<?php
   }
   elseif(!$TKS->is_supported_mime($_FILES['selector']['type']) || empty($_FILES['selector']['type']))
   {
?>
  <h2>Error</h2>
  <div class="container">
   The file type you are trying to upload is not allowed!<br /> <br />
   <input type="button" onclick="location.href='./';" value=" Back " />
  </div>
<?php
   }
   else
   {
    $upload_path = "uploads/" . $_FILES['selector']['name'];
    $extension = $TKS->get_extension_for($_FILES['selector']['type']);
    $new_file_name = "uploads/" . md5($_FILES['selector']['name'] . time()) . "." . $extension;
    
    if(@move_uploaded_file($_FILES['selector']['tmp_name'], $upload_path))
    {
     if(@rename($upload_path, $new_file_name))
    
     {
      if($extension == 'png' || $extension == 'jpg' || $extension == 'gif')
      {
       $extension_type = 'Image';
      }
      elseif($extension == 'doc' || $extension == 'rtf' || $extension == 'psd')
      {
       $extension_type = 'Document';
      }
      elseif($extension == 'zip' || $extension == 'torrent' || $extension == 'rar')
      {
       $extension_type = 'Archive';
      }
      elseif($extension == 'mp3' || $extension == 'midi' || $extension == 'wav' || $extension == 'wma')
      {
       $extension_type = 'Audio';
      }
      else
      {
       $extension_type = 'Video';
      }
      
  
        
      
      
      $TKS->sql_query("UPDATE " . $TK['kalleload']['MYSQL_PREFIX'] . "core SET total_uploads = total_uploads + 1");
?>
    <h2>Path</h2>
    <div class="container">
     <b>Your file has been uploaded. You can access it just by pointing your browser at:</b> <br />
     <a href="http://<?= $CORE['domain'] . $new_file_name; ?>" target="_new">http://<?= $CORE['domain'] . $new_file_name; ?></a> <br /> <br />
     <input type="button" onclick="location.href='./';" value="Upload new file" />
    </div>
    <div class="spacer"></div>
    <h2>HTML Code</h2>
    <div class="container">
     <b>Open in same browser Window:</b> <br />
     <?= htmlentities('<a href="http://' . $CORE['domain'] . $new_file_name . '">Link to my ' . strtoupper($extension) . '-' . $extension_type . '</a>'); ?> <br /> <br />
     <b>Open in a new browser Window:</b> <br />
     <?= htmlentities('<a href="http://' . $CORE['domain'] . $new_file_name . '" target="_new">Link to my ' . strtoupper($extension) . '-' . $extension_type . '</a>'); ?>
    </div>
    <div class="spacer"></div>
    <h2>BB Code</h2>
    <div class="container">
     <b>Show picture:</b> <br />
     <br /> <br />
     <b>Print link:</b> <br />
     http://<?= $CORE['domain'] . $new_file_name; ?>
    </div>
<?php
      if($TKS->has_thumbnail_support($_FILES['selector']['type']))
      {
?>
    <div class="spacer"></div>
    <h2>Thumbnail</h2>
    <div class="container">
     Path to Thumbnail:<br />
     <a href="./imageview.php?thumbnail=<?= str_replace('uploads/', '', $new_file_name); ?>" target="_new">http://<?= $CORE['domain']; ?>imageview.php?thumbnail=<?= str_replace('./uploads/', '', $new_file_name); ?></a>
    </div>
<?php
      }
?>
    <div class="spacer"></div>
<?php
      if($CORE['image_preview'] && $_POST['preview'])
      {
       if($_POST['preview'] && $extension != 'psd')
       {
?>
    <h2>Preview</h2>
    <div class="container">
     <img src="<?= $new_file_name; ?>" alt="Image preview" />
    </div>
<?php
       }
       elseif($_POST['preview'] && $extension == 'psd')
       {
?>
    <h2>Notice</h2>
    <div class="container">
     You are trying to view a not supported file format!
    </div>
<?php
       }
      }
      elseif($_POST['preview'])
      {
?>
    <h2>Notice</h2>
    <div class="container">
     The image preview feature is disabled!
    </div>
<?php
      }
     }
     else
     {
      @unlink($upload_path);
      @unlink($new_file_name);
?>
  <h2>Error</h2>
  <div class="container">
   Unable to re-name your file! <br /> <br />
   <input type="button" onclick="location.href='./';" value=" Back " />
  </div>
<?php
     }
    }
    else
    {
?>
  <h2>Error</h2>
  <div class="container">
   Error while uploading your file! Please try again, if you still get this error then contact the Webmaster. <br /> <br />
   <input type="button" onclick="location.href='./';" value=" Back " />
  </div>
<?php
    }
   }
  }
  else
  {
?>
  <h2>Public Upload</h2>
  <div class="container">
   <form action="./" method="post" enctype="multipart/form-data">
    <b>Select file:</b> <br />
    <input type="file" name="selector" size="64" />
    <input type="submit" name="progress" value=" Upload " /> <br /> <br />
    <b>Max upload size:</b> <br />
    <?= $TKS->human_size($CORE['max_upload_size']); ?> <br /> <br />
<?php
   if($CORE['image_preview'] == 1)
   {
?>
    <input type="checkbox" name="preview" value="1" id="KL_preview" /> <label for="KL_preview" class="hand">Preview my picture when uploaded (Only for PNG/GIF/JPEG Images)</label>
<?php
   }
?>
    <input type="hidden" name="MAX_FILE_SIZE" value="<?= $CORE['max_upload_size']; ?>" />
   </form>
  </div>
  <div class="spacer"></div>
  <h2>Allowed file types</h2>
  <div class="container">
   <ul>
    <li>PNG Images (Image/PNG & Image/x-PNG)</li>
    <li>GIF Images (Image/GIF & Image/x-GIF)</li>
    <li>JPEG Images (Image/JPEG, Image/x-JPEG & Image/pJPEG)</li>
    <li>Adobe Photoshop Documents (Image/x-Photoshop)</li>
    <li>Documents (Application/msword & Application/rtf)</li>
     <li>Archives (Application/zip, Application/x-zip-compressed, Application/x-rar-compressed & Application/rar)</li>
    </ul>
</div>
<?php
  }
}
elseif(!$CORE['max_upload_size'])
{
?>
  <h2>Error</h2>
  <div class="container">
   The max upload size must be greater than 0 bytes!
  </div>
<?php
}
else
{
?>
  <h2>Error</h2>
  <div class="container">
   The upload feature has been disabled by the Webmaster!
  </div>
<?php
}
require('./includes/templates/footer.php');
?>

Thank you

Link to comment
https://forums.phpfreaks.com/topic/118615-solved-auto-chmod-please-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.