Пример #1
0
 /**
  * This function calculates the base location of package in filesystem and in browser
  * This is a critical function for other packages to work properly
  * By default it points to the real path when symlinks are used
  * 
  * Site with subdomain should set siteFolderPath manually and also pass siteFolderPathBrowser (http://domain.com) 
  */
 function getCalculatedLocations($options, $parameters)
 {
     $server = $_SERVER;
     if (!isset($server['DOCUMENT_ROOT'])) {
         $server['DOCUMENT_ROOT'] = str_replace('\\', '/', substr($server['SCRIPT_FILENAME'], 0, 0 - strlen($server['PHP_SELF'])));
     }
     if (isset($server['DOCUMENT_ROOT'])) {
         if (strpos('ASD@#$@#$#23423' . dirname(__FILE__), 'ASD@#$@#$#23423' . $server['DOCUMENT_ROOT']) === false) {
             $server['DOCUMENT_ROOT'] = '/chroot' . $server['DOCUMENT_ROOT'];
         }
     }
     if (!isset($options['pageFolderPath'])) {
         $options['pageFolderPath'] = dirname($server['SCRIPT_FILENAME']);
         $options['pageFolderPath'] = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $options['pageFolderPath']);
     }
     if (!isset($options['pageFolderPathBrowser'])) {
         $options['pageFolderPathBrowser'] = dirname($server['SCRIPT_NAME']);
     }
     if (!isset($options['siteFolderPath'])) {
         $options['siteFolderPath'] = $server['DOCUMENT_ROOT'];
         if (is_link($options['siteFolderPath'])) {
             $options['siteFolderPath'] = readlink($options['siteFolderPath']);
         }
     }
     if (!isset($options['siteFolderPathBrowser'])) {
         $options['siteFolderPathBrowser'] = '';
     }
     if (!isset($options['packageFolderPath'])) {
         $options['packageFolderPath'] = dirname($parameters['filePath']);
         $options['siteFolderPath'] = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $options['siteFolderPath']);
     }
     if (!isset($options['packageFolderPathBrowser'])) {
         $fileRelativePath = $options['siteFolderPathBrowser'] . '/' . str_replace($options['siteFolderPath'], '', $options['packageFolderPath']);
         $options['packageFolderPathBrowser'] = cmfcDirectory::normalizePath($fileRelativePath);
     }
     if (!isset($options['cmfFolderPath'])) {
         $options['cmfFolderPath'] = realpath($options['packageFolderPath'] . '/../../..');
         $options['cmfFolderPath'] = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $options['cmfFolderPath']);
     }
     if (!isset($options['cmfFolderPathBrowser'])) {
         $fileRelativePath = $options['siteFolderPathBrowser'] . '/' . str_replace($options['siteFolderPath'], '', $options['cmfFolderPath']);
         $options['cmfFolderPathBrowser'] = cmfcDirectory::normalizePath($fileRelativePath);
     }
     return $options;
 }