예제 #1
0
 /**
  * 发送评论
  */
 function send()
 {
     $this->response->addHeader('Content-Type', 'application/json');
     if (!login::user()) {
         return json_encode(array('code' => 3, 'result' => '尚未登陆'));
     }
     $pid = filter::int($this->post->pid);
     $content = $this->post->content;
     if (isset($_FILES['file'])) {
         $image = new image();
         $files = $this->file->receiveMultiFile($_FILES['file'], config('file'));
         foreach ($files as &$file) {
             $file = $image->resizeImage($file, 640, 320);
         }
     } else {
         $files = array();
     }
     $score = filter::int($this->post->score);
     $score = $score <= 5 && $score >= 0 ? $score : 0;
     if (!empty($pid)) {
         $commentModel = $this->model('comment');
         if ($commentModel->create($this->session->id, $pid, $content, $score, $files)) {
             return json_encode(array('code' => 1, 'result' => 'ok'));
         }
         return json_encode(array('code' => 0, 'result' => 'failed'));
     }
     return json_encode(array('code' => 2, 'result' => '参数错误'));
 }
예제 #2
0
 /**
  * 获取自定义图像大小
  */
 function resize()
 {
     $width = filter::int($this->get->width);
     $height = filter::int($this->get->height);
     $id = filter::int($this->get->id);
     $productimgModel = $this->model('productimg');
     $result = $productimgModel->get($id);
     if (!empty($result)) {
         $this->response->addHeader('Content-Type', (new filesystem())->mimetype($result['oldimage']));
         $image = new image();
         $file = $image->resizeImage($result['base_path'], $width, $height);
         $this->response->setBody(file_get_contents($file));
         @unlink($file);
     }
 }
예제 #3
0
 /**
  * 创建退账申请
  */
 function create()
 {
     $id = filter::int($this->post->id);
     $type = filter::int($this->post->type);
     $type = empty($type) ? 0 : 1;
     $reason = $this->post->reason;
     $money = filter::number($this->post->money);
     $money = empty($money) ? 0 : $money;
     if (empty($id) || empty($reason) || empty($money)) {
         return json_encode(array('code' => 5, 'result' => '参数不全'));
     }
     $description = $this->post->description;
     $description = empty($description) ? '' : $description;
     $imgs = array();
     if (isset($_FILES['img'])) {
         $image = new image();
         $imgs = $this->file->receiveMultiFile($_FILES['img'], config('file'));
         foreach ($imgs as &$img) {
             $img = $image->resizeImage($img, 640, 320);
         }
     }
     if (login::user()) {
         $orderModel = $this->model('orderlist');
         $order = $orderModel->get($id);
         if (empty($order)) {
             return json_encode(array('code' => 3, 'result' => '订单不存在'));
         }
         if (!in_array($order['status'], array(orderlistModel::STATUS_COMPLETE, orderlistModel::STATUS_PAYED, orderlistModel::STATUS_SHIPPED, orderlistModel::STATUS_SHIPPING))) {
             return json_encode(array('code' => 4, 'result' => '该订单不允许退款或者已经退款'));
         }
         $refundModel = $this->model('refund');
         if ($refundModel->create($this->session->id, $id, $type, $reason, $money, $description, $imgs)) {
             $orderModel->refund($id);
             return json_encode(array('code' => 1, 'result' => 'ok'));
         }
         return json_encode(array('code' => 0, 'result' => '申请失败'));
     }
     return json_encode(array('code' => 2, 'result' => '尚未登陆'));
 }
예제 #4
0
파일: index.php 프로젝트: jin123456bat/home
 /**
  * 临时文件上传通道
  */
 function image()
 {
     $file = $this->file->file;
     if (is_file($file)) {
         $width = $this->get->width;
         $height = $this->get->height;
         $width = empty($width) ? 640 : $width;
         $height = empty($height) ? 640 * 2 : $height;
         $image = new image();
         $file = $image->resizeImage($file, $width, $height);
         if ($this->get->type == 'text') {
             return json_encode(array('code' => 1, 'result' => 'ok', 'body' => file::realpathToUrl($file)));
         } else {
             return new json(json::OK, NULL, file::realpathToUrl($file));
         }
     }
     if ($this->get->type == 'text') {
         return json_encode(array('code' => 0, 'result' => '图片上传失败'));
     } else {
         return new json(json::PARAMETER_ERROR, '图片上传失败');
     }
 }
예제 #5
0
 /**
  * 用于保存app的一些配置信息
  */
 function saveapp()
 {
     $roleModel = $this->model('role');
     if (login::admin() && $roleModel->checkPower($this->session->role, 'system', roleModel::POWER_UPDATE)) {
         $startpage1 = $this->file->system_app_startpage1;
         $startpage2 = $this->file->system_app_startpage2;
         $startpage3 = $this->file->system_app_startpage3;
         $startpage4 = $this->file->system_app_startpage4;
         if (is_file($startpage1)) {
             $image = new image();
             $startpage1 = $image->resizeImage($startpage1, 414, 736);
             $systemModel = $this->model('system');
             if ($systemModel->set('startpage1', 'app', $startpage1)) {
                 return json_encode(array('code' => 1, 'result' => 'ok', 'body' => file::realpathToUrl($startpage1)));
             }
         }
         if (is_file($startpage2)) {
             $image = new image();
             $startpage2 = $image->resizeImage($startpage2, 414, 736);
             $systemModel = $this->model('system');
             if ($systemModel->set('startpage2', 'app', $startpage2)) {
                 return json_encode(array('code' => 1, 'result' => 'ok', 'body' => file::realpathToUrl($startpage2)));
             }
         }
         if (is_file($startpage3)) {
             $image = new image();
             $startpage3 = $image->resizeImage($startpage3, 414, 736);
             $systemModel = $this->model('system');
             if ($systemModel->set('startpage3', 'app', $startpage3)) {
                 return json_encode(array('code' => 1, 'result' => 'ok', 'body' => file::realpathToUrl($startpage3)));
             }
         }
         if (is_file($startpage4)) {
             $image = new image();
             $startpage3 = $image->resizeImage($startpage4, 414, 736);
             $systemModel = $this->model('system');
             if ($systemModel->set('startpage4', 'app', $startpage4)) {
                 return json_encode(array('code' => 1, 'result' => 'ok', 'body' => file::realpathToUrl($startpage4)));
             }
         }
     } else {
         return json_encode(array('code' => 2, 'result' => '权限不足'));
     }
 }
