dever 6 years ago
parent
commit
9e9bab706b

+ 210 - 0
audit/database/data.php

@@ -0,0 +1,210 @@
+<?php
+
+$type = Dever::config('base')->type;
+
+$audit = Dever::config('base')->audit;
+
+$status = Dever::config('base')->status;
+
+$cate = function()
+{
+	$array = array();
+	$info = Dever::db('content/cate')->state();
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+return array
+(
+	# 表名
+	'name' => 'data',
+	# 显示给用户看的名称
+	'lang' => '审核管理',
+	# 后台菜单排序
+	'order' => 7,
+	'menu'	=> 'content',
+	'end' => array
+	(
+		'update_audit' => 'audit/lib/core.audit',
+		'update_status' => 'audit/lib/core.status',
+	),
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			//'list'		=> true,
+			'order'		=> 'desc',
+		),
+
+		'cate_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '所属栏目',
+			'default' 	=> '1',
+			'desc' 		=> '所属栏目',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $cate,
+			'search'	=> 'select',
+			'list'		=> true,
+		),
+
+		'type'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '类型',
+			'default' 	=> '1',
+			'desc' 		=> '类型',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $type,
+			'search'	=> 'select',
+			'list'		=> true,
+			//'edit'		=> true,
+		),
+
+		'data_id'		=> array
+		(
+			'type' 		=> 'varchar-80',
+			'name' 		=> '数据ID',
+			'default' 	=> '',
+			'desc' 		=> '数据id',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			//'search'	=> 'fulltext',
+			//'list'		=> true,
+		),
+		
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-80',
+			'name' 		=> '标题',
+			'default' 	=> '',
+			'desc' 		=> '标题',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'audit'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '审核状态',
+			'default' 	=> '1',
+			'desc' 		=> '审核',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $audit,
+			'search'	=> 'select',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'status'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '发布状态',
+			'default' 	=> '1',
+			'desc' 		=> '发布状态',
+			'match' 	=> 'is_numeric',
+			//'update'	=> 'select',
+			'option'	=> $status,
+			'search'	=> 'select',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+		
+		'pdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '发布时间',
+			'match' 	=> 'is_numeric',
+			'default'	=> '',
+			'desc' 		=> '',
+			'update'	=> 'date',
+			'callback'	=> 'maketime',
+			'list'		=> 'date("Y-m-d H:i:s", {pdate})',
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'search'	=> 'order',
+			'list'		=> true,
+			'order'		=> 'desc',
+			//'edit'		=> true,
+		),
+
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+			'edit'		=> false,
+		),
+		
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			//'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	'manage' => array
+	(
+		'delete' => false,
+		'edit' => false,
+		'insert' => false,
+		'mul' => true,
+
+		'list_button' => array
+		(
+			'edit' => array('预览', str_replace('https://api.', 'http://www.', Dever::url('main/preview.get?audit=1'))),
+		),
+	),
+
+	# request 请求接口定义
+	'request' => array
+	(
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'cate_id' => 'yes',
+				'type' => 'yes',
+				'type_no' => array('yes-type', '!='),
+				'audit' => 2,
+				'status' => 2,
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc','id' => 'desc'),
+			'page' => array(15, 'list'),
+			'col' => '*',
+		),
+	)
+);

+ 8 - 0
audit/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'audit');
+define('DEVER_APP_LANG', '审核管理');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 199);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-tabs');
+include(DEVER_APP_PATH . '../boot.php');

+ 36 - 0
audit/lib/Core.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace Audit\Lib;
+
+use Dever;
+
+class Core
+{
+    public function audit($id, $name, $data)
+    {
+        $audit = Dever::param('audit', $data);
+        $info = Dever::db('audit/data')->one($id);
+        $table = Dever::config('base')->type_table[$info['type']];
+
+        $source = Dever::db($table)->one($info['data_id']);
+
+        if ($source && $source['audit'] != $audit) {
+            Dever::config('base')->after = false;
+            Dever::db($table)->update(array('where_id' => $info['data_id'], 'audit' => $audit));
+        }
+    }
+
+    public function status($id, $name, $data)
+    {
+        $status = Dever::param('status', $data);
+        $info = Dever::db('audit/data')->one($id);
+        $table = Dever::config('base')->type_table[$info['type']];
+
+        $source = Dever::db($table)->one($info['data_id']);
+
+        if ($source && $source['status'] != $status) {
+            Dever::config('base')->after = false;
+            Dever::db($table)->update(array('where_id' => $info['data_id'], 'status' => $status));
+        }
+    }
+}

+ 12 - 0
content/database/article.php

@@ -54,6 +54,18 @@ return array
 	'lang' => '图文管理',
 	'order' => 100,
 
