$client_my_id = $client_my_info["id"];
 }
 $n = 0;
 foreach ($_POST['file'] as $file) {
     $n++;
     if (!empty($file['name'])) {
         /**
          * If the uploader is a client, set the "client" var to the current
          * uploader username, since the "client" field is not posted.
          */
         if ($current_level == 0) {
             $file['assignments'] = 'c' . $global_user;
         }
         $this_upload = new PSend_Upload_File();
         if (!in_array($file['file'], $urls_db_files)) {
             $file['file'] = $this_upload->safe_rename($file['file']);
         }
         $location = $work_folder . '/' . $file['file'];
         if (file_exists($location)) {
             /**
              * If the file isn't already on the database, rename/chmod.
              */
             if (!in_array($file['file'], $urls_db_files)) {
                 $move_arguments = array('uploaded_name' => $location, 'filename' => $file['file']);
                 $new_filename = $this_upload->upload_move($move_arguments);
             } else {
                 $new_filename = $file['original'];
             }
             if (!empty($new_filename)) {
                 $delete_key = array_search($file['original'], $uploaded_files);
                 unset($uploaded_files[$delete_key]);
// Settings
$targetDir = UPLOADED_FILES_FOLDER;
$cleanupTargetDir = true;
// Remove old files
$maxFileAge = 5 * 3600;
// Temp file age in seconds
@set_time_limit(UPLOAD_TIME_LIMIT);
// Uncomment this one to fake upload time
// usleep(5000);
// Get parameters
$chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0;
$chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0;
$fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : '';
$this_file = new PSend_Upload_File();
// Rename the file
$fileName = $this_file->safe_rename($fileName);
// Make sure the fileName is unique but only if chunking is disabled
if ($chunks < 2 && file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName)) {
    $ext = strrpos($fileName, '.');
    $fileName_a = substr($fileName, 0, $ext);
    $fileName_b = substr($fileName, $ext);
    $count = 1;
    while (file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName_a . '_' . $count . $fileName_b)) {
        $count++;
    }
    $fileName = $fileName_a . '_' . $count . $fileName_b;
}
$filePath = $targetDir . DIRECTORY_SEPARATOR . $fileName;
// Create target dir
if (!file_exists($targetDir)) {
    @mkdir($targetDir);
Example #3
0
$logo_file_info = generate_logo_url();
?>

<div id="main">
	<h2><?php 
echo $page_title;
?>
</h2>

<?php 
if ($_POST) {
    /** Valid file extensions (images) */
    $image_file_types = "/^\\.(jpg|jpeg|gif|png){1}\$/i";
    if (is_uploaded_file($_FILES['select_logo']['tmp_name'])) {
        $this_upload = new PSend_Upload_File();
        $safe_filename = $this_upload->safe_rename($_FILES['select_logo']['name']);
        /**
         * Check the file type for allowed extensions.
         *
         * @todo Use the file upload class file type validation function.
         */
        if (preg_match($image_file_types, strrchr($safe_filename, '.'))) {
            /**
             * Move the file to the destination defined on sys.vars.php. If ok, add the
             * new file name to the database.
             */
            if (move_uploaded_file($_FILES['select_logo']['tmp_name'], LOGO_FOLDER . $safe_filename)) {
                $q = 'UPDATE tbl_options SET value="' . $safe_filename . '" WHERE name="logo_filename"';
                $sql = $database->query($q, $database->connection);
                $status = '1';
                /** Record the action log */