一个用于查询拍拍帐号信息的小程序,初学php写的比较烂。
1 <?php 2 include_once('./simple_html_dom.php'); 3 4 $info_detail = array(); //卖家资料 5 $colligation_score = array(); //综合评分 6 $service_status = array(); //店铺近30天服务状况 7 $comp_rate = array(); //投诉率 8 $refund_rate = array(); //退款率 9 10 $is_display_credit = false; //是否显示信用模块 11 $credit_score = ''; //信用分数 12 $reputation_rate = ''; //好评率 13 14 $last_week = array(); //最近一周 15 $last_month = array(); //最近一月 16 $last_six_months = array(); //最近半年 17 $total = array(); 18 19 $qq = isset($_POST['qq']) ? $_POST['qq'] : ''; 20 if($qq != ''){ 21 $info_detail['account'] = $qq; 22 $info_detail['detail link'] = "http://shop.paipai.com/cgi-bin/creditinfo/view?uin=" . $qq . "&flag=1"; 23 24 /* $ch = curl_init(); 25 curl_setopt($ch, CURLOPT_URL, $info_detail['detail link']); 26 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 27 curl_setopt($ch, CURLOPT_HEADER, 0); 28 $result = curl_exec($ch); 29 curl_close($ch); 30 */ 31 $result = file_get_contents($info_detail['detail link']); 32 33 $html = new simple_html_dom(); 34 $html->load($result); 35 36 //卖家资料 37 $ele = $html->find('div[class=name]'); 38 if($ele == null){ 39 echo "<script type=\"text/javascript\">location.href='./index.php'</script>"; 40 } 41 42 $info_detail['nick'] = $ele[0]->next_sibling()->plaintext; 43 $info_detail['area'] = $ele[1]->next_sibling()->plaintext; 44 $info_detail['time'] = $ele[2]->next_sibling()->plaintext; 45 46 //店铺综合评分 47 $colligation_score['score'] = $html->find('div[class=score module] h1 span.times strong', 0)->plaintext; 48 $ele = $html->find('div[class=score module] div.nav ul li'); 49 $colligation_score['conform'] = $ele[0]->children[1]->children[0]->plaintext; 50 $colligation_score['attitude'] = $ele[1]->children[1]->children[0]->plaintext; 51 $colligation_score['delivery speed'] = $ele[2]->children[1]->children[0]->plaintext; 52 53 54 //店铺近30天服务状况 55 $ele = $html->find('div[class=score module shop_about] div div ul li'); 56 $service_status['backmoney speed'] = $ele[0]->children[1]->children[0]->plaintext; 57 $service_status['backmoney rate'] = $ele[1]->children[1]->children[0]->plaintext; 58 $service_status['complaint handing speed'] = $ele[2]->children[1]->children[0]->plaintext; 59 $service_status['complaint rate'] = $ele[3]->children[1]->children[0]->plaintext; 60 61 62 //投诉率 63 $ele = $html->find('div[class=center_block small_table] div[class=score module shop_about] div ul li'); 64 $comp_rate['commercial quality'] = $ele[0]->children[1]->children[0]->plaintext; //商品质量原因 65 $comp_rate['stockout'] = $ele[1]->children[1]->children[0]->plaintext; //缺货原因 66 $comp_rate['attitude'] = $ele[2]->children[1]->children[0]->plaintext; //服务态度原因 67 $comp_rate['delivery speed'] = $ele[3]->children[1]->children[0]->plaintext; //发货速度原因 68 69 //退款率 70 $ele = $html->find('div[class=center_block small_table refund] div[class=score module shop_about] div ul li'); 71 $refund_rate['commercial quality'] = $ele[0]->children[1]->children[0]->plaintext; 72 $refund_rate['stockout'] = $ele[1]->children[1]->children[0]->plaintext; 73 $refund_rate['attitude'] = $ele[2]->children[1]->children[0]->plaintext; 74 75 //店铺信用率 76 $ele = $html->find('div[class=score module shop_score] h1.title', 0); 77 if($ele != null) { 78 $is_display_credit = true; 79 $credit_score = $ele->children[2]->score; 80 $reputation_rate = $ele->children[3]->children[0]->plaintext; 81 82 $ele = $html->find('div[class=score module shop_score] div.table table tr'); 83 $last_week['good'] = $ele[1]->children[1]->innertext; 84 $last_week['average'] = $ele[1]->children[2]->innertext; 85 $last_week['fail'] = $ele[1]->children[3]->innertext; 86 87 $last_month['good'] = $ele[2]->children[1]->innertext; 88 $last_month['average'] = $ele[2]->children[2]->innertext; 89 $last_month['fail'] = $ele[2]->children[3]->innertext; 90 91 $last_six_months['good'] = $ele[3]->children[1]->innertext; 92 $last_six_months['average'] = $ele[3]->children[2]->innertext; 93 $last_six_months['fail'] = $ele[3]->children[3]->innertext; 94 95 $total['good'] = $ele[4]->children[1]->innertext; 96 $total['average'] = $ele[4]->children[2]->innertext; 97 $total['fail'] = $ele[4]->children[3]->innertext; 98 } 99 100 $html->clear();101 102 103 104 }105 106 ?>107 108 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">109 <html xmlns="http://www.w3.org/1999/xhtml">110 <head>111 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />112 <title>拍拍帐号信息查询</title>113 114 <style type="text/css">115 116 *{117 font-size:13px;118 }119 120 a{121 color:#00f;122 text-decoration:none;123 }124 125 a:hover{126 color:#f60;127 }128 129 strong{130 color:#FF4E00;131 }132 133 134 135 #query_box{136 margin:20px auto;137 width:60%;138 line-height:50px;139 text-align:center;140 border:1px solid #ddd;141 }142 143 144 #query_form input#qq{145 width:300px;146 height:20px;147 line-height:20px;148 }149 150 #query_form button.btn_query{151 width:50px;152 height:25px;153 }154 155 #query_result{156 margin:20px auto;157 width:60%; 158 }159 160 #query_result table, #query_result table tr, #query_result table td{161 border:1px solid #ccc;162 }163 164 #query_result table {165 width:100%;166 border-collapse:collapse;167 }168 169 #query_result table td{170 padding:5px;171 }172 173 .tle {174 background-color:#ddd;175 line-height:30px;176 font-weight:bold;177 }178 179 .item_title{180 width:20%;181 }182 183 #credit, #credit tr, #credit td{184 border:none;185 text-align:center;186 }187 188 .good_ico, .average_ico, .fail_ico{189 width:30px;190 line-height:20px;191 padding-left:20px;192 margin:0px auto;193 display:block;194 }195 196 .good_ico {197 background:url(./images/bg_shop_credit_rating.png) scroll 0px -270px;198 }199 200 .average_ico{201 background:url(./images/bg_shop_credit_rating.png) scroll 0px -290px;202 }203 204 .fail_ico{205 background:url(./images/bg_shop_credit_rating.png) scroll 0px -310px;206 }207 208 209 </style>210 211 </head>212 213 <body>214 <div id="query_box">215 <form id="query_form" action="./index.php" method="post">216 <label for="qq">拍拍帐号: </label><input type="text" id="qq" name="qq" />217 <button class="btn_query" type="submit">查询</button>218 </form>219 </div>220 221 <?php if($qq != '') {?>222 <div id="query_result">223 <table>224 <tr><td class="tle" colspan="4">卖家资料</td></tr>225 <tr><td class="item_title">拍拍帐号</td><td colspan="3"><?php echo $info_detail['account']; ?></td></tr>226 <tr><td class="item_title">卖家昵称</td><td colspan="3"><?php echo $info_detail['nick']; ?></td></tr>227 <tr><td class="item_title">所属地区</td><td colspan="3"><?php echo $info_detail['area']; ?></td></tr>228 <tr><td class="item_title">开店时间</td><td colspan="3"><?php echo $info_detail['time']; ?></td></tr>229 <tr><td class="item_title">详细信息</td><td colspan="3"><a target="_blank" href="<?php echo $info_detail['detail link']; ?>"><?php echo $info_detail['detail link']; ?></a></td></tr>230 231 <tr><td class="tle" colspan="4">店铺综合评分 <strong><?php echo $colligation_score['score']; ?></strong> 分</td></tr>232 <tr><td class="item_title">商品与描述相符</td><td colspan="3"><strong><?php echo $colligation_score['conform']; ?></strong>分</td></tr>233 <tr><td class="item_title">卖家的服务态度</td><td colspan="3"><strong><?php echo $colligation_score['attitude']; ?></strong>分</td></tr>234 <tr><td class="item_title">卖家发货的速度</td><td colspan="3"><strong><?php echo $colligation_score['delivery speed']; ?></strong>分</td></tr>235 236 <tr><td class="tle" colspan="4">店铺近30天服务状况</td></tr>237 <tr><td class="item_title">平均退款速度</td><td colspan="3"><strong><?php echo $service_status['backmoney speed']; ?></strong></td></tr>238 <tr><td class="item_title">退款率</td><td colspan="3"><strong><?php echo $service_status['backmoney rate']; ?></strong></td></tr>239 <tr><td class="item_title">平均投诉处理速度</td><td colspan="3"><strong><?php echo $service_status['complaint handing speed']; ?></strong></td></tr>240 <tr><td class="item_title">投诉率</td><td colspan="3"><strong><?php echo $service_status['complaint rate']; ?></strong></td></tr>241 242 <tr><td class="tle" colspan="2">投诉率</td><td class="tle" colspan="2">退款率</td></tr>243 <tr>244 <td class="item_title">商品质量原因</td><td><strong><?php echo $comp_rate['commercial quality']; ?></strong></td>245 <td class="item_title">商品质量原因</td><td><strong><?php echo $refund_rate['commercial quality']; ?></strong></td>246 </tr>247 248 <tr>249 <td class="item_title">缺货原因</td><td><strong><?php echo $comp_rate['stockout']; ?></strong></td>250 <td class="item_title">缺货原因</td><td><strong><?php echo $refund_rate['stockout']; ?></strong></td>251 </tr>252 253 <tr>254 <td class="item_title">服务态度原因</td><td><strong><?php echo $comp_rate['attitude']; ?></strong></td>255 <td class="item_title">服务态度原因</td><td><strong><?php echo $refund_rate['attitude']; ?></strong></td>256 </tr>257 258 <tr>259 <td class="item_title">发货速度原因</td><td colspan="3"><strong><?php echo $comp_rate['delivery speed']; ?></strong></td>260 </tr>261 262 263 <?php if($is_display_credit) { ?>264 <tr><td class="tle" colspan="4">店铺信用 <strong><?php echo $credit_score; ?></strong> 好评率:<strong><?php echo $reputation_rate; ?></strong></td></tr>265 <tr><td style="padding:0px;" colspan="4">266 <table id="credit">267 <tr><td></td><td><span class="good_ico">好评</span></td><td><span class="average_ico">中评</span></td><td><span class="fail_ico">差评<span></td></tr>268 <tr><td class="item_title">最近一周</td><td><strong><?php echo $last_week['good']; ?></strong></td><td><strong><?php echo $last_week['average']; ?></strong></td><td><strong><?php echo $last_week['fail']; ?></strong></td></tr>269 <tr><td class="item_title">最近一月</td><td><strong><?php echo $last_month['good']; ?></strong></td><td><strong><?php echo $last_month['average']; ?></strong></td><td><strong><?php echo $last_month['fail']; ?></strong></td></tr>270 <tr><td class="item_title">最近半年</td><td><strong><?php echo $last_six_months['good']; ?></strong></td><td><strong><?php echo $last_six_months['average']; ?></strong></td><td><strong><?php echo $last_six_months['fail']; ?></strong></td></tr>271 <tr><td class="item_title">总计</td><td><strong><?php echo $total['good']; ?></strong></td><td><strong><?php echo $total['average']; ?></strong></td><td><strong><?php echo $total['fail']; ?></strong></td></tr>272 </table>273 </td></tr>274 <?php } ?>275 </table>276 </div>277 <?php } ?>278 </body>279 </html>

