Yii Framework writes XML interface

Source: Internet
Author: User

<?PHPclassInterfacescontrollerextendscontroller{/** Member access record XML interface * 2015-07-15*/       Public functionactionmemberrecordlist () {//get parameters from URL path        $stardate=$_get[' StarDate ']; $ltime=$_get[' Ltime ']; $key=$_get[' Key ']; $mykey=MD5($stardate.$ltime.‘ ASDE89DSMM '); //determine if the Ltime request is longer than 60 seconds//Determine if the key is correct        if($key!=$mykey) {            Echo' Key error ';//indicates an illegal request            Exit(); }         if($ltime+60<= ( Time())){            Echo' Time expires ';//indicates an illegal request            Exit(); }        //satisfies the condition query user accesses the record table         $sql="select User_name,reference_url,module,action,login_ip,login_time from ' Smm_en_user_log ' Where login_time>= ' {$stardate} ' and user_name! = ' "; $result=yii::app ()->db->createcommand ($sql),Queryall (); if($result){                        $html=<?xml version= "1.0" encoding= "UTF-8"?> <memberrecordlist xmlns= "HTTP://WWW.SITEMAPS.O rg/schemas/sitemap/0.9 "xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance "Xsi:schem alocation=" http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd ">‘; foreach($result  as $key=$value) {                     if(Preg_match('/(\<*\>) +/',$value[' Action '])){                          Continue; }Else{                        $html=<recordinfo> <email>‘.$value[' user_name ']. '</email> <source>‘.$value[' Reference_url ']. '</source> <items>‘.$value[' module ']. '</items> <content>‘.$value[' Action ']. '</content> <ip>‘.$value[' Login_ip ']. '</ip> <date>‘.$value[' Login_time ']. '</date> </recordinfo>‘; }                            }                 $html. = ' </memberrecordlist> '; Echo $html; }Else{                 Echo' Sorry, the query data is empty, there is no data to meet the demand! ‘; Exit(); }          }

Yii Framework writes XML interface

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.