Example #1
0
 if ($action == "user_upload_qrcode") {
     //上传图片路径
     $imgpath = $_REQUEST["imgpath"];
     $uploadPath = dirname(__FILE__) . "/upload/" . $imgpath . "/";
     if ($_FILES["file"]["error"] <= 0) {
         if (file_exists($uploadPath . $_FILES["file"]["name"])) {
             unlink($uploadPath . $_FILES["file"]["name"]);
         }
         //取文件扩展名
         //strripos -计算指定字符串在目标字符串中最后一次出现的位置(不区分大小写)
         $filename = $_FILES["file"]["name"];
         $point = strripos($filename, ".");
         $ext = substr($filename, $point, strlen($filename));
         $time = md5(time());
         //裁剪图片
         my_image_resize($_FILES["file"]["tmp_name"], $uploadPath . $time . $ext, 430, 430);
         $picurl = $time . $ext;
         $verurl = "qrcode/" . $picurl;
         //保存
         $params = array(array(intval($_SESSION["cid"]), SQLSRV_PARAM_IN), array("", SQLSRV_PARAM_IN), array("", SQLSRV_PARAM_IN), array($verurl, SQLSRV_PARAM_IN));
         sp_execute("{call web_set_canteen_verify(?,?,?,?)}", $params);
         $status = "ok";
         $info = $picurl;
     }
     //
 } else {
     if ($action == "user_set_sales_win") {
         $winids = $_REQUEST["winids"];
         $winid = str2num(saleswin_content, $winids);
         $winname = $_POST["winname"];
         //生成二维码
Example #2
0
 unset($_SESSION["ccl"]);
 if (isset($_REQUEST["canteenName"])) {
     //download image
     if (isset($_REQUEST["mediaId"])) {
         $mediaId = $_REQUEST["mediaId"];
         //https://api.weixin.qq.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id=MEDIA_ID
         $access_token = db_get_token_ticket(CFG_APPID, CFG_SECRET)["token"];
         $url = "https://api.weixin.qq.com/cgi-bin/media/get?access_token={$access_token}&media_id={$mediaId}";
         $fileinfo = downloadWeixinFile($url);
         //
         $uploadPath = dirname(dirname(__FILE__)) . "/upload/shop/";
         $tmpFile = "aaa.jpg";
         $time = time();
         $ext = ".jpg";
         saveWeixinFile($uploadPath . $tmpFile, $fileinfo["body"]);
         my_image_resize($uploadPath . $tmpFile, $uploadPath . $time . $ext, 375, 300);
     }
     //
     $canteenName = $_REQUEST["canteenName"];
     $canteenTel = $_REQUEST["canteenTel"];
     $picurl = $time . $ext;
     $cid = 0;
     //创建餐厅,并建立绑定关系,设置成管理员
     $longitude = $_REQUEST["longitude"];
     $latitude = $_REQUEST["latitude"];
     db_log("create canteen x:{$longitude}, y:{$latitude}, tel:{$canteenTel}");
     $params = array(array(intval($_SESSION["uid"]), SQLSRV_PARAM_IN), array("" . $canteenName, SQLSRV_PARAM_IN), array("" . $canteenTel, SQLSRV_PARAM_IN), array("" . $picurl, SQLSRV_PARAM_IN), array("" . $longitude, SQLSRV_PARAM_IN), array("" . $latitude, SQLSRV_PARAM_IN), array($cid, SQLSRV_PARAM_OUT));
     sp_execute("{call app_user_create_canteen(?,?,?,?,?,?,?)}", $params);
     $_SESSION["cid"] = $cid;
     $_SESSION["cname"] = $canteenName;
     $_SESSION["shop_picurl"] = $picurl;
Example #3
0
        //取比例大的那个值
        // 定义一个中间的大图像,该图像的高或宽和目标图像相等,然后对原图放大
        $inter_w = (int) ($w * $ratio);
        $inter_h = (int) ($h * $ratio);
        $inter_img = imagecreatetruecolor($inter_w, $inter_h);
        //将原图缩放比例后裁剪
        imagecopyresampled($inter_img, $src_img, 0, 0, 0, 0, $inter_w, $inter_h, $w, $h);
        // 定义一个新的图像
        $new_img = imagecreatetruecolor($new_width, $new_height);
        imagecopy($new_img, $inter_img, 0, 0, 0, 0, $new_width, $new_height);
        switch ($type) {
            case IMAGETYPE_JPEG:
                imagejpeg($new_img, $dst_file, 100);
                // 存储图像
                break;
            case IMAGETYPE_PNG:
                imagepng($new_img, $dst_file, 100);
                break;
            case IMAGETYPE_GIF:
                imagegif($new_img, $dst_file, 100);
                break;
            default:
                break;
        }
    }
    // if3
}
// end function
for ($i = 0; $i < 5; ++$i) {
    my_image_resize('images/slide2.jpg', '1_1.jpg', '1000px', '335px');
}