Correcting some PHP tools

Source: Internet
Author: User
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;}}

?

?

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.