/** * 执行多张图片上传 * @return void */ public function upload_muti_pic() { $albumId = intval($_REQUEST['albumId']); $albumDao = D('Album', 'photo'); $albumInfo = $albumDao->field('id')->find($albumId); if (!$albumInfo) { $this->error('不存在的相册ID'); } $config = photo_getConfig(); $options['userId'] = $this->mid; $options['allow_exts'] = $config['photo_file_ext']; $options['max_size'] = $config['photo_max_size']; $info = model('attach')->upload(array('upload_type' => 'image'), $options); if ($info['status']) { $info['info'] = $this->save_photo($albumId, $info['info']); //记录上传的图片数量 $upnum = count($info['info']); //重置相册图片数 $albumDao->updateAlbumPhotoCount($albumId); $res['status'] = 1; $res['info'] = '上传成功'; $res['data'] = array('albumId' => $albumId, 'upnum' => $upnum); } else { $res['status'] = 0; $res['info'] = $info['info']; $res['data'] = ''; } exit(json_encode($res)); }
/** * 显示一个图片专辑 * @return void */ public function album() { $id = intval($_REQUEST['id']); // 获取相册信息 $albumDao = D('Album'); $album = $albumDao->where("id={$id}")->find(); if (!$album) { $this->assign('jumpUrl', U('photo/Index/index')); $this->error('专辑不存在或已被删除!'); } // 隐私控制 if ($this->mid != $album['userId']) { $relationship = getFollowState($this->mid, $this->uid); if ($album['privacy'] == 3) { $this->error('这个' . $this->appName . ',只有主人自己可见。'); } else { if ($album['privacy'] == 2 && $relationship == 'unfollow') { $this->error('这个' . $this->appName . ',只有主人的粉丝可见。'); } else { if ($album['privacy'] == 4) { $cookie_password = cookie('album_password_' . $album['id']); // 如果密码不正确,则需要输入密码 if ($cookie_password != md5($album['privacy_data'] . '_' . $album['id'] . '_' . $album['userId'] . '_' . $this->mid)) { $this->need_password($album); exit; } } } } } // 获取图片数据 $order = '`order` DESC, `id` DESC'; $map['albumId'] = $id; $map['userId'] = $this->uid; $map['is_del'] = 0; $config = photo_getConfig(); // $photos = D('Photo', 'photo')->order($order)->where($map)->findPage($config['photo_raws']); $photos = D('Photo', 'photo')->order($order)->where($map)->findPage(20); $this->assign('photos', $photos); // 点击率加1 $res = $albumDao->where("id={$id} AND userId={$this->uid}")->setInc('readCount'); //dump($res);dump($albumDao->getLastSql());exit; $this->setTitle(getUserName($this->uid) . '的' . $this->appName . ':' . $album['name']); $this->assign('photo_preview', $config['photo_preview']); $this->assign('album', $album); $this->display(); }