I asked a question in CSDN when I wanted to implement a function in PHP Author: Chuwen Time: 2021-06-28 Classification: talk of everything under the sun ##Subject matter When I was free, I suddenly searched my * * QQ trumpet * * on Google. Unexpectedly, there would be unexpected gains. I even raised a question about PHP on CSDN five or six years ago (October 28, 2015) ! []( https://cdn.nowtime.cc/2021/06/28/2150184956.png ) ! []( https://cdn.nowtime.cc/2021/06/28/3178275766.png ) Original content: ``` <? php $auth= http://g.xsscp.com/include/code1.php?url= $_SERVER['HTTP_HOST']"; <? php $url = " http://g.xsscp.com/include/code1.php?url= $_SERVER['HTTP_HOST']"; $html = file_get_contents($url); if(!in_array($_SERVER['HTTP_HOST'], array(echo $html;))) { Exit ('64407039 reminds you that your domain name is not authorized! Or you can access it directly through the website! For authorization, please contact QQ: 644407039 '); } ?> It's just not enough. Please help me, The idea is as follows hypothesis $_SERVER['HTTP_HOST']" Equal to r.xsscp.com So this website http://g.xsscp.com/include/code1.php?url= $_SERVER['HTTP_HOST']" Becomes http://g.xsscp.com/include/code1.php?url=r.xsscp.com If authorized, return to the current URL And passed. If there is no authorization, return No Admittance Benefiting from dripping water, when Yongquan reports pictures If the above code doesn't work, you can refer to the following figure for design. This code is sent by someone else and is also authorized. Only part of it has been shown. ``` ###Let's look at the code: >Bad writing and grammar mistakes ```php <? php $url = " http://g.xsscp.com/include/code1.php?url= $_SERVER['HTTP_HOST']"; $html = file_get_contents($url); if(!in_array($_SERVER['HTTP_HOST'], array(echo $html;))) { Exit ('64407039 reminds you that your domain name is not authorized! Or you can access it directly through the website! For authorization, please contact QQ: 644407039 '); } ?> ``` ##It's not over yet. I searched my QQ again >Then I found the code I wrote. I don't know the exact age. At this time, I should have mastered the use of MySQL in PHP. I should know a little about regular SQL statements. But at this time, only the class library written by others will be called, and the native 'mysql' and 'mysqli' will not > >As can be seen from the following, I still don't understand the 'return' statement, which results in 'if else' infinite nesting. After I learned 'ThinkPHP', I learned that the method will terminate execution when it encounters a retrn > >In addition, the grammar is not rigorous, thinking that there is only success and no failure ```php <? php class API{ function idiom($idiom){ global $DB; If (stristr ($idiom, 'Idiom Solitaire')){ $idiom=explore ('Idiom Solitaire ', $idiom); if($idiom['1']){ $row=$DB->get_row("SELECT * FROM `api_idiom` WHERE `name`='{$idiom['1']}' LIMIT 1"); if($row['name']==$idiom['1']){ $count=utf8_strlen($idiom['1']); $key=mb_substr($idiom,($count-1),$count,'UTF-8'); $row=$DB->get_row("SELECT * FROM `api_idiom` WHERE `name` LIKE '{$idiom['1']}%' ORDER BY RAND() LIMIT 1"); if($row['name']){ return $row['name']; }else{ Return 'You're too good. I can't get it. Let's use another idiom to play ω<* ฅ)'; } }else{ Return 'Are you sure this idiom ('. $idiom ['1 '].') exists? Don't fool me; } }else{ $row=$DB->get_row("SELECT * FROM `api_idiom` ORDER BY RAND() LIMIT 1"); return $row['name']; } }Elseif (stristr ($idiom, 'idiom')){ $idiom=explore ('idiom ', $idiom); if($idiom['1']){ $row=$DB->get_row("SELECT * FROM `api_idiom` WHERE `name`='{$idiom['1']}' LIMIT 1"); if($row['name']==$idiom['1']){ Return 'Pronunciation:'$ row['spell'].' \N Idiom: '$ row['name'].' \N n Definition: '$ row['content']; }else{ Return 'Are you sure this idiom ('. $idiom ['1 '].') exists? Don't fool me; } }else{ Return 'You haven't entered the idiom to query its definition~(● - ●)'; } } #Function Die } function query_express($nu){ global $DB; if(!$nu){ Return 'Please enter the waybill number to query the express information!'; }else{ $express=json_decode(curl_get(' http://www.kuaidi100.com/autonumber/auto?num= '.$ nu),true); $exname=$express[0]['comCode']; if(!$exname){ Return 'Please enter the waybill number correctly!'; }else{ $query=json_decode(curl_get(' http://www.kuaidi100.com/query?type= '.$ exname.'& postid='.$ nu),true); if($query['status']=='400'){ Return 'Query failed! Maybe the logistics information of the goods has not been updated, please check again later! '; }else{ if($query['status']=='201'){ Return 'The query failed. The reason is: n1. Maybe the logistics information of the goods has not been updated. Please check again later! \N n2. The waybill number does not exist [Please check whether the waybill number is entered correctly!] or it has expired! \N nPS: If the waybill number exists, but this prompt appears, please contact the express to query API author QQ: 1361289290, thank you for your cooperation! '; }else{ $com=$query['com']; if($query['state']=='0'){ $state='Goods are in transit! '; }elseif($query['state']=='1'){ $state='The goods have been collected by the express company'; }elseif($query['state']=='2'){ $state='There was a problem during the delivery of the goods'; }elseif($query['state']=='3'){ $state='The recipient has signed in'; }elseif($query['state']=='4'){ $state='The goods are returned due to the user's refusal to sign, over area and other reasons, and the sender has signed for them'; }elseif($query['state']=='5'){ $state='The express delivery is in progress'; }elseif($query['state']=='3'){ $state='The goods are being returned to the sender'; }else{ $state='Status query failed, please query later!'; } $row=$DB->get_row("SELECT * FROM `api_expresscom` WHERE `com`='$com' LIMIT 1"); $arrlength=count($query['data']); for($i=0;$i<$arrlength;$i++){ $data.=$ query['data'][$i]['time'].' \n'.$ query['data'][$i]['context'].' \n\n'; } Return 'Query the waybill number:'$ nu.'['.$ row['name'].'] \N Cargo status: '$ state.' \n\n'.$ data.' Query time: '. date ('Y-m-d H: i: s'); } } } } #Function Die } function joke(){ global $DB; $row=$DB->get_row("SELECT * FROM `api_joke` ORDER BY RAND() LIMIT 1"); return '《'.$row['title'].'》\n'.$ row['text']; } function historic($msg){ global $DB; If (stristr ($msg, 'today')){ $m=date('m'); $d=date('d'); }else{ $text=str_replace (Array ('days in history '),' ', $msg); $t=explore ('month ', $text); $m=$t['0']; $d=$t['1']; } if($m && $d){ $m=str_replace(Array('01','02','03','04','05','06','07','08','09'),Array('01'=>'1','02'=>'2','03'=>'3','04'=>'4','05'=>'5','06'=>'6','07'=>'7','08'=>'8','09'=>'9'),$m); if($m<'0'){$m='1';}elseif($m>'13'){$m='12';} $d=str_replace(Array('01','02','03','04','05','06','07','08','09'),Array('01'=>'1','02'=>'2','03'=>'3','04'=>'4','05'=>'5','06'=>'6','07'=>'7','08'=>'8','09'=>'9'),$d); if($d<'0'){$d='1';}elseif($d>'32'){$d='31';} }else{ $m=str_replace(Array('01','02','03','04','05','06','07','08','09'),Array('01'=>'1','02'=>'2','03'=>'3','04'=>'4','05'=>'5','06'=>'6','07'=>'7','08'=>'8','09'=>'9'),date('m')); $d=str_replace(Array('01','02','03','04','05','06','07','08','09'),Array('01'=>'1','02'=>'2','03'=>'3','04'=>'4','05'=>'5','06'=>'6','07'=>'7','08'=>'8','09'=>'9'),date('d')); } } } ``` --- Only this memory label: memory