Tutorial-PHP Tutorial

Source: Internet
Author: User
Game virtual domain name ◎ +. I don't know if you have recently discovered a new phenomenon on the Internet, that is, some websites are starting to provide virtual domain name services for username @ server. Thanks to the charm of @, you may be wondering if you have recently discovered a new phenomenon on the Internet, that is, some websites are starting to provide virtual domain name services for "username @ server. Thanks to the charm of "@", you may want to: "If I can provide this kind of service, how nice it is? :) the popularity must be good !" This article will unveil the "mystery" of "@", so that everyone can refer to "@"! (Do u @ today ?)
Don't worry, this is not the e-mail address, is a virtual domain name, you can access the "bbs@zphp.com" in the browser if you don't believe it ". Some friends should have used the FTP function of IE, that is, entering "password: username @ server" IE in the address bar of the browser will automatically log on to the FTP server. in Http1.1, the Http access authorization function is also provided in the form of "password: username @ server", where "password:" can be omitted, it is also to access the "bbs@zphp.com" is actually to access the "zphp.com" server as a bbs.
Then we just need to send the specific URI to the PHP program and search for the real URL redirection in the database.
Sources source code:
Script
This. location = 'gotourl. php? Url = '+ this. location. href;
Script
The above code redirects the browser to gotourl. php and assigns the variable $ url to the current URI through QueryString.
After the URI is successfully passed to the PHP program, you can enter the database to find the real URL. The following is the structure of the table corresponding to the SQL database:
Create table domain (
Id int (3) unsigned default '0' not null, # domain name ID
Domain char (20) not null, # Domain name
Gotourl char (255) not null, # real URL
);
After creating a Table, you can write gotourl. php. The program is divided into three parts:
1. analysis URL:
$ Url = preg_replace ("/^ http: // I", "", $ url); // remove "http: //" in front of the URL, which is case insensitive.
$ Url = preg_replace ("/@. + $/", "", $ url); // remove the part after "@"
The remaining URL contains only the "username" part.
To apply the log service to the database, you need to process the Ming characters:
$ Url = addslashes ($ url );
2. search for real URLs:

Bytes. Thanks to the charm of @, you may want...

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.