+	# 同步更新另外一个或多个表的数据
+	'syncone' => array
+	(
+		'audit/data' => array
+		(
+			# 更新另外一个表的字段 => 本表的字段
+			'where' => array('data_id' => 'id', 'type' => 1),
+			# 要更新的数据
+			'update' => array('data_id' => 'id', 'type' => 1, 'pdate' => 'pdate', 'reorder' => 'reorder', 'name' => 'name', 'audit' => 'audit', 'status' => 'status', 'cate_id' => 'cate_id', 'state' => 'state'),
+		)
+	),
+	
 	# 数据结构
 	'struct' => array
 	(

+ 0 - 34
content/lib/Applet.php

@@ -1,34 +0,0 @@
-<?php
-
-namespace Content\Lib;
-
-use Dever;
-
-class Applet
-{
-    # 更新数据
-    public function update_api()
-    {
-        $applet = Dever::db('content/applet')->state();
-
-        $option = '<option parent="" value="" selected>当前小程序</option>';
-        if ($applet) {
-            foreach ($applet as $k => $v) {
-                $option .= '<option parent="" value="'.$v['appid'].'">'.$v['name'].'</option>';
-            }
-        }
-        $html = '<div class="layui-card-body">';
-
-        $html .= '<div class="layui-form-item "><div classs="layui-col-lg6"><div><label style="font-size:14px;font-weight:bold;" class="">选择小程序</label></div><div><select lay-ignore="" class="update_value form-control layui-input layui-select   validate[required]" name="editor_applet_id" id="editor_applet_id">'.$option.'</select></div></div></div>';
-
-        $html .= '<div class="layui-form-item "><div classs="layui-col-lg6"><div><label style="font-size:14px;font-weight:bold;" class="">路径</label></div><div><input type="text" class="update_value form-control layui-input validate[required]" value="" name="editor_applet_path" id="editor_applet_path" autocomplete="new-password" placeholder=""></div></div></div>';
-
-        $html .= '<div class="layui-form-item "><div classs="layui-col-lg6"><div><label style="font-size:14px;font-weight:bold;" class="">链接-为空则使用小程序里的链接</label></div><div><input type="text" class="update_value form-control layui-input validate[required]" value="" name="editor_applet_link" id="editor_applet_link" autocomplete="new-password" placeholder=""></div></div></div>';
-
-        $html .= '<div class="layui-form-item "><div classs="layui-col-lg6"><div><label style="font-size:14px;font-weight:bold;" class="">封面图<span style="font-size:12px;font-weight:normal;font-color:#bababa;margin-left:5px;">[图片宽度750px高度自适应,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式]</span></label></div><div><input type="button" style="width:100px;display:inline;padding-left:0px;" class="form-control layui-input image_upload" v="editor_applet_pic" id="file_applet_pic" key="1" value="本地上传" autocomplete="new-password">
-        <div style="margin-top:5px;">
-        <input type="text" class="update_value form-control layui-input " name="editor_applet_pic" id="editor_applet_pic" value="" autocomplete="new-password"></div></div></div></div>';
-        $html .= '</div>';
-        return $html;
-    }
-}

+ 0 - 167
content/lib/Article.php

@@ -16,173 +16,6 @@ class Article
         if (!$data) {
             Dever::alert('错误的文章信息');
         }
-    
-        $data = $this->getContent($data, $uid);
-
-        return $data;
-    }
-
-    public function getContent($data, $uid = false)
-    {
-        //embed
-        $data['content_array'] = array();
-
-        $data['content'] = Dever::filter($data['content']);
-
-        $content = $data['content'];
-        $replace = array();
-
-        # embed已废弃
-        if (strstr($data['content'], 'embed')) {
-            # 音频
-            preg_match_all('/<embed src="(.*?)"(.*?)\/>/i', $content, $matches);
-            if (isset($matches[1])) {
-                foreach ($matches[1] as $k => $v) {
-                    $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
-
-                    if (strstr($v, '.mp4') || strstr($v, '.mov') || strstr($v, '.m3u8')) {
-                        $replace[] = array('type' => 6, 'content' => $v);
-                    } else {
-                        $replace[] = array('type' => 5, 'content' => $v);
-                    }
-                }
-            }
-        }
-
-        if (strstr($data['content'], 'data-applet')) {
-            # 小程序
-            preg_match_all('/<img(.*?)data-applet="(.*?)" \/>/', $content, $matches);
-
-            if (isset($matches[2])) {
-                foreach ($matches[2] as $k => $v) {
-                    $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
-                    $temp = explode('||', $v);
-                    $pic = $temp[0];
-                    $appid = $temp[1];
-                    $path = $temp[2];
-
-                    $appinfo = Dever::db('content/applet')->one(array('appid' => $appid));
-                    if (isset($temp[3]) && $temp[3]) {
-                        $appinfo['link'] = $temp[3];
-                    }
-
-                    $replace[] = array('type' => 7, 'pic_cover' => $pic, 'appid' => $appid, 'path' => $path, 'name' => $appinfo['name'], 'link' => $appinfo['link']);
-                }
-            }
-        }
-
-        if (strstr($data['content'], 'data-file')) {
-            # 音频
-            preg_match_all('/<img src="(.*?)" style="(.*?)" data-file="(.*?)" \/>/', $content, $matches);
-
-            if (!isset($matches[1][0])) {
-                preg_match_all('/<img style="(.*?)" src="(.*?)" data-file="(.*?)" \/>/', $content, $matches);
-                $temp = array();
-                if (isset($matches[2][0])) {
-                    $temp = $matches;
-                    $matches[1] = $temp[2];
-                    unset($temp);
-                }
-            }
-
-            if (isset($matches[1])) {
-                foreach ($matches[1] as $k => $v) {
-                    if (isset($matches[3][$k])) {
-                        $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
-
-                        $file = $matches[3][$k];
-                        $temp = explode('||', $file);
-                        $file = $temp[0];
-                        if (isset($temp[1])) {
-                            $name = $temp[1];
-                        } else {
-                            $name = '';
-                        }
-                        
-                        $cover = $v;
-
-                        if (strstr($v, '.mp4') || strstr($v, '.mov') || strstr($v, '.m3u8')) {
-                            $replace[] = array('type' => 6, 'content' => $file, 'cover' => $cover, 'name' => $name);
-                        } else {
-                            $replace[] = array('type' => 5, 'content' => $file, 'cover' => $cover, 'name' => $name);
-                        }
-                    }
-                }
-            }
-        }
-
-        if (strstr($data['content'], 'data-id')) {
-            # 视频+直播
-            preg_match_all('/<img(.*?)data-id="(.*?)" data-key="(.*?)" \/>/', $content, $matches);
-            
-            
-            if (!isset($matches[2][0])) {
-                preg_match_all('/<img(.*?)data-key="(.*?)" data-id="(.*?)" \/>/', $content, $matches);
-                $temp = array();
-                if (isset($matches[2][0]) && isset($matches[3][0])) {
-                    $temp = $matches;
-                    $matches[2] = $temp[3];
-                    $matches[3] = $temp[2];
-                    unset($temp);
-                }
-            }
-            
-            if (isset($matches[2][0]) && isset($matches[3][0])) {
-                foreach ($matches[2] as $k => $v) {
-                    $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
-                    if ($matches[3][$k] == 'video/lib/core.vod') {
-                        $method = 'video/lib/vod';
-                        $type = 2;
-                    } else {
-                        $type = 3;
-                        $method = 'video/lib/live';
-                    }
-
-                    $info = Dever::load($method)->get($v);
-                    if (isset($info['content'])) {
-                        unset($info['content']);
-                    }
-
-                    if ($type == 3) {
-                        # 查看是否有预约
-                        if ($uid > 0) {
-                            $info['user_act']['note'] = Dever::load('act/lib/note')->get($uid, $v, $type);
-                        } else {
-                            $info['user_act']['note'] = 2;
-                        }
-                    }
-                    $replace[] = array('id' => $v, 'type' => $type, 'content' => $info);
-                }
-            }
-        }
-
-        //$data['content'] = preg_replace('/<div class="dever-drop">([\s\S]*?)<\/div>/i', '', $data['content']);
-
-        $content = explode('{replace}', $content);
-        $data['content_array'] = array();
-        //print_r($content);die;
-        foreach ($content as $k => $v) {
-            $v = trim($v);
-            if (is_numeric($v) && $v >= 0 && isset($replace[$v])) {
-                $data['content_array'][] = $replace[$v];
-            } elseif ($v) {
-                $data['content_array'][] = array
-                (
-                    'type' => 1,
-                    'content' => $v,
-                );
-            }
-        }
-
-        if (!$data['content_array']) {
-            $data['content_array'][] = array
-            (
-                'type' => 1,
-                'content' => $data['content'],
-            );
-        }
-
-        unset($data['content']);
 
         return $data;
     }

