<?php
/** 
 * UQ云商：	www.uqcms.com  
 * 联系QQ：	2200631718 
 * 可免费商用，需要留UQ云商链接作为交换，只首页底部留取即可，不影响使用。
 */

defined('IN_UQ') or exit('Access Denied'); class album_uqcms extends control { function __construct() { $this->uid = @$_SESSION['user']['uid']; parent::__construct(); } public function upload() { $uq0 = G('path', '', 'goods'); $uq1 = G('cid', '', '0'); $uq2 = [ 'path'=>$uq0, 'ptype'=>$uq1, 'u_type'=>'user' ]; $uq3 = $this->module('album')->upload($uq2); echo json_encode($uq3); } public function upload_temp() { $uq2 = [ 'path'=>'temp', 'local'=>'1' ]; $uq3 = $this->module('album')->upload($uq2); echo json_encode($uq3); } public function cut_img() { if($_POST){ $uq4 = P('image', '图片提交错误'); $x1 = P('x1/f'); $y1 = P('y1/f'); $uq7 = P('w/f'); $uq8 = P('h/f'); $uq9 = $this->db->get_one("select uid,avatar from ".table('member')." where uid = ".$this->uid); if($uq9['uid']){ $this->module('album')->del($uq9['avatar']); $uq2 = [ 'image'=>$uq4, 'x1'=>$x1, 'y1'=>$y1, 'w'=>$uq7, 'h'=>$uq8, ]; $uq10 = 'temp/goods/'.file::filename($uq4); file::mk_dir($uq10); $uq11 = image::init()->crop($uq4, $x1, $y1, $uq7, $uq8, $uq10); if(!empty($uq11)){ $uq12 = $this->module('album')->upload_move($uq11, 'avatar'); if($uq12['name']){ $uq13 = $this->db->update(table('member'), ['avatar'=>$uq12['name']], 'uid = '.$this->uid); if($uq13){ $uq2['error'] = '0'; $uq2['msg'] = $uq12['name']; echo json_encode($uq2); }else{ error_json('保存错误'); } }else{ error_json('剪切错误'); } }else{ error_json('剪切失败'); } }else{ error_json('用户不存在，请重新登陆'); } }else{ error_json('提交错误'); } } } 