From 35c7ff28cbc311fba5e394b11fb756a4dc1edcb9 Mon Sep 17 00:00:00 2001 From: wei <> Date: Tue, 13 Dec 2005 07:08:30 +0000 Subject: Removed inline javascript from components. Adding TJavascriptLogger and logger.js --- framework/Web/UI/TAssetManager.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'framework/Web/UI/TAssetManager.php') diff --git a/framework/Web/UI/TAssetManager.php b/framework/Web/UI/TAssetManager.php index df189b58..dfc1fa53 100644 --- a/framework/Web/UI/TAssetManager.php +++ b/framework/Web/UI/TAssetManager.php @@ -150,7 +150,7 @@ class TAssetManager extends TModule return ''; else if(is_file($fullpath)) { - $dir=md5(dirname($fullpath)); + $dir=$this->hash(dirname($fullpath)); $file=$this->_basePath.'/'.$dir.'/'.basename($fullpath); if(!is_file($file) || $checkTimestamp || $this->_application->getMode()!=='Performance') { @@ -164,7 +164,7 @@ class TAssetManager extends TModule } else { - $dir=md5($fullpath); + $dir=$this->hash($fullpath); if(!is_dir($this->_basePath.'/'.$dir) || $checkTimestamp || $this->_application->getMode()!=='Performance') $this->copyDirectory($fullpath,$this->_basePath.'/'.$dir); $this->_published[$path]=$this->_baseUrl.'/'.$dir; @@ -172,6 +172,27 @@ class TAssetManager extends TModule } } + /** + * Generate a CRC32 hash for the directory path. Collisions are higher + * than MD5 but generates a much smaller hash string. + * @param string string to be hashed. + * @return string hashed string. + */ + private function hash($dir) + { + $num = sprintf('%u', crc32($dir)); + $base = 62; + $index = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $out = ''; + for ( $t = floor( log10( $num ) / log10( $base ) ); $t >= 0; $t-- ) + { + $a = floor( $num / pow( $base, $t ) ); + $out = $out . substr( $index, $a, 1 ); + $num = $num - ( $a * pow( $base, $t ) ); + } + return $out; + } + /** * Copies a directory recursively as another. * If the destination directory does not exist, it will be created. -- cgit v1.2.3