" ;
$oCurrentFolder = opendir( $sServerDir ) ;
while ( $sFile = readdir( $oCurrentFolder ) )
{
if ( $sFile != '.' && $sFile != '..' && 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()
{
$ret = "";
$ret.= ReadCmsTree(0);
$ret.= "";
echo $ret;
}
function ReadCmsTree($st_id, $level = 0)
{
$conn = GetADODbConnection();
$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'];
}
if ( $email_templates_folder_id == "" ) $email_templates_folder_id = 0;
if ( $cms_mode == 1 ) {
$query = "
SELECT
st.st_path AS page_title,
st.*
FROM
structure_templates AS st
WHERE
st.st_parent_id = ".$st_id."
AND
st_id != ".$email_templates_folder_id."
AND
st_path != '/cms'";
}
else {
$query = "SELECT st.*, wb.eng_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'";
}
//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.'- ';
$res .= '';
$res .= ReadCmsTree($rs->fields['st_id'], $level+1);
$rs->MoveNext();
}
return $res;
}
}
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 != '..' )
{
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 ;
}
?>