" ; $oCurrentFolder = opendir( $sServerDir ) ; while ( $sFile = readdir( $oCurrentFolder ) ) { if ( $sFile != '.' && $sFile != '..' && $sFile != 'CVS' && is_dir( $sServerDir . $sFile ) ) echo '' ; } closedir( $oCurrentFolder ) ; // Close the "Folders" node. echo "" ; } /* function GetCmsTree() { $conn = GetADODbConnection(); $query="SELECT st.* , wb.eng_content AS page_title FROM structure_templates st LEFT JOIN working_blocks AS wb ON (st.st_id = wb.template_id) AND (wb.block_type = 3) WHERE st_id != '5' AND st_path != '/cms' GROUP BY st_id ORDER BY st_lastupdate desc"; $rs = $conn->Execute($query); if ($rs && !$rs->EOF) { $ret = ""; while($rs && !$rs->EOF) { $ret.= ''; //echo $rs->fields['page_title']."
"; $rs->MoveNext(); } $ret.= '
'; echo $ret; } } */ function GetCmsTree() { global $Config; $ret = ""; if (isset($Config['K4Mode'])) { $ret.= K4ReadCmsTree(0); } else { $ret.= ReadCmsTree(0); } $ret.= ""; echo $ret; } function K4ReadCmsTree($cat_id, $level = 0) { $application =& kApplication::Instance(); $application->Init(); $query = 'SELECT Path, Title FROM '.TABLE_PREFIX.'Pages ORDER By Title'; $pages = $application->DB->Query($query); $res = ''; foreach ($pages as $page) { $page_path = $page['Path'].'.html'; $title = $page['Title'].' ('.$page_path.')'; $res .= ''; } return $res; } function ReadCmsTree($st_id, $level = 0) { $conn = GetADODbConnection(); $query = "SELECT value FROM config WHERE name = 'default_lang_prefix'"; $rs = $conn->Execute($query); if ($rs && !$rs->EOF) { $default_lang_prefix = $rs->fields['value']; } $query = "SELECT value FROM config WHERE name = 'cms_direct_mode'"; $rs = $conn->Execute($query); if ($rs && !$rs->EOF) { $cms_mode = $rs->fields['value']; } $query = "SELECT value FROM config WHERE name = 'email_templates_folder_id'"; $rs = $conn->Execute($query); if ($rs && !$rs->EOF) { $email_templates_folder_id = $rs->fields['value']; } /* $query = "SELECT value FROM config WHERE name = 'custom_cms'"; $rs = $conn->Execute($query); if ($rs && !$rs->EOF) { $custom_cms = $rs->fields['value']; } */ if ( $email_templates_folder_id == "" ) $email_templates_folder_id = 0; if ( $cms_mode == 1 ) { $query = " SELECT st.*, IF(lb.".$default_lang_prefix."_content='' OR lb.".$default_lang_prefix."_content IS NULL, st.st_path, lb.".$default_lang_prefix."_content ) AS page_title FROM structure_templates AS st LEFT JOIN live_blocks AS lb ON (st.st_id = lb.template_id) AND (lb.block_type = 3) WHERE st.st_parent_id = ".$st_id." AND st_id != ".$email_templates_folder_id." AND st_path != '/cms' ORDER BY st.st_order"; } else { $query = " SELECT st.*, IF(wb.".$default_lang_prefix."_content='' OR wb.".$default_lang_prefix."_content IS NULL, st.st_path, wb.".$default_lang_prefix."_content ) AS page_title FROM structure_templates AS st LEFT JOIN working_blocks AS wb ON (st.st_id = wb.template_id) AND (wb.block_type = 3) WHERE st.st_parent_id = ".$st_id." AND st_id != ".$email_templates_folder_id." AND st_path != '/cms%' ORDER BY st.st_order"; } //echo $query."
"; $rs = $conn->Execute($query); if ($rs && !$rs->EOF) { while ($rs && !$rs->EOF) { $page_path = ltrim($rs->fields['st_path'], '/'); //$page_path = SERVER_NAME.BASE_PATH.'/index.php?t='.$page_path; //$page_path = $page_path; $prefix=''; for ($i = 0; $i < $level; $i++) $prefix .= '--'; if ($level > 0) $prefix=$prefix.'- '; $page = ereg_replace("&","&",$rs->fields['page_title']); $page = ereg_replace("\"",""",$page); $page = ereg_replace("'","'",$page); $page = ereg_replace("<","<",$page); $page = ereg_replace(">",">",$page); // echo $page."
"; //$page = htmlentities($rs->fields['page_title'],ENT_QUOTES); $page = $rs->fields['page_title']; $page = ereg_replace("ã","a",$page); $res .= ''; $res .= ReadCmsTree($rs->fields['st_id'], $level+1); $rs->MoveNext(); } return $res; } } /* $res .= ' <![CDATA['.$prefix.$page.']]> fields['st_id'].']]> '; */ function GetFoldersAndFiles( $resourceType, $currentFolder ) { // Map the virtual path to the local server path. $sServerDir = ServerMapFolder( $resourceType, $currentFolder ) ; // Initialize the output buffers for "Folders" and "Files". $sFolders = '' ; $sFiles = '' ; $oCurrentFolder = opendir( $sServerDir ) ; while ( $sFile = readdir( $oCurrentFolder ) ) { if ( $sFile != '.' && $sFile != '..' && $sFile != 'CVS') { if ( is_dir( $sServerDir . $sFile ) ) $sFolders .= '' ; else { $iFileSize = filesize( $sServerDir . $sFile ) ; if ( $iFileSize > 0 ) { $iFileSize = round( $iFileSize / 1024 ) ; if ( $iFileSize < 1 ) $iFileSize = 1 ; } $sFiles .= '' ; } } } echo $sFolders ; // Close the "Folders" node. echo '' ; echo $sFiles ; // Close the "Files" node. echo '' ; } function CreateFolder( $resourceType, $currentFolder ) { $sErrorNumber = '0' ; $sErrorMsg = '' ; if ( isset( $_GET['NewFolderName'] ) ) { $sNewFolderName = $_GET['NewFolderName'] ; // Map the virtual path to the local server path of the current folder. $sServerDir = ServerMapFolder( $resourceType, $currentFolder ) ; if ( is_writable( $sServerDir ) ) { $sServerDir .= $sNewFolderName ; $sErrorMsg = CreateServerFolder( $sServerDir ) ; switch ( $sErrorMsg ) { case '' : $sErrorNumber = '0' ; break ; case 'Invalid argument' : case 'No such file or directory' : $sErrorNumber = '102' ; // Path too long. break ; default : $sErrorNumber = '110' ; break ; } } else $sErrorNumber = '103' ; } else $sErrorNumber = '102' ; // Create the "Error" node. echo '' ; } function FileUpload( $resourceType, $currentFolder ) { $sErrorNumber = '0' ; $sFileName = '' ; if ( isset( $_FILES['NewFile'] ) && !is_null( $_FILES['NewFile']['tmp_name'] ) ) { $oFile = $_FILES['NewFile'] ; // Map the virtual path to the local server path. $sServerDir = ServerMapFolder( $resourceType, $currentFolder ) ; // Get the uploaded file name. $sFileName = $oFile['name'] ; $sOriginalFileName = $sFileName ; $sExtension = substr( $sFileName, ( strrpos($sFileName, '.') + 1 ) ) ; global $Config ; $arAllowed = $Config['AllowedExtensions'][$resourceType] ; $arDenied = $Config['DeniedExtensions'][$resourceType] ; if ( ( count($arAllowed) == 0 || in_array( $sExtension, $arAllowed ) ) && ( count($arDenied) == 0 || !in_array( $sExtension, $arDenied ) ) ) { $iCounter = 0 ; while ( true ) { $sFilePath = $sServerDir . $sFileName ; 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 ) ; } break ; } } } else $sErrorNumber = '202' ; } else $sErrorNumber = '202' ; echo '' ; exit ; } ?>