PHP類型提示提升代碼質量和可讀性。 1)標量類型提示:自PHP7.0起,允許在函數參數中指定基本數據類型,如int、float等。 2)返回類型提示:確保函數返回值類型的一致性。 3)聯合類型提示:自PHP8.0起,允許在函數參數或返回值中指定多個類型。 4)可空類型提示:允許包含null值,處理可能返回空值的函數。

PHP中使用clone關鍵字創建對象副本,並通過\_\_clone魔法方法定制克隆行為。 1.使用clone關鍵字進行淺拷貝,克隆對象的屬性但不克隆對象屬性內的對象。 2.通過\_\_clone方法可以深拷貝嵌套對象,避免淺拷貝問題。 3.注意避免克隆中的循環引用和性能問題,優化克隆操作以提高效率。

PHP適用於Web開發和內容管理系統,Python適合數據科學、機器學習和自動化腳本。 1.PHP在構建快速、可擴展的網站和應用程序方面表現出色,常用於WordPress等CMS。 2.Python在數據科學和機器學習領域表現卓越,擁有豐富的庫如NumPy和TensorFlow。

HTTP緩存頭的關鍵玩家包括Cache-Control、ETag和Last-Modified。 1.Cache-Control用於控制緩存策略,示例:Cache-Control:max-age=3600,public。 2.ETag通過唯一標識符驗證資源變化,示例:ETag:"686897696a7c876b7e"。 3.Last-Modified指示資源最後修改時間,示例:Last-Modified:Wed,21Oct201507:28:00GMT。

