} return $matches[1] . $curFileDir . $imgPath . $matches[4]; } $LastChangeTime = 1144055759; //文件最后的修改时间 foreach ($arrFiles as $idx => $filePath) { $realPath = realpath($filePath); if (!$realPath) { $filecontent = "/*!file " . $filePath . " does not exists*/"; } else { //取得文件列表中最近修改的文件作为拼合后文件的最后修改时间 $fileLastChangeTime = filemtime($realPath); if ($fileLastChangeTime > $LastChangeTime) { $LastChangeTime = $fileLastChangeTime; } $filecontent = readFileStr($realPath); if (preg_match("/\\.css\$|\\.less\$/", $filePath)) { //拼合css,less中的相对路径 //将 "images/abc.png|gif" (images/abc.png|gif) "images/abc.png" 中的相对路径替换成相对smartcomb.php路径 $filecontent = preg_replace_callback("/(\\(|\"|\\')([^\\)\"\\']+\\.(jpg|png|gif))(\\)|\"|\\')/im", "replaceImgPath", $filecontent); } } $content = $content . $filecontent; } if ($_REQUEST) { if ($type == "css") { header('Content-type: text/css'); } // cache reference :http://www.jonasjohn.de/snippets/php/caching.htm $HashID = md5($content); $headers = apache_request_headers();
function buildFile($filePath) { global $buildCount; $buildCount = 0; echo "\n替换文件" . $filePath . "\n"; $fileContent = readFileStr($filePath); if (preg_match("/(\"|\\')([^\"\\']+smartcomb\\.php[^\"\\']+)(|\"|\\')/im", $fileContent)) { $fileContent = preg_replace_callback("/(\"|\\')([^\"\\']+smartcomb\\.php[^\"\\']+)(\"|\\')/im", "replaceCombRef", $fileContent); } echo "文件" . $filePath . "替换" . $buildCount . "处\n"; file_put_contents($filePath, $fileContent); }
function buildFile($filePath) { global $buildCount; $buildCount = 0; echo "\n替换文件" . $filePath . "\n"; $fileContent = readFileStr($filePath); if (preg_match("/(\"|\\')([^\"\\']+[a-zA-Z0-9]{32,32}\\.[^\"\\']+)(|\"|\\')/im", $fileContent)) { $fileContent = preg_replace_callback("/(\"|\\')([^\"\\']+[a-zA-Z0-9]{32,32}\\.[^\"\\']+)(\"|\\')/im", "replaceStaticRef", $fileContent); } echo "文件" . $filePath . "替换" . $buildCount . "处\n"; file_put_contents($filePath, $fileContent); }