/**
  * 修改截取后的头像
  */
 public function ModifyAvator()
 {
     $ShearPhoto["config"] = array("proportional" => 0);
     import('Vendor.ShearPhoto.ShearPhoto');
     $Shear = new \ShearPhoto(ACPopedom::mixPass(ACPopedom::getID()));
     $tmp_name = $Shear->run(json_decode(trim(stripslashes($_POST["JSdate"])), true), $ShearPhoto["config"]);
     //传入参数运行
     if (!$tmp_name) {
         $this->ajaxReturn(array('erro' => '头像保存失败'));
     }
     $filename = $Shear->filename . $Shear->imagesuffix;
     //又拍云上传
     import('Vendor.Upyun.UpYunApi');
     $upYunApi = new \UpYunApi(UPYUN_BUCKET, UPYUN_USERNAME, UPYUN_PASSWORD);
     $upYunApi->debug = false;
     $upYunApi->setApiDomain(UPYUN_HOST);
     $fh = fopen($tmp_name, 'rb');
     $rsp = $upYunApi->writeFile('/Attachment/face/' . $filename, $fh, true);
     if (file_exists(ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . $Shear->filename)) {
         unlink(ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . $filename);
     }
     fclose($fh);
     if ($rsp) {
         $result = M('Users')->where('userid = ' . ACPopedom::getID())->save(array('avator' => UPYUN_BASIC_URL . '/Attachment/face/' . $filename));
         if ($result !== false) {
             $userinfo = ACPopedom::getUserInfo();
             cookie("__info__", authcode(serialize(array('nickname' => $userinfo['nickname'], 'userid' => $userinfo['userid'], 'avator' => UPYUN_BASIC_URL . '/Attachment/face/' . $filename)), "ENCODE", SESSION_AUTH, C('COOKIE_EXPIRE')));
             $this->ajaxReturn(array('success' => '截图成功!如不能立即显示,请多刷新两次', 'url' => U('Web/UserCenter/index')));
         } else {
             $this->ajaxReturn(array('erro' => '头像更新失败'));
         }
     } else {
         $this->ajaxReturn(array('erro' => '头像更新失败'));
     }
 }
 /**
  *上传活动封面图
  *
  */
 public function upload()
 {
     $userinfo = ACPopedom::getUserInfo();
     $subName = substr(md5($userinfo['userid']), -1);
     $result = UploadFile($subName, "/Attachment/", 'upload/');
     $this->ajaxReturn($result);
 }
 public function index()
 {
     \Predis\Autoloader::register();
     $redis = new \Predis\Client();
     $feedList = M('Feed')->alias('f')->field('f.feedid,f.posttime,f.show,f.content,f.picpath,f.appid,u.avator,u.nickname')->join(array('__USERS__ AS u ON f.userid =  u.userid '))->where('f.userid = ' . ACPopedom::getID())->select();
     foreach ($feedList as $key => $value) {
         $feedList[$key]['posttime'] = beforeTime($value['posttime']);
         if ($value['picpath']) {
             $feedList[$key]['picpath'] = explode('#$', $value['picpath']);
             $feedList[$key]['pic-col'] = count($feedList[$key]['picpath']) > 4 ? 3 : 12 / count($feedList[$key]['picpath']);
         }
         //取出点赞数
         $praise = $redis->hget('feed:' . $value['feedid'], 'praise');
         $feedList[$key]['praise'] = $praise ? $praise : 0;
     }
     //var_dump($feedList);
     $this->assign('feedlist', $feedList);
     $this->assign('userinfo', ACPopedom::getUserInfo());
     $this->display();
 }
Esempio n. 4
0
 public function test()
 {
     $this->assign('userinfo', ACPopedom::getUserInfo());
     $this->display('Public:nav');
 }