[svn r21625] FS#2867 - The FCKEditor, the simple file manager: Removing obsolete directories and files.

skala
Ivan Tcholakov 16 years ago
parent c61e7e67d7
commit 87d45ef6c2
  1. 8
      main/inc/lib/fckeditor/editor/filemanager/upload/index.html
  2. 44
      main/inc/lib/fckeditor/editor/filemanager/upload/php/config.php
  3. 8
      main/inc/lib/fckeditor/editor/filemanager/upload/php/index.html
  4. 241
      main/inc/lib/fckeditor/editor/filemanager/upload/php/upload.php
  5. 36
      main/inc/lib/fckeditor/editor/filemanager/upload/php/util.php
  6. 127
      main/inc/lib/fckeditor/editor/filemanager/upload/test.html

@ -1,8 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
</head>
<body>
<br />
</body>
</html>

@ -1,44 +0,0 @@
<?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/
*
* "Support Open Source software. What about a donation today?"
*
* File Name: config.php
* Configuration file for the PHP File Uploader.
*
* File Authors:
* Frederico Caldeira Knabben (fredck@fckeditor.net)
*/
global $Config ;
// SECURITY: You must explicitelly enable this "uploader".
$Config['Enabled'] = true ;
// 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') ;
$Config['DeniedExtensions']['Flash'] = array() ;
$Config['AllowedExtensions']['MP3'] = array('mp3') ;
$Config['DeniedExtensions']['MP3'] = array() ;
$Config['AllowedExtensions']['Video'] = array('avi','mpg','mpeg','mov','wmv','rm','flv') ;
$Config['DeniedExtensions']['Video'] = array() ;
?>

@ -1,8 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
</head>
<body>
<br />
</body>
</html>

@ -1,241 +0,0 @@
<?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/
*
* "Support Open Source software. What about a donation today?"
*
* File Name: upload.php
* This is the "File Uploader" for PHP.
*
* File Authors:
* Frederico Caldeira Knabben (fredck@fckeditor.net)
*/
$language_file = array('create_course');
include '../../../../../../global.inc.php';
require_once api_get_path(INCLUDE_PATH).'lib/fckeditor/repositories_config.php';
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 ;
}
function check_and_create_resource_directory($repository_path, $resource_directory, $resource_directory_name)
{
global $permissions_for_new_directories;
$resource_directory_full_path = substr($repository_path, 0, strlen($repository_path) - 1) . $resource_directory . '/';
if (!is_dir($resource_directory_full_path))
{
if (@mkdir($resource_directory_full_path, $permissions_for_new_directories))
{
// While we are in a course: Registering the newly created folder in the course's database.
if (api_is_in_course())
{
global $_course, $_user;
global $group_properties, $to_group_id;
$group_directory = !empty($group_properties['directory']) ? $group_properties['directory'] : '';
$doc_id = add_document($_course, $group_directory.$resource_directory, 'folder', 0, $resource_directory_name);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderCreated', $_user['user_id'], $to_group_id);
}
return true;
}
return false;
}
return true;
}
// 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 ;
$sType=strtolower($sType);
// Choosing the repository to be used.
if (api_is_in_course())
{
if (!api_is_in_group())
{
// 1. We are inside a course and not in a group.
if (api_is_allowed_to_edit())
{
// 1.1. Teacher
$sServerDir = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document/';
$sserverWebath = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/';
}
else
{
// 1.2. Student
$sServerDir = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document/shared_folder/sf_user_'.api_get_user_id().'/';
$sserverWebath = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/shared_folder/sf_user_'.api_get_user_id().'/';
}
}
else
{
// 2. Inside a course and inside a group.
$sServerDir = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/';
$sserverWebath = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/';
}
}
else
{
if (api_is_platform_admin() && $_SESSION['this_section'] == 'platform_admin')
{
// 3. Platform administration activities.
$sServerDir = $_configuration['root_sys'].'home/default_platform_document/';
$sserverWebath = $_configuration['root_web'].'home/default_platform_document/';
}
else
{
// 4. The user is outside courses.
$sServerDir = $_configuration['root_sys'].'main/upload/users/'.api_get_user_id().'/my_files/';
$sserverWebath = $_configuration['root_web'].'main/upload/users/'.api_get_user_id().'/my_files/';
}
}
// Set the upload path according to the resource type.
if ($sType == 'audio')
{
check_and_create_resource_directory($sServerDir, '/audio', get_lang('Audio'));
$sServerDir = $sServerDir.'audio/';
$sserverWebath = $sserverWebath.'audio/';
$path = '/audio/';
}
elseif ($sType == 'mp3')
{
$sType = 'audio';
check_and_create_resource_directory($sServerDir, '/audio', get_lang('Audio'));
$sServerDir = $sServerDir.'audio/';
$sserverWebath = $sserverWebath.'audio/';
$path = '/audio/';
}
elseif ($sType == 'flash')
{
check_and_create_resource_directory($sServerDir, '/flash', get_lang('Flash'));
$sServerDir = $sServerDir.'flash/';
$sserverWebath = $sserverWebath.'flash/';
$path = '/flash/';
}
elseif ($sType == 'images')
{
check_and_create_resource_directory($sServerDir, '/images', get_lang('Images'));
$sServerDir = $sServerDir.'images/';
$sserverWebath = $sserverWebath.'images/';
$path = '/images/';
}
elseif ($sType == 'video')
{
check_and_create_resource_directory($sServerDir, '/video', get_lang('Video'));
$sServerDir = $sServerDir.'video/';
$sserverWebath = $sserverWebath.'video/';
$path = '/video/';
}
elseif ($sType == 'video/flv')
{
check_and_create_resource_directory($sServerDir, '/video', get_lang('Video'));
check_and_create_resource_directory($sServerDir, '/video/flv', 'flv');
$sServerDir = $sServerDir.'video/flv/';
$sserverWebath = $sserverWebath.'video/flv/';
$path = '/video/flv/';
}
else
{
$path = '/';
}
// Try to add an extension to the file if it has'nt one
$sFileName = add_ext_on_mime(stripslashes($oFile['name']),$oFile['type']);
// Replace dangerous characters
$sFileName = replace_dangerous_char($sFileName,'strict');
// Transform any .php file in .phps for security
$sFileName = php2phps($sFileName);
if ( is_file( $sServerDir.$sFileName ) ){
$dotIndex = strrpos($sFileName, '.');
$ext = '';
if(is_int($dotIndex))
{
$ext = substr($sFileName, $dotIndex);
$base = substr($sFileName, 0, $dotIndex);
}
$counter = 0;
while(is_file($sServerDir.$sFileName))
{
$counter++;
$sFileName = $base.'_'.$counter.$ext;
}
}
if (!move_uploaded_file( $oFile['tmp_name'], $sServerDir.$sFileName )) $sErrorNumber = '203' ; // Check php.ini setting.
if ( is_file( $sServerDir.$sFileName ) )
{
$oldumask = umask(0) ;
chmod( $sServerDir.$sFileName, $permissions_for_new_files ) ;
umask( $oldumask ) ;
// If we are in a course we record the uploaded file in database.
if (api_is_in_course())
{
$document_name = $sFileName;
$document_size=$oFile["size"];
$group_directory = !empty($group_properties['directory']) ? $group_properties['directory'] : '';
$doc_id = add_document($_course, $group_directory.$path.$document_name, 'file', $document_size, $document_name);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentCreated', $_user['user_id'], $to_group_id);
}
}
SendResults( $sErrorNumber, $sserverWebath.$sFileName, $sFileName ) ;
?>

