[ Index ]
 

Code source de GeekLog 1.4.1

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/system/classes/ -> upload.class.php (sommaire)

(pas de description)

Poids: 1245 lignes (43 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

upload:: (42 méthodes):
  upload()
  _addWarning()
  _addError()
  _addDebugMsg()
  _logItem()
  _setAvailableMimeTypes()
  _isImage()
  _fileSizeOk()
  _imageSizeOK()
  _getImageDimensions()
  _calcSizefactor()
  _keepOriginalFile()
  _getDestinationName()
  _getPermissions()
  _copyFile()
  setMogrifyPath()
  setNetPBM()
  setGDLib()
  setAutomaticResize()
  setMaxFileSize()
  setMaxDimensions()
  setMaxFileUploads()
  keepOriginalImage()
  limitByIP()
  setContinueOnError()
  setLogFile()
  setLogging()
  loggingEnabled()
  setDebug()
  printErrors()
  printWarnings()
  printDebugMsgs()
  areErrors()
  setAllowedMimeTypes()
  getAllowedMimeTypes()
  checkMimeType()
  setPath()
  getPath()
  setFileNames()
  setPerms()
  numFiles()
  uploadFiles()


Classe: upload  - X-Ref

This class will allow you to securely upload one or more files from a form
submitted via POST method.  Please read documentation as there are a number of
security related features that will come in handy for you.

upload()   X-Ref
Constructor


_addWarning($warningText)   X-Ref
Adds a warning that was encountered

param: string  $warningText     Text of warning

_addError($errorText)   X-Ref
Adds an error that was encountered

param: string      $errorText      Text of error

_addDebugMsg($debugText)   X-Ref
Adds a debug message

param: string      $debugText      Text of debug message

_logItem($logtype, $text)   X-Ref
Logs an item to the log file

param: string      $logtype    can be 'warning' or 'error'
param: string      $text       Text to log to log file
return: boolean     Whether or not we successfully logged an item

_setAvailableMimeTypes($mimeTypes = array()   X-Ref
Defines superset of available Mime types.

param: array   $mimeTypes  string array of valid mime types this object will accept

_isImage()   X-Ref
Checks if current file is an image

return: boolean   returns true if file is an image, otherwise false

_fileSizeOk()   X-Ref
Verifies the file size meets specified size limitations

return: boolean   returns true of file size is within our limits otherwise false

_imageSizeOK($doResizeCheck=true)   X-Ref
Checks to see if file is an image and, if so, whether or not
it meets width and height limitations

return: boolean     returns true if image height/width meet our limitations otherwise false

_getImageDimensions()   X-Ref
Gets the width and height of an image

return: array     Array with width and height of current image

_calcSizefactor($width, $height)   X-Ref
Calculate the factor to scale images with if they're not meeting
the size restrictions.

param: int     $width      width of the unscaled image
param: int     $height     height of the unscaled image
return: double              resize factor

_keepOriginalFile($filename)   X-Ref
Keep the original (unscaled) image file, if configured.

param: string  $filename   name of uploaded file
return: bool                true: okay, false: an error occured

_getDestinationName()   X-Ref
Gets destination file name for current file

return: string    returns destination file name

_getPermissions()   X-Ref
Gets permissions for a file.  This is used to do a chmod

return: string  returns final permisisons for current file

_copyFile()   X-Ref
This function actually completes the upload of a file

return: boolean     true if copy succeeds otherwise false

setMogrifyPath($path_to_mogrify)   X-Ref
Sets the path to where the mogrify ImageMagic function is

param: string    $path_to_mogrify    Absolute path to mogrify
return: boolean   True if set, false otherwise

setNetPBM($path_to_netpbm)   X-Ref
Sets the path to where the netpbm utilities are

param: string    $path_to_netpbm    Absolute path to netpbm dir
return: boolean   True if set, false otherwise

setGDLib()   X-Ref
Configure upload to use GD library

return: boolean   True if set, false otherwise

setAutomaticResize($switch)   X-Ref
Sets mode to automatically resize images that are either too wide or
too tall

param: boolean    $switch  True to turn on, false to turn off

setMaxFileSize($size_in_bytes)   X-Ref
Allows you to override default max file size

param: int     $size_in_bytes      Max. size for uploaded files
return: boolean true if we set it OK, otherwise false

setMaxDimensions($width_pixels, $height_pixels)   X-Ref
Allows you to override default max. image dimensions

param: int    $width_pixels    Max. width allowed
param: int    $height_pixels   Max. height allowed
return: boolean true if we set values OK, otherwise false

setMaxFileUploads($maxfiles)   X-Ref
Sets the max number of files that can be uploaded per form

param: int       $maxfiles    Maximum number of files to allow. Default is 5
return: boolean   True if set, false otherwise

keepOriginalImage($keepit)   X-Ref
Allows you to keep the original (unscaled) image.

param: boolean   $keepit   true = keep original, false = don't
return: boolean   true if we set values OK, otherwise false

limitByIP($validIPS = array('127.0.0.1')   X-Ref
Extra security option that forces all attempts to upload a file to be done
so from a set of VERY specific IP's.  This is only good for those who are
paranoid

param: array   $validIPS   Array of valid IP addresses to allow file uploads from
return: boolean returns true if we successfully limited the IP's, otherwise false

setContinueOnError($switch)   X-Ref
Allows you to specify whether or not to continue processing other files
when an error occurs or exit immediately. Default is to exit immediately

NOTE: this only affects the actual file upload process.

param: boolean     $switch     true or false

setLogFile($logFile = '')   X-Ref
Sets log file

param: string  $fileName   fully qualified path to log files
return: boolean returns true if we set the log file, otherwise false

setLogging($switch)   X-Ref
Enables/disables logging of errors and warnings

param: boolean     $switch     flag, true or false

loggingEnabled()   X-Ref
Returns whether or not logging is enabled

return: boolean returns true if logging is enabled otherwise false

setDebug($switch)   X-Ref
Will force the debug messages in this class to be
printed

param: boolean     $switch     flag, true or false

printErrors($verbose=true)   X-Ref
This function will print any errors out.  This is useful in debugging

param: boolean     $verbose    whether or not to print immediately or return only a string
return: string  if $verbose is false it returns all errors otherwise just an empty string

printWarnings()   X-Ref
This function will print any warnings out.  This is useful in debugging


printDebugMsgs()   X-Ref
This function will print any debmug messages out.


areErrors()   X-Ref
Returns if any errors have been encountered thus far

return: boolean returns true if there were errors otherwise false

setAllowedMimeTypes($mimeTypes = array()   X-Ref
Sets allowed mime types for this instance

param: array   allowedMimeTypes        Array of allowed mime types

getAllowedMimeTypes()   X-Ref
Gets allowed mime types for this instance

return: array   Returns array of allowed mime types

checkMimeType()   X-Ref
Checks to see that mime type for current file is allowed for upload

return: boolean     true if current file's mime type is allowed otherwise false

setPath($uploadDir)   X-Ref
Sets file upload path

param: string  $uploadDir  Directory on server to store uploaded files
return: boolean returns true if we successfully set path otherwise false

getPath()   X-Ref
Returns directory to upload to

return: string  returns path to file upload directory

setFileNames($fileNames = 'geeklog_uploadedfile')   X-Ref
Sets file name(s) for files

This function will set the name of any files uploaded.  If the
number of file names sent doesn't match the number of uploaded
files a warning will be generated but processing will continue

param: string|array    $fileNames      A string or string array of file names

setPerms($perms)   X-Ref
Changes permissions for uploaded files.  If only one set of perms is
sent then they are applied to all uploaded files.  If more then one set
of perms is sent (i.e. $perms is an array) then permissions are applied
one by one.  Any files not having an associated permissions will be
left alone.  NOTE: this is meant to be called BEFORE you do the upload
and ideally is called right after setFileNames()

param: string|array    $perms      A string or string array of file permissions

numFiles()   X-Ref
Returns how many actual files were sent for upload.  NOTE: this will
ignore HTML file fields that were left blank.

return: int returns number of files were sent to be uploaded

uploadFiles()   X-Ref
Uploads any posted files.

return: boolean returns true if no errors were encountered otherwise false



Généré le : Wed Nov 21 12:27:40 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics