Home > Backend Development > PHP Tutorial > Commonly used classes in PHP to detect whether the input data is legal

Commonly used classes in PHP to detect whether the input data is legal

WBOY
Release: 2016-07-25 09:12:24
Original
1018 people have browsed it
  1. class Fun{
  2. function isEmpty($val)
  3. {
  4. if (!is_string($val)) return false; //Is it a string type?
  5. if (empty($val )) return false; //Whether it has been set
  6. if ($val=='') return false; //Whether it is empty
  7. return true;
  8. }
  9. /*
  10. -------- -------------------------------------------------- -
  11. Function name: isNumber
  12. Brief description: Check whether the input is a number
  13. Input: string
  14. Output: boolean
  15. Modification log: ------
  16. --------------- --------------------------------------------------
  17. */
  18. function isNumber ($val)
  19. {
  20. if(ereg("^[0-9]+$", $val))
  21. return true;
  22. return false;
  23. }
  24. /*
  25. --------- --------------------------------------------------
  26. Function name: isPhone
  27. Brief description: Check whether the input is a phone
  28. Input: string
  29. Output: boolean
  30. Modification log: ------
  31. ---------------- --------------------------------------------------
  32. */
  33. function isPhone( $val)
  34. {
  35. //eg: xxx-xxxxxxxx-xxx | xxxx-xxxxxxx-xxx ...
  36. if(ereg("^((0d{2,3})-)(d{7,8}) (-(d{3,}))?$",$val))
  37. return true;
  38. return false;
  39. }
  40. /*
  41. ------------------ ------------------------------------------
  42. Function name: isPostcode
  43. Brief description : Check whether the input is a zip code
  44. Input: string
  45. Output: boolean
  46. Modification log: ------
  47. ------------------------ ----------------------------------
  48. */
  49. function isPostcode($val)
  50. {
  51. if( ereg("^[0-9]{4,6}$",$val))
  52. return true;
  53. return false;
  54. }
  55. /*
  56. -------------- ---------------------------------------------
  57. Function name: isEmail
  58. Brief description: Email address legality check
  59. Input: string
  60. Output: boolean
  61. Modification log: ------
  62. ----------------------- ----------------------------------------
  63. */
  64. function isEmail($val,$domain= "")
  65. {
  66. if(!$domain)
  67. {
  68. if( preg_match("/^[a-z0-9-_.]+@[da-z][.w-]+.[a-z]{ 2,4}$/i", $val) )
  69. {
  70. return true;
  71. }
  72. else
  73. return false;
  74. }
  75. else
  76. {
  77. if( preg_match("/^[a-z0-9-_. ]+@".$domain."$/i", $val) )
  78. {
  79. return true;
  80. }
  81. else
  82. return false;
  83. }
  84. }//end func
  85. /*
  86. ----- -------------------------------------------------- ----
  87. Function name: isName
  88. Brief description: Name and nickname validity check, only Chinese and English can be entered
  89. Input: string
  90. Output: boolean
  91. Modification log: ------
  92. ------- -------------------------------------------------- --
  93. */
  94. function isName($val)
  95. {
  96. if( preg_match("/^[x80-xffa-zA-Z0-9]{3,60}$/", $val) )//2008- 7-24
  97. {
  98. return true;
  99. }
  100. return false;
  101. }//end func
  102. /*
  103. ----------------------- ------------------------------------
  104. Function name: isStrLength($theelement, $min, $max )
  105. Brief description: Check whether the string length meets the requirements
  106. Input: mixed (string, minimum length, maximum length)
  107. Output: boolean
  108. Modification log: ------
  109. --------- --------------------------------------------------
  110. */
  111. function isStrLength($val, $min, $max)
  112. {
  113. $theelement= trim($val);
  114. if(ereg("^[a-zA-Z0-9]{".$min. ",".$max."}$",$val))
  115. return true;
  116. return false;
  117. }
  118. /*
  119. ------------------ ----------------------------------------
  120. Function name: isNumberLength($theelement, $min, $max)
  121. Brief description: Check whether the string length meets the requirements
  122. Input: mixed (string, minimum length, maximum length)
  123. Output: boolean
  124. Modification log: ------
  125. ---- -------------------------------------------------- -----
  126. */
  127. function isNumLength($val, $min, $max)
  128. {
  129. $theelement= trim($val);
  130. if(ereg("^[0-9]{".$min .",".$max."}$",$val))
  131. return true;
  132. return false;
  133. }
  134. /*
  135. ------------------ ----------------------------------------
  136. Function name: isNumberLength($theelement, $min, $max)
  137. Brief description: Check whether the string length meets the requirements
  138. Input: mixed (string, minimum length, maximum length)
  139. Output: boolean
  140. Modification log: ------
  141. ---- -------------------------------------------------- -----
  142. */
  143. function isEngLength($val, $min, $max)
  144. {
  145. $theelement= trim($val);
  146. if(ereg("^[a-zA-Z]{". $min.",".$max."}$",$val))
  147. return true;
  148. return false;
  149. }
  150. /*
  151. --------------------------------------------- ---------------
  152. Function name: isEnglish
  153. Brief description: Check whether the input is in English
  154. Input: string
  155. Output: boolean
  156. Author: ------
  157. Modification log: - -----
  158. ----------------------------------------------- ---------------
  159. */
  160. function isEnglish($theelement)
  161. {
  162. if( ereg("[x80-xff].",$theelement) )
  163. {
  164. Return false ;
  165. }
  166. Return true;
  167. }
  168. /*
  169. ---------------------------------------- -----------------------
  170. Function name: isChinese
  171. Brief description: Check whether the input is Chinese characters
  172. Input: string
  173. Output: boolean
  174. Modification log: - -----
  175. ----------------------------------------------- ---------------
  176. */
  177. /*
  178. function isChinese($sInBuf)//The function in question
  179. {
  180. $iLen= strlen($sInBuf);
  181. for($ i= 0; $i< $iLen; $i++)
  182. {
  183. if(ord($sInBuf{$i})>=0x80)
  184. {
  185. if( (ord($sInBuf{$i})>= 0x81 && ord($sInBuf{$i})<=0xFE) && ((ord($sInBuf{$i+1})>=0x40 && ord($sInBuf{$i+1}) < 0x7E) || (ord($sInBuf{$i+1}) > 0x7E && ord($sInBuf{$i+1})<=0xFE)) )
  186. {
  187. if(ord($sInBuf{$i}) >0xA0 && ord($sInBuf{$i})<0xAA)
  188. {
  189. //There is Chinese punctuation
  190. return false;
  191. }
  192. }
  193. else
  194. {
  195. //There is Japanese or other text
  196. return false;
  197. }
  198. $i++;
  199. }
  200. else
  201. {
  202. return false;
  203. }
  204. }
  205. return true;
  206. }*/
  207. function isChinese($sInBuf)//Correct function
  208. {
  209. if (preg_match("/ ^[x7f-xff]+$/", $sInBuf)) { //Compatible with gb2312,utf-8
  210. return true;
  211. }
  212. else
  213. {
  214. return false;
  215. }
  216. }
  217. /*
  218. --- -------------------------------------------------- ------
  219. Function name: isDomain($Domain)
  220. Brief description: Check whether an (English) domain name is legal
  221. Input: string domain name
  222. Output: boolean
  223. Modification log: -------
  224. --- -------------------------------------------------- ------
  225. */
  226. function isDomain($Domain)
  227. {
  228. if(!eregi("^[0-9a-z]+[0-9a-z.-]+[0-9a-z ]+$", $Domain))
  229. {
  230. Return false;
  231. }
  232. if( !eregi(".", $Domain))
  233. {
  234. Return false;
  235. }
  236. if(eregi("-.", $Domain) or eregi("--", $Domain) or eregi("..", $Domain) or eregi(".-", $Domain))
  237. {
  238. Return false;
  239. }
  240. $aDomain= explode(".",$Domain);
  241. if( !eregi("[a-zA-Z]",$aDomain[count($aDomain)-1]) )
  242. {
  243. Return false;
  244. }
  245. if (strlen($aDomain[0]) > 63 || strlen($aDomain[0]) < 1)
  246. {
  247. Return false;
  248. }
  249. Return true;
  250. }
  251. /**
  252. * Function to verify date
  253. * @param unknown_type $date
  254. * @param unknown_type $format
  255. * @throws Exception
  256. * @return boolean
  257. */
  258. function validateDate( $date, $format='YYYY-MM-DD')
  259. {
  260. switch( $format )
  261. {
  262. case 'YYYY/MM/DD':
  263. case 'YYYY-MM-DD':
  264. list( $y, $m, $d ) = preg_split( '/[-./ ]/', $date );
  265. break;
  266. case 'YYYY/DD/MM':
  267. case 'YYYY-DD-MM':
  268. list( $y, $d, $m ) = preg_split( '/[-./ ]/', $date );
  269. break;
  270. case 'DD-MM-YYYY':
  271. case 'DD/MM/ YYYY':
  272. list( $d, $m, $y ) = preg_split( '/[-./ ]/', $date );
  273. break;
  274. case 'MM-DD-YYYY':
  275. case 'MM /DD/YYYY':
  276. list( $m, $d, $y ) = preg_split( '/[-./ ]/', $date );
  277. break;
  278. case 'YYYYMMDD':
  279. $y = substr ( $date, 0, 4 );
  280. $m = substr( $date, 4, 2 );
  281. $d = substr( $date, 6, 2 );
  282. break;
  283. case 'YYYYDDMM':
  284. $y = substr( $date, 0, 4 );
  285. $d = substr( $date, 4, 2 );
  286. $m = substr( $date, 6, 2 );
  287. break;
  288. default:
  289. throw new Exception ( "Invalid Date Format" );
  290. }
  291. return checkdate( $m, $d, $y );
  292. }
  293. /*
  294. ------------------ ----------------------------------------
  295. Function name: isDate
  296. Brief description: Check whether the date matches 0000-00-00
  297. Input: string
  298. Output: boolean
  299. Modification log: ------
  300. ----------------------- ----------------------------------------
  301. */
  302. function isDate($sDate)
  303. {
  304. if( ereg("^[0-9]{4}-[][0-9]{2}-[0-9]{2}$",$sDate) )
  305. {
  306. Return true;
  307. }
  308. else
  309. {
  310. Return false;
  311. }
  312. }
  313. /*
  314. -------------------------------------------------- -------------
  315. Function name: isTime
  316. Brief description: Check whether the date matches 0000-00-00 00:00:00
  317. Input: string
  318. Output: boolean
  319. Modification log: -- ----
  320. ------------------------------------------------ ---------------
  321. */
  322. function isTime($sTime)
  323. {
  324. if( ereg("^[0-9]{4}-[][0-9]{ 2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$",$sTime) )
  325. {
  326. Return true;
  327. }
  328. else
  329. {
  330. Return false;
  331. }
  332. }
  333. /*
  334. ---------------------------------- ----------------------------
  335. Function name: isMoney($val)
  336. Brief description: Check whether the input value is in legal RMB format
  337. Input: string
  338. Output: boolean
  339. Modification log: ------
  340. -------------------------------- -----------------------------
  341. */
  342. function isMoney($val)
  343. {
  344. if(ereg("^[0-9 ]{1,}$", $val))
  345. return true;
  346. if( ereg("^[0-9]{1,}.[0-9]{1,2}$", $val) )
  347. return true;
  348. return false;
  349. }
  350. /*
  351. ---------------------------------- ------------------------
  352. Function name: isIp($val)
  353. Brief description: Check whether the input IP meets the requirements
  354. Input: string
  355. Output: boolean
  356. Modification log:------
  357. ------------------------------------------ ---------------------
  358. */
  359. function isIp($val)
  360. {
  361. return(bool) ip2long($val);
  362. }
  363. //- -------------------------------------------------- --------------------------
  364. /**
  365. * Verify mobile number
  366. * @param int $mobile
  367. */
  368. function valid_mobile($mobile){
  369. if(strlen ($mobile)!=11) return false;
  370. if(preg_match('/13[0-9]d{8}|15[0|1|2|3|5|6|7|8|9]d {8}|18[0|5|6|7|8|9]d{8}/',$mobile)){
  371. return true;
  372. }else{
  373. return false;
  374. }
  375. }
  376. /* *
  377. * Thumbnail generation function, it is best to use GD2
  378. *
  379. * @param string $srcFile The file to generate thumbnails
  380. * @param int $toW Thumbnail width
  381. * @param int $toH Thumbnail height
  382. * @param string $toFile thumbnail file
  383. */
  384. function ImageResize($srcFile,$toW,$toH,$toFile=""){
  385. if($toFile==""){ $toFile = $srcFile; }
  386. $info = "" ;
  387. $data = GetImageSize($srcFile,$info);
  388. switch ($data[2]){
  389. case 1:
  390. if(!function_exists("imagecreatefromgif")){
  391. //echo "Your GD library cannot For images in GIF format, please use Jpeg or PNG format! return";
  392. return false;
  393. }
  394. $im = ImageCreateFromGIF($srcFile);
  395. break;
  396. case 2:
  397. if (!function_exists("imagecreatefromjpeg")){
  398. //echo "Your GD library cannot use images in jpeg format, please use images in other formats!default";
  399. return false;
  400. }
  401. $im = ImageCreateFromJpeg($srcFile);
  402. break;
  403. case 3:
  404. $ im = ImageCreateFromPNG($srcFile);
  405. break;
  406. }
  407. $srcW=ImageSX($im);
  408. $srcH=ImageSY($im);
  409. $toWH=$toW/$toH; $srcH;
  410. if($toWH<=$srcWH){
  411. $ftoW=$toW;
  412. $ftoH=$ftoW*($srcH/$srcW);
  413. }
  414. else{
  415. $ftoH=$toH;
  416. $ ftoW=$ftoH*($srcW/$srcH);
  417. }
  418. if($srcW>$toW||$srcH>$toH)
  419. {
  420. if(function_exists("imagecreateTrueColor")){
  421. @$ni = ImageCreateTrueColor ($ftoW, $ftoH);
  422. if($ni) ImageCopyResampled($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);
  423. else{
  424. $ni= ImageCreate ( $ftoW , $ftoH )
  425. ImageCopyResized ( $ ni , $ im , 0 , 0 , 0 , 0 , $ ftoW , $ photo H , $ srcW , $ srcH ); ($ftoW, $ftoH);
  426. ImageCopyResized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);
  427. }
  428. if(function_exists('imagepeg')); ImageJpeg($ni,$toFile);
  429. else ImagePNG($ni,$toFile);
  430. ImageDestroy($ni);
  431. }else{
  432. ImageDestroy($im);
  433. return false;
  434. }
  435. ImageDestroy($im); ;
  436. return true;
  437. }
  438. // public static function strTrim($str)
  439. {
  440. return preg_replace("/s/","",$str);
  441. }
  442. //; static function userName($str,$type,$len)
  443. {
  444. $str=self::strTrim($str);
  445. if($len {
  446. return false;
  447. }else {
  448. switch ( $type )
  449. {
  450. case " EN " ://default
  451. if ( preg_match ( " / ^ [ a - zA - Z ] + $ / " , $str ))
  452. {
  453. return true ;
  454. } else {
  455. return false ;
  456. }
  457. break ;
  458. case " ENNUM "
  459. }
  460. if ( preg_match ( " / ^ [ a - zA - Z0 - 9 ] + $ / " , $ str ) )
  461. {
  462. return true ;
  463. } else {
  464. return false ;
  465. }
  466. break ;
  467. case " ALL " : // set preg_match ( | - _ preg_match )
  468. if ( preg_match ( " / ^ [| -_a -zA-Z0-9]+$/",$str))
  469. {
  470. return true;
  471. }else{
  472. return false;
  473. }
  474. break;
  475. }
  476. }
  477. }
  478. //Create a lock static function passWord($min,$max,$size)
  479. {
  480. $size=self::strTrim($size);
  481. if(size($size)>=$min &&size($size)<=$ max)
  482. {
  483. return true ;
  484. } else {
  485. return false ;
  486. }
  487. }
  488. // key Email
  489. static function Email ( $str )
  490. {
  491. $str = self :: strTrim ( $str );
  492. if(preg_match("/^([a-z0-9_]|\-|\.)+@(([a-z0-9_]|\-)+\.){1,2}[a-z] {2.4}$/i",$str))
  493. {
  494. return true;
  495. }else{
  496. return false;
  497. }
  498. }
  499. //Create IDCard($str)
  500. static function idCard($str )
  501. {
  502. $str=self::strTrim($str);
  503. if(preg_match("/^([0-9]{15}|[0-9]{17}[0-9a-z]) $/i", $str))
  504. {
  505. return true;
  506. }else{
  507. return false;
  508. }
  509. }
  510. //Specify the keyword static function Phone($type,$str)
  511. {
  512. $str = self :: strTrim ( $str )
  513. switch ( $ type )
  514. {
  515. case " CHN " :
  516. if ( preg_match ( " / ^ ( [ 0 - 9 ] { 3 } | 0 [ 0 - 9 ] { }) - [ 0 - 9 ] { 7 , 8 } $ / " , $ str ) )
  517. {
  518. return true ;
  519. } else {
  520. return false ;
  521. }
  522. break ;
  523. case " INT " :
  524. if ( preg_match ("/^[0-9]{4}-([0-9]{3}|0[0-9]{3})-[0-9]{7.8}$/",$str ))
  525. {
  526. return true;
  527. }else{
  528. return false;
  529. }
  530. break;
  531. }
  532. }
  533. /**
  534. * Filter the values ​​of the two-dimensional array
  535. * @param two-dimensional array $arr_data
  536. * @param one-dimensional array $field
  537. * @return Ambigous
  538. */
  539. function getarrayfield($arr_data, $field)
  540. {
  541. $resultArr = array();
  542. foreach($arr_data as $key => $value ) {
  543. foreach ($field as $k=>$v)
  544. {
  545. if(array_key_exists($v, $value))//invalid array
  546. {
  547. $resultArr[$key][$v] =$value[$v] ;
  548. }
  549. else
  550. {
  551. $resultArr[$key][$v]="return $resultArr;
  552. };
  553. /**
  554. * Get the client IP address
  555. * @return ip
  556. */
  557. function get_client_ip(){
  558. if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
  559. $ip = getenv("HTTP_CLIENT_IP");
  560. else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
  561. $ip = getenv("HTTP_X_FORWARDED_FOR");
  562. else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
  563. $ip = getenv("REMOTE_ADDR");
  564. else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
  565. $ip = $_SERVER['REMOTE_ADDR'];
  566. else
  567. $ip = "unknown";
  568. return($ip);
  569. }
  570. function get_http_user_agent(){
  571. return isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "";
  572. }
  573. /**
  574. * Get real address from IP address
  575. * @param IP $ip
  576. */
  577. function get_address_from_ip($ip){
  578. $url='http://www.youdao.com/smartresult-xml/search.s?type=ip&q=';
  579. $xml=file_get_contents($url.$ip);
  580. $data=simplexml_load_string($xml);
  581. return $data->product->location;
  582. }
  583. /**
  584. * Generate a random string, which can be used to automatically generate passwords. The default length is a mixture of 6 letters and numbers
  585. * @param string $len length
  586. * @param string $type string type
  587. * 0 letters 1 numbers 2 uppercase letters 3 lowercase letters Default mixed 4 Chinese
  588. * @param string $addChars extra characters
  589. * @return string
  590. */
  591. function rand_string($len=6,$type='',$addChars='') {
  592. $str ='';
  593. switch($type) {
  594. case 0:
  595. $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.$addChars;
  596. break;
  597. case 1:
  598. $chars= str_repeat('0123456789',3);
  599. break;
  600. case 2:
  601. $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ'.$addChars;
  602. break;
  603. case 3:
  604. $chars='abcdefghijklmnopqrstuvwxyz'.$addChars;
  605. break;
  606. case 4:
  607. $chars = "We think that when we do it, we have to move the domestically produced one is that the workers can make progress in the discord and have the main people in the main body to divide students into lower-level students. The local people said in person that after the revolution, many children were added to the social network, and the power of the power line, the high-quality long-term party, the real family, the deep law, the water physical and chemical struggle, and the emergence of two political, three good, and ten wars without agriculture. The road map of the anti-sexual and anti-physical cooperation is to focus on the things that are discussed in the end and the new ones, from the two points of the talent team, to focus on the thoughts and time, to eliminate the factors, the daily benefits, the pressure, the karma, and the whole. The fruit period of the group leads to the leveling of each base or the hair of the month. However, if the shape, imagination, and heart are all turned to change, ask the ratio, show that it is the most external and does not look at the five interpretations of the relationship between the forest. The Mi Qun head means only four roads. It is recognized that the sub-text is relatively grammatical, but the leading force flows into the receiving seat and the crude oil is placed in question to refer to the district construction inspection activity. Many education decisions are made. Hereby, Chang Shiqiang and Tu Shaoji have established a common and unified system. Jiuyou and Xizhi are re-elected. Zhiguan, Qimoshan, Cheng Baibao, and the report will see that it is necessary to keep heat and entrust hands to change the management. We will repair the branches, identify the symptoms, the number of old people, the six types, and the number of rehabilitation belts. After finishing the wind, he returned to Nanguang, Laolunke, and planned the truck schedule and production section. The work was integrated and the step number was listed. The temperature was installed, and the shaft was grinded and monochromatic. The fast defense was made at the Rashidal Field Weaving Calendar Flower. The passing of information, the collection of gold medals, the determination of gold medals, the border clearing, and the final examination of the technical conditions, the factories must be separated from the sea, and the children's youth certificates are low and cross the eight test regulations. The county soldiers are solid and can lead to thousands of victories, fine shadows, and Jibai grid effect. Body-tight liquid system, accurate weight angle, dimension reduction board, Xu broken technique, bottom bed field potential, sense of mind, Hecun composition, appearance, Yamo family fire section, suitable value, beautiful appearance, Huang Yibiao, morning shift wheat cut letter The sound of rowing the stage should be attacked. Zhang Mi harms Houcao. He Shufei follows the right city. The city strictly inspects the snails. The left page resists the Soviet Union. Eyes she catches containing seedlings vice miscellaneous general talk about surrounding food radioactive sources causing acidity old but sufficient short stroke agent Xuanhuan Luoshou Chibo Chengfenjianfu fish with test engraving rely on enough full husband loss to encapsulate and promote branch bacterium circumferential protection Rock engineer Qu Chunyuan super negative sand sealing replacement Taimo poverty reduction Yangjiang analysis Mu Mu Yan Qi Chao Medical School Gu Ni Dao Song Ting Wei Shu Hua Station another Wei Zi Gu Gang wrote Liu Wei Lue Fan Gong A Kuai certain merits The set friends are limited to rewind the roll and create the law. The rain lets Guyuan help Chupi broadcast the advantage and occupy the poisonous circle. Weiji training and control stimulates the clouds and cracks the grain. Late Silk Girl Disperse Welding Gongzhu Yin Leng Che Bounce Disperse Business Visual Art Destroy Edition Lie Zero Room Light Blood Double Deficiency Pump Cha Jue Fu City Chong Spray Soil Jian Fuzhu Li Wangpan Magi Xiong Seems to be Trapped Gong Yizhou Takes Off and Delivers Slave Side Run The cover waved away, touched the star, and sent the official to be promoted. The mixed discipline has not yet emerged. The wide winter chapter is wet and partial. The boss is responsible for the mine village. The responsibility is mature and the hard price is won. Thick Luo Ni Pi Sui Egg Box Palm Oxygen Love Stop Once Solved Camp End Gang Meng Qian Waiting for Exhaustion Russian Shrink Sand Retreat Chen Challenge Equipment Carrying Cell Young Which Exploitation Rotary levy Grotto Handled Carrying Still Yeah Fresh Bar Card Thick Introduction Drilling By Weakness The feet are afraid of the salt dust, the clouds, the fog, the crown, the Bing Street, the radiated intestines, Fu Ji, Rui, startled, squeezed for seconds, hanging Mu Lansen, sugar, Holy concave pottery poems, late silkworms, billions of moments, Kang Zunmu, being framed in a garden tone, incense, flesh brother Wu Minhui, forgetting to compile and print. The bee is anxious to expand the wound and expose the core edge. You vibrate the center of Wuyu. It is very rapid and heterogeneous. It is paper-free, night town, Jiuli, cylinder clip and read Lan Yinggou B? Carbon performance, attached to the teeth, buds, permanent tiles, oblique irrigation, European Xianshun, pigs, foreign rots, please reveal the dangers, the veins should smile, if the tail bunches are strong, the vegetables, the ears of vegetables, the Chu and Han heals, the green drags the cows, dyes, all over the autumn, forged jade, summer treatment, pointed breeding wells, Feizhou visit Blow the glorious copper edge to summon the rolling guests, summon the drought, realize the stabbing of the brain, penetrate the Tibet, dare to make the cracks in the furnace shell, the sulfur coal welcomes the casting and sticks, explores the thin ten days, good fortune, indulges in the choice of etiquette, is willing to subdue the residual thunder and extend the smoke, the sentence is pure, gradually plowing, running the swamp, slowly planting Lu Chifan The situation turned upside down, the Xichi was ruined, the ship was ruined, and the false light was said to be entrusted to the husband, Zhehuai, cut off and pay tribute, and presented the powerful wealth. The belly is recorded, the woman is evil, the village is in danger, the bell is shaken, the handle is debated, the bamboo valley is sold, the bridge is in chaos, Ober rushes to the vertical road, the forehead is cut off, the wild remains are quiet, the class is hanged, the town is prosperous, the endurance is supported, the key is returned, Fu Qing is gathered around Mo Busy dancing, encountering the sound of Gu Jiaoyang Lake nail kernel, breaking the sound, stretching out the lamp to avoid flooding and dying, answering the brave emperor, Liu Hajie, Gan Nuo, Xian Nong Island, who is attacked by the flood, the cannon pours the spots, the understanding of the spirit egg, the child releases the breast, the giant's private bank Yi Jingtan Lei Jun mold Du Lele separated the bends Zhao Shao Hu Hu Tong Feng Ling Chai Huang Wu jumped to Shang Ding Qin Shao Chai Liang broke off the alkali special hill digging the blade drama pile He He Che Heng Qin film was published in the case journal The seedlings are slow and protruding, the snow chains are cut, the faces are cut, the snow chain is fished, the faces are locked, the league is bought, Yang Zongjiao Sai flag is filtered, the silicon carbon stock is steamed and condensed, and the gun is trapped in the gun. Li saves the dark hole and commits the tube. Jianzun Doupa Mo arrived at Sangpo sewing police picked dirty ice Cambodian mouth what rice plastic mailed Zhao shouting pad Dandu ear planing tiger pen thin Kunlang Sa tea drops shallow support hole covered Lun Niang tons soaked sleeve beads female mother purple play tower hammer The shocking age, the appearance of a clean cut, the suspicion of the tyrant, the fierce complaint against the brutality, the sudden disaster, Qiao Tang leaked the news about the sinking of the chlorine waste, and the men who robbed the statues were also loyal and sang. Capture, touch, rust, sweep, glass, treasure core, secret, clean, Jiang Calcium shoulder, Teng dry, throw track, mix dad, follow the temptation, encourage Ken, wine rope, poor pond, dry bubble bag, feed aluminum, soft canal, habitual trade, excrement, comprehensive wall, move towards the other side, ink hinders Qi Ni Sun Linling cheated and borrowed ".$addChars;
  608. break;
  609. case 5:
  610. $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.$addChars;
  611. break;
  612. default :
  613. // The easily confused characters oOLl and are removed by default Number 01, to add please use addChars parameter
  614. $chars='ABCDEFGHIJKMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789'.$addChars;
  615. break;
  616. }
  617. if($len>10 ) {//The number of digits is too long and the string is repeated a certain number of times
  618. $chars= $type==1? str_repeat($chars,$len) : str_repeat($chars,5);
  619. }
  620. if($type == 4){ // Processing Chinese
  621. $chars = preg_replace('/[^\x{4e00}-\x{9fa5}]/u', '', $chars); // / /Get rid of non-utf8 Chinese characters
  622. $chars = chunk_split($chars,3,","); // //Insert a "," every 3 characters, convert it to an array, use strlen() to measure the php One Chinese occupies 3
  623. $re = explode(",",$chars);
  624. shuffle($re);//Randomly reorder the array
  625. $chars = implode($re);
  626. unset($re);
  627. $str = mb_substr($chars,0,$len,"utf-8");
  628. }else{
  629. $chars = str_shuffle($chars);
  630. $str = substr($chars,0,$len);
  631. }
  632. return $str;
  633. }
  634. //Get the value of the parameter in the url
  635. function geturlval($url,$name)
  636. {
  637. $arr = parse_url($url);
  638. $arr_query = $this-> ;convertUrlQuery($arr['query']);
  639. return $arr_query[$name];
  640. }
  641. function convertUrlQuery($query)
  642. {
  643. $queryParts = explode('&', $query);
  644. $params = array();
  645. foreach ($queryParts as $param)
  646. {
  647. $item = explode('=', $param);
  648. $params[$item[0]] = $item[1];
  649. }
  650. return $params;
  651. }
  652. /**
  653. * Grab remote images
  654. *
  655. * @param string $url remote image path
  656. * @param string $filename local storage file name
  657. */
  658. function grabImage($url, $savepath) {
  659. if($url =="") {
  660. return false; //If $url is If empty, return false;
  661. }
  662. $ext_name = strrchr($url, '.'); //Get the extension of the image
  663. if($ext_name != '.gif' && $ext_name != '.jpg' && $ ext_name != '.bmp' && $ext_name != '.png') {
  664. return false; //The format is not within the allowed range
  665. }
  666. //Get the original picture name
  667. $filename = $savepath.'\'.end (explode('/',$url));
  668. //Start capturing
  669. ob_start();
  670. readfile($url);
  671. $img_data = ob_get_contents();
  672. ob_end_clean();
  673. $size = strlen($img_data );
  674. $local_file = fopen($filename, 'a');
  675. echo $filename;
  676. if(fwrite($local_file, $img_data)== FALSE){
  677. echo 'Picture download failed';
  678. }
  679. fclose( $local_file);
  680. return $filename;
  681. }
  682. }
  683. ?>
Copy code



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template