@ -1,36 +0,0 @@
<?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/
*
* "Support Open Source software. What about a donation today?"
*
* File Name: util.php
* This is the File Manager Connector for ASP.
*
* File Authors:
* Frederico Caldeira Knabben (fredck@fckeditor.net)
*/
function RemoveExtension( $fileName )
{
return substr( $fileName, 0, strrpos( $fileName, '.' ) ) ;
}
function GetRootPath()
{
$sRealPath = realpath( './' ) ;
$sSelfPath = api_get_self();
$sSelfPath = substr( $sSelfPath, 0, strrpos( $sSelfPath, '/' ) ) ;
return substr( $sRealPath, 0, strlen( $sRealPath ) - strlen( $sSelfPath ) ) ;
}
?>

@ -1,127 +0,0 @@
<!--
* 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/
*
* "Support Open Source software. What about a donation today?"
*
* File Name: test.html
* Test page for the "File Uploaders".
*
* File Authors:
* Frederico Caldeira Knabben (fredck@fckeditor.net)
-->
<html>
<head>
<title>FCKeditor - Uploaders Tests</title>
<script language="javascript">
function SendFile()
{
var sUploaderUrl = cmbUploaderUrl.value ;
if ( sUploaderUrl.length == 0 )
sUploaderUrl = txtCustomUrl.value ;
if ( sUploaderUrl.length == 0 )
{
alert( 'Please provide your custom URL or select a default one' ) ;
return ;
}
eURL.innerHTML = sUploaderUrl ;
txtUrl.value = '' ;
frmUpload.action = sUploaderUrl ;
frmUpload.submit() ;
}
function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg )
{
switch ( errorNumber )
{
case 0 : // No errors
txtUrl.value = fileUrl ;
alert( 'File uploaded with no errors' ) ;
break ;
case 1 : // Custom error
alert( customMsg ) ;
break ;
case 10 : // Custom warning
txtUrl.value = fileUrl ;
alert( customMsg ) ;
break ;
case 201 :
txtUrl.value = fileUrl ;
alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ;
break ;
case 202 :
alert( 'Invalid file' ) ;
break ;
case 203 :
alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ;
break ;
default :
alert( 'Error on file upload. Error number: ' + errorNumber ) ;
break ;
}
}
</script>
</head>
<body>
<table cellSpacing="0" cellPadding="0" width="100%" border="0" height="100%">
<tr>
<td>
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td nowrap>
Select the "File Uploader" to use:<br>
<select id="cmbUploaderUrl" name="Select1">
<option selected value="asp/upload.asp">ASP</option>
<option value="aspx/upload.aspx">ASP.Net</option>
<option value="php/upload.php">PHP</option>
<option value="">(Custom)</option>
</select>
</td>
<td nowrap>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td width="100%">
Custom Uploader URL:<BR>
<input id="txtCustomUrl" style="WIDTH: 100%; BACKGROUND-COLOR: #dcdcdc" disabled type="text">
</td>
</tr>
</table>
<br>
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td noWrap>
<form id="frmUpload" target="UploadWindow" enctype="multipart/form-data" action="" method="post">
Upload a new file:<br>
<input type="file" name="NewFile"><br>
<input type="button" value="Send it to the Server" onclick="SendFile();">
</form>
</td>
<td style="WIDTH: 16px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td vAlign="top" width="100%">
Uploaded File URL:<br>
<INPUT id="txtUrl" style="WIDTH: 100%" readonly type="text">
</td>
</tr>
</table>
<br>
Post URL: <span id="eURL">&nbsp;</span>
</td>
</tr>
<tr>
<td height="100%">
<iframe name="UploadWindow" width="100%" height="100%" src="../../fckblank.html"></iframe>
</td>
</tr>
</table>
</body>
</html>
Loading…
Cancel
Save