コード例 #1
0
 /**
  * @param string $sDir
  *
  * @return string
  */
 protected function _makeSubdir($sDir)
 {
     if (!isset($this->aMapDir[$sDir])) {
         $this->aMapDir[$sDir] = F::Crc32($sDir, true);
     }
     return $this->aMapDir[$sDir];
 }
コード例 #2
0
ファイル: ViewerAsset.class.php プロジェクト: AntiqS/altocms
 /**
  * Calculate hash of file's dirname
  *
  * @param  string $sFile
  *
  * @return string
  */
 public function AssetFileHashDir($sFile)
 {
     if (substr($sFile, -1) == '/') {
         $sDir = $sFile;
     } else {
         $sDir = dirname($sFile);
     }
     return F::Crc32($sDir, true);
 }
コード例 #3
0
ファイル: ViewerAsset.class.php プロジェクト: anp135/altocms
 /**
  * Make path of asset file
  *
  * @param  string $sLocalFile
  * @param  string $sParentDir
  *
  * @return string
  */
 public function AssetFilePath($sLocalFile, $sParentDir = null)
 {
     if ($n = strpos($sLocalFile, '?')) {
         $sBasename = basename(substr($sLocalFile, 0, $n)) . '-' . F::Crc32(substr($sLocalFile, $n));
         $sExtension = F::File_GetExtension($sLocalFile);
         if ($sExtension) {
             $sBasename .= '.' . $sExtension;
         }
     } else {
         $sBasename = basename($sLocalFile);
     }
     $sResult = $this->AssetFileHashDir($sLocalFile) . '/' . $sBasename;
     if ($sParentDir) {
         if (substr($sParentDir, -1) != '/') {
             $sParentDir .= '/';
         }
         $sResult = $sParentDir . $sResult;
     }
     return $sResult;
 }
コード例 #4
0
 protected function _convertUrlsInCss($sContent, $sSourceDir)
 {
     // Есть ли в файле URLs
     if (!preg_match_all('/(?P<src>src:)?url\\((?P<url>.*?)\\)/is', $sContent, $aMatchedUrl, PREG_OFFSET_CAPTURE)) {
         return $sContent;
     }
     // * Обрабатываем список URLs
     $aUrls = array();
     foreach ($aMatchedUrl['url'] as $nIdx => $aPart) {
         $sPath = $aPart[0];
         //$nPos = $aPart[1];
         // * Don't touch data URIs
         if (strstr($sPath, 'data:')) {
             continue;
         }
         $sPath = str_replace(array('\'', '"'), '', $sPath);
         // * Если путь является абсолютным, то не обрабатываем
         if (substr($sPath, 0, 1) == "/" || substr($sPath, 0, 5) == 'http:' || substr($sPath, 0, 6) == 'https:') {
             continue;
         }
         if (($n = strpos($sPath, '?')) || ($n = strpos($sPath, '#'))) {
             $sPath = substr($sPath, 0, $n);
             $sFileParam = substr($sPath, $n);
         } else {
             $sFileParam = '';
         }
         if (!isset($aUrls[$sPath])) {
             // if url didn't prepare...
             $sRealPath = realpath($sSourceDir . $sPath);
             if ($sRealPath) {
                 $sDestination = F::File_GetAssetDir() . F::Crc32(dirname($sRealPath), true) . '/' . basename($sRealPath);
                 $aUrls[$sPath] = array('source' => $sRealPath, 'destination' => $sDestination, 'url' => E::ModuleViewerAsset()->AssetFileDir2Url($sDestination) . $sFileParam);
                 F::File_Copy($sRealPath, $sDestination);
             }
         }
     }
     if ($aUrls) {
         $sContent = str_replace(array_keys($aUrls), F::Array_Column($aUrls, 'url'), $sContent);
     }
     return $sContent;
 }
コード例 #5
0
ファイル: Cache.class.php プロジェクト: AlexSSN/altocms
 /**
  * @return string
  */
 public function GetCachePrefix()
 {
     $sUniqKey = C::Get(C::ALTO_UNIQUE_KEY);
     if (!$sUniqKey) {
         $sUniqKey = E::ModuleSecurity()->GenerateUniqKey();
     }
     return C::Get('sys.cache.prefix') . '_' . F::Crc32($sUniqKey, true);
 }
コード例 #6
0
ファイル: Mresource.class.php プロジェクト: hard990/altocms
 /**
  * @param string $sStorage
  * @param string $sFileName
  * @param string $sFileHash
  * @param int    $iUserId
  *
  * @return string
  */
 public static function CreateUuid($sStorage, $sFileName, $sFileHash, $iUserId)
 {
     $sUuid = '0u' . F::Crc32($iUserId . ':' . $sFileHash, true) . '-' . F::Crc32($sStorage . ':' . $sFileName . ':' . $iUserId, true) . '-' . F::Crc32($sStorage . ':' . $sFileHash . ':' . $sFileName, true);
     return $sUuid;
 }