Ignore:
Timestamp:
Dec 18, 2005 12:16:03 AM (18 years ago)
Author:
scdev
Message:

detabbed all files ;P

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Upload.inc.php

    r41 r42  
    11<?php
    22/**
    3  * Upload.inc.php 
     3 * Upload.inc.php
    44 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
    55 *
     
    2222
    2323class Upload {
    24    
     24
    2525    // General object parameters.
    2626    var $_params = array(
    27    
     27
    2828        // Which messages do we pass to raiseMsg?
    2929        'display_messages' => UPLOAD_MSG_ALL,
    30        
     30
    3131        // Existing files will be overwritten when there is a name conflict?
    3232        'allow_overwriting' => false,
     
    222222        'ice'     => 'x-conference/x-cooltalk',
    223223    );
    224    
     224
    225225    /**
    226226     * Set (or overwrite existing) parameters by passing an array of new parameters.
     
    232232    {
    233233        if (isset($params) && is_array($params)) {
    234        
     234
    235235            // Enforce valid upload_path parameter.
    236236            if (isset($params['upload_path'])) {
     
    249249                $params['upload_path'] = preg_replace('!/+$!', '', $params['upload_path']);
    250250            }
    251        
     251
    252252            // Merge new parameters with old overriding only those passed.
    253253            $this->_params = array_merge($this->_params, $params);
     
    276276    /**
    277277     * Process uploaded files. Processes files existing within the specified $_FILES['form_name'] array.
    278      * It tests for errors, cleans the filename, optionally sets custom file names. It will process 
     278     * It tests for errors, cleans the filename, optionally sets custom file names. It will process
    279279     * multiple files automatically if the file form element is an array (<input type="file" name="myfiles[]" />).
    280280     *
     
    296296            return false;
    297297        }
    298        
     298
    299299        // Ensure the file form element specified actually exists.
    300300        if (!isset($_FILES[$form_name])) {
     
    303303            return false;
    304304        }
    305        
     305
    306306        if (is_array($_FILES[$form_name]['name'])) {
    307307            $files = $_FILES[$form_name];
     
    318318
    319319        // To keep this script running even if user tries to stop browser.
    320         ignore_user_abort(true); 
     320        ignore_user_abort(true);
    321321        ini_set('max_execution_time', 300);
    322322        ini_set('max_input_time', 300);
     
    332332                continue;
    333333            }
    334            
     334
    335335            // Determine final file name.
    336336            if ($num == 1) {
     
    362362            // Clean the file name of bad characters.
    363363            $file_name = $this->cleanFileName($file_name);
    364            
     364
    365365            // If the file name has no extension, use the mime-type extension.
    366366            if (!preg_match('/\.[^.]{1,5}$/', $file_name) && function_exists('mime_content_type')) {
     
    369369                }
    370370            }
    371            
     371
    372372            // Set the path and file name.
    373373            $file_path_name = $this->getParam('upload_path') . '/' . $file_name;
    374            
    375            
     374
     375
    376376            // Check The php upload error messages.
    377377            if (UPLOAD_ERR_INI_SIZE === $files['error'][$i]) {
     
    407407                continue;
    408408            }
    409            
     409
    410410            // Check to be sure it's an uploaded file.
    411411            if (!is_uploaded_file($files['tmp_name'][$i])) {
     
    415415                continue;
    416416            }
    417            
     417
    418418            // Check to be sure the file is not empty.
    419419            if ($files['size'][$i] < 1) {
     
    423423                continue;
    424424            }
    425            
     425
    426426            // Check to be sure the file has a valid file name extension.
    427427            if (!in_array(strtolower($this->getFilenameExtension($file_name)), $this->getParam('valid_file_extensions'))) {
     
    431431                continue;
    432432            }
    433            
     433
    434434            // Check to be sure the file has a unique file name.
    435435            if (!$this->getParam('allow_overwriting') && $this->exists($file_name)) {
     
    439439                continue;
    440440            }
    441            
     441
    442442            // Move the file to the final place.
    443443            if (move_uploaded_file($files['tmp_name'][$i], $file_path_name)) {
     
    462462            }
    463463        }
    464        
     464
    465465        // Return names of files uploaded (or empty array when none processed).
    466466        return $new_file_names;
    467467    }
    468    
     468
    469469    /**
    470470     * Remove file within upload path.
     
    481481            return false;
    482482        }
    483        
     483
    484484        $file_path_name = $this->getParam('upload_path') . '/' . $file_name;
    485485
     
    495495        }
    496496    }
    497    
     497
    498498    /**
    499499     * Renames a file within the upload path.
     
    511511            return false;
    512512        }
    513        
     513
    514514        $old_file_path_name = $this->getParam('upload_path') . '/' . $old_name;
    515515        $new_file_path_name = $this->getParam('upload_path') . '/' . $new_name;
     
    529529        }
    530530    }
    531    
     531
    532532    /**
    533533     * Tests if a file exists within the current upload_path.
     
    544544            return false;
    545545        }
    546        
     546
    547547        return file_exists($this->getParam('upload_path') . '/' . $file_name);
    548548    }
    549549
    550550    /**
    551      * Get filename by glob pattern. Searches a directory for an image that matches the 
     551     * Get filename by glob pattern. Searches a directory for an image that matches the
    552552     * specified glob pattern and returns the filename of the first file found.
    553553     *
     
    620620        return isset($ext[1]) ? $ext[1] : '';
    621621    }
    622    
     622
    623623    /**
    624624     * An alias for App::raiseMsg that only sends messages configured by display_messages.
Note: See TracChangeset for help on using the changeset viewer.