function CreateXmlHeader($command, $resourceType, $currentFolder) { // Create the XML document header. echo '<?xml version="1.0" encoding="utf-8" ?>'; // Create the main "Connector" node. echo '<Connector command="' . $command . '" resourceType="' . $resourceType . '">'; // Add the current folder node. echo '<CurrentFolder path="' . ConvertToXmlAttribute($currentFolder) . '" url="' . ConvertToXmlAttribute(GetUrlFromPath($resourceType, $currentFolder)) . '" />'; }
function GetFoldersAndFiles($resourceType, $currentFolder) { global $Config; // Map the virtual path to the local server path. $sServerDir = ServerMapFolder($resourceType, $currentFolder, 'GetFoldersAndFiles'); $sCurrentPath = GetUrlFromPath($resourceType, $currentFolder, 'GetFoldersAndFiles'); // Arrays that will hold the folders and files names. $aFolders = array(); $aFiles = array(); $oCurrentFolder = opendir($sServerDir); while ($sFile = readdir($oCurrentFolder)) { if ($sFile != '.' && $sFile != '..') { if (is_dir($sServerDir . $sFile)) { $aFolders[] = '<Folder name="' . ConvertToXmlAttribute($sFile) . '" size="' . filemanager_dirsize($sServerDir . $sFile) . '"/>'; } else { $iFileSize = @filesize($sServerDir . $sFile); if (!$iFileSize) { $iFileSize = 0; } if ($iFileSize > 0) { $iFileSize = filemanager_size($iFileSize); } if ($resourceType == 'Image' && $Config['ThumbList']) { $new = filemanager_getthumbname($currentFolder . $sFile); if (file_exists(CombinePaths($_SERVER['DOCUMENT_ROOT'] . GetResourceTypePath('ImageThumb', 'GetFoldersAndFiles'), $new))) { $t = CombinePaths(GetResourceTypePath('ImageThumb', 'GetFoldersAndFiles'), $new); } else { $t = 'X'; } list($w, $h) = getimagesize($sServerDir . $sFile); $add = 'thumb="' . ConvertToXmlAttribute($t) . '" width="' . $w . '" height="' . $h . '"'; } else { $add = ''; } $aFiles[] = '<File name="' . ConvertToXmlAttribute($sFile) . '" size="' . $iFileSize . '" ' . $add . '/>'; } } } // Send the folders natcasesort($aFolders); echo '<Folders>'; foreach ($aFolders as $sFolder) { echo $sFolder; } echo '</Folders>'; // Send the files natcasesort($aFiles); echo '<Files>'; foreach ($aFiles as $sFiles) { echo $sFiles; } echo '</Files>'; }
function CreateXmlHeader($command, $resourceType, $currentFolder) { global $Config; SetXmlHeaders(); // Create the XML document header. echo '<?xml version="1.0" encoding="utf-8" ?>'; // Create the main "Connector" node. echo '<Connector command="' . $command . '" resourceType="' . $resourceType . '">'; // Add the current folder node. $url = GetUrlFromPath($resourceType, $currentFolder, $command); $absurl = $Config['k_append_url'] . $url; echo '<CurrentFolder path="' . ConvertToXmlAttribute($currentFolder) . '" url="' . ConvertToXmlAttribute($url) . '" absurl="' . ConvertToXmlAttribute($absurl) . '" />'; $GLOBALS['HeaderSent'] = true; }