//清空导出之前的缓存 /* 循环读取需要cache的目录*/ foreach ($arrCacheDir as $value) { compileDir($value); } /* 生成bin文件*/ if (!apc_bin_dumpfile($arrCacheFile, array(), APCBIN . DIRECTORY_SEPARATOR . BINNAME . '_' . $strDateTime)) { exit('write to ' . APCBIN . DIRECTORY_SEPARATOR . BINNAME . '_' . $strDateTime . ' failed!!!' . NEWLINE); } $strBinMd5 = md5_file(APCBIN . DIRECTORY_SEPARATOR . BINNAME . '_' . $strDateTime); /* 未被缓存的php警告*/ foreach ($arrCacheFileFailed as $value) { echo $value, " cant't to cached ....." . NEWLINE; } /* 清空被缓存文件*/ replaceFile($strBinMd5); /* 复制被过滤文件 */ moveDropFile($arrDropFile); /* 复制需要被复制文件 */ moveDropFile($arrCopyFile); /* 复制被过滤目录 */ moveDropDir($arrDropDir); exit('Apc cache done!' . NEWLINE); function compileDir($dir) { global $arrCacheFile, $arrCacheFileFailed, $arrDropDir, $arrDropFile; if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..') { if (is_dir($dir . DIRECTORY_SEPARATOR . $file)) { //exit($dir.DIRECTORY_SEPARATOR.$file);
/** * Performs a search and replace for given pattern in files in supplied * sub-folder/file * * @param array $args $args[0] contains path to sub-folder/file, * $args[1] contains the regex searching for, $args[2] contains * what it should be replaced with, $args[3] (defaults to effect) * controls the mode of operation. One of "effect", "change", or * "interactive". effect shows line number and lines matching pattern, * but commits no changes; interactive for each match, prompts user * if should do the change, change does a global search and replace * without output * @return bool $no_instructions false if should output code_tool.php * instructions */ function replace($args) { $no_instructions = false; if (isset($args[0]) && isset($args[1]) && isset($args[2])) { $path = realpath($args[0]); $no_instructions = true; $pattern = $args[1]; $replace = $args[2]; $mode = isset($args[3]) ? $args[3] : "effect"; $len = strlen($pattern); if ($len >= 2) { $pattern = preg_quote($pattern, "@"); $pattern = "@{$pattern}@"; replaceFile("", $pattern, $replace, $mode); // initialize callback mapPath($path, "replaceFile"); } } return $no_instructions; }