- class Fun{
-
- function isEmpty($val)
- {
- if (!is_string($val)) return false; //Is it a string type?
- if (empty($val )) return false; //Whether it has been set
- if ($val=='') return false; //Whether it is empty
- return true;
-
- }
- /*
- -------- -------------------------------------------------- -
- Function name: isNumber
- Brief description: Check whether the input is a number
- Input: string
- Output: boolean
- Modification log: ------
- --------------- --------------------------------------------------
- */
- function isNumber ($val)
- {
- if(ereg("^[0-9]+$", $val))
- return true;
- return false;
- }
-
- /*
- --------- --------------------------------------------------
- Function name: isPhone
- Brief description: Check whether the input is a phone
- Input: string
- Output: boolean
- Modification log: ------
- ---------------- --------------------------------------------------
- */
- function isPhone( $val)
- {
- //eg: xxx-xxxxxxxx-xxx | xxxx-xxxxxxx-xxx ...
- if(ereg("^((0d{2,3})-)(d{7,8}) (-(d{3,}))?$",$val))
- return true;
- return false;
- }
- /*
- ------------------ ------------------------------------------
- Function name: isPostcode
- Brief description : Check whether the input is a zip code
- Input: string
- Output: boolean
- Modification log: ------
- ------------------------ ----------------------------------
- */
- function isPostcode($val)
- {
- if( ereg("^[0-9]{4,6}$",$val))
- return true;
- return false;
- }
-
- /*
- -------------- ---------------------------------------------
- Function name: isEmail
- Brief description: Email address legality check
- Input: string
- Output: boolean
- Modification log: ------
- ----------------------- ----------------------------------------
- */
- function isEmail($val,$domain= "")
- {
- if(!$domain)
- {
- if( preg_match("/^[a-z0-9-_.]+@[da-z][.w-]+.[a-z]{ 2,4}$/i", $val) )
- {
- return true;
- }
- else
- return false;
- }
- else
- {
- if( preg_match("/^[a-z0-9-_. ]+@".$domain."$/i", $val) )
- {
- return true;
- }
- else
- return false;
- }
- }//end func
-
- /*
- ----- -------------------------------------------------- ----
- Function name: isName
- Brief description: Name and nickname validity check, only Chinese and English can be entered
- Input: string
- Output: boolean
- Modification log: ------
- ------- -------------------------------------------------- --
- */
- function isName($val)
- {
- if( preg_match("/^[x80-xffa-zA-Z0-9]{3,60}$/", $val) )//2008- 7-24
- {
- return true;
- }
- return false;
- }//end func
-
-
- /*
- ----------------------- ------------------------------------
- Function name: isStrLength($theelement, $min, $max )
- Brief description: Check whether the string length meets the requirements
- Input: mixed (string, minimum length, maximum length)
- Output: boolean
- Modification log: ------
- --------- --------------------------------------------------
- */
- function isStrLength($val, $min, $max)
- {
- $theelement= trim($val);
- if(ereg("^[a-zA-Z0-9]{".$min. ",".$max."}$",$val))
- return true;
- return false;
- }
-
-
- /*
- ------------------ ----------------------------------------
- Function name: isNumberLength($theelement, $min, $max)
- Brief description: Check whether the string length meets the requirements
- Input: mixed (string, minimum length, maximum length)
- Output: boolean
- Modification log: ------
- ---- -------------------------------------------------- -----
- */
- function isNumLength($val, $min, $max)
- {
- $theelement= trim($val);
- if(ereg("^[0-9]{".$min .",".$max."}$",$val))
- return true;
- return false;
- }
-
- /*
- ------------------ ----------------------------------------
- Function name: isNumberLength($theelement, $min, $max)
- Brief description: Check whether the string length meets the requirements
- Input: mixed (string, minimum length, maximum length)
- Output: boolean
- Modification log: ------
- ---- -------------------------------------------------- -----
- */
- function isEngLength($val, $min, $max)
- {
- $theelement= trim($val);
- if(ereg("^[a-zA-Z]{". $min.",".$max."}$",$val))
- return true;
- return false;
- }
-
- /*
- --------------------------------------------- ---------------
- Function name: isEnglish
- Brief description: Check whether the input is in English
- Input: string
- Output: boolean
- Author: ------
- Modification log: - -----
- ----------------------------------------------- ---------------
- */
- function isEnglish($theelement)
- {
- if( ereg("[x80-xff].",$theelement) )
- {
- Return false ;
- }
- Return true;
- }
-
- /*
- ---------------------------------------- -----------------------
- Function name: isChinese
- Brief description: Check whether the input is Chinese characters
- Input: string
- Output: boolean
- Modification log: - -----
- ----------------------------------------------- ---------------
- */
- /*
- function isChinese($sInBuf)//The function in question
- {
- $iLen= strlen($sInBuf);
- for($ i= 0; $i< $iLen; $i++)
- {
- if(ord($sInBuf{$i})>=0x80)
- {
- 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)) )
- {
- if(ord($sInBuf{$i}) >0xA0 && ord($sInBuf{$i})<0xAA)
- {
- //There is Chinese punctuation
- return false;
- }
- }
- else
- {
- //There is Japanese or other text
- return false;
- }
- $i++;
- }
- else
- {
- return false;
- }
- }
- return true;
- }*/
-
-
- function isChinese($sInBuf)//Correct function
- {
- if (preg_match("/ ^[x7f-xff]+$/", $sInBuf)) { //Compatible with gb2312,utf-8
-
- return true;
- }
- else
- {
- return false;
- }
- }
- /*
- --- -------------------------------------------------- ------
- Function name: isDomain($Domain)
- Brief description: Check whether an (English) domain name is legal
- Input: string domain name
- Output: boolean
- Modification log: -------
- --- -------------------------------------------------- ------
- */
- function isDomain($Domain)
- {
- if(!eregi("^[0-9a-z]+[0-9a-z.-]+[0-9a-z ]+$", $Domain))
- {
- Return false;
- }
- if( !eregi(".", $Domain))
- {
- Return false;
- }
-
- if(eregi("-.", $Domain) or eregi("--", $Domain) or eregi("..", $Domain) or eregi(".-", $Domain))
- {
- Return false;
- }
-
- $aDomain= explode(".",$Domain);
- if( !eregi("[a-zA-Z]",$aDomain[count($aDomain)-1]) )
- {
- Return false;
- }
-
- if (strlen($aDomain[0]) > 63 || strlen($aDomain[0]) < 1)
- {
- Return false;
- }
- Return true;
- }
- /**
- * Function to verify date
- * @param unknown_type $date
- * @param unknown_type $format
- * @throws Exception
- * @return boolean
- */
- function validateDate( $date, $format='YYYY-MM-DD')
- {
- switch( $format )
- {
- case 'YYYY/MM/DD':
- case 'YYYY-MM-DD':
- list( $y, $m, $d ) = preg_split( '/[-./ ]/', $date );
- break;
-
- case 'YYYY/DD/MM':
- case 'YYYY-DD-MM':
- list( $y, $d, $m ) = preg_split( '/[-./ ]/', $date );
- break;
-
- case 'DD-MM-YYYY':
- case 'DD/MM/ YYYY':
- list( $d, $m, $y ) = preg_split( '/[-./ ]/', $date );
- break;
-
- case 'MM-DD-YYYY':
- case 'MM /DD/YYYY':
- list( $m, $d, $y ) = preg_split( '/[-./ ]/', $date );
- break;
-
- case 'YYYYMMDD':
- $y = substr ( $date, 0, 4 );
- $m = substr( $date, 4, 2 );
- $d = substr( $date, 6, 2 );
- break;
-
- case 'YYYYDDMM':
- $y = substr( $date, 0, 4 );
- $d = substr( $date, 4, 2 );
- $m = substr( $date, 6, 2 );
- break;
-
- default:
- throw new Exception ( "Invalid Date Format" );
- }
- return checkdate( $m, $d, $y );
- }
-
-
- /*
- ------------------ ----------------------------------------
- Function name: isDate
- Brief description: Check whether the date matches 0000-00-00
- Input: string
- Output: boolean
- Modification log: ------
- ----------------------- ----------------------------------------
- */
- function isDate($sDate)
- {
- if( ereg("^[0-9]{4}-[][0-9]{2}-[0-9]{2}$",$sDate) )
- {
- Return true;
- }
- else
- {
- Return false;
- }
- }
- /*
- -------------------------------------------------- -------------
- Function name: isTime
- Brief description: Check whether the date matches 0000-00-00 00:00:00
- Input: string
- Output: boolean
- Modification log: -- ----
- ------------------------------------------------ ---------------
- */
- function isTime($sTime)
- {
- if( ereg("^[0-9]{4}-[][0-9]{ 2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$",$sTime) )
- {
- Return true;
- }
- else
- {
- Return false;
- }
- }
-
- /*
- ---------------------------------- ----------------------------
- Function name: isMoney($val)
- Brief description: Check whether the input value is in legal RMB format
- Input: string
- Output: boolean
- Modification log: ------
- -------------------------------- -----------------------------
- */
- function isMoney($val)
- {
- if(ereg("^[0-9 ]{1,}$", $val))
- return true;
- if( ereg("^[0-9]{1,}.[0-9]{1,2}$", $val) )
- return true;
- return false;
- }
-
- /*
- ---------------------------------- ------------------------
- Function name: isIp($val)
- Brief description: Check whether the input IP meets the requirements
- Input: string
- Output: boolean
- Modification log:------
- ------------------------------------------ ---------------------
- */
- function isIp($val)
- {
- return(bool) ip2long($val);
- }
- //- -------------------------------------------------- --------------------------
-
-
-
- /**
- * Verify mobile number
- * @param int $mobile
- */
- function valid_mobile($mobile){
- if(strlen ($mobile)!=11) return false;
- 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)){
- return true;
- }else{
- return false;
- }
- }
-
- /* *
- * Thumbnail generation function, it is best to use GD2
- *
- * @param string $srcFile The file to generate thumbnails
- * @param int $toW Thumbnail width
- * @param int $toH Thumbnail height
- * @param string $toFile thumbnail file
- */
- function ImageResize($srcFile,$toW,$toH,$toFile=""){
- if($toFile==""){ $toFile = $srcFile; }
- $info = "" ;
- $data = GetImageSize($srcFile,$info);
- switch ($data[2]){
- case 1:
- if(!function_exists("imagecreatefromgif")){
- //echo "Your GD library cannot For images in GIF format, please use Jpeg or PNG format! return";
- return false;
- }
- $im = ImageCreateFromGIF($srcFile);
- break;
- case 2:
- if (!function_exists("imagecreatefromjpeg")){
- //echo "Your GD library cannot use images in jpeg format, please use images in other formats!default";
- return false;
- }
- $im = ImageCreateFromJpeg($srcFile);
- break;
- case 3:
- $ im = ImageCreateFromPNG($srcFile);
- break;
- }
- $srcW=ImageSX($im);
- $srcH=ImageSY($im);
- $toWH=$toW/$toH; $srcH;
- if($toWH<=$srcWH){
- $ftoW=$toW;
- $ftoH=$ftoW*($srcH/$srcW);
- }
- else{
- $ftoH=$toH;
- $ ftoW=$ftoH*($srcW/$srcH);
- }
- if($srcW>$toW||$srcH>$toH)
- {
- if(function_exists("imagecreateTrueColor")){
- @$ni = ImageCreateTrueColor ($ftoW, $ftoH);
- if($ni) ImageCopyResampled($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);
- else{
- $ni= ImageCreate ( $ftoW , $ftoH )
- ImageCopyResized ( $ ni , $ im , 0 , 0 , 0 , 0 , $ ftoW , $ photo H , $ srcW , $ srcH ); ($ftoW, $ftoH);
- ImageCopyResized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);
- }
- if(function_exists('imagepeg')); ImageJpeg($ni,$toFile);
- else ImagePNG($ni,$toFile);
- ImageDestroy($ni);
- }else{
- ImageDestroy($im);
- return false;
- }
- ImageDestroy($im); ;
- return true;
- }
-
-
-
- // public static function strTrim($str)
- {
- return preg_replace("/s/","",$str);
- }
-
- //; static function userName($str,$type,$len)
- {
- $str=self::strTrim($str);
- if($len {
- return false;
- }else {
- switch ( $type )
- {
- case " EN " ://default
- if ( preg_match ( " / ^ [ a - zA - Z ] + $ / " , $str ))
- {
- return true ;
- } else {
- return false ;
- }
- break ;
- case " ENNUM "
- }
- if ( preg_match ( " / ^ [ a - zA - Z0 - 9 ] + $ / " , $ str ) )
- {
- return true ;
- } else {
- return false ;
- }
- break ;
- case " ALL " : // set preg_match ( | - _ preg_match )
- if ( preg_match ( " / ^ [| -_a -zA-Z0-9]+$/",$str))
- {
- return true;
- }else{
- return false;
- }
- break;
- }
- }
- }
-
- //Create a lock static function passWord($min,$max,$size)
- {
- $size=self::strTrim($size);
- if(size($size)>=$min &&size($size)<=$ max)
- {
- return true ;
- } else {
- return false ;
- }
- }
-
- // key Email
- static function Email ( $str )
- {
- $str = self :: strTrim ( $str );
-
- if(preg_match("/^([a-z0-9_]|\-|\.)+@(([a-z0-9_]|\-)+\.){1,2}[a-z] {2.4}$/i",$str))
- {
- return true;
- }else{
- return false;
- }
- }
- //Create IDCard($str)
- static function idCard($str )
- {
- $str=self::strTrim($str);
- if(preg_match("/^([0-9]{15}|[0-9]{17}[0-9a-z]) $/i", $str))
- {
- return true;
- }else{
- return false;
- }
- }
-
- //Specify the keyword static function Phone($type,$str)
- {
- $str = self :: strTrim ( $str )
- switch ( $ type )
- {
- case " CHN " :
- if ( preg_match ( " / ^ ( [ 0 - 9 ] { 3 } | 0 [ 0 - 9 ] { }) - [ 0 - 9 ] { 7 , 8 } $ / " , $ str ) )
- {
- return true ;
- } else {
- return false ;
- }
- break ;
- case " INT " :
- if ( preg_match ("/^[0-9]{4}-([0-9]{3}|0[0-9]{3})-[0-9]{7.8}$/",$str ))
- {
- return true;
- }else{
- return false;
- }
- break;
- }
- }
- /**
- * Filter the values of the two-dimensional array
- * @param two-dimensional array $arr_data
- * @param one-dimensional array $field
- * @return Ambigous
- */
- function getarrayfield($arr_data, $field)
- {
- $resultArr = array();
- foreach($arr_data as $key => $value ) {
- foreach ($field as $k=>$v)
- {
- if(array_key_exists($v, $value))//invalid array
- {
- $resultArr[$key][$v] =$value[$v] ;
- }
- else
- {
- $resultArr[$key][$v]="return $resultArr;
- };
- /**
- * Get the client IP address
- * @return ip
- */
- function get_client_ip(){
- if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
- $ip = getenv("HTTP_CLIENT_IP");
- else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
- $ip = getenv("HTTP_X_FORWARDED_FOR");
- else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
- $ip = getenv("REMOTE_ADDR");
- else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
- $ip = $_SERVER['REMOTE_ADDR'];
- else
- $ip = "unknown";
- return($ip);
- }
-
- function get_http_user_agent(){
- return isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "";
- }
-
- /**
- * Get real address from IP address
- * @param IP $ip
- */
- function get_address_from_ip($ip){
- $url='http://www.youdao.com/smartresult-xml/search.s?type=ip&q=';
- $xml=file_get_contents($url.$ip);
- $data=simplexml_load_string($xml);
- return $data->product->location;
- }
-
-
- /**
- * Generate a random string, which can be used to automatically generate passwords. The default length is a mixture of 6 letters and numbers
- * @param string $len length
- * @param string $type string type
- * 0 letters 1 numbers 2 uppercase letters 3 lowercase letters Default mixed 4 Chinese
- * @param string $addChars extra characters
- * @return string
- */
- function rand_string($len=6,$type='',$addChars='') {
- $str ='';
- switch($type) {
- case 0:
- $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.$addChars;
- break;
- case 1:
- $chars= str_repeat('0123456789',3);
- break;
- case 2:
- $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ'.$addChars;
- break;
- case 3:
- $chars='abcdefghijklmnopqrstuvwxyz'.$addChars;
- break;
- case 4:
- $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;
- break;
- case 5:
- $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.$addChars;
- break;
- default :
- // The easily confused characters oOLl and are removed by default Number 01, to add please use addChars parameter
- $chars='ABCDEFGHIJKMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789'.$addChars;
- break;
- }
- if($len>10 ) {//The number of digits is too long and the string is repeated a certain number of times
- $chars= $type==1? str_repeat($chars,$len) : str_repeat($chars,5);
- }
-
- if($type == 4){ // Processing Chinese
- $chars = preg_replace('/[^\x{4e00}-\x{9fa5}]/u', '', $chars); // / /Get rid of non-utf8 Chinese characters
- $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
- $re = explode(",",$chars);
- shuffle($re);//Randomly reorder the array
- $chars = implode($re);
- unset($re);
- $str = mb_substr($chars,0,$len,"utf-8");
- }else{
- $chars = str_shuffle($chars);
- $str = substr($chars,0,$len);
- }
-
- return $str;
- }
-
- //Get the value of the parameter in the url
- function geturlval($url,$name)
- {
- $arr = parse_url($url);
- $arr_query = $this-> ;convertUrlQuery($arr['query']);
-
- return $arr_query[$name];
-
- }
- function convertUrlQuery($query)
- {
- $queryParts = explode('&', $query);
-
- $params = array();
- foreach ($queryParts as $param)
- {
- $item = explode('=', $param);
- $params[$item[0]] = $item[1];
- }
-
- return $params;
- }
- /**
- * Grab remote images
- *
- * @param string $url remote image path
- * @param string $filename local storage file name
- */
- function grabImage($url, $savepath) {
- if($url =="") {
- return false; //If $url is If empty, return false;
- }
- $ext_name = strrchr($url, '.'); //Get the extension of the image
- if($ext_name != '.gif' && $ext_name != '.jpg' && $ ext_name != '.bmp' && $ext_name != '.png') {
- return false; //The format is not within the allowed range
- }
- //Get the original picture name
- $filename = $savepath.'\'.end (explode('/',$url));
- //Start capturing
- ob_start();
- readfile($url);
- $img_data = ob_get_contents();
- ob_end_clean();
- $size = strlen($img_data );
- $local_file = fopen($filename, 'a');
- echo $filename;
- if(fwrite($local_file, $img_data)== FALSE){
- echo 'Picture download failed';
- }
- fclose( $local_file);
- return $filename;
- }
-
- }
- ?>
Copy code
|