Index: branches/5.1.x/core/units/helpers/fck_helper.php
===================================================================
diff -u -r13086 -r13545
--- branches/5.1.x/core/units/helpers/fck_helper.php (.../fck_helper.php) (revision 13086)
+++ branches/5.1.x/core/units/helpers/fck_helper.php (.../fck_helper.php) (revision 13545)
@@ -1,6 +1,6 @@
Config['AllowedExtensions']['Files'] = array('jpg','gif','jpeg','png','swf','fla','jpg','gif','jpeg','png','avi','mpg','mpeg','zip','rar','arj','gz','tar','doc','pdf','ppt','rdp','swf','swt','txt','vsd','xls','csv','odt') ;
- $this->Config['DeniedExtensions']['Files'] = array('php','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg') ;
- $this->Config['AllowedExtensions']['Images'] = array('jpg','gif','jpeg','png', 'bmp') ;
- $this->Config['DeniedExtensions']['Images'] = array('php','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg');
- $this->Config['AllowedExtensions']['Flash'] = array('swf','fla') ;
- $this->Config['DeniedExtensions']['Flash'] = array('php','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg') ;
- $this->Config['AllowedExtensions']['Media'] = array('asf','asx','avi','wav','wax','wma','wm','wmv','m3u','mp2v','mpg','mpeg','m1v','mp2','mp3','mpa','mpe','mpv2','mp4','mid','midi','rmi','qt','aif','aifc','aiff','mov','flv','rm','svcd','swf','vcd') ;
- $this->Config['DeniedExtensions']['Media'] = array('php','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg');
- $this->Config['AllowedExtensions']['Documents'] = array('doc','pdf','ppt','rdp','swf','swt','txt','vsd','xls','csv','zip','odt') ;
- $this->Config['DeniedExtensions']['Documents'] = array('php','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg');
-
+ $this->Config['AllowedExtensions']['Files'] = Array('jpg','gif','jpeg','png','swf','fla','jpg','gif','jpeg','png','avi','mpg','mpeg','zip','rar','arj','gz','tar','doc','pdf','ppt','rdp','swf','swt','txt','vsd','xls','csv','odt');
+ $this->Config['DeniedExtensions']['Files'] = Array('php','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg');
+ $this->Config['AllowedExtensions']['Images'] = Array('jpg','gif','jpeg','png', 'bmp');
+ $this->Config['DeniedExtensions']['Images'] = Array('php','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg');
+ $this->Config['AllowedExtensions']['Flash'] = Array('swf','fla');
+ $this->Config['DeniedExtensions']['Flash'] = Array('php','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg');
+ $this->Config['AllowedExtensions']['Media'] = Array('asf','asx','avi','wav','wax','wma','wm','wmv','m3u','mp2v','mpg','mpeg','m1v','mp2','mp3','mpa','mpe','mpv2','mp4','mid','midi','rmi','qt','aif','aifc','aiff','mov','flv','rm','svcd','swf','vcd');
+ $this->Config['DeniedExtensions']['Media'] = Array('php','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg');
+ $this->Config['AllowedExtensions']['Documents'] = Array('doc','pdf','ppt','rdp','swf','swt','txt','vsd','xls','csv','zip','odt');
+ $this->Config['DeniedExtensions']['Documents'] = Array('php','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg');
+
+ $this->Config['ExtensionIcons'] = Array('ai','avi','bmp','cs','dll','doc','exe','fla','gif','htm','html','jpg','js','mdb','mp3','pdf','png','ppt','rdp','swf','swt','txt','vsd','xls','xml','zip');
}
function CreateFolder($folder = '')
@@ -53,9 +54,8 @@
function IsAllowedExtension($folder, $file_name)
{
- $base_folder = $this->getBaseFolder($folder);
- eregi("(\.[a-zA-Z0-9]{1,10})$", $file_name, $regs);
- $ext = strtolower(ltrim($regs[1],"."));
+ $base_folder = $this->getBaseFolder($folder);
+ $ext = strtolower( pathinfo($file_name, PATHINFO_EXTENSION) );
if (isset($this->Config['DeniedExtensions'][$folder])) {
if (in_array($ext, $this->Config['DeniedExtensions'][$folder])) {
return false;
@@ -71,7 +71,7 @@
function getBaseFolder($folder)
{
- $end = strpos("/", $folder);
+ $end = strpos('/', $folder);
if ($end) {
return substr($folder, 0, $end);
}
@@ -93,7 +93,6 @@
return $aFolders;
}
-
function ReadFiles($files_dir)
{
$aFiles = array();
@@ -108,25 +107,26 @@
return $aFiles;
}
-
function PrintFolders()
{
$order_by = $this->Application->GetVar('order_by');
$sort_by = $this->Application->GetVar('sort_by');
$folder = $this->Application->GetVar('folder');
- $files_dir = WRITEABLE."/user_files/".$folder."/";
- $aFolders = $this->ReadFolders($files_dir);
- $ret = '';
+ $files_dir = WRITEABLE . '/user_files/' . $folder . '/';
+ $aFolders = $this->ReadFolders($files_dir);
$order_by = $this->Application->GetVar('order_by');
$sort_by = $this->Application->GetVar('sort_by');
natcasesort($aFolders);
+
+ $ret = '';
foreach ($aFolders as $k => $v) {
$ret .= ''.$v.''."\n";
}
-
+
if ($sort_by == 'name' && $order_by == '_desc') {
$aFolders = array_reverse($aFolders);
}
+
foreach ($aFolders as $k => $v) {
$ret .= ''.$v.''."\n";
}
@@ -143,18 +143,9 @@
}
function CheckIconType($v)
- {
- $a_ext = Array('ai','avi','bmp','cs','dll','doc','exe','fla','gif','htm','html','jpg','js','mdb','mp3','pdf','png','ppt','rdp','swf','swt','txt','vsd','xls','xml','zip');
-
- eregi("(\.[a-zA-Z0-9]{1,10})$", $v, $regs);
- $ext = strtolower(ltrim($regs[1],"."));
- if (in_array($ext, $a_ext))
- {
- $icon = $ext;
- } else {
- $icon = 'default.icon';
- }
- return $icon;
+ {
+ $ext = strtolower( pathinfo($v, PATHINFO_EXTENSION) );
+ return ($ext && in_array($ext, $this->Config['ExtensionIcons']))? $ext : 'default.icon';
}
function GetXmlString($size,$url,$icon,$date,$file_name)
@@ -168,14 +159,14 @@
$sort_by = $this->Application->GetVar('sort_by');
$folder = $this->Application->GetVar('folder');
- $files_dir = WRITEABLE . "/user_files/" . $folder."/";
- $files_url = BASE_PATH . str_replace(DIRECTORY_SEPARATOR, '/', WRITEBALE_BASE) . "/user_files/" . $folder . "/";
+ $files_dir = WRITEABLE . '/user_files/' . $folder . '/';
+ $files_url = BASE_PATH . str_replace(DIRECTORY_SEPARATOR, '/', WRITEBALE_BASE) . '/user_files/' . $folder . '/';
$aFiles = $this->ReadFiles($files_dir);
$ret = '';
$date_format = "m/d/Y h:i A";
natcasesort($aFiles);
if ($sort_by == 'name' && $order_by == '_desc') {
- $aFiles = array_reverse($aFiles,TRUE);
+ $aFiles = array_reverse($aFiles, TRUE);
}
foreach ($aFiles as $k => $v)
@@ -221,17 +212,11 @@
}
function UploadFile()
- {
- $Extensions['Allowed']['Files'] = array('jpg','gif','jpeg','png','swf','fla','jpg','gif','jpeg','png','avi','mpg','mpeg','zip','rar','arj','gz','tar','doc','pdf','ppt','rdp','swf','swt','txt','vsd','xls','csv','odt') ;
- $Extensions['Allowed']['Images'] = array('jpg','gif','jpeg','png', 'bmp') ;
- $Extensions['Allowed']['Flash'] = array('swf','fla') ;
- $Extensions['Allowed']['Media'] = array('asf','asx','avi','wav','wax','wma','wm','wmv','m3u','mp2v','mpg','mpeg','m1v','mp2','mp3','mpa','mpe','mpv2','mp4','mid','midi','rmi','qt','aif','aifc','aiff','mov','flv','rm','svcd','swf','vcd') ;
- $Extensions['Allowed']['Documents'] = array('doc','pdf','ppt','rdp','swf','swt','txt','vsd','xls','csv','zip','odt') ;
-
+ {
$upload_dir = $this->Application->GetVar('upload_dir');
- $type = explode("/",$upload_dir);
+ $type = explode('/', $upload_dir);
$type = $type[0];
- $sServerDir = WRITEABLE."/user_files/".$upload_dir."/";
+ $sServerDir = WRITEABLE . '/user_files/' . $upload_dir . '/';
$aUpFile = $_FILES['NewFile'];
$sFileName = $aUpFile['name'];
@@ -240,46 +225,49 @@
$sErrorNumber = 0;
if ( isset( $_FILES['NewFile'] ) && !is_null( $_FILES['NewFile']['tmp_name'] ) )
{
- if (in_array($sExtension,$Extensions['Allowed'][$type]))
+ if (in_array($sExtension, $this->Config['AllowedExtensions'][$type]))
{
-
if (!$aUpFile['error']) {
$iCounter = 0 ;
while ( true )
{
- $sFilePath = $sServerDir . $sFileName ;
+ $sFilePath = $sServerDir . $sFileName;
if ( is_file( $sFilePath ) )
{
$iCounter++ ;
- $sFileName = $this->RemoveExtension( $sOriginalFileName ) . '(' . $iCounter . ').' . $sExtension ;
- $sErrorNumber = '201' ;
+ $sFileName = $this->RemoveExtension( $sOriginalFileName ) . '(' . $iCounter . ').' . $sExtension;
+ $sErrorNumber = '201';
}
else
{
// Turn off all error reporting.
error_reporting( 0 ) ;
+
// Enable error tracking to catch the error.
- ini_set( 'track_errors', '1' ) ;
- move_uploaded_file( $aUpFile['tmp_name'], $sFilePath ) ;
- $sErrorMsg = $php_errormsg ;
+ ini_set( 'track_errors', '1' );
+
+ move_uploaded_file( $aUpFile['tmp_name'], $sFilePath );
+ $sErrorMsg = $php_errormsg;
+
// Restore the configurations.
- ini_restore( 'track_errors' ) ;
- ini_restore( 'error_reporting' ) ;
+ ini_restore( 'track_errors' );
+ ini_restore( 'error_reporting' );
- if ( is_file( $sFilePath ) )
- {
- $oldumask = umask(0) ;
- chmod( $sFilePath, 0666 ) ;
- umask( $oldumask ) ;
+ if ( is_file( $sFilePath ) ) {
+ $oldumask = umask(0);
+ chmod( $sFilePath, 0666 );
+ umask( $oldumask );
}
break ;
}
}
}
- } else {
+ }
+ else {
$sErrorNumber = '203';
}
- } else {
+ }
+ else {
$sErrorNumber = '202' ;
}
echo '