예제 #6
0
파일: user.php 프로젝트: jin123456bat/home
 /**
  * 用户设置自己昵称和头像
  */
 function setnamegravatar()
 {
     if (login::user()) {
         $username = $this->post->username;
         $gravatar = $this->file->file;
         $userModel = $this->model('user');
         if (empty($username) && !is_file($gravatar)) {
             return json_encode(array('code' => 0, 'result' => '参数错误'));
         }
         if ($username !== NULL) {
             if (!$userModel->setName($this->session->id, $username)) {
                 return json_encode(array('code' => 0, 'result' => '用户名修改失败'));
             }
         }
         if (is_file($gravatar)) {
             $image = new image();
             $file = $image->resizeImage($gravatar, 200, 200);
             filesystem::unlink($gravatar);
             if (!$userModel->setGravatar($this->session->id, $file)) {
                 return json_encode(array('code' => 0, 'result' => '头像上传失败'));
             }
         }
         return json_encode(array('code' => 1, 'result' => 'ok'));
     }
     return json_encode(array('code' => 2, 'result' => '尚未登陆'));
 }
예제 #7
0
 /**
  * 添加滚动图
  */
 function create()
 {
     $roleModel = $this->model('role');
     if (login::admin() && $roleModel->checkPower($this->session->role, 'carousel', roleModel::POWER_INSERT)) {
         $pic = $this->file->pic;
         if (!empty($pic)) {
             $image = new image();
             $pic = $image->resizeImage($pic, 640, 320);
         } else {
             //滚动图的默认图片
             $pic = ROOT . '/application/assets/global/plugins/jcrop/demos/demo_files/image3.jpg';
         }
         $title = $this->post->title;
         $stop = $this->post->stop;
         $type = $this->post->type;
         $src_product = filter::int($this->post->src_product);
         $src_url = filter::url($this->post->src_url);
         $src_theme = filter::int($this->post->src_theme);
         switch ($type) {
             case 'url':
                 $src = $src_url;
                 break;
             case 'product':
                 $src = $src_product;
                 break;
             case 'theme':
                 $src = $src_theme;
                 break;
             default:
                 $src = '';
                 break;
         }
         $carouselModel = $this->model('carousel');
         $id = $carouselModel->create($title, $pic, $stop, $type, $src);
         return new json(json::OK, NULL, $id);
     } else {
         return new json(json::NO_POWER);
     }
 }
예제 #8
0
파일: theme.php 프로젝트: jin123456bat/home
 /**
  * 保存对主题的修改
  */
 function save()
 {
     $this->response->addHeader('Content-Type', 'application/json');
     $roleModel = $this->model('role');
     if (login::admin() && $roleModel->checkPower($this->session->role, 'theme', roleModel::POWER_UPDATE)) {
         $id = $this->post->id;
         $name = $this->post->name;
         $description = $this->post->description;
         $orderby = $this->post->orderby;
         $bigpic = $this->file->bigpic;
         $middlepic = $this->file->middlepic;
         $smallpic = $this->file->smallpic;
         $themeModel = $this->model('theme');
         if (empty($id)) {
             return json_encode(array('code' => 2, 'result' => '空id'));
         }
         if ($name !== NULL) {
             $themeModel->where('id=?', array($id))->update('name', $name);
             $body = $name;
         }
         if ($description !== NULL) {
             $themeModel->where('id=?', array($id))->update('description', $description);
             $body = $description;
         }
         if ($orderby !== NULL) {
             $themeModel->where('id=?', array($id))->update('orderby', $orderby);
             $body = $orderby;
         }
         $image = new image();
         if (is_file($bigpic)) {
             $bigpic = $image->resizeImage($bigpic, 640, 280);
             $themeModel->where('id=?', array($id))->update('bigpic', $bigpic);
             $body = file::realpathToUrl($bigpic);
         }
         if (is_file($middlepic)) {
             $middlepic = $image->resizeImage($middlepic, 320, 260);
             $themeModel->where('id=?', array($id))->update('middlepic', $middlepic);
             $body = file::realpathToUrl($middlepic);
         }
         if (is_file($smallpic)) {
             $smallpic = $image->resizeImage($smallpic, 320, 130);
             $themeModel->where('id=?', array($id))->update('smallpic', $smallpic);
             $body = file::realpathToUrl($smallpic);
         }
         return json_encode(array('code' => 1, 'result' => 'ok', 'body' => $body));
     }
     return json_encode(array('code' => 0, 'result' => '没有权限'));
 }