<?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