Index: branches/unlabeled/unlabeled-1.53.4/admin/editor/cmseditor/editor/filemanager/browser/default/connectors/php/commands.php =================================================================== diff -u -N -r7930 -r8699 --- branches/unlabeled/unlabeled-1.53.4/admin/editor/cmseditor/editor/filemanager/browser/default/connectors/php/commands.php (.../commands.php) (revision 7930) +++ branches/unlabeled/unlabeled-1.53.4/admin/editor/cmseditor/editor/filemanager/browser/default/connectors/php/commands.php (.../commands.php) (revision 8699) @@ -81,6 +81,15 @@ { global $Config; if (isset($Config['K4Mode'])) { + if (isset($Config['K4Mode'])) { + define('ADMIN',1); + $application =& kApplication::Instance(); + $application->Init(); + if (!$application->CheckPermission('LOGIN',1)) { + echo 'NO PERMISSION'; + return false; + } + } return true; } else { @@ -297,6 +306,7 @@ $aFileSizes = array(); $sFolders = '' ; $sFiles = '' ; + CreateServerFolder( $sServerDir ) ; $oCurrentFolder = opendir( $sServerDir ) ; while ( $sFile = readdir( $oCurrentFolder ) ) { @@ -537,21 +547,100 @@ } function DeleteConfirmedFiles($resourceType, $currentFolder, $aFiles) -{ global $Config; -$sServerDir = ServerMapFolder( $resourceType, $currentFolder ) ; -foreach ($aFiles AS $k=>$v) { - @unlink($sServerDir.$v); +{ + global $Config; + $sServerDir = ServerMapFolder( $resourceType, $currentFolder ) ; + foreach ($aFiles AS $k=>$v) { + @unlink($sServerDir.$v); + } + } +function K4DeleteFiles($resourceType, $currentFolder, $aFiles, $confirm) +{ + $application =& kApplication::Instance(); + $application->Init(); + + $conn =& $application->Conn; + + $sErrorNumber = 230; + if ($confirm == 1) { + DeleteConfirmedFiles($resourceType, $currentFolder, $aFiles); + echo '' ; + } + $ret_xml = ''; + if (!$confirm) { + // we need to check all the fields in database for the file being deleted + // this is impossible when FCK is used all over the system + // it was possible for CMS/SMS only - need to be implemented there + // in some special mode... + + + $ml_helper =& $application->recallObject('kMultiLanguageHelper'); + /* @var $ml_helper kMultiLanguageHelper */ + $langs = $ml_helper->getLanguageCount(); + + foreach ($aFiles AS $k=>$v) { + $add_sql = ''; + if ($v == '') { + continue; + } + $deleted_file = $Config['UserFilesPathNoBase'].$resourceType.$currentFolder.addslashes($v); + for($i=1; $i<=$langs; $i++) { + $add_sql.= " l".$i."_Content LIKE '%".$deleted_file."%' OR"; + } + + if (strlen($add_sql) > 0) { + $add_sql = rtrim($add_sql," OR"); + $sql = 'SELECT c.CategoryId, c.l1_Name FROM '.TABLE_PREFIX.'PageContent AS pc + LEFT JOIN '.TABLE_PREFIX.'Category AS c + ON pc.PageId = c.CategoryId + WHERE '.$add_sql; + $rs = $conn->Query($sql); + foreach ($rs as $row) { + $used = 1; + $page = $row['l'.$application->GetVar('lang_id').'_Name']; + $page = @html_entity_decode($page,ENT_NOQUOTES,'UTF-8'); + $page = @htmlspecialchars($page); + $ret_xml.= '' ; + $rs->MoveNext(); + } + } + } + if ($ret_xml && !$confirm) { + echo $ret_xml; + } + if (!$ret_xml && !$confirm) { + DeleteConfirmedFiles($resourceType, $currentFolder, $aFiles); + echo '' ; + } + } } + function DeleteFiles($resourceType, $currentFolder, $files = '', $confirm=0) { global $Config ; if ($files == '') return; //$files = rtrim("|",$files); + echo "files: [$files]"; $aFiles=explode("|",$files); if (count($aFiles) == 0) return; + + if (isset($Config['K4Mode'])) { + define('ADMIN',1); + $application =& kApplication::Instance(); + $application->Init(); + if (!$application->CheckPermission('LOGIN',1)) { + echo 'NO PERMISSION'; + return; + } + + K4DeleteFiles($resourceType, $currentFolder, $aFiles, $confirm); + return ; + } + + $conn = GetADODbConnection(); $aLangs = array(); $multilang = GetConfigValue('multilingual_mode'); @@ -573,6 +662,7 @@ DeleteConfirmedFiles($resourceType, $currentFolder, $aFiles); echo '' ; } + if (!$confirm) { foreach ($aFiles AS $k=>$v) { $add_sql = '';