Index: branches/5.1.x/core/units/fck/fck_eh.php
===================================================================
diff -u -r12127 -r12657
--- branches/5.1.x/core/units/fck/fck_eh.php (.../fck_eh.php) (revision 12127)
+++ branches/5.1.x/core/units/fck/fck_eh.php (.../fck_eh.php) (revision 12657)
@@ -1,6 +1,6 @@
array('self' => true),
- 'OnLoadResources' => array('self' => true),
- 'OnRenameFile' => array('self' => true),
- 'OnDeleteFiles' => array('self' => true),
- 'OnGetFoldersFilesList' => array('self' => true),
- 'OnCreateFolder' => array('self' => true),
- 'OnUploadFile' => array('self' => true),
- );
-
- $this->permMapping = array_merge($this->permMapping, $permissions);
- }
-
/**
* Checks permissions of user
*
@@ -40,6 +24,7 @@
function CheckPermission(&$event)
{
if ($this->Application->LoggedIn() && $this->Application->IsAdmin()) {
+ // this limits all event execution only to logged-in users in admin
return true;
}
@@ -98,106 +83,106 @@
}
- function OnRenameFile(&$event)
- {
- $event->status = erSTOP;
- $old_name = $this->Application->GetVar('old_name');
- $new_name = $this->Application->GetVar('new_name');
- $folder = $this->Application->GetVar('folder');
- $sServerDir = WRITEABLE.'/user_files/'.$folder.'/';
+ function OnRenameFile(&$event)
+ {
+ $event->status = erSTOP;
+ $old_name = $this->Application->GetVar('old_name');
+ $new_name = $this->Application->GetVar('new_name');
+ $folder = $this->Application->GetVar('folder');
+ $sServerDir = WRITEABLE . '/user_files/' . $folder . '/';
- if (!file_exists($sServerDir.$old_name) || !is_file($sServerDir.$old_name)) {
- echo 204;
- return;
- }
+ if (!file_exists($sServerDir.$old_name) || !is_file($sServerDir.$old_name)) {
+ echo 204;
+ return;
+ }
- $fck_helper =& $this->Application->recallObject('FCKHelper');
- /* @var fck_helper fckFCKHelper*/
+ $fck_helper =& $this->Application->recallObject('FCKHelper');
+ /* @var fck_helper fckFCKHelper*/
- if (!$fck_helper->IsAllowedExtension($folder, $new_name)) {
- echo 203;
- return;
- }
+ if (!$fck_helper->IsAllowedExtension($folder, $new_name)) {
+ echo 203;
+ return;
+ }
- if (!rename($sServerDir.$old_name,$sServerDir.$new_name)) {
-// echo $sServerDir.$old_name.' -> '.$sServerDir.$new_name;
- echo 205;
- return;
+ if (!rename($sServerDir.$old_name,$sServerDir.$new_name)) {
+ // echo $sServerDir.$old_name.' -> '.$sServerDir.$new_name;
+ echo 205;
+ return;
+ }
+
+ echo '0';
}
- echo '0';
- }
+ function OnDeleteFiles(&$event)
+ {
+ $event->status = erSTOP;
+ $files = trim($this->Application->GetVar('files'),'|');
+ // echo $files;
+ $a_files = explode('|', $files);
+ $folder = $this->Application->GetVar('folder');
+ $sServerDir = WRITEABLE . '/user_files/' . $folder . '/';
- function OnDeleteFiles(&$event)
- {
- $event->status = erSTOP;
- $files = trim($this->Application->GetVar('files'),'|');
-// echo $files;
- $a_files = explode('|', $files);
- $folder = $this->Application->GetVar('folder');
- $sServerDir = WRITEABLE.'/user_files/'.$folder.'/';
+ foreach ($a_files AS $file) {
+ @unlink($sServerDir.$file);
+ }
- foreach ($a_files AS $file) {
- @unlink($sServerDir.$file);
+ // print_r($a_files);
}
-// print_r($a_files);
- }
+ function OnGetFoldersFilesList(&$event)
+ {
+ $this->CreateXmlHeader();
+ $fck_helper =& $this->Application->recallObject('FCKHelper');
+ /* @var fck_helper fckFCKHelper*/
- function OnGetFoldersFilesList(&$event)
- {
- $this->CreateXmlHeader();
- $fck_helper =& $this->Application->recallObject('FCKHelper');
- /* @var fck_helper fckFCKHelper*/
+ $ret = ''."\n" ;
+ $ret .= ""."\n";
+ $ret .= $fck_helper->PrintFolders();
+ $ret .= $fck_helper->PrintFiles();
+ $ret .= ""."\n";
+ echo $ret;
+ exit;
+ }
- $ret = ''."\n" ;
- $ret .= ""."\n";
- $ret .= $fck_helper->PrintFolders();
- $ret .= $fck_helper->PrintFiles();
- $ret .= ""."\n";
- echo $ret;
- exit;
- }
+ function OnCreateFolder(&$event)
+ {
+ $event->status = erSTOP;
- function OnCreateFolder(&$event)
- {
- $event->status = erSTOP;
+ $new_folder = $this->Application->GetVar('new_folder');
+ $current_folder = $this->Application->GetVar('current_folder');
+ $folderPath = WRITEABLE . '/user_files' . '/' . $current_folder . "/" . $new_folder;
+ if ( file_exists( $folderPath ) && is_dir($folderPath)) {
+ echo "101";
+ }
- $new_folder = $this->Application->GetVar('new_folder');
- $current_folder = $this->Application->GetVar('current_folder');
- $folderPath = WRITEABLE.'/user_files'.'/'.$current_folder."/".$new_folder;
- if ( file_exists( $folderPath ) && is_dir($folderPath)) {
- echo "101";
+ if ( !file_exists( $folderPath ) )
+ {
+ // Turn off all error reporting.
+ error_reporting( 0 ) ;
+ // Enable error tracking to catch the error.
+ ini_set( 'track_errors', '1' ) ;
+ // To create the folder with 0777 permissions, we need to set umask to zero.
+ $oldumask = umask(0) ;
+ mkdir( $folderPath, 0777 ) ;
+ umask( $oldumask ) ;
+ $sErrorMsg = $php_errormsg ;
+ // Restore the configurations.
+ ini_restore( 'track_errors' ) ;
+ ini_restore( 'error_reporting' ) ;
+ if ($sErrorMsg)
+ echo $sErrorMsg ;
+ else
+ echo '0';
+ }
}
- if ( !file_exists( $folderPath ) )
+ function OnUploadFile(&$event)
{
- // Turn off all error reporting.
- error_reporting( 0 ) ;
- // Enable error tracking to catch the error.
- ini_set( 'track_errors', '1' ) ;
- // To create the folder with 0777 permissions, we need to set umask to zero.
- $oldumask = umask(0) ;
- mkdir( $folderPath, 0777 ) ;
- umask( $oldumask ) ;
- $sErrorMsg = $php_errormsg ;
- // Restore the configurations.
- ini_restore( 'track_errors' ) ;
- ini_restore( 'error_reporting' ) ;
- if ($sErrorMsg)
- echo $sErrorMsg ;
- else
- echo '0';
+ $event->status = erSTOP;
+ $fck_helper =& $this->Application->recallObject('FCKHelper');
+ /* @var fck_helper fckFCKHelper*/
+ $fck_helper->UploadFile();
}
- }
-
- function OnUploadFile(&$event)
- {
- $event->status = erSTOP;
- $fck_helper =& $this->Application->recallObject('FCKHelper');
- /* @var fck_helper fckFCKHelper*/
- $fck_helper->UploadFile();
- }
-}
+ }
\ No newline at end of file