If your URL link is relative to the path "Static/mapi.css", you want to replace him in bulk with the absolute path "http://dev.baidu.com/wiki/static/map/cloud/static/mapi.css". Well, you can do this:
Write a php file and write the URL that needs to be replaced.
The meaning of this code is to replace #base_url# with http://api.map.baidu.com/lbsapi/cloud/.
The meaning of this sentence is to replace the contents of the resource file, and then put it in the Cloud folder. Fileutil::copydir ("Resource", "cloud", true);
copy code code as follows:
<?php
//need to replace the keyword
$GLOBALS ["patterns"] = Array (
"/#BASE_URL #/"
);
//replacement content, and the above matching rule one by one corresponds
$GLOBALS ["replacements"] = Array (
"http://api.map.baidu.com/lbsapi/cloud/"
//"http://172.22.168.178/lbsapi/"
//"http://dev.baidu.com/wiki/static/map/cloud/"
);
/**
* Manipulating File class
*
* Example:
* Fileutil::copydir (' B ', ' d/e '); Test the Replication folder create a d/e folder and copy the contents of the B folder
* Fileutil::copyfile (' b/1/2/3.exe ', ' b/b/3.exe '); Test the copy file to create a b/b folder and copy the 3.exe files in the B/1/2 folder
* Fileutil::createdir (' A/1/2/3 '); Test build folder Build a A/1/2/3 folder
* Fileutil::unlinkfile (' b/d/3.exe '); Test Delete file Delete b/d/3.exe file
*/
class Fileutil {
/**
* Create Folder
*
* @param string $aimUrl
* @return Viod
*/
function Createdir ($AIMURL) {
$aimUrl = Str_replace (', '/', $AIMURL);
$aimDir = ';
$arr = explode ('/', $AIMURL);
foreach ($arr as $str) {
$aimDir. = $str. '/';
if (!file_exists ($aimDir)) {
mkdir ($aimDir);
}
}
}
/**
* Delete File
*
* @param string $aimUrl
* @return Boolean
*/
function Unlinkfile ($AIMURL) {
if (file_exists ($AIMURL)) {
unlink ($AIMURL);
return true;
} else {
return false;
}
}
/**
* Copy Folder
*
* @param string $oldDir
* @param string $aimDir
* @param boolean $overWrite This parameter controls whether to overwrite the original file
* @return Boolean
*/
function Copydir ($oldDir, $aimDir, $overWrite = False) {
$aimDir = Str_replace (', '/', $aimDir);
$aimDir = substr ($aimDir,-1) = = '/'? $aimDir: $aimDir. ' /';
$oldDir = Str_replace (', '/', $oldDir);
$oldDir = substr ($oldDir,-1) = = '/'? $oldDir: $oldDir. ' /';
if (!is_dir ($oldDir)) {
return false;
}
if (!file_exists ($aimDir)) {
Fileutil::createdir ($aimDir);
}
$dirHandle = Opendir ($oldDir);
while (false!== ($file = Readdir ($dirHandle))) {
if ($file = = '. ' | | $file = = ' ... ') {
continue;
}
if (!is_dir ($oldDir. $file)) {
fileutil::copyfile ($oldDir. $file, $aimDir. $file, $overWrite);
} else {
Fileutil::copydir ($oldDir. $file, $aimDir. $file, $overWrite);
}
}
return Closedir ($dirHandle);
}
/**
* Copy File
*
* @param string $fileUrl
* @param string $aimUrl
* @param boolean $overWrite This parameter controls whether to overwrite the original file
* @return Boolean
*/
function CopyFile ($FILEURL, $aimUrl, $overWrite = False) {
if (!file_exists ($FILEURL)) {
return false;
}
if (file_exists ($AIMURL) && $overWrite = = False) {
return false;
} elseif (File_exists ($AIMURL) && $overWrite = = True) {
Fileutil::unlinkfile ($AIMURL);
}
$aimDir = dirname ($AIMURL);
Fileutil::createdir ($aimDir);
copy ($FILEURL, $AIMURL);
//substitution variable
$apiFilePointer = fopen ($aimUrl, ' R ');
$apiFileContent = fread ($apiFilePointer, FileSize ($AIMURL));
//Only in JS, HTML, CSS file replacement
if (Preg_match (. js|). html|. css|. HTM) $/', $aimUrl)) {
$apiFileContent = preg_replace ($GLOBALS ["patterns"], $GLOBALS ["replacements"], $apiFileContent);
}
fclose ($apiFilePointer);
echo $aimUrl. " RN ";
$apiFilePointer = fopen ($aimUrl, ' w+ ');
fwrite ($apiFilePointer, $apiFileContent);
fclose ($apiFilePointer);
//substitution variable
return true;
}
}
Fileutil::copydir ("Resource", "cloud", true);
?>
Then write a bat batch file to run this PHP.
PHP release.php
Now, just click on the bat file and the relative address in the entire page becomes an absolute address.