Advertisement router development (ii) practices

Source: Internet
Author: User

The previous article analyzes the data streams between authpuppy under wifidog. In this article, I will introduce how to write a simple advertising router.

After the above analysis, it is not difficult to see that it is very simple to implement an advertising router.

Because I am not familiar with the symfony framework, the following sample code uses the Phalcon framework for writing (only for demonstration)


<? Phpnamespace controllers; Class interfacecontroller extends \ Phalcon \ MVC \ controller {public function initialize () {} public function indexaction () {} public function loginaction () {if ($ this-> request-> isget () & null = $ this-> request-> getquery ('advs ')) {$ strdebug = var_export ($ _ server, true); $ this-> View-> setvar ('frefreshtime', 10 ); // The advertising time is 10 seconds. $ this-> View-> setvar ('url', $ this-> request-> getserver ('Request _ URI '). '& ADVs = ADVs'); $ this-> View-> pick ('interface/ADVs '); // here, the advertisement is displayed.} else {$ this-> View-> disable (); $ strtoken = sha1 (RAND (). time (); $ this-> persistent-> set ('redirecturl', $ this-> request-> getquery ('url ')); $ this-> response-> redirect ('HTTP ://'. $ this-> request-> get ('gw _ address '). ':'. $ this-> request-> get ('gw _ port '). '/wifidog/auth? Token = '. $ strtoken, true) ;}} public function logoutaction () {echo 'auth: 0';} public function portalaction () {// jump to $ this-> View-> disable (); If (null! = $ Strurl = $ this-> persistent-> get ('redirecturl') {$ this-> response-> redirect ($ strurl, true );} else {$ this-> response-> redirect ('HTTP: // blog.csdn.net/qzfzz', true) ;}} public function pingaction () {echo 'pong ';} public function msgaction () {} public function authaction () {echo 'auth: 1 ';}}


View

<! -- ADVs. phtml --> <! Doctype HTML <HTML> 

After the above development, a simple advertising router is completed.

Advertisement router development (ii) practices

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.