+ 1 - 1
main/lib/Core.php

@@ -38,7 +38,7 @@ class Core
         //?imageView2/1/w/100/h/100/q/75
         $config = array
         (
-            'pic','pic_cover', 'pic_cover_169', 'content', 'share_pic'
+            'pic','pic_cover', 'content', 'share_pic'
         );
 
         foreach ($config as $k => $v) {

+ 13 - 81
main/src/Content.php

@@ -7,56 +7,6 @@ use Main\Lib\Core;
 
 class Content extends Core
 {
-    /*
-    public function del()
-    {
-        $uid = Dever::input('uid');
-        Dever::db('passport/user')->delete($uid);
-        $info = Dever::db('passport/wechat')->state(array('uid' => $uid));
-        if ($info) {
-            foreach ($info as $k => $v) {
-                Dever::db('passport/wechat')->delete($v['id']);
-            }
-        }
-
-        return 'ok';
-    }
-    */
-
-    public function test()
-    {
-        $journal = Dever::db('journal/info')->one(8);
-        # 发模板消息
-        $uid = Dever::input('uid');
-        $user = Dever::db('passport/user')->one($uid);
-        $wechat = Dever::db('passport/wechat')->one(array('uid' => $uid));
-
-        print_r($wechat);die;
-        if ($wechat && Dever::project('wechat_applet')) {
-            $send['key'] = 'buy_journal';
-            $send['project_id'] = 1;
-            $send['touser'] = $wechat['openid'];
-            $send['page'] = Dever::config('base')->applet_index . '?scene=' . Dever::login($uid) . ',' . '4,' . $order['product_id'];
-            $send['data'] = json_encode(array
-            (
-                'keyword1' => array('value' => date('Y年m月d日 H:i', $order['cdate'])),
-                'keyword2' => array('value' => '购买成功,您获得了 '.$journal['name'].' 的阅读资格!'),
-            ));
-            $send['form_id'] = Dever::load('act/lib/form')->get($uid, 2);
-
-            if ($send['form_id']) {
-                Dever::load('wechat_applet/msg.send', $send);
-            }
-        }
-
-        # 发短信
-        if (isset($user['mobile']) && $user['mobile'] && Dever::project('sms')) {
-            $send = array();
-            $send['name'] = $journal['name'];
-            Dever::load('sms/api.send', 'buy_journal', $user['mobile'], $send);
-        }
-    }
-
     # 开屏广告
     public function ad()
     {
@@ -68,42 +18,24 @@ class Content extends Core
     # 首页精选
     public function home()
     {
-        //1 Y2JhNGRwc0hhMEt5akp2bHBPeWIwc08tTDRWcG1DVURrUUZ4ZjV0Um85U01QMlZkOEtTcGEtR3c=
-        //2 ZTdjNjBHUTY4QUpoZk16QVlZRlg0d3locDFRcll5a3FQcWhFdEo1M1QzaFhmNGhrUlAyTTdGVWc= 
-        //9 ZTBiZWN5dW9ublpnSzR2dmlXUUc5MWJJQWk5d3pFQmx0TEp6a0VJVkU4NG5HVTYtcjhFNTdfdnc=
-        # 栏目
-        //$this->data['push_menu'] = Dever::load('push/lib/data')->get('menu', '头部导航');
-
         $this->data['menu'] = Dever::db('content/cate')->getAll();
 
-        if ($this->app) {
-            # 焦点图
-            $this->data['push_focus'] = Dever::load('push/lib/data')->get('app_focus', 'APP精选焦点图');
-
-            # 广告
-            $this->data['push_ad'] = Dever::load('push/lib/data')->get('app_ad', 'APP精选广告位');
+        # 焦点图
+        $this->data['push_focus'] = Dever::load('push/lib/data')->get('focus', '精选焦点图');
 
-            # 广告弹窗
-            $this->data['push_open_ad'] = Dever::load('push/lib/data')->get('app_open_ad', 'APP精选弹窗广告位');
-        } else {
-            # 焦点图
-            $this->data['push_focus'] = Dever::load('push/lib/data')->get('focus', '精选焦点图');
+        /*
+        # 广告
+        $this->data['push_ad'] = Dever::load('push/lib/data')->get('ad', '精选广告位');
 
-            # 广告
-            $this->data['push_ad'] = Dever::load('push/lib/data')->get('ad', '精选广告位');
-
-            # 广告弹窗
-            $this->data['push_open_ad'] = Dever::load('push/lib/data')->get('open_ad', '精选弹窗广告位');
-        }
-        
-        # 开屏广告
-        $this->data['push_screen_ad'] = Dever::load('push/lib/data')->get('app_screen_ad', 'APP开屏广告', 1);
+        # 广告弹窗
+        $this->data['push_open_ad'] = Dever::load('push/lib/data')->get('open_ad', '精选弹窗广告位');
 
         # 推荐位
         $this->data['push_link'] = Dever::load('push/lib/data')->get('link', '精选分类');
 
         # 精选推荐
         $this->data['push_up'] = Dever::load('push/lib/data')->get('up', '精选推荐');
+        */
 
         $this->news();
 
@@ -113,16 +45,16 @@ class Content extends Core
     # 精选推荐更多
     public function up()
     {
-    	$this->data['push_up'] = Dever::load('push/lib/data')->get('up', '精选推荐', 10, true);
+        $this->data['push_up'] = Dever::load('push/lib/data')->get('up', '精选推荐', 10, true);
 
-    	return $this->data;
+        return $this->data;
     }
 
     # 下拉更多
     public function news()
     {
-    	# 直接从已审核的列表中读取
-    	$this->data['news'] = array();
+        # 直接从已审核的列表中读取
+        $this->data['news'] = array();
 
         $cate = Dever::input('menu');
         $where = array();
@@ -139,7 +71,7 @@ class Content extends Core
             $where['type_no'] = 2;
         }
 
-    	$data = Dever::db('audit/data')->getAll($where);
+        $data = Dever::db('audit/data')->getAll($where);
         if ($data) {
             foreach ($data as $k => $v) {
                 $data[$k] = $this->content($v);

+ 0 - 825
main/src/Journal.php

@@ -1,825 +0,0 @@
-<?php
-
-namespace Main\Src;
-
-use Dever;
-use Main\Lib\Core;
-
-class Journal extends Core
-{
-    private function getCate()
-    {
-        $id = Dever::input('system', 1);
-
-        $cate = array();
-        if ($id > 0) {
-            $cate = Dever::db('journal/cate')->one($id);
-        }
-
-        if (!$cate) {
-            Dever::alert('分类错误');
-        }
-
-        $this->data['cate'] = $cate;
-
-        return $cate;
-    }
-
-    # 小刊首页
-    public function home()
-    {
-        # 精选推荐
-        $this->jingxuan(-1, 5);
-
-        $cate = $this->getCate();
-
-        # 小刊列表
-        $where = array();
-        $where['cate_id'] = $cate['id'];
-        if (checkVersion()->journal_buy == 2) {
-            # 隐藏支付的小刊
-            //$where['buy'] = 2;
-        }
-        $data = Dever::db('journal/info')->getAll($where);
-        if ($data) {
-            foreach ($data as $k => $v) {
-                $data[$k] = $this->info($v);
-            }
-            $this->data['journal'] = $data;
-        } else {
-            $this->data['journal'] = array();
-        }
-
-        return $this->data;
-    }
-
-    # 根据分类获取小刊列表
-    public function getList()
-    {
-        $cate = $this->getCate();
-
-        $this->data['push'] = Dever::db('journal/info')->getOne($cate['journal_id']);
-
-        # 小刊列表
-        $where = array();
-        $where['cate_id'] = $cate['id'];
-        $data = Dever::db('journal/info')->getAllByPage($where);
-        if ($data) {
-            foreach ($data as $k => $v) {
-                $data[$k] = $this->info($v);
-            }
-            $this->data['journal'] = $data;
-        } else {
-            $this->data['journal'] = array();
-        }
-
-        return $this->data;
-    }
-
-    # 根据分类获取我已订阅的小刊列表
-    public function getMyList()
-    {
-        if (!$this->data['uid']) {
-            Dever::alert('错误的用户信息');
-        }
-
-        $cate = $this->getCate();
-
-        $this->data['push'] = Dever::db('journal/info')->getOne($cate['journal_id']);
-
-        # 获取我的信息
-        $this->data['user'] = Dever::load('passport/api')->info($this->data['uid']);
-        
-        # 我的小刊列表
-        $where = array();
-        $where['type'] = 4;
-        $where['source'] = '1,2,3,4';
-        $where['cate_id'] = $cate['id'];
-        $data = Dever::db('act/subscribe')->getMyAll($where);
-        if ($data) {
-            foreach ($data as $k => $v) {
-                $data[$k] = $this->info($v);
-            }
-            $this->data['journal'] = $data;
-        } else {
-            $this->data['journal'] = array();
-        }
-
-        return $this->data;
-    }
-
-    # 获取详细信息
-    private function info($data, $subscribe = true)
-    {
-        if ($data['pdate'] > 0) {
-            $data['pdate_time'] = date('Y-m-d H:i:s', $data['pdate']);
-        }
-
-        if ($data['pic_view_bg']) {
-            $data['pic_view_bg'] = explode(',', $data['pic_view_bg']);
-        } else {
-            $data['pic_view_bg'] = array();
-        }
-
-        $data['buy'] = intval($data['buy']);
-
-        # 获取订阅列表
-        if ($subscribe) {
-            $data['subscribe'] = Dever::load('act/lib/subscribe')->getList($data['id'], 4);
-
-            if (!$data['subscribe']) {
-                $data['subscribe'] = array();
-            }
-        }
-
-        return $data;
-    }
-
-    # 精选推荐更多
-    public function jingxuan($page = true, $num = 4)
-    {
-        if (!$page) {
-            $page = true;
-        }
-        if ($page === -1) {
-            $page = false;
-        }
-        if (!$num) {
-            $num = 4;
-        }
-        $this->data['push_jingxuan'] = Dever::load('push/lib/data')->get('jingxuan', '小刊精选推荐', 4, $page, $num);
-
-        $count = count($this->data['push_jingxuan']);
-
-        
-        if ($num == 5) {
-            if ($count < 4 || !$this->data['push_jingxuan']) {
-                $this->data['push_jingxuan'] = array();
-            }
-
-            $this->data['push_jingxuan_more'] = 2;
-            # 是否有更多按钮
-            if ($count > 4 && isset($this->data['push_jingxuan'][4])) {
-                unset($this->data['push_jingxuan'][4]);
-                $this->data['push_jingxuan_more'] = 1;
-            }
-        } else {
-            $page = Dever::pageInfo();
-            if ($page['status'] != 1) {
-                Dever::$global['page']['current']['next_page'] = 1;
-            }
-        }
-
-        return $this->data;
-    }
-
-    # 小刊查看详情
-    public function view()
-    {
-        $id = $this->check();
-        $this->data['info'] = $this->info($this->data['info'], false);
-        $this->button($this->data['info']);
-
-        if ($this->data['uid'] > 0) {
-            Dever::score($this->data['uid'], 'view_journal', '浏览小刊首页');
-        }
-
-        return $this->data;
-    }
-
-    # 按钮设置
-    private function button($info)
-    {
-        $this->data['button'] = array();
-        $this->setButton();
-
-        $uid = $this->data['uid'];
-
-        # 查看是否订阅
-        $subscribe = Dever::load('act/lib/subscribe')->get($info['id'], $uid, 4);
-        $this->data['info']['subscribe'] = 2;
-
-        # 查看是否有活动
-        $active = Dever::db('journal/active')->one(array('id' => $info['id']));
-        $this->data['info']['active'] = 2;
-        if ($active && $active['status'] == 1) {
-            $this->data['info']['active'] = 1;
-        }
-
-        if (isset($this->data['info']['share_content'])) {
-            $source = Dever::db('source/info')->one(1);
-            $this->data['info']['share_link'] = $source['code'];
-        }
-        
-        $time = time();
-        if ($active && $time >= $active['start'] && $time < $active['end']) {
-            $this->data['info']['active'] = 1;
-        }
-
-        if ($this->data['info']['active'] == 1) {
-            $this->setButton('share', 1);
-        } else {
-            $this->setButton('share', -1);
-        }
-
-        if ($info['buy'] == 2) {
-            # 免费的
-            $this->setButton('read', 1, '开始阅读');
-            $this->setButton('code', -1);
-            $this->setButton('share', -1);
-        } elseif ($subscribe == 1) {
-            $this->data['info']['subscribe'] = 1;
-            # 已订阅
-            $this->setButton('read', 1, '开始阅读');
-            $this->setButton('code', 2, '再次购买');
-
-            if (checkVersion()->journal_buy == 2) {
-                $this->setButton('code', 1, '兑换码阅读');
-                $this->setButton('share', -1);
-            }
-        } elseif ($info['buy'] == 1 || $info['buy'] == 3) {
-            # 需要购买
-            $this->setButton('read', 2, '购买阅读');
-            $this->setButton('code', 1, '兑换码阅读');
-
-            if (checkVersion()->journal_buy == 2) {
-                $this->setButton('read', -1);
-                $this->setButton('share', -1);
-            }
-        }
-
-        $applet_type = Dever::input('applet_type');
-        if ($applet_type == 2 && isset($this->data['config']['ios_pay']) && $this->data['config']['ios_pay'] == 1 && $info['buy'] == 1) {
-            # 关闭支付
-            if ($subscribe == 1) {
-                $this->data['info']['subscribe'] = 1;
-                $this->setButton('read', 1, '开始阅读');
-            } else {
-                $this->setButton('read', -1);
-            }
-            
-            $this->setButton('code', 1, '兑换码阅读');
-            //$this->setButton('share', -1);
-        }
-    }
-
-    private function setButton($key = false, $status = false, $name = false)
-    {
-        # 按钮状态,-1为不显示
-        if (!$this->data['button']) {
-            $this->data['button'] = array
-            (
-                # 第一个按钮
-                'read' => array('status' => -1, 'name' => '购买阅读'),
-                # 第二个按钮
-                'code' => array('status' => -1, 'name' => '兑换码阅读'),
-                # 第三个按钮 免费阅读赢取大礼包 改为
-                'share' => array('status' => 1, 'name' => '积分打榜赢奖品'),
-            );
-        }
-
-        if ($key && isset($this->data['button'][$key])) {
-            if ($status) {
-                $this->data['button'][$key]['status'] = $status;
-            }
-            if ($name) {
-                $this->data['button'][$key]['name'] = $name;
-            }
-        }
-    }
-
-    # 购买阅读页
-    public function buy()
-    {
-        if (!$this->data['uid']) {
-            Dever::alert('错误的用户信息');
-        }
-        $id = $this->check();
-
-        # 获取购买说明
-        $buy = Dever::db('journal/buy')->one(array('id' => $id));
-
-        $this->data['buy_desc'] = '';
-        if ($buy) {
-            $this->data['buy_desc'] = $buy['buy_content'];
-        }
-
-        if ($this->data['info']['buy'] == 2) {
-            $this->data['buy_list'] = array();
-            return $this->data;
-        }
-        # 获取购买列表
-        $this->data['buy_list'] = Dever::db('journal/buy_num')->getAll(array('info_id' => $id));
-
-        if ($this->data['info']['cash'] <= 0) {
-            $this->data['info']['cash'] = 100000;
-        }
-        if ($this->data['buy_list']) {
-            foreach ($this->data['buy_list'] as $k => $v) {
-                if (!$v['name']) {
-                    $this->data['buy_list'][$k]['name'] = '购买' . $v['num'] . '本';
-                }
-
-                $price = $v['num'] * $this->data['info']['cash'];
-                if (!$v['price']) {
-                    $this->data['buy_list'][$k]['price'] = $price;
-                }
-
-                $this->data['buy_list'][$k]['cash'] = $price;
-            }
-        }
-
-        return $this->data;
-    }
-
-    # 小刊邀请活动页
-    public function active()
-    {
-        $id = $this->check();
-
-        # 获取购买说明
-        $buy = Dever::db('journal/buy')->one(array('id' => $id));
-
-        # 获取活动说明
-        $this->data['active'] = Dever::db('journal/active')->one(array('id' => $id));
-
-
-        if (!$this->data['active']) {
-            $this->data['active'] = (object) array();
-            return $this->data;
-        }
-
-        $time = time();
-        if ($this->data['active'] && $time >= $this->data['active']['start'] && $time < $this->data['active']['end']) {
-            $this->data['active']['status'] = 1;
-        } else {
-            $this->data['active']['status'] = 2;
-        }
-
-        if ($time < $this->data['active']['start']) {
-            $this->data['active']['status'] = 3;
-        }
-
-        $this->data['active']['buy_title'] = '';
-        $this->data['active']['buy_desc'] = '';
-        if ($buy) {
-            $this->data['active']['buy_title'] = $buy['buy_title'];
-            $this->data['active']['buy_desc'] = $buy['buy_desc'];
-        }
-
-        # 获取我邀请的好友
-        if ($this->data['uid']) {
-            $this->data['invite'] = Dever::load('act/lib/invite')->getList($this->data['uid'], $id);
-        }
-
-        # 是否显示购买按钮 1显示 2不显示
-        $this->data['buy'] = 1;
-        if (checkVersion()->journal_buy == 2) {
-            $this->data['buy'] = 2;
-        }
-
-        return $this->data;
-    }
-
-    # 积分排行榜
-    public function score()
-    {
-        $id = $this->check();
-
-        $this->data['score'] = Dever::load('act/lib/score')->getList($id);
-
-        # 获取活动说明
-        $this->data['active'] = Dever::db('journal/active')->one(array('id' => $id));
-
-
-        if (!$this->data['active']) {
-            $this->data['active'] = (object) array();
-            return $this->data;
-        }
-
-        $time = time();
-        if ($this->data['active'] && $time >= $this->data['active']['start'] && $time < $this->data['active']['end']) {
-            $this->data['active']['status'] = 1;
-        } else {
-            $this->data['active']['status'] = 2;
-        }
-
-        if ($time < $this->data['active']['start']) {
-            $this->data['active']['status'] = 3;
-        }
-
-        return $this->data;
-    }
-
-    # 邀请好友排行榜
-    public function invite()
-    {
-        if (!$this->data['uid']) {
-            Dever::alert('错误的用户信息');
-        }
-
-        $id = $this->check();
-
-        $this->data['invite'] = Dever::load('act/lib/invite')->getList($this->data['uid'], $id);
-
-        return $this->data;
-    }
-
-
-    # 小刊阅读页
-    public function read()
-    {
-        if (!$this->data['uid']) {
-            Dever::alert('错误的用户信息');
-        }
-        # 验证是否可以阅读
-        $id = $this->check();
-        $this->data['info'] = $this->info($this->data['info'], false);
-
-        # 是否转码
-        //$this->data['info']['bgmusic'] = convert($this->data['info']['bgmusic'], 'mp3', 'journal/info', $this->data['info']['id'], 'bgmusic');
-
-        $subscribe = Dever::load('act/lib/subscribe')->get($id, $this->data['uid'], 4);
-
-        if ($this->data['info']['buy'] == 1 && $subscribe == 2) {
-            Dever::alert('未订阅');
-        }
-
-        if ($this->data['info']['buy'] == 2) {
-            Dever::load('act/lib/subscribe')->submit($this->data['uid'], $id, 4);
-        }
-
-        if ($this->data['uid'] > 0) {
-            Dever::score($this->data['uid'], 'read_journal', '阅读小刊');
-        }
-
-        # 获取最新10条内容
-        $where = array();
-        $where['info_id'] = $id;
-        $data = Dever::db('journal/content')->getAll($where);
-        if ($data) {
-            foreach ($data as $k => $v) {
-                $data[$k] = $this->readContent($v);
-            }
-            $this->data['content'] = $data;
-        } else {
-            $this->data['content'] = array();
-        }
-
-        # 浏览量+1
-        Dever::db('journal/info')->addView($id);
-
-        return $this->data;
-    }
-
-    public function readContent($info)
-    {
-        $name = $info['name'];
-        $focus = $info['focus'];
-        $author_id = $info['author_id'];
-        $content = $info['content'];
-        unset($info['name']);
-        unset($info['focus']);
-        unset($info['author_id']);
-        unset($info['content']);
-
-        if ($info['type'] == 1 && $info['text']) {
-            $info['text'] = Dever::array_decode($info['text']);
-            if ($info['text']) {
-                foreach ($info['text'] as $k => $v) {
-                    if (isset($info['text'][$k]['bgcolor_type']) && $info['text'][$k]['bgcolor_type'] == array(2)) {
-                        $info['text'][$k]['bgcolor'] = '';
-                    }
-                }
-            }
-            
-        } else {
-            unset($info['text']);
-        }
-
-        if ($info['type'] == 3) {
-            $info['info'] = array();
-            $info['info']['name'] = $name;
-            $info['info']['focus'] = $focus;
-            $info['info']['author_id'] = $author_id;
-            $info['info']['content'] = $content;
-            $info['info'] = Dever::load('content/lib/article')->getContent($info['info'], $this->data['uid']);
-        } elseif ($info['type'] == 4 || $info['type'] == 5) {
-            $info['video'] = convert($info['video'], 'mp4', 'journal/content', $info['id'], 'video');
-            if ($info['type'] == 5) {
-                $info['name'] = $name;
-            }
-        } elseif ($info['type'] == 6) {
-            $info['name'] = $name;
-            //音频先不转码
-            //$info['music'] = convert($info['music'], 'mp3', 'journal/content', $info['id'], 'music');
-        } elseif ($info['type'] == 11) {
-            $info['info'] = Dever::load('content/lib/article')->get($info['article_id']);
-        } elseif ($info['type'] == 12) {
-            $info['info'] = Dever::load('video/lib/vod')->get($info['vod_id']);
-        } elseif ($info['type'] == 13) {
-            $info['info'] = Dever::load('video/lib/live')->get($info['live_id']);
-
-            if ($this->data['uid'] > 0) {
-                $info['info']['note'] = Dever::load('act/lib/note')->get($this->data['uid'], $info['info']['id'], 3);
-                
-            } else {
-                $info['info']['note'] = 2;
-            }
-        }
-
-        if (isset($info['info']['author_id']) && $info['info']['author_id']) {
-            $info['info']['author'] = Dever::db('content/author')->one($info['info']['author_id']);
-        }
-
-        if (isset($info['pic']) && $info['pic']) {
-            $info['pic'] = str_replace('http://', 'https://', $info['pic']);
-        }
-
-        return $info;
-    }
-
-    private function check()
-    {
-        $id = Dever::input('id');
-        if (!$id) {
-            Dever::alert('小刊已下架');
-        }
-
-        $where['id'] = $id;
-        $this->data['info'] = Dever::db('journal/info')->one($where);
-
-        if (!$this->data['info']) {
-            Dever::alert('小刊已下架');
-        }
-
-        return $id;
-    }
-
-    # 购买
-    public function buy_action()
-    {
-        if (!$this->data['uid']) {
-            Dever::alert('错误的用户信息');
-        }
-        $source_uid = $this->getSourceUid(false);
-        $buy_id = Dever::input('buy_id');
-        $journal_id = Dever::input('journal_id');
-        $cate = $this->getCate();
-
-        if (!$buy_id) {
-            Dever::alert('请传入正确的支付ID');
-        }
-        if (!$journal_id) {
-            Dever::alert('请传入正确的小刊ID');
-        }
-
-        $info = Dever::db('journal/info')->one($journal_id);
-        $buy = Dever::db('journal/buy_num')->one($buy_id);
-
-        if (!$buy || !$info) {
-            Dever::alert('请传入正确的小刊ID');
-        }
-
-        if (!$buy['name']) {
-            $buy['name'] = '购买' . $buy['num'] . '本';
-        }
-
-        $user = Dever::db('passport/user')->one($this->data['uid']);
-        $wechat = Dever::db('passport/wechat')->one(array('uid' => $this->data['uid'], 'type' => 1, 'system_id' => $this->data['system']));
-
-        $source_type = Dever::input('source_type');
-
-        if ($source_type == 'ios') {
-            $method = 'apple';
-            $order_data['system'] = 3;
-            $account_id = 3;
-            # 使用苹果内购支付
-            $receipt = Dever::input('receipt');
-            if (!$receipt) {
-                Dever::alert('苹果内购支付失败,没有receipt参数');
-            }
-        } elseif ($source_type == 'android') {
-            $method = 'app';
-            $order_data['system'] = 4;
-            $account_id = 3;
-        } else {
-            $method = 'applet';
-            $order_data['system'] = 1;
-            $account_id = 1;
-            # 根据cate_id走不同的支付id,暂时不需要
-            if ($cate && $cate['id'] == 2) {
-                $account_id = 4;
-            } elseif ($cate && $cate['id'] == 2) {
-                $account_id = 5;
-            }
-            //$account_id = $cate['pay_id'];
-        }
-
-        $order_id = $this->createOrder('JP');
-        $order_data['cate_id'] = $cate['id'];
-        $order_data['order_id'] = $order_id;
-        $order_data['product_id'] = $journal_id;
-        $order_data['buy_id'] = $buy_id;
-        $order_data['uid'] = $this->data['uid'];
-        if ($source_uid > 0) {
-            $order_data['source_uid'] = $source_uid;
-        }
-        
-        $order_data['type'] = 1;
-        $order_data['status'] = 1;
-        $order_data['name'] = $info['name'] . '-' . $buy['name'];
-        //$order_data['num'] = Dever::input('num', 1);
-        $order_data['num'] = $buy['num'];
-        if (isset($buy['price']) && $buy['price'] && $buy['price'] > 0) {
-            $order_data['cash'] = $buy['price'];
-        } else {
-            $order_data['cash'] = $info['cash'] * $order_data['num'];
-        }
-
-        $source = Dever::input('source');
-        if ($source) {
-            $order_data['source'] = $source;
-        }
-        $seller = Dever::input('seller');
-        if ($seller) {
-            $order_data['seller_id'] = $seller;
-        }
-
-        $id = Dever::db('journal/order')->insert($order_data);
-
-        if (!$id) {
-            Dever::alert('支付失败');
-        }
-
-        //$param参数
-        $param = array
-        (
-            'account_id' => $account_id,
-            'project_id' => 1,
-            'uid' => $this->data['uid'],
-            'username' => $user['username'],
-            'name' => $order_data['name'],
-            'cash' => $order_data['cash'],
-            //'cash' => '0.01',
-            'openid' => $wechat['openid'],
-            'product_id' => $journal_id . '-' . $buy_id,
-            'order_id' => $order_id,
-        );
-
-        if ($method == 'apple') {
-            $param['other'] = $receipt;
-        }
-
-        $this->data['pay'] = Dever::load('pay/api.' . $method, $param);
-
-        if ($order_data['system'] == 1) {
-            if (isset($this->data['pay']['prepay_id'])) {
-                Dever::load('act/lib/form')->submit($this->data['uid'], $this->data['pay']['prepay_id'], 2, $this->data['system']);
-            } else {
-                Dever::alert('支付失败');
-            }
-        }
-
-        return $this->data;
-    }
-
-    # 根据code检索是否存在
-    public function checkCode()
-    {
-        if (!$this->data['uid']) {
-            Dever::alert('错误的用户信息');
-        }
-        $code = trim(Dever::input('code'));
-
-        if ($code) {
-
-            $info = Dever::db('code/info')->one(array('code' => $code));
-
-            if (!$info) {
-                Dever::alert('兑换码不存在');
-            }
-
-            if ($info['type'] == 3) {
-                Dever::alert('兑换码已被使用');
-            }
-
-            if ($info['type'] == 2 && $this->data['uid'] != $info['uid']) {
-                //Dever::alert('兑换码已被领取');
-            }
-
-            $order = Dever::db('journal/order')->one(array('code' => $code));
-
-            if ($order) {
-                Dever::alert('兑换码已被使用');
-            }
-
-            if ($info['product_id']) {
-                $product = Dever::db('journal/info')->one($info['product_id']);
-                $this->data['product'] = $product;
-
-                return $this->data;
-            }
-
-        } else {
-            Dever::alert('请输入正确的兑换码');
-        }
-
-        return true;
-    }
-
-    # 兑换
-    public function code()
-    {
-        if (!$this->data['uid']) {
-            Dever::alert('错误的用户信息');
-        }
-        $journal_id = Dever::input('journal_id', false, '> 0', '请传入正确的小刊id');
-
-        $code = Dever::input('code');
-
-        $source_uid = $this->getSourceUid(false);
-
-        if ($code) {
-
-            $code = trim($code);
-
-            $code = str_replace("\n", '', $code);
-
-            $product = Dever::db('journal/info')->one($journal_id);
-
-            $info = Dever::db('code/info')->one(array('product_id' => $journal_id, 'code' => $code));
-
-            if (!$info) {
-                Dever::alert('兑换码不存在');
-            }
-
-            if ($info['type'] == 3) {
-                Dever::alert('兑换码已被使用');
-            }
-
-            if ($info['type'] == 2 && $this->data['uid'] != $info['uid']) {
-                //Dever::alert('兑换码已被领取');
-            }
-
-            $order = Dever::db('journal/order')->one(array('product_id' => $journal_id, 'code' => $code, 'type' => 2, 'uid' => $this->data['uid']));
-
-            if ($order) {
-                Dever::alert('您已经使用过该兑换码');
-            }
-
-            Dever::db('code/info')->update(array('where_id' => $info['id'], 'type' => 3, 'uid' => $this->data['uid'], 'ldate' => time()));
-
-            $order_id = $this->createOrder('JC');
-
-            $order_data['order_id'] = $order_id;
-            $order_data['product_id'] = $journal_id;
-            $order_data['uid'] = $this->data['uid'];
-            $order_data['code'] = $code;
-            if ($source_uid > 0) {
-                $order_data['source_uid'] = $source_uid;
-            }
-            
-            $order_data['type'] = 2;
-            $order_data['status'] = 2;
-            $order_data['name'] = $product['name'];
-
-            $id = Dever::db('journal/order')->insert($order_data);
-
-            # 订阅
-            Dever::load('act/lib/subscribe')->submit($this->data['uid'], $journal_id, 2);
-
-            $score = false;
-            $num = false;
-            if (isset($info['product_num']) && $info['product_num'] > 0) {
-                if ($product && $product['dh_score'] > 0) {
-                    $score = $info['product_num'] * $product['dh_score'];
-                } elseif ($product) {
-                    $num = $info['product_num'];
-                }
-            }
-            # 增加积分
-            Dever::score($this->data['uid'], 'dh_journal', '兑换小刊', 'act/lib/score.submit?method=code&type=4&id=' . $journal_id, $score, $num);
-
-        } else {
-            Dever::alert('请输入正确的兑换码');
-        }
-
-        return array('order_id' => $order_id);
-    }
-
-    private function createOrder($prefix = 'JC')
-    {
-        $order = Dever::order($prefix);
-
-        //$order = Dever::rand(2, 2) . Dever::rand(6, 0);
-
-        $info = Dever::db('journal/order')->one(array('order_id' => $order));
-
-        if ($info) {
-            return $this->createOrder($prefix);
-        }
-
-        return $order;
-    }
-}

+ 2 - 2
push/database/info.php

@@ -14,7 +14,7 @@ $type = array
 
 //$define = Dever::config('base')->module;
 
-$function = array();
+$function = Dever::config('base')->type;
 $function[10] = '链接';
 
 $col = array
@@ -152,7 +152,7 @@ return array
         (
             'type'      => 'varchar-30',
             'name'      => '启用的功能',
-            'default'   => '1,2,3,4,6,7,10',
+            'default'   => '1',
             'desc'      => '启用的功能',
             'match'     => 'is_string',
             'option'    => $function,

+ 2 - 0
push/lib/Data.php

@@ -32,9 +32,11 @@ class Data
             $where['info_id'] = $info['id'];
 
             
+            /*
             if (checkVersion()->video == 2) {
                 $where['type_no'] = 2;
             }
+            */
 
             if ($page) {
                 $where['page'] = array($info['num'], 'list');