Php domain name forwarding Program-PHP source code

Source: Internet
Author: User
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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.