Ec (2); I have seen the php domain name forwarding program from other places. It is implemented through the exchange of xml and php. Let's take a look at the source file. & Lt ;? Xmlversion & quot; 1.0 & quot; encoding & quot; UTF-8 & quot ;? & Gt; & lt; urls & gt; & nbsp; & lt; num & gt; 1 & lt; num & gt; & nbsp; & lt; urlid & quot; 1 & quot; & script ec (2); script
I have seen the php domain name forwarding program from other places. It is implemented through the xml exchange with php. Let's look at the source file.
1
Test.domain.com
Http://www.111cn.net/to>
Index. php file.
/*
Pseudo-domain jump plan
By IVershuo.cn
*/
Header ("content-type: text/html; charset = UTF-8 ");
$ Xml = simplexml_load_file ("url. xml"); // xml file path
$ To = 'HTTP: // www.111cn.net '; // default redirect address
Foreach ($ xml as $ key => $ value ){
If ($ value-> domain ==$ _ SERVER ['server _ name']) {
$ To = $ value->;
Break;
}
}
Header ('location: '. $ );
?>
Process files
/*
Domain Name pseudo jump scheme, domain name jump configuration script
### Note: configuration is allowed if verification is not set. Modify the file name and xml file name when using it !!!
By IVershuo.cn
*/
$ XmlFile = 'url. xml'; // path of the xml file
$ Xml = simplexml_load_file ($ xmlFile );
$ Num = $ xml-> num [0];
If (@ $ _ POST ['domain '] & $ _ POST ['to']) {
$ XmlUrl = $ xml-> addChild ('url ');
$ XmlUrl-> addAttribute ('id', $ num + = 1 );
$ XmlUrl-> addChild ('domain ', $ _ POST ['domain']);
$ XmlUrl-> addChild ('to', $ _ POST ['to']);
$ Xml-> num [0] = $ num;
}
If (@ $ _ GET ['del ']) {
RemoveNode ($ xml, "// url [@ id = '". $ _ GET ['del']. "']", 'all ');
$ Xml-> num [0] = $ num;
}
$ Sp = fopen ($ xmlFile, "wb ");
Fwrite ($ sp, $ xml-> asXML ());
Fclose ($ sp );
Function removeNode ($ xml, $ path, $ multi = 'one '){
$ Result = $ xml-> xpath ($ path );
# For wrong $ path
If (! Isset ($ result [0]) return false;
Switch ($ multi ){
Case 'all ':
$ Errlevel = error_reporting (E_ALL &~ E_WARNING );
Foreach ($ result as $ r) unset ($ r [0]);
Error_reporting ($ errlevel );
Return true;
Case 'child ':
Unset ($ result [0] [0]);
Return true;
Case 'one ':
If (count ($ result [0]-> children () = 0 & count ($ result) = 1 ){
Unset ($ result [0] [0]);
Return true;
}
Default:
Return false;
}
}
Echo' '. "N ";
?>
Add Domain Name