|
@@ -1,107 +1,54 @@
|
|
|
<?php namespace Content\Lib;
|
|
|
use Dever;
|
|
|
+use Place;
|
|
|
class Info
|
|
|
{
|
|
|
- public function getList($member, $cate = false, $id = false, $num = 10)
|
|
|
+
|
|
|
+ public function getCol()
|
|
|
{
|
|
|
- $where = array('status' => 1);
|
|
|
- if ($cate) {
|
|
|
- $cate = explode(',', $cate);
|
|
|
- $where['cate_parent_id'] = $cate[0];
|
|
|
- if (isset($cate[1])) {
|
|
|
- $where['cate_child_id'] = $cate[0];
|
|
|
- }
|
|
|
- }
|
|
|
- $times = Dever::input('times');
|
|
|
- if ($times) {
|
|
|
- $where['times_id'] = $times;
|
|
|
- }
|
|
|
- $name = Dever::input('search');
|
|
|
- if ($name) {
|
|
|
- $where['name'] = array('like', $name);
|
|
|
- }
|
|
|
- $set['col'] = 'id,name,cdate,pic,price';
|
|
|
- if ($id) {
|
|
|
- $set['limit'] = '0,6';
|
|
|
- $where['id'] = array('!=', $id);
|
|
|
- } else {
|
|
|
- $set['num'] = $num;
|
|
|
- }
|
|
|
- $info = Dever::db('info', 'content')->select($where, $set);
|
|
|
- $result = array();
|
|
|
- foreach ($info as $k => $v) {
|
|
|
- $v = $this->getInfo($v, $member);
|
|
|
- $result[] = $v;
|
|
|
- }
|
|
|
- return $result;
|
|
|
+ return 'id,name,info,pic,price,cdate';
|
|
|
}
|
|
|
|
|
|
- public function getOne($member)
|
|
|
+
|
|
|
+ public function getInfo($info)
|
|
|
{
|
|
|
- $id = Dever::input('id');
|
|
|
- $where = array('status' => 1);
|
|
|
- $where['id'] = $id;
|
|
|
- $info = Dever::db('info', 'content')->find($where);
|
|
|
- if (!$info) {
|
|
|
- Dever::alert('内容不存在');
|
|
|
- }
|
|
|
- $info = $this->getInfo($info, $member);
|
|
|
return $info;
|
|
|
}
|
|
|
|
|
|
- private function getInfo($info, $member)
|
|
|
+ public function submit($info)
|
|
|
{
|
|
|
- unset($info['password']);
|
|
|
- $info['cdate_str'] = date('Y-m-d H:i:s', $info['cdate']);
|
|
|
- if (isset($info['content'])) {
|
|
|
- $info['button'] = '下载';
|
|
|
- if ($member['id'] && $member['id'] > 0) {
|
|
|
- $collect = Dever::db('collect', 'content')->find(array('info_id' => $info['id'], 'uid' => $member['id']));
|
|
|
- if ($collect && $collect['status'] == 1) {
|
|
|
- $info['collect'] = 1;
|
|
|
- } else {
|
|
|
- $info['collect'] = 2;
|
|
|
- }
|
|
|
+ $result = $info['price'];
|
|
|
+ $password = Dever::input('password');
|
|
|
+ if ($password) {
|
|
|
+ if ($info['password'] && $password == $info['password']) {
|
|
|
+ $result['status'] = 1;
|
|
|
+ } else {
|
|
|
+ Dever::error('密码输入错误');
|
|
|
}
|
|
|
- $info['price_vip'] = array('name' => '会员', 'status' => 2, 'data' => array());
|
|
|
- $price = Dever::db('price', 'content')->select(array('type' => 1, 'info_id' => $info['id']));
|
|
|
- if ($price) {
|
|
|
- foreach ($price as &$v) {
|
|
|
- $vip = Dever::db('vip', 'place')->find($v['type_id']);
|
|
|
- if ($vip) {
|
|
|
- $v['name'] = $vip['name'];
|
|
|
- $v['price_text'] = $this->getPrice($v['price'], $member['score']);
|
|
|
- $info['price_vip']['status'] = 1;
|
|
|
- $info['price_vip']['data'][] = $v;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- $info['price_agent'] = array('name' => '代理', 'status' => 2, 'data' => array());
|
|
|
- $price = Dever::db('price', 'content')->select(array('type' => 2, 'info_id' => $info['id']));
|
|
|
- if ($price) {
|
|
|
- foreach ($price as &$v) {
|
|
|
- $vip = Dever::db('agent', 'place')->find($v['type_id']);
|
|
|
- if ($vip) {
|
|
|
- $v['name'] = $vip['name'];
|
|
|
- $v['price_text'] = $this->getPrice($v['price'], $member['score']);
|
|
|
- $info['price_agent']['status'] = 1;
|
|
|
- $info['price_agent']['data'][] = $v;
|
|
|
+ }
|
|
|
+ if ($result['status'] == 1) {
|
|
|
+ if ($id) {
|
|
|
+ $result['value'] = Dever::db('value', 'content')->find(array('info_id' => $info['id'], 'id' => $id));
|
|
|
+ } else {
|
|
|
+ $result['value'] = Dever::db('value', 'content')->select(array('info_id' => $info['id']));
|
|
|
+ if ($result['value']) {
|
|
|
+ $param['p'] = Dever::input('p');
|
|
|
+ $param['t'] = Dever::input('t');
|
|
|
+ foreach ($result['value'] as &$v) {
|
|
|
+ if ($v['file']) {
|
|
|
+ $param['g'] = \Dever\Helper\Secure::encode($v['id']);
|
|
|
+ $v['file'] = Dever::url('place/down.act', $param);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- $info['content'] = htmlspecialchars_decode($info['content']);
|
|
|
+ } elseif ($result['status'] == 2) {
|
|
|
+ $result['id'] = $info['id'];
|
|
|
+ $result['name'] = $info['name'];
|
|
|
+ $result['button'] = '购买';
|
|
|
+ } elseif ($result['status'] == 3) {
|
|
|
+ $result['text'] = '专享内容,升级会员可下载';
|
|
|
}
|
|
|
- $info['price_text'] = $this->getPrice($info['price'], $member['score']);
|
|
|
- return $info;
|
|
|
- }
|
|
|
-
|
|
|
- public function getPrice($price, $score)
|
|
|
- {
|
|
|
- if ($price > 0) {
|
|
|
- $price = $price . $score;
|
|
|
- } else {
|
|
|
- $price = '免费';
|
|
|
- }
|
|
|
- return $price;
|
|
|
+ return $result;
|
|
|
}
|
|
|
}
|