From: Thyamad c. <th...@us...> - 2005-09-29 19:50:04
|
Update of /cvsroot/thyapi/thyapi/thywidgets/external/fckeditor/editor/filemanager/upload/php In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv563/thywidgets/external/fckeditor/editor/filemanager/upload/php Added Files: config.php upload.php util.php Log Message: Commiting file additions and modification from SVN revision 2028 to 2029... Changes made by frank on 2005-09-29 21:42:57 +0200 (Thu, 29 Sep 2005) corresponding to SVN revision 2029 with message: updating fckeditor in dynapi --- NEW FILE: config.php --- <?php /* * FCKeditor - The text editor for internet * Copyright (C) 2003-2005 Frederico Caldeira Knabben * * Licensed under the terms of the GNU Lesser General Public License: * http://www.opensource.org/licenses/lgpl-license.php * * For further information visit: * http://www.fckeditor.net/ * * File Name: config.php * Configuration file for the PHP File Uploader. * * File Authors: * Frederico Caldeira Knabben (fr...@fc...) */ global $Config ; // SECURITY: You must explicitelly enable this "uploader". $Config['Enabled'] = false ; // Path to uploaded files relative to the document root. $Config['UserFilesPath'] = '/UserFiles/' ; $Config['AllowedExtensions']['File'] = array() ; $Config['DeniedExtensions']['File'] = array('php','php3','php5','phtml','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg','cgi') ; $Config['AllowedExtensions']['Image'] = array('jpg','gif','jpeg','png') ; $Config['DeniedExtensions']['Image'] = array() ; $Config['AllowedExtensions']['Flash'] = array('swf','fla') ; $Config['DeniedExtensions']['Flash'] = array() ; ?> --- NEW FILE: util.php --- <?php /* * FCKeditor - The text editor for internet * Copyright (C) 2003-2005 Frederico Caldeira Knabben * * Licensed under the terms of the GNU Lesser General Public License: * http://www.opensource.org/licenses/lgpl-license.php * * For further information visit: * http://www.fckeditor.net/ * * File Name: util.php * This is the File Manager Connector for ASP. * * File Authors: * Frederico Caldeira Knabben (fr...@fc...) */ function RemoveExtension( $fileName ) { return substr( $fileName, 0, strrpos( $fileName, '.' ) ) ; } function GetRootPath() { $sRealPath = realpath( './' ) ; $sSelfPath = $_SERVER['PHP_SELF'] ; $sSelfPath = substr( $sSelfPath, 0, strrpos( $sSelfPath, '/' ) ) ; return substr( $sRealPath, 0, strlen( $sRealPath ) - strlen( $sSelfPath ) ) ; } ?> --- NEW FILE: upload.php --- <?php /* * FCKeditor - The text editor for internet * Copyright (C) 2003-2005 Frederico Caldeira Knabben * * Licensed under the terms of the GNU Lesser General Public License: * http://www.opensource.org/licenses/lgpl-license.php * * For further information visit: * http://www.fckeditor.net/ * * File Name: upload.php * This is the "File Uploader" for PHP. * * File Authors: * Frederico Caldeira Knabben (fr...@fc...) */ require('config.php') ; require('util.php') ; // This is the function that sends the results of the uploading process. function SendResults( $errorNumber, $fileUrl = '', $fileName = '', $customMsg = '' ) { echo '<script type="text/javascript">' ; echo 'window.parent.OnUploadCompleted(' . $errorNumber . ',"' . str_replace( '"', '\\"', $fileUrl ) . '","' . str_replace( '"', '\\"', $fileName ) . '", "' . str_replace( '"', '\\"', $customMsg ) . '") ;' ; echo '</script>' ; exit ; } // Check if this uploader has been enabled. if ( !$Config['Enabled'] ) SendResults( '1', '', '', 'This file uploader is disabled. Please check the "editor/filemanager/upload/php/config.php" file' ) ; // Check if the file has been correctly uploaded. if ( !isset( $_FILES['NewFile'] ) || is_null( $_FILES['NewFile']['tmp_name'] ) || $_FILES['NewFile']['name'] == '' ) SendResults( '202' ) ; // Get the posted file. $oFile = $_FILES['NewFile'] ; // Get the uploaded file name and extension. $sFileName = $oFile['name'] ; $sOriginalFileName = $sFileName ; $sExtension = substr( $sFileName, ( strrpos($sFileName, '.') + 1 ) ) ; $sExtension = strtolower( $sExtension ) ; // The the file type (from the QueryString, by default 'File'). $sType = isset( $_GET['Type'] ) ? $_GET['Type'] : 'File' ; // Get the allowed and denied extensions arrays. $arAllowed = $Config['AllowedExtensions'][$sType] ; $arDenied = $Config['DeniedExtensions'][$sType] ; // Check if it is an allowed extension. if ( ( count($arAllowed) > 0 && !in_array( $sExtension, $arAllowed ) ) || ( count($arDenied) > 0 && in_array( $sExtension, $arDenied ) ) ) SendResults( '202' ) ; $sErrorNumber = '0' ; $sFileUrl = '' ; // Initializes the counter used to rename the file, if another one with the same name already exists. $iCounter = 0 ; // The the target directory. $sServerDir = GetRootPath() . $Config["UserFilesPath"] ; while ( true ) { // Compose the file path. $sFilePath = $sServerDir . $sFileName ; // If a file with that name already exists. if ( is_file( $sFilePath ) ) { $iCounter++ ; $sFileName = RemoveExtension( $sOriginalFileName ) . '(' . $iCounter . ').' . $sExtension ; $sErrorNumber = '201' ; } else { move_uploaded_file( $oFile['tmp_name'], $sFilePath ) ; if ( is_file( $sFilePath ) ) { $oldumask = umask(0) ; chmod( $sFilePath, 0777 ) ; umask( $oldumask ) ; } $sFileUrl = $Config["UserFilesPath"] . $sFileName ; break ; } } SendResults( $sErrorNumber, $sFileUrl, $sFileName ) ; ?> |