Modify some PHP tools
The original code in the non-frame is a wood problem, but used in the framework of the error, MB, finally modified ...?
?
Specific use see accessories, you can package under hehe
?
/** * QR code image generation */class Helper_qrcode {/** * Generate two-dimensional code picture * * @param string $url corresponding URL address * @param integer $size Image size * @param integer $margin margin * * @return qview_output Output object containing a two-D code image */static function Generateimage ($url, $size =6, $m Argin=1) {$filename = ' qkenrcode-'. Mt_rand (); Ob_start (); $mime = Image_type_to_mime_type (imagetype_gif); $QR = QRCode:: Getminimumqrcode ($url, qr_error_correct_level_h); $im = $qr->createimage ($size, $margin); Imagegif ($im); Imagedestroy ($im); unset ($im); $output = new Qview_output ($filename, $mime, Ob_get_clean ()); $output Contentdisposition (' inline ') ->enableclientcache (false); return $output;}}
?
/** * geo-related auxiliary class * */class Helper_geo {private static function trueIp ($IP) {return Filter_var ($ip, FILTER_VALIDATE_IP, filter_flag_ipv4| filter_flag_ipv6| filter_flag_no_res_range| Filter_flag_no_priv_range);} /** * Calculates the corresponding landmark information according to the IP address * * @param $ip IP Address * * @return array */static function GetData ($ip) {$ip = self: : TrueIp ($IP); if ($IP) {Unirest::verifypeer (false); Unirest::timeout (2); $response = Unirest::get (' http://ip.taobao.com/service/getIpInfo.php ', Array ("Accept" and "=" Application/json "), Array (" IP "= = $ip)), if (Is_array ($response->body) && $response->body[' code ') = = = 0 &&!empty ($response->body[' data ')) {return $response->body[' data '];} } return false;}}
?
?