在PHP中,應使用password_hash和password_verify函數實現安全的密碼哈希處理,不應使用MD5或SHA1。1)password_hash生成包含鹽值的哈希,增強安全性。 2)password_verify驗證密碼,通過比較哈希值確保安全。 3)MD5和SHA1易受攻擊且缺乏鹽值,不適合現代密碼安全。

PHP是一種服務器端腳本語言,用於動態網頁開發和服務器端應用程序。 1.PHP是一種解釋型語言,無需編譯,適合快速開發。 2.PHP代碼嵌入HTML中,易於網頁開發。 3.PHP處理服務器端邏輯,生成HTML輸出,支持用戶交互和數據處理。 4.PHP可與數據庫交互,處理表單提交,執行服務器端任務。

PHP在過去幾十年中塑造了網絡,並將繼續在Web開發中扮演重要角色。 1)PHP起源於1994年,因其易用性和與MySQL的無縫集成成為開發者首選。 2)其核心功能包括生成動態內容和與數據庫的集成,使得網站能夠實時更新和個性化展示。 3)PHP的廣泛應用和生態系統推動了其長期影響,但也面臨版本更新和安全性挑戰。 4)近年來的性能改進,如PHP7的發布,使其能與現代語言競爭。 5)未來,PHP需應對容器化、微服務等新挑戰,但其靈活性和活躍社區使其具備適應能力。

PHP的核心優勢包括易於學習、強大的web開發支持、豐富的庫和框架、高性能和可擴展性、跨平台兼容性以及成本效益高。 1)易於學習和使用,適合初學者;2)與web服務器集成好,支持多種數據庫;3)擁有如Laravel等強大框架;4)通過優化可實現高性能;5)支持多種操作系統;6)開源,降低開發成本。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

禪工作室 13.0.1
強大的PHP整合開發環境

記事本++7.3.1
好用且免費的程式碼編輯器

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

WebStorm Mac版
好用的JavaScript開發工具

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),