コード例 #1
0
ファイル: UserController.php プロジェクト: nicklos17/ucenter
 /**
  * [cropPhoto 裁剪用户头像]
  * @return [type] [description]
  */
 public function cropPhotoAction()
 {
     if (!$this->validFlag) {
         echo json_encode(array('ret' => 0, 'msg' => $this->warnMsg));
         $this->view->disable();
         return;
     } else {
         if ($this->di['session']->has('userAvatar')) {
             $img = $this->di['session']->get('userAvatar');
             if (ImgUpload::resizeThumbnailImage(preg_replace('/\\.jpg/', '_thumb.jpg', $img[0]), $img[0], $this->_sanReq['w'], $this->_sanReq['h'], $this->_sanReq['x1'], $this->_sanReq['y1'], 100 / $this->_sanReq['w'])) {
                 unlink($img[0]);
                 $users = new Users();
                 $users->changeAvatar($this->session->get('uid'), preg_replace('/\\.jpg/', '_thumb.jpg', $img[1]));
                 unset($_SESSION['userAvatar']);
             }
         }
         $this->response->redirect('user/index');
     }
 }