Source for file OCSP_FILE.phpclass
Documentation is available at OCSP_FILE.phpclass
* openCSP class file OCSP_FILE.phpclass
* @project Open CSP-Management
* @author Peter Krebs <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: OCSP_FILE.phpclass,v 1.3 2008/11/11 07:04:42 pitlinz Exp $
// ---------------------------------------------------------
// ---------------------------------------------------------
* openCSP class OCSP_FILE
* @project Open CSP-Management
* @author Peter Krebs <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: OCSP_FILE.phpclass,v 1.3 2008/11/11 07:04:42 pitlinz Exp $
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
* @constant string CLASS_SRC_FILE
const CLASS_SRC_FILE = __FILE__
;
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
/*** class vars ------------------------------------------------------ */
/*** class methods --------------------------------------------------- */
* checks if $aFile is a file
* follows symlinks when checking
public static function isFile($aFile)
return self::isFile($aFile);
* returns a filename where some special char are converted
* unknown chars are replaced with _
* @param string $fileName
* @param string $replChar
* @since pk-08-11-05 $replChar added
return preg_replace('/[^a-z0-9_\-\.]/i', $replChar, $fileName);
* returns if a filename is an absolute path
* checks slashes in $aFile
foreach($arr_path as $str_part)
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
* factories a file object from an file upload
* @param array $upload ($_FILES['UPLOAD INPUT NAME'])
* @param string $destDir (destination directory)
* @param boolean $overwrite (replace existing file?)
public static function factoryFromUpload($upload,$destDir,$overwrite=
True,$debug=
False)
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"Error destionation does not exits: " .
$destDir);
if ($upload['error'] ==
UPLOAD_ERR_OK)
$str_name =
self::checkFileName($upload['name']);
if (!$overwrite &&
self::isFile($destDir .
$str_name))
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"Error File Exists: " .
$destDir .
$str_name);
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"Dest: " .
$destDir .
$str_name);
if (self::isFile($destDir .
$str_name))
echoDebugLine(__FILE__
,__LINE__
,"File not found: ".
$destDir .
$str_name);
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"Error: " .
$upload['error']);
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
/*** compostion --------------------------------------------------- */
/*** attributes -------------------------------------------------- */
* the file (absolut path in the system)
* @var string $myFilePath
* the file name (relative path / value set)
* @var string $myFileName
* @var boolean $fileExists
* image informations from getimagesize
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
* @return boolean (if the file exists)
// ensure the loop is terminated with a break or return
$this->myFilePath =
self::checkFilePath($_SERVER['DOCUMENT_ROOT'] .
$aFile);
* returns absoulute file path
* returns the file size in bytes
* sets the file form an upload
public function setFromUplaod($upload,$destDir,$overwrite=
False,$debug=
False)
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"Error destionation does not exits: " .
$destDir);
if ($upload['error'] ==
UPLOAD_ERR_OK)
$str_name =
self::checkFileName($upload['name']);
if (!$overwrite &&
self::isFile($destDir .
$str_name))
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"Error File Exists: " .
$destDir .
$str_name);
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"Dest: " .
$destDir .
$str_name);
return $this->setFile($destDir .
$str_name);
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"Error: " .
$upload['error']);
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
* returns the mimetype of
* @todo get mime type from T_MED_MIMETYPES
// scripts ----------------------
return "text/javascript";
return "application/jsonrequest";
// text --------------------------
return "application/octet-stream";
* returns if the file is an image
* returns the imagesize array
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
* passes the file as is to the browser
header("Status: 404 Not Found");
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
Documentation generated on Thu, 08 Jan 2009 17:45:38 +0100 by phpDocumentor 1.4.0a2