diff --git a/cache/.htaccess b/cache/.htaccess
new file mode 100644
index 0000000..34737c8
--- /dev/null
+++ b/cache/.htaccess
@@ -0,0 +1,9 @@
+
+ Require all denied
+
+
+ Deny from all
+
+
+ Deny from all
+
\ No newline at end of file
diff --git a/cache/Readme.txt b/cache/Readme.txt
new file mode 100644
index 0000000..4c28033
--- /dev/null
+++ b/cache/Readme.txt
@@ -0,0 +1,21 @@
+此目录属于迅睿框架缓存文件存储目录,需要设置可读写权限(777)
+设置自动清理无用缓存文件和更新缓存文件配置方法:http://help.xunruicms.com/353.html
+
+app 存储应用插件缓存数据及其配置信息(清空下面文件会导致部分插件配置失效)
+attach 存储附件信息缓存(可清空下面文件)
+authcode 认证时效性的缓存数据(可清空下面文件)
+backups 备份目录,升级备份、修改模板备份等(可清空下面文件)
+config 系统配置文件(重要数据不可删除,不可删除,不可删除)
+cloud 应用市场下载目录(可清空下面文件)
+data 系统配置缓存数据(可清空下面文件)
+database 保留未使用(数据库查询相关的缓存)
+debugbar 调试模式缓存数据(可清空下面文件)
+debuglog 调试变量记录文件(可清空下面文件)
+error 错误日志记录(可清空下面文件)
+file 文件缓存数据(可清空下面文件)
+log 操作日志记录(可清空下面文件)
+session session会话数据(可清空下面文件)
+temp 临时数据文件夹(可清空下面文件)
+template 模板缓存(可清空下面文件)
+thread 远程执行任务缓存(可清空下面文件)
+watermark 图片水印文件(不可删除,不可删除,不可删除)
\ No newline at end of file
diff --git a/cache/api.php b/cache/api.php
new file mode 100644
index 0000000..9970708
--- /dev/null
+++ b/cache/api.php
@@ -0,0 +1,10 @@
+
+ Require all denied
+
+
+ Deny from all
+
diff --git a/cache/attach/.htaccess b/cache/attach/.htaccess
new file mode 100644
index 0000000..3462048
--- /dev/null
+++ b/cache/attach/.htaccess
@@ -0,0 +1,6 @@
+
+ Require all denied
+
+
+ Deny from all
+
diff --git a/cache/authcode/.htaccess b/cache/authcode/.htaccess
new file mode 100644
index 0000000..3462048
--- /dev/null
+++ b/cache/authcode/.htaccess
@@ -0,0 +1,6 @@
+
+ Require all denied
+
+
+ Deny from all
+
diff --git a/cache/backups/.htaccess b/cache/backups/.htaccess
new file mode 100644
index 0000000..3462048
--- /dev/null
+++ b/cache/backups/.htaccess
@@ -0,0 +1,6 @@
+
+ Require all denied
+
+
+ Deny from all
+
diff --git a/cache/backups/db/.htaccess b/cache/backups/db/.htaccess
new file mode 100644
index 0000000..3462048
--- /dev/null
+++ b/cache/backups/db/.htaccess
@@ -0,0 +1,6 @@
+
+ Require all denied
+
+
+ Deny from all
+
diff --git a/cache/backups/db/index.html b/cache/backups/db/index.html
new file mode 100644
index 0000000..b702fbc
--- /dev/null
+++ b/cache/backups/db/index.html
@@ -0,0 +1,11 @@
+
+
+
+ Directory access is forbidden.
+
+
+
diff --git a/cache/backups/file/.htaccess b/cache/backups/file/.htaccess
new file mode 100644
index 0000000..3462048
--- /dev/null
+++ b/cache/backups/file/.htaccess
@@ -0,0 +1,6 @@
+Directory access is forbidden.
+
+
+
diff --git a/cache/backups/template/.htaccess b/cache/backups/template/.htaccess
new file mode 100644
index 0000000..3462048
--- /dev/null
+++ b/cache/backups/template/.htaccess
@@ -0,0 +1,6 @@
+Directory access is forbidden.
+
+
+
diff --git a/cache/backups/theme/.htaccess b/cache/backups/theme/.htaccess
new file mode 100644
index 0000000..3462048
--- /dev/null
+++ b/cache/backups/theme/.htaccess
@@ -0,0 +1,6 @@
+Directory access is forbidden.
+
+
+
diff --git a/cache/captcha.ttf b/cache/captcha.ttf
new file mode 100644
index 0000000..54a14ed
Binary files /dev/null and b/cache/captcha.ttf differ
diff --git a/cache/cloud/.htaccess b/cache/cloud/.htaccess
new file mode 100644
index 0000000..3462048
--- /dev/null
+++ b/cache/cloud/.htaccess
@@ -0,0 +1,6 @@
+Directory access is forbidden.
+
+
+
diff --git a/cache/log/.htaccess b/cache/log/.htaccess
new file mode 100644
index 0000000..3462048
--- /dev/null
+++ b/cache/log/.htaccess
@@ -0,0 +1,6 @@
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Block/Views/block_post.html b/dayrui/App/Block/Views/block_post.html
new file mode 100644
index 0000000..ae58963
--- /dev/null
+++ b/dayrui/App/Block/Views/block_post.html
@@ -0,0 +1,65 @@
+{template "header.html"}
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Block/Views/block_show.html b/dayrui/App/Block/Views/block_show.html
new file mode 100644
index 0000000..9b309a7
--- /dev/null
+++ b/dayrui/App/Block/Views/block_show.html
@@ -0,0 +1,59 @@
+{template "header.html"}
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Block/Views/config.html b/dayrui/App/Block/Views/config.html
new file mode 100644
index 0000000..22da05f
--- /dev/null
+++ b/dayrui/App/Block/Views/config.html
@@ -0,0 +1,21 @@
+{template "header.html"}
+
+
+ {$form}
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Action/Category.php b/dayrui/App/Cms/Action/Category.php
new file mode 100644
index 0000000..a91ca0e
--- /dev/null
+++ b/dayrui/App/Cms/Action/Category.php
@@ -0,0 +1,95 @@
+get('module-'.$system['site'].'-'.$dirname);
+if (!$module) {
+ return $this->_return($system['return'], "妯″潡({$dirname})灏氭湭瀹夎");
+} elseif (!$module['category']) {
+ return $this->_return($system['return'], "妯″潡({$dirname})娌℃湁鏍忕洰鏁版嵁");
+}
+
+$show = isset($param['show']) && $param['show'] ? 1 : 0; // 鏈塻how鍙傛暟琛ㄧず鏄剧ず闅愯棌鏍忕洰
+$return = [];
+
+if (isset($param['pid'])) {
+ $param['pid'] = explode(',', (string)$param['pid']);
+}
+if (isset($param['catid']) && $param['catid']) {
+ $param['id'] = $param['catid'];
+}
+if (isset($param['id']) && $param['id']) {
+ $arr = explode(',', $param['id']);
+ if ($arr) {
+ $new = [];
+ foreach ($arr as $t) {
+ if ($t && isset($module['category'][$t]) && $module['category'][$t]) {
+ $new[$t] = $module['category'][$t];
+ }
+ }
+ $module['category'] = $new;
+ }
+}
+
+if ($module['category']) {
+ foreach ($module['category'] as $t) {
+ if (!$t['show'] && !$show) {
+ continue;
+ } elseif (isset($param['pid']) && !dr_in_array($t['pid'], $param['pid'])) {
+ continue;
+ } elseif (isset($param['mid']) && $t['mid'] != $param['mid']) {
+ continue;
+ } elseif (isset($param['tid']) && $t['tid'] != (int)$param['tid']) {
+ continue;
+ } elseif (isset($param['child']) && $t['child'] != (int)$param['child']) {
+ continue;
+ } elseif (isset($system['more']) && !$system['more']) {
+ unset($t['field'], $t['setting']);
+ }
+ if ($t['tid'] == 2) {
+ // 澶栭摼鏍忕洰
+ } else {
+ $t['url'] = dr_url_rel(dr_url_prefix($t['url'], $module['mid'], $system['site'], $this->_is_mobile));
+ }
+ $return[] = $t;
+ }
+}
+
+// order
+if ($system['order']) {
+ $arr = explode(',', $system['order']);
+ foreach ($arr as $t) {
+ $a = explode('_', $t);
+ $b = strtolower(end($a));
+ if (in_array($b, ['desc', 'asc', 'instr'])) {
+ $a = str_replace('_'.$b, '', $t);
+ } else {
+ $a = $t;
+ $b = 'desc';
+ }
+ if ($b == 'instr') {
+
+ } else {
+ $return = dr_array_sort($return, $a, $b);
+ }
+ }
+}
+
+// num鍙傛暟
+if ($system['num']) {
+ if (is_numeric($system['num'])) {
+ $return = array_slice($return, 0, $system['num']);
+ } elseif (strpos($system['num'], ',') !== false) {
+ list($a, $b) = explode(',', $system['num']);
+ $return = array_slice($return, max(0, $a - 1), $b);
+ }
+}
+
+if (!$return) {
+ return $this->_return($system['return'], '娌℃湁鍖归厤鍒板唴瀹');
+}
+
+return $this->_return($system['return'], $return, '');
\ No newline at end of file
diff --git a/dayrui/App/Cms/Action/Category_search_field.php b/dayrui/App/Cms/Action/Category_search_field.php
new file mode 100644
index 0000000..8202cfe
--- /dev/null
+++ b/dayrui/App/Cms/Action/Category_search_field.php
@@ -0,0 +1,42 @@
+get('module-'.$system['site'].'-'.$dirname);
+if (!$module) {
+ return $this->_return($system['return'], '妯″潡('.$dirname.')鏈畨瑁');
+} elseif (!$catid) {
+ return $this->_return($system['return'], '娌℃湁catid鍊兼棤娉曟樉绀虹粨鏋');
+} elseif (!isset($module['category'][$catid])) {
+ return $this->_return($system['return'], '妯″潡('.$dirname.')鐨勬爮鐩紙'.$catid.'锛変笉瀛樺湪');
+} elseif (dr_count($module['category'][$catid]['field']) == 0) {
+ return $this->_return($system['return'], '妯″潡('.$dirname.')鐨勬爮鐩紙'.$catid.'锛夋病鏈夊垎閰嶆ā鍨嬪瓧娈');
+}
+
+$return = [];
+
+foreach ($module['category'][$catid]['field'] as $field) {
+ $t = $module['category_data_field'][$field];
+ if ($t) {
+ $data = dr_format_option_array($t['setting']['option']['options']);
+ if ($t['issearch'] && in_array($t['fieldtype'], ['Select', 'Selects', 'Radio', 'Checkbox']) && $data) {
+ $list = [];
+ foreach ($data as $value => $name) {
+ $name && !is_null($value) && $list[] = array(
+ 'name' => trim($name),
+ 'value' => trim($value)
+ );
+ }
+ $list && $return[] = array(
+ 'data' => $list,
+ 'name' => $t['name'],
+ 'field' => $t['fieldname'],
+ 'displayorder' => $t['displayorder'],
+ );
+ }
+ }
+}
+
+$system['order'] && $return = dr_array_sort($return, 'displayorder');
+
+return $this->_return($system['return'], $return, '');
\ No newline at end of file
diff --git a/dayrui/App/Cms/Action/Content.php b/dayrui/App/Cms/Action/Content.php
new file mode 100644
index 0000000..5704b89
--- /dev/null
+++ b/dayrui/App/Cms/Action/Content.php
@@ -0,0 +1,56 @@
+get('module-'.$system['site'].'-'.$dirname);
+if (!$module) {
+ return $this->_return($system['return'], "妯″潡({$dirname})鏈畨瑁");
+} elseif (!$param['id']) {
+ return $this->_return($system['return'], "妯″潡({$dirname})缂哄皯id鍙傛暟");
+}
+
+$tableinfo = \Phpcmf\Service::L('cache')->get('table-'.$system['site']);
+if (!$tableinfo) {
+ // 娌℃湁琛ㄧ粨鏋勭紦瀛樻椂杩斿洖绌
+ return $this->_return($system['return'], '琛ㄧ粨鏋勭紦瀛樹笉瀛樺湪');
+}
+
+$table = \Phpcmf\Service::M()->dbprefix(dr_module_table_prefix($module['dirname'], $system['site'])); // 妯″潡涓昏〃`
+if (!isset($tableinfo[$table])) {
+ return $this->_return($system['return'], '琛紙'.$table.'锛夌粨鏋勭紦瀛樹笉瀛樺湪');
+}
+
+// 鍒濆鍖栨暟鎹〃
+$db = \Phpcmf\Service::M('Content', $dirname);
+$db->_init($dirname, $system['site']);
+if ($module['category_data_field']) {
+ $system['more'] = 1;
+}
+$data = $db->get_data(intval($param['id']), 0, [], $system['more']);
+
+// 缂撳瓨鏌ヨ缁撴灉
+if (is_array($data) && $data) {
+ // 妯″潡琛ㄧ殑绯荤粺瀛楁
+ $fields = $module['field']; // 涓昏〃鐨勫瓧娈
+ if ($module['category_data_field']) {
+ $fields = dr_array2array($fields, $module['category_data_field']);
+ }
+ $fields['inputtime'] = array('fieldtype' => 'Date');
+ $fields['updatetime'] = array('fieldtype' => 'Date');
+ // 鏍煎紡鍖栨樉绀鸿嚜瀹氫箟瀛楁鍐呭
+ $dfield = \Phpcmf\Service::L('Field')->app($module['dirname']);
+ $data['url'] = dr_url_rel(dr_url_prefix($data['url'], $dirname, $system['site'], $this->_is_mobile));
+ $data = $dfield->format_value($fields, $data, 1);
+
+ // 瀛樺偍缂撳瓨
+ $system['cache'] && $this->_save_cache_data($cache_name, [
+ 'data' => [$data],
+ 'sql' => '',
+ 'total' => 0,
+ 'pages' => 0,
+ 'pagesize' => 0,
+ 'page_used' => $this->_page_used,
+ 'page_urlrule' => $this->_page_urlrule,
+ ], $system['cache']);
+
+}
+return $this->_return($system['return'], [$data]);
\ No newline at end of file
diff --git a/dayrui/App/Cms/Action/Module.php b/dayrui/App/Cms/Action/Module.php
new file mode 100644
index 0000000..4acb837
--- /dev/null
+++ b/dayrui/App/Cms/Action/Module.php
@@ -0,0 +1,316 @@
+_return($system['return'], '妯″潡鍙傛暟module鏈~鍐');
+ return;
+}
+
+$module = \Phpcmf\Service::L('cache')->get('module-'.$system['site'].'-'.$dirname);
+if (!$module) {
+ if (strpos($system['module'], ',') || $system['module'] == 'all') {
+ require 'Modules.php';
+ return;
+ }
+ $return_data = $this->_return($system['return'], '妯″潡('.$dirname.')鏈畨瑁');
+ return;
+}
+
+$tableinfo = \Phpcmf\Service::L('cache')->get('table-'.$system['site']);
+
+// 娌℃湁琛ㄧ粨鏋勭紦瀛樻椂杩斿洖绌
+if (!$tableinfo) {
+ $return_data = $this->_return($system['return'], '琛ㄧ粨鏋勭紦瀛樹笉瀛樺湪');
+ return;
+}
+
+$table = \Phpcmf\Service::M()->dbprefix(dr_module_table_prefix($module['dirname'], $system['site'])); // 妯″潡涓昏〃`
+if (!isset($tableinfo[$table])) {
+ $return_data = $this->_return($system['return'], '琛紙'.$table.'锛夌粨鏋勭紦瀛樹笉瀛樺湪');
+ return;
+}
+
+// 鍔犱笂鐘舵佸垽鏂
+//$where[] = ['adj' => '', 'name' => 'status', 'value' => 9];
+
+// 鏄惁鎿嶄綔鑷畾涔墂here
+if ($param['where']) {
+ $where[] = [
+ 'adj' => 'SQL',
+ 'value' => urldecode($param['where'])
+ ];
+ unset($param['where']);
+}
+
+$fields = $module['field']; // 涓昏〃鐨勫瓧娈
+
+// 鎺掑簭鎿嶄綔
+if (!$system['order'] && isset($where['id']) && $where['id']['adj'] == 'IN' && $where['id']['value']) {
+ // 鎸塱d搴忓垪鏉ユ帓搴
+ $system['order'] = strlen($where['id']['value']) < 10000 && $where['id']['value'] ? 'FIELD(`'.$table.'`.`id`, '.$where['id']['value'].')' : 'NULL';
+} else {
+ // 榛樿鎺掑簭鍙傛暟
+ !$system['order'] && ($system['order'] = $system['flag'] ? 'updatetime_desc' : ($action == 'hits' ? 'hits' : 'updatetime'));
+}
+
+// 鏍忕洰绛涢
+if ($system['catid']) {
+ $fwhere = [];
+ if (strpos($system['catid'], ',') !== FALSE) {
+ $temp = explode(',', $system['catid']);
+ if ($temp) {
+ $catids = [];
+ foreach ($temp as $i) {
+ $catids = $module['category'][$i]['child'] ? array_merge($catids, $module['category'][$i]['catids']) : array_merge($catids, array($i));
+ }
+ $catids && $fwhere[] = '`'.$table.'`.`catid` IN ('.implode(',', $catids).')';
+ }
+ unset($temp);
+ } elseif ($module['category'][$system['catid']]['child']) {
+ $catids = explode(',', $module['category'][$system['catid']]['childids']);
+ $fwhere[] = '`'.$table.'`.`catid` IN ('.$module['category'][$system['catid']]['childids'].')';
+ } else {
+ $fwhere[] = '`'.$table.'`.`catid` = '.(int)$system['catid'];
+ $catids = [$system['catid']];
+ }
+
+ // 鍓爮鐩垽鏂
+ if (isset($fields['catids']) && $fields['catids']['fieldtype'] = 'Catids') {
+ foreach ($catids as $c) {
+ $fwhere[] = \Phpcmf\Service::M()->where_json($table, 'catids', intval($c));
+ }
+ }
+ $fwhere && $where[] = [
+ 'adj' => 'SQL',
+ 'value' => urldecode(count($fwhere) == 1 ? $fwhere[0] : '('.implode(' OR ', $fwhere).')')
+ ];
+ unset($fwhere);
+ unset($catids);
+}
+
+// 鏌ユ壘mwhere鐩綍
+$mwhere = \Phpcmf\Service::Mwhere_Apps();
+if ($mwhere) {
+ $mid = $dirname;
+ $field = $tableinfo[$table];
+ $siteid = $system['site'];
+ foreach ($mwhere as $mapp) {
+ $w = require dr_get_app_dir($mapp).'Config/Mwhere.php';
+ if ($w) {
+ $where[] = ['adj' => 'sql', 'value' => $w];
+ }
+ }
+}
+
+
+// groupid鏌ヨ
+if (isset($param['groupid']) && $param['groupid']) {
+
+ if (strpos($param['groupid'], ',') !== false) {
+ $gwhere = ' `'.$table.'`.`uid` in (select uid from `'.\Phpcmf\Service::M()->dbprefix('member').'_group_index` where `gid` in ('.dr_safe_replace($param['groupid']).'))';
+ } elseif (strpos($param['groupid'], '-') !== false) {
+ $arr = explode('-', $param['groupid']);
+ $gwhere = [];
+ foreach ($arr as $t) {
+ $t = intval($t);
+ $t && $gwhere[] = ' `'.$table.'`.`uid` in (select uid from `'.\Phpcmf\Service::M()->dbprefix('member').'_group_index` where `gid` = '. $t.')';
+ }
+ $gwhere = $gwhere ? '('.implode(' AND ', $gwhere).')' : '';
+ } else {
+ $gwhere = ' `'.$table.'`.`uid` in (select uid from `'.\Phpcmf\Service::M()->dbprefix('member').'_group_index` where `gid` = '. intval($param['groupid']).')';
+ }
+ $gwhere && $where['id'] = [
+ 'adj' => 'SQL',
+ 'name' => 'id',
+ 'value' => $gwhere
+ ];
+ unset($param['groupid']);
+}
+
+$where = $this->_set_where_field_prefix($where, $tableinfo[$table], $table, $fields); // 缁欐潯浠跺瓧娈靛姞涓婅〃鍓嶇紑
+$system['field'] = $this->_set_select_field_prefix($system['field'], $tableinfo[$table], $table); // 缁欐樉绀哄瓧娈靛姞涓婅〃鍓嶇紑
+
+// 澶氳〃缁勫悎鎺掑簭
+$_order = [];
+$_order[$table] = $tableinfo[$table];
+
+// sql鐨刦rom瀛愬彞
+if ($action == 'hits') {
+ $sql_from = '`'.$table.'` LEFT JOIN `'.$table.'_hits` ON `'.$table.'`.`id`=`'.$table.'_hits`.`id`';
+ $table_more = $table.'_hits'; // hits琛
+ $system['field'] = $this->_set_select_field_prefix($system['field'], $tableinfo[$table_more], $table_more); // 缁欐樉绀哄瓧娈靛姞涓婅〃鍓嶇紑
+ $_order[$table_more] = $tableinfo[$table_more];
+ if (!$system['field']) {
+ $system['field'] = '`'.$table.'`.*';
+ $fields_more = \Phpcmf\Service::M()->db->getFieldNames($table_more);
+ if ($fields_more) {
+ foreach ($fields_more as $f) {
+ if (!in_array($f, ['id', 'catid', 'uid'])) {
+ $system['field'].= ',`'.$table_more.'`.`'.$f.'`';
+ }
+ }
+ }
+ }
+} else {
+ $sql_from = '`'.$table.'`';
+}
+
+// 鍏宠仈鏍忕洰妯″瀷琛
+if ($system['more']) {
+ $table_more = $table.'_category_data'; // 鏍忕洰妯″瀷琛
+ if (isset($module['category_data_field']) && $module['category_data_field']) {
+ $fields = array_merge($fields, $module['category_data_field']);
+ $where = $this->_set_where_field_prefix($where, $tableinfo[$table_more], $table_more, $fields); // 缁欐潯浠跺瓧娈靛姞涓婅〃鍓嶇紑
+ $system['field'] = $this->_set_select_field_prefix($system['field'], $tableinfo[$table_more], $table_more); // 缁欐樉绀哄瓧娈靛姞涓婅〃鍓嶇紑
+ $_order[$table_more] = $tableinfo[$table_more];
+ }
+ $sql_from.= " LEFT JOIN $table_more ON `$table_more`.`id`=`$table`.`id`"; // sql鐨刦rom瀛愬彞
+ if (!$system['field']) {
+ $system['field'] = '`'.$table.'`.*';
+ $fields_more = \Phpcmf\Service::M()->db->getFieldNames($table_more);
+ if ($fields_more) {
+ foreach ($fields_more as $f) {
+ if (!in_array($f, ['id', 'catid', 'uid'])) {
+ $system['field'].= ',`'.$table_more.'`.`'.$f.'`';
+ }
+ }
+ }
+ }
+}
+
+// 鍏宠仈琛
+if ($system['join'] && $system['on']) {
+ $rt = $this->_join_table($table, $system, $where, $_order, $sql_from);
+ if (!$rt['code']) {
+ $return_data = $this->_return($system['return'], $rt['msg']);
+ return;
+ }
+ list($system, $where, $_order, $sql_from) = $rt['data'];
+}
+
+$sql_limit = $pages = '';
+$sql_where = $this->_get_where($where); // sql鐨剋here瀛愬彞
+
+// 鍟嗗搧鏈夋晥鏈
+// isset($fields['order_etime']) && ($system['oot'] ? $sql_where.= ' AND `order_etime` BETWEEN 1 AND '.SYS_TIME : $sql_where.= ' AND NOT (`order_etime` BETWEEN 1 AND '.SYS_TIME.')');
+
+// 鎺ㄨ崘浣嶈皟鐢
+if ($system['flag']) {
+ if ($system['show_flag']) {
+ $sql_from.= ' LEFT JOIN `'.$table.'_flag'.'` ON `'.$table.'`.`id`=`'.$table.'_flag`.`id`';
+ $sql_where = ($sql_where ? $sql_where.' AND' : '').' `'.$table.'_flag`.'.(strpos($system['flag'], ',') ? '`flag` IN ('.$this->_get_where_in($system['flag']).')' : '`flag`='.(int)$system['flag']);
+ } else {
+ $flag = "select `id` from `{$table}_flag` where ".(strpos($system['flag'], ',') ? '`flag` IN ('.$this->_get_where_in($system['flag']).')' : '`flag`='.(int)$system['flag']);
+ $sql_where = ($sql_where ? $sql_where.' AND' : '')." `$table`.`id` IN (".$flag.")";
+ unset($flag);
+ }
+}
+// 鎺掗櫎鎺ㄨ崘浣
+if ($system['not_flag']) {
+ $flag = "select `id` from `{$table}_flag` where ".(strpos($system['not_flag'], ',') ? '`flag` IN ('.$this->_get_where_in($system['not_flag']).')' : '`flag`='.(int)$system['not_flag']);
+ $sql_where = ($sql_where ? $sql_where.' AND' : '')." `$table`.`id` NOT IN (".$flag.")";
+ unset($flag);
+}
+
+// 缁熻鏍囩
+if ($this->_return_sql) {
+ $sql = "SELECT ".$this->_select_rt_name." FROM $sql_from ".($sql_where ? "WHERE $sql_where" : "")." ORDER BY NULL";
+} else {
+ $first_url = $system['firsturl'];
+ if ($system['page']) {
+ $page = $this->_get_page_id($system['page']);
+ if ($system['catid'] && is_numeric($system['catid'])) {
+ if (!$system['sbpage']) {
+ if ($system['pagesize']) {
+ $this->_list_error[] = '瀛樺湪catid鍙傛暟鍜宲age鍙傛暟鏃讹紝pagesize鍙傛暟灏嗕細鏃犳晥';
+ }
+ if ($system['urlrule']) {
+ $this->_list_error[] = '瀛樺湪catid鍙傛暟鍜宲age鍙傛暟鏃讹紝urlrule鍙傛暟灏嗕細鏃犳晥';
+ }
+ if ($this->_is_mobile) {
+ $system['pagesize'] = (int)$module['category'][$system['catid']]['setting']['template']['mpagesize'];
+ } else {
+ $system['pagesize'] = (int)$module['category'][$system['catid']]['setting']['template']['pagesize'];
+ }
+ // 闃叉鏍忕洰鐢熸垚绗竴椤甸棶棰
+ if ($system['action'] == 'module') {
+ $first_url = \Phpcmf\Service::L('router')->category_url($module, $module['category'][$system['catid']]);
+ if (!$this->_is_pc || SITE_ID > 1) {
+ $first_url = dr_url_prefix($first_url, $module['dirname']);
+ }
+ }
+ $system['urlrule'] = \Phpcmf\Service::L('router')->category_url($module, $module['category'][$system['catid']], '{page}');
+ if (!$this->_is_pc || SITE_ID > 1) {
+ $system['urlrule'] = dr_url_prefix($system['urlrule'], $module['dirname']);
+ }
+ }
+ }
+ if ($system['num']) {
+ $this->_list_error[] = '瀛樺湪page鍙傛暟鏃讹紝num鍙傛暟灏嗕細鏃犳晥';
+ }
+ $pagesize = (int)$system['pagesize'];
+ !$pagesize && $pagesize = 10;
+ // 鏁版嵁閲
+ $sql = "SELECT count(*) as c FROM $sql_from " . ($sql_where ? "WHERE $sql_where" : "") . " ORDER BY NULL";
+ $row = $this->_query($sql, $system, FALSE);
+ $total = (int)$row['c'];
+ if ($system['maxlimit'] && $total > $system['maxlimit']) {
+ $total = $system['maxlimit']; // 鏈澶ч檺鍒
+ if ($page * $pagesize > $total) {
+ $return_data = $this->_return($system['return'], 'maxlimit璁剧疆鏈澶ф樉绀'.$system['maxlimit'].'鏉★紝褰撳墠锛'.$total.'锛夊凡瓒呭嚭', $sql, 0);
+ return;
+ }
+ }
+ // 娌℃湁鏁版嵁鏃惰繑鍥炵┖
+ if (!$total) {
+ $return_data = $this->_return($system['return'], '娌℃湁鏌ヨ鍒板唴瀹', $sql, 0);
+ return;
+ }
+ $system['firsturl'] = $first_url;
+ $pages = $this->_new_pagination($system, $pagesize, $total);
+ $sql_limit = 'LIMIT ' . intval($pagesize * ($page - 1)) . ',' . $pagesize;
+ } elseif ($system['num']) {
+ $pages = '';
+ $sql_limit = "LIMIT {$system['num']}";
+ }
+
+ $system['order'] = $this->_set_orders_field_prefix($system['order'], $_order); // 缁欐帓搴忓瓧娈靛姞涓婅〃鍓嶇紑
+ $sql = "SELECT " .$this->_get_select_field($system['field'] ? $system['field'] : '*') . " FROM $sql_from " . ($sql_where ? "WHERE $sql_where" : "") . ($system['order'] == "null" || !$system['order'] ? "" : " ORDER BY {$system['order']}") . " $sql_limit";
+}
+
+$data = $this->_query($sql, $system);
+
+// 缂撳瓨鏌ヨ缁撴灉
+if (is_array($data) && $data) {
+ // 妯″潡琛ㄧ殑绯荤粺瀛楁
+ $fields['inputtime'] = ['fieldtype' => 'Date'];
+ $fields['updatetime'] = ['fieldtype' => 'Date'];
+ // 鏍煎紡鍖栨樉绀鸿嚜瀹氫箟瀛楁鍐呭
+ $dfield = \Phpcmf\Service::L('Field')->app($module['dirname']);
+ foreach ($data as $i => $t) {
+ $t['url'] = dr_url_rel(dr_url_prefix($t['url'], $dirname, $system['site'], $this->_is_mobile));
+ $data[$i] = $dfield->format_value($fields, $t, 1);
+ }
+}
+
+// 瀛樺偍缂撳瓨
+$system['cache'] && $this->_save_cache_data($cache_name, [
+ 'data' => $data,
+ 'sql' => $sql,
+ 'total' => $total,
+ 'pages' => $pages,
+ 'pagesize' => $pagesize,
+ 'page_used' => $this->_page_used,
+ 'page_urlrule' => $this->_page_urlrule,
+], $system['cache']);
+
+$return_data = $this->_return($system['return'], $data, $sql, $total, $pages, $pagesize);
\ No newline at end of file
diff --git a/dayrui/App/Cms/Action/Modules.php b/dayrui/App/Cms/Action/Modules.php
new file mode 100644
index 0000000..59be852
--- /dev/null
+++ b/dayrui/App/Cms/Action/Modules.php
@@ -0,0 +1,191 @@
+get('module-'.$system['site'].'-content');
+if (!$modules) {
+ return $return_data = $this->_return($system['return'], '绔欑偣('.$system['site'].')娌℃湁瀹夎鍐呭妯″潡');
+}
+
+if ($system['module'] == 'all') {
+ $system['module'] = '';
+ foreach ($modules as $t) {
+ $system['module'].= $t['dirname'].',';
+ $module_all[] = $t['dirname'];
+ }
+ $system['module'] = trim($system['module'], ',');
+} else {
+ $module_all = explode(',', $system['module']);
+ if (dr_count($module_all) == 1) {
+ $rt = require 'Module.php';
+ return $rt;
+ }
+}
+
+if ($this->_return_sql) {
+ $system['field'].= ',id,'.$system['sum'];
+}
+
+if (!$system['field']) {
+ return $return_data = $this->_return($system['return'], '蹇呴』浼犲叆field鍙傛暟鏉ユ寚瀹氭樉绀哄瓧娈');
+}
+
+if ($system['more']) {
+ $this->_list_error[] = '澶氭ā鍧楁煡璇㈡椂more鍙傛暟灏嗕細鏃犳晥';
+}
+
+if ($system['join']) {
+ $this->_list_error[] = '澶氭ā鍧楁煡璇㈡椂join鍙傛暟灏嗕細鏃犳晥';
+}
+
+$system['field'] = trim($system['field'], ',');
+$field = explode(',', $system['field']);
+
+// 鏄惁鎿嶄綔鑷畾涔墂here
+if ($param['where']) {
+ $where[] = [
+ 'adj' => 'SQL',
+ 'value' => urldecode($param['where'])
+ ];
+ unset($param['where']);
+}
+
+$form = [];
+
+// 楠岃瘉妯″潡鐨勬湁鏁堟
+foreach ($module_all as $m) {
+ if (!isset($modules[$m])) {
+ return $return_data = $this->_return($system['return'], '绔欑偣('.$system['site'].')娌℃湁瀹夎鍐呭妯″潡('.$m.')');
+ }
+ $table = \Phpcmf\Service::M()->dbprefix($system['site'].'_'.$m);
+ $mfield = \Phpcmf\Service::M()->db->getFieldNames($table);
+ $infield = array_diff($field, $mfield);
+ if ($infield) {
+ return $return_data = $this->_return($system['return'], '绔欑偣('.$system['site'].')鐨勫唴瀹规ā鍧('.$m.')涓嶅瓨鍦ㄧ殑瀛楁锛'.implode(',', $infield));
+ }
+ $mywhere = [
+ // '`status` = 9',
+ ];
+ // 鎺ㄨ崘浣嶈皟鐢
+ if ($system['flag']) {
+ $mywhere[] = "`$table`.`id` IN (".("select `id` from `{$table}_flag` where ".(strpos($system['flag'], ',') ? '`flag` IN ('.$this->_get_where_in($system['flag']).')' : '`flag`='.(int)$system['flag'])).")";
+ }
+ // 鎺掗櫎鎺ㄨ崘浣
+ if ($system['not_flag']) {
+ $mywhere[] = "`$table`.`id` NOT IN (".("select `id` from `{$table}_flag` where ".(strpos($system['not_flag'], ',') ? '`flag` IN ('.$this->_get_where_in($system['not_flag']).')' : '`flag`='.(int)$system['not_flag'])).")";
+ }
+ $module = \Phpcmf\Service::L('cache')->get('module-'.$system['site'].'-'.$m);
+ $fields = $module['field'];
+ // 鏍忕洰绛涢
+ if ($system['catid']) {
+ $fwhere = [];
+ if (strpos($system['catid'], ',') !== FALSE) {
+ $temp = explode(',', $system['catid']);
+ if ($temp) {
+ $catids = [];
+ foreach ($temp as $i) {
+ $cat = dr_cat_value($system['site'], $module['mid'], $i);
+ $catids = $cat['child'] ? array_merge($catids, $cat['catids']) : array_merge($catids, array($i));
+ }
+ $catids && $fwhere[] = '`'.$table.'`.`catid` IN ('.implode(',', $catids).')';
+ }
+ unset($temp);
+ } else {
+ $cat = dr_cat_value($system['site'], $module['mid'], $system['catid']);
+ if ($cat['child']) {
+ $catids = explode(',', $cat['childids']);
+ $fwhere[] = '`'.$table.'`.`catid` IN ('.$cat['childids'].')';
+ } else {
+ $fwhere[] = '`'.$table.'`.`catid` = '.(int)$system['catid'];
+ $catids = [$system['catid']];
+ }
+ }
+
+ // 鍓爮鐩垽鏂
+ if (isset($fields['catids']) && $fields['catids']['fieldtype'] = 'Catids') {
+ foreach ($catids as $c) {
+ $fwhere[] = \Phpcmf\Service::M()->where_json($table, 'catids', intval($c));
+ }
+ }
+ if ($fwhere) {
+ $mywhere[] = ''.(count($fwhere) == 1 ? $fwhere[0] : '('.implode(' OR ', $fwhere).')');
+ }
+ unset($fwhere);
+ unset($catids);
+ }
+ if ($mywhere) {
+ $form[] = 'SELECT '.$system['field'].',\''.$m.'\' AS mid FROM `'.$table.'` WHERE '.implode(' AND ', $mywhere);
+ } else {
+ $form[] = 'SELECT '.$system['field'].',\''.$m.'\' AS mid FROM `'.$table.'`';
+ }
+
+}
+
+$sql_limit = $pages = '';
+$where = $this->_set_where_field_prefix($where, $field, 'my', $fields); // 缁欐潯浠跺瓧娈靛姞涓婅〃鍓嶇紑
+$sql_where = $this->_get_where($where); // sql鐨剋here瀛愬彞
+
+
+$sql_from = '('. implode(' UNION ALL ', $form).') as my';
+
+// 缁熻鏍囩
+if ($this->_return_sql) {
+ $sql = "SELECT ".$this->_select_rt_name." FROM $sql_from ".($sql_where ? "WHERE $sql_where" : "")." ORDER BY NULL";
+} else {
+ if ($system['page']) {
+ $page = $this->_get_page_id($system['page']);
+ $pagesize = (int)$system['pagesize'];
+ !$pagesize && $pagesize = 10;
+ // 缁熻鏁伴噺
+ $sql = "SELECT count(*) as c FROM $sql_from " . ($sql_where ? "WHERE $sql_where" : "") . " ORDER BY NULL";
+ $row = $this->_query($sql, $system, FALSE);
+ $total = (int)$row['c'];
+ if ($system['maxlimit'] && $total > $system['maxlimit']) {
+ $total = $system['maxlimit']; // 鏈澶ч檺鍒
+ if ($page * $pagesize > $total) {
+ $return_data = $this->_return($system['return'], 'maxlimit璁剧疆鏈澶ф樉绀'.$system['maxlimit'].'鏉★紝褰撳墠锛'.$total.'锛夊凡瓒呭嚭', $sql, 0);
+ return;
+ }
+ }
+ // 娌℃湁鏁版嵁鏃惰繑鍥炵┖
+ if (!$total) {
+ return $return_data = $this->_return($system['return'], '娌℃湁鏌ヨ鍒板唴瀹', $sql, 0);
+ }
+ // 璁$畻鍒嗛〉鏍囩
+ $pages = $this->_new_pagination($system, $pagesize, $total);
+ $sql_limit = 'LIMIT ' . intval($pagesize * ($page - 1)) . ',' . $pagesize;
+ } elseif ($system['num']) {
+ $pages = '';
+ $sql_limit = "LIMIT {$system['num']}";
+ }
+
+ $system['order'] = $this->_set_order_field_prefix($system['order'], $field, 'my'); // 缁欐帓搴忓瓧娈靛姞涓婅〃鍓嶇紑
+ $sql = "SELECT " .$system['field'] . ",mid FROM $sql_from " . ($sql_where ? "WHERE $sql_where" : "") . ($system['order'] == "null" || !$system['order'] ? "" : " ORDER BY {$system['order']}") . " $sql_limit";
+}
+
+$data = $this->_query($sql, $system);
+
+// 缂撳瓨鏌ヨ缁撴灉
+if (is_array($data) && $data) {
+ // 妯″潡琛ㄧ殑绯荤粺瀛楁
+ $fields['inputtime'] = ['fieldtype' => 'Date'];
+ $fields['updatetime'] = ['fieldtype' => 'Date'];
+ // 鏍煎紡鍖栨樉绀鸿嚜瀹氫箟瀛楁鍐呭
+ $dfield = \Phpcmf\Service::L('Field')->app($m);
+ foreach ($data as $i => $t) {
+ $t['url'] = dr_url_rel(dr_url_prefix($t['url'], $t['mid'], $system['site'], $this->_is_mobile));
+ $data[$i] = $dfield->format_value($fields, $t, 1);
+ }
+}
+
+// 瀛樺偍缂撳瓨
+$system['cache'] && $this->_save_cache_data($cache_name, [
+ 'data' => $data,
+ 'sql' => $sql,
+ 'total' => $total,
+ 'pages' => $pages,
+ 'pagesize' => $pagesize,
+ 'page_used' => $this->_page_used,
+ 'page_urlrule' => $this->_page_urlrule,
+], $system['cache']);
+
+$return_data = $this->_return($system['return'], $data, $sql, $total, $pages, $pagesize);
\ No newline at end of file
diff --git a/dayrui/App/Cms/Action/Related.php b/dayrui/App/Cms/Action/Related.php
new file mode 100644
index 0000000..fb780d4
--- /dev/null
+++ b/dayrui/App/Cms/Action/Related.php
@@ -0,0 +1,41 @@
+_return($system['return'], '娌℃湁浼犲叆tag鍙傛暟鐨勫唴瀹'); // 娌℃湁鏌ヨ鍒板唴瀹
+ return;
+}
+
+$sql = [];
+$array = explode(',', urldecode($param['tag']));
+$tfield = 'keywords';
+if (isset($param['tfield']) && $param['tfield']) {
+ $tfield = $param['tfield'];
+ unset($param['tfield']);
+}
+foreach ($array as $name) {
+ $name && $sql[] = '(`title` LIKE "%'.dr_safe_replace($name).'%" OR `'.$tfield.'` LIKE "%'.dr_safe_replace($name).'%")';
+}
+$sql && $where[] = [
+ 'adj' => 'SQL',
+ 'value' => '('.implode(' OR ', $sql).')'
+];
+unset($param['tag']);
+if (isset($where['tag'])) {
+ unset($where['tag']);
+}
+if (method_exists($this, 'add_load_tips')) {
+ $this->add_load_tips('', 'Related鏍囩閫傜敤浜庝竴涓囨潯鏁版嵁浠ュ唴鐨勫皬鏁版嵁閲忓叧鑱旀煡璇');
+}
+// 璺宠浆鍒癿odule鏂规硶
+if (strpos($system['module'], ',') || $system['module'] == 'all') {
+ if (!$system['field']) {
+ $system['field'] = 'id,title,url,'.$tfield;
+ } elseif (strpos($system['field'], $tfield) === false) {
+ $system['field'] = trim($system['field'], ',');
+ $system['field'].= ','.$tfield;
+ }
+ require 'Modules.php';
+} else {
+ require 'Module.php';
+}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Action/Search.php b/dayrui/App/Cms/Action/Search.php
new file mode 100644
index 0000000..df34844
--- /dev/null
+++ b/dayrui/App/Cms/Action/Search.php
@@ -0,0 +1,145 @@
+_is_list_search = 1;
+
+$total = (int)$system['total'];
+unset($system['total']);
+
+// 娌℃湁鏁版嵁鏃惰繑鍥炵┖
+if (!$total) {
+ return $this->_return($system['return'], 'total鍙傛暟涓虹┖', '', 0);
+} elseif (!$dirname) {
+ return $this->_return($system['return'], 'module鍙傛暟涓嶈兘涓虹┖');
+} elseif (!$param['id']) {
+ return $this->_return($system['return'], 'id鍙傛暟涓虹┖', '', 0);
+}
+
+$module = \Phpcmf\Service::L('cache')->get('module-'.$system['site'].'-'.$dirname);
+if (!$module) {
+ return $this->_return($system['return'], '妯″潡('.$dirname.')鏈畨瑁');
+}
+
+$tableinfo = \Phpcmf\Service::L('cache')->get('table-'.$system['site']);
+// 娌℃湁琛ㄧ粨鏋勭紦瀛樻椂杩斿洖绌
+if (!$tableinfo) {
+ return $this->_return($system['return'], '琛ㄧ粨鏋勭紦瀛樹笉瀛樺湪');
+}
+
+$table = \Phpcmf\Service::M()->dbprefix(dr_module_table_prefix($module['dirname'], $system['site'])); // 妯″潡涓昏〃`
+if (!isset($tableinfo[$table])) {
+ return $this->_return($system['return'], '琛紙'.$table.'锛夌粨鏋勭紦瀛樹笉瀛樺湪');
+}
+
+if ($where) {
+ foreach ($where as $i => $t) {
+ if ($t['name'] == 'id') {
+ unset($where[$i]);
+ }
+ }
+}
+
+$index = \Phpcmf\Service::L('cache')->get_data('module-search-'.$dirname.'-'.$param['id']);
+if (!$index) {
+ $index = $this->_query('SELECT `params` FROM `'.$table.'_search` WHERE `id`="'.$param['id'].'"', $system, 0);
+ if ($index) {
+ $p = dr_string2array($index['params']);
+ $index['sql'] = $p['sql'];
+ $index['where'] = $p['where'];
+ } else {
+ return $this->_return($system['return'], '娌℃湁鎼滅储缁撴灉', '', 0);
+ }
+}
+
+if (isset($index['where']) && $index['where']) {
+ $where[] = [
+ 'adj' => 'SQL',
+ 'value' => $index['where']
+ ];
+} elseif (isset($index['sql']) && $index['sql']) {
+ $where[] = [
+ 'adj' => 'SQL',
+ 'value' => '(`'.$table.'`.`id` IN('.$index['sql'].'))'
+ ];
+} else {
+ return $this->_return($system['return'], '娌℃湁鏌ヨ鍒板唴瀹', $index['sql'], 0);
+}
+
+unset($param['id']);
+
+// 鎺掑簭鎿嶄綔
+if (!$system['order'] && isset($where['id']) && $where['id']['adj'] == 'IN' && $where['id']['value']) {
+ // 鎸塱d搴忓垪鏉ユ帓搴
+ $system['order'] = strlen($where['id']['value']) < 10000 && $where['id']['value'] ? 'FIELD(`'.$table.'`.`id`, '.$where['id']['value'].')' : 'NULL';
+} else {
+ // 榛樿鎺掑簭鍙傛暟
+ !$system['order'] && ($system['order'] = $system['flag'] ? 'updatetime_desc' : ($action == 'hits' ? 'hits' : 'updatetime'));
+}
+
+$fields = $module['field']; // 涓昏〃鐨勫瓧娈
+$_order = [$table => $tableinfo[$table]];
+$sql_from = '`'.$table.'`';
+$sql_where = $this->_get_where($where); // sql鐨剋here瀛愬彞
+
+// 鍏宠仈鏍忕洰妯″瀷琛
+if ($system['more'] && isset($module['category_data_field']) && $module['category_data_field']) {
+ $fields = array_merge($fields, $module['category_data_field']);
+ $table_more = $table.'_category_data'; // 鏍忕洰妯″瀷琛
+ $sql_from.= " LEFT JOIN $table_more ON `$table_more`.`id`=`$table`.`id`"; // sql鐨刦rom瀛愬彞
+ $_order[$table_more] = $tableinfo[$table_more];
+ if (!$system['field']) {
+ $system['field'] = '`'.$table.'`.*';
+ $fields_more = \Phpcmf\Service::M()->db->getFieldNames($table_more);
+ if ($fields_more) {
+ foreach ($fields_more as $f) {
+ if (!in_array($f, ['id', 'catid', 'uid'])) {
+ $system['field'].= ',`'.$table_more.'`.`'.$f.'`';
+ }
+ }
+ }
+ }
+}
+
+$system['order'] = $this->_set_orders_field_prefix($system['order'], $_order); // 缁欐帓搴忓瓧娈靛姞涓婅〃鍓嶇紑
+
+// 鍒嗛〉澶勭悊
+$page = $this->_get_page_id($system['page']);
+$pagesize = (int)$system['pagesize'];
+!$pagesize && $pagesize = 10;
+if ($module['setting']['search']['max'] && $page * $pagesize > $module['setting']['search']['max']) {
+ $return_data = $this->_return($system['return'], '鎼滅储璁剧疆鏈澶ф樉绀'.$module['setting']['search']['max'].'鏉★紝褰撳墠锛'.($page * $pagesize).'锛夊凡瓒呭嚭', '', 0);
+ return;
+}
+isset($index['params']) && $index['params'] && $system['firsturl'] = \Phpcmf\Service::L('Router')->search_url($index['params']);
+$pages = $this->_new_pagination($system, $pagesize, $total);
+$sql_limit = 'LIMIT ' . intval($pagesize * ($page - 1)) . ',' . $pagesize;
+
+// 鏌ヨ缁撴灉
+$sql = "SELECT " .$this->_get_select_field($system['field'] ? $system['field'] : '*') . " FROM $sql_from " . ($sql_where ? "WHERE $sql_where" : "") . ($system['order'] == "null" || !$system['order'] ? "" : " ORDER BY {$system['order']}") . " $sql_limit";
+$data = $this->_query($sql, $system);
+
+// 缂撳瓨鏌ヨ缁撴灉
+if (is_array($data) && $data) {
+ // 妯″潡琛ㄧ殑绯荤粺瀛楁
+ $fields['inputtime'] = ['fieldtype' => 'Date'];
+ $fields['updatetime'] = ['fieldtype' => 'Date'];
+ // 鏍煎紡鍖栨樉绀鸿嚜瀹氫箟瀛楁鍐呭
+ $dfield = \Phpcmf\Service::L('Field')->app($module['dirname']);
+ foreach ($data as $i => $t) {
+ $t['url'] = dr_url_rel(dr_url_prefix($t['url'], $dirname, $system['site'], $this->_is_mobile));
+ $data[$i] = $dfield->format_value($fields, $t, 1);
+ }
+}
+
+// 瀛樺偍缂撳瓨
+$system['cache'] && $this->_save_cache_data($cache_name, [
+ 'data' => $data,
+ 'sql' => $sql,
+ 'total' => $total,
+ 'pages' => $pages,
+ 'pagesize' => $pagesize,
+ 'page_used' => $this->_page_used,
+ 'page_urlrule' => $this->_page_urlrule,
+], $system['cache']);
+
+return $this->_return($system['return'], $data, $sql, $total, $pages, $pagesize);
\ No newline at end of file
diff --git a/dayrui/App/Cms/Config/App.php b/dayrui/App/Cms/Config/App.php
new file mode 100644
index 0000000..2fa198f
--- /dev/null
+++ b/dayrui/App/Cms/Config/App.php
@@ -0,0 +1,10 @@
+ 'app',
+ 'name' => '寤虹珯绯荤粺澶т紬鐗',
+ 'author' => '杩呯澘浜戣蒋浠',
+ 'icon' => 'fa fa-th-large',
+
+];
\ No newline at end of file
diff --git a/dayrui/App/Cms/Config/Auto.php b/dayrui/App/Cms/Config/Auto.php
new file mode 100644
index 0000000..e8abc13
--- /dev/null
+++ b/dayrui/App/Cms/Config/Auto.php
@@ -0,0 +1,25 @@
+ [
+
+
+ ],
+
+ /**
+ * 绫诲悕鏄犲皠鍏崇郴
+ */
+ 'classmap' => [
+
+ 'Phpcmf\Member\Module' => IS_USE_MODULE.'Extends/Member/Module.php',
+
+ ],
+
+
+];
\ No newline at end of file
diff --git a/dayrui/App/Cms/Config/Before.php b/dayrui/App/Cms/Config/Before.php
new file mode 100644
index 0000000..d04f2a5
--- /dev/null
+++ b/dayrui/App/Cms/Config/Before.php
@@ -0,0 +1,16 @@
+is_table_exists('module')) {
+ // 琛ㄧず妯″潡琛ㄥ凡缁忔搷浣滐紝鎵嬪姩瀹夎妯″潡
+ $rs = file_put_contents(dr_get_app_dir('module').'/install.lock', 'fix');
+ if (!$rs) {
+ return dr_return_data(0, '鐩綍锛'.dr_get_app_dir('module').'锛夋棤娉曞啓鍏');
+ }
+ return dr_return_data(0, '銆愬缓绔欑郴缁熴戞彃浠跺凡琚畨瑁');
+}
+
+return dr_return_data(1, 'ok');
diff --git a/dayrui/App/Cms/Config/Cache.html b/dayrui/App/Cms/Config/Cache.html
new file mode 100644
index 0000000..b99353f
--- /dev/null
+++ b/dayrui/App/Cms/Config/Cache.html
@@ -0,0 +1,113 @@
+get('module-'.SITE_ID.'-content');
+ if ($module) {
+ $module = dr_array_sort($module, 'share', 'asc');
+ $limit = 10;
+ if (is_array($module) && dr_count($module) > $limit) {
+ $module_more = array_slice($module, $limit);
+ $module = array_slice($module, 0, $limit);
+ }
+ }
+}
+if (dr_is_app('sites')) {
+ $cname[] = '鏇存柊瀛愮珯鐩綍';
+}
+if (dr_is_app('client')) {
+ $cname[] = '鏇存柊缁堢鐩綍';
+}
+if ($cname) {
+ $add['module2'] = [implode('銆', $cname), 'update_site_config'];
+}
+?>
+{loop $add $id $t}
+
+
+ {$key}
+
+
+ {dr_lang($t[0])}
+
+
+
+ {dr_lang('绔嬪嵆鎵ц')}
+
+
+
+
+
+
+{php $key=$key+1;}
+{/loop}
+
+
+ {$key++}
+
+
+ {dr_lang('鏂板鎴栧彉鏇存爮鐩悗锛岄渶瑕佹洿鏂版爮鐩紦瀛樻暟鎹')}
+
+
+
+ {dr_lang('鍏变韩鏍忕洰')}
+
+ {loop $module $c}
+ {if !$c.share}
+
+ {dr_lang($c.name)}
+
+ {/if}
+ {/loop}
+ {if $module_more}
+
+ {dr_lang('鏇村')}
+
+
+
+
+
+ {/if}
+
+
+
+
+ {$key++}
+
+
+ {dr_lang('鍐呭鍦板潃涓庤缃湴鍧涓嶅悓姝ユ椂锛屾洿鏂板唴瀹筓RL鍦板潃')}
+
+
+ {loop $module $c}
+
+ {dr_lang($c.name)}
+
+ {/loop}
+ {if $module_more}
+
+ {dr_lang('鏇村')}
+
+
+
+
+
+ {/if}
+
+
\ No newline at end of file
diff --git a/dayrui/App/Cms/Config/Cache.php b/dayrui/App/Cms/Config/Cache.php
new file mode 100644
index 0000000..9dc1306
--- /dev/null
+++ b/dayrui/App/Cms/Config/Cache.php
@@ -0,0 +1,13 @@
+ 椤圭洰鐩綍
+ *
+ **/
+
+return [
+
+
+];
\ No newline at end of file
diff --git a/dayrui/App/Cms/Config/Content.php b/dayrui/App/Cms/Config/Content.php
new file mode 100644
index 0000000..3eea189
--- /dev/null
+++ b/dayrui/App/Cms/Config/Content.php
@@ -0,0 +1,248 @@
+ [
+
+ 1 => [
+ 'comment' => '鍐呭涓昏〃',
+ 'fields' => [
+ 'id' => 'int(10) unsigned NOT NULL AUTO_INCREMENT',
+ 'catid' => 'smallint(5) unsigned NOT NULL COMMENT \'鏍忕洰id\'',
+ 'title' => 'varchar(255) DEFAULT NULL COMMENT \'涓婚\'',
+ 'thumb' => 'varchar(255) DEFAULT NULL COMMENT \'缂╃暐鍥綷'',
+ 'keywords' => 'varchar(255) DEFAULT NULL COMMENT \'鍏抽敭瀛梊'',
+ 'description' => 'text COMMENT \'鎻忚堪\'',
+ 'hits' => 'int(10) unsigned DEFAULT NULL COMMENT \'娴忚鏁癨'',
+ 'uid' => 'int(10) unsigned NOT NULL COMMENT \'浣滆卛d\'',
+ 'author' => 'varchar(50) NOT NULL COMMENT \'绗斿悕\'',
+ 'status' => 'tinyint(2) NOT NULL COMMENT \'鐘舵(宸插簾寮)\'',
+ 'url' => 'varchar(255) DEFAULT NULL COMMENT \'鍦板潃\'',
+ 'link_id' => 'int(10) DEFAULT NULL DEFAULT \'0\' COMMENT \'鍚屾id\'',
+ 'tableid' => 'smallint(5) unsigned NOT NULL COMMENT \'闄勮〃id\'',
+ 'inputip' => 'varchar(200) DEFAULT NULL COMMENT \'褰曞叆鑰卛p\'',
+ 'inputtime' => 'int(10) unsigned NOT NULL COMMENT \'褰曞叆鏃堕棿\'',
+ 'updatetime' => 'int(10) unsigned NOT NULL COMMENT \'鏇存柊鏃堕棿\'',
+ 'displayorder' => 'int(10) DEFAULT \'0\' COMMENT \'鎺掑簭鍊糪'',
+ ],
+ 'indexes' => [
+ 'PRIMARY KEY (`id`)',
+ 'KEY `uid` (`uid`)',
+ 'KEY `catid` (`catid`)',
+ 'KEY `link_id` (`link_id`)',
+ 'KEY `status` (`status`)',
+ 'KEY `updatetime` (`updatetime`)',
+ 'KEY `hits` (`hits`)',
+ 'KEY `category` (`catid`, `status`)',
+ 'KEY `displayorder` (`displayorder`)',
+ ],
+ ],
+
+ 0 => [
+ 'comment' => '鍐呭闄勮〃',
+ 'fields' => [
+ 'id' => 'int(10) unsigned NOT NULL',
+ 'uid' => 'mediumint(8) unsigned NOT NULL COMMENT \'浣滆卽id\'',
+ 'catid' => 'smallint(5) unsigned NOT NULL COMMENT \'鏍忕洰id\'',
+ 'content' => 'mediumtext COMMENT \'鍐呭\'',
+ ],
+ 'indexes' => [
+ 'UNIQUE KEY `id` (`id`)',
+ 'KEY `uid` (`uid`)',
+ 'KEY `catid` (`catid`)',
+ ],
+ ],
+
+ ],
+
+ 'field' => [
+
+ 1 => array (
+ 0 =>
+ array (
+ 'fieldname' => 'title',
+ 'fieldtype' => 'Text',
+ 'relatedname' => 'module',
+ 'isedit' => '1',
+ 'ismain' => '1',
+ 'issystem' => '1',
+ 'ismember' => '1',
+ 'issearch' => '1',
+ 'disabled' => '0',
+ 'setting' =>
+ array (
+ 'option' =>
+ array (
+ 'width' => 400,
+ 'fieldtype' => 'VARCHAR',
+ 'fieldlength' => '255',
+ ),
+ 'validate' =>
+ array (
+ 'xss' => 1,
+ 'required' => 1,
+ 'formattr' => 'onblur="check_title();get_keywords(\'keywords\');"',
+ ),
+ ),
+ 'displayorder' => '0',
+ 'textname' => dr_lang('鏍囬'),
+ ),
+ 1 =>
+ array (
+ 'fieldname' => 'thumb',
+ 'fieldtype' => 'File',
+ 'relatedid' => '28',
+ 'relatedname' => 'module',
+ 'isedit' => '1',
+ 'ismain' => '1',
+ 'issystem' => 1,
+ 'ismember' => '1',
+ 'issearch' => '1',
+ 'disabled' => '0',
+ 'setting' =>
+ array (
+ 'option' =>
+ array (
+ 'ext' => 'jpg,gif,png',
+ 'size' => 10,
+ 'width' => 400,
+ 'fieldtype' => 'VARCHAR',
+ 'fieldlength' => '255',
+ ),
+ ),
+ 'displayorder' => '0',
+ 'textname' => dr_lang('缂╃暐鍥'),
+ ),
+ 2 =>
+ array (
+ 'fieldname' => 'keywords',
+ 'fieldtype' => 'Text',
+ 'relatedid' => '28',
+ 'relatedname' => 'module',
+ 'isedit' => '1',
+ 'ismain' => '1',
+ 'issystem' => 1,
+ 'ismember' => '1',
+ 'issearch' => '1',
+ 'disabled' => '0',
+ 'setting' =>
+ array (
+ 'option' =>
+ array (
+ 'width' => 400,
+ 'fieldtype' => 'VARCHAR',
+ 'fieldlength' => '255',
+ ),
+ 'validate' =>
+ array (
+ 'xss' => 1,
+ 'formattr' => ' data-role="tagsinput"', // tag灞炴
+ ),
+ ),
+ 'displayorder' => '0',
+ 'textname' => dr_lang('鍏抽敭瀛'),
+ ),
+ 3 =>
+ array (
+ 'fieldname' => 'description',
+ 'fieldtype' => 'Textarea',
+ 'relatedid' => '28',
+ 'relatedname' => 'module',
+ 'isedit' => '1',
+ 'ismain' => '1',
+ 'issystem' => 1,
+ 'ismember' => '1',
+ 'issearch' => '1',
+ 'disabled' => '0',
+ 'setting' =>
+ array (
+ 'option' =>
+ array (
+ 'width' => 500,
+ 'height' => 60,
+ 'fieldtype' => 'VARCHAR',
+ 'fieldlength' => '255',
+ ),
+ 'validate' =>
+ array (
+ 'xss' => 1,
+ 'filter' => 'dr_filter_description',
+ ),
+ ),
+ 'displayorder' => '0',
+ 'textname' => dr_lang('鎻忚堪'),
+ ),
+ 4 =>
+ array (
+ 'fieldname' => 'author',
+ 'fieldtype' => 'Text',
+ 'relatedname' => 'module',
+ 'isedit' => '1',
+ 'ismain' => '1',
+ 'issystem' => 1,
+ 'ismember' => '1',
+ 'issearch' => '1',
+ 'disabled' => '0',
+ 'setting' =>
+ array (
+ 'is_right' => 1,
+ 'option' =>
+ array (
+ 'width' => 200,
+ 'fieldtype' => 'VARCHAR',
+ 'fieldlength' => '255',
+ 'value' => '{name}'
+ ),
+ 'validate' =>
+ array (
+ 'xss' => 1,
+ ),
+ ),
+ 'displayorder' => '0',
+ 'textname' => dr_lang('绗斿悕'),
+ ),
+ ),
+
+ 0 => array (
+ 0 =>
+ array (
+ 'fieldname' => 'content',
+ 'fieldtype' => 'Editor',
+ 'relatedname' => 'module',
+ 'isedit' => '1',
+ 'ismain' => '0',
+ 'issystem' => 1,
+ 'ismember' => '1',
+ 'issearch' => '1',
+ 'disabled' => '0',
+ 'setting' =>
+ array (
+ 'option' =>
+ array (
+ 'mode' => 1,
+ 'show_bottom_boot' => 1,
+ 'div2p' => 1,
+ 'width' => '100%',
+ 'height' => 400,
+ ),
+ 'validate' =>
+ array (
+ 'xss' => 1,
+ 'required' => 1,
+ ),
+ ),
+ 'displayorder' => '0',
+ 'textname' => dr_lang('鍐呭'),
+ ),
+ ),
+
+ ],
+];
\ No newline at end of file
diff --git a/dayrui/App/Cms/Config/Cron.php b/dayrui/App/Cms/Config/Cron.php
new file mode 100644
index 0000000..0aa2885
--- /dev/null
+++ b/dayrui/App/Cms/Config/Cron.php
@@ -0,0 +1,72 @@
+site_info as $siteid => $site) {
+ // 妯″潡
+ $module = \Phpcmf\Service::L('cache')->get('module-'.$siteid.'-content');
+ if ($module) {
+ foreach ($module as $dir => $mod) {
+ // 鍒犻櫎妯″潡棣栭〉
+ if ($mod['is_index_html']) {
+ if ($mod['domain']) {
+ // 缁戝畾鍩熷悕鏃
+ $file = 'index.html';
+ } else {
+ $file = ltrim(\Phpcmf\Service::L('Router')->remove_domain($mod['url']), '/'); // 浠庡湴鍧涓幏鍙栬鐢熸垚鐨勬枃浠跺悕;
+ }
+ if ($file) {
+ unlink(dr_is_app('chtml') ? \Phpcmf\Service::L('html', 'chtml')->get_webpath($siteid, $dir, $file) : WEBPATH.$file);
+ unlink(dr_is_app('chtml') ? \Phpcmf\Service::L('html', 'chtml')->get_webpath($siteid, $dir, 'mobile/'.$file) : WEBPATH.'mobile/'.$file);
+ }
+ }
+ // 瀹氭椂鍙戝竷鍔ㄤ綔
+ $times = \Phpcmf\Service::M()->table($siteid.'_'.$dir.'_time')->where('posttime > 0 and posttime < '.SYS_TIME)->getAll(1);
+ if ($times) {
+ $lockFile = WRITEPATH."config/module_cron_".$siteid.$dir.".lock";
+ if (file_exists($lockFile)) {
+ $ctime = intval(filectime($lockFile));
+ if (SYS_TIME - $ctime > 1000) {
+ unlink($lockFile);
+ } else {
+ CI_DEBUG && log_message('debug', '瀹氭椂鍙戝竷鏂囦欢閿佸畾锛'.date("Y-m-d H:i:s", $ctime));
+ exit;
+ }
+ }
+ $fp = fopen($lockFile, 'w');
+ if ($fp) {
+ // 鑾峰彇閿佹垚鍔燂紝鎵ц浣犵殑浠g爜
+ chmod($lockFile, 0666); // 纭繚鏂囦欢鏈夎冻澶熸潈闄
+ $this->_module_init($dir, $siteid, 1);
+ \Phpcmf\Service::C()->module = $this->module;
+ \Phpcmf\Service::C()->content_model->siteid = $siteid;
+ \Phpcmf\Service::C()->content_model->_init($dir, $siteid);
+ foreach ($times as $t) {
+ $rt = $this->content_model->post_time($t);
+ if (!$rt['code']) {
+ echo '妯″潡銆'.$dir.'銆戝畾鏃跺彂甯冿紙'.$t['id'].'锛夊け璐'.PHP_EOL;
+ CI_DEBUG && log_message('error', '妯″潡銆'.$dir.'銆戝畾鏃跺彂甯冿紙'.$t['id'].'锛夊け璐ワ細'.$rt['msg']);
+ } else {
+ \Phpcmf\Service::M()->table($siteid.'_'.$dir.'_time')->update($t['id'], [
+ 'posttime' => 0,
+ ]);
+ echo '妯″潡銆'.$dir.'銆戝畾鏃跺彂甯冿紙'.$rt['code'].'锛夋垚鍔'.PHP_EOL;
+ }
+ sleep(10);
+ }
+ // 鎵ц瀹屾瘯鍚庨噴鏀鹃攣
+ fclose($fp);
+ unlink($lockFile);
+ break;
+ } else {
+ CI_DEBUG && log_message('debug', '瀹氭椂鍙戝竷鏂囦欢涓婇攣鎴愬姛锛'.date("Y-m-d H:i:s"));
+ exit;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Config/Filters.php b/dayrui/App/Cms/Config/Filters.php
new file mode 100644
index 0000000..507fc5d
--- /dev/null
+++ b/dayrui/App/Cms/Config/Filters.php
@@ -0,0 +1,14 @@
+ [
+ 'cms/api/related',
+ 'cms/api/related',
+ ],
+
+];
\ No newline at end of file
diff --git a/dayrui/App/Cms/Config/Hooks.php b/dayrui/App/Cms/Config/Hooks.php
new file mode 100644
index 0000000..85e916a
--- /dev/null
+++ b/dayrui/App/Cms/Config/Hooks.php
@@ -0,0 +1,948 @@
+newInstanceWithoutConstructor();
+ // 鍚屾褰撳墠鎺у埗鍣ㄧ殑 public 灞炴э紙site_info銆乵ember 绛夛級
+ foreach (get_object_vars($ci) as $key => $value) {
+ $c->$key = $value;
+ }
+ if (method_exists($c, 'index')) {
+ $c->index();
+ return dr_return_data(1, 'ok');
+ }
+ }
+
+});
+/**
+ * 妯″潡棣栭〉鍦板潃
+ * $dir 妯″潡鐩綍
+ */
+function dr_module_url($dir) {
+
+ if (defined('MOD_DIR') && $dir == MOD_DIR) {
+ return MODULE_URL;
+ }
+
+ return \Phpcmf\Service::L('cache')->get('module-'.dr_module_siteid().'-'.$dir, 'url');
+}
+
+function dr_module_category_data_field($cat, $field, $module) {
+ if (!$cat['ismain']) {
+ // 闈炰富鏍忕洰缁ф壙涓婄骇
+ $cat = dr_cat_value(
+ $module['mid'],
+ \Phpcmf\Service::L('category', 'module')->get_ismain_id($module['mid'], $cat)
+ );
+ }
+ if ($cat) {
+ if (isset($module['setting']['module_category_hide']) && $module['setting']['module_category_hide']) {
+ if ($module['category_data_field']) {
+ foreach ($module['category_data_field'] as $f => $v) {
+ if (!dr_in_array($f, $cat['field'])) {
+ $field[$f] = $v;
+ }
+ }
+ }
+ } else {
+ if ($cat['field']) {
+ foreach ($cat['field'] as $f) {
+ if ($module['category_data_field'][$f]) {
+ $field[$f] = $module['category_data_field'][$f];
+ }
+ }
+ }
+ }
+ }
+ return $field;
+}
+function dr_module_param($mid, $name) {
+
+ if (!$mid) {
+ return '';
+ }
+
+ return \Phpcmf\Service::L('cache')->get('module-'.dr_module_siteid().'-'.$mid, 'setting', 'param', $name);
+}
+// 鑾峰彇鎵灞炵珯鐐筰d
+function dr_module_siteid() {
+ if (isset(XR_C()->content_model->siteid) && (XR_C()->content_model->siteid)) {
+ return XR_C()->content_model->siteid;
+ }
+ return SITE_ID;
+}
+
+if (!function_exists('dr_is_double_search')) {
+ // 鍒ゆ柇鎼滅储鍊兼槸鍚︽槸澶氶噸閫夋嫨鏃剁殑閫変腑鐘舵 1閫変腑 0涓嶉
+ function dr_is_double_search($param, $value) {
+
+ if (!$param) {
+ return 0;
+ }
+
+ $arr = explode('|', $param);
+ if (in_array($value, $arr)) {
+ return 1;
+ }
+
+ return 0;
+ }
+}
+
+if (!function_exists('dr_get_double_search')) {
+ // 鑾峰彇澶氶噸閫夋嫨鏄殑鍙傛暟鍊
+ function dr_get_double_search($param, $value) {
+
+ if (!$param) {
+ return $value;
+ }
+
+ $arr = explode('|', $param);
+ if (in_array($value, $arr)) {
+ // 濡傛灉瀛樺湪锛岄偅涔堜箙绉婚櫎浠
+ $arr = array_merge(array_diff($arr, array($value)));
+ } else {
+ // 娌℃湁灏卞姞涓
+ $arr[] = $value;
+ }
+
+ return $arr ? @implode('|', $arr) : '';
+ }
+}
+
+// 鑾峰彇鍐呭鐨則ags
+function dr_get_content_tags($value) {
+
+ if (is_array($value)) {
+ return $value;
+ } elseif (!$value) {
+ return [];
+ }
+
+ $rt = [];
+ $tag = explode(',', $value);
+ foreach ($tag as $t) {
+ $t = trim($t);
+ if ($t) {
+ // 璇荤紦瀛
+ if (dr_is_app('tag')) {
+ $obj = \Phpcmf\Service::M('tag', 'tag');
+ if (method_exists($obj, 'get_tag_url')) {
+ $url = $obj->get_tag_url($t);
+ if ($url) {
+ $rt[$t] = $url;
+ }
+ }
+ }
+ }
+ }
+
+ return $rt;
+}
+
+// 鑾峰彇鍐呭鐨勬悳绱㈣瘝
+function dr_get_content_kws($value, $mid = '') {
+
+ if (is_array($value)) {
+ return $value;
+ } elseif (!$value) {
+ return [];
+ }
+
+ $rt = [];
+ $mid = $mid ? $mid : (defined('MOD_DIR') ? MOD_DIR : '');
+ $tag = explode(',', $value);
+ foreach ($tag as $t) {
+ $t = trim($t);
+ if ($t) {
+ $rt[$t] = \Phpcmf\Service::L('router')->search_url([], 'keyword', $t, $mid);
+ }
+ }
+
+ return $rt;
+}
+
+
+/**
+ * 鍐呭鏂囩珷鏄剧ず鍐呴摼
+ */
+function dr_content_link($tags, $content, $num = 0, $blank = 1) {
+
+ if (!$tags || !$content) {
+ return $content;
+ } elseif (!is_array($tags)) {
+ return $content;
+ }
+
+ foreach ($tags as $name => $url) {
+ if ($name && $url) {
+ $content = @preg_replace(
+ '\'(?!((<.*?)|(
]*?)>)|([^>]*?)|([^>]*?))\'si',
+ ''.$name.' ',
+ $content,
+ $num ? $num : -1
+ );
+ }
+ }
+
+ return $content;
+}
+
+
+// 鍐呭鍔犲唴閾
+function dr_neilian($content, $blank = 1, $num = 0) {
+
+ if (!$content) {
+ return '';
+ }
+
+ if (dr_is_app('tag')) {
+ $obj = \Phpcmf\Service::M('tag', 'tag');
+ if (method_exists($obj, 'neilian')) {
+ return $obj->neilian($content, $blank, $num);
+ }
+ }
+
+ return $content;
+}
+
+// 鑾峰彇妯″潡鏁版嵁鍙婅嚜瀹氫箟瀛楁
+function dr_mod_value(...$get) {
+
+ if (empty($get)) {
+ return '';
+ }
+
+ if (is_numeric($get[0]) && defined('MOD_DIR') && MOD_DIR) {
+ // 鍊兼槸鏍忕洰id鏃讹紝琛ㄧず褰撳墠妯″潡
+ $name = 'module-'.dr_module_siteid().'-'.MOD_DIR;
+ } else {
+ // 鎸囧畾妯″潡
+ $name = strpos($get[0], '-') ? 'module-'.$get[0] : 'module-'.dr_module_siteid().'-'.$get[0];
+ unset($get[0]);
+ }
+
+ $i = 0;
+ $param = [];
+ foreach ($get as $t) {
+ if ($i == 0) {
+ $param[] = $name;
+ }
+ $param[] = $t;
+ $i = 1;
+ }
+
+ return call_user_func_array([\Phpcmf\Service::C(), 'get_cache'], $param);
+}
+
+
+// 鑾峰彇鏍忕洰鏁版嵁鍙婅嚜瀹氫箟瀛楁
+function dr_page_value($id, $field, $site = SITE_ID) {
+
+ if (empty($id)) {
+ return '';
+ }
+
+ return \Phpcmf\Service::C()->get_cache('page-'.$site, 'data', $id, $field);
+}
+
+// 鑾峰彇鏍忕洰鏁版嵁鍙婅嚜瀹氫箟瀛楁
+function dr_cat_value(...$get) {
+
+ if (empty($get)) {
+ return [];
+ }
+
+ $mid = '';
+ if (is_numeric($get[0])) {
+ // 鍊兼槸鏍忕洰id鏃讹紝琛ㄧず褰撳墠妯″潡
+ if (defined('MOD_DIR') && MOD_DIR) {
+ $mid = MOD_DIR;
+ $name = 'module-'.dr_module_siteid().'-'.MOD_DIR;
+ } else {
+ $name = 'module-'.dr_module_siteid().'-share';
+ }
+ } else {
+ // 鎸囧畾妯″潡
+ $mid = $get[0] ? $get[0] : 'share';
+ $name = strpos($mid, '-') ? 'module-'.$mid : 'module-'.dr_module_siteid().'-'.$mid;
+ unset($get[0]);
+ }
+
+ $i = 0;
+ $param = [];
+ foreach ($get as $t) {
+ if ($i == 0) {
+ $param[] = $name;
+ $param[] = 'category';
+ }
+ $param[] = $t;
+ $i = 1;
+ }
+
+ $rt = call_user_func_array([\Phpcmf\Service::C(), 'get_cache'], $param);
+ if (end($param) == 'url' && $rt) {
+ $rt = dr_url_rel(dr_url_prefix($rt, $mid));
+ }
+
+ return $rt;
+}
+
+// 鑾峰彇鍏变韩鏍忕洰鏁版嵁鍙婅嚜瀹氫箟瀛楁
+function dr_share_cat_value($id, $field='') {
+
+ $get = func_get_args();
+ if (empty($get)) {
+ return [];
+ }
+
+ $i = 0;
+ $param = [];
+ foreach ($get as $t) {
+ if ($i == 0) {
+ $param[] = 'module-'.dr_module_siteid().'-share';
+ $param[] = 'category';
+ }
+ $param[] = $t;
+ $i = 1;
+ }
+
+ $rt = call_user_func_array(array(\Phpcmf\Service::C(), 'get_cache'), $param);
+
+ return $field == 'url' && $rt ? dr_url_rel(dr_url_prefix($rt)) : $rt;
+}
+
+
+/**
+ * 妯″潡鏍忕洰闈㈠寘灞戝鑸
+ *
+ * @param intval $catid 鏍忕洰id
+ * @param string $symbol 闈㈠寘灞戦棿闅旂鍙
+ * @param string $url 鏄惁鏄剧ずURL
+ * @param string $html 鏍煎紡鏇挎崲
+ * @return string
+ */
+function dr_catpos($catid, $symbol = ' > ', $url = true, $html= '', $dirname = 'MOD_DIR', $url_call_func = '') {
+
+ if (!$catid) {
+ return '';
+ }
+
+ $mid = $dirname == 'MOD_DIR' && defined('MOD_DIR') && MOD_DIR ? MOD_DIR : (!$dirname || $dirname == 'MOD_DIR' ? 'share' : $dirname);
+ $cat = \Phpcmf\Service::L('cache')->get('module-'.dr_module_siteid().'-'.$mid, 'category');
+ if (!isset($cat[$catid])) {
+ return '';
+ }
+
+ $name = [];
+ $array = explode(',', $cat[$catid]['pids']);
+ $array[] = $catid;
+ foreach ($array as $id) {
+ if ($id && $cat[$id]) {
+ if ($url_call_func && function_exists($url_call_func)) {
+ $murl = $url_call_func($cat[$id]);
+ } else {
+ $murl = dr_url_rel(dr_url_prefix($cat[$id]['url'], $mid));
+ //$murl = dr_url_prefix($cat[$id]['url'], MOD_DIR, dr_module_siteid(), \Phpcmf\Service::IS_MOBILE_TPL())
+ }
+ $name[] = $url ? ($html ? str_replace(['[url]', '[name]'], [$murl, $cat[$id]['name']], $html): "{$cat[$id]['name']} ") : $cat[$id]['name'];
+ }
+ }
+
+ return implode($symbol, array_unique($name));
+}
+
+
+// 鎵撹祻鏀粯
+function dr_donation($id, $title = '', $dir = '', $remove_div = 1) {
+ if (!dr_is_app('pay')) {
+ return '娌℃湁瀹夎銆屾敮浠樼郴缁熴嶆彃浠';
+ }
+ !$dir && $dir = defined('MOD_DIR') ? MOD_DIR : 'share';
+ return \Phpcmf\Service::M('Pay', 'pay')->payform('my-shang_buy-'.$id.'_'.$dir.'-'.dr_module_siteid(), 0, $title, '', $remove_div);
+}
+
+// 鏄惁瀛樺湪鏀惰棌澶逛腑 1鏀惰棌浜 2娌℃湁鏀惰棌
+function dr_is_favorite($dir, $id, $uid = 0) {
+
+ !$uid && $uid = \Phpcmf\Service::C()->uid;
+
+ if (!$uid) {
+ return 0;
+ } elseif (!$dir) {
+ return 0;
+ }
+
+ return \Phpcmf\Service::M()->db->table(dr_module_table_prefix($dir).'_favorite')->where('uid', $uid)->where('cid', $id)->countAllResults();
+}
+
+
+/**
+ * 妯″潡鍐呭闃呰閲忔樉绀簀s
+ *
+ * @param intval $id
+ * @return string
+ */
+if (!function_exists('dr_show_hits')) {
+ function dr_show_hits($id, $dom = "", $dir = 'MOD_DIR') {
+ $is = $dom;
+ !$dom && $dom = "dr_show_hits_{$id}";
+ $html = $is ? "" : "0 ";
+ if (defined('MODULE_MYSHOW')) {
+ return $html;
+ }
+ $dir = $dir == 'MOD_DIR' && defined('MOD_DIR') && MOD_DIR ? MOD_DIR : $dir;
+ $rt = "$(\".{$dom}\").html(data.msg);";
+ if ($is) {
+ $rt.= "$(\"#{$dom}\").html(data.msg);";
+ }
+ return $html."";
+ }
+}
+
+
+/**
+ * 鏍忕洰涓嬬骇鎴栬呭悓绾ф爮鐩
+ * $data 鏁翠釜鏍忕洰鏁扮粍
+ * $catid 褰撳墠鏍忕洰id
+ */
+function dr_related_cat($data, $catid) {
+
+ if (!$data) {
+ return [[], []];
+ }
+
+ $my = $data[$catid];
+ $related = $parent = [];
+
+ if ($my['child']) {
+ // 褰撳瓨鍦ㄥ瓙鏍忕洰鏃跺氨鏄剧ず涓嬬骇瀛愭爮鐩
+ $parent = $my['pid'] ? $data[$my['pid']] : $my;
+ foreach ($data as $t) {
+ if (!$t['show']) {
+ continue;
+ }
+ if ($t['pid'] == $my['id']) {
+ $t['url'] = dr_url_prefix($t['url'], defined('MOD_DIR') ? MOD_DIR : '');
+ $related[$t['id']] = $t;
+ }
+ }
+ } elseif ($my['pid']) {
+ // 褰撳睘浜庡瓙鏍忕洰鏃跺氨鏄剧ず鍚岀骇鍒爮鐩
+ foreach ($data as $t) {
+ if (!$t['show']) {
+ continue;
+ }
+ if ($t['pid'] == $my['pid']) {
+ $t['url'] = dr_url_prefix($t['url'], defined('MOD_DIR') ? MOD_DIR : '');
+ $related[$t['id']] = $t;
+ $parent = $data[$t['pid']];
+ }
+ }
+ } else {
+ // 鏄剧ず椤剁骇鏍忕洰
+ if (!$data) {
+ return [[], []];
+ }
+ $parent = $my;
+ foreach ($data as $t) {
+ if (!$t['show']) {
+ continue;
+ }
+ if ($t['pid'] == 0) {
+ $t['url'] = dr_url_prefix($t['url'], defined('MOD_DIR') ? MOD_DIR : '');
+ $related[$t['id']] = $t;
+ }
+ }
+ }
+
+ $parent && $parent['url'] = dr_url_prefix($parent['url'], defined('MOD_DIR') ? MOD_DIR : '');
+
+ return [$parent, $related];
+}
+
+/**
+ * 妯″潡鏍忕洰灞傛鍏崇郴
+ *
+ * @param array $mod
+ * @param array $cat
+ * @param string $symbol
+ */
+function dr_get_cat_pname($mod, $catid, $symbol = '_') {
+
+ $cat = $mod['category'][$catid];
+
+ if (!$cat['pids']) {
+ return $cat['name'];
+ }
+
+ $name = [];
+ $array = explode(',', $cat['pids']);
+
+ foreach ($array as $id) {
+ if ($id && $mod['category'][$id]) {
+ $name[] = $mod['category'][$id]['name'];
+ }
+ }
+
+ $name[] = $cat['name'];
+
+ $name = array_unique($name);
+
+ krsort($name);
+
+ return implode($symbol, $name);
+}
+
+
+
+/**
+ * url杞负鐩稿璺緞
+ */
+if (!function_exists('dr_url_rel')) {
+
+ /**
+ * url杞负鐩稿璺緞
+ */
+ function dr_url_rel($url, $prefix = '') {
+
+ if ((IS_API_HTTP && (!defined('SYS_API_REL') || !SYS_API_REL)) || IS_ADMIN) {
+ return $url;
+ } elseif (defined('SYS_URL_REL') && SYS_URL_REL) {
+ $surl = FC_NOW_HOST;
+ if (defined('SC_HTML_FILE') && SITE_IS_MOBILE_HTML
+ && \Phpcmf\Service::V()->_is_mobile
+ && strpos(SITE_MURL, SITE_URL) === false
+ ) {
+ // 闈欐佺敓鎴愶紝绉诲姩绔煙鍚嶆ā寮忎笅
+ $surl = SITE_MURL;
+ }
+ $url = str_replace($surl, '/', $url);
+ if (IS_DEV && strpos($url, 'http') === 0) {
+ $url.= '#绔欏鍩熷悕涓嶈兘杞负鐩稿璺緞锛堟湰鎻愮ず淇℃伅鍏抽棴寮鍙戣呮ā寮忔椂涓嶆樉绀猴級';
+ }
+ $prefix && $url = str_replace($prefix, '/', $url);
+ }
+
+ return $url;
+ }
+}
+
+
+/**
+ * 鍐呭涓殑杞负鐩稿璺緞
+ */
+if (!function_exists('dr_text_rel')) {
+
+
+ /**
+ * 鍐呭涓殑杞负鐩稿璺緞
+ */
+ function dr_text_rel($text, $prefix = '') {
+
+ if ((IS_API_HTTP && (!defined('SYS_API_REL') || !SYS_API_REL)) || IS_ADMIN) {
+ return $text;
+ } elseif (defined('SYS_URL_REL') && SYS_URL_REL) {
+ $surl = FC_NOW_HOST;
+ if (defined('SC_HTML_FILE') && SITE_IS_MOBILE_HTML
+ && \Phpcmf\Service::V()->_is_mobile
+ && strpos(SITE_MURL, SITE_URL) === false
+ ) {
+ // 闈欐佺敓鎴愶紝绉诲姩绔煙鍚嶆ā寮忎笅
+ $surl = SITE_MURL;
+ }
+ $text = str_replace('href="'.$surl, 'href="/', $text);
+ $text = str_replace('href=\''.$surl, 'href="/', $text);
+ $text = str_replace('src="'.$surl, 'src="/', $text);
+ $text = str_replace('src=\''.$surl, 'src="/', $text);
+ if ($prefix) {
+ $surl = $prefix;
+ $text = str_replace('href="'.$surl, 'href="/', $text);
+ $text = str_replace('href=\''.$surl, 'href="/', $text);
+ $text = str_replace('src="'.$surl, 'src="/', $text);
+ $text = str_replace('src=\''.$surl, 'src="/', $text);
+ }
+ }
+
+ return $text;
+ }
+}
+
+
+/**
+ * 妯″潡鏍忕洰URL鍦板潃
+ *
+ * @param array $mod
+ * @param array $data
+ * @param intval $page
+ * @return string
+ */
+function dr_module_category_url($mod, $data, $page = 0, $fid = 0) {
+
+ if (!$mod) {
+ return '鏍忕洰鎵灞炴ā鍧椾笉瀛樺湪';
+ } elseif (!$data) {
+ return '鏍忕洰鏁版嵁涓嶅瓨鍦';
+ }
+
+ // 鏄惁鍒嗛〉
+ $page && $data['page'] = $page = is_numeric($page) ? max((int)$page, 1) : $page;
+ !$page && $page = 1;
+ $is_page = $page > 1 || strpos($page, 'page') !== false;
+
+ // 鍔ㄦ佸湴鍧
+ $php_url = \Phpcmf\Service::L('router')->url_prefix('module_php', $mod, $data, $fid) . 'c=category&id=' . (isset($data['id']) ? $data['id'] : 0) . ($is_page ? '&page=' . $page : '');
+
+ // 鑾峰彇鑷畾涔塙RL
+ $url = '';
+ $rule = isset($data['setting']['urlrule']) ? \Phpcmf\Service::L('cache')->get('urlrule', (int)$data['setting']['urlrule'], 'value') : 0;
+ if ($is_page) {
+ if (isset($data['myurl_page']) && $data['myurl_page']) {
+ $url = ltrim($data['myurl_page'], '/');
+ $myurl = \Phpcmf\Service::L('router')->get_url_value($data, $url, \Phpcmf\Service::L('router')->url_prefix('rewrite', $mod, $data, $fid));
+ dr_save_rewrite_routes($my_url, trim($php_url, '/'));
+ return $myurl;
+ } elseif ($rule && $rule['list_page']) {
+ $url = ltrim($rule['list_page'], '/');
+ }
+ } else {
+ if (isset($data['myurl']) && $data['myurl']) {
+ $url = ltrim($data['myurl'], '/');
+ $myurl = \Phpcmf\Service::L('router')->get_url_value($data, $url, \Phpcmf\Service::L('router')->url_prefix('rewrite', $mod, $data, $fid));
+ dr_save_rewrite_routes($my_url, trim($php_url, '/'));
+ return $myurl;
+ } elseif ($rule && $rule['list']) {
+ $url = ltrim($rule['list'], '/');
+ }
+ }
+
+ if ($url) {
+ // URL妯″紡涓鸿嚜瀹氫箟锛屼笖宸茬粡璁剧疆瑙勫垯
+ $data['fid'] = $fid;
+ $data['modname'] = $mod['share'] ? '鍏变韩鏍忕洰涓嶈兘浣跨敤modname鏍囩' : $mod['dirname'];
+ $data['pdirname'].= $data['dirname'];
+ $data['pdirname'] = str_replace('/', $rule['catjoin'], $data['pdirname']);
+ $data['otdirname'] = $data['opdirname'] = $data['dirname'];
+ if ($data['pid']) {
+ $pcat = dr_cat_value($mod['mid'], $data['pid']);
+ if ($pcat) {
+ $data['opdirname'] = $pcat['dirname'];
+ }
+ }
+ if ($data['topid']) {
+ $pcat = dr_cat_value($mod['mid'], $data['topid']);
+ if ($pcat) {
+ $data['otdirname'] = $pcat['dirname'];
+ }
+ }
+ $myurl = \Phpcmf\Service::L('router')->get_url_value($data, $url, \Phpcmf\Service::L('router')->url_prefix('rewrite', $mod, $data, $fid));
+ dr_save_rewrite_routes($myurl, trim($php_url, '/'));
+ return $myurl;
+ }
+
+ return \Phpcmf\Service::L('router')->url_prefix('module_php', $mod, $data, $fid) . 'c=category&id=' . (isset($data['id']) ? $data['id'] : 0) . ($is_page ? '&page=' . $page : '');
+}
+
+/**
+ * 妯″潡鍐呭URL鍦板潃
+ *
+ * @param array $mod
+ * @param array $data
+ * @param mod $page
+ * @return string
+ */
+function dr_module_show_url($mod, $data, $page = 0) {
+
+ if (!$mod) {
+ return 'mod鍙傛暟涓嶅瓨鍦';
+ } elseif (!$data) {
+ return 'data鍙傛暟涓嶅畬鏁';
+ }
+
+ $cat = dr_cat_value($mod['mid'], $data['catid']);
+
+ $page && $data['page'] = $page = is_numeric($page) ? max((int)$page, 1) : $page;
+ !$page && $page = 1;
+ $is_page = $page > 1 || strpos($page, 'page') !== false;
+
+ $url = '';
+ $rule = \Phpcmf\Service::L('cache')->get('urlrule', (int)$cat['setting']['urlrule'], 'value');
+ if ($is_page) {
+ if (isset($data['myurl_page']) && $data['myurl_page']) {
+ $url = ltrim($data['myurl_page'], '/');
+ return \Phpcmf\Service::L('router')->get_url_value($data, $url, \Phpcmf\Service::L('router')->url_prefix('rewrite', $mod, $cat));
+ } elseif ($rule && $rule['show_page']) {
+ $url = ltrim($rule['show_page'], '/');
+ }
+ } else {
+ if (isset($data['myurl']) && $data['myurl']) {
+ $url = ltrim($data['myurl'], '/');
+ return \Phpcmf\Service::L('router')->get_url_value($data, $url, \Phpcmf\Service::L('router')->url_prefix('rewrite', $mod, $cat));
+ } elseif ($rule && $rule['show']) {
+ $url = ltrim($rule['show'], '/');
+ }
+ }
+
+ $php_url = \Phpcmf\Service::L('router')->url_prefix('module_php', $mod, $cat) . 'c=show&id=' . $data['id'] . ($is_page ? '&page=' . $page : '');
+
+ if ($url) {
+ // URL妯″紡涓鸿嚜瀹氫箟锛屼笖宸茬粡璁剧疆瑙勫垯
+ $data['cat'] = $cat;
+ $data['modname'] = $mod['dirname'];
+ $cat['pdirname'].= $cat['dirname'];
+ $data['dirname'] = $cat['dirname'];
+ $inputtime = isset($data['_inputtime']) ? $data['_inputtime'] : $data['inputtime'];
+ $data['y'] = date('Y', $inputtime);
+ $data['yy'] = date('y', $inputtime);
+ $data['m'] = date('m', $inputtime);
+ $data['d'] = date('d', $inputtime);
+ $data['pdirname'] = str_replace('/', $rule['catjoin'], $cat['pdirname']);
+ $data['otdirname'] = $data['opdirname'] = $cat['dirname'];
+ if ($cat['pid']) {
+ $pcat = dr_cat_value($mod['mid'], $cat['pid']);
+ if ($pcat) {
+ $data['opdirname'] = $pcat['dirname'];
+ }
+ }
+ if ($cat['topid']) {
+ $pcat = dr_cat_value($mod['mid'], $cat['topid']);
+ if ($pcat) {
+ $data['otdirname'] = $pcat['dirname'];
+ }
+ }
+
+ $data['url'] = $myurl = \Phpcmf\Service::L('router')->get_url_value($data, $url, \Phpcmf\Service::L('router')->url_prefix('rewrite', $mod, $cat));
+ dr_save_rewrite_routes($myurl, trim($php_url, '/'));
+ } else {
+ $data['url'] = \Phpcmf\Service::L('router')->url_prefix('module_php', $mod, $cat) . 'c=show&id=' . $data['id'] . ($is_page ? '&page=' . $page : '');
+ }
+
+ // 鎸傞挬鐐 妯″潡鍐呭url鍦板潃鑾峰彇
+ $rt = \Phpcmf\Hooks::trigger_callback('module_update_url', $data);
+ if ($rt && isset($rt['code']) && $rt['code']) {
+ $data['url'] = $rt['data'];
+ dr_save_rewrite_routes($data['url'], trim($php_url, '/'));
+ }
+
+ return $data['url'];
+}
+// 妯″潡URL
+function dr_module_index_url($mod, $sid) {
+
+ // 缁戝畾鍩熷悕鐨勬儏鍐典笅
+ if ($mod['site'][$sid]['domain']) {
+ return dr_http_prefix($mod['site'][$sid]['domain']) . '/';
+ }
+ $php_url = dr_web_prefix('index.php?s=' . $mod['dirname']);
+
+ // 鑷畾涔夎鍒欑殑鎯呭喌涓
+ $rule = \Phpcmf\Service::L('cache')->get('urlrule', (int)$mod['urlrule'], 'value', 'module');
+ if ($rule) {
+ $url = dr_web_prefix(str_replace('{modname}', $mod['dirname'], $rule));
+ dr_save_rewrite_routes($url, 'index.php?s=' . $mod['dirname']);
+ return $url;
+ }
+
+ return dr_web_prefix('index.php?s=' . $mod['dirname']);
+}
+/**
+ * 鎼滅储url缁勫悎
+ *
+ * @param array $params 鎼滅储鍙傛暟鏁扮粍
+ * @param string|array $name 褰撳墠鍙傛暟鍚嶇О
+ * @param string|array $value 褰撳墠鍙傛暟鍊
+ * @param string $mid 寮哄埗瀹氫綅鍒版ā鍧
+ * @param string $fid 鎸囧畾fid
+ * @return string
+ */
+function dr_module_search_url($params = [], $name = '', $value = '', $mid = '', $fid = SITE_FID) {
+
+
+ // 妯″潡鐩綍璇嗗埆
+ defined('MOD_DIR') && MOD_DIR && $dir = MOD_DIR;
+ $mid && $dir = $mid;
+
+ $mod = \Phpcmf\Service::L('cache')->get('module-' . dr_module_siteid() . '-' . $dir);
+ if (!$mod) {
+ return '妯″潡[' . $dir . ']缂撳瓨涓嶅瓨鍦';
+ }
+
+ if ($name) {
+ if (is_array($name)) {
+ foreach ($name as $i => $_name) {
+ if (isset($value[$i]) && strlen((string)$value[$i])) {
+ $params[$_name] = $value[$i];
+ } else {
+ unset($params[$_name]);
+ }
+ }
+ } else {
+ if (strlen((string)$value)) {
+ $params[$name] = $value;
+ } else {
+ unset($params[$name]);
+ }
+ }
+ }
+
+ if (is_array($params)) {
+ foreach ($params as $i => $t) {
+ if (strlen((string)$t) == 0) {
+ unset($params[$i]);
+ }
+ }
+ }
+
+ $php_url = \Phpcmf\Service::L('router')->url_prefix('php', $mod, [], $fid) . trim('c=search&' . (is_array($params) ? http_build_query($params) : ''), '&');
+
+ $rule = \Phpcmf\Service::L('cache')->get('urlrule', (int)$mod['urlrule'], 'value');
+ if ($rule && $rule['search']) {
+ $fid && $data['fid'] = $fid;
+ $data['modname'] = $mod['dirname'];
+ $data['param'] = dr_search_rewrite_encode($params, $mod['setting']['search']);
+ if ($params && !$data['param']) {
+ log_message('debug', '妯″潡['.$mod['dirname'].']鏃犳硶閫氳繃[鎼滅储鍙傛暟瀛楃涓茶鍒橾鑾峰緱鍙傛暟');
+ }
+ $url = ltrim($data['param'] ? $rule['search_page'] : $rule['search'], '/');
+ $my_url = \Phpcmf\Service::L('router')->get_url_value($data, $url, \Phpcmf\Service::L('router')->url_prefix('rewrite', $mod));
+ dr_save_rewrite_routes($my_url, trim($php_url, '/'));
+ return dr_url_rel(dr_url_prefix($my_url, $mod['dirname']));
+ } else {
+ return dr_url_rel(dr_url_prefix(\Phpcmf\Service::L('router')->url_prefix('php', $mod, [], $fid) . trim('c=search&' . (is_array($params) ? http_build_query($params) : ''), '&'), $mod['dirname']));
+ }
+}
+
+
+function dr_module_checktitle() {
+ // 鑾峰彇鍙傛暟
+ $id = (int)\Phpcmf\Service::L('input')->get('id');
+ $title = dr_safe_replace(htmlspecialchars((string)\Phpcmf\Service::L('input')->get('title')));
+ $module = dr_safe_filename(\Phpcmf\Service::L('input')->get('module'));
+ $cache = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-'.$module);
+
+ // 鍒ゆ柇鍙傛暟
+ if (!$title || !$module || !$cache) {
+ exit('');
+ }
+
+ // 鍒ゆ柇鏄惁閲嶅瀛樺湪
+ if (\Phpcmf\Service::M()->db->table(dr_module_table_prefix($module))->where('id<>'.$id)->where('title', $title)->countAllResults()) {
+ exit(dr_lang('宸茬粡鏈夌浉鍚岀殑%s瀛樺湪', isset($cache['field']['title']['name']) ? $cache['field']['title']['name'] : dr_lang('涓婚')));
+ }
+
+ exit('');
+}
+
+function dr_module_api_search() {
+
+ $dir = dr_safe_filename(\Phpcmf\Service::L('input')->get('dir'));
+ if (!$dir) {
+ \Phpcmf\Service::C()->_msg(0, dr_lang('妯″潡鍙傛暟涓嶈兘涓虹┖'));
+ } elseif (!dr_is_module($dir)) {
+ \Phpcmf\Service::C()->goto_404_page(dr_lang('妯″潡[%s]鏈畨瑁', $dir));
+ }
+
+ $get = \Phpcmf\Service::L('input')->get();
+ $cache = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-'.$dir);
+ $cache['field']['catdir'] = true;
+ $cache['field']['catid'] = true;
+ $cache['field']['order'] = true;
+
+ $param = [];
+ foreach ($get as $key => $value) {
+ if ($cache['field'] && isset($cache['field'][$key])) {
+ $param[$key] = $value;
+ }
+ }
+
+ // 璺宠浆url
+ dr_redirect(\Phpcmf\Service::L('Router')->search_url(
+ $param,
+ 'keyword',
+ dr_safe_replace(\Phpcmf\Service::L('input')->get('keyword')),
+ $dir
+ ));
+}
+
+// 璇勮鍚嶇О
+if (!function_exists('dr_comment_cname')) {
+ function dr_comment_cname($name) {
+
+ if (!$name) {
+ return dr_lang('璇勮');
+ }
+
+ return dr_lang($name);
+ }
+}
+
+/**
+ * 鎻愬彇鎻忚堪淇℃伅杩囨护鍑芥暟
+ */
+
+ if (! function_exists('dr_filter_description')) {
+ function dr_filter_description($value, $data = [], $old = []) {
+ return dr_get_description($value, 0);
+ }
+ }
+
+if (! function_exists('dr_get_description')) {
+ /**
+ * 鎻愬彇鎻忚堪淇℃伅
+ */
+ function dr_get_description($text, $limit = 0) {
+
+ $rs = \Phpcmf\Hooks::trigger_callback('cms_get_description', $text);
+ if ($rs && isset($rs['code']) && $rs['code'] && $rs['msg']) {
+ $text = $rs['msg'];
+ }
+
+ if (!$limit) {
+ $limit = isset(\Phpcmf\Service::C()->module['setting']['desc_limit']) && \Phpcmf\Service::C()->module['setting']['desc_limit'] ? \Phpcmf\Service::C()->module['setting']['desc_limit'] : 200;
+ }
+
+ if (isset(\Phpcmf\Service::C()->module['setting']['desc_clear']) && \Phpcmf\Service::C()->module['setting']['desc_clear']) {
+ $text = str_replace(' ', '', $text);
+ $text = str_replace('銆', '', $text);
+ }
+
+ return trim(dr_strcut(dr_clearhtml($text), $limit, ''));
+ }
+}
+if (! function_exists('dr_get_keywords')) {
+ /**
+ * 鎻愬彇鍏抽敭瀛
+ */
+ function dr_get_keywords($kw, $siteid = SITE_ID)
+ {
+
+ if (!$kw) {
+ return '';
+ }
+
+ $rs = \Phpcmf\Hooks::trigger_callback('cms_get_keywords', $kw, $siteid);
+ if ($rs && isset($rs['code']) && $rs['code'] && $rs['msg']) {
+ return $rs['msg'];
+ }
+
+ if (is_file(FCPATH.'ThirdParty/WordAnalysis/phpanalysis.class.php')) {
+ require_once FCPATH.'ThirdParty/WordAnalysis/phpanalysis.class.php';
+ \PhpAnalysis::$loadInit = false;
+ $pa = new \PhpAnalysis ( 'utf-8', 'utf-8', false );
+ $pa->LoadDict ();
+ $pa->SetSource ($kw);
+ $pa->StartAnalysis ( true );
+
+ $tags = $pa->GetFinallyKeywords (20);
+ if ($tags) {
+ return $tags;
+ }
+ }
+
+ return '';
+ }
+}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Config/Install.php b/dayrui/App/Cms/Config/Install.php
new file mode 100644
index 0000000..35327ad
--- /dev/null
+++ b/dayrui/App/Cms/Config/Install.php
@@ -0,0 +1,160 @@
+install_schema([
+ 'tables' => [
+ 'urlrule' => [
+ 'comment' => 'URL瑙勫垯琛',
+ 'fields' => [
+ 'id' => 'smallint(5) unsigned NOT NULL AUTO_INCREMENT',
+ 'type' => 'tinyint(1) unsigned NOT NULL COMMENT \'瑙勫垯绫诲瀷\'',
+ 'name' => 'varchar(50) NOT NULL COMMENT \'瑙勫垯鍚嶇О\'',
+ 'value' => 'text NOT NULL COMMENT \'璇︾粏瑙勫垯\'',
+ ],
+ 'indexes' => [
+ 'PRIMARY KEY (`id`)',
+ 'KEY `type` (`type`)',
+ ],
+ ],
+ 'module' => [
+ 'comment' => '妯″潡琛',
+ 'fields' => [
+ 'id' => 'smallint(5) unsigned NOT NULL AUTO_INCREMENT',
+ 'site' => 'mediumtext NULL COMMENT \'绔欑偣鍒掑垎\'',
+ 'dirname' => 'varchar(50) NOT NULL COMMENT \'鐩綍鍚嶇О\'',
+ 'share' => 'tinyint(1) unsigned DEFAULT NULL COMMENT \'鏄惁鍏变韩妯″潡\'',
+ 'setting' => 'text NULL COMMENT \'閰嶇疆淇℃伅\'',
+ 'comment' => 'text NULL COMMENT \'璇勮淇℃伅\'',
+ 'disabled' => 'tinyint(1) NOT NULL DEFAULT \'0\' COMMENT \'绂佺敤锛焅'',
+ 'displayorder' => 'smallint(5) DEFAULT \'0\'',
+ ],
+ 'indexes' => [
+ 'PRIMARY KEY (`id`)',
+ 'UNIQUE KEY `dirname` (`dirname`)',
+ 'KEY `disabled` (`disabled`)',
+ 'KEY `displayorder` (`displayorder`)',
+ ],
+ ],
+ 'admin_verify' => [
+ 'comment' => '瀹℃牳绠$悊琛',
+ 'fields' => [
+ 'id' => 'smallint(5) unsigned NOT NULL AUTO_INCREMENT',
+ 'name' => 'text NOT NULL COMMENT \'鍚嶇О\'',
+ 'verify' => 'text NOT NULL COMMENT \'瀹℃牳閮ㄧ讲\'',
+ ],
+ 'indexes' => [
+ 'PRIMARY KEY (`id`)',
+ ],
+ ],
+ ],
+ 'seeds' => [
+ ['table' => 'admin_verify', 'data' => ['id' => 1, 'name' => '榛樿瀹℃牳', 'verify' => '{"edit":"1","role":{"1":"2"}}']],
+ ],
+]);
+if (empty($rt['code'])) {
+ log_message('error', 'Cms_free install_schema: '.($rt['msg'] ?? ''));
+ return dr_return_data(0, dr_lang('瀹夎澶辫触').'锛'.($rt['msg'] ?? ''));
+}
+
+foreach ($this->site as $siteid) {
+ $catTable = $this->dbprefix($siteid.'_share_category');
+ if (!$this->is_table_exists($catTable)) {
+ $crt = \Phpcmf\Service::M('table')->create_table(
+ $catTable,
+ [
+ 'id' => 'smallint(5) unsigned NOT NULL AUTO_INCREMENT',
+ 'tid' => 'tinyint(1) NOT NULL COMMENT \'鏍忕洰绫诲瀷锛0鍗曢〉锛1妯″潡锛2澶栭摼\'',
+ 'pid' => 'smallint(5) unsigned NOT NULL DEFAULT \'0\' COMMENT \'涓婄骇id\'',
+ 'mid' => 'varchar(20) NOT NULL COMMENT \'妯″潡鐩綍\'',
+ 'pids' => 'varchar(255) NOT NULL COMMENT \'鎵鏈変笂绾d\'',
+ 'name' => 'varchar(255) NOT NULL COMMENT \'鏍忕洰鍚嶇О\'',
+ 'dirname' => 'varchar(255) NOT NULL COMMENT \'鏍忕洰鐩綍\'',
+ 'pdirname' => 'varchar(255) NOT NULL COMMENT \'涓婄骇鐩綍\'',
+ 'child' => 'tinyint(1) unsigned NOT NULL DEFAULT \'0\' COMMENT \'鏄惁鏈変笅绾'',
+ 'disabled' => 'tinyint(1) unsigned NOT NULL DEFAULT \'0\' COMMENT \'鏄惁绂佺敤\'',
+ 'ismain' => 'tinyint(1) unsigned NOT NULL DEFAULT \'1\' COMMENT \'鏄惁涓绘爮鐩甛'',
+ 'childids' => 'text NOT NULL COMMENT \'涓嬬骇鎵鏈塱d\'',
+ 'thumb' => 'varchar(255) NOT NULL COMMENT \'鏍忕洰鍥剧墖\'',
+ 'show' => 'tinyint(1) unsigned NOT NULL DEFAULT \'1\' COMMENT \'鏄惁鏄剧ず\'',
+ 'content' => 'mediumtext NOT NULL COMMENT \'鍗曢〉鍐呭\'',
+ 'setting' => 'mediumtext NOT NULL COMMENT \'灞炴ч厤缃甛'',
+ 'displayorder' => 'smallint(5) NOT NULL DEFAULT \'0\'',
+ ],
+ [
+ 'PRIMARY KEY (`id`)',
+ 'KEY `mid` (`mid`)',
+ 'KEY `tid` (`tid`)',
+ 'KEY `show` (`show`)',
+ 'KEY `disabled` (`disabled`)',
+ 'KEY `ismain` (`ismain`)',
+ 'KEY `dirname` (`dirname`)',
+ 'KEY `module` (`pid`,`displayorder`,`id`)',
+ ],
+ '鍏变韩妯″潡鏍忕洰琛'
+ );
+ if (empty($crt['code'])) {
+ log_message('error', 'Cms_free create table failed['.$catTable.']: '.($crt['msg'] ?? ''));
+ return dr_return_data(0, dr_lang('瀹夎澶辫触').'锛'.($crt['msg'] ?? '鏃犳硶鍒涘缓琛 '.$catTable));
+ }
+ }
+
+ $idxTable = $this->dbprefix($siteid.'_share_index');
+ if (!$this->is_table_exists($idxTable)) {
+ $crt = \Phpcmf\Service::M('table')->create_table(
+ $idxTable,
+ [
+ 'id' => 'int(10) unsigned NOT NULL AUTO_INCREMENT',
+ 'mid' => 'varchar(20) NOT NULL COMMENT \'妯″潡鐩綍\'',
+ ],
+ [
+ 'PRIMARY KEY (`id`)',
+ 'KEY `mid` (`mid`)',
+ ],
+ '鍏变韩妯″潡鍐呭绱㈠紩琛'
+ );
+ if (empty($crt['code'])) {
+ log_message('error', 'Cms_free create table failed['.$idxTable.']: '.($crt['msg'] ?? ''));
+ return dr_return_data(0, dr_lang('瀹夎澶辫触').'锛'.($crt['msg'] ?? '鏃犳硶鍒涘缓琛 '.$idxTable));
+ }
+ }
+}
+
+file_put_contents(CONFIGPATH.'rewrite.php', file_get_contents(dr_get_app_dir('cms').'Config/Rewrite.php'));
+
+file_put_contents(WRITEPATH.'is_module_install.lock', 1);
+
+$json = [];
+$json[] = '{"id":"5","type":"3","name":"涓嶅甫鏍忕洰璺緞","value":"{\"list\":\"list-{dirname}.html\",\"list_page\":\"list-{dirname}-{page}.html\",\"show\":\"show-{id}.html\",\"show_page\":\"\",\"catjoin\":\"/\"}"}';
+$json[] = '{"id":"4","type":"3","name":"甯︽爮鐩矾寰","value":"{\"list\":\"{dirname}/\",\"list_page\":\"{dirname}/p{page}.html\",\"show\":\"{dirname}/{id}.html\",\"show_page\":\"\",\"catjoin\":\"/\"}"}';
+$json[] = '{"id":"8","type":"2","name":"鍏变韩妯″潡鎼滅储","value":"{\"search\":\"search/{modname}.html\",\"search_page\":\"search/{modname}/{param}.html\",\"catjoin\":\"/\"}"}';
+foreach ($json as $t) {
+ $data = dr_string2array($t);
+ unset($data['id']);
+ $this->table('urlrule')->insert($data);
+}
+
+\Phpcmf\Service::M('module', 'cms')->install('news', null, 0, 1);
+
+// 榛樿绔欑偣淇℃伅瀛楁
+$site_field = [];
+$site_field['yqlj'] = '{"name":"鍙嬫儏閾炬帴","fieldname":"yqlj","fieldtype":"Ftable","isedit":"1","ismain":"1","issystem":"0","ismember":"1","issearch":"0","disabled":"0","setting":{"option":{"is_add":"1","is_first_hang":"0","count":"","first_cname":"","hang":{"1":{"name":""},"2":{"name":""},"3":{"name":""},"4":{"name":""},"5":{"name":""}},"field":{"1":{"type":"1","name":"缃戠珯鍚嶇О","width":"200","option":""},"2":{"type":"1","name":"缃戠珯鍦板潃","width":"","option":""},"3":{"type":"0","name":"","width":"","option":""},"4":{"type":"0","name":"","width":"","option":""},"5":{"type":"0","name":"","width":"","option":""},"6":{"type":"0","name":"","width":"","option":""},"7":{"type":"0","name":"","width":"","option":""},"8":{"type":"0","name":"","width":"","option":""},"9":{"type":"0","name":"","width":"","option":""},"10":{"type":"0","name":"","width":"","option":""}},"width":"","height":"","css":""},"validate":{"required":"0","pattern":"","errortips":"","xss":"1","check":"","filter":"","tips":"","formattr":""},"is_right":"0"},"displayorder":"0"}';
+$site_field['hdtp'] = '{"name":"骞荤伅鍥剧墖","fieldname":"hdtp","fieldtype":"Ftable","isedit":"1","ismain":"1","issystem":"0","ismember":"1","issearch":"0","disabled":"0","setting":{"option":{"is_add":"1","is_first_hang":"0","count":"","first_cname":"","hang":{"1":{"name":""},"2":{"name":""},"3":{"name":""},"4":{"name":""},"5":{"name":""}},"field":{"1":{"type":"3","name":"鍥剧墖","width":"200","option":""},"2":{"type":"1","name":"鍚嶇О","width":"200","option":""},"3":{"type":"1","name":"璺宠浆鍦板潃","width":"","option":""},"4":{"type":"0","name":"","width":"","option":""},"5":{"type":"0","name":"","width":"","option":""},"6":{"type":"0","name":"","width":"","option":""},"7":{"type":"0","name":"","width":"","option":""},"8":{"type":"0","name":"","width":"","option":""},"9":{"type":"0","name":"","width":"","option":""},"10":{"type":"0","name":"","width":"","option":""}},"width":"","height":"","css":""},"validate":{"required":"0","pattern":"","errortips":"","xss":"1","check":"","filter":"","tips":"","formattr":""},"is_right":"0"},"displayorder":"0"}';
+foreach ($site_field as $fname => $t) {
+ $value = dr_string2array($t);
+ if (!$value) {
+ continue;
+ }
+ $value['setting'] = dr_string2array($value['setting']);
+ \Phpcmf\Service::M('Field')->relatedid = SITE_ID;
+ \Phpcmf\Service::M('Field')->relatedname = 'site';
+ if (\Phpcmf\Service::M()->table('field')
+ ->where('relatedid', \Phpcmf\Service::M('Field')->relatedid)
+ ->where('relatedname', \Phpcmf\Service::M('Field')->relatedname)
+ ->where('fieldname', $fname)->counts()
+ ) {
+ continue;
+ }
+ $field = \Phpcmf\Service::L('field')->get($value['fieldtype']);
+ \Phpcmf\Service::M('Field')->add($value, $field);
+}
diff --git a/dayrui/App/Cms/Config/Install.sql b/dayrui/App/Cms/Config/Install.sql
new file mode 100644
index 0000000..e69de29
diff --git a/dayrui/App/Cms/Config/Install_site.sql b/dayrui/App/Cms/Config/Install_site.sql
new file mode 100644
index 0000000..e69de29
diff --git a/dayrui/App/Cms/Config/Menu.php b/dayrui/App/Cms/Config/Menu.php
new file mode 100644
index 0000000..48bf748
--- /dev/null
+++ b/dayrui/App/Cms/Config/Menu.php
@@ -0,0 +1,236 @@
+ [
+
+ 'config' => [
+ 'name' => '璁剧疆',
+ 'icon' => 'fa fa-cogs',
+ 'displayorder' => '-2',
+ 'left' => [
+ 'config-web' => [
+ 'name' => '缃戠珯璁剧疆',
+ 'icon' => 'fa fa-cog',
+ 'link' => [
+ [
+ 'name' => '缃戠珯璁剧疆',
+ 'icon' => 'fa fa-cog',
+ 'uri' => 'cms/site_config/index',
+ ],
+ [
+ 'name' => '鎵嬫満璁剧疆',
+ 'icon' => 'fa fa-mobile',
+ 'uri' => 'cms/site_mobile/index',
+ ],
+ [
+ 'name' => '鍩熷悕缁戝畾',
+ 'icon' => 'fa fa-globe',
+ 'uri' => 'cms/site_domain/index',
+ ],
+ ],
+ 'displayorder' => -1,
+ ],
+
+ 'config-content' => [
+ 'name' => '鍐呭璁剧疆',
+ 'icon' => 'fa fa-navicon',
+ 'link' => [
+ [
+ 'name' => '鍒涘缓妯″潡',
+ 'icon' => 'fa fa-plus',
+ 'uri' => 'cms/module_create/index',
+ 'displayorder' => -1,
+ ],
+ [
+ 'name' => '妯″潡绠$悊',
+ 'icon' => 'fa fa-gears',
+ 'uri' => 'cms/module/index',
+ 'displayorder' => -1,
+ ],
+ [
+ 'name' => '妯″潡鎼滅储',
+ 'icon' => 'fa fa-search',
+ 'uri' => 'cms/module_search/index',
+ 'displayorder' => -1,
+ ],
+ ]
+ ],
+
+ 'config-qx' => [
+ 'name' => '鏉冮檺璁剧疆',
+ 'icon' => 'fa fa-user',
+ 'link' => [
+ [
+ 'name' => '瀹℃牳娴佺▼',
+ 'icon' => 'fa fa-sort-numeric-asc',
+ 'uri' => 'cms/admin_verify/index',
+ ],
+ [
+ 'name' => '鍐呭鏉冮檺',
+ 'icon' => 'fa fa-table',
+ 'uri' => 'cms/auth/index',
+ ],
+ ]
+ ],
+
+ 'config-seo' => [
+ 'name' => 'SEO璁剧疆',
+ 'icon' => 'fa fa-internet-explorer',
+ 'link' => [
+ [
+ 'name' => '绔欑偣SEO',
+ 'icon' => 'fa fa-cog',
+ 'uri' => 'cms/seo_site/index',
+ ],
+ [
+ 'name' => '妯″潡SEO',
+ 'icon' => 'fa fa-th-large',
+ 'uri' => 'cms/seo_module/index',
+ ],
+ [
+ 'name' => '鏍忕洰SEO',
+ 'icon' => 'fa fa-reorder',
+ 'uri' => 'cms/seo_category/index',
+ ],
+ [
+ 'name' => 'URL瑙勫垯',
+ 'icon' => 'fa fa-link',
+ 'uri' => 'cms/urlrule/index',
+ ],
+ [
+ 'name' => '浼潤鎬佽В鏋',
+ 'icon' => 'bi bi-code-square',
+ 'uri' => 'cms/urlrule/rewrite_index',
+ ],
+ ]
+ ],
+ 'config-help' => [
+ 'name' => '鎿嶄綔鎸囧崡',
+ 'icon' => 'fa fa-question-circle',
+ 'link' => [
+ [
+ 'name' => '鍩虹鎿嶄綔',
+ 'icon' => 'bi bi-code-square',
+ 'uri' => 'cms/help/index',
+ ],
+ [
+ 'name' => '妯℃澘鍒朵綔',
+ 'icon' => 'bi bi-code-square',
+ 'uri' => 'cms/help/template',
+ ],
+ [
+ 'name' => 'SEO鐢ㄦ硶',
+ 'icon' => 'bi bi-code-square',
+ 'uri' => 'cms/help/seo',
+ ],
+ [
+ 'name' => '鑷畾涔塙RL',
+ 'icon' => 'bi bi-code-square',
+ 'uri' => 'cms/help/url',
+ ],
+ ]
+ ],
+ ],
+ ],
+
+
+
+
+ 'content' => [
+ 'name' => '鍐呭',
+ 'icon' => 'fa fa-th-large',
+ 'displayorder' => '-1',
+ 'left' => [
+ 'content-module' => [
+ 'name' => '鍐呭绠$悊',
+ 'icon' => 'fa fa-th-large',
+ 'link' => [
+ [
+ 'name' => '鍏变韩鏍忕洰',
+ 'icon' => 'fa fa-reorder',
+ 'uri' => 'category/index',
+ ],
+ [
+ 'name' => '缃戠珯淇℃伅',
+ 'icon' => 'fa fa-edit',
+ 'uri' => 'cms/site_param/index',
+ ],
+ ]
+ ],
+ 'content-verify' => [
+ 'name' => '鍐呭瀹℃牳',
+ 'icon' => 'fa fa-edit',
+ 'link' => [
+ ]
+ ],
+ ],
+ ],
+
+
+
+ ],
+
+
+ 'admin_min' => [
+ 'home' => [
+ 'link' => [
+ [
+ 'name' => '缃戠珯璁剧疆',
+ 'icon' => 'fa fa-cog',
+ 'uri' => 'module/site_param/index',
+ ],
+ [
+ 'name' => '鍥剧墖璁剧疆',
+ 'icon' => 'fa fa-photo',
+ 'uri' => 'module/site_image/index',
+ ],
+ ],
+ ],
+ 'config-seo' => [
+ 'name' => 'SEO璁剧疆',
+ 'icon' => 'fa fa-internet-explorer',
+ 'link' => [
+ [
+ 'name' => '绔欑偣SEO',
+ 'icon' => 'fa fa-cog',
+ 'uri' => 'module/seo_site/index',
+ ],
+ [
+ 'name' => '妯″潡SEO',
+ 'icon' => 'fa fa-gears',
+ 'uri' => 'module/seo_module/index',
+ ],
+ [
+ 'name' => '鏍忕洰SEO',
+ 'icon' => 'fa fa-reorder',
+ 'uri' => 'module/seo_category/index',
+ ],
+ [
+ 'name' => 'URL瑙勫垯',
+ 'icon' => 'fa fa-link',
+ 'uri' => 'module/urlrule/index',
+ ],
+ ]
+ ],
+
+ 'content-module' => [
+ 'name' => '鍐呭绠$悊',
+ 'icon' => 'fa fa-th-large',
+ 'link' => [
+ [
+ 'name' => '鍏变韩鏍忕洰',
+ 'icon' => 'fa fa-reorder',
+ 'uri' => 'category/index',
+ ],
+ ]
+ ],
+
+ ]
+
+];
\ No newline at end of file
diff --git a/dayrui/App/Cms/Config/Module_init.php b/dayrui/App/Cms/Config/Module_init.php
new file mode 100644
index 0000000..6e5625f
--- /dev/null
+++ b/dayrui/App/Cms/Config/Module_init.php
@@ -0,0 +1,90 @@
+is_module_init == $dirname.'-'.$siteid) {
+ // 闃叉妯″潡閲嶅鍒濆鍖
+ return 1;
+}
+
+$this->is_module_init = $dirname.'-'.$siteid;
+
+// 鍒ゆ柇妯″潡鏄惁瀹夎鍦ㄧ珯鐐逛腑
+$cache = \Phpcmf\Service::L('cache')->get('module-'.$siteid);
+$this->module = [];
+if ($dirname == 'share' || (isset($cache[$dirname]) && $cache[$dirname])) {
+ $this->module = \Phpcmf\Service::L('cache')->get('module-'.$siteid.'-'.$dirname);
+}
+
+// 鍒ゆ柇妯″潡鏄惁瀛樺湪
+if (!$this->module) {
+ // 閲嶆柊鐢熸垚涓娆$紦瀛
+ \Phpcmf\Service::M('cache')->sync_cache('');
+ $this->module = \Phpcmf\Service::L('cache')->get('module-'.$siteid.'-'.$dirname);
+ if (!$this->module) {
+ if (IS_ADMIN) {
+ if ($dirname == 'share') {
+ if ($rt) {
+ return 0;
+ } else {
+ CI_DEBUG && log_message('debug', $dirname.' - '.dr_lang('绯荤粺鏈畨瑁呭叡浜ā鍧楋紝鏃犳硶浣跨敤鏍忕洰'));
+ if (SITE_ID > 1) {
+ $this->_admin_msg(0, dr_lang('绯荤粺鏈畨瑁呭叡浜ā鍧楋紝鏃犳硶浣跨敤鏍忕洰').' '.dr_lang('鐐瑰嚮涓嬫柟閾炬帴杩涜瑁呰浇鍏变韩妯″潡'), dr_url('module/module/index'), 10);
+ } else {
+ $this->_admin_msg(0, dr_lang('绯荤粺鏈畨瑁呭叡浜ā鍧楋紝鏃犳硶浣跨敤鏍忕洰'), dr_url('module/module/index'), 10);
+ }
+ }
+ } else {
+ if ($rt) {
+ return 0;
+ } else {
+ CI_DEBUG && log_message('error', $dirname.' - '.dr_lang('妯″潡銆%s銆戜笉瀛樺湪', $dirname));
+ $this->_admin_msg(0, dr_lang('妯″潡缂撳瓨銆%s銆戜笉瀛樺湪', $dirname));
+ }
+ }
+ } else {
+ if ($rt) {
+ return 0;
+ } else {
+ CI_DEBUG && log_message('error', $dirname.' - '.dr_lang('妯″潡銆%s銆戜笉瀛樺湪', $dirname));
+ $this->goto_404_page(dr_lang('妯″潡缂撳瓨銆%s銆戜笉瀛樺湪', $dirname));
+ }
+ }
+ }
+}
+
+// 鏃犳潈闄愯闂ā鍧
+if (!defined('SC_HTML_FILE') && !IS_ADMIN && !IS_MEMBER && IS_USE_MEMBER
+ && \Phpcmf\Service::M('member_auth', 'cms')->module_auth($dirname, 'show', $this->member)) {
+ if ($rt) {
+ CI_DEBUG && log_message('debug', $dirname.' - '.dr_lang('鎮ㄧ殑鐢ㄦ埛缁勬棤鏉冮檺璁块棶妯″潡'));
+ return 0;
+ }
+ $this->_msg(0, dr_lang('鎮ㄧ殑鐢ㄦ埛缁勬棤鏉冮檺璁块棶妯″潡'), $this->uid || !defined('SC_HTML_FILE') ? '' : dr_member_url('login/index'));
+}
+
+// 鍒濆鍖栨暟鎹〃
+$this->content_model = \Phpcmf\Service::M('Content', $dirname);
+$this->content_model->_init($dirname, $siteid, $this->module['share']);
+
+// 鍏变韩妯″潡鏃讹紝鍗曢〉鐣岄潰鏃讹紝鎺掗櫎
+if ($dirname == 'share') {
+ return 0;
+}
+
+$this->module['comment'] = dr_is_app('comment') && \Phpcmf\Service::L('cache')->get('app-comment-'.SITE_ID, 'module', $dirname, 'use') ? 1 : 0;
+
+// 鍏煎鑰佺増鏈
+define('MOD_DIR', $dirname);
+define('IS_SHARE', $this->module['share']);
+define('IS_COMMENT', $this->module['comment']);
+define('MODULE_URL', $this->module['share'] ? '/' : $this->module['url']); // 鍏变韩妯″潡娌℃湁妯″潡url
+define('MODULE_NAME', dr_lang($this->module['name']));
+
+$this->content_model->is_hcategory = $this->is_hcategory = isset($this->module['config']['hcategory']) && $this->module['config']['hcategory'];
+
+// 璁剧疆妯℃澘鍒版ā鍧椾笅
+!$this->module['url'] && \Phpcmf\Service::V()->module($dirname);
+
+// 鍒濆鍖栧姞杞
+$this->init_file($dirname);
\ No newline at end of file
diff --git a/dayrui/App/Cms/Config/Rewrite.php b/dayrui/App/Cms/Config/Rewrite.php
new file mode 100644
index 0000000..4a9f082
--- /dev/null
+++ b/dayrui/App/Cms/Config/Rewrite.php
@@ -0,0 +1,24 @@
+ 'index.php?s=demo&c=show&id=114',
+ * 鍔ㄦ乮d瑙f瀽锛 "([0-9]+).html" => 'index.php?s=demo&c=show&id=$1',
+ */
+
+return [
+
+ "list-([A-za-z0-9 \-\_]+)-([0-9]+)\.html" => "index.php?c=category&dir=$1&page=$2", //銆愪笉甯︽爮鐩矾寰勩戞ā鍧楁爮鐩垪琛(鍒嗛〉)锛坙ist-{dirname}-{page}.html锛
+ "list-([A-za-z0-9 \-\_]+)\.html" => "index.php?c=category&dir=$1", //銆愪笉甯︽爮鐩矾寰勩戞ā鍧楁爮鐩垪琛紙list-{dirname}.html锛
+ "show-([0-9]+)\.html" => "index.php?c=show&id=$1", //銆愪笉甯︽爮鐩矾寰勩戞ā鍧楀唴瀹归〉锛坰how-{id}.html锛
+
+ "search\/([a-z]+)\/(.+)\.html" => "index.php?s=$1&c=search&rewrite=$2", //銆愬叡浜ā鍧楁悳绱€戞ā鍧楁悳绱㈤〉(鍒嗛〉)锛坰earch/{modname}/{param}.html锛
+ "search\/([a-z]+)\.html" => "index.php?s=$1&c=search", //銆愬叡浜ā鍧楁悳绱€戞ā鍧楁悳绱㈤〉锛坰earch/{modname}.html锛
+
+
+ "([A-za-z0-9 \-\_]+)\/p([0-9]+)\.html" => "index.php?c=category&dir=$1&page=$2", //銆愬甫鏍忕洰璺緞銆戞ā鍧楁爮鐩垪琛(鍒嗛〉)锛坽dirname}/p{page}.html锛
+ "([A-za-z0-9 \-\_]+)\/([0-9]+)\.html" => "index.php?c=show&id=$2", //銆愬甫鏍忕洰璺緞銆戞ā鍧楀唴瀹归〉锛坽dirname}/{id}.html锛
+ "([A-za-z0-9 \-\_]+)" => "index.php?c=category&dir=$1", //銆愬甫鏍忕洰璺緞銆戞ā鍧楁爮鐩垪琛紙{dirname}锛
+
+];
\ No newline at end of file
diff --git a/dayrui/App/Cms/Config/Routes.php b/dayrui/App/Cms/Config/Routes.php
new file mode 100644
index 0000000..ef3217b
--- /dev/null
+++ b/dayrui/App/Cms/Config/Routes.php
@@ -0,0 +1,4 @@
+site_info[SITE_ID]['SITE_MOBILE'] // 娌℃湁缁戝畾绉诲姩绔煙鍚嶄笉璺
+ //&& !in_array(DOMAIN_NAME, $client) // 褰撳墠鍩熷悕涓嶅瓨鍦ㄤ簬瀹㈡埛绔腑鏃
+ && $this->site_info[SITE_ID]['SITE_AUTO'] // 寮鍚嚜鍔ㄨ瘑鍒烦杞
+) {
+ $domain = trim(DOMAIN_NAME.WEB_DIR, '/');
+ if (\Phpcmf\Service::IS_MOBILE_USER()) {
+ // 杩欐槸绉诲姩绔
+ if (isset($client[$domain])) {
+ // 琛ㄧず杩欎釜鍩熷悕灞炰簬鐢佃剳绔,闇瑕佽烦杞埌绉诲姩绔
+ \Phpcmf\Service::L('Router')->auto_redirect(str_replace(dr_http_prefix($domain), dr_http_prefix($client[$domain]), dr_now_url()));
+ }
+ } else {
+ // 杩欐槸鐢佃剳绔
+ if (dr_in_array($domain, $client)) {
+ // 琛ㄧず杩欎釜鍩熷悕灞炰簬绉诲姩绔,闇瑕佽烦杞埌pc
+ $arr = array_flip($client);
+ \Phpcmf\Service::L('Router')->auto_redirect(str_replace(dr_http_prefix($domain), dr_http_prefix($arr[$domain]), dr_now_url()));
+ }
+ }
+}
+
+// 鍒ゆ柇缃戠珯鏄惁鍏抽棴
+if (!IS_DEV && !IS_ADMIN && !IS_API
+ && $this->site_info[SITE_ID]['SITE_CLOSE']
+ && (!$this->member || !$this->member['is_admin'])) {
+ // 鎸傞挬鐐 缃戠珯鍏抽棴鏃
+ \Phpcmf\Hooks::trigger('cms_close');
+ $this->_msg(0, $this->get_cache('site', SITE_ID, 'config', 'SITE_CLOSE_MSG'));
+}
+
+// 绔欑兢绯荤粺鎺ュ叆
+if (is_file(ROOTPATH.'api/fclient/sync.php')) {
+ $sync = \Phpcmf\Service::R(ROOTPATH.'api/fclient/sync.php') ;
+ if ($sync['status'] == 4) {
+ if ($sync['close_url']) {
+ dr_redirect($sync['close_url']);
+ } else {
+ $this->_msg(0, '缃戠珯琚叧闂');
+ }
+ } elseif ($sync['status'] == 3 || ($sync['endtime'] && SYS_TIME > $sync['endtime'])) {
+ if ($sync['pay_url']) {
+ dr_redirect($sync['pay_url']);
+ } else {
+ $this->_msg(0, '缃戠珯宸茶繃鏈');
+ }
+ }
+}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Config/SysTable.php b/dayrui/App/Cms/Config/SysTable.php
new file mode 100644
index 0000000..dc4ec5b
--- /dev/null
+++ b/dayrui/App/Cms/Config/SysTable.php
@@ -0,0 +1,216 @@
+ [
+ 'comment' => '鍐呭鑽夌ǹ琛',
+ 'fields' => [
+ 'id' => 'int(10) unsigned NOT NULL AUTO_INCREMENT',
+ 'cid' => 'int(10) unsigned NOT NULL COMMENT \'鍐呭id\'',
+ 'uid' => 'mediumint(8) unsigned NOT NULL COMMENT \'浣滆卽id\'',
+ 'catid' => 'mediumint(8) unsigned NOT NULL COMMENT \'鏍忕洰id\'',
+ 'content' => 'mediumtext NOT NULL COMMENT \'鍏蜂綋鍐呭\'',
+ 'inputtime' => 'int(10) unsigned NOT NULL COMMENT \'褰曞叆鏃堕棿\'',
+ ],
+ 'indexes' => [
+ 'PRIMARY KEY (`id`)',
+ 'KEY `uid` (`uid`)',
+ 'KEY `cid` (`cid`)',
+ 'KEY `catid` (`catid`)',
+ 'KEY `inputtime` (`inputtime`)',
+ ],
+ ],
+
+ '_verify' => [
+ 'comment' => '鍐呭瀹℃牳琛',
+ 'fields' => [
+ 'id' => 'int(10) unsigned NOT NULL',
+ 'uid' => 'mediumint(8) unsigned NOT NULL COMMENT \'浣滆卽id\'',
+ 'vid' => 'tinyint(2) NOT NULL COMMENT \'瀹℃牳id鍙穃'',
+ 'isnew' => 'tinyint(1) unsigned NOT NULL COMMENT \'0淇敼1鏂板2鍒犻櫎\'',
+ 'islock' => 'tinyint(1) unsigned NOT NULL COMMENT \'鏄惁閿佸畾\'',
+ 'author' => 'varchar(50) NOT NULL COMMENT \'浣滆匼'',
+ 'catid' => 'mediumint(8) unsigned NOT NULL COMMENT \'鏍忕洰id\'',
+ 'status' => 'tinyint(2) NOT NULL COMMENT \'瀹℃牳鐘舵乗'',
+ 'content' => 'mediumtext NOT NULL COMMENT \'鍏蜂綋鍐呭\'',
+ 'backuid' => 'mediumint(8) unsigned NOT NULL COMMENT \'鎿嶄綔浜簎id\'',
+ 'backinfo' => 'text NOT NULL COMMENT \'鎿嶄綔閫鍥炰俊鎭痋'',
+ 'inputtime' => 'int(10) unsigned NOT NULL COMMENT \'褰曞叆鏃堕棿\'',
+ ],
+ 'indexes' => [
+ 'UNIQUE KEY `id` (`id`)',
+ 'KEY `uid` (`uid`)',
+ 'KEY `vid` (`vid`)',
+ 'KEY `catid` (`catid`)',
+ 'KEY `status` (`status`)',
+ 'KEY `inputtime` (`inputtime`)',
+ 'KEY `backuid` (`backuid`)',
+ ],
+ ],
+
+ '_hits' => [
+ 'comment' => '鏃舵鐐瑰嚮閲忕粺璁',
+ 'fields' => [
+ 'id' => 'int(10) unsigned NOT NULL COMMENT \'鏂囩珷id\'',
+ 'hits' => 'int(10) unsigned NOT NULL COMMENT \'鎬荤偣鍑绘暟\'',
+ 'day_hits' => 'int(10) unsigned NOT NULL COMMENT \'鏈棩鐐瑰嚮\'',
+ 'week_hits' => 'int(10) unsigned NOT NULL COMMENT \'鏈懆鐐瑰嚮\'',
+ 'month_hits' => 'int(10) unsigned NOT NULL COMMENT \'鏈湀鐐瑰嚮\'',
+ 'year_hits' => 'int(10) unsigned NOT NULL COMMENT \'骞寸偣鍑婚噺\'',
+ 'day_time' => 'int(10) unsigned NOT NULL COMMENT \'鏈棩\'',
+ 'week_time' => 'int(10) unsigned NOT NULL COMMENT \'鏈懆\'',
+ 'month_time' => 'int(10) unsigned NOT NULL COMMENT \'鏈湀\'',
+ 'year_time' => 'int(10) unsigned NOT NULL COMMENT \'骞碶'',
+ ],
+ 'indexes' => [
+ 'UNIQUE KEY `id` (`id`)',
+ 'KEY `day_hits` (`day_hits`)',
+ 'KEY `week_hits` (`week_hits`)',
+ 'KEY `month_hits` (`month_hits`)',
+ 'KEY `year_hits` (`year_hits`)',
+ ],
+ ],
+
+ '_index' => [
+ 'comment' => '鍐呭绱㈠紩琛',
+ 'fields' => [
+ 'id' => 'int(10) unsigned NOT NULL AUTO_INCREMENT',
+ 'uid' => 'mediumint(8) unsigned NOT NULL COMMENT \'浣滆卽id\'',
+ 'catid' => 'mediumint(8) unsigned NOT NULL COMMENT \'鏍忕洰id\'',
+ 'status' => 'tinyint(2) NOT NULL COMMENT \'瀹℃牳鐘舵乗'',
+ 'inputtime' => 'int(10) unsigned NOT NULL COMMENT \'褰曞叆鏃堕棿\'',
+ ],
+ 'indexes' => [
+ 'PRIMARY KEY (`id`)',
+ 'KEY `uid` (`uid`)',
+ 'KEY `catid` (`catid`)',
+ 'KEY `status` (`status`)',
+ 'KEY `inputtime` (`inputtime`)',
+ ],
+ ],
+
+ '_category' => [
+ 'comment' => '鏍忕洰琛',
+ 'fields' => [
+ 'id' => 'mediumint(8) unsigned NOT NULL AUTO_INCREMENT',
+ 'pid' => 'mediumint(8) unsigned NOT NULL DEFAULT \'0\' COMMENT \'涓婄骇id\'',
+ 'pids' => 'varchar(255) NOT NULL COMMENT \'鎵鏈変笂绾d\'',
+ 'name' => 'varchar(255) NOT NULL COMMENT \'鏍忕洰鍚嶇О\'',
+ 'dirname' => 'varchar(255) NOT NULL COMMENT \'鏍忕洰鐩綍\'',
+ 'pdirname' => 'varchar(255) NOT NULL COMMENT \'涓婄骇鐩綍\'',
+ 'child' => 'tinyint(1) unsigned NOT NULL DEFAULT \'0\' COMMENT \'鏄惁鏈変笅绾'',
+ 'disabled' => 'tinyint(1) unsigned NOT NULL DEFAULT \'0\' COMMENT \'鏄惁绂佺敤\'',
+ 'ismain' => 'tinyint(1) unsigned NOT NULL DEFAULT \'1\' COMMENT \'鏄惁涓绘爮鐩甛'',
+ 'childids' => 'text NOT NULL COMMENT \'涓嬬骇鎵鏈塱d\'',
+ 'thumb' => 'varchar(255) NOT NULL COMMENT \'鏍忕洰鍥剧墖\'',
+ 'show' => 'tinyint(1) unsigned NOT NULL DEFAULT \'1\' COMMENT \'鏄惁鏄剧ず\'',
+ 'setting' => 'mediumtext NOT NULL COMMENT \'灞炴ч厤缃甛'',
+ 'displayorder' => 'mediumint(8) NOT NULL DEFAULT \'0\'',
+ ],
+ 'indexes' => [
+ 'PRIMARY KEY (`id`)',
+ 'KEY `show` (`show`)',
+ 'KEY `disabled` (`disabled`)',
+ 'KEY `ismain` (`ismain`)',
+ 'KEY `module` (`pid`,`displayorder`,`id`)',
+ ],
+ ],
+
+ '_category_data' => [
+ 'comment' => '鏍忕洰妯″瀷琛',
+ 'fields' => [
+ 'id' => 'int(10) unsigned NOT NULL AUTO_INCREMENT',
+ 'uid' => 'mediumint(8) unsigned NOT NULL COMMENT \'浣滆卽id\'',
+ 'catid' => 'int(3) unsigned NOT NULL COMMENT \'鏍忕洰id\'',
+ ],
+ 'indexes' => [
+ 'PRIMARY KEY (`id`)',
+ 'KEY `uid` (`uid`)',
+ 'KEY `catid` (`catid`)',
+ ],
+ ],
+
+ '_flag' => [
+ 'comment' => '鏍囪琛',
+ 'fields' => [
+ 'flag' => 'tinyint(2) unsigned NOT NULL DEFAULT \'1\' COMMENT \'鏂囨。鏍囪id\'',
+ 'id' => 'int(10) unsigned NOT NULL COMMENT \'鏂囨。鍐呭id\'',
+ 'uid' => 'mediumint(8) unsigned NOT NULL COMMENT \'浣滆卽id\'',
+ 'catid' => 'mediumint(8) unsigned NOT NULL COMMENT \'鏍忕洰id\'',
+ ],
+ 'indexes' => [
+ 'KEY `flag` (`flag`,`id`,`uid`)',
+ 'KEY `catid` (`catid`)',
+ ],
+ ],
+
+ '_search' => [
+ 'comment' => '鎼滅储琛',
+ 'fields' => [
+ 'id' => 'varchar(32) NOT NULL',
+ 'catid' => 'mediumint(8) unsigned NOT NULL COMMENT \'鏍忕洰id\'',
+ 'params' => 'text NOT NULL COMMENT \'鍙傛暟鏁扮粍\'',
+ 'keyword' => 'varchar(255) NOT NULL COMMENT \'鍏抽敭瀛梊'',
+ 'contentid' => 'int(10) unsigned NOT NULL COMMENT \'瀛楁鏀规垚浜嗙粨鏋滄暟閲忓糪'',
+ 'inputtime' => 'int(10) unsigned NOT NULL COMMENT \'鎼滅储鏃堕棿\'',
+ ],
+ 'indexes' => [
+ 'PRIMARY KEY (`id`)',
+ 'UNIQUE KEY `id` (`id`)',
+ 'KEY `catid` (`catid`)',
+ 'KEY `keyword` (`keyword`)',
+ 'KEY `inputtime` (`inputtime`)',
+ ],
+ ],
+
+ '_recycle' => [
+ 'comment' => '鍐呭鍥炴敹绔欒〃',
+ 'fields' => [
+ 'id' => 'int(10) unsigned NOT NULL AUTO_INCREMENT',
+ 'cid' => 'int(10) unsigned NOT NULL COMMENT \'鍐呭id\'',
+ 'uid' => 'mediumint(8) unsigned NOT NULL COMMENT \'浣滆卽id\'',
+ 'catid' => 'tinyint(3) unsigned NOT NULL COMMENT \'鏍忕洰id\'',
+ 'content' => 'mediumtext NOT NULL COMMENT \'鍏蜂綋鍐呭\'',
+ 'result' => 'text NOT NULL COMMENT \'鍒犻櫎鐞嗙敱\'',
+ 'inputtime' => 'int(10) unsigned NOT NULL COMMENT \'褰曞叆鏃堕棿\'',
+ ],
+ 'indexes' => [
+ 'PRIMARY KEY (`id`)',
+ 'KEY `uid` (`uid`)',
+ 'KEY `cid` (`cid`)',
+ 'KEY `catid` (`catid`)',
+ 'KEY `inputtime` (`inputtime`)',
+ ],
+ ],
+
+ '_time' => [
+ 'comment' => '鍐呭瀹氭椂鍙戝竷琛',
+ 'fields' => [
+ 'id' => 'int(10) unsigned NOT NULL AUTO_INCREMENT',
+ 'uid' => 'mediumint(8) unsigned NOT NULL COMMENT \'浣滆卽id\'',
+ 'catid' => 'mediumint(8) unsigned NOT NULL COMMENT \'鏍忕洰id\'',
+ 'content' => 'mediumtext NOT NULL COMMENT \'鍏蜂綋鍐呭\'',
+ 'result' => 'text NOT NULL COMMENT \'澶勭悊缁撴灉\'',
+ 'error' => 'tinyint(1) unsigned NOT NULL COMMENT \'鏄惁閿欒\'',
+ 'posttime' => 'int(10) unsigned NOT NULL COMMENT \'瀹氭椂鍙戝竷鏃堕棿\'',
+ 'inputtime' => 'int(10) unsigned NOT NULL COMMENT \'褰曞叆鏃堕棿\'',
+ ],
+ 'indexes' => [
+ 'PRIMARY KEY (`id`)',
+ 'KEY `uid` (`uid`)',
+ 'KEY `catid` (`catid`)',
+ 'KEY `error` (`error`)',
+ 'KEY `posttime` (`posttime`)',
+ 'KEY `inputtime` (`inputtime`)',
+ ],
+ ],
+
+];
diff --git a/dayrui/App/Cms/Config/Uninstall.php b/dayrui/App/Cms/Config/Uninstall.php
new file mode 100644
index 0000000..dc4bf08
--- /dev/null
+++ b/dayrui/App/Cms/Config/Uninstall.php
@@ -0,0 +1,2 @@
+prefix;
+
+// 瀹℃牳娴佺▼琛
+if (!\Phpcmf\Service::M()->is_table_exists('admin_verify')) {
+ $rt = \Phpcmf\Service::M('table')->install_schema([
+ 'tables' => [
+ 'admin_verify' => [
+ 'comment' => '瀹℃牳绠$悊琛',
+ 'fields' => [
+ 'id' => 'smallint(5) unsigned NOT NULL AUTO_INCREMENT',
+ 'name' => 'text NOT NULL COMMENT \'鍚嶇О\'',
+ 'verify' => 'text NOT NULL COMMENT \'瀹℃牳閮ㄧ讲\'',
+ ],
+ 'indexes' => [
+ 'PRIMARY KEY (`id`)',
+ ],
+ ],
+ ],
+ 'seeds' => [
+ ['table' => 'admin_verify', 'data' => ['id' => 1, 'name' => '榛樿瀹℃牳', 'verify' => '{"edit":"1","role":{"1":"2"}}']],
+ ],
+ ]);
+ if (empty($rt['code'])) {
+ log_message('error', 'Cms_free update admin_verify: '.($rt['msg'] ?? ''));
+ }
+}
+
+// 妯″潡
+$is_module = \Phpcmf\Service::M()->is_table_exists('module');
+if ($is_module) {
+ $module = \Phpcmf\Service::M()->table('module')->order_by('displayorder ASC,id ASC')->getAll();
+ // 鏍忕洰妯″瀷瀛楁淇
+ \Phpcmf\Service::M()->db->table('field')->where('relatedname', 'share-'.SITE_ID)->update(['relatedname' => 'catmodule-share']);
+ if ($module) {
+ foreach ($module as $m) {
+ if (!\Phpcmf\Service::M()->table('field')->where('relatedname', 'module')
+ ->where('relatedid', $m['id'])->where('fieldname', 'author')->counts()) {
+ \Phpcmf\Service::M()->db->table('field')->insert(array(
+ 'name' => '绗斿悕',
+ 'fieldname' => 'author',
+ 'fieldtype' => 'Text',
+ 'relatedid' => $m['id'],
+ 'relatedname' => 'module',
+ 'isedit' => 1,
+ 'ismain' => 1,
+ 'ismember' => 1,
+ 'issystem' => 1,
+ 'issearch' => 1,
+ 'disabled' => 0,
+ 'setting' => dr_array2string(array(
+ 'is_right' => 1,
+ 'option' => array(
+ 'width' => 200, // 琛ㄥ崟瀹藉害
+ 'fieldtype' => 'VARCHAR', // 瀛楁绫诲瀷
+ 'fieldlength' => '255', // 瀛楁闀垮害
+ 'value' => '{name}'
+ ),
+ 'validate' => array(
+ 'xss' => 1, // xss杩囨护
+ )
+ )),
+ 'displayorder' => 0,
+ ));
+ }
+ }
+ }
+}
+
+
+// 绔欑偣
+foreach ($this->site as $siteid) {
+ // 鍗囩骇鏍忕洰琛
+ if ($is_module) {
+ $table = $prefix . $siteid . '_share_category';
+ if (\Phpcmf\Service::M()->is_table_exists($table)) {
+ // 鍒涘缓瀛楁 浠g爜
+ if (!\Phpcmf\Service::M()->db->fieldExists('disabled', $table)) {
+ \Phpcmf\Service::M('table')->add_field($table, 'disabled', 'tinyint(1)', 'DEFAULT \'0\'', '');
+ \Phpcmf\Service::M()->query('UPDATE `' . $table . '` SET `disabled` = 0');
+ }
+ \Phpcmf\Service::M()->query('UPDATE `' . $table . '` SET `disabled` = 0 WHERE `disabled` IS NULL ');
+ if (!\Phpcmf\Service::M()->db->fieldExists('ismain', $table)) {
+ \Phpcmf\Service::M('table')->add_field($table, 'ismain', 'tinyint(1)', 'DEFAULT \'0\'', '');
+ \Phpcmf\Service::M()->query('UPDATE `' . $table . '` SET `ismain` = 1');
+ }
+ }
+ if ($module) {
+ foreach ($module as $m) {
+ $mtable = $prefix . $siteid . '_' . $m['dirname'];
+ if (!\Phpcmf\Service::M()->is_table_exists($mtable)) {
+ continue;
+ }
+ // 闄勮〃瀛楁鏄惁鍚屾
+ $tables = [];
+ $otable = $mtable.'_data_0'; // 姣嶈〃
+ list($a, $sql) = \Phpcmf\Service::M('table')->create_table_sql($otable);
+
+ $old = \Phpcmf\Service::M('table')->show_full_colunms($otable);
+
+ // 妯″潡闄勮〃
+ for ($i = 1; $i < 200; $i ++) {
+ // 鏂拌〃鏄惁瀛樺湪
+ if (!\Phpcmf\Service::M()->is_table_exists($mtable.'_data_'.$i)) {
+ break;
+ }
+ $new = \Phpcmf\Service::M('table')->show_full_colunms($mtable.'_data_'.$i);
+ foreach ($old as $t) {
+ $td = 0;
+ foreach ($new as $n) {
+ if ($t['Field'] == $n['Field']) {
+ $td = 1;
+ break;
+ }
+ }
+ if ($td == 0 && $sql[$t['Field']] && !\Phpcmf\Service::M()->db->fieldExists($t['Field'], $mtable.'_data_'.$i)) {
+ // 鏂板琛ㄥ瓧娈
+ $def = preg_replace('/^`'.preg_quote($t['Field'], '/').'`\s+/', '', trim($sql[$t['Field']]));
+ \Phpcmf\Service::M('table')->add_field($mtable.'_data_'.$i, $t['Field'], $def, '', '');
+ }
+ }
+ }
+
+ // 澧炲姞闀垮害
+ $table = $prefix . $siteid . '_' . $m['dirname'];
+ if (\Phpcmf\Service::M()->db->fieldExists('inputip', $table)) {
+ \Phpcmf\Service::M('table')->edit_field($table, 'inputip', 'VARCHAR(100)', 'NOT NULL', '瀹㈡埛绔痠p淇℃伅');
+ }
+ $table = $prefix . $siteid . '_' . $m['dirname'] . '_time';
+ if (!\Phpcmf\Service::M()->db->fieldExists('error', $table)) {
+ \Phpcmf\Service::M('table')->add_field($table, 'error', 'tinyint(1)', 'DEFAULT 0', '');
+ }
+
+ $table = $prefix . $siteid . '_' . $m['dirname'] . '_recycle';
+ if (\Phpcmf\Service::M()->is_table_exists($table)) {
+ // 鍒涘缓瀛楁 鍒犻櫎鐞嗙敱
+ if (!\Phpcmf\Service::M()->db->fieldExists('result', $table)) {
+ \Phpcmf\Service::M('table')->add_field($table, 'result', 'Text', 'NOT NULL', '');
+ }
+ }
+ $table = $prefix . $siteid . '_' . $m['dirname'] . '_support';
+ if (\Phpcmf\Service::M()->is_table_exists($table)) {
+ // 鍒涘缓瀛楁 娓稿鐐硅禐
+ if (!\Phpcmf\Service::M()->db->fieldExists('agent', $table)) {
+ \Phpcmf\Service::M('table')->add_field($table, 'agent', 'VARCHAR(200)', 'DEFAULT NULL', '');
+ }
+ }
+ $table = $prefix . $siteid . '_' . $m['dirname'] . '_oppose';
+ if (\Phpcmf\Service::M()->is_table_exists($table)) {
+ // 鍒涘缓瀛楁 娓稿鐐硅禐
+ if (!\Phpcmf\Service::M()->db->fieldExists('agent', $table)) {
+ \Phpcmf\Service::M('table')->add_field($table, 'agent', 'VARCHAR(200)', 'DEFAULT NULL', '');
+ }
+ }
+ $table = $prefix . $siteid . '_' . $m['dirname'] . '_verify';
+ if (!\Phpcmf\Service::M()->db->fieldExists('vid', $table)) {
+ \Phpcmf\Service::M('table')->add_field($table, 'vid', 'INT(10)', 'DEFAULT NULL', '');
+ }
+ if (!\Phpcmf\Service::M()->db->fieldExists('islock', $table)) {
+ \Phpcmf\Service::M('table')->add_field($table, 'islock', 'tinyint(1)', 'DEFAULT NULL', '');
+ }
+ // 鐐瑰嚮鏃堕棿
+ $table = $prefix . $siteid . '_' . $m['dirname'] . '_hits';
+ foreach (['day_time', 'week_time', 'month_time', 'year_time'] as $a) {
+ if (!\Phpcmf\Service::M()->db->fieldExists($a, $table)) {
+ \Phpcmf\Service::M('table')->add_field($table, $a, 'INT(10)', 'DEFAULT NULL', '');
+ }
+ }
+ $table = $prefix . $siteid . '_' . $m['dirname'] . '_category';
+ if (\Phpcmf\Service::M()->is_table_exists($table)) {
+ if (!\Phpcmf\Service::M()->db->fieldExists('disabled', $table)) {
+ \Phpcmf\Service::M('table')->add_field($table, 'disabled', 'tinyint(1)', 'DEFAULT \'0\'', '');
+ \Phpcmf\Service::M()->query('UPDATE `' . $table . '` SET `disabled` = 0');
+ }
+ \Phpcmf\Service::M()->query('UPDATE `' . $table . '` SET `disabled` = 0 WHERE `disabled` IS NULL ');
+ if (!\Phpcmf\Service::M()->db->fieldExists('ismain', $table)) {
+ \Phpcmf\Service::M('table')->add_field($table, 'ismain', 'tinyint(1)', 'DEFAULT \'0\'', '');
+ \Phpcmf\Service::M()->query('UPDATE `' . $table . '` SET `ismain` = 1');
+ }
+ }
+ // 鏍忕洰妯″瀷瀛楁淇
+ \Phpcmf\Service::M()->db->table('field')->where('relatedname', $m['dirname'] . '-' . $siteid)->update(['relatedname' => 'catmodule-' . $m['dirname']]);
+ // 鏃犵鍙蜂慨姝
+ //\Phpcmf\Service::M()->query('ALTER TABLE `'.$prefix.$siteid.'_'.$m['dirname'].'` CHANGE `updatetime` `updatetime` INT(10) NOT NULL COMMENT \'鏇存柊鏃堕棿\'');
+ //\Phpcmf\Service::M()->query('ALTER TABLE `'.$prefix.$siteid.'_'.$m['dirname'].'` CHANGE `inputtime` `inputtime` INT(10) NOT NULL COMMENT \'鏇存柊鏃堕棿\'');
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Config/Version.php b/dayrui/App/Cms/Config/Version.php
new file mode 100644
index 0000000..6134da3
--- /dev/null
+++ b/dayrui/App/Cms/Config/Version.php
@@ -0,0 +1,14 @@
+ '928',
+ 'version' => '4.1',
+ 'license' => '00000000000000000',
+ 'updatetime' => '2023-3-1',
+
+];
\ No newline at end of file
diff --git a/dayrui/App/Cms/Controllers/Admin/Admin_verify.php b/dayrui/App/Cms/Controllers/Admin/Admin_verify.php
new file mode 100644
index 0000000..0ae988d
--- /dev/null
+++ b/dayrui/App/Cms/Controllers/Admin/Admin_verify.php
@@ -0,0 +1,137 @@
+assign([
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '瀹℃牳娴佺▼' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-sort-numeric-asc'],
+ '娣诲姞' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/add', 'fa fa-plus'],
+ '淇敼' => ['hide:'.APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/edit', 'fa fa-edit'],
+ 'help' => ['825'],
+ ]
+ ),
+ 'is_vip' => is_file(IS_USE_MODULE.'/Models/Verify.php'),
+ ]);
+ // 鏀寔闄勮〃瀛樺偍
+ $this->is_data = 0;
+ $this->my_field = array(
+ 'name' => array(
+ 'ismain' => 1,
+ 'name' => dr_lang('鍚嶇О'),
+ 'fieldname' => 'name',
+ 'fieldtype' => 'Text',
+ 'setting' => array(
+ 'option' => array(
+ 'width' => 200,
+ ),
+ 'validate' => array(
+ 'required' => 1,
+ )
+ )
+ ),
+ );
+ // url鏄剧ず鍚嶇О
+ $this->name = dr_lang('瀹℃牳娴佺▼');
+ // 鍒濆鍖栨暟鎹〃
+ $this->_init([
+ 'table' => 'admin_verify',
+ 'field' => $this->my_field,
+ 'order_by' => 'id desc',
+ ]);
+ $this->role = \Phpcmf\Service::M('Auth')->get_role_all();
+ }
+
+ // 鍚庡彴鏌ョ湅url鍒楄〃
+ public function index() {
+
+ $this->_List([], -1);
+ \Phpcmf\Service::V()->display('verify_index.html');
+ }
+
+ // 鍚庡彴娣诲姞url鍐呭
+ public function add() {
+ $this->_Post(0);
+ \Phpcmf\Service::V()->display('verify_add.html');
+ }
+
+ // 鍚庡彴淇敼url鍐呭
+ public function edit() {
+ $this->_Post(intval(\Phpcmf\Service::L('input')->get('id')));
+ \Phpcmf\Service::V()->display('verify_add.html');
+ }
+
+ // 澶嶅埗
+ public function copy_edit() {
+
+ $id = intval(\Phpcmf\Service::L('input')->get('id'));
+ $data = \Phpcmf\Service::M()->db->table('admin_verify')->where('id', $id)->get()->getRowArray();
+ if (!$data) {
+ $this->_json(0, dr_lang('鏁版嵁#%s涓嶅瓨鍦', $id));
+ }
+
+ unset($data['id']);
+ $data['name'].= '_copy';
+
+ $rt = \Phpcmf\Service::M()->table('admin_verify')->insert($data);
+ if (!$rt['code']) {
+ $this->_json(0, dr_lang($rt['msg']));
+ }
+
+ \Phpcmf\Service::M('cache')->sync_cache('');
+ $this->_json(1, dr_lang('澶嶅埗鎴愬姛'));
+ }
+
+
+ // 淇濆瓨
+ protected function _Save($id = 0, $data = [], $old = [], $func = null, $func2 = null) {
+ return parent::_Save($id, $data, $old, function($id, $data){
+ // 淇濆瓨鍓嶇殑鏍煎紡鍖
+ $value = \Phpcmf\Service::L('input')->post('value');
+ if ($value['role']) {
+ foreach ($value['role'] as $i => $ids) {
+ if (!$ids) {
+ unset($value['role'][$i]);
+ }
+ }
+ }
+ $data[1]['verify'] = dr_array2string($value);
+ return dr_return_data(1, 'ok', $data);
+ }, function ($id, $data, $old) {
+
+ \Phpcmf\Service::M('cache')->sync_cache('');
+ });
+ }
+
+ /**
+ * 鑾峰彇鍐呭
+ * $id 鍐呭id,鏂板涓0
+ * */
+ protected function _Data($id = 0) {
+
+ $data = parent::_Data($id);
+ $data['value'] = dr_string2array($data['verify']);
+ return $data;
+ }
+
+ // 鍚庡彴鍒犻櫎url鍐呭
+ public function del() {
+ $this->_Del(
+ \Phpcmf\Service::L('input')->get_post_ids(),
+ null,
+ function ($r) {
+ \Phpcmf\Service::M('cache')->sync_cache('');
+ }
+ );
+ }
+
+}
diff --git a/dayrui/App/Cms/Controllers/Admin/Api.php b/dayrui/App/Cms/Controllers/Admin/Api.php
new file mode 100644
index 0000000..90f2c35
--- /dev/null
+++ b/dayrui/App/Cms/Controllers/Admin/Api.php
@@ -0,0 +1,194 @@
+ $value) {
+ $this->$var = $value;
+ }
+ }
+ }
+
+ // 缁熻
+ public function mtotal() {
+
+ $t1 = $t2 = $t3 = $t4 = $t5 = 0;
+ $dir = dr_safe_filename(\Phpcmf\Service::L('input')->get('dir'));
+ $prefix = dr_module_table_prefix($dir);
+ if (is_dir(dr_get_app_dir($dir))) {
+ $this->_module_init($dir);
+ $t1 = \Phpcmf\Service::M()->table($prefix)->where($this->content_model->get_admin_list_where($prefix))->where('DATEDIFF(from_unixtime(inputtime),now())=0')->counts();
+ $t2 = \Phpcmf\Service::M()->table($prefix)->where($this->content_model->get_admin_list_where($prefix))->counts();
+ $t3 = \Phpcmf\Service::M()->table($prefix.'_verify')->where($this->content_model->get_admin_list_verify_where($this->content_model->get_admin_list_where($prefix.'_verify')))->counts();
+ $t4 = \Phpcmf\Service::M()->table($prefix.'_recycle')->where($this->content_model->get_admin_list_where($prefix.'_recycle'))->counts();
+ $t5 = \Phpcmf\Service::M()->table($prefix.'_time')->where($this->content_model->get_admin_list_where($prefix.'_time'))->counts();
+ }
+ echo '$("#'.$dir.'_today").html('.$t1.');';
+ echo '$("#'.$dir.'_all").html('.$t2.');';
+ echo '$("#'.$dir.'_verify").html('.$t3.');';
+ echo '$("#'.$dir.'_recycle").html('.$t4.');';
+ echo '$("#'.$dir.'_timing").html('.$t5.');';
+ exit;
+ }
+
+ // 鏇存柊url
+ public function update_url() {
+
+ $mid = dr_safe_filename(\Phpcmf\Service::L('input')->get('mid'));
+ if (!$mid) {
+ $this->_html_msg(0, dr_lang('mid鍙傛暟涓嶈兘涓虹┖'));
+ }
+
+ $this->_module_init($mid);
+
+ $page = (int)\Phpcmf\Service::L('input')->get('page');
+ $total = (int)\Phpcmf\Service::L('input')->get('total');
+
+ if (!$page) {
+ // 璁$畻鏁伴噺
+ $total = \Phpcmf\Service::M()->db->table($this->content_model->mytable)->countAllResults();
+ if (!$total) {
+ $this->_html_msg(0, dr_lang('鏃犲彲鐢ㄥ唴瀹规洿鏂'));
+ }
+
+ $url = dr_url('module/api/'.\Phpcmf\Service::L('Router')->method, ['mid' => $mid]);
+ $this->_html_msg(1, dr_lang('姝e湪鎵ц涓...'), $url.'&total='.$total.'&page='.($page+1));
+ }
+
+ $psize = 300; // 姣忛〉澶勭悊鐨勬暟閲
+ if (isset($this->module['setting']['update_psize'])) {
+ $psize = max((int)$this->module['setting']['update_psize'], 100);
+ }
+
+ $tpage = ceil($total / $psize); // 鎬婚〉鏁
+
+ // 鏇存柊瀹屾垚
+ if ($page > $tpage) {
+ \Phpcmf\Service::M('cache')->update_data_cache();
+ $this->_html_msg(1, dr_lang('鏇存柊瀹屾垚'));
+ }
+
+ $update = [];
+ $data = \Phpcmf\Service::M()->db->table($this->content_model->mytable)->limit($psize, $psize * ($page - 1))->orderBy('id DESC')->get()->getResultArray();
+ foreach ($data as $t) {
+ if ($t['link_id'] && $t['link_id'] >= 0) {
+ // 鍚屾鏍忕洰鐨勬暟鎹
+ $i = $t['id'];
+ $t = \Phpcmf\Service::M()->db->table($this->content_model->mytable)->where('id', (int)$t['link_id'])->get()->getRowArray();
+ if (!$t) {
+ continue;
+ }
+ $url = \Phpcmf\Service::L('Router')->show_url($this->module, $t);
+ $t['id'] = $i; // 鏇挎崲鎴愬綋鍓峣d
+ } else {
+ $url = \Phpcmf\Service::L('Router')->show_url($this->module, $t);
+ }
+ $t['url'] != $url && $update[] = [
+ 'id' => (int)$t['id'],
+ 'url'=> $url,
+ ];
+ }
+ $update && \Phpcmf\Service::M()->table($this->content_model->mytable)->update_batch($update);
+
+ $this->_html_msg( 1, dr_lang('姝e湪鎵ц涓%s銆...', "$tpage/$page"),
+ dr_url('module/api/'.\Phpcmf\Service::L('Router')->method, ['mid' => $mid,'total' => $total, 'page' => $page + 1])
+ );
+ }
+
+ // 缁熻鏍忕洰
+ public function ctotal() {
+
+ $rt = '';
+ if (IS_POST) {
+ $ids = dr_string2array(\Phpcmf\Service::L('input')->post('cid'));
+ if ($ids) {
+ foreach ($ids as $t) {
+ list($id, $mid) = explode('-', $t);
+ if ($id && $mid && dr_is_module($mid) ) {
+ $db = \Phpcmf\Service::M()->table(dr_module_table_prefix($mid).'_index');
+ $mod = $this->get_cache('module-'.SITE_ID.'-'.$mid);
+ if ($mod['category'][$id]['childids']) {
+ $db->where('catid in ('.$mod['category'][$id]['childids'].')');
+ } else {
+ $db->where('catid', $id);
+ }
+ $num = $db->where('status=9')->counts();
+ if ($num) {
+ $rt.= '$(".cat-total-'.$id.'").html("'.dr_lang('锛堢害%s锛', $num).'");';
+ }
+ }
+ }
+ }
+ }
+
+ $this->_json(1, $rt);
+ }
+
+ // 鏇存柊鏍忕洰缂撳瓨閰嶇疆
+ public function update_category_repair() {
+
+ $mid = dr_safe_filename(\Phpcmf\Service::L('input')->get('mid'));
+ if (!$mid) {
+ $cdir = 'share';
+ } else {
+ $cdir = $mid;
+ }
+ if (\Phpcmf\Service::M()->table(SITE_ID.'_'.$cdir.'_category')->counts() > MAX_CATEGORY) {
+ \Phpcmf\Service::M('module')->update_category_cache(SITE_ID, $cdir);
+ }
+
+ \Phpcmf\Service::M('cache')->sync_cache();
+
+ $this->_html_msg(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ public function update_category_cache() {
+
+ $mid = dr_safe_filename(\Phpcmf\Service::L('input')->get('mid'));
+ if (!$mid) {
+ $cdir = 'share';
+ } else {
+ $cdir = $mid;
+ }
+
+ \Phpcmf\Service::M('module')->update_category_cache(SITE_ID, $cdir);
+ \Phpcmf\Service::M('cache')->sync_cache();
+
+ dr_dir_delete(WRITEPATH.'module/category-'.SITE_ID.'-'.$cdir.'-child');
+ dr_dir_delete(WRITEPATH.'module/category-'.SITE_ID.'-'.$cdir.'-data');
+ dr_dir_delete(WRITEPATH.'module/category-'.SITE_ID.'-'.$cdir.'-min');
+ dr_dir_delete(WRITEPATH.'module/category-'.SITE_ID.'-'.$cdir.'-main');
+ dr_dir_delete(WRITEPATH.'module/category-'.SITE_ID.'-'.$cdir.'-select');
+ dr_dir_delete(WRITEPATH.'module/category-'.SITE_ID.'-share-select');
+
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ // 鏌ョ湅瀹℃牳娴佺▼
+ public function verify() {
+
+ $id = intval(\Phpcmf\Service::L('input')->get('id'));
+ if (!$id) {
+ $this->_json(0, dr_lang('瀹℃牳娴佺▼id涓嶅瓨鍦'));
+ }
+
+ $data = \Phpcmf\Service::M()->db->table('admin_verify')->where('id', $id)->get()->getRowArray();
+ if (!$data) {
+ $this->_json(0, dr_lang('鏁版嵁#%s涓嶅瓨鍦', $id));
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'role' => \Phpcmf\Service::M('Auth')->get_role_all(),
+ 'value' => dr_string2array($data['verify']),
+ ]);
+ \Phpcmf\Service::V()->display('verify_show.html');exit;
+ }
+
+}
diff --git a/dayrui/App/Cms/Controllers/Admin/Auth.php b/dayrui/App/Cms/Controllers/Admin/Auth.php
new file mode 100644
index 0000000..691b0d1
--- /dev/null
+++ b/dayrui/App/Cms/Controllers/Admin/Auth.php
@@ -0,0 +1,981 @@
+_admin_msg(0, dr_lang('鏈畨瑁呯敤鎴风郴缁燂紝鏃犳硶璁剧疆鍐呭鏉冮檺'));
+ }
+ }
+
+ // 褰撳墠鍙厤缃殑鍐呭妯″潡
+ protected function _content_modules() {
+ $module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content');
+ if (!$module) {
+ return [];
+ }
+ foreach ($module as $dir => $t) {
+ if ($t['hlist'] == 1) {
+ unset($module[$dir]);
+ }
+ }
+ return $module;
+ }
+
+ // 鏋勫缓鐢ㄦ埛缁 / 绛夌骇鍒
+ protected function _auth_columns($auth_type) {
+
+ $group = [
+ 0 => [
+ 'id' => 0,
+ 'name' => dr_lang('娓稿'),
+ 'use' => 1,
+ ]
+ ];
+ foreach ($this->member_cache['group'] as $t) {
+ $group[$t['id']] = [
+ 'id' => $t['id'],
+ 'name' => dr_lang($t['name']),
+ 'use' => 1,
+ ];
+ }
+
+ $level = [
+ 0 => [
+ 'id' => 0,
+ 'name' => dr_lang('娓稿'),
+ 'group_name' => '',
+ 'level_name' => dr_lang('娓稿'),
+ 'use' => 1,
+ ]
+ ];
+ foreach ($this->member_cache['group'] as $t) {
+ $gname = dr_lang($t['name']);
+ $level[$t['id']] = [
+ 'id' => $t['id'],
+ 'name' => $gname,
+ 'group_name' => '',
+ 'level_name' => $gname,
+ 'use' => 1,
+ ];
+ if ($t['level']) {
+ foreach ($t['level'] as $lv) {
+ $lname = dr_lang($lv['name']);
+ $level[$t['id'].'-'.$lv['id']] = [
+ 'id' => $t['id'].'-'.$lv['id'],
+ 'name' => $gname.' / '.$lname,
+ 'group_name' => $gname,
+ 'level_name' => $lname,
+ 'use' => 1,
+ ];
+ $level[$t['id']]['use'] = 0;
+ }
+ }
+ }
+
+ if ($auth_type == 1) {
+ return $group;
+ }
+ if ($auth_type == 2) {
+ $columns = [];
+ foreach ($level as $i => $t) {
+ if ($t['use']) {
+ $columns[$i] = $t;
+ }
+ }
+ return $columns;
+ }
+ return [
+ 'public' => [
+ 'id' => 'public',
+ 'name' => dr_lang('鍏ㄥ眬'),
+ 'use' => 1,
+ ]
+ ];
+ }
+
+ protected function _get_auth_row($auth_data, $aid) {
+ $key = (string)$aid;
+ if (isset($auth_data[$aid]) && is_array($auth_data[$aid])) {
+ return $auth_data[$aid];
+ }
+ if (isset($auth_data[$key]) && is_array($auth_data[$key])) {
+ return $auth_data[$key];
+ }
+ return [];
+ }
+
+ protected function _get_post_row($post, $aid) {
+ $key = (string)$aid;
+ if (isset($post[$aid]) && is_array($post[$aid])) {
+ return $post[$aid];
+ }
+ if (isset($post[$key]) && is_array($post[$key])) {
+ return $post[$key];
+ }
+ return [];
+ }
+
+ // 鏈嬀閫夌殑 checkbox 涓嶄細鍑虹幇鍦 POST 涓紝鏄惧紡鍐欐垚 0锛岄伩鍏嶅叧闂獙璇佺爜绛夋棤鏁
+ protected function _normalize_category_auth_flags($auth) {
+ if (!is_array($auth)) {
+ $auth = [];
+ }
+ foreach (['show', 'add', 'edit', 'del', 'code'] as $f) {
+ $auth[$f] = empty($auth[$f]) ? 0 : 1;
+ }
+ return $auth;
+ }
+
+ // 琛ㄥご锛氱敤鎴风粍 / 绛夌骇鍒
+ protected function _auth_thead_html($columns) {
+ $html = ''.dr_lang('鏉冮檺椤').' ';
+ foreach ($columns as $aid => $col) {
+ $key = (string)$aid;
+ if ($key === '0') {
+ $title = ''.htmlspecialchars((string)$col['name']).' ';
+ } elseif (!empty($col['group_name'])) {
+ $title = ''.htmlspecialchars((string)$col['group_name']).' '
+ .''.htmlspecialchars((string)$col['level_name']).' ';
+ } else {
+ $title = htmlspecialchars((string)$col['name']);
+ }
+ $html .= ''.$title.' ';
+ }
+ return $html;
+ }
+
+ protected function _auth_form_switch($label, $input_name, $checked, $help = '') {
+ $html = '';
+ return $html;
+ }
+
+ protected function _auth_matrix_wrap($thead, $tbody) {
+ return '';
+ }
+
+ // 鏍忕洰鏉冮檺寮圭獥鎸夐挳
+ protected function _auth_category_btn($aid, $page, $title, $btn_class = 'btn blue btn-xs', $btn_text = '') {
+ $url = dr_url('cms/auth/add', ['aid' => $aid, 'page' => $page]);
+ $js_title = str_replace(["\\", "'"], ["\\\\", "\\'"], (string)$title);
+ if ($btn_text === '') {
+ $btn_text = dr_lang('璁剧疆');
+ }
+ return ''
+ .' '.$btn_text
+ .' ';
+ }
+
+ // 鏍忕洰鏉冮檺鍏ュ彛锛堝叏灞琛ㄥ崟锛
+ protected function _auth_category_form($columns, $page = 'cms') {
+ $aid = 'public';
+ $name = dr_lang('鍏ㄥ眬');
+ foreach ($columns as $k => $col) {
+ $aid = (string)$k;
+ $name = (string)$col['name'];
+ break;
+ }
+ return '';
+ }
+
+ // 鏍忕洰鏉冮檺鐭╅樀琛
+ protected function _auth_category_row($columns, $page = 'cms') {
+ $html = ''.dr_lang('鏍忕洰鏉冮檺').' ';
+ foreach ($columns as $aid => $col) {
+ $key = (string)$aid;
+ $html .= ''
+ .$this->_auth_category_btn($key, $page, dr_lang('[%s]鏍忕洰鏉冮檺', $col['name']))
+ .' ';
+ }
+ $html .= ' ';
+ return $html;
+ }
+
+ public function index() {
+
+ $v = \Phpcmf\Service::M()->db->table('member_setting')->where('name', 'auth_type')->get()->getRowArray();
+ $auth_type = intval($v['value']);
+ $columns = $this->_auth_columns($auth_type);
+ $modules = $this->_content_modules();
+
+ $row = \Phpcmf\Service::M()->db->table('member_setting')->where('name', 'auth2')->get()->getRowArray();
+ $value = $row ? dr_string2array($row['value']) : [];
+ if (!is_array($value)) {
+ $value = [];
+ }
+ $auth_data = isset($value[SITE_ID]) && is_array($value[SITE_ID]) ? $value[SITE_ID] : [];
+
+ if (IS_AJAX_POST) {
+
+ $post = \Phpcmf\Service::L('input')->post('data');
+ if (!is_array($post)) {
+ $post = [];
+ }
+
+ foreach ($columns as $aid => $col) {
+ $old = $this->_get_auth_row($auth_data, $aid);
+ $post_row = $this->_get_post_row($post, $aid);
+
+ $home = isset($old['home']) && is_array($old['home']) ? $old['home'] : [];
+ $home['show'] = empty($post_row['home']['show']) ? 0 : 1;
+ $old['home'] = $home;
+
+ $mod = isset($old['module']) && is_array($old['module']) ? $old['module'] : [];
+ foreach ($modules as $mid => $m) {
+ if (!isset($mod[$mid]) || !is_array($mod[$mid])) {
+ $mod[$mid] = [];
+ }
+ $mod[$mid]['show'] = empty($post_row['module'][$mid]['show']) ? 0 : 1;
+ $mod[$mid]['search'] = empty($post_row['module'][$mid]['search']) ? 0 : 1;
+ }
+ $old['module'] = $mod;
+
+ $auth_data[$aid] = $old;
+ }
+
+ $value[SITE_ID] = $auth_data;
+ \Phpcmf\Service::M()->db->table('member_setting')->replace([
+ 'name' => 'auth2',
+ 'value' => dr_array2string($value)
+ ]);
+ \Phpcmf\Service::M('cache')->sync_cache('member');
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ $is_single = dr_count($columns) <= 1;
+ $page = \Phpcmf\Service::L('input')->get('page');
+ if (!$page) {
+ $page = 'site';
+ }
+ if ($page !== 'site' && !isset($modules[$page])) {
+ $page = 'site';
+ }
+
+ $tabs = [];
+
+ // 鈥斺 鏁寸珯 鈥斺
+ $site_html = '';
+ if ($is_single) {
+ $aid = 'public';
+ foreach ($columns as $k => $col) {
+ $aid = (string)$k;
+ break;
+ }
+ $data = $this->_get_auth_row($auth_data, $aid);
+ $aid_attr = htmlspecialchars($aid);
+ $site_html .= $this->_auth_form_switch(
+ dr_lang('绂佹鏁寸珯璁块棶'),
+ 'data['.$aid_attr.'][home][show]',
+ !empty($data['home']['show']),
+ dr_lang('閽堝鏁翠釜缃戠珯鐨勫墠绔晫闈㈣闂潈闄')
+ );
+ $site_html .= $this->_auth_category_form($columns, 'cms');
+ } else {
+ $tbody = ''.dr_lang('绂佹鏁寸珯璁块棶').' ';
+ foreach ($columns as $aid => $col) {
+ $key = (string)$aid;
+ $data = $this->_get_auth_row($auth_data, $aid);
+ $checked = !empty($data['home']['show']) ? ' checked' : '';
+ $tbody .= ''
+ .' '
+ .' ';
+ }
+ $tbody .= ' ';
+ $tbody .= $this->_auth_category_row($columns, 'cms');
+ $site_html .= $this->_auth_matrix_wrap($this->_auth_thead_html($columns), $tbody);
+ }
+ $tabs['site'] = [
+ 'id' => 'site',
+ 'name' => dr_lang('鏁寸珯'),
+ 'dirname' => '',
+ 'icon' => 'fa fa-globe',
+ 'html' => $site_html,
+ ];
+
+ // 鈥斺 鍚勫唴瀹规ā鍧 鈥斺
+ foreach ($modules as $mid => $m) {
+ $mname = dr_lang($m['name']);
+ $icon = !empty($m['icon']) ? $m['icon'] : 'fa fa-folder';
+ $mod_html = '';
+ if ($is_single) {
+ $aid = 'public';
+ foreach ($columns as $k => $col) {
+ $aid = (string)$k;
+ break;
+ }
+ $data = $this->_get_auth_row($auth_data, $aid);
+ $aid_attr = htmlspecialchars($aid);
+ $mid_attr = htmlspecialchars($mid);
+ $mod_html .= $this->_auth_form_switch(
+ dr_lang('绂佹璁块棶'),
+ 'data['.$aid_attr.'][module]['.$mid_attr.'][show]',
+ !empty($data['module'][$mid]['show']),
+ dr_lang('绂佹鍚庢棤娉曡闂湰妯″潡鍓嶅彴')
+ );
+ $mod_html .= $this->_auth_form_switch(
+ dr_lang('绂佹鎼滅储'),
+ 'data['.$aid_attr.'][module]['.$mid_attr.'][search]',
+ !empty($data['module'][$mid]['search']),
+ dr_lang('绂佹鍚庢棤娉曚娇鐢ㄦ湰妯″潡鎼滅储')
+ );
+ if (empty($m['share'])) {
+ $mod_html .= $this->_auth_category_form($columns, $mid);
+ } else {
+ $mod_html .= '';
+ }
+ } else {
+ $tbody = '';
+ $tbody .= ''.dr_lang('绂佹璁块棶').' ';
+ foreach ($columns as $aid => $col) {
+ $key = (string)$aid;
+ $data = $this->_get_auth_row($auth_data, $aid);
+ $checked = !empty($data['module'][$mid]['show']) ? ' checked' : '';
+ $tbody .= ''
+ .' '
+ .' ';
+ }
+ $tbody .= ' ';
+ $tbody .= ''.dr_lang('绂佹鎼滅储').' ';
+ foreach ($columns as $aid => $col) {
+ $key = (string)$aid;
+ $data = $this->_get_auth_row($auth_data, $aid);
+ $checked = !empty($data['module'][$mid]['search']) ? ' checked' : '';
+ $tbody .= ''
+ .' '
+ .' ';
+ }
+ $tbody .= ' ';
+ if (empty($m['share'])) {
+ $tbody .= $this->_auth_category_row($columns, $mid);
+ }
+ $mod_html .= $this->_auth_matrix_wrap($this->_auth_thead_html($columns), $tbody);
+ if (!empty($m['share'])) {
+ $mod_html .= ''
+ .dr_lang('鏈ā鍧椾娇鐢ㄥ叡浜爮鐩紝璇峰埌銆屾暣绔欍嶄腑璁剧疆鏍忕洰鏉冮檺')
+ .'
';
+ }
+ }
+ $tabs[$mid] = [
+ 'id' => $mid,
+ 'name' => $mname,
+ 'dirname' => $mid,
+ 'icon' => $icon,
+ 'html' => $mod_html,
+ ];
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '鍐呭鏉冮檺' => ['cms/auth/index', 'fa fa-table'],
+ 'help' => [801],
+ ]
+ ),
+ 'auth_type' => $auth_type,
+ 'page' => $page,
+ 'tabs' => $tabs,
+ ]);
+ \Phpcmf\Service::V()->display('auth_index.html');
+ }
+
+ // 瀛樺偍妯″紡鍊
+ public function save_edit() {
+
+ $value = intval(\Phpcmf\Service::L('input')->get('value'));
+ if (!$value) {
+ $msg = dr_lang('宸插垏鎹㈣嚦鎸夊叏灞閰嶇疆妯″紡');
+ } elseif ($value == 1) {
+ $msg = dr_lang('宸插垏鎹㈣嚦鎸夌敤鎴风粍閰嶇疆妯″紡');
+ } elseif ($value == 2) {
+ $msg = dr_lang('宸插垏鎹㈣嚦鎸夌敤鎴风粍绛夌骇閰嶇疆妯″紡');
+ } else {
+ $this->_json(0, dr_lang('鏈煡妯″紡'));
+ }
+
+ \Phpcmf\Service::M()->db->table('member_setting')->replace([
+ 'name' => 'auth_type',
+ 'value' => $value
+ ]);
+ \Phpcmf\Service::M('cache')->sync_cache('member');
+
+ $this->_json(1, $msg);
+ }
+
+ // 鍒濆鍖栫粍鏉冮檺锛堜粎娓呯┖鍐呭鐩稿叧閰嶇疆锛屼繚鐣欑敤鎴锋潈闄愶級
+ public function init_edit() {
+
+ $v = \Phpcmf\Service::M()->db->table('member_setting')->where('name', 'auth2')->get()->getRowArray();
+ $aid = \Phpcmf\Service::L('input')->get('aid');
+ if ($aid === null || $aid === false || $aid === '') {
+ $this->_json(0, dr_lang('鍙傛暟閿欒'));
+ }
+ if ($aid !== 'public' && $aid !== '0' && $aid !== 0
+ && !preg_match('/^\d+(-\d+)?$/', (string)$aid)) {
+ $this->_json(0, dr_lang('鍙傛暟閿欒'));
+ }
+ $value = $v ? dr_string2array($v['value']) : [];
+ if (!is_array($value)) {
+ $value = [];
+ }
+ $old = isset($value[SITE_ID][$aid]) && is_array($value[SITE_ID][$aid]) ? $value[SITE_ID][$aid] : [];
+ if (!$old && is_numeric($aid) && isset($value[SITE_ID][intval($aid)]) && is_array($value[SITE_ID][intval($aid)])) {
+ $old = $value[SITE_ID][intval($aid)];
+ }
+ $keep = [];
+ if (isset($old['member'])) {
+ $keep['member'] = $old['member'];
+ }
+ if (isset($old['app'])) {
+ $keep['app'] = $old['app'];
+ }
+ $value[SITE_ID][$aid] = $keep;
+
+ \Phpcmf\Service::M()->db->table('member_setting')->replace([
+ 'name' => 'auth2',
+ 'value' => dr_array2string($value)
+ ]);
+ \Phpcmf\Service::M('cache')->sync_cache('member');
+
+ $this->_json(1, dr_lang('鏈粍鍐呭鏉冮檺鍒濆鍖栧畬鎴'));
+ }
+
+ // 鏍忕洰绛夎缁嗘潈闄愯缃
+ public function add() {
+
+ $aid = \Phpcmf\Service::L('input')->get('aid');
+ if ($aid == 'public') {
+ $name = dr_lang('鍏ㄥ眬');
+ } elseif (!$aid && $aid !== '0' && $aid !== 0) {
+ $aid = 0;
+ $name = dr_lang('娓稿');
+ } elseif (strpos((string)$aid, '-') !== false) {
+ list($gid, $lid) = explode('-', $aid);
+ if (!$this->member_cache['group'][$gid]) {
+ $this->_admin_msg(0, dr_lang('姝ょ敤鎴风粍涓嶅瓨鍦'));
+ } elseif (!$this->member_cache['group'][$gid]['level'][$lid]) {
+ $this->_admin_msg(0, dr_lang('姝ょ敤鎴风粍绛夌骇涓嶅瓨鍦'));
+ }
+ $name = $this->member_cache['group'][$gid]['name'].'-'.$this->member_cache['group'][$gid]['level'][$lid]['name'];
+ } else {
+ if ($aid !== '0' && $aid !== 0 && !$this->member_cache['group'][$aid]) {
+ $this->_admin_msg(0, dr_lang('姝ょ敤鎴风粍涓嶅瓨鍦'));
+ }
+ $name = ($aid === '0' || $aid === 0) ? dr_lang('娓稿') : $this->member_cache['group'][$aid]['name'];
+ }
+
+ // 鍏变韩鏍忕洰
+ $share_module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-share');
+ $share_categroy = [];
+ if (is_file(dr_get_app_dir('module').'Libraries/Category.php')) {
+ $share_module['category'] = \Phpcmf\Service::L('category', 'module')->get_category('share');
+ }
+ if ($share_module['category']) {
+ foreach ($share_module['category'] as $t) {
+ if ($t['tid'] != 2) {
+ $t['is_post'] = 0;
+ if (!$t['child'] && $t['tid'] == 1) {
+ $t['is_post'] = 1;
+ }
+ $share_categroy[$t['id']] = $t;
+ }
+ }
+ }
+
+ // 妯″潡閮ㄥ垎
+ $module = $this->_content_modules();
+ if ($module) {
+ foreach ($module as $dir => $t) {
+ if (is_file(dr_get_app_dir('module').'Libraries/Category.php')) {
+ $module[$dir]['category'] = \Phpcmf\Service::L('tree', 'module')
+ ->init(\Phpcmf\Service::L('category', 'module')->get_category($dir))
+ ->html_icon()->get_tree_array(0);
+ } else {
+ $module[$dir]['category'] = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-'.$dir, 'category');
+ }
+ }
+ }
+
+ $v = \Phpcmf\Service::M()->db->table('member_setting')->where('name', 'auth2')->get()->getRowArray();
+ $value = $v ? dr_string2array($v['value']) : [];
+ if (!is_array($value)) {
+ $value = [];
+ }
+ $data = isset($value[SITE_ID][$aid]) && is_array($value[SITE_ID][$aid]) ? $value[SITE_ID][$aid] : [];
+ $auth = [
+ 'share_category' => is_array($data['share_category_public'] ?? null) ? $data['share_category_public'] : [],
+ 'category' => is_array($data['category_public'] ?? null) ? $data['category_public'] : [],
+ ];
+
+ if (IS_AJAX_POST) {
+
+ $post = \Phpcmf\Service::L('input')->post('data');
+ if (!is_array($post)) {
+ $post = [];
+ }
+ $save = $data;
+
+ // 鏍忕洰妯″紡涓庣粺涓鏍忕洰鏉冮檺
+ if (isset($post['home']['is_category'])) {
+ if (!isset($save['home']) || !is_array($save['home'])) {
+ $save['home'] = [];
+ }
+ $save['home']['is_category'] = empty($post['home']['is_category']) ? 0 : 1;
+ }
+ $share_public = \Phpcmf\Service::L('input')->post('share_category');
+ if (is_array($share_public)) {
+ $save['share_category_public'] = $this->_normalize_category_auth_flags($share_public);
+ }
+ $cat_public = \Phpcmf\Service::L('input')->post('category');
+ if (is_array($cat_public)) {
+ if (!isset($save['category_public']) || !is_array($save['category_public'])) {
+ $save['category_public'] = [];
+ }
+ foreach ($cat_public as $cmid => $crow) {
+ // 妯℃澘閲岀殑 hidden test 瀛楁涓嶇畻鏉冮檺閰嶇疆
+ if (!is_array($crow) || (dr_count($crow) === 1 && isset($crow['test']))) {
+ continue;
+ }
+ $save['category_public'][$cmid] = $this->_normalize_category_auth_flags($crow);
+ }
+ }
+ if (isset($post['module']) && is_array($post['module'])) {
+ if (!isset($save['module']) || !is_array($save['module'])) {
+ $save['module'] = [];
+ }
+ foreach ($post['module'] as $mid => $row) {
+ if (!isset($save['module'][$mid]) || !is_array($save['module'][$mid])) {
+ $save['module'][$mid] = [];
+ }
+ if (isset($row['is_category'])) {
+ $save['module'][$mid]['is_category'] = empty($row['is_category']) ? 0 : 1;
+ }
+ }
+ }
+
+ // 淇濈暀鐢ㄦ埛鏉冮檺 / 搴旂敤鏉冮檺 / 璁块棶绂佹椤 / 鎸夋爮鐩嫭绔嬭缃
+ if (isset($data['member'])) {
+ $save['member'] = $data['member'];
+ }
+ if (isset($data['app'])) {
+ $save['app'] = $data['app'];
+ }
+ if (isset($data['home']['show'])) {
+ if (!isset($save['home']) || !is_array($save['home'])) {
+ $save['home'] = [];
+ }
+ $save['home']['show'] = $data['home']['show'];
+ }
+ if (isset($data['module']) && is_array($data['module'])) {
+ foreach ($data['module'] as $mid => $row) {
+ if (!isset($save['module'][$mid]) || !is_array($save['module'][$mid])) {
+ $save['module'][$mid] = [];
+ }
+ if (isset($row['show'])) {
+ $save['module'][$mid]['show'] = $row['show'];
+ }
+ if (isset($row['search'])) {
+ $save['module'][$mid]['search'] = $row['search'];
+ }
+ }
+ }
+ if (isset($data['share_category'])) {
+ $save['share_category'] = $data['share_category'];
+ }
+ if (isset($data['category'])) {
+ $save['category'] = $data['category'];
+ }
+
+ $value[SITE_ID][$aid] = $save;
+ \Phpcmf\Service::M()->db->table('member_setting')->replace([
+ 'name' => 'auth2',
+ 'value' => dr_array2string($value)
+ ]);
+ \Phpcmf\Service::M('cache')->sync_cache('member');
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ $page = trim(\Phpcmf\Service::L('input')->get('page'));
+ if (!$page) {
+ $page = 'cms';
+ }
+
+ // 寮圭獥鍙睍绀哄綋鍓嶅叆鍙e搴旂殑鏍忕洰锛堝叡浜 / 鍗曚釜妯″潡锛
+ $is_share_page = ($page === 'cms' || $page === 'site');
+ $mid = '';
+ $m = [];
+ if ($is_share_page) {
+ $page = 'cms';
+ $page_name = dr_lang('鍏变韩鏍忕洰');
+ } elseif (isset($module[$page])) {
+ $mid = $page;
+ $m = $module[$page];
+ $page_name = dr_lang($m['name']);
+ // 鍏变韩鍨嬫ā鍧楁棤鐙珛鏍忕洰锛屽洖閫鍒板叡浜爮鐩
+ if (!empty($m['share'])) {
+ $is_share_page = true;
+ $page = 'cms';
+ $mid = '';
+ $m = [];
+ $page_name = dr_lang('鍏变韩鏍忕洰');
+ }
+ } else {
+ $this->_admin_msg(0, dr_lang('妯″潡涓嶅瓨鍦'));
+ }
+
+ $verify = [];
+ if (\Phpcmf\Service::M()->is_table_exists('admin_verify')) {
+ $verify = \Phpcmf\Service::M()->table('admin_verify')->getAll();
+ }
+
+ $diy = $this->_get_diy();
+ if ($is_share_page) {
+ $diy['module'] = [];
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'aid' => $aid,
+ 'diy' => $diy,
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ dr_lang('%s锛%s鏍忕洰鏉冮檺', $name, $page_name) => ['cms/auth/add{aid='.$aid.'&page='.$page.'}', 'fa fa-table'],
+ 'help' => [801],
+ ]
+ ),
+ 'page' => $page,
+ 'page_name' => $page_name,
+ 'is_share_page' => $is_share_page,
+ 'mid' => $mid,
+ 'm' => $m,
+ 'data' => $data,
+ 'auth' => $auth,
+ 'verify' => $verify,
+ 'is_ajax_edit' => 0,
+ 'share_categroy' => \Phpcmf\Service::L('tree')->init($share_categroy)->html_icon()->get_tree_array(0),
+ ]);
+ \Phpcmf\Service::V()->display('auth_setting.html');
+ }
+
+ // 寮瑰嚭璁剧疆鍗曠嫭鏉冮檺
+ public function edit() {
+
+ $at = dr_safe_filename(\Phpcmf\Service::L('input')->get('at'));
+ if (!$at || !in_array($at, ['share_category', 'category'])) {
+ $this->_json(0, dr_lang('at鍙傛暟閿欒'));
+ }
+
+ $v = \Phpcmf\Service::M()->db->table('member_setting')->where('name', 'auth2')->get()->getRowArray();
+ $aid = \Phpcmf\Service::L('input')->get('aid');
+ !$aid && $aid !== '0' && $aid = 0;
+ $value = $v ? dr_string2array($v['value']) : [];
+ if (!is_array($value)) {
+ $value = [];
+ }
+
+ $id = intval(\Phpcmf\Service::L('input')->get('id'));
+ if (!$id) {
+ $this->_json(0, dr_lang('id鍙傛暟閿欒'));
+ }
+
+ $mid = dr_safe_filename(\Phpcmf\Service::L('input')->get('mid'));
+
+ if (IS_AJAX_POST) {
+
+ if ($at == 'category') {
+ $post = \Phpcmf\Service::L('input')->post($at);
+ $row = is_array($post[$mid] ?? null) ? $post[$mid] : [];
+ $value[SITE_ID][$aid][$at][$mid][$id] = $this->_normalize_category_auth_flags($row);
+ } else {
+ $row = \Phpcmf\Service::L('input')->post($at);
+ $value[SITE_ID][$aid][$at][$id] = $this->_normalize_category_auth_flags($row);
+ }
+
+ \Phpcmf\Service::M()->db->table('member_setting')->replace([
+ 'name' => 'auth2',
+ 'value' => dr_array2string($value)
+ ]);
+ \Phpcmf\Service::M('cache')->sync_cache('member');
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ if ($at == 'category') {
+ $auth = [$at => [$mid => $value[SITE_ID][$aid][$at][$mid][$id]]];
+ } else {
+ $auth = [$at => $value[SITE_ID][$aid][$at][$id]];
+ }
+
+ $verify = [];
+ if (\Phpcmf\Service::M()->is_table_exists('admin_verify')) {
+ $verify = \Phpcmf\Service::M()->table('admin_verify')->getAll();
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'mid' => $mid,
+ 'diy' => $this->_get_diy(),
+ 'auth' => $auth,
+ 'verify' => $verify,
+ 'is_ajax_edit' => 1,
+ ]);
+ \Phpcmf\Service::V()->display('auth_'.$at.'.html');
+ }
+
+ // 澶嶅埗鍔ㄤ綔
+ public function copy_edit() {
+
+ $id = intval(\Phpcmf\Service::L('input')->get('id'));
+ $at = dr_safe_filename(\Phpcmf\Service::L('input')->get('at'));
+ if (!$at) {
+ $this->_json(0, dr_lang('at鍙傛暟閿欒'));
+ }
+
+ $v = \Phpcmf\Service::M()->db->table('member_setting')->where('name', 'auth2')->get()->getRowArray();
+ $aid = \Phpcmf\Service::L('input')->get('aid');
+ !$aid && $aid !== '0' && $aid = 0;
+ $value = $v ? dr_string2array($v['value']) : [];
+ if (!is_array($value)) {
+ $value = [];
+ }
+
+ switch ($at) {
+
+ case 'level':
+ case 'group':
+ $group = [
+ 0 => [
+ 'id' => 0,
+ 'name' => dr_lang('娓稿'),
+ ],
+ ];
+ foreach ($this->member_cache['group'] as $t) {
+ if ($at == 'level') {
+ $group[$t['id']] = [
+ 'id' => $t['id'],
+ 'name' => dr_lang($t['name']),
+ ];
+ if ($t['level']) {
+ foreach ($t['level'] as $lv) {
+ $group[$t['id'].'-'.$lv['id']] = [
+ 'id' => $t['id'].'-'.$lv['id'],
+ 'name' => ' 鈹 '.dr_lang($lv['name']),
+ ];
+ }
+ }
+ } else {
+ $group[$t['id']] = $t;
+ }
+ }
+
+ if (IS_AJAX_POST) {
+
+ $auth = $value[SITE_ID][$aid];
+ if (!$auth) {
+ $this->_json(0, dr_lang('褰撳墠鐢ㄦ埛缁勬病鏈夐厤缃潈闄愯鍒'));
+ }
+
+ $catids = \Phpcmf\Service::L('input')->post('catid');
+ if (!$catids) {
+ $this->_json(0, dr_lang('浣犺繕娌℃湁閫夋嫨鐢ㄦ埛缁勫憿'));
+ }
+
+ $c = 0;
+ if (isset($catids[0]) && $catids[0] == 0) {
+ foreach ($group as $gid => $t) {
+ $c++;
+ $value[SITE_ID][$gid] = $auth;
+ }
+ } else {
+ foreach ($catids as $gid) {
+ $c++;
+ $value[SITE_ID][$gid] = $auth;
+ }
+ }
+
+ \Phpcmf\Service::M()->db->table('member_setting')->replace([
+ 'name' => 'auth2',
+ 'value' => dr_array2string($value)
+ ]);
+ \Phpcmf\Service::M('cache')->sync_cache('member');
+ $this->_json(1, dr_lang('鍏卞鍒%s涓敤鎴风粍', $c));
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'form' => dr_form_hidden(),
+ 'select' => \Phpcmf\Service::L('tree')->select_category(
+ $group,
+ 0,
+ 'id=\'dr_catid\' name=\'catid[]\' multiple="multiple" style="height:200px"',
+ '',
+ 0,
+ 0
+ ),
+ ]);
+ \Phpcmf\Service::V()->display('auth_copy_group.html');exit;
+
+ case 'share_category':
+ $share_module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-share');
+ if (is_file(dr_get_app_dir('module').'Libraries/Category.php')) {
+ $share_module['category'] = \Phpcmf\Service::L('category', 'module')->get_category('share');
+ }
+ if (IS_AJAX_POST) {
+
+ $auth = $value[SITE_ID][$aid]['share_category'][$id];
+ if (!$auth) {
+ $this->_json(0, dr_lang('褰撳墠鏍忕洰娌℃湁閰嶇疆鏉冮檺瑙勫垯'));
+ }
+
+ $catids = \Phpcmf\Service::L('input')->post('catid');
+ if (!$catids) {
+ $this->_json(0, dr_lang('浣犺繕娌℃湁閫夋嫨鏍忕洰鍛'));
+ }
+
+ $c = 0;
+ if (isset($catids[0]) && $catids[0] == 0) {
+ foreach ($share_module['category'] as $cid => $t) {
+ $c++;
+ $value[SITE_ID][$aid]['share_category'][$cid] = $auth;
+ }
+ } else {
+ foreach ($catids as $cid) {
+ $c++;
+ $value[SITE_ID][$aid]['share_category'][$cid] = $auth;
+ }
+ }
+
+ \Phpcmf\Service::M()->db->table('member_setting')->replace([
+ 'name' => 'auth2',
+ 'value' => dr_array2string($value)
+ ]);
+ \Phpcmf\Service::M('cache')->sync_cache('member');
+ $this->_json(1, dr_lang('鍏卞鍒%s涓爮鐩', $c));
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'form' => dr_form_hidden(),
+ 'select' => \Phpcmf\Service::L('tree')->select_category(
+ $share_module['category'],
+ 0,
+ 'id=\'dr_catid\' name=\'catid[]\' multiple="multiple" style="height:200px"',
+ dr_lang('鍏ㄩ儴鏍忕洰'),
+ 0,
+ 0
+ ),
+ ]);
+ \Phpcmf\Service::V()->display('auth_copy_category.html');exit;
+
+ case 'category':
+ $mid = dr_safe_filename(\Phpcmf\Service::L('input')->get('mid'));
+ $module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-'.$mid);
+ if (is_file(dr_get_app_dir('module').'Libraries/Category.php')) {
+ $module['category'] = \Phpcmf\Service::L('category', 'module')->get_category($mid);
+ }
+ if (IS_AJAX_POST) {
+
+ $auth = $value[SITE_ID][$aid]['category'][$mid][$id];
+ if (!$auth) {
+ $this->_json(0, dr_lang('褰撳墠鏍忕洰娌℃湁閰嶇疆鏉冮檺瑙勫垯'));
+ }
+
+ $catids = \Phpcmf\Service::L('input')->post('catid');
+ if (!$catids) {
+ $this->_json(0, dr_lang('浣犺繕娌℃湁閫夋嫨鏍忕洰鍛'));
+ }
+
+ $c = 0;
+ if (isset($catids[0]) && $catids[0] == 0) {
+ foreach ($module['category'] as $cid => $t) {
+ $c++;
+ $value[SITE_ID][$aid]['category'][$mid][$cid] = $auth;
+ }
+ } else {
+ foreach ($catids as $cid) {
+ $c++;
+ $value[SITE_ID][$aid]['category'][$mid][$cid] = $auth;
+ }
+ }
+
+ \Phpcmf\Service::M()->db->table('member_setting')->replace([
+ 'name' => 'auth2',
+ 'value' => dr_array2string($value)
+ ]);
+ \Phpcmf\Service::M('cache')->sync_cache('member');
+ $this->_json(1, dr_lang('鍏卞鍒%s涓爮鐩', $c));
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'form' => dr_form_hidden(),
+ 'select' => \Phpcmf\Service::L('category', 'module')->select(
+ $module['mid'],
+ 0,
+ 'id=\'dr_catid\' name=\'catid[]\' multiple="multiple" style="height:200px"',
+ dr_lang('鍏ㄩ儴鏍忕洰'),
+ 0,
+ 0
+ ),
+ ]);
+ \Phpcmf\Service::V()->display('auth_copy_category.html');exit;
+ }
+
+ $this->_json(0, dr_lang('鏈煡绫诲瀷'));
+ }
+
+ private function _get_diy() {
+
+ $diy = [
+ 'module' => [],
+ 'category' => [],
+ ];
+
+ $local = \Phpcmf\Service::Apps(1);
+ foreach ($local as $dir => $path) {
+ if (is_file($path.'Config/Auth.php')) {
+ $_data = require $path.'Config/Auth.php';
+ if ($_data) {
+ foreach ($_data as $key => $val) {
+ if ($val && isset($diy[$key])) {
+ foreach ($val as $file) {
+ if (is_file($path.'Views/auth/'.$file)) {
+ $diy[$key][] = [
+ 'app' => $dir,
+ 'file' => $path.'Views/auth/'.$file,
+ ];
+ } else {
+ log_message('error', '搴旂敤鎻掍欢['.$dir.']鏉冮檺妯℃澘鏂囦欢涓嶅瓨鍦細'.$path.'Views/auth/'.$file);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return $diy;
+ }
+
+}
diff --git a/dayrui/App/Cms/Controllers/Admin/Field.php b/dayrui/App/Cms/Controllers/Admin/Field.php
new file mode 100644
index 0000000..86e373b
--- /dev/null
+++ b/dayrui/App/Cms/Controllers/Admin/Field.php
@@ -0,0 +1,56 @@
+ $path) {
+ if (is_file(dr_get_app_dir($dir).'Config/App.php')) {
+ $key = strtolower($dir);
+ $cfg = require dr_get_app_dir($dir).'Config/App.php';
+ if ($cfg['type'] == 'module' || $cfg['ftype'] == 'module') {
+ if (isset($cfg['hlist']) && $cfg['hlist']) {
+ // 涓嶅湪鍒楄〃鏄剧ず
+ continue;
+ }
+ $cfg['dirname'] = $key;
+ $list[$key] = $cfg;
+ }
+ }
+ }
+
+ $my = [];
+ $module = \Phpcmf\Service::M('Module')->All(); // 搴撲腑宸插畨瑁呮ā鍧
+ if ($module) {
+ foreach ($module as $t) {
+ $dir = $t['dirname'];
+ if ($list[$dir]) {
+ $t['name'] = dr_lang($list[$dir]['name']);
+ $t['mtype'] = $list[$dir]['mtype'];
+ $t['system'] = $list[$dir]['system'];
+ $t['version'] = $list[$dir]['version'];
+ $site = dr_string2array($t['site']);
+ $t['install'] = isset($site[SITE_ID]) && $site[SITE_ID] ? 1 : 0;
+ $my[$dir] = $t;
+ unset($list[$dir]);
+ }
+ }
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'my' => $my,
+ 'list' => $list,
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '鑷畾涔夊瓧娈' => [APP_DIR.'/field/index', 'fa fa-code'],
+ ]
+ ),
+ ]);
+ \Phpcmf\Service::V()->display('field.html');
+ }
+
+
+}
diff --git a/dayrui/App/Cms/Controllers/Admin/Help.php b/dayrui/App/Cms/Controllers/Admin/Help.php
new file mode 100644
index 0000000..c7ad3bf
--- /dev/null
+++ b/dayrui/App/Cms/Controllers/Admin/Help.php
@@ -0,0 +1,62 @@
+get('page'));
+
+ \Phpcmf\Service::V()->assign([
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu([
+ '鍩虹鎿嶄綔' => [APP_DIR.'/help/index', 'fa fa-book'],
+ ]),
+ 'title' => dr_lang('寤虹珯绯荤粺 - 鍩虹鎿嶄綔'),
+ 'page' => $page,
+ ]);
+ \Phpcmf\Service::V()->display('help_index.html');
+ }
+
+ public function template() {
+
+ $page = max(0, (int)\Phpcmf\Service::L('input')->get('page'));
+
+ \Phpcmf\Service::V()->assign([
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu([
+ '妯℃澘鍒朵綔' => [APP_DIR.'/help/template', 'fa fa-code'],
+ ]),
+ 'title' => dr_lang('寤虹珯绯荤粺 - 妯℃澘鍒朵綔'),
+ 'page' => $page,
+ ]);
+ \Phpcmf\Service::V()->display('help_template.html');
+ }
+
+ public function seo() {
+
+ $page = max(0, (int)\Phpcmf\Service::L('input')->get('page'));
+
+ \Phpcmf\Service::V()->assign([
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu([
+ 'SEO鐢ㄦ硶' => [APP_DIR.'/help/seo', 'fa fa-internet-explorer'],
+ ]),
+ 'title' => dr_lang('寤虹珯绯荤粺 - SEO鐢ㄦ硶'),
+ 'page' => $page,
+ ]);
+ \Phpcmf\Service::V()->display('help_seo.html');
+ }
+
+ public function url() {
+
+ $page = max(0, (int)\Phpcmf\Service::L('input')->get('page'));
+
+ \Phpcmf\Service::V()->assign([
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu([
+ '鑷畾涔塙RL鐢ㄦ硶' => [APP_DIR.'/help/url', 'fa fa-link'],
+ ]),
+ 'title' => dr_lang('寤虹珯绯荤粺 - 鑷畾涔塙RL鐢ㄦ硶'),
+ 'page' => $page,
+ ]);
+ \Phpcmf\Service::V()->display('help_url.html');
+ }
+
+}
diff --git a/dayrui/App/Cms/Controllers/Admin/Module.php b/dayrui/App/Cms/Controllers/Admin/Module.php
new file mode 100644
index 0000000..778de15
--- /dev/null
+++ b/dayrui/App/Cms/Controllers/Admin/Module.php
@@ -0,0 +1,357 @@
+dir = dr_safe_replace(\Phpcmf\Service::L('input')->get('dir'));
+ $menu = [
+ '鍐呭妯″潡' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-cogs'],
+ '鍒涘缓妯″潡' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'_create/index', 'fa fa-plus'],
+ '妯″潡閰嶇疆' => ['hide:'.APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/edit', 'fa fa-cog'],
+ '鎺ㄨ崘浣嶉厤缃' => ['hide:'.APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/flag_edit', 'fa fa-flag'],
+ 'help' => [57]
+ ];
+ if (!IS_DEV) {
+ unset($menu['鍒涘缓妯″潡']);
+ }
+ if (strpos(\Phpcmf\Service::L('Router')->method, 'flag') !== false) {
+ $menu['help'] = [440];
+ } elseif (strpos(\Phpcmf\Service::L('Router')->method, 'edit') !== false) {
+ $menu['help'] = [1040];
+ }
+ \Phpcmf\Service::V()->assign('menu', \Phpcmf\Service::M('auth')->_admin_menu($menu));
+ }
+
+ // 瀹夎妯″潡
+ public function install() {
+
+ $dir = dr_safe_replace(\Phpcmf\Service::L('input')->get('dir'));
+ $type = (int)\Phpcmf\Service::L('input')->get('type');
+
+ if (!preg_match('/^[a-z]+$/U', $dir)) {
+ $this->_json(0, dr_lang('妯″潡鐩綍[%s]鏍煎紡涓嶆纭', $dir));
+ } elseif (\Phpcmf\Service::M('app')->is_sys_dir($dir)) {
+ $this->_json(0, dr_lang('妯″潡鐩綍[%s]鍚嶇О鏄郴缁熶繚鐣欏悕绉帮紝璇烽噸鍛藉悕', $dir));
+ }
+
+ $path = dr_get_app_dir($dir);
+ if (!is_dir($path)) {
+ $this->_json(0, dr_lang('妯″潡鐩綍[%s]涓嶅瓨鍦', $path));
+ }
+
+ // 瀵瑰綋鍓嶆ā鍧楀睘鎬у垽鏂
+ $cfg = require $path.'Config/App.php';
+ if (!$cfg) {
+ $this->_json(0, dr_lang('鏂囦欢[%s]涓嶅瓨鍦', 'App/'.ucfirst($dir).'/Config/App.php'));
+ }
+
+ $cfg['share'] = $type ? 0 : 1;
+
+ $rt = \Phpcmf\Service::M('module')->install($dir, $cfg);
+ \Phpcmf\Service::M('cache')->sync_cache(''); // 鑷姩鏇存柊缂撳瓨
+ $this->_json($rt['code'], $rt['msg'], $rt['data']);
+ }
+
+ // 鍗歌浇妯″潡
+ public function uninstall() {
+
+ $dir = dr_safe_replace(\Phpcmf\Service::L('input')->get('dir'));
+ if (!preg_match('/^[a-z]+$/U', $dir)) {
+ $this->_json(0, dr_lang('妯″潡鐩綍[%s]鏍煎紡涓嶆纭', $dir));
+ }
+
+ $path = dr_get_app_dir($dir);
+ if (!is_dir($path)) {
+ $this->_json(0, dr_lang('妯″潡鐩綍[%s]涓嶅瓨鍦', $path));
+ }
+
+ $cfg = require $path.'Config/App.php';
+ if (!$cfg) {
+ $this->_json(0, dr_lang('鏂囦欢[%s]涓嶅瓨鍦', 'App/'.ucfirst($dir).'/Config/App.php'));
+ }
+
+ $rt = \Phpcmf\Service::M('Module')->uninstall($dir, $cfg);
+ \Phpcmf\Service::M('cache')->sync_cache(''); // 鑷姩鏇存柊缂撳瓨
+ $this->_json($rt['code'], $rt['msg']);
+
+ }
+
+ // 妯″潡绠$悊
+ public function index() {
+
+ $list = [];
+ $local = \Phpcmf\Service::Apps();
+ foreach ($local as $dir => $path) {
+ if (is_file(dr_get_app_dir($dir).'Config/App.php')) {
+ $key = strtolower($dir);
+ $cfg = require dr_get_app_dir($dir).'Config/App.php';
+ if ($cfg['type'] == 'module' || $cfg['ftype'] == 'module') {
+ if (isset($cfg['hlist']) && $cfg['hlist']) {
+ // 涓嶅湪鍒楄〃鏄剧ず
+ continue;
+ }
+ $cfg['dirname'] = $key;
+ $list[$key] = $cfg;
+ }
+ }
+ }
+
+ $my = [];
+ $module = \Phpcmf\Service::M('Module')->All(); // 搴撲腑宸插畨瑁呮ā鍧
+ if ($module) {
+ foreach ($module as $t) {
+ $dir = $t['dirname'];
+ if ($list[$dir]) {
+ $t['name'] = dr_lang($list[$dir]['name']);
+ $t['mtype'] = $list[$dir]['mtype'];
+ $t['system'] = $list[$dir]['system'];
+ $t['version'] = $list[$dir]['version'];
+ $site = dr_string2array($t['site']);
+ $t['install'] = isset($site[SITE_ID]) && $site[SITE_ID] ? 1 : 0;
+ $my[$dir] = $t;
+ unset($list[$dir]);
+ }
+ }
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'my' => $my,
+ 'list' => $list,
+ ]);
+ \Phpcmf\Service::V()->display('module_list.html');
+ }
+
+ // 閲嶅懡鍚
+ public function name_edit() {
+
+ $mid = dr_safe_filename($_GET['dir']);
+ $file = dr_get_app_dir($mid).'Config/App.php';
+ if (!is_file($file)) {
+ $this->_json(0, dr_lang('褰撳墠妯″潡閰嶇疆鏂囦欢涓嶅瓨鍦'));
+ }
+
+ $config = require $file;
+
+ if (IS_POST) {
+
+ $data = \Phpcmf\Service::L('input')->post('data');
+
+ // 鍙傛暟鍒ゆ柇
+ if (!$data['name']) {
+ $this->_json(0, dr_lang('鍚嶇О涓嶈兘涓虹┖'), ['field' => 'name']);
+ } elseif (!$data['icon']) {
+ $this->_json(0, dr_lang('妯″潡鍥炬爣涓嶈兘涓虹┖'), ['field' => 'icon']);
+ } elseif (!dr_check_put_path(dirname($file))) {
+ $this->_json(0, dr_lang('鐩綍[%s]娌℃湁鍒涘缓鏂囦欢鏉冮檺', dirname($file)), ['field' => 'dirname']);
+ }
+
+ $old = $config['name'];
+ $config['name'] = dr_safe_filename($data['name']);
+ $config['icon'] = dr_safe_replace($data['icon']);
+ file_put_contents($file, 'update_module_name($mid, $old, $config['name'], $config['icon']);
+
+ // 閲嶇疆Zend OPcache
+ function_exists('opcache_reset') && opcache_reset();
+
+ \Phpcmf\Service::M('cache')->sync_cache(''); // 鑷姩鏇存柊缂撳瓨
+
+ \Phpcmf\Service::L('input')->system_log('妯″潡['.$mid.']鍚嶇О鍙樻洿');
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'form' => dr_form_hidden(),
+ 'config' => $config,
+ ]);
+ \Phpcmf\Service::V()->display('module_name_edit.html');exit;
+ }
+
+ // 鎺掑簭
+ public function displayorder_edit() {
+
+ // 鏌ヨ鏁版嵁
+ $id = (int)\Phpcmf\Service::L('input')->get('id');
+ $row = \Phpcmf\Service::M('Module')->table('module')->get($id);
+ if (!$row) {
+ $this->_json(0, dr_lang('鏁版嵁#%s涓嶅瓨鍦', $id));
+ }
+
+ $value = (int)\Phpcmf\Service::L('input')->get('value');
+ $rt = \Phpcmf\Service::M('Module')->table('module')->save($id, 'displayorder', $value);
+ if (!$rt['code']) {
+ $this->_json(0, $rt['msg']);
+ }
+
+ \Phpcmf\Service::M('cache')->sync_cache(''); // 鑷姩鏇存柊缂撳瓨
+ \Phpcmf\Service::L('input')->system_log('淇敼妯″潡('.$row['dirname'].')鐨勬帓搴忓间负'.$value);
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ // 闅愯棌鎴栬呭惎鐢
+ public function hidden_edit() {
+
+ $id = (int)\Phpcmf\Service::L('input')->get('id');
+ $row = \Phpcmf\Service::M('Module')->table('module')->get($id);
+ if (!$row) {
+ $this->_json(0, dr_lang('鏁版嵁#%s涓嶅瓨鍦', $id));
+ }
+
+ $v = $row['disabled'] ? 0 : 1;
+ \Phpcmf\Service::M('Module')->table('module')->update($id, ['disabled' => $v]);
+
+ \Phpcmf\Service::M('cache')->sync_cache(''); // 鑷姩鏇存柊缂撳瓨
+ $this->_json(1, dr_lang($v ? '妯″潡宸茶绂佺敤' : '妯″潡宸茶鍚敤'), ['value' => $v]);
+ }
+
+ // 妯″潡閰嶇疆
+ public function edit() {
+
+ $id = (int)\Phpcmf\Service::L('input')->get('id');
+ if ($this->dir) {
+ $data = \Phpcmf\Service::M()->table('module')->where('dirname', $this->dir)->getRow();
+ if (!$data) {
+ $this->_admin_msg(0, dr_lang('鏁版嵁#%s涓嶅瓨鍦', $id));
+ }
+ $id = $data['id'];
+ } else {
+ $data = \Phpcmf\Service::M()->table('module')->get($id);
+ if (!$data) {
+ $this->_admin_msg(0, dr_lang('鏁版嵁#%s涓嶅瓨鍦', $id));
+ }
+ }
+
+ // 鏍煎紡杞崲
+ $data['site'] = dr_string2array($data['site']);
+ $data['setting'] = dr_string2array($data['setting']);
+
+ // 鍒ゆ柇绔欑偣
+ if (!$data['site'][SITE_ID]) {
+ $this->_admin_msg(0, dr_lang('褰撳墠绔欑偣灏氭湭瀹夎'));
+ }
+
+ // 涓昏〃瀛楁
+ $field = \Phpcmf\Service::M()->db->table('field')
+ ->where('disabled', 0)
+ ->where('ismain', 1)
+ ->where('relatedname', 'module')
+ ->where('relatedid', $id)
+ ->orderBy('displayorder ASC,id ASC')
+ ->get()->getResultArray();
+ $sys_field = \Phpcmf\Service::L('Field')->sys_field(['id', 'catid', 'uid', 'inputtime', 'inputip', 'updatetime', 'hits', 'displayorder']);
+ $field = dr_list_field_value($data['setting']['list_field'], $sys_field, $field);
+
+ if (IS_AJAX_POST) {
+ $this->init_file($data['dirname']);
+ $post = \Phpcmf\Service::L('input')->post('data');
+ if ($post['setting']['list_field']) {
+ foreach ($post['setting']['list_field'] as $t) {
+ if ($t['func']) {
+ if (method_exists(\Phpcmf\Service::L('Function_list'), $t['func'])) {
+ } elseif (!function_exists($t['func'])) {
+ $this->_json(0, dr_lang('鍒楄〃鍥炶皟鍑芥暟[%s]鏈畾涔', $t['func']));
+ } elseif (strpos($t['func'], 'dr_') === false && strpos($t['func'], 'my_') === false) {
+ $this->_json(0, '鍑芥暟銆'.$t['func'].'銆戝繀椤讳互dr_鎴栬卪y_寮澶');
+ }
+ }
+ }
+ }
+ if ($post['setting']['search_time'] && !isset($field[$post['setting']['search_time']])) {
+ $this->_json(0, dr_lang('鍚庡彴鍒楄〃鏃堕棿鎼滅储瀛楁%s涓嶅瓨鍦', $post['setting']['search_time']));
+ }
+ if ($post['setting']['order']) {
+ if (strpos($post['setting']['order'], '(') or strpos($post['setting']['order'], ')')) {
+ $this->_json(0, dr_lang('鍚庡彴鍒楄〃鐨勯粯璁ゆ帓搴忓瓧娈典笉鍏佽鐗规畩绗﹀彿'));
+ }
+ $arr = explode(',', trim($post['setting']['order']));
+ foreach ($arr as $t) {
+ list($a) = explode(' ', trim($t));
+ if ($a && !isset($field[$a])) {
+ $this->_json(0, dr_lang('鍚庡彴鍒楄〃鐨勯粯璁ゆ帓搴忓瓧娈%s涓嶅瓨鍦', $a));
+ }
+ }
+ }
+
+ $rt = \Phpcmf\Service::M('Module')->config($data, $post);
+ if ($rt['code']) {
+ \Phpcmf\Service::M('cache')->sync_cache(''); // 鑷姩鏇存柊缂撳瓨
+ $this->_json(1, '鎿嶄綔鎴愬姛');
+ } else {
+ $this->_json(0, $rt['msg']);
+ }
+ }
+
+ $page = intval(\Phpcmf\Service::L('input')->get('page'));
+ $config = require dr_get_app_dir($data['dirname']).'Config/App.php';
+
+ if (!$data['site'][SITE_ID]['title']) {
+ $data['site'][SITE_ID]['title'] = $config['name'];
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'page' => $page,
+ 'data' => $data,
+ 'site' => $data['site'][SITE_ID],
+ 'form' => dr_form_hidden(['page' => $page]),
+ 'field' => $field,
+ 'is_hcategory' => isset($config['hcategory']) && $config['hcategory'],
+ ]);
+ \Phpcmf\Service::V()->display('module_edit.html');
+ }
+
+ // 鎺ㄨ崘浣
+ public function flag_edit() {
+
+ $id = (int)\Phpcmf\Service::L('input')->get('id');
+ if ($this->dir) {
+ $data = \Phpcmf\Service::M()->table('module')->where('dirname', $this->dir)->getRow();
+ if (!$data) {
+ $this->_admin_msg(0, dr_lang('鏁版嵁#%s涓嶅瓨鍦', $id));
+ }
+ } else {
+ $data = \Phpcmf\Service::M()->table('module')->get($id);
+ if (!$data) {
+ $this->_admin_msg(0, dr_lang('鏁版嵁#%s涓嶅瓨鍦', $id));
+ }
+ }
+
+ // 鏍煎紡杞崲
+ $data['setting'] = dr_string2array($data['setting']);
+
+ if (IS_AJAX_POST) {
+ $post = \Phpcmf\Service::L('input')->post('flag');
+ if ($post) {
+ $role = \Phpcmf\Service::L('input')->post('role');
+ foreach ($post as $fid => $t) {
+ $post[$fid]['role'] = [];
+ if (isset($role[$fid]) && $role[$fid]) {
+ foreach ($role[$fid] as $fid2 => $aid) {
+ $post[$fid]['role'][$aid] = 1;
+ }
+ }
+ }
+ }
+ $rt = \Phpcmf\Service::M('Module')->config($data, null, [
+ 'flag' => $post,
+ ]);
+ if ($rt['code']) {
+ \Phpcmf\Service::M('cache')->sync_cache(''); // 鑷姩鏇存柊缂撳瓨
+ $this->_json(1, '鎿嶄綔鎴愬姛');
+ } else {
+ $this->_json(0, $rt['msg']);
+ }
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'flag' => $data['setting']['flag'],
+ 'form' => dr_form_hidden(),
+ 'role' => \Phpcmf\Service::C()->get_cache('auth'),
+ ]);
+ \Phpcmf\Service::V()->display('module_flag.html');
+ }
+
+}
diff --git a/dayrui/App/Cms/Controllers/Admin/Module_category.php b/dayrui/App/Cms/Controllers/Admin/Module_category.php
new file mode 100644
index 0000000..8c29407
--- /dev/null
+++ b/dayrui/App/Cms/Controllers/Admin/Module_category.php
@@ -0,0 +1,163 @@
+get('dir');
+ $module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content');
+ if (!$module) {
+ $this->_admin_msg(0, dr_lang('绯荤粺娌℃湁瀹夎鍐呭妯″潡'), dr_url('module/module/index'));
+ }
+
+ $share = 0;
+
+ // 璁剧疆url
+ foreach ($module as $dir => $t) {
+ if ($t['share']) {
+ $share = 1;
+ unset($module[$dir]);
+ continue;
+ } elseif ($t['system'] == 2) {
+ // 鑷畾涔夎彍鍗曠殑
+ unset($module[$dir]);
+ continue;
+ } elseif ($t['hcategory']) {
+ // 绂佹浣跨敤鏍忕洰
+ unset($module[$dir]);
+ continue;
+ }
+ if ($mid && $mid != $dir) {
+ unset($module[$dir]);
+ continue;
+ }
+ $module[$dir]['name'] = dr_lang('%s鏍忕洰', $t['name']);
+ $module[$dir]['url'] = \Phpcmf\Service::L('Router')->url($dir.'/category/index');
+ }
+
+ if ($share) {
+ $tmp['share'] = [
+ 'name' => '鍏变韩鏍忕洰',
+ 'icon' => 'fa fa-share-alt',
+ 'title' => '鍏变韩',
+ 'url' => \Phpcmf\Service::L('Router')->url('category/index'),
+ 'dirname' => 'share',
+ ];
+ $one = $tmp['share'];
+ $module = dr_array22array($tmp, $module);
+ } else {
+ $one = reset($module);
+ }
+
+ if (!$module) {
+ $this->_admin_msg(0, dr_lang('绯荤粺娌℃湁鍙敤鍐呭妯″潡'), dr_url('module/module/index'));
+ }
+
+ // 鍙瓨鍦ㄤ竴涓」鐩
+ dr_count($module) == 1 && dr_redirect($one['url']);
+
+ \Phpcmf\Service::V()->assign([
+ 'url' => $one['url'],
+ 'menu' => \Phpcmf\Service::M('auth')->_iframe_menu($module, $one['dirname']),
+ 'module' => $module,
+ 'dirname' => $one['dirname'],
+ ]);
+ \Phpcmf\Service::V()->display('iframe_content.html');exit;
+ }
+
+ public function field_index() {
+
+ $dir = dr_safe_replace(\Phpcmf\Service::L('input')->get('dir'));
+ if (!$dir) {
+ $this->_admin_msg(0, dr_lang('绯荤粺娌℃湁鍙敤鍐呭妯″潡'));
+ }
+
+ $module = \Phpcmf\Service::M()->table('module')->where('dirname', $dir)->getRow();
+ if (!$module) {
+ $this->_admin_msg(0, dr_lang('鏁版嵁#%s涓嶅瓨鍦', $dir));
+ }
+
+ $list = [];
+
+ // 瀛楁鏌ヨ
+ $mid = $dir;
+ $like = ['catmodule-'.$dir];
+ if ($module['share']) {
+ $like[] = 'catmodule-share';
+ $mid = 'share';
+ }
+ $setting = dr_string2array($module['setting']);
+ $field = \Phpcmf\Service::M()->db->table('field')
+ ->where('ismain', 1)
+ ->where('disabled', 0)
+ ->whereIn('relatedname', $like)
+ ->orderBy('displayorder ASC, id ASC')->get()->getResultArray();
+ if ($field) {
+ $module['category'] = $this->get_cache('module-'.SITE_ID.'-'.$dir, 'category');
+ foreach ($field as $f) {
+ /*
+ $f['setting'] = dr_string2array($f['setting']);
+ if ($f['relatedid']) {
+ $f['setting']['diy']['cat_field_catids'][] = $f['relatedid'];
+ }*/
+ $catids = [];
+ foreach ($module['category'] as $t) {
+ if ($t['setting']['module_field'] && isset($t['setting']['module_field'][$f['fieldname']])) {
+ $catids[] = $t['id'];
+ }
+ }
+ $f['select'] = \Phpcmf\Service::L('Tree')->ismain(1)->select_category(
+ $module['category'],
+ $catids,
+ 'name=\'data['.$f['fieldname'].'][]\' multiple="multiple" data-actions-box="true"',
+ '',
+ 0,
+ 0
+ );
+ $list[$f['id']] = $f;
+ }
+ }
+
+ if (IS_POST) {
+ $setting['module_category_hide'] = (int)\Phpcmf\Service::L('input')->post('hide');
+ \Phpcmf\Service::M()->table('module')->update($module['id'], ['setting' => dr_array2string($setting)]);
+ $post = \Phpcmf\Service::L('input')->post('data');
+ $table = $module['share'] ? 'share_category' : $module['dirname'].'_category';
+ foreach ($module['category'] as $t) {
+ //if ($t['ismain']) {
+ $setting = dr_string2array($t['setting']);
+ $setting['module_field'] = [];
+ if ($post) {
+ foreach ($post as $fname => $catids) {
+ if (in_array($t['id'], $catids)) {
+ $setting['module_field'][$fname] = 1;
+ }
+ }
+ }
+ \Phpcmf\Service::M()->table_site($table)->update($t['id'], ['setting' => dr_array2string($setting)]);
+ //}
+ }
+ // 鑷姩鏇存柊缂撳瓨
+ \Phpcmf\Service::M('cache')->sync_cache();
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'mid' => $mid,
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '鍐呭妯″潡' => ['module/module/index', 'fa fa-cogs'],
+ '妯″潡銆'.$module['dirname'].'銆戞爮鐩ā鍨嬪瓧娈' => ['module/module_category/field_index{dir='.$dir.'}', 'fa fa-code', 'module_category/field_index'],
+ '鑷畾涔夊瓧娈' => ['url:'.\Phpcmf\Service::L('Router')->url('field/index', ['rname'=>'catmodule-'.$dir, 'rid'=>0]), 'fa fa-code', 'field/add'],
+ 'help' => [798],
+ ]
+ ),
+ 'list' => $list,
+ 'hide' => $setting['module_category_hide'],
+ ]);
+ \Phpcmf\Service::V()->display('module_category_field.html');
+ }
+
+}
diff --git a/dayrui/App/Cms/Controllers/Admin/Module_create.php b/dayrui/App/Cms/Controllers/Admin/Module_create.php
new file mode 100644
index 0000000..8df30cc
--- /dev/null
+++ b/dayrui/App/Cms/Controllers/Admin/Module_create.php
@@ -0,0 +1,71 @@
+_json(0, '绂佹鎿嶄綔');
+ }
+
+ $data = \Phpcmf\Service::L('input')->post('data');
+
+ // 鍙傛暟鍒ゆ柇
+ if (!$data['name']) {
+ $this->_json(0, dr_lang('鍚嶇О涓嶈兘涓虹┖'), ['field' => 'name']);
+ } elseif (!$data['dirname']) {
+ $this->_json(0, dr_lang('鐩綍涓嶈兘涓虹┖'), ['field' => 'dirname']);
+ }
+
+ $data['dirname'] = strtolower($data['dirname']);
+ if (!preg_match('/^[a-z]+$/i', $data['dirname'])) {
+ $this->_json(0, dr_lang('鐩綍鍙兘鏄嫳鏂囧瓧姣'), ['field' => 'dirname']);
+ } elseif (is_dir(APPSPATH.ucfirst($data['dirname']))) {
+ $this->_json(0, dr_lang('姝ょ洰褰曞凡缁忓瓨鍦'), ['field' => 'dirname']);
+ } elseif (!$data['icon']) {
+ $this->_json(0, dr_lang('妯″潡鍥炬爣涓嶈兘涓虹┖'), ['field' => 'icon']);
+ } elseif (!dr_check_put_path(APPSPATH)) {
+ $this->_json(0, dr_lang('鏈嶅姟鍣ㄦ病鏈夊垱寤虹洰褰曠殑鏉冮檺'), ['field' => 'dirname']);
+ } elseif (\Phpcmf\Service::M('app')->is_sys_dir($data['dirname'])) {
+ $this->_json(0, dr_lang('鐩綍[%s]鍚嶇О鏄郴缁熶繚鐣欏悕绉帮紝璇烽噸鍛藉悕', $data['dirname']));
+ }
+
+ // 寮濮嬪鍒跺埌鎸囧畾鐩綍
+ $path = APPSPATH.ucfirst($data['dirname']).'/';
+ \Phpcmf\Service::L('File')->copy_file(APPPATH.'Temps/Module/', $path);
+ if (!is_file($path.'Config/App.php')) {
+ $this->_json(0, dr_lang('鐩綍鍒涘缓澶辫触锛岃妫鏌ユ枃浠舵潈闄'), ['field' => 'dirname']);
+ }
+
+ // 鏇挎崲妯″潡閰嶇疆鏂囦欢
+ $app = file_get_contents($path.'Config/App.php');
+ $app = str_replace(['{name}', '{icon}'], [dr_safe_filename($data['name']), dr_safe_replace($data['icon'])], $app);
+ file_put_contents($path.'Config/App.php', $app);
+
+ $this->_json(1, dr_lang('妯″潡鍒涘缓鎴愬姛'), [
+ 'url' => dr_url('module/module/index')
+ ]);
+ exit;
+
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'form' => dr_form_hidden(),
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu([
+ '妯″潡绠$悊' => [APP_DIR.'/module/index', 'fa fa-cogs'],
+ '鍒涘缓妯″潡' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-plus'],
+ 'help' => [24]
+ ])
+ ]);
+ \Phpcmf\Service::V()->display('module_create.html');
+ }
+
+
+
+
+}
diff --git a/dayrui/App/Cms/Controllers/Admin/Module_param.php b/dayrui/App/Cms/Controllers/Admin/Module_param.php
new file mode 100644
index 0000000..3565be4
--- /dev/null
+++ b/dayrui/App/Cms/Controllers/Admin/Module_param.php
@@ -0,0 +1,14 @@
+get('dir');
+ $all = \Phpcmf\Service::M('Module')->get_module_info();
+ $module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content');
+
+ // 璁剧疆url
+ if ($module) {
+ foreach ($module as $dir => $t) {
+ if ($t['hlist'] == 1) {
+ unset($module[$dir]);
+ continue;
+ }
+ if (!$all[$dir]) {
+ unset($module[$dir]);
+ continue;
+ }
+ if ($mid && $mid != $dir) {
+ unset($module[$dir]);
+ continue;
+ }
+ $data = $all[$dir];
+
+ // 鎼滅储瀛楁
+ $data['search_field'] = [
+ 'catid' => dr_lang('鏍忕洰'),
+ 'keyword' => dr_lang('鎼滅储璇'),
+ 'order' => dr_lang('鎺掑簭'),
+ 'page' => dr_lang('鍒嗛〉'),
+ ];
+ if (!$data['setting']['search']['field']) {
+ $data['setting']['search']['field'] = 'title,keywords';
+ }
+ $field = \Phpcmf\Service::M()->db->table('field')
+ ->where('disabled', 0)
+ ->where('ismain', 1)
+ ->where('relatedname', 'module')
+ ->where('relatedid', $data['id'])
+ ->orderBy('displayorder ASC,id ASC')
+ ->get()->getResultArray();
+ foreach ($field as $f) {
+ $data['search_field'][$f['fieldname']] = $f['name'];
+ }
+ $module[$dir] = $data;
+ $module[$dir]['field'] = $field;
+ $module[$dir]['save_url'] = dr_url(APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/edit', ['dir' => $dir]);
+ }
+ } else {
+ $this->_admin_msg(0, dr_lang('绯荤粺娌℃湁瀹夎鍐呭妯″潡'));
+ }
+
+
+ $one = reset($module);
+ $page = \Phpcmf\Service::L('input')->get('page');
+ if (!$page) {
+ $page = $one['dirname'];
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'page' => $page,
+ 'form' => dr_form_hidden(),
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '妯″潡鎼滅储璁剧疆' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-search'],
+ 'help' => [1041],
+ ]
+ ),
+ 'module' => $module,
+ 'site_name' => $this->site_info[SITE_ID]['SITE_NAME'],
+ ]);
+ \Phpcmf\Service::V()->display('module_search.html');
+ }
+
+ public function edit() {
+
+ $dir = \Phpcmf\Service::L('input')->get('dir');
+ $cache = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content');
+ if (!$cache[$dir]) {
+ $this->_json(0, dr_lang('妯″潡#%s涓嶅瓨鍦', $dir));
+ }
+
+ $all = \Phpcmf\Service::M('Module')->get_module_info();
+ if (!$all[$dir]) {
+ $this->_json(0, dr_lang('妯″潡#%s涓嶅瓨鍦', $dir));
+ }
+
+ if (IS_POST) {
+
+ $post = \Phpcmf\Service::L('input')->post('data');
+ foreach ($post as $dir => $t) {
+ $all[$dir]['setting']['search'] = $t;
+ $all[$dir]['setting']['search']['field'] = implode(',', $_POST['search_field'][$dir]);
+ \Phpcmf\Service::M()->db->table('module')->where('dirname', $dir)->update([
+ 'setting' => dr_array2string($all[$dir]['setting']),
+ ]);
+ }
+
+ // 鑷姩鏇存柊缂撳瓨
+ \Phpcmf\Service::M('cache')->sync_cache();
+
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'), [
+ 'url' => dr_url(APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', ['page' => $dir])
+ ]);
+ }
+
+ $this->_json(0, dr_lang('璇锋眰閿欒'));
+ }
+
+}
diff --git a/dayrui/App/Cms/Controllers/Admin/Seo.php b/dayrui/App/Cms/Controllers/Admin/Seo.php
new file mode 100644
index 0000000..60bb529
--- /dev/null
+++ b/dayrui/App/Cms/Controllers/Admin/Seo.php
@@ -0,0 +1,88 @@
+config(
+ SITE_ID,
+ 'seo',
+ \Phpcmf\Service::L('input')->post('data', true)
+ );
+ \Phpcmf\Service::M('Site')->config_value(SITE_ID, 'config', [
+ 'SITE_INDEX_HTML' => intval(\Phpcmf\Service::L('input')->post('SITE_INDEX_HTML'))
+ ]);
+ if (!is_array($rt)) {
+ $this->_json(0, dr_lang('缃戠珯SEO(#%s)涓嶅瓨鍦', SITE_ID));
+ }
+ \Phpcmf\Service::L('input')->system_log('璁剧疆缃戠珯SEO');
+ \Phpcmf\Service::M('cache')->sync_cache('');
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ $page = intval(\Phpcmf\Service::L('input')->get('page'));
+ $data = \Phpcmf\Service::M('Site')->config(SITE_ID);
+
+ \Phpcmf\Service::V()->assign([
+ 'page' => $page,
+ 'data' => $data['seo'],
+ 'form' => dr_form_hidden(['page' => $page]),
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '绔欑偣SEO' => [APP_DIR.'/seo/index', 'fa fa-cog'],
+ 'help' => [494],
+ ]
+ ),
+ 'module' => \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content'),
+ 'site_name' => $this->site_info[SITE_ID]['SITE_NAME'],
+ 'SITE_INDEX_HTML' => $data['config']['SITE_INDEX_HTML'],
+ ]);
+ \Phpcmf\Service::V()->display('seo.html');
+ }
+
+ public function sync_index() {
+
+ $url = dr_url(APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/'.\Phpcmf\Service::L('Router')->method);
+ $page = intval(\Phpcmf\Service::L('input')->get('page'));
+ if (!$page) {
+ // 璁$畻鏁伴噺
+ $total = \Phpcmf\Service::M()->db->table('module')->countAllResults();
+ if (!$total) {
+ $this->_html_msg(0, dr_lang('鏃犲彲鐢ㄦā鍧楁洿鏂'));
+ }
+ $this->_html_msg(1, dr_lang('姝e湪鎵ц涓...'), $url.'&total='.$total.'&page=1');
+ }
+
+ $psize = 100; // 姣忛〉澶勭悊鐨勬暟閲
+ $total = (int)\Phpcmf\Service::L('input')->get('total');
+ $tpage = ceil($total / $psize); // 鎬婚〉鏁
+
+ // 鏇存柊瀹屾垚
+ if ($page > $tpage) {
+ \Phpcmf\Service::M('cache')->sync_cache('');
+ $this->_html_msg(1, dr_lang('鏇存柊瀹屾垚'));
+ }
+
+ $category = \Phpcmf\Service::M()->db->table('module')->limit($psize, $psize * ($page - 1))->orderBy('id DESC')->get()->getResultArray();
+ if ($category) {
+ $site = \Phpcmf\Service::M('Site')->config(SITE_ID);
+ $update = [];
+ foreach ($category as $data) {
+ $data['site'] = dr_string2array($data['site']);
+ $data['site'][SITE_ID]['show_title'] = $site['seo']['show_title'];
+ $data['site'][SITE_ID]['show_keywords'] = $site['seo']['show_keywords'];
+ $data['site'][SITE_ID]['show_description'] = $site['seo']['show_description'];
+ $update[] = [
+ 'id' => (int)$data['id'],
+ 'site'=> dr_array2string($data['site']),
+ ];
+ }
+ $update && \Phpcmf\Service::M()->table('module')->update_batch($update);
+ }
+
+ $this->_html_msg(1, dr_lang('姝e湪鎵ц涓%s銆...', "$tpage/$page"), $url.'&total='.$total.'&page='.($page+1));
+ }
+
+}
diff --git a/dayrui/App/Cms/Controllers/Admin/Seo_category.php b/dayrui/App/Cms/Controllers/Admin/Seo_category.php
new file mode 100644
index 0000000..9b09bfa
--- /dev/null
+++ b/dayrui/App/Cms/Controllers/Admin/Seo_category.php
@@ -0,0 +1,312 @@
+get('module-'.SITE_ID.'-content');
+ if (!$module) {
+ $this->_admin_msg(0, dr_lang('绯荤粺娌℃湁瀹夎鍐呭妯″潡'));
+ }
+
+ $page = \Phpcmf\Service::L('input')->get('page');
+ $share = 0;
+
+ // 璁剧疆url
+ foreach ($module as $dir => $t) {
+ if ($t['share']) {
+ $share = 1;
+ unset($module[$dir]);
+ continue;
+ } elseif ($t['hlist'] == 1) {
+ //1琛ㄧず涓嶅嚭鐜板湪妯″潡绠$悊銆佽瘎璁簍ab銆佹悳绱ab銆佸唴瀹圭淮鎶ab鐨勫垪琛ㄤ箣涓
+ unset($module[$dir]);
+ continue;
+ } elseif ($t['hcategory']) {
+ //1琛ㄧず涓嶄娇鐢ㄦ爮鐩姛鑳藉拰鍙戝竷鏉冮檺鍔熻兘
+ unset($module[$dir]);
+ continue;
+ }
+ $cache = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-'.$dir);
+ if (!$cache) {
+ unset($module[$dir]);
+ continue;
+ } elseif ($cache['setting']['search']['catsync']) {
+ unset($module[$dir]);
+ continue;
+ }
+ if (!isset($cache['site'][SITE_ID]['is_cat']) || !$cache['site'][SITE_ID]['is_cat']) {
+ if ($page && $page == $dir) {
+ $this->_admin_msg(0, dr_lang('姝ゆā鍧楁病鏈夊紑鍚寜鏍忕洰鍒嗗埆璁剧疆SEO閫夐」'));
+ }
+ unset($module[$dir]);
+ continue;
+ }
+
+ $module[$dir]['name'] = dr_lang('%s鏍忕洰', $t['name']);
+ $module[$dir]['list'] = $this->_get_tree_list(
+ $dir,
+ \Phpcmf\Service::M('category')->init(['table' => dr_module_table_prefix($dir).'_category'])->cat_data(0)
+ );
+ $module[$dir]['save_url'] = dr_url(APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/edit', ['dir' => $dir]);
+ }
+
+ if ($share) {
+ $tmp['share'] = [
+ 'name' => '鍏变韩鏍忕洰',
+ 'icon' => 'fa fa-share-alt',
+ 'title' => '鍏变韩',
+ 'save_url' => dr_url(APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/edit', ['dir' => 'share']),
+ 'dirname' => 'share',
+ 'list' => $this->_get_tree_list(
+ 'share',
+ \Phpcmf\Service::M('category')->init(['table' => dr_module_table_prefix('share').'_category'])->cat_data(0)
+ ),
+ ];
+ $module = dr_array22array($tmp, $module);
+ }
+
+ $one = reset($module);
+ if (!$page) {
+ $page = $one['dirname'];
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'page' => $page,
+ 'form' => dr_form_hidden(),
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '鏍忕洰SEO' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-reorder'],
+ 'help' => [496],
+ ]
+ ),
+ 'module' => $module,
+ 'site_name' => $this->site_info[SITE_ID]['SITE_NAME'],
+ ]);
+ \Phpcmf\Service::V()->display('seo_category.html');
+ }
+
+ // 閫夋嫨瑙勫垯
+ private function _select_rule($dir, $rule, $t) {
+
+ if ($dir != 'share') {
+ if ($t['setting']['urlrule']
+ && isset($rule[$t['setting']['urlrule']])
+ && $rule[$t['setting']['urlrule']]) {
+ $html = ''.dr_lang($rule[$t['setting']['urlrule']]['name']).' ';
+ } else {
+ $html = ''.dr_lang('鍔ㄦ佸湴鍧').' ';
+ }
+ } else {
+ $html = '';
+ $html.= '';
+ $html.= ' '.dr_lang('鍔ㄦ佸湴鍧').' ';
+ if ($rule) {
+ foreach ($rule as $b) {
+ $select = isset($t['setting']['urlrule']) && $t['setting']['urlrule'] == $b['id'] ? 'selected' : '';
+ if ($dir == 'share') {
+ if ($b['type'] == 3) {
+ $html.= ' '.dr_lang($b['name']).' ';
+ }
+ } elseif ($b['type'] == 1) {
+ $html.= ' '.dr_lang($b['name']).' ';
+ }
+ }
+ }
+ $html.= ' ';
+ $html.= ' ';
+ }
+
+ return $html;
+ }
+
+ // 鑾峰彇鏍戝舰缁撴瀯鍒楄〃
+ private function _get_tree_list($dir, $data) {
+
+ $str = "";
+ $str.= "\$id ";
+ $str.= "\$spacer\$name ";
+ $str.= "\$html ";
+ if (dr_is_app('chtml')) {
+ $str .= "\$is_page_html ";
+ $str .= "\$is_page_html2 ";
+ }
+ $str.= "\$option ";
+ $str.= " ";
+
+ $rule = $this->get_cache('urlrule');
+ if ($dir != 'share') {
+ $mod = \Phpcmf\Service::M()->table('module')->where('dirname', $dir)->getRow();
+ if (!$mod) {
+ $this->_admin_msg(0, dr_lang('妯″潡#%s涓嶅瓨鍦', $dir));
+ }
+ $mod['site'] = dr_string2array($mod['site']);
+ } else {
+ $mod = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-share');
+ }
+
+ $tree = '';
+ foreach($data as $t) {
+ $t['name'] = dr_strcut($t['name'], 30);
+ $t['setting'] = dr_string2array($t['setting']);
+ $t['option'] = ' '.dr_lang('璁剧疆SEO').' ';
+ $t['option'].= ' '.dr_lang('鍚屾鍒板叾浠栨爮鐩').' ';
+ // 鍒ゆ柇鏄惁鐢熸垚闈欐
+ if (dr_is_app('chtml')) {
+ $is_html = intval($t['setting']['html']);
+ $is_html2 = intval($t['setting']['chtml']);
+ $t['is_page_html'] = ' ';
+ $t['is_page_html2'] = ' ';
+ }
+ if ($mod && isset($mod['site'][SITE_ID]['urlrule'])) {
+ $t['setting']['urlrule'] = $mod['site'][SITE_ID]['urlrule'];
+ }
+ $t['html'] = $this->_select_rule($dir, $rule, $t);
+
+ $pid = explode(',', $t['pids']);
+ $mod['category'][$t['id']]['topid'] = $t['topid'] = isset($pid[1]) ? $pid[1] : $t['id'];
+ $t['url'] = $t['tid'] == 2 && $t['setting']['linkurl'] ? dr_url_prefix($t['setting']['linkurl']) : dr_url_prefix(\Phpcmf\Service::L('router')->category_url($mod, $t));
+
+ if ($t['child'] || $t['pcatpost']) {
+ $t['spacer'] = $this->_get_spacer($t['pids']).'[+] ';
+ } else {
+ $t['spacer'] = $this->_get_spacer($t['pids']);
+ }
+
+ $t['class'] = 'dr_catid_'.$dir.'_'.$t['id']. ' dr_pid_'.$dir.'_'.$t['pid'];
+ $arr = explode(',', $t['pids']);
+ if ($arr) {
+ foreach ($arr as $a) {
+ $t['class'].= ' dr_pid_'.$dir.'_'.$a;
+ }
+ }
+ extract($t);
+ eval("\$nstr = \"$str\";");
+ $tree.= $nstr;
+ }
+
+ return $tree;
+ }
+
+ public function list_index() {
+ $pid = intval(\Phpcmf\Service::L('input')->get('pid'));
+ $mid = dr_safe_filename(\Phpcmf\Service::L('input')->get('mid'));
+ $b = $this->_get_tree_list($mid, \Phpcmf\Service::M('category')->init(['table' => dr_module_table_prefix($mid).'_category'])->cat_data($pid));
+ $this->_json(1, $b);
+ }
+
+ // 鏇挎崲绌烘牸濉厖绗﹀彿
+ private function _get_spacer($str) {
+ $rt = '';
+ $num = substr_count((string)$str, ',') * 2;
+ if ($num) {
+ for ($i = 0; $i < $num; $i ++) {
+ $rt.= ' ';
+ }
+ }
+ return $rt;
+ }
+
+
+ public function show_index() {
+
+ $dir = \Phpcmf\Service::L('input')->get('dir');
+ $this->module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-'.$dir);
+ if (!$this->module) {
+ $this->_admin_msg(0, dr_lang('妯″潡[%s]缂撳瓨涓嶅瓨鍦', $dir));
+ return;
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'list' => $this->_get_tree_list($this->module['category']),
+ 'dirname' => $dir,
+ 'save_url' => dr_url('module/'.\Phpcmf\Service::L('Router')->class.'/edit', ['dir' => $dir]),
+ 'site_name' => $this->site_info[SITE_ID]['SITE_NAME'],
+ ]);
+ \Phpcmf\Service::V()->display('seo_category.html');
+ }
+
+ public function rule_edit() {
+
+ $dir = \Phpcmf\Service::L('input')->get('dir');
+ $module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-'.$dir);
+ if (!$module) {
+ $this->_admin_msg(0, dr_lang('妯″潡[%s]缂撳瓨涓嶅瓨鍦', $dir));
+ return;
+ }
+
+ $id = (int)\Phpcmf\Service::L('input')->get('id');
+ $value = (int)\Phpcmf\Service::L('input')->get('value');
+
+ if ($dir == 'share') {
+ $data = \Phpcmf\Service::M()->table(dr_module_table_prefix($dir).'_category')->where('id', $id)->getRow();
+ if (!$data) {
+ $this->_admin_msg(0, dr_lang('鏍忕洰#%s涓嶅瓨鍦', $id));
+ }
+ $data['setting'] = dr_string2array($data['setting']);
+ $data['setting']['urlrule'] = $value;
+ \Phpcmf\Service::M()->db->table(dr_module_table_prefix($dir).'_category')->where('id', $id)->update([
+ 'setting' => dr_array2string($data['setting']),
+ ]);
+ } else {
+ $data = \Phpcmf\Service::M()->table('module')->where('dirname', $dir)->getRow();
+ if (!$data) {
+ $this->_admin_msg(0, dr_lang('妯″潡#%s涓嶅瓨鍦', $dir));
+ }
+
+ $data['site'] = dr_string2array($data['site']);
+ $data['site'][SITE_ID]['urlrule'] = $value;
+
+ \Phpcmf\Service::M()->db->table('module')->where('dirname', $dir)->update([
+ 'site' => dr_array2string($data['site']),
+ ]);
+ }
+
+ \Phpcmf\Service::M('cache')->sync_cache('');
+ $this->_json(1, '鎿嶄綔鎴愬姛锛屾洿鏂扮紦瀛樼敓鏁');
+ }
+
+ public function edit() {
+
+ $dir = \Phpcmf\Service::L('input')->get('dir');
+ $module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-'.$dir);
+ if (!$module) {
+ $this->_admin_msg(0, dr_lang('妯″潡[%s]缂撳瓨涓嶅瓨鍦', $dir));
+ return;
+ }
+
+ $id = (int)\Phpcmf\Service::L('input')->get('id');
+ $data = \Phpcmf\Service::M()->table(dr_module_table_prefix($dir).'_category')->where('id', $id)->getRow();
+ if (!$data) {
+ $this->_admin_msg(0, dr_lang('鏍忕洰#%s涓嶅瓨鍦', $id));
+ }
+ $data['setting'] = dr_string2array($data['setting']);
+
+ if (IS_AJAX_POST) {
+ $seo = \Phpcmf\Service::L('input')->post('seo');
+ $set = \Phpcmf\Service::L('input')->post('setting');
+ if (!isset($data['setting']['seo']) || !$data['setting']['seo']) {
+ $data['setting']['seo'] = [];
+ }
+ foreach (['list_title', 'list_keywords', 'list_description'] as $name) {
+ $data['setting']['seo'][$name] = isset($seo[$name]) ? $seo[$name] : '';
+ }
+ $data['setting']['html'] = isset($set['html']) ? (int)$set['html'] : 0;
+ $data['setting']['chtml'] = isset($set['chtml']) ? (int)$set['chtml'] : 0;
+ $data['setting']['urlrule'] = isset($set['urlrule']) ? (int)$set['urlrule'] : 0;
+ \Phpcmf\Service::M()->db->table(dr_module_table_prefix($dir).'_category')->where('id', $id)->update([
+ 'setting' => dr_array2string($data['setting']),
+ ]);
+ \Phpcmf\Service::M('cache')->sync_cache('');
+ $this->_json(1, '鎿嶄綔鎴愬姛锛屾洿鏂扮紦瀛樼敓鏁');
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'data' => $data,
+ 'dirname' => $dir,
+ ]);
+ \Phpcmf\Service::V()->display('seo_category_edit.html');exit;
+ }
+
+}
diff --git a/dayrui/App/Cms/Controllers/Admin/Seo_module.php b/dayrui/App/Cms/Controllers/Admin/Seo_module.php
new file mode 100644
index 0000000..8c0ed43
--- /dev/null
+++ b/dayrui/App/Cms/Controllers/Admin/Seo_module.php
@@ -0,0 +1,90 @@
+get('dir');
+ $module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content');
+
+ // 璁剧疆url
+ if ($module) {
+ foreach ($module as $dir => $t) {
+ if ($t['hlist'] == 1) {
+ unset($module[$dir]);
+ continue;
+ }
+ if ($mid && $mid != $dir) {
+ unset($module[$dir]);
+ continue;
+ }
+ $data = \Phpcmf\Service::M()->table('module')->where('dirname', $dir)->getRow();
+ if (!$data) {
+ unset($module[$dir]);
+ continue;
+ }
+ $site = dr_string2array($data['site']);
+ $module[$dir]['site'] = $site[SITE_ID];
+ $module[$dir]['setting'] = dr_string2array($data['setting']);
+ $module[$dir]['save_url'] = dr_url(APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/edit', ['dir' => $dir]);
+ }
+ } else {
+ $this->_admin_msg(0, dr_lang('绯荤粺娌℃湁瀹夎鍐呭妯″潡'));
+ }
+
+ $one = reset($module);
+ $page = \Phpcmf\Service::L('input')->get('page');
+ if (!$page) {
+ $page = $one['dirname'];
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'page' => $page,
+ 'form' => dr_form_hidden(),
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '鍐呭妯″潡SEO' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-cogs'],
+ 'help' => [398],
+ ]
+ ),
+ 'module' => $module,
+ 'site_name' => $this->site_info[SITE_ID]['SITE_NAME'],
+ ]);
+ \Phpcmf\Service::V()->display('seo_module.html');
+ }
+
+ // 瀛樺偍鎸囧畾鐨勬ā鍧
+ public function edit() {
+
+ $dir = \Phpcmf\Service::L('input')->get('dir');
+ $data = \Phpcmf\Service::M()->table('module')->where('dirname', $dir)->getRow();
+ if (!$data) {
+ $this->_admin_msg(0, dr_lang('妯″潡#%s涓嶅瓨鍦', $dir));
+ }
+
+ $data['site'] = dr_string2array($data['site']);
+ $data['setting'] = dr_string2array($data['setting']);
+
+ if (IS_AJAX_POST) {
+ $site = \Phpcmf\Service::L('input')->post('site');
+ foreach (['html', 'urlrule', 'is_cat',
+ 'show_title', 'show_keywords', 'show_description',
+ 'list_title', 'list_keywords', 'list_description',
+ 'search_title', 'search_keywords', 'search_description',
+ 'module_title', 'module_keywords', 'module_description'] as $name) {
+ $data['site'][SITE_ID][$name] = $site[$name];
+ }
+ $data['setting']['module_index_html'] = intval($_POST['module_index_html']);
+ \Phpcmf\Service::M()->db->table('module')->where('dirname', $dir)->update([
+ 'site' => dr_array2string($data['site']),
+ 'setting' => dr_array2string($data['setting']),
+ ]);
+ \Phpcmf\Service::M('cache')->sync_cache('');
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'), [
+ 'url' => dr_url(APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', ['page' => $dir])
+ ]);
+ }
+ }
+
+}
diff --git a/dayrui/App/Cms/Controllers/Admin/Seo_site.php b/dayrui/App/Cms/Controllers/Admin/Seo_site.php
new file mode 100644
index 0000000..d21933b
--- /dev/null
+++ b/dayrui/App/Cms/Controllers/Admin/Seo_site.php
@@ -0,0 +1,93 @@
+config(
+ SITE_ID,
+ 'seo',
+ \Phpcmf\Service::L('input')->post('data', true)
+ );
+ \Phpcmf\Service::M('Site')->config_value(SITE_ID, 'config', [
+ 'SITE_INDEX_HTML' => intval(\Phpcmf\Service::L('input')->post('SITE_INDEX_HTML'))
+ ]);
+ if (!is_array($rt)) {
+ $this->_json(0, dr_lang('缃戠珯SEO(#%s)涓嶅瓨鍦', SITE_ID));
+ }
+ \Phpcmf\Service::L('input')->system_log('璁剧疆缃戠珯SEO');
+ \Phpcmf\Service::M('cache')->sync_cache('');
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ $page = intval(\Phpcmf\Service::L('input')->get('page'));
+ $data = \Phpcmf\Service::M('Site')->config(SITE_ID);
+
+ \Phpcmf\Service::V()->assign([
+ 'page' => $page,
+ 'data' => $data['seo'],
+ 'form' => dr_form_hidden(['page' => $page]),
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '绔欑偣SEO' => [APP_DIR.'/'.'seo_site/index', 'fa fa-cog'],
+ 'help' => [494],
+ ]
+ ),
+ 'module' => \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content'),
+ 'site_name' => $this->site_info[SITE_ID]['SITE_NAME'],
+ 'SITE_INDEX_HTML' => $data['config']['SITE_INDEX_HTML'],
+ ]);
+ \Phpcmf\Service::V()->display('seo_site.html');
+ }
+
+ public function sync_index() {
+
+ $ct = intval(\Phpcmf\Service::L('input')->get('ct'));
+ $value = intval(\Phpcmf\Service::L('input')->get('value'));
+ $url = dr_url(APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/'.\Phpcmf\Service::L('Router')->method, ['ct' => $ct, 'value' => $value]);
+ $page = intval(\Phpcmf\Service::L('input')->get('page'));
+ if (!$page) {
+ // 璁$畻鏁伴噺
+ $total = \Phpcmf\Service::M()->db->table(SITE_ID.'_share_category')->countAllResults();
+ if (!$total) {
+ $this->_html_msg(0, dr_lang('鏃犲彲鐢ㄦ爮鐩洿鏂'));
+ }
+ $this->_html_msg(1, dr_lang('姝e湪鎵ц涓...'), $url.'&total='.$total.'&page=1');
+ }
+
+ $psize = 100; // 姣忛〉澶勭悊鐨勬暟閲
+ $total = (int)\Phpcmf\Service::L('input')->get('total');
+ $tpage = ceil($total / $psize); // 鎬婚〉鏁
+
+ // 鏇存柊瀹屾垚
+ if ($page > $tpage) {
+ \Phpcmf\Service::M('cache')->sync_cache('');
+ $this->_html_msg(1, dr_lang('鏇存柊瀹屾垚'));
+ }
+
+ $category = \Phpcmf\Service::M()->db->table(SITE_ID.'_share_category')->limit($psize, $psize * ($page - 1))->orderBy('id DESC')->get()->getResultArray();
+ if ($category) {
+ $update = [];
+ foreach ($category as $data) {
+ $data['setting'] = dr_string2array($data['setting']);
+ if ($ct == 1) {
+ $data['setting']['urlrule'] = $value;
+ } elseif ($ct == 2) {
+ $data['setting']['template']['pagesize'] = $value;
+ } elseif ($ct == 3) {
+ $data['setting']['template']['mpagesize'] = $value;
+ }
+ $update[] = [
+ 'id' => (int)$data['id'],
+ 'setting'=> dr_array2string($data['setting']),
+ ];
+ }
+ $update && \Phpcmf\Service::M()->table_site('share_category')->update_batch($update);
+ }
+
+ $this->_html_msg(1, dr_lang('姝e湪鎵ц涓%s銆...', "$tpage/$page"), $url.'&total='.$total.'&page='.($page+1));
+ }
+
+}
diff --git a/dayrui/App/Cms/Controllers/Admin/Site_config.php b/dayrui/App/Cms/Controllers/Admin/Site_config.php
new file mode 100644
index 0000000..0e4737d
--- /dev/null
+++ b/dayrui/App/Cms/Controllers/Admin/Site_config.php
@@ -0,0 +1,68 @@
+config(SITE_ID);
+
+ if (IS_AJAX_POST) {
+
+ $post = \Phpcmf\Service::L('input')->post('data');
+ if (isset($_POST['theme']) && $_POST['theme']) {
+ // 杩滅▼璧勬簮
+ $post['SITE_THEME'] = $post['SITE_THEME2'];
+ } else {
+ // 鏈湴璧勬簮
+ }
+
+ // 闃叉鍙傛暟涓㈠け
+ $data['config']['SITE_NAME'] = $post['SITE_NAME'];
+ $data['config']['SITE_CLOSE'] = $post['SITE_CLOSE'];
+ $data['config']['SITE_INDEX_HTML'] = $post['SITE_INDEX_HTML'];
+ $data['config']['SITE_CLOSE_MSG'] = $post['SITE_CLOSE_MSG'];
+ $data['config']['SITE_LANGUAGE'] = $post['SITE_LANGUAGE'];
+ $data['config']['SITE_TEMPLATE'] = $post['SITE_TEMPLATE'];
+ $data['config']['SITE_TIMEZONE'] = $post['SITE_TIMEZONE'];
+ $data['config']['SITE_TIME_FORMAT'] = $post['SITE_TIME_FORMAT'];
+ $data['config']['SITE_THEME'] = $post['SITE_THEME'];
+ $data['config']['SITE_INDEX_TIME'] = $post['SITE_INDEX_TIME'];
+
+ $rt = \Phpcmf\Service::M('Site')->config(SITE_ID, 'config', $data['config']);
+ if (!is_array($rt)) {
+ $this->_json(0, dr_lang('缃戠珯淇℃伅(#%s)涓嶅瓨鍦', SITE_ID));
+ }
+
+ \Phpcmf\Service::L('input')->system_log('璁剧疆缃戠珯鍙傛暟');
+
+ \Phpcmf\Service::M('cache')->sync_cache('');
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ $page = intval(\Phpcmf\Service::L('input')->get('page'));
+ $run_time = '';
+ if (is_file(WRITEPATH.'config/run_time.php')) {
+ $run_time = file_get_contents(WRITEPATH.'config/run_time.php');
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'page' => $page,
+ 'data' => $data['config'],
+ 'form' => dr_form_hidden(['page' => $page]),
+ 'lang' => dr_dir_map(ROOTPATH.'api/language/', 1),
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '缃戠珯璁剧疆' => ['module/site_config/index', 'fa fa-cog'],
+ 'help' => [505],
+ ]
+ ),
+ 'theme' => dr_get_theme(),
+ 'run_time' => $run_time,
+ 'is_theme' => dr_strpos($data['config']['SITE_THEME'], '/') !== false ? 1 : 0,
+ 'template_path' => dr_dir_map(TPLPATH.'pc/', 1),
+ ]);
+ \Phpcmf\Service::V()->display('site_config.html');
+ }
+
+}
diff --git a/dayrui/App/Cms/Controllers/Admin/Site_domain.php b/dayrui/App/Cms/Controllers/Admin/Site_domain.php
new file mode 100644
index 0000000..19cf312
--- /dev/null
+++ b/dayrui/App/Cms/Controllers/Admin/Site_domain.php
@@ -0,0 +1,105 @@
+post('data');
+ if ($data['site_domain'] == $data['mobile_domain']) {
+ $this->_json(0, dr_lang('鎵嬫満鍩熷悕涓嶈兘涓庣數鑴戠浉鍚'));
+ }
+ foreach ($post as $name => $value) {
+ unset($data[$name]);
+ if ($value) {
+ if (strpos($name, 'webpath') === 0) {
+ // 鐩綍涓嶉獙璇
+ } elseif ($name == 'site_domain') {
+ if (!\Phpcmf\Service::L('Form')->check_domain_dir($value)) {
+ $this->_json(0, dr_lang('鍩熷悕锛%s锛夋牸寮忎笉姝g‘', $value));
+ }
+ } else {
+ // 楠岃瘉鍩熷悕鍙敤鎬
+ if (dr_in_array($value, $data)) {
+ $this->_json(0, dr_lang('鍩熷悕锛%s锛夌粦瀹氶噸澶', $value));
+ } elseif (!\Phpcmf\Service::L('Form')->check_domain($value)) {
+ $this->_json(0, dr_lang('鍩熷悕锛%s锛夋牸寮忎笉姝g‘', $value));
+ }
+ list($cname, $mid) = explode('_', $name);
+ if ($cname == 'module' && $mid != 'mobile' && $post['module_'.$mid] && !$post['webpath_'.$mid]) {
+ $this->_json(0, dr_lang('妯″潡锛%s锛夌殑Web鐩綍蹇呴』濉啓', $mid));
+ }
+ }
+ }
+ $data[$name] = $value;
+ }
+ \Phpcmf\Service::M('Site')->domain($post);
+ \Phpcmf\Service::M('cache')->sync_cache('');
+ \Phpcmf\Service::L('input')->system_log('璁剧疆鍩熷悕鍙傛暟');
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ $page = intval(\Phpcmf\Service::L('input')->get('page'));
+ list($module, $data) = \Phpcmf\Service::M('Site')->domain();
+
+ \Phpcmf\Service::V()->assign([
+ 'page' => $page,
+ 'data' => $data,
+ 'form' => dr_form_hidden(['page' => $page]),
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '鍩熷悕璁剧疆' => ['module/site_domain/index', 'fa fa-cog'],
+ 'help' => ['407'],
+ ]
+ ),
+ 'module' => $module,
+ ]);
+ \Phpcmf\Service::V()->display('site_domain.html');
+ }
+
+ public function bang_index() {
+ $this->index();
+ }
+
+ public function edit() {
+
+ $name = '';
+ $is_fclient = is_file(ROOTPATH.'api/fclient/index.php');
+ if ($is_fclient && is_file(MYPATH . 'Config/License.php')) {
+ $license = require MYPATH . 'Config/License.php';
+ $name = $license['name'];
+ }
+
+ !$name && $name = dr_lang('杞欢鏈嶅姟鍟');
+
+ if (IS_POST) {
+
+ if ($is_fclient) {
+ $this->_json(0, dr_lang('褰撳墠缃戠珯涓嶈兘淇敼涓诲煙鍚'));
+ }
+
+ $domain = trim(\Phpcmf\Service::L('input')->post('domain'));
+ if (!\Phpcmf\Service::L('Form')->check_domain($domain)) {
+ $this->_json(0, dr_lang('鍩熷悕锛%s锛夋牸寮忎笉姝g‘', $domain));
+ }
+
+ \Phpcmf\Service::M('Site')->edit_domain($domain);
+ \Phpcmf\Service::L('input')->system_log('鍙樻洿缃戠珯涓诲煙鍚');
+ \Phpcmf\Service::M('cache')->sync_cache(''); // 鑷姩鏇存柊缂撳瓨
+
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛锛岃鏇存柊鍏ㄧ珯缂撳瓨'), [
+ 'tourl' => dr_url('cache/index')
+ ]);
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'form' => dr_form_hidden(),
+ 'fcname' => $name,
+ 'is_fclient' => $is_fclient,
+ ]);
+ \Phpcmf\Service::V()->display('site_domain_edit.html');exit;
+ }
+
+}
+
diff --git a/dayrui/App/Cms/Controllers/Admin/Site_image.php b/dayrui/App/Cms/Controllers/Admin/Site_image.php
new file mode 100644
index 0000000..147af06
--- /dev/null
+++ b/dayrui/App/Cms/Controllers/Admin/Site_image.php
@@ -0,0 +1,15 @@
+index();
+ }
+
+
+}
diff --git a/dayrui/App/Cms/Controllers/Admin/Site_mobile.php b/dayrui/App/Cms/Controllers/Admin/Site_mobile.php
new file mode 100644
index 0000000..f4006a5
--- /dev/null
+++ b/dayrui/App/Cms/Controllers/Admin/Site_mobile.php
@@ -0,0 +1,62 @@
+post('data');
+ if (!$post['mode']) {
+ if (!\Phpcmf\Service::L('Form')->check_domain($post['domain'])) {
+ $this->_json(0, dr_lang('鍩熷悕锛%s锛夋牸寮忎笉姝g‘', $post['domain']));
+ } elseif ($this->site_info[SITE_ID]['SITE_DOMAIN'] == $post['domain']) {
+ $this->_json(0, dr_lang('鎵嬫満鍩熷悕涓嶈兘涓庣數鑴戠浉鍚'));
+ }
+ }
+ if ($post['mode'] == -1) {
+ $post['auto'] = $post['auto2'];
+ $post['tohtml'] = 0;
+ $post['dirname'] = $post['domain'] = '';
+ } elseif ($post['mode'] == 1) {
+ // 鐢熸垚鎵嬫満鐩綍
+ $rt = \Phpcmf\Service::M('cache')->update_mobile_webpath(WEBPATH, $post['dirname']);
+ if ($rt) {
+ $this->_json(0, dr_lang($rt));
+ }
+ }
+ $rt = \Phpcmf\Service::M('Site')->config(SITE_ID, 'mobile', $post);
+ if (!is_array($rt)) {
+ $this->_json(0, dr_lang('缃戠珯淇℃伅(#%s)涓嶅瓨鍦', SITE_ID));
+ }
+ \Phpcmf\Service::L('input')->system_log('璁剧疆鎵嬫満缃戠珯鍙傛暟');
+ \Phpcmf\Service::M('cache')->sync_cache('');
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ $page = intval(\Phpcmf\Service::L('input')->get('page'));
+ $data = \Phpcmf\Service::M('Site')->config(SITE_ID);
+
+ if (!isset($data['mobile']['dirname']) || !$data['mobile']['dirname']) {
+ $data['mobile']['dirname'] = 'mobile';
+ }
+ if (!isset($data['mobile']['mode']) || (!$data['mobile']['mode'] && !$data['mobile']['domain'])) {
+ $data['mobile']['mode'] = -1;
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'page' => $page,
+ 'data' => $data['mobile'],
+ 'form' => dr_form_hidden(['page' => $page]),
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '鎵嬫満缃戠珯' => ['module/site_mobile/index', 'fa fa-mobile'],
+ 'help' => [506],
+ ]
+ ),
+ 'is_tpl' => is_file(TPLPATH.'mobile/'.SITE_TEMPLATE.'/home/index.html'),
+ ]);
+ \Phpcmf\Service::V()->display('site_mobile.html');
+ }
+
+}
diff --git a/dayrui/App/Cms/Controllers/Admin/Site_param.php b/dayrui/App/Cms/Controllers/Admin/Site_param.php
new file mode 100644
index 0000000..b08a9e9
--- /dev/null
+++ b/dayrui/App/Cms/Controllers/Admin/Site_param.php
@@ -0,0 +1,109 @@
+ [
+ 'ismain' => 1,
+ 'fieldtype' => 'File',
+ 'fieldname' => 'logo',
+ 'setting' => ['option' => ['ext' => 'jpg,gif,png,jpeg,webp,svg', 'size' => 10, 'input' => 1]]
+ ]
+ ];
+
+ $data = \Phpcmf\Service::M('Site')->config(SITE_ID);
+ $field = \Phpcmf\Service::M('field')->get_mysite_field(SITE_ID);
+
+ // 鍒濆鍖栬嚜瀹氫箟瀛楁绫
+ \Phpcmf\Service::L('Field')->app('');
+
+ if (IS_AJAX_POST) {
+
+ $post = \Phpcmf\Service::L('input')->post('data', false);
+
+ // param
+ if ($field) {
+ list($save, $return, $attach, $notfield) = \Phpcmf\Service::L('form')->validation($post, null, $field, $data['param']);
+ // 杈撳嚭閿欒
+ if ($return) {
+ $this->_json(0, $return['error'], ['field' => $return['name']]);
+ }
+ if ($notfield) {
+ // 淇濈暀鏃犳潈闄愮殑瀛楁鍊
+ foreach ($notfield as $t) {
+ $save[1][$t] = $data['param'][$t];
+ }
+ }
+ $rt = \Phpcmf\Service::M('Site')->config(
+ SITE_ID,
+ 'param',
+ $save[1]
+ );
+ if (!is_array($rt)) {
+ $this->_json(0, dr_lang('缃戠珯淇℃伅(#%s)涓嶅瓨鍦', SITE_ID));
+ }
+ // 闄勪欢褰掓。
+ if (SYS_ATTACHMENT_DB) {
+ $attach && \Phpcmf\Service::M('Attachment')->handle($this->member['id'], \Phpcmf\Service::M()->dbprefix('site'), $attach);
+ }
+ foreach ($field as $t) {
+ if (isset($post[$t['fieldname']])) {
+ unset($post[$t['fieldname']]);
+ }
+ }
+ }
+
+ // config
+ $config = \Phpcmf\Service::L('input')->post('data');
+ $config['SITE_TONGJI'] = isset($_POST['data']['SITE_TONGJI']) ? trim($_POST['data']['SITE_TONGJI']) : '';
+ // 闃叉鍙傛暟涓㈠け
+ $config['SITE_CLOSE'] = $data['config']['SITE_CLOSE'];
+ $config['SITE_INDEX_HTML'] = $data['config']['SITE_INDEX_HTML'];
+ $config['SITE_CLOSE_MSG'] = $data['config']['SITE_CLOSE_MSG'];
+ $config['SITE_LANGUAGE'] = $data['config']['SITE_LANGUAGE'];
+ $config['SITE_TEMPLATE'] = $data['config']['SITE_TEMPLATE'];
+ $config['SITE_TIMEZONE'] = $data['config']['SITE_TIMEZONE'];
+ $config['SITE_TIME_FORMAT'] = $data['config']['SITE_TIME_FORMAT'];
+ $config['SITE_THEME'] = $data['config']['SITE_THEME'];
+ $rt = \Phpcmf\Service::M('Site')->config(SITE_ID, 'config', $config);
+ if (!is_array($rt)) {
+ $this->_json(0, dr_lang('缃戠珯淇℃伅(#%s)涓嶅瓨鍦', SITE_ID));
+ }
+ // 闄勪欢褰掓。
+ if (SYS_ATTACHMENT_DB) {
+ list($post, $return, $attach) = \Phpcmf\Service::L('form')->validation($config, null, $logo);
+ $attach && \Phpcmf\Service::M('Attachment')->handle($this->member['id'], \Phpcmf\Service::M()->dbprefix('site'), $attach);
+ }
+
+ \Phpcmf\Service::L('input')->system_log('璁剧疆缃戠珯鑷畾涔夊弬鏁');
+ \Phpcmf\Service::M('cache')->sync_cache('');
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ $page = intval(\Phpcmf\Service::L('input')->get('page'));
+
+ \Phpcmf\Service::V()->assign([
+ 'page' => $page,
+ 'form' => dr_form_hidden(['page' => $page]),
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '缃戠珯淇℃伅' => ['module/site_param/index', 'fa fa-edit'],
+ '鑷畾涔夊瓧娈' => ['url:'.\Phpcmf\Service::L('Router')->url('field/index', ['rname' => 'site', 'rid' => SITE_ID]), 'fa fa-code'],
+ 'help' => [1125],
+ ]
+ ),
+ 'data' => $data['config'],
+ 'field' => $field,
+ 'myfield' => $field ? \Phpcmf\Service::L('Field')->toform(0, $field, $data['param']) : '',
+ 'mymerge' => $field ? \Phpcmf\Service::L('Field')->merge : '',
+ 'logofield' => dr_fieldform($logo['logo'], $data['config']['logo']),
+ 'my_site_info' => is_file(MYPATH.'View/site_info.html') ? MYPATH.'View/site_info.html' : '',
+ ]);
+
+ \Phpcmf\Service::V()->display('site_param.html');
+ }
+
+
+}
diff --git a/dayrui/App/Cms/Controllers/Admin/Urlrule.php b/dayrui/App/Cms/Controllers/Admin/Urlrule.php
new file mode 100644
index 0000000..16d321d
--- /dev/null
+++ b/dayrui/App/Cms/Controllers/Admin/Urlrule.php
@@ -0,0 +1,767 @@
+type = array(
+ //0 => dr_lang('鑷畾涔夐〉闈㈡彃浠'),
+ 1 => dr_lang('鐙珛妯″潡'),
+ 2 => dr_lang('鍏变韩妯″潡鎼滅储'),
+ 3 => dr_lang('鍏变韩鏍忕洰鍜屽唴瀹归〉'),
+ //5 => dr_lang('妯″潡琛ㄥ崟'),
+ );
+ if (!dr_is_app('page')) {
+ unset($this->type[0]);
+ }
+ \Phpcmf\Service::V()->assign([
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ 'URL瑙勫垯' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-link'],
+ '娣诲姞' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/add', 'fa fa-plus'],
+ '淇敼' => ['hide:'.APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/edit', 'fa fa-edit'],
+ '浼潤鎬' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/rewrite_index', 'fa fa-cog'],
+ '瀵煎叆' => ['add:'.APP_DIR.'/urlrule/import_add', 'fa fa-sign-in', '60%', '70%'],
+ 'help' => [418],
+ ]
+ ),
+ ]);
+ // 鏀寔闄勮〃瀛樺偍
+ $this->is_data = 0;
+ $this->my_field = array(
+ 'name' => array(
+ 'ismain' => 1,
+ 'name' => dr_lang('鍚嶇О'),
+ 'fieldname' => 'name',
+ 'fieldtype' => 'Text',
+ 'setting' => array(
+ 'option' => array(
+ 'width' => 200,
+ ),
+ 'validate' => array(
+ 'required' => 1,
+ )
+ )
+ ),
+ );
+ // url鏄剧ず鍚嶇О
+ $this->name = dr_lang('URL瑙勫垯');
+ // 鍒濆鍖栨暟鎹〃
+ $this->_init([
+ 'table' => 'urlrule',
+ 'field' => $this->my_field,
+ 'order_by' => 'id desc',
+ ]);
+ }
+
+ // 鍚庡彴鏌ョ湅url鍒楄〃
+ public function index() {
+
+ $this->_List([], -1);
+ \Phpcmf\Service::V()->assign('color', [
+ 0 => 'default',
+ 1 => 'info',
+ 2 => 'success',
+ 3 => 'warning',
+ 4 => 'danger',
+ 5 => '',
+ 6 => 'primary',
+ ]);
+ \Phpcmf\Service::V()->display('urlrule_index.html');
+ }
+
+ // 浼潤鎬
+ public function rewrite_index() {
+
+ $domain = [];
+ list($module, $site) = \Phpcmf\Service::M('Site')->domain();
+ $domain[$site['site_domain']] = dr_lang('鏈珯鐢佃剳鍩熷悕');
+ $site['mobile_domain'] && $domain[$site['mobile_domain']] = dr_lang('鏈珯鎵嬫満鍩熷悕');
+ if ($module) {
+ foreach ($module as $dir => $t) {
+ if ($site['module_'.$dir]) {
+ $domain[$site['module_'.$dir]] = dr_lang('%s鐢佃剳鍩熷悕', $t['name']);
+ }
+ if ($site['module_mobile_'.$dir]) {
+ $domain[$site['module_mobile_'.$dir]] = dr_lang('%s鎵嬫満鍩熷悕', $t['name']);
+ }
+ }
+ }
+
+ $site = \Phpcmf\Service::M('Site')->config(SITE_ID);
+ if ($site['client']) {
+ foreach ($site['client'] as $t) {
+ if ($t['domain']) {
+ $domain[$t['domain']] = dr_lang('%s缁堢鍩熷悕', $t['name']);
+ }
+ }
+ }
+
+ if (strpos($site['config']['SITE_DOMAIN'], '/') !== false) {
+ list($a, $b) = explode('/', $site['config']['SITE_DOMAIN']);
+ $root = '/'.$b;
+ } else {
+ $root = '';
+ }
+ $server = strtolower($_SERVER['SERVER_SOFTWARE']);
+ if (strpos($server, 'apache') !== FALSE) {
+ $name = 'Apache';
+ $note = ''.dr_lang('灏嗕互涓嬪唴瀹逛繚瀛樹负.htaccess鏂囦欢锛屾斁鍒版瘡涓煙鍚嶆墍缁戝畾鐨勬牴鐩綍').' ';
+ $code = '';
+
+ // 瀛愮洰褰
+ $code.= '###褰撳瓨鍦ㄥ涓瓙鐩綍鏍煎紡鐨勫煙鍚嶆椂锛岄渶瑕佸鍐欏嚑缁凴ewriteBase鏍囩锛歊ewriteBase /鐩綍/ '.PHP_EOL;
+ if (isset($site['mobile']['mode']) && $site['mobile']['mode'] && $site['mobile']['dirname']) {
+ $code.= 'RewriteEngine On'.PHP_EOL.PHP_EOL;
+ $code.= 'RewriteBase /'.$site['mobile']['dirname'].'/'.PHP_EOL
+ .'RewriteCond %{REQUEST_FILENAME} !-f'.PHP_EOL
+ .'RewriteCond %{REQUEST_FILENAME} !-d'.PHP_EOL
+ .'RewriteRule !.(js|ico|gif|jpe?g|bmp|png|css)$ /'.$site['mobile']['dirname'].'/index.php [NC,L]'.PHP_EOL.PHP_EOL;
+ $code.= '####浠ヤ笂鐩綍闇瑕佸崟鐙繚鎸佸埌/'.$site['mobile']['dirname'].'/.htaccess鏂囦欢涓';
+ }
+ // 涓荤洰褰
+ $code.= 'RewriteEngine On'.PHP_EOL.PHP_EOL;
+ $code.= 'RewriteBase '.$root.'/'.PHP_EOL
+ .'RewriteCond %{REQUEST_FILENAME} !-f'.PHP_EOL
+ .'RewriteCond %{REQUEST_FILENAME} !-d'.PHP_EOL
+ .'RewriteRule !.(js|ico|gif|jpe?g|bmp|png|css)$ '.$root.'/index.php [NC,L]'.PHP_EOL.PHP_EOL;
+ } elseif (strpos($server, 'nginx') !== FALSE) {
+ $name = $server;
+ $note = ''.dr_lang('灏嗕互涓嬩唬鐮佹斁鍒癗ginx閰嶇疆鏂囦欢涓幓锛堝鏋滄槸缁戝畾浜嗗煙鍚嶏紝鎵缁戝畾鐩綍涔熻閰嶇疆涓嬮潰鐨勪唬鐮侊級').' ';
+ // 瀛愮洰褰
+ $code = '###褰撳瓨鍦ㄥ涓瓙鐩綍鏍煎紡鐨勫煙鍚嶆椂锛岄渶瑕佸鍐欏嚑缁刲ocation鏍囩锛歭ocation /鐩綍/ '.PHP_EOL;
+ if (isset($site['mobile']['mode']) && $site['mobile']['mode'] && $site['mobile']['dirname']) {
+ $code.= 'location '.$root.'/'.$site['mobile']['dirname'].'/ { '.PHP_EOL
+ .' if (-f $request_filename) {'.PHP_EOL
+ .' break;'.PHP_EOL
+ .' }'.PHP_EOL
+ .' if ($request_filename ~* "\.(js|ico|gif|jpe?g|bmp|png|css)$") {'.PHP_EOL
+ .' break;'.PHP_EOL
+ .' }'.PHP_EOL
+ .' if (!-e $request_filename) {'.PHP_EOL
+ .' rewrite . '.$root.'/'.$site['mobile']['dirname'].'/index.php last;'.PHP_EOL
+ .' }'.PHP_EOL
+ .'}'.PHP_EOL.PHP_EOL;
+ }
+ // 涓荤洰褰
+ $code.= 'location '.$root.'/ { '.PHP_EOL
+ .' if (-f $request_filename) {'.PHP_EOL
+ .' break;'.PHP_EOL
+ .' }'.PHP_EOL
+ .' if ($request_filename ~* "\.(js|ico|gif|jpe?g|bmp|png|css)$") {'.PHP_EOL
+ .' break;'.PHP_EOL
+ .' }'.PHP_EOL
+ .' if (!-e $request_filename) {'.PHP_EOL
+ .' rewrite . '.$root.'/index.php last;'.PHP_EOL
+ .' }'.PHP_EOL
+ .'}'.PHP_EOL;
+ } else {
+ $name = $server;
+ $note = ''.dr_lang('鏃犳硶涓烘鏈嶅姟鍣ㄦ彁渚涗吉闈欐佽鍒欙紝寤鸿璁╄繍钀ュ晢甯綘鎶婁笅闈㈢殑Apache瑙勫垯鍋氳浆鎹').' ';
+ $code = 'RewriteEngine On'.PHP_EOL
+ .'RewriteBase /'.PHP_EOL
+ .'RewriteCond %{REQUEST_FILENAME} !-f'.PHP_EOL
+ .'RewriteCond %{REQUEST_FILENAME} !-d'.PHP_EOL
+ .'RewriteRule !.(js|ico|gif|jpe?g|bmp|png|css)$ /index.php [NC,L]';
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'name' => $name,
+ 'code' => $code,
+ 'note' => $note,
+ 'site' => $site,
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ 'URL瑙勫垯' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-link'],
+ '浼潤鎬' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/rewrite_index', 'fa fa-cog'],
+ 'help' => [21],
+ ]
+ ),
+ 'count' => $code ? dr_count(explode(PHP_EOL, $code)) : 0,
+ 'domain' => $domain,
+ ]);
+ \Phpcmf\Service::V()->display('urlrule_rewrite.html');
+ }
+
+ // 鍚庡彴娣诲姞url鍐呭
+ public function add() {
+ $this->_Post(0);
+ \Phpcmf\Service::V()->display('urlrule_add.html');
+ }
+
+ // 鍚庡彴淇敼url鍐呭
+ public function edit() {
+ $this->_Post(intval(\Phpcmf\Service::L('input')->get('id')));
+ \Phpcmf\Service::V()->display('urlrule_add.html');
+ }
+
+ // 澶嶅埗url
+ public function copy_edit() {
+
+ $id = intval(\Phpcmf\Service::L('input')->get('id'));
+ $data = \Phpcmf\Service::M()->db->table('urlrule')->where('id', $id)->get()->getRowArray();
+ if (!$data) {
+ $this->_json(0, dr_lang('鏁版嵁#%s涓嶅瓨鍦', $id));
+ }
+
+ unset($data['id']);
+ $data['name'].= '_copy';
+
+ $rt = \Phpcmf\Service::M()->table('urlrule')->insert($data);
+ if (!$rt['code']) {
+ $this->_json(0, dr_lang($rt['msg']));
+ }
+
+ \Phpcmf\Service::M('cache')->sync_cache('urlrule', 'module');
+ $this->_json(1, dr_lang('澶嶅埗鎴愬姛'));
+ }
+
+ // 淇濆瓨
+ protected function _Save($id = 0, $data = [], $old = [], $func = null, $func2 = null) {
+ return parent::_Save($id, $data, $old, function($id, $data){
+ // 淇濆瓨鍓嶇殑鏍煎紡鍖
+ $type = (int)\Phpcmf\Service::L('input')->post('type');
+ $value = \Phpcmf\Service::L('input')->post('value');
+ if ($value[$type]) {
+ foreach ($value[$type] as $i => $t) {
+ if (strpos($t, '?') !== false) {
+ $this->_json(0, dr_lang('URL瑙勫垯涓笉鑳藉寘鍚%s鍙', '?'));
+ } elseif (strpos($t, '#') !== false) {
+ $this->_json(0, dr_lang('URL瑙勫垯涓笉鑳藉寘鍚%s鍙', '#'));
+ } elseif (strpos($t, '(')
+ && preg_match('/\{([a-z0-9_]+)\(\$data\)\}/iU', $t, $mt)) {
+ if (!function_exists($mt[1])) {
+ $this->_json(0, dr_lang('URL瑙勫垯涓嚱鏁%s鏈畾涔', $mt[1]));
+ }
+ }
+ $value[$type][$i] = trim($t);
+ }
+ }
+ $data[1]['type'] = $type;
+ $join = \Phpcmf\Service::L('input')->post('catjoin');
+ $value[$type]['catjoin'] = $join ? $join : '/';
+ $data[1]['value'] = dr_array2string($value[$type]);
+ return dr_return_data(1, 'ok', $data);
+ }, function ($id, $data, $old) {
+ \Phpcmf\Service::M('cache')->sync_cache('urlrule', 'module');
+ });
+ }
+
+ // 瀵煎嚭
+ public function export_edit() {
+
+ $id = intval(\Phpcmf\Service::L('input')->get('id'));
+ $data = \Phpcmf\Service::M()->table('urlrule')->get($id);
+ if (!$data) {
+ $this->_admin_msg(0, dr_lang('URL瑙勫垯锛%s锛変笉瀛樺湪', $id));
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'data' => dr_array2string($data),
+ ]);
+ \Phpcmf\Service::V()->display('api_export_code.html');exit;
+ }
+
+ // 瀵煎叆
+ public function import_add() {
+
+ if (IS_AJAX_POST) {
+ $data = \Phpcmf\Service::L('input')->post('code');
+ $data = dr_string2array($data);
+ if (!is_array($data)) {
+ $this->_json(0, dr_lang('瀵煎叆淇℃伅楠岃瘉澶辫触'));
+ } elseif (!$data['value']) {
+ $this->_json(0, dr_lang('瀵煎叆淇℃伅涓嶅畬鏁'));
+ }
+ unset($data['id']);
+ $rt = \Phpcmf\Service::M()->table('urlrule')->insert($data);
+ if (!$rt['code']) {
+ $this->_json(0, $rt['msg']);
+ }
+ \Phpcmf\Service::M('cache')->sync_cache('urlrule', 'module');
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'data' => '',
+ 'form' => dr_form_hidden(),
+ ]);
+ \Phpcmf\Service::V()->display('api_export_code.html');
+ exit;
+ }
+
+ /**
+ * 鑾峰彇鍐呭
+ * $id 鍐呭id,鏂板涓0
+ * */
+ protected function _Data($id = 0) {
+ $data = parent::_Data($id);
+ $data['value'] = dr_string2array($data['value']);
+ return $data;
+ }
+
+ // 鍚庡彴鍒犻櫎url鍐呭
+ public function del() {
+ $this->_Del(
+ \Phpcmf\Service::L('input')->get_post_ids(),
+ null,
+ function ($r) {
+ \Phpcmf\Service::M('cache')->sync_cache('urlrule', 'module');
+ }
+ );
+ }
+
+ // 鐢熸垚浼潤鎬佽В鏋愭枃浠惰鍒
+ public function rewrite_add() {
+ $rt = $this->get_rewrite_code();
+ $this->_json($rt['code'], $rt['msg'], $rt['data']);
+ }
+
+ // 鐢熸垚浼潤鎬佽В鏋愪唬鐮
+ private function get_rewrite_code() {
+
+ $data = \Phpcmf\Service::M()->table('urlrule')->getAll();
+ if (!$data) {
+ return dr_return_data(0, dr_lang('浣犳病鏈夎缃甎RL瑙勫垯'));
+ }
+
+ $code = '';
+ $error = '';
+ $write = []; // 闃叉閲嶅
+ foreach ($data as $r) {
+ $value = dr_string2array($r['value']);
+ if ($r['type'] == 1) {
+ // 鐙珛妯″潡
+ $code.= PHP_EOL.' // '.$r['name'].'---瑙f瀽瑙勫垯----寮濮'.PHP_EOL;
+ if ($value['module']) {
+ $rule = $value['module'];
+ $cname = "銆".$r['name']."銆戞ā鍧楅椤碉紙{$rule}锛";
+ list($preg, $rname) = $this->_rule_preg_value($rule);
+ if (!$preg) {
+ $error.= "".$cname."鏃犳硶璇嗗埆锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ if (!isset($rname['{modname}'])) {
+ $rule = 'index.php?s=鎵嬪姩濉啓妯″潡鐩綍';
+ } else {
+ $rule = 'index.php?s=$'.$rname['{modname}'];
+ }
+ if (isset($write[$preg])) {
+ $error.= "".$cname."涓".$write[$preg]."瑙勫垯瀛樺湪鍐茬獊锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ $write[$preg] = $cname;
+ $code.= ' "'.$preg.'" => "'.$rule.'", //'.$cname.'锛堟瑙勫垯鐢辩郴缁熺敓鎴愶紝涓嶄竴瀹氫細鍑嗙‘锛岃寮鍙戣呰嚜琛岃皟鏁达級 ';
+ }
+ }
+ }
+ if ($value['list_page']) {
+ $rule = $value['list_page'];
+ $cname = "銆".$r['name']."銆戞ā鍧楁爮鐩垪琛(鍒嗛〉)锛坽$rule}锛";
+ list($preg, $rname) = $this->_rule_preg_value($rule);
+ if (!$rname) {
+ $error.= "".$cname."鏃犳硶璇嗗埆锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } elseif (!isset($rname['{page}'])) {
+ $error.= "".$cname."缂哄皯{page}鏍囩锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } elseif (!isset($rname['{dirname}']) && !isset($rname['{id}']) && !isset($rname['{pdirname}'])) {
+ $error.= "".$cname."缂哄皯{dirname}鎴杮id}鎴杮pdirname}鏍囩锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ if (!isset($rname['{modname}'])) {
+ $rname['{modname}'] = '{modname}';
+ }
+ if (isset($rname['{dirname}'])) {
+ // 鐩綍鏍煎紡
+ $rule = 'index.php?s=$'.$rname['{modname}'].'&c=category&dir=$'.$rname['{dirname}'].'&page=$'.$rname['{page}'];
+ } elseif (isset($rname['{pdirname}'])) {
+ // 灞傛鐩綍鏍煎紡
+ $rule = 'index.php?s=$'.$rname['{modname}'].'&c=category&dir=$'.$rname['{pdirname}'].'&page=$'.$rname['{page}'];
+ } else {
+ // id妯″紡
+ $rule = 'index.php?s=$'.$rname['{modname}'].'&c=category&id=$'.$rname['{id}'].'&page=$'.$rname['{page}'];
+ }
+ $rule = str_replace('${modname}', '鎵嬪姩濉啓妯″潡鐩綍', $rule);
+ if (isset($write[$preg])) {
+ $error.= "".$cname."涓".$write[$preg]."瑙勫垯瀛樺湪鍐茬獊锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ $write[$preg] = $cname;
+ $code.= ' "'.$preg.'" => "'.$rule.'", //'.$cname.'锛堟瑙勫垯鐢辩郴缁熺敓鎴愶紝涓嶄竴瀹氫細鍑嗙‘锛岃寮鍙戣呰嚜琛岃皟鏁达級 ';
+ }
+ }
+ }
+ if ($value['list']) {
+ $rule = $value['list'];
+ $cname = "銆".$r['name']."銆戞ā鍧楁爮鐩垪琛紙{$rule}锛";
+ list($preg, $rname) = $this->_rule_preg_value($rule);
+ if (!$rname) {
+ $error.= "".$cname."鏃犳硶璇嗗埆锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } elseif (!isset($rname['{dirname}']) && !isset($rname['{id}']) && !isset($rname['{pdirname}'])) {
+ $error.= "".$cname."缂哄皯{dirname}鎴杮id}鎴杮pdirname}鏍囩锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ if (!isset($rname['{modname}'])) {
+ $rname['{modname}'] = '{modname}';
+ }
+ if (isset($rname['{dirname}'])) {
+ // 鐩綍鏍煎紡
+ $rule = 'index.php?s=$'.$rname['{modname}'].'&c=category&dir=$'.$rname['{dirname}'];
+ } elseif (isset($rname['{pdirname}'])) {
+ // 灞傛鐩綍鏍煎紡
+ $rule = 'index.php?s=$'.$rname['{modname}'].'&c=category&dir=$'.$rname['{pdirname}'];
+ } else {
+ // id妯″紡
+ $rule = 'index.php?s=$'.$rname['{modname}'].'&c=category&id=$'.$rname['{id}'];
+ }
+ $rule = str_replace('${modname}', '鎵嬪姩濉啓妯″潡鐩綍', $rule);
+ if (isset($write[$preg])) {
+ $error.= "".$cname."涓".$write[$preg]."瑙勫垯瀛樺湪鍐茬獊锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ $write[$preg] = $cname;
+ $code.= ' "'.$preg.'" => "'.$rule.'", //'.$cname."锛堟瑙勫垯鐢辩郴缁熺敓鎴愶紝涓嶄竴瀹氫細鍑嗙‘锛岃寮鍙戣呰嚜琛岃皟鏁达級 ";
+ }
+ }
+ }
+ if ($value['show_page']) {
+ $rule = $value['show_page'];
+ $cname = "銆".$r['name']."銆戞ā鍧楀唴瀹归〉(鍒嗛〉)锛坽$rule}锛";
+ list($preg, $rname) = $this->_rule_preg_value($rule);
+ if (!$rname) {
+ $error.= "".$cname."鏃犳硶璇嗗埆锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } elseif (!isset($rname['{id}'])) {
+ $error.= "".$cname."缂哄皯{id}鏍囩锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } elseif (!isset($rname['{page}'])) {
+ $error.= "".$cname."缂哄皯{page}鏍囩锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ if (!isset($rname['{modname}'])) {
+ $rname['{modname}'] = '{modname}';
+ }
+ $rule = 'index.php?s=$'.$rname['{modname}'].'&c=show&id=$'.$rname['{id}'].'&page=$'.$rname['{page}'];
+ $rule = str_replace('${modname}', '鎵嬪姩濉啓妯″潡鐩綍', $rule);
+ if (isset($write[$preg])) {
+ $error.= "".$cname."涓".$write[$preg]."瑙勫垯瀛樺湪鍐茬獊锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ $write[$preg] = $cname;
+ $code.= ' "'.$preg.'" => "'.$rule.'", //'.$cname."锛堟瑙勫垯鐢辩郴缁熺敓鎴愶紝涓嶄竴瀹氫細鍑嗙‘锛岃寮鍙戣呰嚜琛岃皟鏁达級 ";
+ }
+ }
+ }
+ if ($value['show']) {
+ $rule = $value['show'];
+ $cname = "銆".$r['name']."銆戞ā鍧楀唴瀹归〉锛坽$rule}锛";
+ list($preg, $rname) = $this->_rule_preg_value($rule);
+ if (!$rname) {
+ $error.= "".$cname."鏃犳硶璇嗗埆锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } elseif (!isset($rname['{id}'])) {
+ $error.= "".$cname."缂哄皯{id}鏍囩锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ if (!isset($rname['{modname}'])) {
+ $rname['{modname}'] = '{modname}';
+ }
+ $rule = 'index.php?s=$'.$rname['{modname}'].'&c=show&id=$'.$rname['{id}'];
+ $rule = str_replace('${modname}', '鎵嬪姩濉啓妯″潡鐩綍', $rule);
+ if (isset($write[$preg])) {
+ $error.= "".$cname."涓".$write[$preg]."瑙勫垯瀛樺湪鍐茬獊锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ $write[$preg] = $cname;
+ $code.= ' "'.$preg.'" => "'.$rule.'", //'.$cname."锛堟瑙勫垯鐢辩郴缁熺敓鎴愶紝涓嶄竴瀹氫細鍑嗙‘锛岃寮鍙戣呰嚜琛岃皟鏁达級 ";
+ }
+ }
+ }
+ if ($value['search_page']) {
+ $rule = $value['search_page'];
+ $cname = "銆".$r['name']."銆戞ā鍧楁悳绱㈤〉(鍒嗛〉)锛坽$rule}锛";
+ list($preg, $rname) = $this->_rule_preg_value($rule);
+ if (!$rname) {
+ $error.= "".$cname."鏃犳硶璇嗗埆锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } elseif (!isset($rname['{param}']) && !isset($rname['{rewrite}'])) {
+ $error.= "".$cname."缂哄皯{param}鏍囩锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ if (!isset($rname['{modname}'])) {
+ $rname['{modname}'] = '{modname}';
+ }
+ $rule = 'index.php?s=$'.$rname['{modname}'].'&c=search&rewrite=$'.($rname['{param}'] ? $rname['{param}'] : $rname['{rewrite}']);
+ $rule = str_replace('${modname}', '鎵嬪姩濉啓妯″潡鐩綍', $rule);
+ if (isset($write[$preg])) {
+ $error.= "".$cname."涓".$write[$preg]."瑙勫垯瀛樺湪鍐茬獊锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ $write[$preg] = $cname;
+ $code.= ' "'.$preg.'" => "'.$rule.'", //'.$cname."锛堟瑙勫垯鐢辩郴缁熺敓鎴愶紝涓嶄竴瀹氫細鍑嗙‘锛岃寮鍙戣呰嚜琛岃皟鏁达級 ";
+ }
+ }
+ }
+ if ($value['search']) {
+ $rule = $value['search'];
+ $cname = "銆".$r['name']."銆戞ā鍧楁悳绱㈤〉锛坽$rule}锛";
+ list($preg, $rname) = $this->_rule_preg_value($rule);
+ if (!$preg) {
+ $error.= "".$cname."鏃犳硶璇嗗埆锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ if (!isset($rname['{modname}'])) {
+ $rname['{modname}'] = '{modname}';
+ }
+ $rule = 'index.php?s=$'.$rname['{modname}'].'&c=search';
+ $rule = str_replace('${modname}', '鎵嬪姩濉啓妯″潡鐩綍', $rule);
+ if (isset($write[$preg])) {
+ $error.= "".$cname."涓".$write[$preg]."瑙勫垯瀛樺湪鍐茬獊锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ $write[$preg] = $cname;
+ $code.= ' "'.$preg.'" => "'.$rule.'", //'.$cname."锛堟瑙勫垯鐢辩郴缁熺敓鎴愶紝涓嶄竴瀹氫細鍑嗙‘锛岃寮鍙戣呰嚜琛岃皟鏁达級 ";
+ }
+ }
+ }
+
+ $code.= PHP_EOL.' // '.$r['name'].'---瑙f瀽瑙勫垯----缁撴潫'.PHP_EOL;
+ } elseif ($r['type'] == 3 ) {
+ // 鍏变韩鏍忕洰
+ $code.= PHP_EOL.' // '.$r['name'].'---瑙f瀽瑙勫垯----寮濮'.PHP_EOL;
+ if ($value['list_page']) {
+ $rule = $value['list_page'];
+ $cname = "銆".$r['name']."銆戞ā鍧楁爮鐩垪琛(鍒嗛〉)锛坽$rule}锛";
+ list($preg, $rname) = $this->_rule_preg_value($rule);
+ if (!$preg || !$rname) {
+ $error.= "".$cname."鏃犳硶璇嗗埆锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } elseif (!isset($rname['{page}'])) {
+ $error.= "".$cname."缂哄皯{page}鏍囩锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } elseif (!isset($rname['{dirname}']) && !isset($rname['{id}']) && !isset($rname['{pdirname}'])) {
+ $error.= "".$cname."缂哄皯{dirname}鎴杮id}鎴杮pdirname}鏍囩锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ if (isset($rname['{dirname}'])) {
+ // 鐩綍鏍煎紡
+ $rule = 'index.php?c=category&dir=$'.$rname['{dirname}'].'&page=$'.$rname['{page}'];
+ } elseif (isset($rname['{pdirname}'])) {
+ // 灞傛鐩綍鏍煎紡
+ $rule = 'index.php?c=category&dir=$'.$rname['{pdirname}'].'&page=$'.$rname['{page}'];
+ } else {
+ // id妯″紡
+ $rule = 'index.php?c=category&id=$'.$rname['{id}'].'&page=$'.$rname['{page}'];
+ }
+ if (isset($write[$preg])) {
+ $error.= "".$cname."涓".$write[$preg]."瑙勫垯瀛樺湪鍐茬獊锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ $write[$preg] = $cname;
+ $code.= ' "'.$preg.'" => "'.$rule.'", //'.$cname."锛堟瑙勫垯鐢辩郴缁熺敓鎴愶紝涓嶄竴瀹氫細鍑嗙‘锛岃寮鍙戣呰嚜琛岃皟鏁达級 ";
+ }
+ }
+ }
+ if ($value['list']) {
+ $rule = $value['list'];
+ $cname = "銆".$r['name']."銆戞ā鍧楁爮鐩垪琛紙{$rule}锛";
+ list($preg, $rname) = $this->_rule_preg_value($rule);
+ if (!$preg || !$rname) {
+ $error.= "".$cname."鏃犳硶璇嗗埆锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } elseif (!isset($rname['{dirname}']) && !isset($rname['{id}']) && !isset($rname['{pdirname}'])) {
+ $error.= "".$cname."缂哄皯{dirname}鎴杮id}鎴杮pdirname}鏍囩锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ if (isset($rname['{dirname}'])) {
+ // 鐩綍鏍煎紡
+ $rule = 'index.php?c=category&dir=$'.$rname['{dirname}'];
+ } elseif (isset($rname['{pdirname}'])) {
+ // 灞傛鐩綍鏍煎紡
+ $rule = 'index.php?c=category&dir=$'.$rname['{pdirname}'];
+ } else {
+ // id妯″紡
+ $rule = 'index.php?c=category&id=$'.$rname['{id}'];
+ }
+ if (isset($write[$preg])) {
+ $error.= "".$cname."涓".$write[$preg]."瑙勫垯瀛樺湪鍐茬獊锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ $write[$preg] = $cname;
+ $code.= ' "'.$preg.'" => "'.$rule.'", //'.$cname."锛堟瑙勫垯鐢辩郴缁熺敓鎴愶紝涓嶄竴瀹氫細鍑嗙‘锛岃寮鍙戣呰嚜琛岃皟鏁达級 ";
+ }
+ }
+ }
+ if ($value['show_page']) {
+ $rule = $value['show_page'];
+ $cname = "銆".$r['name']."銆戞ā鍧楀唴瀹归〉(鍒嗛〉)锛坽$rule}锛";
+ list($preg, $rname) = $this->_rule_preg_value($rule);
+ if (!$preg || !$rname) {
+ $error.= "".$cname."鏃犳硶璇嗗埆锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } elseif (!isset($rname['{page}'])) {
+ $error.= "".$cname."缂哄皯{page}鏍囩锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } elseif (!isset($rname['{id}'])) {
+ $error.= "".$cname."缂哄皯{id}鏍囩锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ $rule = 'index.php?c=show&id=$'.$rname['{id}'].'&page=$'.$rname['{page}'];
+ if (isset($write[$preg])) {
+ $error.= "".$cname."涓".$write[$preg]."瑙勫垯瀛樺湪鍐茬獊锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ $write[$preg] = $cname;
+ $code.= ' "'.$preg.'" => "'.$rule.'", //'.$cname."锛堟瑙勫垯鐢辩郴缁熺敓鎴愶紝涓嶄竴瀹氫細鍑嗙‘锛岃寮鍙戣呰嚜琛岃皟鏁达級 ";
+ }
+ }
+ }
+ if ($value['show']) {
+ $rule = $value['show'];
+ $cname = "銆".$r['name']."銆戞ā鍧楀唴瀹归〉锛坽$rule}锛";
+ list($preg, $rname) = $this->_rule_preg_value($rule);
+ if (!$preg || !$rname) {
+ $error.= "".$cname."鏃犳硶璇嗗埆锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } elseif (!isset($rname['{id}'])) {
+ $error.= "".$cname."鏃犳硶璇嗗埆锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ $rule = 'index.php?c=show&id=$'.$rname['{id}'];
+ if (isset($write[$preg])) {
+ $error.= "".$cname."涓".$write[$preg]."瑙勫垯瀛樺湪鍐茬獊锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ $write[$preg] = $cname;
+ $code.= ' "'.$preg.'" => "'.$rule.'", //'.$cname."锛堟瑙勫垯鐢辩郴缁熺敓鎴愶紝涓嶄竴瀹氫細鍑嗙‘锛岃寮鍙戣呰嚜琛岃皟鏁达級 ";
+ }
+ }
+ }
+ $code.= PHP_EOL.' // '.$r['name'].'---瑙f瀽瑙勫垯----缁撴潫'.PHP_EOL;
+ } elseif ($r['type'] == 2 ) {
+ // 鍏变韩妯″潡
+ $code.= PHP_EOL.' // '.$r['name'].'---瑙f瀽瑙勫垯----寮濮'.PHP_EOL;
+ if ($value['search_page']) {
+ $rule = $value['search_page'];
+ $cname = "銆".$r['name']."銆戞ā鍧楁悳绱㈤〉(鍒嗛〉)锛坽$rule}锛";
+ list($preg, $rname) = $this->_rule_preg_value($rule);
+ if (!$preg || !$rname) {
+ $error.= "".$cname."鏃犳硶璇嗗埆锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } elseif (!isset($rname['{modname}'])) {
+ $error.= "".$cname."缂哄皯{modname}鏍囩锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } elseif (!isset($rname['{param}'])) {
+ $error.= "".$cname."缂哄皯{param}鏍囩锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ $rule = 'index.php?s=$'.$rname['{modname}'].'&c=search&rewrite=$'.$rname['{param}'];
+ if (isset($write[$preg])) {
+ $error.= "".$cname."涓".$write[$preg]."瑙勫垯瀛樺湪鍐茬獊锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ $write[$preg] = $cname;
+ $code.= ' "'.$preg.'" => "'.$rule.'", //'.$cname."锛堟瑙勫垯鐢辩郴缁熺敓鎴愶紝涓嶄竴瀹氫細鍑嗙‘锛岃寮鍙戣呰嚜琛岃皟鏁达級 ";
+ }
+ }
+ }
+ if ($value['search']) {
+ $rule = $value['search'];
+ $cname = "銆".$r['name']."銆戞ā鍧楁悳绱㈤〉锛坽$rule}锛";
+ list($preg, $rname) = $this->_rule_preg_value($rule);
+ if (!$preg || !$rname) {
+ $error.= "".$cname."鏃犳硶璇嗗埆锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } elseif (!isset($rname['{modname}'])) {
+ $error.= "".$cname."缂哄皯{modname}鏍囩锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ $rule = 'index.php?s=$'.$rname['{modname}'].'&c=search';
+ if (isset($write[$preg])) {
+ $error.= "".$cname."涓".$write[$preg]."瑙勫垯瀛樺湪鍐茬獊锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ $write[$preg] = $cname;
+ $code.= ' "'.$preg.'" => "'.$rule.'", //'.$cname."锛堟瑙勫垯鐢辩郴缁熺敓鎴愶紝涓嶄竴瀹氫細鍑嗙‘锛岃寮鍙戣呰嚜琛岃皟鏁达級 ";
+ }
+ }
+ }
+ $code.= PHP_EOL.' // '.$r['name'].'---瑙f瀽瑙勫垯----缁撴潫'.PHP_EOL;
+ } elseif ($r['type'] == 4 ) {
+ // 鍏抽敭璇嶅簱鎻掍欢
+ $code.= PHP_EOL.' // '.$r['name'].'---瑙f瀽瑙勫垯----寮濮'.PHP_EOL;
+ if ($value['tag']) {
+ $rule = $value['tag'];
+ $cname = "銆".$r['name']."銆慣agURL锛坽$rule}锛";
+ list($preg, $rname) = $this->_rule_preg_value($rule);
+ if (!$preg || !$rname) {
+ $error.= "".$cname."鏃犳硶璇嗗埆锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } elseif (!isset($rname['{tag}'])) {
+ $error.= "".$cname."缂哄皯{tag}鏍囩锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ $rule = 'index.php?s=tag&name=$'.$rname['{tag}'];
+ if (isset($write[$preg])) {
+ $error.= "".$cname."涓".$write[$preg]."瑙勫垯瀛樺湪鍐茬獊锛岄渶瑕佹墜鍔ㄥ啓瑙f瀽瑙勫垯
";
+ } else {
+ $write[$preg] = $cname;
+ $code.= ' "'.$preg.'" => "'.$rule.'", //'.$cname."锛堟瑙勫垯鐢辩郴缁熺敓鎴愶紝涓嶄竴瀹氫細鍑嗙‘锛岃寮鍙戣呰嚜琛岃皟鏁达級 ";
+ }
+ }
+ }
+
+ $code.= PHP_EOL.' // '.$r['name'].'---瑙f瀽瑙勫垯----缁撴潫'.PHP_EOL;
+ }
+ }
+
+ return dr_return_data(1, dr_lang('鐢熸垚鎴愬姛'), [
+ 'code' => nl2br($code),
+ 'error' => $error,
+ ]);
+ }
+
+
+ // 姝e垯瑙f瀽
+ private function _rule_preg_value($rule) {
+
+ $rule = trim(trim($rule, '/'));
+
+ if (preg_match_all('/\{(.*)\}/U', $rule, $match)) {
+
+ $value = [];
+ foreach ($match[0] as $k => $v) {
+ $value[$v] = ($k + 1);
+ }
+
+ $preg = preg_replace(
+ [
+ '#\{id\}#U',
+ '#\{uid\}#U',
+ '#\{mid\}#U',
+ '#\{fid\}#U',
+ '#\{page\}#U',
+
+ '#\{pdirname\}#Ui',
+ '#\{dirname\}#Ui',
+ '#\{opdirname\}#Ui',
+ '#\{otdirname\}#Ui',
+ '#\{modname\}#Ui',
+ '#\{name\}#Ui',
+
+ '#\{tag\}#U',
+ '#\{param\}#U',
+ '#\{rewrite\}#U',
+
+ '#\{y\}#U',
+ '#\{m\}#U',
+ '#\{d\}#U',
+
+ '#\{\.+}#U',
+ '#/#'
+ ],
+ [
+ '([0-9]+)',
+ '([0-9]+)',
+ '(\d+)',
+ '(\w+)',
+ '([0-9]+)',
+
+ '([\w\/]+)',
+ '([A-za-z0-9 \-\_]+)',
+ '([A-za-z0-9 \-\_]+)',
+ '([A-za-z0-9 \-\_]+)',
+ '([a-z]+)',
+ '([a-z]+)',
+
+ '(.+)',
+ '(.+)',
+ '(.+)',
+
+ '([0-9]{4})',
+ '([0-9]{2})',
+ '([0-9]{2})',
+
+ '(.+)',
+ '\/'
+ ],
+ $rule
+ );
+
+ // 鏇挎崲鐗规畩鐨勭粨鏋
+ $preg = str_replace(
+ ['(.+))}-', '.html'],
+ ['(.+)-', '\.html'],
+ $preg
+ );
+
+ return [$preg, $value];
+ }
+
+ return [$rule, []];
+ }
+
+
+}
diff --git a/dayrui/App/Cms/Controllers/Admin/Urlrule_code.php b/dayrui/App/Cms/Controllers/Admin/Urlrule_code.php
new file mode 100644
index 0000000..700c9f2
--- /dev/null
+++ b/dayrui/App/Cms/Controllers/Admin/Urlrule_code.php
@@ -0,0 +1,114 @@
+domain();
+ $domain[$site['site_domain']] = dr_lang('鏈珯鐢佃剳鍩熷悕');
+ $site['mobile_domain'] && $domain[$site['mobile_domain']] = dr_lang('鏈珯鎵嬫満鍩熷悕');
+ if ($module) {
+ foreach ($module as $dir => $t) {
+ if ($site['module_'.$dir]) {
+ $domain[$site['module_'.$dir]] = dr_lang('%s鐢佃剳鍩熷悕', $t['name']);
+ }
+ if ($site['module_mobile_'.$dir]) {
+ $domain[$site['module_mobile_'.$dir]] = dr_lang('%s鎵嬫満鍩熷悕', $t['name']);
+ }
+ }
+ }
+
+ $site = \Phpcmf\Service::M('Site')->config(SITE_ID);
+ if ($site['client']) {
+ foreach ($site['client'] as $t) {
+ if ($t['domain']) {
+ $domain[$t['domain']] = dr_lang('%s缁堢鍩熷悕', $t['name']);
+ }
+ }
+ }
+ if (strpos($site['config']['SITE_DOMAIN'], '/') !== false) {
+ list($a, $b) = explode('/', $site['config']['SITE_DOMAIN']);
+ $root = '/'.$b;
+ } else {
+ $root = '';
+ }
+ $server = strtolower($_SERVER['SERVER_SOFTWARE']);
+ if (strpos($server, 'apache') !== FALSE) {
+ $name = 'Apache';
+ $note = '灏嗕互涓嬪唴瀹逛繚瀛樹负.htaccess鏂囦欢锛屾斁鍒版瘡涓煙鍚嶆墍缁戝畾鐨勬牴鐩綍 ';
+ $code = '';
+
+ // 瀛愮洰褰
+ $code.= '###褰撳瓨鍦ㄥ涓瓙鐩綍鏍煎紡鐨勫煙鍚嶆椂锛岄渶瑕佸鍐欏嚑缁凴ewriteBase鏍囩锛歊ewriteBase /鐩綍/ '.PHP_EOL;
+ if (isset($site['mobile']['mode']) && $site['mobile']['mode'] && $site['mobile']['dirname']) {
+ $code.= 'RewriteEngine On'.PHP_EOL.PHP_EOL;
+ $code.= 'RewriteBase /'.$site['mobile']['dirname'].'/'.PHP_EOL
+ .'RewriteCond %{REQUEST_FILENAME} !-f'.PHP_EOL
+ .'RewriteCond %{REQUEST_FILENAME} !-d'.PHP_EOL
+ .'RewriteRule !.(js|ico|gif|jpe?g|bmp|png|css)$ /'.$site['mobile']['dirname'].'/index.php [NC,L]'.PHP_EOL.PHP_EOL;
+ $code.= '####浠ヤ笂鐩綍闇瑕佸崟鐙繚鎸佸埌/'.$site['mobile']['dirname'].'/.htaccess鏂囦欢涓';
+ }
+ // 涓荤洰褰
+ $code.= 'RewriteEngine On'.PHP_EOL.PHP_EOL;
+ $code.= 'RewriteBase '.$root.'/'.PHP_EOL
+ .'RewriteCond %{REQUEST_FILENAME} !-f'.PHP_EOL
+ .'RewriteCond %{REQUEST_FILENAME} !-d'.PHP_EOL
+ .'RewriteRule !.(js|ico|gif|jpe?g|bmp|png|css)$ '.$root.'/index.php [NC,L]'.PHP_EOL.PHP_EOL;
+ } elseif (strpos($server, 'nginx') !== FALSE) {
+ $name = $server;
+ $note = '灏嗕互涓嬩唬鐮佹斁鍒癗ginx閰嶇疆鏂囦欢涓幓锛堝鏋滄槸缁戝畾浜嗗煙鍚嶏紝鎵缁戝畾鐩綍涔熻閰嶇疆涓嬮潰鐨勪唬鐮侊級 ';
+ // 瀛愮洰褰
+ $code = '###褰撳瓨鍦ㄥ涓瓙鐩綍鏍煎紡鐨勫煙鍚嶆椂锛岄渶瑕佸鍐欏嚑缁刲ocation鏍囩锛歭ocation /鐩綍/ '.PHP_EOL;
+ if (isset($site['mobile']['mode']) && $site['mobile']['mode'] && $site['mobile']['dirname']) {
+ $code.= 'location '.$root.'/'.$site['mobile']['dirname'].'/ { '.PHP_EOL
+ .' if (-f $request_filename) {'.PHP_EOL
+ .' break;'.PHP_EOL
+ .' }'.PHP_EOL
+ .' if ($request_filename ~* "\.(js|ico|gif|jpe?g|bmp|png|css)$") {'.PHP_EOL
+ .' break;'.PHP_EOL
+ .' }'.PHP_EOL
+ .' if (!-e $request_filename) {'.PHP_EOL
+ .' rewrite . '.$root.'/'.$site['mobile']['dirname'].'/index.php last;'.PHP_EOL
+ .' }'.PHP_EOL
+ .'}'.PHP_EOL.PHP_EOL;
+ }
+ // 涓荤洰褰
+ $code.= 'location '.$root.'/ { '.PHP_EOL
+ .' if (-f $request_filename) {'.PHP_EOL
+ .' break;'.PHP_EOL
+ .' }'.PHP_EOL
+ .' if ($request_filename ~* "\.(js|ico|gif|jpe?g|bmp|png|css)$") {'.PHP_EOL
+ .' break;'.PHP_EOL
+ .' }'.PHP_EOL
+ .' if (!-e $request_filename) {'.PHP_EOL
+ .' rewrite . '.$root.'/index.php last;'.PHP_EOL
+ .' }'.PHP_EOL
+ .'}'.PHP_EOL;
+ } else {
+ $name = $server;
+ $note = '鏃犳硶涓烘鏈嶅姟鍣ㄦ彁渚涗吉闈欐佽鍒欙紝寤鸿璁╄繍钀ュ晢甯綘鎶婁笅闈㈢殑Apache瑙勫垯鍋氳浆鎹 ';
+ $code = 'RewriteEngine On'.PHP_EOL
+ .'RewriteBase /'.PHP_EOL
+ .'RewriteCond %{REQUEST_FILENAME} !-f'.PHP_EOL
+ .'RewriteCond %{REQUEST_FILENAME} !-d'.PHP_EOL
+ .'RewriteRule !.(js|ico|gif|jpe?g|bmp|png|css)$ /index.php [NC,L]';
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'name' => $name,
+ 'code' => $code,
+ 'note' => $note,
+ 'domain' => $domain,
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '浼潤鎬佷唬鐮' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-link'],
+ ]
+ ),
+ 'count' => $code ? dr_count(explode(PHP_EOL, $code)) : 0,
+ ]);
+ \Phpcmf\Service::V()->display('urlrule_code.html');exit;
+ }
+
+}
diff --git a/dayrui/App/Cms/Controllers/Api.php b/dayrui/App/Cms/Controllers/Api.php
new file mode 100644
index 0000000..18aa5d1
--- /dev/null
+++ b/dayrui/App/Cms/Controllers/Api.php
@@ -0,0 +1,236 @@
+get('mid'));
+ if (!$dirname) {
+ $dirname = dr_safe_filename(\Phpcmf\Service::L('input')->get('module'));
+ }
+ if (!$dirname) {
+ $this->_json(0, dr_lang('module鍙傛暟涓嶅瓨鍦'));
+ }
+
+ $site = max(1, (int)\Phpcmf\Service::L('input')->get('site'));
+ if (!$site) {
+ $site = SITE_ID;
+ }
+
+ // 鐙珛妯″潡濉洰褰 / 鍏变韩妯″潡濉 share
+ $category = \Phpcmf\Service::L('category', 'module')->get_category($dirname, $site);
+ if (!$category) {
+ $this->_json(0, dr_lang('鏍忕洰涓嶅瓨鍦ㄦ垨鏈敓鎴愮紦瀛'), []);
+ }
+
+ // 妯″潡鏄惁鍏变韩锛堢紦瀛橈級
+ $mod_share = [];
+
+ $list = [];
+ foreach ($category as $id => $t) {
+ if (!$t || !is_array($t)) {
+ continue;
+ }
+ $tid = (int)($t['tid'] ?? 0);
+ // 澶栭摼鏍忕洰涓嶈緭鍑
+ if ($tid === 2) {
+ continue;
+ }
+
+ $cid = (int)($t['id'] ?? $id);
+ $cmid = dr_safe_filename((string)($t['mid'] ?? ''));
+
+ // show_url锛氬熀纭璺緞锛岀珯鐐瑰煙鍚嶄笌 api_token 鐢卞鎴风鑷缁勮
+ if ($dirname !== 'share') {
+ $t['show_url'] = 'index.php?s='.$dirname.'&c=category&id='.$cid;
+ } else {
+ $use_s = false;
+ if ($cmid !== '') {
+ if (!isset($mod_share[$cmid])) {
+ $mod = \Phpcmf\Service::L('cache')->get('module-'.$site.'-'.$cmid);
+ $mod_share[$cmid] = ($mod && empty($mod['share'])) ? 0 : 1;
+ }
+ // share=0 琛ㄧず鐙珛妯″潡
+ $use_s = ($mod_share[$cmid] === 0);
+ }
+ if ($use_s) {
+ $t['show_url'] = 'index.php?s='.$cmid.'&c=category&id='.$cid;
+ } else {
+ $t['show_url'] = 'index.php?c=category&id='.$cid;
+ }
+ }
+
+ // list_url锛氭ā鍧楁爮鐩墠鏈夊垪琛
+ if ($tid === 1 && $cmid !== '') {
+ $t['list_url'] = 'index.php?s='.$cmid.'&c=search&catid='.$cid;
+ } else {
+ $t['list_url'] = '';
+ }
+
+ $list[$id] = $t;
+ }
+
+ $this->_json(1, 'ok', $list);
+ }
+
+
+ /**
+ * 鍐呭鍏宠仈瀛楁鏁版嵁璇诲彇
+ */
+ public function related() {
+
+ // 寮哄埗灏嗘ā鏉胯缃负鍚庡彴
+ \Phpcmf\Service::V()->admin();
+
+ // 鐧婚檰鍒ゆ柇
+ /*
+ if (!$this->uid) {
+ $this->_json(0, dr_lang('浼氳瘽瓒呮椂锛岃閲嶆柊鐧诲綍'));
+ }*/
+
+ // 鍙傛暟鍒ゆ柇
+ $dirname = dr_safe_filename(\Phpcmf\Service::L('input')->get('module'));
+ if (!$dirname) {
+ $this->_json(0, dr_lang('module鍙傛暟涓嶅瓨鍦'));
+ }
+
+ // 绔欑偣閫夋嫨
+ $site = max(1, (int)\Phpcmf\Service::L('input')->get('site'));
+ $pagesize = (int)\Phpcmf\Service::L('input')->get('pagesize');
+ if (!$pagesize) {
+ $pagesize = 10;
+ }
+
+ // 妯″潡缂撳瓨鍒ゆ柇
+ $module = $this->get_cache('module-'.$site.'-'.$dirname);
+ if (!$module) {
+ $this->_json(0, dr_lang('妯″潡锛%s锛変笉瀛樺湪', $dirname));
+ }
+
+ $module['field']['id'] = [
+ 'name' => 'Id',
+ 'ismain' => 1,
+ 'fieldtype' => 'Text',
+ 'fieldname' => 'id',
+ ];
+
+ $param = $data = \Phpcmf\Service::L('input')->get('', true);
+
+ $diy = dr_safe_filename($data['diy']);
+
+ if (IS_POST) {
+ $ids = \Phpcmf\Service::L('input')->get_post_ids();
+ if (!$ids) {
+ $this->_json(0, dr_lang('娌℃湁閫夋嫨椤'));
+ }
+ $id = [];
+ foreach ($ids as $i) {
+ $id[] = (int)$i;
+ }
+ $builder = \Phpcmf\Service::M()->db->table($site.'_'.$dirname);
+ $builder->whereIn('id', $id);
+ $mylist = $builder->orderBy('updatetime DESC')->get()->getResultArray();
+ if (!$mylist) {
+ $this->_json(0, dr_lang('娌℃湁鐩稿叧鏁版嵁'));
+ }
+ $name = dr_safe_filename(\Phpcmf\Service::L('input')->get('name'));
+ if (!$name) {
+ $this->_json(0, dr_lang('name鍙傛暟涓嶈兘涓虹┖'));
+ }
+
+ $mid = $dirname;
+ $ids = [];
+ foreach ($mylist as $t) {
+ $ids[] = $t['id'];
+ }
+
+ $file = \Phpcmf\Service::V()->code2php(
+ file_get_contents(is_file(MYPATH.'View/api_related_field_'.$diy.'.html') ? MYPATH.'View/api_related_field_'.$diy.'.html' : COREPATH.'View/api_related_field.html')
+ );
+ ob_start();
+ require $file;
+ $code = ob_get_clean();
+ $html = explode('', $code);
+
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'), ['ids' => $ids, 'html' => $html[1]]);
+ }
+
+ $my = intval($data['my']);
+ $where = [];
+ if ($my) {
+ $where[] = 'uid = '.$this->uid;
+ } elseif ($this->member && $this->member['adminid'] > 0) {
+ $module['field']['uid'] = [
+ 'name' => dr_lang('璐﹀彿'),
+ 'ismain' => 1,
+ 'fieldtype' => 'Text',
+ 'fieldname' => 'uid',
+ ];
+ }
+ if ($data['search']) {
+ $catid = (int)$data['catid'];
+ if ($catid) {
+ $cat = dr_cat_value($module['mid'], $catid);
+ if ($cat['catids']) {
+ $where[] = '`catid` in('.implode(',', $cat['catids']).')';
+ }
+ }
+ $data['keyword'] = dr_safe_replace(urldecode($data['keyword']));
+ if (isset($data['keyword']) && $data['keyword'] && $data['field'] && isset($module['field'][$data['field']])) {
+ $data['keyword'] = dr_safe_replace(urldecode($data['keyword']));
+ if ($data['field'] == 'id') {
+ // id鎼滅储
+ $id = [];
+ $ids = explode(',', $data['keyword']);
+ foreach ($ids as $i) {
+ $id[] = (int)$i;
+ }
+ $where[] = 'id in('.implode(',', $id).')';
+ } else if ($data['field'] == 'uid') {
+ $uid = \Phpcmf\Service::M('member')->uid($data['keyword']);
+ $where[] = 'uid = '.intval($uid);
+ } else {
+ // 鍏朵粬妯$硦鎼滅储
+ $where[] = $data['field'].' LIKE "%'.$data['keyword'].'%"';
+ }
+ }
+ }
+
+ sort($module['field']);
+ $rules = $data;
+ $rules['page'] = '{page}';
+
+ \Phpcmf\Service::V()->assign([
+ 'diy' => $data['diy'],
+ 'mid' => $dirname,
+ 'mmid' => $module['mid'],
+ 'site' => $site,
+ 'param' => $data,
+ 'field' => $module['field'],
+ 'where' => $where ? urlencode(implode(' AND ', $where)) : '',
+ 'search' => dr_form_search_hidden(['search' => 1, 'is_iframe' => 1, 'module' => $dirname, 'site' => $site, 'diy' => $data['diy'], 'my' => $my, 'pagesize' => $pagesize]),
+ 'select' => \Phpcmf\Service::L('category', 'module')->select(
+ $module['dirname'],
+ $data['catid'],
+ 'name="catid"',
+ '--'
+ ),
+ 'urlrule' => '/index.php?s=module&c=api&m=related&'.http_build_query($rules),
+ 'pagesize' => $pagesize,
+ ]);
+ if (is_file(MYPATH.'View/api_related_'.$diy.'.html')) {
+ \Phpcmf\Service::V()->display('api_related_'.$diy.'.html');
+ } else {
+ \Phpcmf\Service::V()->display('api_related.html');
+ }
+ }
+
+
+
+}
diff --git a/dayrui/App/Cms/Controllers/Home.php b/dayrui/App/Cms/Controllers/Home.php
new file mode 100644
index 0000000..7350410
--- /dev/null
+++ b/dayrui/App/Cms/Controllers/Home.php
@@ -0,0 +1,11 @@
+fix_admin_tpl_path = dr_get_app_dir('module').'Views/';
+ if (!APP_DIR) {
+ $this->admin_tpl_path = $this->fix_admin_tpl_path;
+ }
+ \Phpcmf\Service::V()->admin($this->admin_tpl_path, $this->fix_admin_tpl_path);
+ $this->_Extend_Init();
+ }
+
+ // 缁ф壙绫诲垵濮嬪寲
+ protected function _Extend_Init() {
+ // 鍒濆鍖栨ā鍧
+ $dir = APP_DIR ? APP_DIR : 'share';
+ $this->_module_init($dir);
+ // 鏀寔闄勮〃瀛樺偍
+ $this->is_data = 0;
+ // 妯℃澘鍓嶇紑(閬垮厤娣锋穯)
+ $this->tpl_prefix = 'share_category_';
+ // 鍗曠嫭妯℃澘鍛藉悕
+ $this->tpl_name = 'category_content';
+ // 妯″潡鏄剧ず鍚嶇О
+ $this->name = dr_lang('鍐呭妯″潡[%s]', $dir);
+ $this->is_scategory = $this->module['share'] || (isset($this->module['config']['scategory']) && $this->module['config']['scategory']);
+ if ($this->is_scategory) {
+ // 鍏变韩鏍忕洰鏃舵樉绀哄崟椤靛唴瀹瑰瓧娈
+ if ($this->module['share'] && $dir != 'share' && !$this->_is_extend_var) {
+ // 褰撳叡浜ā鍧楄繘鍏ヤ簡鐙珛妯″潡鐨勬爮鐩紝灏辫烦杞潯鍏变韩妯″潡
+ dr_redirect(dr_url('category/index'));
+ exit;
+ }
+ } else {
+ //unset($this->module['category_field']['content']);
+ // 鐙珛妯″潡
+ if (isset($this->module['config']['hcategory']) && $this->module['config']['hcategory']) {
+ $this->_admin_msg(0, dr_lang('妯″潡銆%s銆戠姝娇鐢ㄦ爮鐩', $dir));
+ }
+ }
+
+ // 鍒濆鍖栨暟鎹〃
+ $this->_init([
+ 'table' => dr_module_table_prefix($dir).'_category',
+ 'field' => $this->module['category_field'],
+ 'order_by' => 'displayorder ASC,id ASC',
+ 'show_field' => 'name',
+ ]);
+
+ \Phpcmf\Service::M('category')->init($this->init); // 鍒濆鍖栧唴瀹规ā鍨
+ //$this->module['category'] = \Phpcmf\Service::M('category')->get_data(0);
+
+ $file = WRITEPATH.'config/category.php';
+ if (is_file($file)) {
+ $this->cat_config = require $file;
+ if (!isset($this->cat_config[$this->module['dirname']])) {
+ if (!$this->cat_config) {
+ $this->cat_config = [];
+ }
+ $this->cat_config[$this->module['dirname']] = [
+ 'sys_field' => ['order','use','show', 'id','tid','mid','ismain','ismain','disabled','html'],
+ 'list_field' => [],
+ ];
+ }
+ } else {
+ $this->cat_config = [
+ $this->module['dirname'] => [
+ 'sys_field' => ['order','use','show', 'id','tid','mid','ismain','disabled','html'],
+ 'list_field' => [],
+ ],
+ ];
+ }
+
+ if (isset($this->cat_config[$this->module['dirname']]['rname']) && $this->cat_config[$this->module['dirname']]['rname']) {
+ define('SYS_CAT_RNAME', 1);
+ }
+ if (isset($this->cat_config[$this->module['dirname']]['popen']) && $this->cat_config[$this->module['dirname']]['popen']) {
+ define('SYS_CAT_POPEN', 1);
+ }
+
+ $menu = [
+ '杩斿洖' => [APP_DIR.'/home/index', 'fa fa-reply'],
+ '鏍忕洰绠$悊' => [APP_DIR.'/category/index', 'fa fa-reorder'],
+ '娣诲姞' => [APP_DIR.'/category/add', 'fa fa-plus'],
+ '鎵归噺' => [APP_DIR.'/category/all_add', 'fa fa-plus'],
+ '灞炴ц缃' => [APP_DIR.'/category/config_add', 'fa fa-cog'],
+ '鑷畾涔夊瓧娈' => ['show:field/index{&is_menu=1&rname=category-'.$this->module['dirname'].'}', 'fa fa-code', '80%', '90%'],
+ ];
+ if (!APP_DIR) {
+ unset($menu['杩斿洖']);
+ }
+
+ // 鍐欏叆妯℃澘
+ \Phpcmf\Service::V()->assign([
+ 'mid' => $dir,
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu($menu),
+ 'module' => $this->module,
+ 'is_seo' => $this->module['setting']['search']['catsync'] ? 0 : ($this->module['share'] ? 1 : (isset($this->module['site'][SITE_ID]['is_cat']) && $this->module['site'][SITE_ID]['is_cat'])),
+ 'reply_url' => \Phpcmf\Service::L('router')->url(APP_DIR.'/category/index'),
+ 'is_scategory' => $this->is_scategory,
+ ]);
+ }
+
+ // ========================
+
+ // 鑾峰彇鏍戝舰缁撴瀯鍒楄〃
+ protected function _get_tree_list($data) {
+
+ $cqx = dr_is_app('cqx') ? \Phpcmf\Service::M('content', 'cqx') : null;
+ $module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content');
+ $is_cat_code = dr_is_app('mbdy') && isset($this->admin['role'][1]) && method_exists(\Phpcmf\Service::M('code', 'mbdy'), 'cat_code') ? 1 : 0;
+
+ $list = "";
+ $head = ' ';
+
+ $list.= "
+
+
+
+
+ ";
+ $head.= '
+
+
+
+
+ ';
+
+ if (dr_in_array('order', $this->cat_config[$this->module['dirname']]['sys_field'])) {
+ $head.= ' '.dr_lang('鎺掑簭').' ';
+ $list.= " ";
+ }
+
+ if (dr_in_array('use', $this->cat_config[$this->module['dirname']]['sys_field'])) {
+ $head .= ' ' . dr_lang('鍙敤') . ' ';
+ $list .= "\$is_used_html ";
+ }
+
+ if (dr_in_array('show', $this->cat_config[$this->module['dirname']]['sys_field'])) {
+ $head .= ' ' . dr_lang('鏄剧ず') . ' ';
+ $list .= "\$is_show_html ";
+ }
+
+ //if (dr_in_array('ismain', $this->cat_config[$this->module['dirname']]['sys_field'])) {
+ //$head .= ' ' . dr_lang('涓绘爮鐩') . ' ';
+ // $list .= "\$is_ismain_html ";
+ //}
+
+ if (dr_in_array('id', $this->cat_config[$this->module['dirname']]['sys_field'])) {
+ $head .= ' Id ';
+ $list .= "\$id ";
+ }
+
+ $head.= ' '.dr_lang('鏍忕洰淇℃伅').' ';
+ $list.= "\$spacer\$name \$parent \$ctotal ";
+
+ if ($this->is_scategory && dr_in_array('tid', $this->cat_config[$this->module['dirname']]['sys_field'])) {
+ $head.= ' '.dr_lang('绫诲瀷').' ';
+ $list.= "\$type_html ";
+ }
+ if ($this->module['share'] && dr_in_array('mid', $this->cat_config[$this->module['dirname']]['sys_field'])) {
+ $head.= ' '.dr_lang('妯″潡 / 鐩綍').' ';
+ $list.= "\$mid ";
+ }
+
+ if ($this->module['share'] && dr_is_app('chtml') && dr_in_array('html', $this->cat_config[$this->module['dirname']]['sys_field'])) {
+ $head.= ' ' . dr_lang('鏍忕洰闈欐') . ' ';
+ $list.= "\$is_page_html ";
+ $head.= ' ' . dr_lang('鍐呭闈欐') . ' ';
+ $list.= "\$is_page_html2 ";
+ }
+
+ if (isset($this->cat_config[$this->module['dirname']]['list_field']) && $this->cat_config[$this->module['dirname']]['list_field']) {
+ foreach ($this->cat_config[$this->module['dirname']]['list_field'] as $i => $t) {
+ if ($t['use']) {
+ $head.= ''.dr_lang($t['name']).' ';
+ $list.= '$'.$i.'_html ';
+ }
+ }
+ }
+
+ $head.= ''.dr_lang('鎿嶄綔').' ';
+ $list.= "\$option ";
+
+ $head.= ' ';
+ $list.= "";
+
+ $tree = '';
+ $tcats = $pcats = [];
+ foreach($data as $k => $t) {
+ if ($cqx && $cqx->is_edit($t['id'])) {
+ unset($data[$k]);
+ continue;
+ }
+ $option = '';
+ !$t['mid'] && $t['mid'] = APP_DIR;
+ $t['tid'] = isset($t['tid']) ? $t['tid'] : 1;
+ $t['name'] = dr_strcut($t['name'], 30);
+ $t['jsname'] = str_replace(['\'', '"'], [], $t['name']);
+ $t['setting'] = dr_string2array($t['setting']);
+ $t['pcatpost'] = 0;
+ $pid = explode(',', $t['pids']);
+ $this->module['category'][$t['id']]['topid'] = $t['topid'] = isset($pid[1]) ? $pid[1] : $t['id'];
+ if ($this->module['share']) {
+ // 鍏变韩鏍忕洰鏃
+ //浠ユ湰鏍忕洰涓哄噯
+ $t['setting']['html'] = intval($t['setting']['html']);
+ $t['setting']['chtml'] = intval($t['setting']['chtml']);
+ $t['setting']['urlrule'] = intval($t['setting']['urlrule']);
+ if ($t['child'] && isset($module[$t['mid']]['pcatpost']) && $module[$t['mid']]['pcatpost']) {
+ // 鍏佽鐖舵爮鐩
+ $t['pcatpost'] = 1;
+ }
+ } else {
+ // 鐙珛妯″潡鏍忕洰
+ //浠ョ珯鐐逛负鍑
+ if (!isset($t['tid'])) {
+ $t['tid'] = $t['setting']['linkurl'] ? 2 : 1; // 鍒ゆ柇鏍忕洰绫诲瀷 2琛ㄧず澶栭摼
+ }
+ $t['setting']['html'] = intval($this->module['html']);
+ $t['setting']['chtml'] = intval($this->module['html']);
+ $t['setting']['urlrule'] = isset($this->module['site'][SITE_ID]['urlrule']) ? intval($this->module['site'][SITE_ID]['urlrule']) : 0;
+ if ($t['child'] && isset($this->module['setting']['pcatpost']) && $this->module['setting']['pcatpost']) {
+ // 鍏佽鐖舵爮鐩
+ $t['pcatpost'] = 1;
+ }
+ }
+ $t['url'] = $t['tid'] == 2 && $t['setting']['linkurl'] ? dr_url_prefix($t['setting']['linkurl']) : dr_url_prefix(\Phpcmf\Service::L('router')->category_url($this->module, $t));
+ if ($this->_is_admin_auth('add')) {
+ // 闈炲閾炬坊鍔犲瓙绫 $t['tid'] != 2 &&
+ $option.= 'url(APP_DIR.'/category/add', array('pid' => $t['id'])).'> '.dr_lang('瀛愮被').' ';
+ }
+ if ($this->_is_admin_auth('edit')) {
+ $option.= 'url(APP_DIR.'/category/edit', array('id' => $t['id'])).'> '.dr_lang('淇敼').' ';
+ }
+ if (($t['tid'] == 1 && ($t['pcatpost'] || !$t['child']) && $t['mid']) && $this->_is_admin_auth($t['mid'].'/home/add')) {
+ $option.= ' '.dr_lang('鍙戝竷').' ';
+ }
+ $t['ctotal'] = '';
+ if (($t['tid'] == 1 && $t['mid']) ) {
+ if ($this->_is_admin_auth($t['mid'].'/home/index')) {
+ $option.= ' '.dr_lang('绠$悊').' ';
+ }
+ $t['ctotal'] = ' ';
+ $tcats[] = $t['id'].'-'.$t['mid'];
+ }
+ if ($this->_is_admin_auth('edit') && dr_count($this->module['category_field']) && ($t['tid'] !=2 && $this->is_scategory)) {
+ $option.= ' '.dr_lang('缂栬緫鍐呭').' ';
+ } elseif ($this->_is_admin_auth('edit') && ($t['tid'] == 2 && $this->is_scategory)) {
+ $option.= ' '.dr_lang('缂栬緫鍦板潃').' ';
+ }
+ // 鍙瓒呯鏈夋晥
+ if (isset($this->admin['role'][1]) && dr_count($this->init['field'])) {
+ $option.= ' '.dr_lang('瀛楁鏉冮檺').' ';
+ }
+ // 绗笁鏂规彃浠舵帴鍏
+ if ($is_cat_code) {
+ $option.= ' '.dr_lang('鍓嶇璋冪敤').' ';
+ }
+ $t['option'] = $option;
+ // 鍒ゆ柇鏄剧ず鍜岄殣钘忓紑鍏
+ $t['is_show_html'] = ' ';
+ $t['is_used_html'] = ' ';
+ //$t['is_ismain_html'] = ' ';
+ // 鍒ゆ柇鏄惁鐢熸垚闈欐
+ $is_html = intval($this->module['share'] ? $t['setting']['html'] : $this->module['html']);
+ $is_html2 = intval($this->module['share'] ? $t['setting']['chtml'] : $this->module['html']);
+ $t['is_page_html'] = ' ';
+ $t['is_page_html2'] = ' ';
+
+ //$purl = $this->module['share'] ? ($t['tid'] == 1 ? dr_url($t['mid'].'/home/index', ['catid'=>$t['id']]) : \Phpcmf\Service::L('Router')->url(APP_DIR.'/category/edit', array('id' => $t['id']))) : dr_url(APP_DIR.'/home/index', ['catid'=>$t['id']]);
+ //$t['total'] = ''.intval($data[$t['id']]['total']).' ';
+ // 鏄惁缂撳瓨
+ //$t['url'] = dr_url_prefix($data[$t['id']]['url'], APP_DIR);
+ // 鍏变韩妯″潡鏄剧ず鏍忕被鍒
+ if ($this->is_scategory) {
+ // 鏍忕洰绫诲瀷
+ if ($t['tid'] == 1) {
+ if ($t['child']) {
+ $t['type_html'] = ' '.dr_lang('灏侀潰').' ';
+ } else {
+ $t['type_html'] = ' '.dr_lang('鍒楄〃').' ';
+ }
+ if ($module[$t['mid']]['name']) {
+ $t['mid'] = $module[$t['mid']]['name'] . ' / '.$t['mid'];
+ } else {
+ $t['mid'] = ''.dr_lang('鏈杞').' ';
+ }
+ } elseif ($t['tid'] == 2) {
+ $t['mid'] = '';
+ $t['type_html'] = ' '.dr_lang('澶栭摼').' ';
+ $t['is_page_html'] = '';
+ } else {
+ $t['mid'] = '';
+ $t['type_html'] = ' '.dr_lang('鍗曢〉').' ';
+ }
+ //!$t['mid'] && $t['mid'] = ''.dr_lang('鏃').' ';
+ } else {
+ //$t['url'] = 'javascript:;';
+ $t['tid'] = 0;
+ $t['mid'] = '';
+ $t['type_html'] = '';
+ $t['is_page_html'] = '';
+ }
+ if (isset($this->cat_config[$this->module['dirname']]['list_field']) && $this->cat_config[$this->module['dirname']]['list_field']) {
+ foreach ($this->cat_config[$this->module['dirname']]['list_field'] as $i => $tt) {
+ if ($tt['use']) {
+ $t[$i . '_html'] = dr_list_function($tt['func'], $t[$i], [], $t, $this->module['category_field'][$i]);
+ }
+ }
+ }
+ //$t['name'] = $this->module['category'][$t['id']]['total'];
+ if (!$t['child']) {
+ // 閲嶅楠岃瘉鏄惁瀛愭爮鐩紝閬垮厤琚鐨勬爮鐩笉鏄剧ず鐨勬儏鍐
+ $t['child'] = \Phpcmf\Service::M('category')->init($this->init)->where('pid', (int)$t['id'])->counts();
+ }
+ if ($t['child'] || $t['pcatpost']) {
+ $pcats[] = $t['id'];
+ $t['spacer'] = $this->_get_spacer($t['pids']).'[+] ';
+ } else {
+ $t['spacer'] = $this->_get_spacer($t['pids']);
+ }
+
+ $t['class'] = 'dr_catid_'.$t['id']. ' dr_pid_'.$t['pid'];
+ $arr = explode(',', $t['pids']);
+ if ($arr) {
+ foreach ($arr as $a) {
+ $t['class'].= ' dr_pid_'.$a;
+ }
+ }
+ extract($t);
+ $list = str_replace('"', '\'', $list);
+ eval("\$nstr = \"$list\";");
+ $tree.= $nstr;
+ }
+
+ return [$head, $tree, $pcats, $tcats];
+ }
+
+ // 鏇挎崲绌烘牸濉厖绗﹀彿
+ protected function _get_spacer($str) {
+ $rt = '';
+ $num = substr_count((string)$str, ',') * 2;
+ if ($num) {
+ for ($i = 0; $i < $num; $i ++) {
+ $rt.= ' ';
+ }
+ }
+ return $rt;
+ }
+
+ // 璁剧疆鏍忕洰灞炴
+ public function config_add() {
+
+ $sysfield = [
+ 'order' => ['鎺掑簭', '璁剧疆鏍忕洰鐨勬帓鍒楅『搴'],
+ 'use' => ['鍙敤', '璁剧疆鏍忕洰鏄惁鍙敤鐨勫揩鎹峰紑鍏'],
+ 'show' => ['鏄剧ず', '璁剧疆鏍忕洰鏄惁鐢ㄤ簬寰幆鏄剧ず'],
+ //'ismain' => ['涓绘爮鐩', '璁剧疆鏄惁涓轰富鏍忕洰鐨勫揩鎹峰紑鍏'],
+ 'id' => ['Id', '鏄剧ず鏍忕洰鐨刬d鍙'],
+ 'tid' => ['绫诲瀷', '鏄剧ず鏍忕洰鐨勭被鍨嬶紝鏈夛細鍗曢〉銆佹ā鍧椼佸閾'],
+ 'mid' => ['妯″潡', '鏄剧ず鎵灞炴ā鍧楃殑鍚嶇О'],
+ 'html' => ['闈欐', '璁剧疆鏍忕洰鏄惁鐢熸垚闈欐佺殑寮鍏'],
+ ];
+ if (!$this->is_scategory) {
+ unset($sysfield['tid']);
+ }
+ if (!$this->module['share']) {
+ unset($sysfield['mid']);
+ }
+ if (!dr_is_app('chtml') || !$this->module['share']) {
+ unset($sysfield['html']);
+ }
+
+ if (IS_POST) {
+ $this->cat_config[$this->module['dirname']] = \Phpcmf\Service::L('input')->post('data');
+ \Phpcmf\Service::L('Config')->file(WRITEPATH.'config/category.php', '鏍忕洰閰嶇疆鏂囦欢', 32)->to_require($this->cat_config);
+ // 鑷姩鏇存柊缂撳瓨
+ $this->_auto_cache(APP_DIR ? APP_DIR : 'share');
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ // 涓昏〃瀛楁
+ $field = \Phpcmf\Service::M()->db->table('field')
+ ->where('disabled', 0)
+ ->where('relatedname', 'category-'.$this->module['dirname'])
+ ->orderBy('displayorder ASC,id ASC')
+ ->get()->getResultArray();
+ $field = dr_list_field_value($this->cat_config[$this->module['dirname']]['list_field'], [], $field);
+
+ \Phpcmf\Service::V()->assign([
+ 'data' => $this->cat_config[$this->module['dirname']],
+ 'field' => $field,
+ 'sysfield' => $sysfield,
+ ]);
+ \Phpcmf\Service::V()->display('share_category_config.html');exit;
+ }
+
+ public function list_index() {
+ $pid = intval(\Phpcmf\Service::L('input')->get('pid'));
+ list($a, $b, $pcats, $tcats) = $this->_get_tree_list(\Phpcmf\Service::M('category')->cat_data($pid));
+ $this->_json(1, $b, json_encode($tcats));
+ }
+
+ // 鍚庡彴鏌ョ湅鍒楄〃
+ protected function _Admin_List() {
+ list($a, $b, $pcats, $tcats) = $this->_get_tree_list(\Phpcmf\Service::M('category')->cat_data(0));
+ \Phpcmf\Service::V()->assign([
+ 'list' => '浣犲湪My/View/share_category_list.html锛岀洰褰曚腑瀹氫箟杩囨爮鐩枃浠讹紝闇瑕佸垹闄ゆ鏂囦欢',
+ 'pcats' => $pcats,
+ 'tcats' => $tcats,
+ 'cat_head' => $a,
+ 'cat_list' => $b,
+ 'list_url' => dr_url(APP_DIR.'/category/index'),
+ 'list_name' => ' '.dr_lang('鏍忕洰绠$悊'),
+ 'move_select' => \Phpcmf\Service::L('tree')->select_category(
+ $this->module['category'],
+ 0,
+ 'name="catid"',
+ dr_lang('椤剁骇鏍忕洰'),
+ 0, 0
+ ),
+ 'uriprefix' => trim(APP_DIR.'/'.\Phpcmf\Service::L('router')->class, '/'),
+ 'MAX_CATEGORY' => \Phpcmf\Service::M()->table($this->init['table'])->counts(),
+ ]);
+ \Phpcmf\Service::V()->display('share_category_list.html');
+ }
+
+ // 鍚庡彴娣诲姞鍐呭
+ protected function _Admin_Add() {
+
+ $id = 0;
+ $pid = intval(\Phpcmf\Service::L('input')->get('pid'));
+ $page = intval(\Phpcmf\Service::L('input')->get('page'));
+
+ $psize = (int)\Phpcmf\Service::C()->get_cache('site', SITE_ID, 'seo', 'pagesize');
+ $msize = (int)\Phpcmf\Service::C()->get_cache('site', SITE_ID, 'seo', 'mpagesize');
+
+ // 榛樿鏁版嵁
+ $value = [
+ 'show' => 1,
+ 'urlrule' => (int)\Phpcmf\Service::C()->get_cache('site', SITE_ID, 'seo', 'SITE_URLRULE'),
+ 'setting' => [
+ 'edit' => 1,
+ 'disabled' => 0,
+ 'template' => [
+ 'page' => 'page.html',
+ 'list' => 'list.html',
+ 'show' => 'show.html',
+ 'category' => 'category.html',
+ 'search' => 'search.html',
+ 'pagesize' => $psize ? $psize : 20,
+ 'mpagesize' => $msize ? $msize : 20,
+ ],
+ 'seo' => [
+ 'list_title' => '[绗瑊page}椤祘join}]{catpname}{join}{SITE_NAME}',
+ 'show_title' => '[绗瑊page}椤祘join}]{title}{join}{catpname}{join}{SITE_NAME}',
+ ],
+ ]
+ ];
+
+ if ($pid) {
+ if (!$this->module['category'][$pid]) {
+ $this->_admin_msg(0, dr_lang('鐖舵爮鐩%s銆戠紦瀛樹笉瀛樺湪', $pid));
+ }
+ $value['setting'] = $this->module['category'][$pid]['setting'];
+ $value['setting']['getchild'] = 0;
+ }
+
+ $value['mid'] = $this->module['category'][$pid]['mid'];
+ $value['setting'] = dr_string2array($value['setting']);
+ list($tpl) = $this->_Post($id, $value, 1);
+
+ \Phpcmf\Service::V()->assign([
+ 'page' => $page,
+ 'data' => $value,
+ 'form' => dr_form_hidden(['page' => $page]),
+ 'select' => \Phpcmf\Service::L('tree')->select_category($this->module['category'], $pid, 'name=\'data[pid]\'', dr_lang('椤剁骇鏍忕洰')),
+ 'list_url' => dr_url(APP_DIR.'/category/index'),
+ 'list_name' => ' '.dr_lang('鏍忕洰绠$悊'),
+ 'select_tpl' => $this->_select_tpl(),
+ 'is_edit_mid' => $pid && $value['mid'] ? 1 : 0,
+ 'module_share' => \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content'),
+ ]);
+ \Phpcmf\Service::V()->display($tpl);
+ }
+
+ // 鍚庡彴淇敼鍐呭
+ protected function _Admin_Edit() {
+
+ $id = intval(\Phpcmf\Service::L('input')->get('id'));
+ $page = intval(\Phpcmf\Service::L('input')->get('page'));
+
+ list($tpl, $data) = $this->_Post($id, null, 1);
+ if (!$data['id']) {
+ $this->_admin_msg(0, dr_lang('鏁版嵁#%s涓嶅瓨鍦', $id));
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'page' => $page,
+ 'data' => $data,
+ 'form' => dr_form_hidden(['page' => $page]),
+ 'select' => \Phpcmf\Service::L('tree')->select_category($this->module['category'], $data['pid'], 'name=\'data[pid]\'', dr_lang('椤剁骇鏍忕洰')),
+ 'web_url' => $data['tid'] == 2 && $data['setting']['linkurl'] ? dr_url_prefix($data['setting']['linkurl']) : dr_url_prefix(dr_module_category_url($this->module, $data), $this->module['mid']),
+ 'list_url' => dr_url(APP_DIR.'/category/index'),
+ 'list_name' => ' '.dr_lang('鏍忕洰绠$悊'),
+ 'select_tpl' => $this->_select_tpl($data['mid']),
+ 'is_edit_mid' => 1,
+ 'module_share' => \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content'),
+ ]);
+ \Phpcmf\Service::V()->display($tpl);
+ }
+
+ // 妯℃澘閫夋嫨
+ protected function _select_tpl($mid = '') {
+
+ $path = dr_tpl_path();
+ $rpath = dirname(dirname($path));
+
+ $ini = dirname($path).'/config.ini';
+ if (is_file($ini)) {
+ $data = json_decode(file_get_contents($ini), true);
+ } else {
+ $data = [];
+ }
+
+ $html = '';
+ $html.= '';
+
+ return $html;
+ }
+
+ // 鍚庡彴鎵归噺娣诲姞
+ protected function _Admin_All_Add() {
+
+ if (IS_AJAX_POST) {
+
+ $post = \Phpcmf\Service::L('input')->post('data');
+ $list = explode(PHP_EOL, $post['list']);
+ if (!$list) {
+ $this->_json(0, dr_lang('鍐呭濉啓涓嶅畬鏁'));
+ }
+
+ $pid = intval($post['pid']);
+ if ($pid && !$this->module['category'][$pid]) {
+ $this->_json(0, dr_lang('鏍忕洰銆%s銆戠紦瀛樹笉瀛樺湪', $pid));
+ } elseif ($pid && $post['tid'] != 2 && $this->module['category'][$pid]['tid'] == 2) {
+ return dr_return_data(0, dr_lang('鐖剁骇鏍忕洰鏄閮ㄥ湴鍧绫诲瀷锛屼笅绾ф爮鐩彧鑳介夋嫨澶栭儴鍦板潃'));
+ } elseif ($pid && $this->module['category'][$pid]['pcatpost'] == 0
+ && $this->module['category'][$pid]['child'] == 0 && $this->module['category'][$pid]['tid'] == 1) {
+ $mid = $this->module['category'][$pid]['mid'] ? $this->module['category'][$pid]['mid'] : APP_DIR;
+ if (dr_is_module($mid) && \Phpcmf\Service::M()->table(dr_module_table_prefix($mid))->where('catid', $pid)->counts()) {
+ $this->_json(0, dr_lang('鐩爣鏍忕洰銆%s銆戝瓨鍦ㄥ唴瀹规暟鎹紝鏃犳硶浣滀负鐖舵爮鐩', $this->module['category'][$pid]['name']));
+ }
+ }
+
+ $count = 0;
+
+ foreach ($list as $t) {
+ list($name, $dir) = explode('|', $t);
+ $data = [];
+ $data['name'] = trim($name);
+ if (!$data['name']) {
+ continue;
+ }
+ $data['dirname'] = trim((string)$dir);
+ !$data['dirname'] && $data['dirname'] = \Phpcmf\Service::L('pinyin')->result($data['name']);
+ $cf = \Phpcmf\Service::M('category')->check_dirname(0, $pid, $data['dirname']);
+
+ $data['pid'] = $pid;
+ $data['show'] = 1;
+ $data['ismain'] = 1;
+ //if ($pid) {
+ //$data['ismain'] = (int)$this->module['category'][$pid]['ismain'];
+ //}
+ $data['disabled'] = 0;
+ $data['pids'] = '';
+ $data['thumb'] = '';
+ $data['pdirname'] = '';
+ $data['childids'] = '';
+ if ($this->module['share']) {
+ $data['mid'] = $post['mid'];
+ $data['tid'] = (int)$post['tid'];
+ $data['content'] = '';
+ // 浣滀负鍐呭妯″潡鐨勬爮鐩垽鏂
+ if ($data['tid'] == 1 && !$data['mid']) {
+ $this->_json(0, dr_lang('蹇呴』閫夋嫨涓涓ā鍧'));
+ // 鍒ゆ柇閫愪釜鐖剁骇鏍忕洰鐨刴id鍊
+ /*
+ list($pmid, $ids) = \Phpcmf\Service::M('category')->get_parent_mid($this->module['category'], $pid);
+ if ($pmid && $pmid != $data['mid']) {
+ $this->_json(0, dr_lang('蹇呴』閫夋嫨涓庝笂绾ф爮鐩浉鍚岀殑鍐呭妯″潡锛%s锛', $pmid));
+ }*/
+ }
+ }
+ $psize = (int)\Phpcmf\Service::C()->get_cache('site', SITE_ID, 'seo', 'pagesize');
+ $msize = (int)\Phpcmf\Service::C()->get_cache('site', SITE_ID, 'seo', 'mpagesize');
+ $data['setting'] = isset($this->module['category'][$pid]['setting']) ? $this->module['category'][$pid]['setting'] : [
+ 'edit' => 1,
+ 'disabled' => 0,
+ 'template' => [
+ 'list' => 'list.html',
+ 'show' => 'show.html',
+ 'category' => 'category.html',
+ 'search' => 'search.html',
+ 'pagesize' => $psize ? $psize : 20,
+ 'mpagesize' => $msize ? $msize : 20,
+ ],
+ 'seo' => [
+ 'list_title' => '[绗瑊page}椤祘join}]{name}{join}{SITE_NAME}',
+ 'show_title' => '[绗瑊page}椤祘join}]{title}{join}{catname}{join}{SITE_NAME}',
+ ],
+ ];
+ $data['setting']['getchild'] = 0;
+ $save['setting']['urlrule'] = (int)\Phpcmf\Service::C()->get_cache('site', SITE_ID, 'seo', 'SITE_URLRULE');
+ $data['setting'] = dr_array2string($data['setting']);
+
+ $rt = \Phpcmf\Service::M('category')->insert($data);
+ if (!$rt['code']) {
+ $this->_json(0, $rt['msg']);
+ }
+ if (!$cf['code']) {
+ // 閲嶅楠岃瘉
+ \Phpcmf\Service::M('category')->update($rt['code'], [
+ 'dirname' => $data['dirname'].$rt['code']
+ ]);
+ }
+ $count ++;
+ }
+ // 鑷姩鏇存柊缂撳瓨
+ $this->_auto_cache(APP_DIR ? APP_DIR : 'share');
+ $this->_json(1, dr_lang('鎵归噺娣诲姞%s涓爮鐩', $count));
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'form' => dr_form_hidden(),
+ 'select' => \Phpcmf\Service::L('tree')->select_category($this->module['category'], 0, 'name=\'data[pid]\'', dr_lang('椤剁骇鏍忕洰')),
+ 'list_url' => dr_url(APP_DIR.'/category/index'),
+ 'list_name' => ' '.dr_lang('鏍忕洰绠$悊'),
+ 'module_share' => \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content'),
+ ]);
+ \Phpcmf\Service::V()->display('share_category_all.html');
+ }
+
+ // 鍚庡彴鎵归噺璁剧疆URL
+ protected function _Admin_Url_Edit() {
+
+ if (!$this->module['share']) {
+ $this->_admin_msg(2, dr_lang('鐙珛妯″潡鍦ㄦā鍧楅厤缃腑璁剧疆URL瑙勫垯'), dr_url('seo_module/show', ['dir' => $this->module['dirname'], 'page' => 2, 'hide_menu' => 1]));
+ }
+
+ if (IS_AJAX_POST) {
+
+ $c = 0;
+ $catid = \Phpcmf\Service::L('input')->post('catid');
+ $urlrule = \Phpcmf\Service::L('input')->post('urlrule');
+
+ foreach ($this->module['category'] as $id => $t) {
+ if (dr_in_array($id, $catid)) {
+ $c++;
+ $t['setting']['urlrule'] = $urlrule;
+ \Phpcmf\Service::M('category')->init($this->init)->update($id, ['setting' => dr_array2string($t['setting'])]);
+ }
+ }
+
+ // 鑷姩鏇存柊缂撳瓨
+ $this->_auto_cache(APP_DIR ? APP_DIR : 'share');
+ $this->_json(1, dr_lang('鎵归噺璁剧疆%s涓爮鐩', $c));
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'form' => dr_form_hidden(),
+ 'select' => \Phpcmf\Service::L('tree')->select_category($this->module['category'], 0, 'name=\'catid[]\' multiple style=\'height:200px\'', ''),
+ 'list_url' =>\Phpcmf\Service::L('router')->url(APP_DIR.'/category/url_edit'),
+ 'list_name' => ' '.dr_lang('鑷畾涔塙RL'),
+ ]);
+ \Phpcmf\Service::V()->display('share_category_url.html');
+ }
+
+ // 鍚庡彴鍒犻櫎鍐呭
+ protected function _Admin_Del() {
+
+ $ids = \Phpcmf\Service::L('input')->get_post_ids();
+ if (!$ids) {
+ $this->_json(0, dr_lang('鎵閫夋爮鐩笉瀛樺湪'));
+ }
+
+ // 閲嶆柊鑾峰彇鏁版嵁
+ $category = \Phpcmf\Service::M('category')->data_for_delete();
+
+ // 绛涢夋爮鐩甶d
+ $catid = '';
+ foreach ($ids as $id) {
+ $catid.= ','.($category[$id]['childids'] ? $category[$id]['childids'] : $id);
+ }
+
+ $catid = explode(',', trim($catid, ','));
+ $catid = array_flip(array_flip($catid));
+
+ parent::_Del(
+ $catid,
+ function ($rows) {
+ // 鍒ゆ柇鍒犻櫎鐨勬爮鐩槸鍚﹀瓨鍦ㄦ暟鎹
+ if ($this->module['share']) {
+ foreach ($rows as $t) {
+ if (!$t['mid']) {
+ continue;
+ }
+ $mod = \Phpcmf\Service::L('cache')->get('module-' . SITE_ID . '-content', $t['mid']);
+ if ($mod) {
+ $table = dr_module_table_prefix($t['mid']);
+ if (!\Phpcmf\Service::M()->db->tableExists(\Phpcmf\Service::M()->dbprefix($table))) {
+ continue;
+ }
+ }
+ }
+ } else {
+ foreach ($rows as $t) {
+ $table = dr_module_table_prefix($this->module['dirname']);
+ if (!\Phpcmf\Service::M()->db->tableExists(\Phpcmf\Service::M()->dbprefix($table))) {
+ continue;
+ }
+ }
+ }
+ return dr_return_data(1);
+ },
+ function ($rows) {
+ // 璁$畻鏍忕洰
+ // 鍒犻櫎涔嬪悗璁板緱鍒犻櫎鐩稿叧妯″潡鏁版嵁
+ \Phpcmf\Service::M('Category')->delete_content($rows, $this->module);
+ // 鑷姩鏇存柊缂撳瓨
+ $this->_auto_cache(APP_DIR ? APP_DIR : 'share');
+ return dr_return_data(1);
+ },
+ \Phpcmf\Service::M()->dbprefix($this->init['table'])
+ );
+ }
+
+ // 鎵归噺璁剧疆闈欐佹ā寮
+ protected function _Admin_Html_All_Edit() {
+
+ $ids = \Phpcmf\Service::L('input')->get_post_ids();
+ if (!$ids) {
+ $this->_json(0, dr_lang('鎵閫夋爮鐩笉瀛樺湪'));
+ }
+ $tid = intval($_GET['tid']);
+ foreach ($ids as $id) {
+
+ $row = \Phpcmf\Service::M('category')->init($this->init)->get($id);
+ if (!$row) {
+ $this->_json(0, dr_lang('鏍忕洰鏁版嵁涓嶅瓨鍦'));
+ }
+
+ $row['setting'] = dr_string2array($row['setting']);
+ if ($tid) {
+ $row['setting']['chtml'] = 1;
+ } else {
+ $row['setting']['html'] = 1;
+ }
+ \Phpcmf\Service::M('category')->init($this->init)->update($id, ['setting' => dr_array2string($row['setting'])]);
+ \Phpcmf\Service::L('input')->system_log('淇敼鏍忕洰鐘舵佷负: 闈欐佹ā寮 ['. $id.']');
+ }
+
+ // 鑷姩鏇存柊缂撳瓨
+ $this->_auto_cache(APP_DIR ? APP_DIR : 'share');
+
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ // 澶嶅埗鏍忕洰瑙勫垯鎵ц
+ public function copy_page_edit() {
+
+ $at = \Phpcmf\Service::L('input')->get('at');
+ $page = (int)\Phpcmf\Service::L('input')->get('page');
+ $catid = (int)\Phpcmf\Service::L('input')->get('catid');
+
+ $catids = \Phpcmf\Service::L('cache')->get_auth_data('copy_edit_'.APP_DIR.'_'.$catid);
+ if (!$catids) {
+ $this->_html_msg(0, dr_lang('鏇存柊鏁版嵁涓虹┖'));
+ }
+
+ $row = \Phpcmf\Service::M('category')->init($this->init)->get($catid);
+ if (!$row) {
+ $this->_json(0, dr_lang('鏍忕洰鏁版嵁涓嶅瓨鍦'));
+ }
+
+ // 鏇存柊瀹屾垚
+ if (!isset($catids[$page]) || !$catids[$page]) {
+ \Phpcmf\Service::M('cache')->sync_cache();
+ \Phpcmf\Service::L('cache')->del_auth_data('copy_edit_'.APP_DIR.'_'.$catid);
+ $this->_html_msg(1, dr_lang('鏇存柊瀹屾垚'));
+ }
+
+ $row['setting'] = dr_string2array($row['setting']);
+ foreach ($catids[$page] as $t) {
+ // 鎸囧畾鏍忕洰
+ \Phpcmf\Service::M('category')->init($this->init)->copy_value($at, $row['setting'], $t);
+ }
+
+ $this->_html_msg( 1, dr_lang('姝e湪鎵ц涓%s銆...', count($catids).'/'.($page+1)),
+ dr_url(APP_DIR.'/category/'.\Phpcmf\Service::L('Router')->method, ['at' => $at, 'catid' => $catid, 'page' => $page + 1])
+ );
+ }
+
+ // 澶嶅埗鏍忕洰瑙勫垯
+ public function copy_edit() {
+
+ $catid = (int)\Phpcmf\Service::L('input')->get('catid');
+ $row = \Phpcmf\Service::M('category')->init($this->init)->get($catid);
+ if (!$row) {
+ $this->_json(0, dr_lang('鏍忕洰鏁版嵁涓嶅瓨鍦'));
+ }
+
+ if (IS_AJAX_POST) {
+
+ $at = \Phpcmf\Service::L('input')->post('at');
+ if (!$at) {
+ $this->_json(0, dr_lang('娌℃湁閫夋嫨鍚屾鏁版嵁椤'));
+ }
+ $use = \Phpcmf\Service::L('input')->post('use');
+ if (!$use) {
+ $catids = [];
+ foreach ($this->module['category'] as $t) {
+ $catids[] = $t['id'];
+ }
+ if (!$catids) {
+ $this->_json(0, dr_lang('娌℃湁鍙敤鐨勬爮鐩'));
+ }
+ } else {
+ $catids = \Phpcmf\Service::L('input')->post('catid');
+ if (!$catids) {
+ $this->_json(0, dr_lang('浣犺繕娌℃湁閫夋嫨鏍忕洰鍛'));
+ }
+ }
+
+ \Phpcmf\Service::L('cache')->set_auth_data('copy_edit_'.APP_DIR.'_'.$catid, array_chunk($catids, 50));
+
+ $this->_json(1, dr_lang('鍗冲皢鍚屾鍒%s涓爮鐩', count($catids)), [
+ 'jscode' => 'dr_iframe_show(\''.dr_lang('鍚屾').'\', \''.dr_url(APP_DIR.'/category/copy_page_edit').'&at='.implode(',', $at).'&catid='.$catid.'\', \'500px\', \'300px\')'
+ ]);
+ }
+ $option = [
+ 'seo' => 'SEO璁剧疆',
+ 'url' => 'url瑙勫垯',
+ 'tpl' => '妯℃澘鏂囦欢',
+ 'size' => '鍒嗛〉鏁版嵁',
+ ];
+ if (dr_is_app('chtml') && !APP_DIR) {
+ $option['html'] = '闈欐佸紑鍏';
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'at' => \Phpcmf\Service::L('input')->get('at'),
+ 'form' => dr_form_hidden(),
+ 'select' => \Phpcmf\Service::L('tree')->select_category(
+ $this->module['category'],
+ 0,
+ 'id=\'dr_catid\' name=\'catid[]\' multiple="multiple" data-actions-box="true"',
+ '',
+ 0,
+ 0
+ ),
+ 'option' => $option,
+ ]);
+ \Phpcmf\Service::V()->display('share_category_copy.html');exit;
+ }
+
+ // 鎵归噺璁剧疆鍔ㄦ佹ā寮
+ protected function _Admin_Php_All_Edit() {
+
+ $ids = \Phpcmf\Service::L('input')->get_post_ids();
+ if (!$ids) {
+ $this->_json(0, dr_lang('鎵閫夋爮鐩笉瀛樺湪'));
+ }
+ $tid = intval($_GET['tid']);
+ foreach ($ids as $id) {
+
+ $row = \Phpcmf\Service::M('category')->init($this->init)->get($id);
+ if (!$row) {
+ $this->_json(0, dr_lang('鏍忕洰鏁版嵁涓嶅瓨鍦'));
+ }
+
+ $row['setting'] = dr_string2array($row['setting']);
+ if ($tid) {
+ $row['setting']['chtml'] = 0;
+ } else {
+ $row['setting']['html'] = 0;
+ }
+ \Phpcmf\Service::M('category')->init($this->init)->update($id, ['setting' => dr_array2string($row['setting'])]);
+ \Phpcmf\Service::L('input')->system_log('淇敼鏍忕洰鐘舵佷负: 鍔ㄦ佹ā寮 ['. $id.']');
+ }
+
+ // 鑷姩鏇存柊缂撳瓨
+ $this->_auto_cache(APP_DIR ? APP_DIR : 'share');
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ // 鍚庡彴鎵归噺淇濆瓨鎺掑簭鍊
+ protected function _Admin_Order() {
+ $this->_Display_Order(
+ intval(\Phpcmf\Service::L('input')->get('id')),
+ intval(\Phpcmf\Service::L('input')->get('value'))
+ );
+ }
+
+ // 鍚庡彴鎵归噺绉诲姩鏍忕洰
+ protected function _Admin_Move_Edit() {
+
+ $ids = \Phpcmf\Service::L('input')->get_post_ids();
+ if (!$ids) {
+ $this->_json(0, dr_lang('鎵閫夋爮鐩笉瀛樺湪'));
+ }
+
+ $topid = (int)\Phpcmf\Service::L('input')->post('catid');
+ foreach ($ids as $id) {
+ if ($id == $topid) {
+ $this->_json(0, dr_lang('鏍忕洰涓婄骇涓嶈兘涓烘湰韬'));
+ }
+ }
+
+ /*
+ $mid = $topid ? '' : $category[$topid]['mid'];
+ // 鍒ゆ柇mid
+ $mmid = '';*/
+ if ($topid) {
+ // 閲嶆柊鑾峰彇鏁版嵁
+ $module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content');
+ $category = \Phpcmf\Service::M('category')->data_for_move();
+ if (!$category[$topid]) {
+ $this->_json(0, dr_lang('鐩爣鏍忕洰涓嶅瓨鍦'));
+ } elseif ($this->is_scategory && $category[$topid]['child'] == 0 && $category[$topid]['tid'] == 1) {
+ $mid = $category[$topid]['mid'] ? $category[$topid]['mid'] : APP_DIR;
+ if (isset($module[$mid]['pcatpost']) && $module[$mid]['pcatpost']) {
+ // 璇存槑鐖舵爮鐩厑璁稿彂甯冿紝涓嶆曚綘鐨勭埗鏍忕洰鏁版嵁
+ } else {
+ if (dr_is_module($mid) && \Phpcmf\Service::M()->table(dr_module_table_prefix($mid))->where('catid', $topid)->counts()) {
+ $this->_json(0, dr_lang('鐩爣鏍忕洰銆%s銆戝瓨鍦ㄥ唴瀹规暟鎹紝鏃犳硶浣滀负鐖舵爮鐩', $category[$topid]['name']));
+ }
+ }
+ }
+ }
+
+ // 鎵归噺鏇存崲鏍忕洰
+ \Phpcmf\Service::M()->db->table($this->init['table'])->whereIn('id', $ids)->update(['pid' => $topid]);
+
+ // 鑷姩鏇存柊缂撳瓨
+ $this->_auto_cache(APP_DIR ? APP_DIR : 'share');
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ // 鍚庡彴鎵归噺淇濆瓨鏄剧ず鐘舵
+ protected function _Admin_Show_Edit() {
+
+ $id = (int)\Phpcmf\Service::L('input')->get('id');
+ $row = \Phpcmf\Service::M('category')->init($this->init)->get($id);
+ if (!$row) {
+ $this->_json(0, dr_lang('鏍忕洰鏁版嵁涓嶅瓨鍦'));
+ }
+
+ $at = \Phpcmf\Service::L('input')->get('at');
+ if ($at == 'used') {
+ // 鍙敤鐘舵
+ $v = $row['disabled'] ? 0 : 1;
+ if ($v) {
+ $num = 0;
+ if ($this->module['share'] && $row['tid'] == 1 && dr_is_module($row['mid'])) {
+ $num = \Phpcmf\Service::M()->table(dr_module_table_prefix($row['mid']))->where('catid in ('.($row['childids'] ? $row['childids'] : $id).')')->counts();
+ } elseif (!$this->module['share']) {
+ $num = \Phpcmf\Service::M()->table(dr_module_table_prefix($this->module['dirname']))->where('catid in ('.($row['childids'] ? $row['childids'] : $id).')')->counts();
+ }
+ if ($num) {
+ $this->_json(0, dr_lang('褰撳墠鏍忕洰鍐呭瀛樺湪%s鏉℃暟鎹紝鏃犳硶绂佺敤', $num));
+ }
+ }
+ \Phpcmf\Service::M('category')->init($this->init)->update($id, ['disabled' => $v]);
+ // 鑷姩鏇存柊缂撳瓨
+ $this->_auto_cache(APP_DIR ? APP_DIR : 'share');
+ \Phpcmf\Service::L('input')->system_log('淇敼鏍忕洰鐨勫彲鐢ㄧ姸鎬: '. $id);
+ $this->_json(1, dr_lang($v ? '璁剧疆涓虹鐢ㄧ姸鎬' : '璁剧疆涓哄彲鐢ㄧ姸鎬'), ['value' => $v, 'share' => 0]);
+ } elseif ($at == 'main') {
+ // 鏄剧ず鐘舵
+ $v = $row['ismain'] ? 0 : 1;
+ \Phpcmf\Service::M('category')->init($this->init)->update($id, ['ismain' => $v]);
+ //\Phpcmf\Service::M('category')->init($this->init)->where('id in ('.$row['childids'].')')->update(NULL, ['ismain' => $v]);
+ // 鑷姩鏇存柊缂撳瓨
+ $this->_auto_cache(APP_DIR ? APP_DIR : 'share');
+ \Phpcmf\Service::L('input')->system_log('淇敼鏍忕洰鐨勪富鏍忕洰鐘舵: '. $id);
+ $this->_json(1, dr_lang($v ? '璁剧疆涓轰富鏍忕洰鐘舵' : '璁剧疆涓洪潪涓绘爮鐩姸鎬'), ['value' => $v, 'share' => 0]);
+ } else {
+ // 鏄剧ず鐘舵
+ $v = $row['show'] ? 0 : 1;
+ \Phpcmf\Service::M('category')->init($this->init)->update($id, ['show' => $v]);
+ // 鑷姩鏇存柊缂撳瓨
+ $this->_auto_cache(APP_DIR ? APP_DIR : 'share');
+ \Phpcmf\Service::L('input')->system_log('淇敼鏍忕洰鐨勬樉绀虹姸鎬: '. $id);
+ $this->_json(1, dr_lang($v ? '璁剧疆涓烘樉绀虹姸鎬' : '璁剧疆涓洪殣钘忕姸鎬'), ['value' => $v, 'share' => 0]);
+ }
+ }
+
+ // 鍚庡彴鎵归噺淇濆瓨鏄惁鐢熸垚闈欐佺殑鐘舵
+ protected function _Admin_Html_Edit() {
+
+ if (!dr_is_app('chtml')) {
+ $this->_json(0, '娌℃湁瀹夎瀹樻柟鐗堛愰潤鎬佺敓鎴愩戞彃浠');
+ }
+
+ $id = (int)\Phpcmf\Service::L('input')->get('id');
+ $tid = (int)\Phpcmf\Service::L('input')->get('tid');
+ $row = \Phpcmf\Service::M('category')->init($this->init)->get($id);
+ if (!$row) {
+ $this->_json(0, dr_lang('鏍忕洰鏁版嵁涓嶅瓨鍦'));
+ }
+
+ if ($this->module['share']) {
+ // 鍏变韩妯″潡
+ $row['setting'] = dr_string2array($row['setting']);
+ if (!$row['setting']['urlrule']) {
+ $this->_json(0, dr_lang('姝ゆ爮鐩槸鍔ㄦ佸湴鍧锛屾病鏈夎缃湴鍧瑙勫垯锛屾棤娉曞紑鍚潤鎬'));
+ }
+ if ($tid) {
+ $html = (int)$row['setting']['chtml'];
+ $v = $html ? 0 : 1;
+ $name = $v ? '鍐呭闈欐佹ā寮' : '鍐呭鍔ㄦ佹ā寮';
+ $row['setting']['chtml'] = $v;
+ } else {
+ $html = (int)$row['setting']['html'];
+ $v = $html ? 0 : 1;
+ $name = $v ? '鏍忕洰闈欐佹ā寮' : '鏍忕洰鍔ㄦ佹ā寮';
+ $row['setting']['html'] = $v;
+ }
+
+ \Phpcmf\Service::M('category')->init($this->init)->update($id, ['setting' => dr_array2string($row['setting'])]);
+ \Phpcmf\Service::L('input')->system_log('淇敼鏍忕洰鐘舵佷负: '. $name . '['. $id.']');
+ // 鑷姩鏇存柊缂撳瓨
+ $this->_auto_cache(APP_DIR ? APP_DIR : 'share');
+ $this->_json(1, dr_lang($name), ['value' => $v, 'share' => 1]);
+ } else {
+ // 鐙珛妯″潡
+ $html = (int)$this->module['html'];
+ $v = $html ? 0 : 1;
+ $name = $v ? '鍏ㄦā鍧楁爮鐩強鍐呭闈欐佹ā寮' : '鍏ㄦā鍧楁爮鐩強鍐呭鍔ㄦ佹ā寮';
+ $module = \Phpcmf\Service::M()->db->table('module')->where('id', $this->module['id'])->get()->getRowArray();
+ if (!$module) {
+ $this->_json(0, dr_lang('妯″潡涓嶅瓨鍦'));
+ }
+ $site = dr_string2array($module['site']);
+ $site[SITE_ID]['html'] = $v;
+ if (!$site[SITE_ID]['urlrule']) {
+ $this->_json(0, dr_lang('姝ゆā鍧楁槸鍔ㄦ佸湴鍧锛屾病鏈夎缃湴鍧瑙勫垯锛屾棤娉曞紑鍚潤鎬'));
+ }
+ \Phpcmf\Service::M()->db->table('module')->where('id', $this->module['id'])->update([
+ 'site' => dr_array2string($site)
+ ]);
+ \Phpcmf\Service::L('input')->system_log('淇敼妯″潡鐘舵佷负: '. $name);
+ // 鑷姩鏇存柊缂撳瓨
+ $this->_auto_cache(APP_DIR ? APP_DIR : 'share');
+ $this->_json(1, dr_lang($name), ['value' => $v, 'share' => 0]);
+ }
+
+ }
+
+ // 鐢熸垚鏍忕洰闈欐
+ public function scjt_edit() {
+
+ if (!dr_is_app('chtml')) {
+ $this->_json(0, '娌℃湁瀹夎瀹樻柟鐗堛愰潤鎬佺敓鎴愩戞彃浠');
+ }
+
+ $ids = \Phpcmf\Service::L('input')->get_post_ids();
+ if (!$ids) {
+ $this->_json(0, dr_lang('娌℃湁閫夋嫨浠讳綍鏍忕洰'));
+ }
+
+ if ($this->module['share']) {
+ $this->_json(1, dr_url('chtml/cat/category_index', ['app' => '', 'ids' => implode(',', $ids)]));
+ } else {
+ $this->_json(1, dr_url('chtml/cat/category_index', ['app' => APP_DIR, 'ids' => implode(',', $ids)]));
+ }
+ }
+
+ // 鐢熸垚鍐呭闈欐
+ public function scjt2_edit() {
+
+ if (!dr_is_app('chtml')) {
+ $this->_json(0, '娌℃湁瀹夎瀹樻柟鐗堛愰潤鎬佺敓鎴愩戞彃浠');
+ }
+
+ $ids = \Phpcmf\Service::L('input')->get_post_ids();
+ if (!$ids) {
+ $this->_json(0, dr_lang('娌℃湁閫夋嫨浠讳綍鏍忕洰'));
+ }
+
+ if ($this->module['share']) {
+ $this->_json(1, dr_url('chtml/html/show_index', ['app' => '', 'catids' => implode(',', $ids)]));
+ } else {
+ $this->_json(1, dr_url('chtml/html/show_index', ['app' => APP_DIR, 'catids' => implode(',', $ids)]));
+ }
+ }
+
+ // 缂栬緫澶栭摼
+ public function link_edit() {
+
+ $id = intval(\Phpcmf\Service::L('input')->get('id'));
+ $row = \Phpcmf\Service::M('category')->init($this->init)->get($id);
+ if (!$row) {
+ $this->_json(0, dr_lang('鏍忕洰鏁版嵁涓嶅瓨鍦'));
+ }
+
+ $row['setting'] = dr_string2array($row['setting']);
+
+ if (IS_POST) {
+ $row['setting']['linkurl'] = \Phpcmf\Service::L('input')->post('url');
+ \Phpcmf\Service::M('category')->init($this->init)->update($id, ['setting' => dr_array2string($row['setting'])]);
+ \Phpcmf\Service::L('input')->system_log('淇敼鏍忕洰澶栭摼鍦板潃: '. $row['name'] . '['. $id.']');
+ // 鑷姩鏇存柊缂撳瓨
+ $this->_auto_cache(APP_DIR ? APP_DIR : 'share');
+ $is_html = $this->module['share'] ? $this->module['category'][$id]['setting']['html'] : $this->module['html'];
+ if ($is_html) {
+ // 鐢熸垚鏉冮檺鏂囦欢
+ if (!dr_html_auth(1)) {
+ $this->_json(0, dr_lang('/cache/html/ 鏃犳硶鍐欏叆鏂囦欢'));
+ }
+ $list = dr_web_prefix('index.php?s='.APP_DIR.'&c=html&m=categoryfile&id='.$id);
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'), ['htmlfile' => $list]);
+ }
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'myurl' => $row['setting']['linkurl'],
+ ]);
+ \Phpcmf\Service::V()->display('share_category_linkurl.html');exit;
+ }
+
+ // 缂栬緫鑷畾涔夊瓧娈垫潈闄
+ public function field_edit() {
+
+ $id = intval(\Phpcmf\Service::L('input')->get('id'));
+ $row = \Phpcmf\Service::M('category')->init($this->init)->get($id);
+ if (!$row) {
+ $this->_json(0, dr_lang('鏍忕洰鏁版嵁涓嶅瓨鍦'));
+ }
+
+ $row['setting'] = dr_string2array($row['setting']);
+
+ if (IS_POST) {
+ $post = \Phpcmf\Service::L('input')->post('ids');
+ $save = $row['setting']['cat_field'] ? $row['setting']['cat_field'] : [];
+ foreach ($this->module['category_field'] as $t) {
+ if ($t['id']) {
+ if (dr_in_array($t['fieldname'], $post)) {
+ // 璇存槑鍕鹃変簡杩欎釜瀛楁
+ if (isset($save[$t['fieldname']])) {
+ unset($save[$t['fieldname']]);
+ }
+ } else {
+ // 娌″嬀閫
+ $save[$t['fieldname']] = 1;
+ }
+ }
+ }
+ $save['name'] = 'test';
+ $row['setting']['cat_field'] = $save;
+ \Phpcmf\Service::M('category')->init($this->init)->update($id, ['setting' => dr_array2string($row['setting'])]);
+ \Phpcmf\Service::L('input')->system_log('淇敼鏍忕洰鑷畾涔夊瓧娈垫潈闄: '. $row['name'] . '['. $id.']');
+
+ $c = 0;
+ $catids = \Phpcmf\Service::L('input')->post('catid');
+ if ($catids) {
+ $row['setting'] = dr_string2array($row['setting']);
+ if (isset($catids[0]) && $catids[0] == 0) {
+ // 鍏ㄩ儴鏍忕洰
+ foreach ($this->module['category'] as $cid => $t) {
+ //if ($t['ismain']) {
+ $c ++;
+ \Phpcmf\Service::M('category')->init($this->init)->copy_value('cat_field', $row['setting'], $cid);
+ //}
+ }
+ } else {
+ // 鎸囧畾鏍忕洰
+ foreach ($catids as $cid) {
+ //if ($this->module['category'][$cid]['ismain']) {
+ $c++;
+ \Phpcmf\Service::M('category')->init($this->init)->copy_value('cat_field', $row['setting'], $cid);
+ //}
+ }
+ if (!in_array($id, $catids)) {
+ \Phpcmf\Service::M('category')->init($this->init)->copy_value('cat_field', $row['setting'], $id);
+ $c++;
+ }
+ }
+ // 鑷姩鏇存柊缂撳瓨
+ $this->_auto_cache(APP_DIR ? APP_DIR : 'share');
+ $this->_json(1, dr_lang('鍏辫缃%s涓爮鐩', $c));
+ } else {
+ // 娌℃湁閫夋嫨琛ㄧず鑷繁
+ \Phpcmf\Service::M('category')->init($this->init)->copy_value('cat_field', $row['setting'], $id);
+ // 鑷姩鏇存柊缂撳瓨
+ $this->_auto_cache(APP_DIR ? APP_DIR : 'share');
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'field' => $this->module['category_field'],
+ 'select' => \Phpcmf\Service::L('tree')->ismain(true)->select_category(
+ $this->module['category'],
+ 0,
+ 'id=\'dr_catid\' name=\'catid[]\' multiple="multiple" data-actions-box="true"',
+ '',
+ 0,
+ 0
+ ),
+ 'cat_field' => $row['setting']['cat_field'],
+ ]);
+ \Phpcmf\Service::V()->display('share_category_field.html');exit;
+ }
+
+ // ===========================
+
+ /**
+ * 鑾峰彇鍐呭
+ * $id 鍐呭id,鏂板涓0
+ * */
+ protected function _Data($id = 0) {
+
+ $row = \Phpcmf\Service::M('category')->get($id);
+ if (!$row) {
+ return [];
+ }
+
+ $row['setting'] = dr_string2array($row['setting']);
+ if ($row['ismain']) {
+ if ($row['setting']['cat_field']) {
+ foreach ($row['setting']['cat_field'] as $key => $v) {
+ unset($this->field[$key]);
+ }
+ }
+ } else {
+ // 鍓爮鐩
+ $id = \Phpcmf\Service::L('category', 'module')->get_ismain_id($this->module['mid'], $row);
+ if ($this->module['category'][$id]['setting']['cat_field']) {
+ foreach ($this->module['category'][$id]['setting']['cat_field'] as $key => $v) {
+ unset($this->field[$key]);
+ }
+ }
+ }
+
+
+ return $row;
+ }
+
+ /**
+ * 淇濆瓨鍐呭
+ * $id 鍐呭id,鏂板涓0
+ * $data 鎻愪氦鍐呭鏁扮粍,鐣欑┖涓鸿嚜鍔ㄨ幏鍙
+ * $func 鏍煎紡鍖栨彁浜ょ殑鏁版嵁
+ * */
+ protected function _Save($id = 0, $data = [], $old = [], $func = null, $func2 = null) {
+
+ return parent::_Save($id, $data, $old,
+ function ($id, $data, $old){
+ // 淇濆瓨涔嬪墠鐨勫垽鏂
+ $save = \Phpcmf\Service::L('input')->post('system');
+ if (!$save['name']) {
+ return dr_return_data(0, dr_lang('鏍忕洰鍚嶇О涓嶈兘涓虹┖'), ['field' => 'name']);
+ } elseif (!$save['dirname']) {
+ return dr_return_data(0, dr_lang('鐩綍鍚嶇О涓嶈兘涓虹┖'), ['field' => 'dirname']);
+ }
+ $rt = \Phpcmf\Service::M('category')->check_dirname($id, $save['pid'], $save['dirname']);
+ if (!$rt['code']) {
+ return dr_return_data(0, $rt['msg'], ['field' => 'dirname']);
+ }
+
+ // 榛樿鏁版嵁
+ $save['show'] = (int)$save['show'];
+ foreach ($data[1] as $n => $t) {
+ $save[$n] = $t ? $t : '';
+ }
+
+ // 鍒ゆ柇鍏变韩鏍忕洰
+ if ($this->module['share']) {
+ // 鍒ゆ柇妯″潡tid鏄惁姝g‘
+ if (isset($save['tid'])) {
+ $save['tid'] = intval($save['tid']);
+ if ($save['tid'] == 1 && !$save['mid']) {
+ return dr_return_data(0, dr_lang('蹇呴』閫夋嫨涓涓ā鍧'));
+ } elseif ($save['pid'] && $save['tid'] != 2 && $this->module['category'][$save['pid']]['tid'] == 2) {
+ return dr_return_data(0, dr_lang('鐖剁骇鏍忕洰鏄閮ㄥ湴鍧绫诲瀷锛屼笅绾ф爮鐩彧鑳介夋嫨澶栭儴鍦板潃'));
+ } elseif ($save['tid'] == 2 && !$save['setting']['linkurl']) {
+ return dr_return_data(0, dr_lang('澶栭儴鍦板潃绫诲瀷蹇呴』濉啓鍦板潃'));
+ }
+ // 鍗曢〉妯℃澘璇嗗埆
+ //!$save['tid'] && $save['setting']['template']['list'] == 'list.html' && $save['setting']['template']['list'] = 'page.html';
+ }
+ if ($old && $old['mid'] && $old['mid'] != $save['mid']
+ && \Phpcmf\Service::M()->is_table_exists(dr_module_table_prefix($old['mid']))
+ && \Phpcmf\Service::M()->table_site($old['mid'])->where('catid', $old['id'])->counts()) {
+ $this->_json(0, dr_lang('鏈爮鐩瓨鍦ㄦ墍灞炴ā鍧楀唴瀹规暟鎹紝璇峰垹闄ゆ暟鎹悗锛屽啀鍙樻洿妯″潡鎿嶄綔'));
+ }
+ // 鍒ゆ柇瀛樺湪mid
+ /*
+ if ($save['mid']) {
+ // 鍒ゆ柇閫愪釜鐖剁骇鏍忕洰鐨刴id鍊
+ list($pmid, $ids) = \Phpcmf\Service::M('Category')->get_parent_mid($this->module['category'], $id ? $id : $save['pid']);
+ $pmid && $pmid != $save['mid'] && $this->_json(0, dr_lang('蹇呴』閫夋嫨涓庝笂绾ф爮鐩浉鍚岀殑鍐呭妯″潡锛%s锛', $pmid));
+ // 鏇存柊涓婄骇鐩稿叧mid
+ \Phpcmf\Service::M()->db->table($this->init['table'])->whereIn('id', $ids)->update(['mid' => $pmid]);
+ }*/
+ }
+
+ if ($save['pid'] && $id && $save['pid'] == $id) {
+ return dr_return_data(0, dr_lang('鏍忕洰涓婄骇涓嶈兘涓烘湰韬'));
+ }
+
+ // 鍙樻洿鏍忕洰鏃
+ if ($old && $save['pid'] && $save['pid'] != $old['pid']) {
+ $pid = $save['pid'];
+ } elseif (!$old && $save['pid']) {
+ $pid = $save['pid'];
+ } else {
+ $pid = 0;
+ }
+
+ //if ($old) {
+ //$save['ismain'] = $old['ismain'];
+ //} else {
+ //$save['ismain'] = 1;
+ //}
+ $save['ismain'] = 1;
+ if ($pid) {
+ if (!$this->module['category'][$save['pid']]) {
+ $this->_json(0, dr_lang('鐖舵爮鐩笉瀛樺湪'));
+ } elseif ($this->is_scategory && $this->module['category'][$save['pid']]['pcatpost'] == 0
+ && $this->module['category'][$save['pid']]['child'] == 0 && $this->module['category'][$save['pid']]['tid'] == 1) {
+ $mid = $this->module['category'][$save['pid']]['mid'] ? $this->module['category'][$save['pid']]['mid'] : APP_DIR;
+ if (dr_is_module($mid) && \Phpcmf\Service::M()->table(dr_module_table_prefix($mid))->where('catid', $save['pid'])->counts()) {
+ $this->_json(0, dr_lang('鐩爣鏍忕洰銆%s銆戝瓨鍦ㄥ唴瀹规暟鎹紝鏃犳硶浣滀负鐖舵爮鐩', $this->module['category'][$save['pid']]['name']));
+ }
+ }
+ //$save['ismain'] = (int)$this->module['category'][$save['pid']]['ismain'];
+ }
+
+ // 涓嶅嚭鐜板湪缂栬緫鍣ㄤ腑鐨勫瓧娈
+ $save['setting']['cat_field'] = $old['setting']['cat_field'];
+ $save['setting']['module_field'] = $old['setting']['module_field'];
+ if (isset($save['tid']) && $save['tid'] != 1) {
+ $save['setting']['notedit'] = 0;
+ }
+
+ if (!$old && (!isset($save['setting']['urlrule']) || !$save['setting']['urlrule'])) {
+ $save['setting']['urlrule'] = \Phpcmf\Service::C()->get_cache('site', SITE_ID, 'seo', 'SITE_URLRULE');
+ }
+
+ // 鏁扮粍json鍖
+ $save['pids'] = '';
+ $save['setting'] = dr_array2string($save['setting']);
+ $save['pdirname'] = '';
+ $save['childids'] = '';
+ $save['disabled'] = 0;
+
+ return dr_return_data(1, '', [ 1 => $save]);
+ }, function ($id, $data, $old) {
+ // 鑷姩鏇存柊缂撳瓨
+ $this->_auto_cache(APP_DIR ? APP_DIR : 'share');
+ \Phpcmf\Hooks::trigger('module_category_save', $data[1]);
+ $is_html = $this->module['share'] ? $this->module['category'][$data[1]['id']]['setting']['html'] : $this->module['html'];
+ if ($is_html) {
+ // 鐢熸垚鏉冮檺鏂囦欢
+ if (!dr_html_auth(1)) {
+ return dr_return_data(0, dr_lang('/cache/html/ 鏃犳硶鍐欏叆鏂囦欢'));
+ }
+ return dr_return_data(1, dr_lang('鎿嶄綔鎴愬姛'), [
+ 'htmlfile' => dr_web_prefix('index.php?s='.APP_DIR.'&c=html&m=categoryfile&id='.$data[1]['id']),
+ 'url' => isset($_GET['is_self']) ? dr_url(APP_DIR.'/category/edit', ['id' => $data[1]['id']]) : '',
+ ]);
+ }
+ return dr_return_data(1, dr_lang('鎿嶄綔鎴愬姛'), [
+ 'url' => isset($_GET['is_self']) ? dr_url(APP_DIR.'/category/edit', ['id' => $data[1]['id']]) : '',
+ ]);
+ }
+ );
+ }
+
+ private function _auto_cache($cdir) {
+ if (\Phpcmf\Service::M()->table(SITE_ID.'_'.$cdir.'_category')->counts() < MAX_CATEGORY) {
+ \Phpcmf\Service::M('module')->update_category_cache(SITE_ID, $cdir);
+ }
+ \Phpcmf\Service::M('cache')->sync_cache();
+ }
+}
diff --git a/dayrui/App/Cms/Extends/Admin/Config.php b/dayrui/App/Cms/Extends/Admin/Config.php
new file mode 100644
index 0000000..24d99ac
--- /dev/null
+++ b/dayrui/App/Cms/Extends/Admin/Config.php
@@ -0,0 +1,54 @@
+_module_init(APP_DIR);
+
+ $data = \Phpcmf\Service::M()->table('module')->where('dirname', APP_DIR)->getRow();
+ if (!$data) {
+ $this->_admin_msg(0, dr_lang('妯″潡#%s涓嶅瓨鍦', APP_DIR));
+ }
+
+
+ $data['setting'] = dr_string2array($data['setting']);
+ if (!isset($data['setting']['param'])) {
+ $data['setting']['param'] = [];
+ }
+
+ if (IS_POST) {
+ $post = \Phpcmf\Service::L('input')->post('data');
+ $data['setting']['param'] = $post;
+ \Phpcmf\Service::M()->db->table('module')->where('dirname', APP_DIR)->update([
+ 'setting' => dr_array2string($data['setting']),
+ ]);
+ $this->_json(1, '鎿嶄綔鎴愬姛');
+ }
+
+ $page = intval(\Phpcmf\Service::L('input')->get('page'));
+ $this->fix_admin_tpl_path = dr_get_app_dir('module').'Views/';
+ \Phpcmf\Service::V()->assign([
+ 'page' => $page,
+ 'form' => dr_form_hidden(['page' => $page]),
+ 'data' => $data['setting']['param'],
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '鍙傛暟閰嶇疆' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-cog'],
+ ]
+ ),
+ ]);
+ \Phpcmf\Service::V()->display('param.html');
+ }
+}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Extends/Admin/Module.php b/dayrui/App/Cms/Extends/Admin/Module.php
new file mode 100644
index 0000000..35ca7ca
--- /dev/null
+++ b/dayrui/App/Cms/Extends/Admin/Module.php
@@ -0,0 +1,1841 @@
+fix_admin_tpl_path = dr_get_app_dir('module').'Views/';
+ \Phpcmf\Service::V()->admin($this->admin_tpl_path, $this->fix_admin_tpl_path);
+ $this->_Extend_Init();
+ }
+
+ // 缁ф壙绫诲垵濮嬪寲
+ protected function _Extend_Init() {
+ // 鍒濆鍖栨ā鍧
+ $this->_module_init(APP_DIR);
+ // 鏀寔闄勮〃瀛樺偍
+ $this->is_data = 1;
+ // 鏄惁鏀寔妯″潡绱㈠紩琛
+ $this->is_module_index = 1;
+ // 鏄惁鏀寔
+ $this->is_category_data_field = $this->module['category_data_field'] ? 1 : 0;
+ // 妯℃澘鍓嶇紑(閬垮厤娣锋穯)
+ $this->tpl_prefix = 'share_';
+ // 鍗曠嫭妯℃澘鍛藉悕
+ $this->tpl_name = APP_DIR;
+ // 妯″潡鏄剧ず鍚嶇О
+ $this->name = dr_lang('鍐呭妯″潡銆%s锛%s锛夈', $this->module['cname'], APP_DIR);
+ $this->is_post_user = \Phpcmf\Service::M('auth')->is_post_user();
+ $this->where_list_sql = $this->content_model->get_admin_list_where();
+ // 鍒濆鍖栨暟鎹〃
+ $this->_init([
+ 'table' => dr_module_table_prefix(APP_DIR),
+ 'field' => $this->module['field'],
+ 'sys_field' => ['inputtime', 'updatetime', 'inputip', 'displayorder', 'hits', 'uid'],
+ 'date_field' => $this->module['setting']['search_time'] ? $this->module['setting']['search_time'] : 'updatetime',
+ 'show_field' => 'title',
+ 'where_list' => $this->where_list_sql,
+ 'order_by' => dr_safe_replace($this->module['setting']['order']),
+ 'list_field' => $this->module['setting']['list_field'],
+ 'search_first_field' => $this->module['setting']['search_first_field'] ? $this->module['setting']['search_first_field'] : 'title',
+ ]);
+ $this->content_model->init($this->init); // 鍒濆鍖栧唴瀹规ā鍨
+ // 瀛愮鐞嗗憳鎺ㄨ崘浣嶆潈闄
+ if (!dr_in_array(1, $this->admin['roleid']) && $this->module['setting']['flag']) {
+ foreach ($this->module['setting']['flag'] as $i => $t) {
+ if (!$t['role']) {
+ unset($this->module['setting']['flag'][$i]);
+ continue;
+ } elseif (dr_array_intersect_key($this->admin['roleid'], $t['role'])) {
+ continue;
+ } else {
+ unset($this->module['setting']['flag'][$i]);
+ }
+ }
+ }
+ $is_right_field = 1;
+ if (isset($this->module['setting']['right_field']) && $this->module['setting']['right_field']) {
+ if ($this->module['setting']['right_field'] == 2) {
+ $is_right_field = 0;
+ } elseif (!dr_in_array(1, $this->admin['roleid'])) {
+ $is_right_field = 0;
+ }
+ }
+ // 鍐欏叆妯℃澘
+ \Phpcmf\Service::V()->assign([
+ 'field' => $this->init['field'],
+ 'module' => $this->module,
+ 'post_url' => \Phpcmf\Service::L('Router')->url(APP_DIR.'/home/add', ['catid' => intval($_GET['catid'])]),
+ 'is_post_user' => $this->is_post_user,
+ 'is_hcategory' => $this->is_hcategory,
+ 'is_right_field' => $is_right_field,
+ 'is_category_show' => $this->is_hcategory ? 0 : (dr_count($this->module['category']) == 1 ? 0 : 1),
+ ]);
+ if ($this->module['setting']['is_hide_search_bar']) {
+ $this->is_show_search_bar = 0;
+ }
+ }
+
+ // ========================
+
+ // 鐢熸垚鍐呭闈欐
+ public function scjt_edit() {
+
+ if (!dr_is_app('chtml')) {
+ $this->_json(0, '娌℃湁瀹夎瀹樻柟鐗堛愰潤鎬佺敓鎴愩戞彃浠');
+ }
+
+ $ids = \Phpcmf\Service::L('input')->get_post_ids();
+ if (!$ids) {
+ $this->_json(0, dr_lang('娌℃湁閫夋嫨浠讳綍鏍忕洰'));
+ }
+
+ $this->_json(1, dr_url('chtml/html/show_index', ['app' => APP_DIR, 'ids' => implode(',', $ids)]));
+ }
+
+ // 鍚庡彴鏌ョ湅鍒楄〃
+ protected function _Admin_List($rt = 0) {
+
+ $this->my_clink = true;
+ $this->is_ajax_list = true;
+ $this->fix_table_list && $this->is_ajax_list = false;
+
+ if (dr_is_app('fstatus') && $this->module['field']['fstatus'] && $this->init['list_field']) {
+ $this->init['list_field']['fstatus'] = [
+ 'use' => 1,
+ 'order' => 1,
+ 'center' => 1,
+ 'width' => 60,
+ 'func' => 'fstatus',
+ 'name' => dr_lang('鐘舵'),
+ ];
+ }
+
+ $clink = $cbottom = [];
+ $this->mytable = [
+ 'foot_tpl' => '',
+ 'link_tpl' => '',
+ ];
+
+ list($tpl, $data) = $this->_List([]);
+
+ if ($this->_is_admin_auth('del') || $this->_is_admin_auth('edit')) {
+ $this->mytable['foot_tpl'].= ' ';
+ }
+ if ($this->_is_admin_auth('del')) {
+ $this->mytable['foot_tpl'].= ' '.dr_lang('鍒犻櫎').' ';
+ }
+
+ if ($this->_is_admin_auth('edit')) {
+
+ if (\Phpcmf\Service::V()->get_value('is_category_show')) {
+ $this->mytable['foot_tpl'].= ''.\Phpcmf\Service::L('Tree')->select_category(
+ $this->module['category'],
+ $data['param']['catid'],
+ 'name="catid"',
+ dr_lang('璇烽夋嫨'),
+ 1, 1
+ ).'
+ '.dr_lang('鏇存敼').' ';
+ }
+
+ $data = [];
+ $data[] = [
+ 'icon' => 'fa fa-flag',
+ 'name' => dr_lang('鎺ㄩ佸埌鎺ㄨ崘浣'),
+ 'uri' => APP_DIR.'/home/edit',
+ 'url' => 'javascript:;" onclick="dr_module_send(\''.dr_lang("鎺ㄨ崘浣").'\', \''.dr_url(APP_DIR.'/home/tui_edit').'&page=0\')',
+ ];
+ $data[] = [
+ 'icon' => 'fa fa-clock-o',
+ 'name' => dr_lang('鏇存柊鏃堕棿'),
+ 'uri' => APP_DIR.'/home/edit',
+ 'url' => 'javascript:;" onclick="dr_module_send_ajax(\''.dr_url(APP_DIR.'/home/tui_edit').'&page=4\')',
+ ];
+ if ($this->module['setting']['sync_category']) {
+ $data[] = [
+ 'icon' => 'fa fa-refresh',
+ 'name' => dr_lang('鍙戝竷鍒板叾浠栨爮鐩'),
+ 'uri' => APP_DIR.'/home/edit',
+ 'url' => 'javascript:;" onclick="dr_module_send(\''.dr_lang("鍙戝竷鍒板叾浠栨爮鐩").'\', \''.dr_url(APP_DIR.'/home/tui_edit').'&page=1\')',
+ ];
+ }
+
+ if (version_compare(CMF_VERSION, '4.6.0') < 0) {
+ $cbottom = $this->_app_cbottom_fix('', $data);
+ } else {
+ $cbottom = $this->_app_cbottom('', $data);
+ }
+
+ if ($cbottom) {
+ $this->mytable['foot_tpl'].= '
+
+ ';
+ }
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'menu' => $this->_module_menu(
+ $this->module,
+ ' '.dr_lang('%s绠$悊', $this->module['cname']),
+ \Phpcmf\Service::L('Router')->url(APP_DIR.'/home/index'),
+ \Phpcmf\Service::L('Router')->url(APP_DIR.'/home/add', ['catid' => intval($_GET['catid'])])
+ ),
+ 'mytable' => $this->mytable,
+ 'category_select' => \Phpcmf\Service::L('Tree')->select_category(
+ $this->module['category'],
+ $data['param']['catid'],
+ 'name="catid"',
+ dr_lang('鍏ㄩ儴'),
+ 0, 1
+ ),
+ 'clink' => $clink,
+ 'cbottom' => $cbottom,
+ ]);
+ if ($rt) {
+ return $tpl;
+ } else {
+ return \Phpcmf\Service::V()->display($tpl);
+ }
+ }
+
+
+ protected function _Clink_tpl($uriprefix, $data) {
+
+ $rt = '';
+ // 璁板綍鐨勯摼鎺ヨ彍鍗
+ if ($this->_is_admin_auth('edit')) {
+ $rt.= ' '.dr_lang('淇敼').' ';
+ if ($this->module['form']) {
+ foreach ($this->module['form'] as $a) {
+ if ($this->_is_admin_auth(APP_DIR.'/'.$a['table'].'/index')) {
+ $rt.= ' '.dr_lang($a['name']);
+ if (isset($data[$a['table'].'_total'])) {
+ $rt.= '锛'.$data[$a['table'].'_total'].'锛';
+ }
+ $rt.= ' ';
+ }
+ }
+ }
+ $clink = $this->_app_clink('', $data);
+ if ($clink) {
+ if ($this->module['setting']['is_op_more']) {
+ $aa = $rt;
+ $rt = '';
+ }
+ $data['cid'] = $data['id'];
+ $data['mid'] = APP_DIR;
+ $rep = new \php5replace($data);
+ foreach ($clink as $a) {
+ $rt.= ' '.dr_lang($a['name']);
+ if ($a['field'] && isset($data[$a['field']])) {
+ $rt.= '锛'.$data[$a['field']].'锛';
+ }
+ $rt.= ' ';
+ }
+
+ if ($this->module['setting']['is_op_more']) {
+ $rt = $aa . '
+
+
+ ' . dr_lang('鏇村') . '
+
+
+
+
';
+ }
+ }
+ }
+
+ return $rt;
+ }
+
+ // 鍚庡彴娣诲姞鍐呭
+ protected function _Admin_Add($rt = 0) {
+
+ $id = 0;
+ $did = intval(\Phpcmf\Service::L('input')->get('did'));
+ $catid = intval(\Phpcmf\Service::L('input')->get('catid'));
+
+ $did && $this->auto_save = 0; // 鑽夌ǹ鏁版嵁鏃朵笉鍔犺浇
+ $draft = $did ? $this->content_model->get_draft($did) : [];
+
+ $catid = $draft['catid'] ? $draft['catid'] : $catid;
+
+ // 鏍忕洰id涓嶅瓨鍦ㄦ椂灏卞幓绗竴涓彲鐢ㄦ爮鐩负catid
+ if (!$catid) {
+ list($select, $catid) = \Phpcmf\Service::L('Tree')->select_category(
+ $this->module['category'],
+ $catid,
+ 'id=\'dr_catid\' name=\'catid\' onChange="show_category_field(this.value)"',
+ '', 1, 1, 1
+ );
+ } else {
+ $select = \Phpcmf\Service::L('Tree')->select_category(
+ $this->module['category'],
+ $catid,
+ 'id=\'dr_catid\' name=\'catid\' onChange="show_category_field(this.value)"',
+ '', 1, 1
+ );
+ }
+
+ $this->is_get_catid = $catid;
+ $draft && $draft['catid'] = $catid;
+
+ list($tpl) = $this->_Post($id, $draft);
+
+ \Phpcmf\Service::V()->assign([
+ 'did' => $did,
+ 'form' => dr_form_hidden(['is_draft' => 0, 'module' => MOD_DIR, 'id' => $id]),
+ 'menu' => $this->_module_menu(
+ $this->module,
+ ' '.dr_lang('%s绠$悊', $this->module['cname']),
+ \Phpcmf\Service::L('Router')->url(APP_DIR.'/home/index'),
+ \Phpcmf\Service::L('Router')->url(APP_DIR.'/home/add', ['catid' => $catid])
+ ),
+ 'catid' => 0,
+ 'select' => $select,
+ 'is_flag' => $this->module['setting']['flag'],
+ 'draft_url' => \Phpcmf\Service::L('Router')->url(APP_DIR.'/home/add'),
+ 'draft_list' => $this->content_model->get_draft_list('cid='.$id),
+ 'category_field_url' => $this->module['category_data_field'] ? \Phpcmf\Service::L('Router')->url(APP_DIR.'/home/add') : '',
+ ]);
+ if ($rt) {
+ return $tpl;
+ } else {
+ return \Phpcmf\Service::V()->display($tpl);
+ }
+ }
+
+ // 鍚庡彴淇敼鍐呭
+ protected function _Admin_Edit($rt = 0) {
+
+ $id = intval(\Phpcmf\Service::L('input')->get('id'));
+ $did = intval(\Phpcmf\Service::L('input')->get('did'));
+ $did && $this->auto_save = 0; // 鑽夌ǹ鏁版嵁鏃朵笉鍔犺浇
+ $draft = $did ? $this->content_model->get_draft($did) : [];
+
+ list($tpl, $data) = $this->_Post($id, $draft);
+ if (!$data) {
+ $this->_admin_msg(0, dr_lang('鏁版嵁#%s涓嶅瓨鍦', $id));
+ } elseif ($this->where_list_sql && $this->content_model->admin_is_edit($data)) {
+ $this->_admin_msg(0, dr_lang('褰撳墠瑙掕壊鏃犳潈闄愮鐞嗘鏍忕洰'));
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'did' => $did,
+ 'form' => dr_form_hidden(['is_draft' => 0, 'module' => MOD_DIR, 'id' => $id]),
+ 'menu' => $this->_module_menu(
+ $this->module,
+ ' '.dr_lang('%s绠$悊', $this->module['cname']),
+ \Phpcmf\Service::L('Router')->url(APP_DIR.'/home/index'),
+ \Phpcmf\Service::L('Router')->url(APP_DIR.'/home/add', ['catid' => $data['catid']])
+ ),
+ 'is_flag' => $this->module['setting']['flag'],
+ 'select' => \Phpcmf\Service::L('Tree')->select_category(
+ $this->module['category'],
+ $data['catid'],
+ 'id=\'dr_catid\' name=\'catid\' onChange="show_category_field(this.value)"',
+ '', 1, 1
+ ),
+ 'web_url' => $data['url'] ? dr_url_prefix($data['url'], APP_DIR) : '',
+ 'draft_url' => \Phpcmf\Service::L('Router')->url(APP_DIR.'/home/edit', ['id' => $id]),
+ 'draft_list' => $this->content_model->get_draft_list('cid='.$id),
+ 'category_field_url' => $this->module['category_data_field'] ?\Phpcmf\Service::L('Router')->url(APP_DIR.'/home/edit', ['id' => $id]) : ''
+ ]);
+ if ($rt) {
+ return $tpl;
+ } else {
+ return \Phpcmf\Service::V()->display($tpl);
+ }
+ }
+
+ // 鍚庡彴鍒犻櫎鍐呭
+ protected function _Admin_Del() {
+
+ if (IS_POST) {
+
+ $ids = \Phpcmf\Service::L('input')->get_post_ids();
+ if (!$ids) {
+ $this->_json(0, dr_lang('娌℃湁閫夋嫨鍐呭'));
+ }
+
+ $rt = $this->content_model->delete_to_recycle($ids, \Phpcmf\Service::L('input')->post('note'));
+ if ($rt['code']) {
+ // 鍐欏叆鏃ュ織
+ \Phpcmf\Service::M('cache')->update_data_cache();
+ \Phpcmf\Service::L('input')->system_log($this->name.'锛氭斁鍏ュ洖鏀剁珯id ('.implode(', ', $ids).')');
+ $this->_json(1, dr_lang('鎵閫夊唴瀹瑰凡琚斁鍏ュ洖鏀剁珯涓'));
+ } else {
+ $this->_json(0, $rt['msg']);
+ }
+ } else {
+ // 閫夋嫨閫夐」
+ $ids = $_GET['ids'];
+ if (!$ids) {
+ $this->_json(0, dr_lang('娌℃湁閫夋嫨鍐呭'));
+ }
+ \Phpcmf\Service::V()->assign([
+ 'ids' => $ids,
+ 'delete_msg' => $this->module['setting']['delete_msg'] ? explode(PHP_EOL, (string)$this->module['setting']['delete_msg']) : [],
+ ]);
+ \Phpcmf\Service::V()->display('share_delete.html');
+ exit;
+ }
+ }
+
+ // 鍚庡彴鎵归噺淇濆瓨鎺掑簭鍊
+ protected function _Admin_Order() {
+ $this->_json(0, '姝ゅ姛鑳藉凡缁忓け鏁堬紝璇峰湪妯″潡璁剧疆涓厤缃悗鍙版樉绀烘湰瀛楁');
+ }
+
+ // 鎵归噺绉诲姩鏍忕洰
+ protected function _Admin_Move() {
+
+ $ids = \Phpcmf\Service::L('input')->get_post_ids();
+ $catid = (int)\Phpcmf\Service::L('input')->post('catid');
+ if (!$ids) {
+ $this->_json(0, dr_lang('閫夋嫨鍐呭涓嶅瓨鍦'));
+ } elseif (!$catid) {
+ $this->_json(0, dr_lang('鐩爣鏍忕洰鏈夋嫨'));
+ } elseif (!$this->content_model->admin_category_auth($catid, 'edit')) {
+ $this->_json(0, dr_lang('鏃犳潈闄愭搷浣滄鏍忕洰'));
+ } elseif ($this->where_list_sql && $this->content_model->admin_is_edit(['catid' => $catid])) {
+ $this->_json(0, dr_lang('褰撳墠瑙掕壊鏃犳潈闄愮鐞嗘鏍忕洰'));
+ }
+
+ $rt = $this->content_model->move_category($ids, $catid);
+
+ // 鍐欏叆鏃ュ織
+ if ($rt['code']) {
+ \Phpcmf\Service::L('input')->system_log($this->name.'锛氭壒閲忎慨鏀规爮鐩甶d ('.implode(', ', $ids).')');
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+ $this->_json(0, $rt['msg']);
+ }
+
+ // 鍚屾鏍忕洰閫夋嫨鍣
+ protected function _Admin_Syncat() {
+
+ $sync = \Phpcmf\Service::L('input')->get('catid');
+
+ if (IS_AJAX_POST) {
+
+ $catid = \Phpcmf\Service::L('input')->post('catid');
+ if (!$catid) {
+ $this->_json(0, dr_lang('浣犳病鏈夐夋嫨鍚屾鐨勬爮鐩'));
+ }
+
+ $syncat = [];
+ foreach ($catid as $i) {
+ if ($this->where_list_sql && $this->content_model->admin_is_edit(['catid' => $i])) {
+ $this->_json(0, dr_lang('褰撳墠瑙掕壊鏃犳潈闄愮鐞嗘鏍忕洰'));
+ } elseif (!$this->module['category'][$i]) {
+ continue;
+ } elseif ($this->module['category'][$i]['tid'] != 1) {
+ continue;
+ } elseif (!$this->module['category'][$i]['is_post']) {
+ continue;
+ } else {
+ $syncat[] = $i;
+ }
+ }
+
+ if (!$syncat) {
+ $this->_json(0, dr_lang('鎵閫夋爮鐩棤鏁'));
+ }
+
+ $this->_json(1, dr_count($syncat), implode(',', $syncat));
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'form' => dr_form_hidden(),
+ 'select' => \Phpcmf\Service::L('Tree')->select_category(
+ $this->module['category'],
+ $sync ? explode(',', $sync) : 0,
+ 'id=\'dr_catid\' name=\'catid[]\' multiple="multiple" data-actions-box="true"',
+ '', 1, 1
+ ),
+ ]);
+ \Phpcmf\Service::V()->display('share_syncat.html');exit;
+ }
+
+ // 鎵归噺鎺ㄩ
+ protected function _Admin_Send() {
+
+ $page = (int)\Phpcmf\Service::L('input')->get('page');
+ if ($page != 5) {
+ $ids = \Phpcmf\Service::L('input')->get('ids');
+ if (!$ids) {
+ $this->_json(0, dr_lang('鎵閫夋暟鎹笉瀛樺湪'));
+ }
+ }
+
+ if (IS_AJAX_POST) {
+
+ $in = [];
+ foreach ($ids as $i) {
+ $i && $in[] = intval($i);
+ }
+
+ if (!$in) {
+ $this->_json(0, dr_lang('鎵閫夋暟鎹笉瀛樺湪'));
+ }
+
+ switch ($page) {
+
+ case 1: // 鎺ㄩ佸埌鍏朵粬鏍忕洰
+
+ $catids = \Phpcmf\Service::L('input')->post('catid');
+ if (!$catids) {
+ $this->_json(0, dr_lang('浣犺繕娌℃湁閫夋嫨鍚屾鐨勬爮鐩'));
+ }
+
+ $data = \Phpcmf\Service::M()->db->table($this->init['table'])->whereIn('id', $in)->where('link_id<=0')->get()->getResultArray();
+ if (!$data) {
+ $this->_json(0, dr_lang('娌℃湁鍙敤鏁版嵁'));
+ }
+
+ $c = 0;
+ foreach ($data as $t) {
+ $u = 0;
+ foreach ($catids as $catid) {
+ if ($catid && $catid != $t['catid']) {
+ if ($this->where_list_sql && $this->content_model->admin_is_edit(['catid' => $catid])) {
+ $this->_json(0, dr_lang('褰撳墠瑙掕壊鏃犳潈闄愮鐞嗘鏍忕洰'));
+ }
+ // 鎻掑叆鍒板悓姝ユ爮鐩腑
+ $new[1] = $t;
+ $new[1]['catid'] = $catid;
+ $new[1]['link_id'] = $t['id'];
+ $new[1]['tableid'] = 0;
+ $new[1]['id'] = $this->content_model->index(0, $new);
+ if ($new[1]['id']) {
+ $this->content_model->table($this->init['table'])->replace($new[1]);
+ $c ++;
+ $u = 1;
+ }
+ }
+ }
+ $u && $this->content_model->table($this->init['table'])->update($t['id'], ['link_id' => -1]);
+ }
+
+ $this->_json(1, dr_lang('鎵归噺鎵ц%s鏉', $c));
+
+ break;
+
+ case 0: // 鎺ㄨ崘浣
+
+ $flag = \Phpcmf\Service::L('input')->post('flag');
+ $clear = \Phpcmf\Service::L('input')->post('clear');
+ if (!$clear && !$flag) {
+ $this->_json(0, dr_lang('浣犺繕娌℃湁閫夋嫨鎺ㄨ崘浣'));
+ }
+
+ if ($clear) {
+ \Phpcmf\Service::M()->db->table($this->init['table'].'_flag')->whereIn('id', $in)->delete();
+ $this->_json(1, dr_lang('鎺ㄨ崘浣嶆竻闄ゆ垚鍔'));
+ }
+
+ $data = \Phpcmf\Service::M()->db->table($this->init['table'].'_index')->whereIn('id', $in)->get()->getResultArray();
+ if (!$data) {
+ $this->_json(0, dr_lang('鎵閫夋暟鎹笉瀛樺湪'));
+ }
+
+ $c = 0;
+ foreach ($data as $t) {
+ foreach ($flag as $fid) {
+ $this->content_model->insert_flag((int)$fid, (int)$t['id'], (int)$t['uid'], (int)$t['catid']);
+ $c ++;
+ }
+ }
+
+ $this->_json(1, dr_lang('鎵归噺鎵ц%s鏉', $c));
+ break;
+ }
+ exit;
+ } else if ($page == 4) {
+ $this->content_model->update_time($ids);
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ exit;
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'page' => $page,
+ 'form' => dr_form_hidden(),
+ 'select' => \Phpcmf\Service::L('Tree')->select_category(
+ $this->module['category'],
+ 0,
+ 'id=\'dr_catid\' name=\'catid[]\' multiple="multiple" style="height:200px"',
+ '', 1, 1
+ ),
+ ]);
+ \Phpcmf\Service::V()->display('share_send.html');exit;
+ }
+
+ // ===========================
+
+ // 鍚庡彴鏌ョ湅鑽夌ǹ鍒楄〃
+ protected function _Admin_Draft_List($rt = 0) {
+
+ if (isset($this->field['content'])) {
+ $this->field['content']['fieldtype'] = 'Text'; // 闃叉璇嗗埆涓虹紪杈戝櫒瀛楁琚浆涔
+ }
+ $this->_init([
+ 'table' => dr_module_table_prefix(APP_DIR).'_draft',
+ 'date_field' => 'inputtime',
+ 'order_by' => 'inputtime desc',
+ 'where_list' => 'uid='.$this->uid,
+ ]);
+
+ list($tpl, $data) = $this->_List();
+
+ \Phpcmf\Service::V()->assign([
+ 'menu' => $this->_module_menu(
+ $this->module,
+ ' '.dr_lang('鑽夌ǹ绠辩鐞'),
+ \Phpcmf\Service::L('Router')->url(APP_DIR.'/draft/index'),
+ \Phpcmf\Service::L('Router')->url(APP_DIR.'/home/add')
+ ),
+ 'category_select' => \Phpcmf\Service::L('Tree')->select_category(
+ $this->module['category'],
+ $data['param']['catid'],
+ 'name="catid"',
+ '--'
+ ),
+ ]);
+
+ $tpl = $this->_tpl_filename('list_draft');
+ if ($rt) {
+ return $tpl;
+ } else {
+ return \Phpcmf\Service::V()->display($tpl);
+ }
+ }
+
+ // 鍚庡彴鍒犻櫎鑽夌ǹ鍐呭
+ protected function _Admin_Draft_Del() {
+
+ // 鏀寔闄勮〃瀛樺偍
+ $this->is_data = 0;
+ $this->name.= dr_lang('鑽夌ǹ');
+ $this->_init([
+ 'table' => dr_module_table_prefix(APP_DIR).'_draft',
+ ]);
+
+ $this->_Del(\Phpcmf\Service::L('input')->get_post_ids());
+ }
+
+ // ===========================
+
+ // 鍚庡彴鏌ョ湅瀹℃牳鍒楄〃
+ protected function _Admin_Verify_List($rt = 0) {
+
+ // 璇存槑鏉ヨ嚜瀹℃牳椤甸潰
+ define('IS_MODULE_VERIFY', 1);
+
+ $is_post_user = \Phpcmf\Service::M('auth')->is_post_user();
+
+ if (isset($_GET['is_all']) && intval($_GET['is_all']) == 1) {
+
+ if (IS_POST) {
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ // 鎵归噺鎿嶄綔
+ $ids = \Phpcmf\Service::L('input')->get('ids');
+ if (!$ids) {
+ $this->_json(0, dr_lang('娌℃湁閫変腑鍐呭'));
+ } elseif ($is_post_user) {
+ $this->_json(0, dr_lang('鎶曠ǹ鑰呰韩浠戒笉鍏佽瀹℃牳鎿嶄綔'));
+ }
+ $num = 10;
+ if (isset($this->module['setting']['verify_num']) && $this->module['setting']['verify_num']) {
+ $num = max(1, intval($this->module['setting']['verify_num']));
+ }
+ if (dr_count($ids) > $num) {
+ $this->_json(0, dr_lang('鎵归噺閫夋嫨鏁伴噺涓嶈兘瓒呰繃%s涓', $num));
+ }
+
+
+ $list = [];
+ $note = \Phpcmf\Service::L('input')->get('note');
+ foreach ($ids as $id) {
+ $row = \Phpcmf\Service::M()->table(dr_module_table_prefix(APP_DIR).'_verify')->get($id);
+ if (!$row) {
+ $this->_json(0, dr_lang('閫変腑鍐呭[#%s]涓嶅瓨鍦', $id));
+ }
+ if (intval($_GET['at']) == 1) {
+ $url = dr_url(MOD_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/edit').'&is_verify_iframe=1&id='.$id;
+ } else {
+ if (!$note) {
+ $this->_json(0, dr_lang('娌℃湁濉啓鎷掔粷鐞嗙敱'));
+ }
+ $url = dr_url(MOD_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/edit').'&is_verify_iframe=1¬e='.$note.'&id='.$id;
+ }
+ $t = dr_string2array($row['content']);
+ $list[$id] = [
+ 'url' => $url,
+ 'title' => $t['title'],
+ ];
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'list' => $list,
+ 'back_url' => dr_url(MOD_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index').'&rand='.SYS_TIME,
+ ]);
+ \Phpcmf\Service::V()->display('share_list_verify_all.html');
+ exit;
+ }
+ if (isset($this->field['content'])) {
+ $this->field['content']['fieldtype'] = 'Text'; // 闃叉璇嗗埆涓虹紪杈戝櫒瀛楁琚浆涔
+ }
+ $where = $this->content_model->get_admin_list_verify_where($this->where_list_sql);
+ $status = isset($_GET['status']) ? intval($_GET['status']) : 0;
+ if ($status > 0) {
+ if ($status == 9){
+ $status = 0;
+ }
+ $w = ' status='.$status;
+ $where = $where ? $where.' AND '.$w : $w;
+ }
+ $this->_init([
+ 'table' => dr_module_table_prefix(APP_DIR).'_verify',
+ 'date_field' => 'inputtime',
+ 'order_by' => 'inputtime desc',
+ 'where_list' => $where,
+ ]);
+
+ list($tpl, $data) = $this->_List();
+
+ $verify_msg = [
+ dr_lang('璇嶆枃涓嶅'),
+ ];
+ if ($this->module['setting']['verify_msg']) {
+ $msg = explode(PHP_EOL, $this->module['setting']['verify_msg']);
+ $msg && $verify_msg = $msg;
+ }
+
+ $step = [];
+ $verify = \Phpcmf\Service::C()->get_cache('verify');
+ if ($verify) {
+ foreach ($verify as $t) {
+ if ($t['value']['role']) {
+ foreach ($t['value']['role'] as $i => $arr) {
+ if (dr_array_intersect($arr, $this->admin['roleid'])) {
+ $step[] = $i;
+ }
+ }
+ }
+ }
+ }
+ $status_select = [
+ 0 => dr_lang('鍏ㄩ儴'),
+ 9 => dr_lang('琚绋'),
+ ];
+ for ($i = 1; $i<9; $i++) {
+ if (dr_in_array(1, $this->admin['roleid'])) {
+ $status_select[$i] = dr_lang('%s瀹′腑', $i);
+ } elseif (dr_in_array($i, $step)) {
+ $status_select[$i] = dr_lang('%s瀹′腑', $i);
+ }
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'menu' => $this->_module_menu(
+ $this->module,
+ ' '.dr_lang('寰呭鏍哥鐞'),
+ \Phpcmf\Service::L('Router')->url(APP_DIR.'/verify/index'),
+ \Phpcmf\Service::L('Router')->url(APP_DIR.'/home/add')
+ ),
+ 'clink' => $this->_app_clink(),
+ 'verify_msg' => $verify_msg,
+ 'is_post_user' => $is_post_user,
+ 'status_select' => $status_select,
+ 'category_select' => \Phpcmf\Service::L('Tree')->select_category(
+ $this->module['category'],
+ $data['param']['catid'],
+ 'name="catid"',
+ '--'
+ ),
+ ]);
+ $tpl = $this->_tpl_filename('list_verify');
+ if ($rt) {
+ return $tpl;
+ } else {
+ return \Phpcmf\Service::V()->display($tpl);
+ }
+ }
+
+ // 鍚庡彴淇敼瀹℃牳鍐呭
+ protected function _Admin_Verify_Edit($rt = 0) {
+
+ // 璇存槑鏉ヨ嚜瀹℃牳椤甸潰
+ define('IS_MODULE_VERIFY', 1);
+
+ $id = intval(\Phpcmf\Service::L('input')->get('id'));
+ list($tpl, $data) = $this->_Post($id);
+ if (!$data['id']) {
+ // 鍒犻櫎瀹℃牳鎻愰啋
+ \Phpcmf\Service::M('member')->delete_admin_notice(APP_DIR.'/verify/edit:id/'.$id, SITE_ID);
+ $this->_admin_msg(0, dr_lang('瀹℃牳鍐呭涓嶅瓨鍦'));
+ } elseif ($this->where_list_sql && $this->content_model->admin_is_edit($data)) {
+ $this->_admin_msg(0, dr_lang('褰撳墠瑙掕壊鏃犳潈闄愮鐞嗘鏍忕洰'));
+ } elseif (!$this->_get_verify_status_edit($data['verify']['vid'], $data['status'])) {
+ $this->_admin_msg(0, dr_lang('褰撳墠瑙掕壊鏃犳潈闄愬鏍告鍐呭'));
+ }
+
+ $step = $this->_get_verify($data['verify']['vid']);
+ $verify_msg = [
+ dr_lang('璇嶆枃涓嶅'),
+ ];
+ if ($this->module['setting']['verify_msg']) {
+ $msg = explode(PHP_EOL, $this->module['setting']['verify_msg']);
+ $msg && $verify_msg = $msg;
+ }
+ $next = dr_count($step) - 1 <= $data['status'] ? 9 : $data['status'] + 1;
+ \Phpcmf\Service::V()->assign([
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '瀹℃牳绠$悊' => [MOD_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-edit'],
+ '瀹℃牳澶勭悊' => ['hide:'.MOD_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/edit', 'fa fa-edit'],
+ ]
+ ),
+ 'form' => dr_form_hidden(['is_draft' => 0, 'module' => MOD_DIR, 'id' => $id]),
+ 'select' => \Phpcmf\Service::L('Tree')->select_category(
+ $this->module['category'],
+ $data['catid'],
+ 'id=\'dr_catid\' name=\'catid\' onChange="show_category_field(this.value)"',
+ '', 1, 1
+ ),
+ 'is_flag' => $this->module['setting']['flag'],
+ 'web_url' => dr_url_prefix('index.php?s='.APP_DIR.'&c=show&m=verify&id='.$id, APP_DIR),
+ 'is_verify' => 1,
+ 'back_note' => \Phpcmf\Service::L('input')->get('note'),
+ 'verify_msg' => $verify_msg,
+ 'verify_step' => $step,
+ 'is_sync_cat' => $data['sync_cat'],
+ 'verify_next' => $next,
+ ]);
+ $tpl = $this->_tpl_filename('post');
+ if ($rt) {
+ return $tpl;
+ } else {
+ return \Phpcmf\Service::V()->display($tpl);
+ }
+ }
+
+ // 鍚庡彴鍒犻櫎瀹℃牳鍐呭
+ protected function _Admin_Verify_Del() {
+
+ // 鏀寔闄勮〃瀛樺偍
+ $this->is_data = 0;
+ $this->name.= dr_lang('瀹℃牳');
+ $this->_init([
+ 'table' => dr_module_table_prefix(APP_DIR).'_verify',
+ ]);
+ $this->_Del(\Phpcmf\Service::L('input')->get_post_ids(), function ($rows) {
+ foreach ($rows as $t) {
+ if ($this->where_list_sql && $this->content_model->admin_is_edit($t)) {
+ return dr_return_data(0, dr_lang('褰撳墠瑙掕壊鏃犳潈闄愮鐞嗘鏍忕洰'));
+ }
+ }
+ return dr_return_data(1, 'ok');
+ }, function($rows) {
+ foreach ($rows as $t) {
+ // 鍒犻櫎绱㈠紩
+ $t['isnew'] && \Phpcmf\Service::M()->table(dr_module_table_prefix(APP_DIR).'_index')->delete($t['id']);
+ // 鍒犻櫎瀹℃牳鎻愰啋
+ \Phpcmf\Service::M('member')->delete_admin_notice(APP_DIR.'/verify/edit:id/'.$t['id'], SITE_ID);
+ }
+ return dr_return_data(1, 'ok');
+ });
+ }
+
+ // ===========================
+
+ // 鍚庡彴瀹氭椂鍙戝竷鍒楄〃
+ protected function _Admin_Time_List($rt = 0) {
+
+ if (isset($this->field['content'])) {
+ $this->field['content']['fieldtype'] = 'Text'; // 闃叉璇嗗埆涓虹紪杈戝櫒瀛楁琚浆涔
+ }
+
+ $this->_init([
+ 'table' => dr_module_table_prefix(APP_DIR).'_time',
+ 'order_by' => 'inputtime desc',
+ 'date_field' => 'inputtime',
+ 'where_list' => $this->where_list_sql,
+ ]);
+
+ list($tpl, $data) = $this->_List();
+
+ \Phpcmf\Service::V()->assign([
+ 'menu' => $this->_module_menu(
+ $this->module,
+ ' '.dr_lang('寰呭彂甯冪鐞'),
+ \Phpcmf\Service::L('Router')->url(APP_DIR.'/time/index'),
+ \Phpcmf\Service::L('Router')->url(APP_DIR.'/home/add')
+ ),
+ 'category_select' => \Phpcmf\Service::L('Tree')->select_category(
+ $this->module['category'],
+ $data['param']['catid'],
+ 'name="catid"',
+ '--'
+ ),
+ ]);
+ $tpl = $this->_tpl_filename('list_time');
+ if ($rt) {
+ return $tpl;
+ } else {
+ return \Phpcmf\Service::V()->display($tpl);
+ }
+ }
+
+ // 鍚庡彴閫绋
+ public function tuigao_edit() {
+ // 璇存槑鏉ラ绋块〉闈
+ define('IS_MODULE_TG', 1);
+ $id = intval(\Phpcmf\Service::L('input')->get('id'));
+ $this->_Post($id);
+ $this->_json(1, dr_lang('鎿嶄綔寮傚父'));
+ exit;
+ }
+
+ // 鍚庡彴瀹氭椂鍙戝竷
+ protected function _Admin_Time_Add() {
+
+ $at = \Phpcmf\Service::L('input')->get('at');
+ if ($at == 'post') {
+ // 鎵归噺鍙戝竷
+ $ids = \Phpcmf\Service::L('input')->get_post_ids();
+ if (!$ids) {
+ $this->_json(0, dr_lang('杩樻病鏈夐夋嫨鍛'));
+ }
+ $html = [];
+ foreach ($ids as $id) {
+ $rt = $this->content_model->post_time(\Phpcmf\Service::M()->table(dr_module_table_prefix(APP_DIR).'_time')->get($id));
+ $rt['data'] && $html[] = $rt['data'];
+ if (!$rt['code']) {
+ $this->_json(0, $rt['msg'], ['htmlfile' => $html]);
+ }
+ }
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'), ['htmlfile' => $html]);
+ exit;
+ }
+
+ // 璇存槑鏉ヨ嚜瀹氭椂椤甸潰
+ define('IS_MODULE_TIME', 1);
+
+ $this->_Post();
+ \Phpcmf\Service::V()->display('share_time.html');
+ exit;
+ }
+
+ // 鍚庡彴淇敼瀹氭椂鏃堕棿
+ public function time_edit() {
+
+ // 璇存槑鏉ヨ嚜瀹氭椂椤甸潰
+ define('IS_MODULE_TIME', 1);
+ $id = intval(\Phpcmf\Service::L('input')->get('id'));
+ $data = \Phpcmf\Service::M()->table(dr_module_table_prefix(APP_DIR).'_time')->get($id);
+ if (!$data) {
+ $this->_admin_msg(0, dr_lang('鍐呭涓嶅瓨鍦'));
+ }
+
+ if (IS_POST) {
+ $time = strtotime(\Phpcmf\Service::L('input')->post('posttime'));
+ if ($time < SYS_TIME) {
+ $this->_json(0, dr_lang('瀹氭椂鏃堕棿涓嶈兘鏅氫簬褰撳墠鏃堕棿'));
+ }
+
+ \Phpcmf\Service::M()->table(dr_module_table_prefix(APP_DIR).'_time')->update($id, [
+ 'posttime' => $time
+ ]);
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ \Phpcmf\Service::V()->assign('form', dr_form_hidden());
+ \Phpcmf\Service::V()->assign('posttime', dr_date($data['posttime'], 'Y-m-d H:i:s'));
+ \Phpcmf\Service::V()->display('share_time.html');exit;
+ }
+
+ // 鍚庡彴淇敼瀹氭椂鍐呭
+ protected function _Admin_Time_Edit() {
+
+ // 璇存槑鏉ヨ嚜瀹氭椂椤甸潰
+ define('IS_MODULE_TIME', 1);
+ $id = intval(\Phpcmf\Service::L('input')->get('id'));
+ list($tpl, $data) = $this->_Post($id);
+ if (!$data) {
+ $this->_admin_msg(0, dr_lang('鍐呭涓嶅瓨鍦'));
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '瀹氭椂鍙戝竷' => [MOD_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-clock-o"'],
+ '淇敼' => ['hide:'.MOD_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/edit', 'fa fa-edit'],
+ ]
+ ),
+ 'form' => dr_form_hidden(['is_draft' => 0, 'module' => MOD_DIR, 'id' => $id]),
+ 'select' => \Phpcmf\Service::L('Tree')->select_category(
+ $this->module['category'],
+ $data['catid'],
+ 'id=\'dr_catid\' name=\'catid\' onChange="show_category_field(this.value)"',
+ '', 1, 1
+ ),
+ 'web_url' => dr_url_prefix('index.php?s='.APP_DIR.'&c=show&m=time&id='.$id, APP_DIR),
+ 'is_post_time' => 1,
+ ]);
+ \Phpcmf\Service::V()->display($this->_tpl_filename('post'));
+ }
+
+ // 鍚庡彴鍒犻櫎瀹氭椂鍐呭
+ protected function _Admin_Time_Del() {
+
+ // 鏀寔闄勮〃瀛樺偍
+ $this->is_data = 0;
+ $this->name.= dr_lang('瀹氭椂');
+ $this->_init([
+ 'table' => dr_module_table_prefix(APP_DIR).'_time',
+ ]);
+
+ $this->_Del(\Phpcmf\Service::L('input')->get_post_ids());
+ }
+
+ // ===========================
+
+ // 鍚庡彴鏌ョ湅鍥炴敹绔欏垪琛
+ protected function _Admin_Recycle_List($rt = 0) {
+
+ if (isset($this->field['content'])) {
+ $this->field['content']['fieldtype'] = 'Text'; // 闃叉璇嗗埆涓虹紪杈戝櫒瀛楁琚浆涔
+ }
+
+ $this->_init([
+ 'table' => dr_module_table_prefix(APP_DIR).'_recycle',
+ 'date_field' => 'inputtime',
+ 'order_by' => 'inputtime desc',
+ 'where_list' => $this->where_list_sql,
+ ]);
+
+ list($tpl, $data) = $this->_List();
+
+ \Phpcmf\Service::V()->assign([
+ 'menu' => $this->_module_menu(
+ $this->module,
+ ' '.dr_lang('鍥炴敹绔欑鐞'),
+ \Phpcmf\Service::L('Router')->url(APP_DIR.'/recycle/index'),
+ \Phpcmf\Service::L('Router')->url(APP_DIR.'/home/add')
+ ),
+ 'category_select' => \Phpcmf\Service::L('Tree')->select_category(
+ $this->module['category'],
+ $data['param']['catid'],
+ 'name="catid"',
+ '--'
+ ),
+ ]);
+ $tpl = $this->_tpl_filename('list_recycle');
+ if ($rt) {
+ return $tpl;
+ } else {
+ return \Phpcmf\Service::V()->display($tpl);
+ }
+ }
+
+ // 鍚庡彴鍥炴敹绔欐竻绌
+ public function recycle_del() {
+
+ $page = (int)\Phpcmf\Service::L('input')->get('page');
+ $psize = 20;
+ if (!$page) {
+ $nums = \Phpcmf\Service::M()->table(dr_module_table_prefix(APP_DIR).'_recycle')->where($this->where_list_sql)->counts();
+ if (!$nums) {
+ $this->_json(0, dr_lang('鏁版嵁涓虹┖'));
+ }
+ $tpage = ceil($nums / $psize); // 鎬婚〉鏁
+ $this->_json(1, dr_lang('鍗冲皢鎵ц娓呯┖鍥炴敹绔欏懡浠'), [
+ 'jscode' => 'dr_iframe_show(\''.dr_lang('娓呯┖鍥炴敹绔').'\', \''.dr_url(APP_DIR.'/recycle/recycle_del').'&page=1&total='.$nums.'&tpage='.$tpage.'\', \'500px\', \'300px\', \'load\')'
+ ]);
+ }
+
+ $tpage = (int)\Phpcmf\Service::L('input')->get('tpage');
+ $total = (int)\Phpcmf\Service::L('input')->get('total');
+
+ $db = \Phpcmf\Service::M()->db->table(dr_module_table_prefix(APP_DIR).'_recycle');
+ $this->where_list_sql && $db->where($this->where_list_sql);
+ $data = $db->limit($psize)->orderBy('id DESC')->get()->getResultArray();
+ if (!$data) {
+ // 鍐欏叆鏃ュ織
+ \Phpcmf\Service::L('input')->system_log($this->name.'锛氭竻绌哄洖鏀剁珯');
+ $this->_html_msg(1, dr_lang('鍏卞垹闄%s鏉℃暟鎹', $total));
+ }
+
+ $ids = [];
+ foreach ($data as $t) {
+ $ids[] = $t['id'];
+ }
+
+ $this->content_model->delete_for_recycle($ids);
+
+ $this->_html_msg( 1, dr_lang('姝e湪鎵ц涓%s銆...', $tpage.'/'.($page+1)),
+ dr_url(APP_DIR.'/recycle/recycle_del', ['total' => $total, 'tpage' => $tpage, 'page' => $page + 1])
+ );
+ }
+
+ // 鍚庡彴鍥炴敹绔欏垹闄ゅ唴瀹
+ protected function _Admin_Recycle_Del() {
+
+ $ids = \Phpcmf\Service::L('input')->get_post_ids();
+ if (!$ids) {
+ $this->_json(0, dr_lang('鍙傛暟涓嶅瓨鍦'));
+ }
+
+ $rt = $this->content_model->delete_for_recycle($ids);
+
+ // 鍐欏叆鏃ュ織
+ \Phpcmf\Service::L('input')->system_log($this->name.'锛氬垹闄ゅ洖鏀剁珯id ('.implode(', ', $ids).')');
+
+ if ($rt['code']) {
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ } else {
+ $this->_json(0, $rt['msg']);
+ }
+ }
+
+ // 鍚庡彴鍥炴敹绔欐仮澶嶆煡鐪
+ protected function _Admin_Recycle_Show() {
+
+ $id = intval(\Phpcmf\Service::L('input')->get('id'));
+
+ // 璇存槑鏉ヨ嚜椤甸潰
+ define('IS_MODULE_RECYCLE', $id);
+
+ list($tpl, $data) = $this->_Show($id);
+ if (!$data) {
+ $this->_admin_msg(0, dr_lang('鍐呭涓嶅瓨鍦'));
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'menu' => $this->_module_menu(
+ $this->module,
+ ' '.dr_lang('鍥炴敹绔欑鐞'),
+ \Phpcmf\Service::L('Router')->url(APP_DIR.'/recycle/index'),
+ \Phpcmf\Service::L('Router')->url(APP_DIR.'/home/add')
+ ),
+ 'catid' => $data['catid'],
+ 'web_url' => dr_url_prefix('index.php?s='.APP_DIR.'&c=show&m=recycle&id='.$id, APP_DIR),
+ ]);
+ \Phpcmf\Service::V()->display($this->_tpl_filename('post'));
+
+ }
+
+ // 鍚庡彴鍥炴敹绔欐仮澶嶅唴瀹
+ protected function _Admin_Recovery() {
+
+ $ids = \Phpcmf\Service::L('input')->get_post_ids();
+ if (!$ids) {
+ $this->_json(0, dr_lang('鍙傛暟涓嶅瓨鍦'));
+ }
+
+ $rt = $this->content_model->recovery($ids);
+
+ if ($rt['code']) {
+ // 鍐欏叆鏃ュ織
+ \Phpcmf\Service::L('input')->system_log($this->name.'锛氭仮澶嶅洖鏀剁珯id ('.implode(', ', $rt['data']).')');
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ } else {
+ $this->_json(0, $rt['msg']);
+ }
+ }
+
+ // 鍚庡彴鍥炴敹绔欑紪杈戝唴瀹
+ protected function _Admin_Recycle_Edit() {
+
+ // 璇存槑鏉ヨ嚜瀹氭椂椤甸潰
+ $id = intval(\Phpcmf\Service::L('input')->get('id'));
+ define('IS_MODULE_RECYCLE', $id);
+ $this->init['show_field'] = 'cid';
+ $this->name.= dr_lang('鎭㈠鍥炴敹绔');
+ list($tpl, $data) = $this->_Post($id);
+ if (!$data) {
+ $this->_admin_msg(0, dr_lang('鍐呭涓嶅瓨鍦'));
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '鍥炴敹绔' => [MOD_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-trash-o"'],
+ '淇敼' => ['hide:'.MOD_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/edit', 'fa fa-edit'],
+ ]
+ ),
+ 'form' => dr_form_hidden(['is_draft' => 0, 'module' => MOD_DIR, 'id' => $id]),
+ 'select' => \Phpcmf\Service::L('Tree')->select_category(
+ $this->module['category'],
+ $data['catid'],
+ 'id=\'dr_catid\' name=\'catid\' onChange="show_category_field(this.value)"',
+ '', 1, 1
+ ),
+ 'web_url' => dr_url_prefix('index.php?s='.APP_DIR.'&c=show&m=recycle&id='.$id, APP_DIR),
+ 'is_recycle' => 1,
+ ]);
+ \Phpcmf\Service::V()->display($this->_tpl_filename('post'));
+ }
+
+ // ===========================
+
+ // 鎺ㄨ崘浣嶇鐞
+ protected function _Admin_Flag_List($rt = 0) {
+
+ $flag = intval(\Phpcmf\Service::L('input')->get('flag'));
+ if (!$this->module['setting']['flag'][$flag]) {
+ $this->_admin_msg(0, dr_lang('鎺ㄨ崘浣嶏紙%s锛変笉瀛樺湪', $flag));
+ }
+
+ if (IS_POST) {
+ $ids = \Phpcmf\Service::L('input')->get_post_ids();
+ if (!$ids) {
+ $this->_json(0, dr_lang('鎵閫夊唴瀹逛笉瀛樺湪'));
+ }
+ foreach ($ids as $id) {
+ $this->content_model->delete_flag($id, $flag);
+ }
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ $this->_init([
+ 'table' => dr_module_table_prefix(APP_DIR),
+ 'field' => $this->module['field'],
+ 'sys_field' => ['inputtime', 'updatetime', 'inputip', 'displayorder', 'hits', 'uid'],
+ 'date_field' => 'inputtime',
+ 'order_by' => 'inputtime desc',
+ 'show_field' => 'title',
+ 'list_field' => $this->module['setting']['list_field'],
+ 'where_list' => 'id IN (select id from `'.\Phpcmf\Service::M()->dbprefix(dr_module_table_prefix(APP_DIR).'_flag').'` where flag='.$flag.')'.($this->where_list_sql ? ' AND '.$this->where_list_sql : ''),
+ ]);
+
+ $this->is_ajax_list = true;
+ $this->fix_table_list && $this->is_ajax_list = false;
+
+ list($tpl, $data) = $this->_List();
+
+ $this->mytable = [
+ 'foot_tpl' => '',
+ 'link_tpl' => '',
+ 'link_var' => 'html = html.replace(/\{id\}/g, row.id);',
+ ];
+ if ($this->_is_admin_auth('del')) {
+ $this->mytable['foot_tpl'].= ' ';
+ $this->mytable['foot_tpl'].= ' '.dr_lang('绉婚櫎').' ';
+ }
+ if ($this->_is_admin_auth('edit')) {
+ $this->mytable['link_tpl'] .= ' ' . dr_lang('淇敼') . ' ';
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'p' => ['flag' => $flag],
+ 'menu' => $this->_module_menu(
+ $this->module,
+ ' '.dr_lang($this->module['setting']['flag'][$flag]['name']),
+ \Phpcmf\Service::L('Router')->url(APP_DIR.'/flag/index', ['flag' => $flag]),
+ \Phpcmf\Service::L('Router')->url(APP_DIR.'/home/add')
+ ),
+ 'category_select' => \Phpcmf\Service::L('Tree')->select_category(
+ $this->module['category'],
+ $data['param']['catid'],
+ 'name="catid"',
+ '--',
+ 0, 1
+ ),
+ 'mytable' => $this->mytable,
+ ]);
+ $tpl = $this->_tpl_filename('list');
+ if ($rt) {
+ return $tpl;
+ } else {
+ return \Phpcmf\Service::V()->display($tpl);
+ }
+ }
+
+ // ===========================
+
+ /**
+ * 鑾峰彇鍐呭
+ * $id 鍐呭id,鏂板涓0
+ * */
+ protected function _Data($id = 0) {
+
+ if (!$id) {
+ $data = [];
+ if (isset($this->module['setting']['hits_min']) && isset($this->module['setting']['hits_max'])
+ && $this->module['setting']['hits_min'] && $this->module['setting']['hits_max']) {
+ $data['hits'] = (int)rand((int)$this->module['setting']['hits_min'], (int)$this->module['setting']['hits_max']);
+ }
+ return $data;
+ }
+
+ $catid = intval(\Phpcmf\Service::L('input')->get('catid'));
+
+ if (defined('IS_MODULE_VERIFY')) {
+ // 鍒ゆ柇鏄惁鏉ヨ嚦瀹℃牳
+ $row = \Phpcmf\Service::M()->table(dr_module_table_prefix(APP_DIR).'_verify')->get($id);
+ if ($row) {
+ // 璋冪敤褰撳墠琛ㄦ暟鎹
+ $now = $this->content_model->get_data($id);
+ if ($now) {
+ $data = dr_string2array($row['content']) + $now;
+ } else {
+ $data = dr_string2array($row['content']);
+ }
+ $data['verify'] = [
+ 'vid' => $row['vid'],
+ 'uid' => $row['backuid'],
+ 'isnew' => $row['isnew'],
+ 'backinfo' => dr_string2array($row['backinfo']),
+ ];
+ $data['my_flag'] = isset($data['verify']['backinfo']['flag']) ? $data['verify']['backinfo']['flag'] : [];
+ $this->is_get_catid = $catid ? $catid : $data['catid'];
+ } else {
+ $data = [
+ 'id' => 0,
+ ];
+ }
+ return $data;
+ } elseif (defined('IS_MODULE_TIME')) {
+ // 鍒ゆ柇鏄惁鏉ヨ嚦瀹氭椂鍙戝竷
+ $row = \Phpcmf\Service::M()->table(dr_module_table_prefix(APP_DIR).'_time')->get($id);
+ $data = dr_string2array($row['content']);
+ $data['my_flag'] = $data['flag'];
+ $data['posttime'] = $row['posttime'];
+ $this->is_get_catid = $catid ? $catid : $data['catid'];
+ return $data;
+ } elseif (defined('IS_MODULE_RECYCLE')) {
+ // 鍒ゆ柇鏄惁鏉ヨ嚦鍥炴敹绔
+ $row = \Phpcmf\Service::M()->table(dr_module_table_prefix(APP_DIR).'_recycle')->get($id);
+ $c = dr_string2array($row['content']);
+ $data = [];
+ if ($c) {
+ foreach ($c as $t) {
+ $t && $data = dr_array22array($data, $t);
+ }
+ }
+ $this->is_get_catid = $data['catid'];
+ return $data;
+ }
+
+ $row = $this->content_model->get_data($id);
+ if (!$row) {
+ return [];
+ }
+
+ // 鍒ゆ柇鏄悓姝ユ爮鐩暟鎹
+ if ($row['link_id'] > 0) {
+ $row = $this->content_model->get_data($row['link_id']);
+ if (!$row) {
+ return [];
+ }
+ $this->replace_id = $id = $row['id'];
+ }
+
+ $this->is_get_catid = $catid ? $catid : $row['catid'];
+
+ // 鎺ㄨ崘浣
+ $row['my_flag'] = isset($row['my_flag']) ? $row['my_flag'] : ($id ? $this->content_model->get_flag($id) : []);
+
+ return $row;
+ }
+
+ // 鏍煎紡鍖栦繚瀛樻暟鎹
+ protected function _Format_Data($id, $data, $old) {
+
+ // 楠岃瘉鏍忕洰
+ $catid = (int)\Phpcmf\Service::L('input')->post('catid');
+ if (!$this->module['category'][$catid] && !$this->is_hcategory) {
+ $this->_json(0, dr_lang('鏍忕洰[%s]涓嶅瓨鍦', $catid));
+ }
+
+ // 楠岃瘉鍚庡彴鏉冮檺
+ $data[1]['catid'] = $data[0]['catid'] = $catid;
+
+ // 楠岃瘉鐘舵
+ if ($this->is_post_user) {
+ // 鎶曠ǹ鑰
+ $data[1]['status'] = \Phpcmf\Service::M('auth')->is_post_user_status() ? 1 : 9;
+ } else {
+ $data[1]['status'] = 9;
+ }
+
+ $data[1]['uid'] = (int)$data[1]['uid'];
+
+ // 榛樿鏁版嵁
+ $data = $this->content_model->format_data($data);
+
+ // 涓嶆洿鏂版椂闂
+ if (!$old['updatetime']) {
+ !$data[1]['updatetime'] && $data[1]['updatetime'] = SYS_TIME;
+ } elseif ($id && isset($_POST['no_time'])
+ && $_POST['no_time']) {
+ $data[1]['updatetime'] = $old['updatetime'];
+ }
+
+ return $data;
+ }
+
+ /**
+ * 淇濆瓨鍐呭
+ * $id 鍐呭id,鏂板涓0
+ * $data 鎻愪氦鍐呭鏁扮粍,鐣欑┖涓鸿嚜鍔ㄨ幏鍙
+ * $func 鏍煎紡鍖栨彁浜ょ殑鏁版嵁
+ * */
+ protected function _Save($id = 0, $data = [], $old = [], $func = null, $func2 = null) {
+
+ $did = intval(\Phpcmf\Service::L('input')->get('did'));
+ $is_draft = intval(\Phpcmf\Service::L('input')->post('is_draft'));
+
+ if ($this->is_post_user) {
+ if ($old && $old['uid'] && $old['uid'] != $data[1]['uid']) {
+ return dr_return_data(0, dr_lang('褰掑睘璐﹀彿鏃犳硶鏇存敼'), ['field' => 'uid']);
+ } elseif ($data[1]['uid'] != $this->uid) {
+ return dr_return_data(0, dr_lang('褰掑睘璐﹀彿鏃犳硶鏇存敼'), ['field' => 'uid']);
+ }
+ }
+
+ // 鍒ゆ柇瀹氭椂鍙戝竷鏃堕棿
+ if (defined('IS_MODULE_TIME')) {
+ if (isset($_POST['posttime']) && $_POST['posttime']) {
+ $this->post_time = (int)strtotime(\Phpcmf\Service::L('input')->post('posttime'));
+ } else {
+ $this->post_time = (int)strtotime(\Phpcmf\Service::L('input')->get('posttime'));
+ }
+ if (SYS_TIME > $this->post_time) {
+ return dr_return_data(0, dr_lang('瀹氭椂鍙戝竷鏃堕棿涓嶆纭'), $data);
+ }
+ // 淇濆瓨瀹氭椂鍙戝竷鏁版嵁
+ $this->init['table'] = dr_module_table_prefix(APP_DIR).'_time';
+ $rt = $this->content_model->save_post_time($id, $data, $this->post_time);
+ $this->_json($rt['code'], $rt['msg']);
+ } elseif ($is_draft) {
+ // 鑽夌ǹ绠卞瓨鍌
+ $data[1]['id'] = $id;
+ $this->name.= dr_lang('鑽夌ǹ绠');
+ $this->init['table'] = dr_module_table_prefix(APP_DIR).'_draft';
+ return $this->content_model->insert_draft($did, $data);
+ } else {
+ // 鍒犻櫎鑽夌ǹ
+ $did && $this->content_model->delete_draft($did);
+ if (defined('IS_MODULE_RECYCLE')) {
+ // 鏄惁鍥炴敹绔欐仮澶嶏紝id鎭㈠浠ュ墠鐨
+ $id = $data[1]['id'] = $data[0]['id'] = intval($old['id']);
+ }
+ // 姝e父瀛樺偍
+ return parent::_Save($id, $data, $old,
+ function ($id, $data, $old) {
+ // 绂佹淇敼鏍忕洰
+ if ($old['catid'] && $this->module['category'][$old['catid']]['setting']['notedit']) {
+ $data[1]['catid'] = $old['catid'];
+ }
+ // 鍙戝竷涔嬪墠鍒ゆ柇
+ if ($old && defined('IS_MODULE_VERIFY')) {
+ // 鏄惁鏉ヨ嚜瀹℃牳
+ if (!isset($_POST['flag'])) {
+ $_POST['flag'] = $old['my_flag'];
+ }
+ if ($this->is_post_user && IS_USE_MEMBER) {
+ // 鎶曠ǹ鑰呯紪杈
+ $data[1]['status'] = $this->is_hcategory ? $this->content_model->_hcategory_member_post_status($this->member) : $this->content_model->get_verify_status(
+ $data[1]['id'],
+ $this->member,
+ \Phpcmf\Service::M('member_auth', 'cms')->category_auth($this->module, $data[1]['catid'], 'verify', $this->member)
+ );
+ } else {
+ if ($_POST['verify']['status']) {
+ // 閫氳繃
+ $step = $this->_get_verify($old['verify']['vid']);
+ $status = intval($old['status']);
+ $data[1]['status'] = dr_count($step) - 1 <= $status ? 9 : $status + 1;
+ // 鍐嶆楠岃瘉瀹℃牳绾у埆
+ if (!$this->_get_verify_status_edit($old['verify']['vid'], $data[1]['status'])) {
+ $this->_json(0, dr_lang('褰撳墠瑙掕壊鏃犳潈闄愬鏍告鍐呭'));
+ }
+ // 浠诲姟鎵ц鎴愬姛
+ \Phpcmf\Service::M('member')->todo_admin_notice( MOD_DIR.'/verify/edit:id/'.$id, SITE_ID);
+ if ($data[1]['status'] == 9 && $old) {
+ // 瀹℃牳閫氳繃鏃惰鍙栨渶鏂版暟鎹
+ $new = \Phpcmf\Service::M()->table_site(MOD_DIR)->get($old['id']);
+ if ($new) {
+ $data[1]['hits'] = $new['hits'];
+ }
+ }
+ } else {
+ // 鎷掔粷
+ $data[1]['status'] = 0;
+ // 閫氱煡
+ $old['note'] = (string)$_POST['verify']['msg'];
+ \Phpcmf\Service::L('Notice')->send_notice('module_content_verify_0', $old);
+ }
+ }
+ } elseif (defined('IS_MODULE_RECYCLE')) {
+ // 鏄惁鍥炴敹绔欐仮澶
+ $this->content_model->recovery([IS_MODULE_RECYCLE]);
+ } elseif (defined('IS_MODULE_TG')) {
+ // 鏄惁閫绋
+ $data[1]['status'] = 0;
+ // 閫氱煡
+ $_POST['verify']['msg'] = $old['note'] = \Phpcmf\Service::L('input')->get('note', true);
+ if (!isset($_POST['flag'])) {
+ $_POST['flag'] = $old['my_flag'];
+ }
+ \Phpcmf\Service::L('Notice')->send_notice('module_content_verify_0', $old);
+ $this->content_model->table($this->content_model->mytable.'_verify')->delete($id);
+ $this->name.= dr_lang('閫绋垮鏍');
+ }
+
+ return dr_return_data(1, 'ok', $data);
+ },
+ function ($id, $data, $old) {
+
+ // 瀹℃牳閫氳繃鍚
+ if ($data[1]['status'] == 9) {
+
+ // 鍚屾鍙戦佸埌鍏朵粬鏍忕洰
+ $this->content_model->sync_cat(\Phpcmf\Service::L('input')->post('sync_cat'), $data);
+ // 澶勭悊鎺ㄨ崘浣
+ if ($old['my_flag']) {
+ $this->content_model->delete_flag($id, 'all');
+ }
+ $myflag = \Phpcmf\Service::L('input')->post('flag');
+ if ($myflag) {
+ foreach ($myflag as $i) {
+ if (isset($this->module['setting']['flag'][$i])) {
+ $this->content_model->insert_flag((int)$i, $id, $data[1]['uid'], $data[1]['catid']);
+ }
+ }
+ }
+ }
+
+ $data[1]['id'] = $id;
+
+ return $data;
+ }
+ );
+ }
+ }
+
+ /**
+ * 鍥炶皟澶勭悊缁撴灉
+ * $data
+ * */
+ protected function _Call_Post($data) {
+
+ if ($data[1]['status'] == 9) {
+ $html = $list = '';
+ if ($this->module['category'][$data[1]['catid']]['setting']['html']) {
+ // 鐢熸垚鏉冮檺鏂囦欢
+ if (!dr_html_auth(1)) {
+ $this->_json(0, dr_lang('/cache/html/ 鏃犳硶鍐欏叆鏂囦欢'));
+ }
+ $list = dr_web_prefix('index.php?s='.MOD_DIR.'&c=html&m=categoryfile&id='.$data[1]['catid']);
+ }
+ if ($this->module['category'][$data[1]['catid']]['setting']['chtml']) {
+ // 鐢熸垚鏉冮檺鏂囦欢
+ if (!dr_html_auth(1)) {
+ $this->_json(0, dr_lang('/cache/html/ 鏃犳硶鍐欏叆鏂囦欢'));
+ }
+ $html = dr_web_prefix('index.php?s='.MOD_DIR.'&c=html&m=showfile&id='.$data[1]['id']);
+ }
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'), [
+ 'id' => $data[1]['id'],
+ 'url' => isset($_GET['is_self']) ? dr_url(MOD_DIR.'/home/edit', ['id' => $data[1]['id']]) : '',
+ 'catid' => $data[1]['catid'],
+ 'htmlfile' => $html,
+ 'htmllist' => $list
+ ]);
+ } else {
+ if (intval(\Phpcmf\Service::L('input')->post('is_draft'))) {
+ // 鑽夌ǹ
+ $this->_json(1, dr_lang('淇濆瓨鑽夌ǹ鎴愬姛'));
+ } elseif ($this->is_post_user) {
+ // 鎶曠ǹ鑰
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛锛岀瓑寰呯鐞嗗憳瀹℃牳'), [
+ 'url' => dr_url($this->_is_admin_auth(MOD_DIR.'/verify/index') ? MOD_DIR.'/verify/index' : MOD_DIR.'/home/index'),
+ 'id' => $data[1]['id'],
+ 'catid' => $data[1]['catid'],
+ ]);
+ }
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'), [
+ 'id' => $data[1]['id'],
+ 'catid' => $data[1]['catid']
+ ]);
+ }
+ }
+
+ // 楠岃瘉鏄惁鍏锋湁瀹℃牳鐘舵
+ protected function _get_verify_status_edit($vid, $status) {
+
+ if (dr_in_array(1, $this->admin['roleid'])) {
+ return 1; // 瓒呯鐢ㄦ埛
+ } elseif ($status == 0) {
+ return 1; // 閫绋跨殑鍙互鐪嬪埌
+ } elseif (\Phpcmf\Service::M('auth')->is_post_user()) {
+ return 0; // 鎶曠ǹ鑰呬笉鍏佽缂栬緫瀹℃牳
+ }
+
+ if (!IS_USE_MEMBER) {
+ return 1;
+ }
+
+ $verify = $this->get_cache('verify');
+ if (!$verify) {
+ return 0; // 娌℃湁瀹℃牳娴佺▼鏃
+ }
+
+ $my = [];
+ foreach ($verify as $t) {
+ if ($t['value']['role']) {
+ $rid = [];
+ foreach ($t['value']['role'] as $c) {
+ if (is_array($c)) {
+ $rid = array_merge($rid, $c);
+ } elseif (is_numeric($c)) {
+ $rid[] = $c;
+ }
+ }
+ if (dr_array_intersect($rid, $this->admin['roleid'])) {
+ $my[] = $t['id'];
+ }
+ }
+ }
+
+ if (!$my) {
+ // 姝ょ鐞嗗憳娌℃湁绠$悊鏉冮檺
+ return 0;
+ }
+
+ // 鏈夋潈闄愪簡
+ if (dr_in_array($vid, $my)) {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ // 鑾峰彇褰撳墠鏍忕洰鐨勬椂鍊欐祦绋
+ protected function _get_verify($vid) {
+
+ $rt = [];
+ $cache = $this->get_cache('verify');
+ if ($cache && $vid && $cache[$vid]) {
+ $verify = $cache[$vid];
+ if ($verify['value']['role']) {
+ $role = $this->get_cache('auth');
+ foreach ($verify['value']['role'] as $id => $rid) {
+ if (!is_array($rid)) {
+ if (isset($role[$rid]) && $role[$rid]) {
+ $rt[$id] = [
+ 'rid' => $rid,
+ 'name' => dr_lang($role[$rid]['name'] ? $role[$rid]['name'] : '绠$悊鍛'),
+ ];
+ }
+ } else {
+ $ns = [];
+ foreach ($rid as $r) {
+ if (isset($role[$r]) && $role[$r]) {
+ $ns[] = dr_lang($role[$r]['name'] ? $role[$r]['name'] : '绠$悊鍛');
+ }
+ }
+ if ($ns) {
+ $ns = array_unique($ns);
+ $rt[$id] = [
+ 'rid' => $r,
+ 'name' => implode('銆', $ns),
+ ];
+ }
+ }
+ }
+ }
+ }
+
+ $rt[9] = [
+ 'name' => dr_lang('瀹屾垚'),
+ ];
+
+ return $rt;
+ }
+
+ // 妯″潡鍚庡彴鑿滃崟
+ protected function _module_menu($module, $list_name, $list_url, $post_url) {
+
+ //
+ $module_menu = ' ';
+ $module_menu.= '';
+
+ // 鏄剧ず鑿滃崟
+ $menu = '';
+ $menu.= ' '.$list_name.' '.$module_menu.' ';
+
+ // 鐙珛妯″潡鏄剧ず鍏舵爮鐩
+ if (!$module['share'] && $this->_is_admin_auth($module['dirname'].'/category/index')) {
+ $menu.= ' '.dr_lang('鏍忕洰绠$悊').' ';
+ }
+
+ $menu.= ' '.dr_lang('鏇存柊URL').' ';
+ if ($this->_is_admin_auth('module/module/edit')) {
+ $menu.= ' '.dr_lang('妯″潡閰嶇疆').' ';
+ }
+
+ // 闈炲唴瀹归〉闈㈠氨鏄剧ず杩斿洖閾炬帴
+ if (\Phpcmf\Service::L('router')->uri() != $module['dirname'].'/home/index'
+ && $this->_is_admin_auth($module['dirname'].'/home/index') ) {
+ $menu.= ' '.dr_lang('杩斿洖').' ';
+ }
+
+ // 鍙戝竷鍜岀紪杈戞潈闄
+ $this->_is_admin_auth($module['dirname'].'/home/add') && $post_url && $menu.= ' '.(isset($module['post_name']) && $module['post_name'] ? dr_lang($module['post_name']) : dr_lang('鍙戝竷')).' ';
+ \Phpcmf\Service::L('router')->method == 'edit' && $menu.= ' '.dr_lang('淇敼').' ';
+
+ // 閫変腑鍒ゆ柇
+ strpos($menu, 'class="on"') === false && $menu = str_replace('{ON}', 'on', $menu);
+
+ return $menu;
+ }
+
+ /**
+ * 鍏煎浣庣増鏈
+ */
+ protected function _app_cbottom_fix($type = '', $data = [])
+ {
+
+ if (!$type) {
+ // 琛ㄧず妯″潡閮ㄥ垎
+ $endfix = '';
+ } else {
+ $endfix = '_'.$type;
+ }
+
+ // 鍔犺浇妯″潡鑷韩鐨
+ if (APP_DIR && is_file(APPPATH.'Config/Cbottom'.$endfix.'.php')) {
+ $_clink = require APPPATH.'Config/Cbottom'.$endfix.'.php';
+ if ($_clink) {
+ if (is_file(APPPATH.'Models/Auth'.$endfix.'.php')) {
+ $obj = \Phpcmf\Service::M('auth'.$endfix, APP_DIR);
+ if (method_exists($obj, 'is_bottom_auth') && $obj->is_bottom_auth(APP_DIR)) {
+ $data = array_merge($data , $_clink);
+ }
+ } else {
+ $data = array_merge($data , $_clink);
+ }
+ }
+ }
+
+ // 鍔犺浇鍏ㄩ儴鎻掍欢鐨
+ $local = \Phpcmf\Service::Apps(1);
+ foreach ($local as $dir => $path) {
+ // 鎺掗櫎妯″潡鑷韩
+ if (strtolower($dir) == APP_DIR) {
+ continue;
+ }
+ // 鍒ゆ柇鎻掍欢鐩綍
+ if (is_file($path.'Config/Cbottom'.$endfix.'.php') && is_file($path.'Config/App.php')) {
+ $cfg = require $path.'Config/App.php';
+ if ($cfg['type'] == 'app' && !$cfg['ftype']) {
+ // 琛ㄧず鎻掍欢闈炴ā鍧
+ $_clink = require $path.'Config/Cbottom'.$endfix.'.php';
+ if ($_clink) {
+ if (is_file($path.'Models/Auth'.$endfix.'.php')) {
+ $obj = \Phpcmf\Service::M('auth'.$endfix, $dir);
+ if (method_exists($obj, 'is_bottom_auth') && $obj->is_bottom_auth(APP_DIR)) {
+ $data = array_merge($data , $_clink);
+ }
+ } else {
+ $data = array_merge($data , $_clink);
+ }
+ }
+ }
+ }
+ }
+
+ if ($data) {
+ foreach ($data as $i => $t) {
+ if (IS_ADMIN) {
+ if (!$t['url']) {
+ unset($data[$i]); // 娌℃湁url
+ CI_DEBUG && log_message('debug', 'Cbottom锛'.$t['name'].'锛夋病鏈夎缃畊rl鍙傛暟');
+ continue;
+ } elseif ($t['uri'] && !$this->_is_admin_auth($t['uri'])) {
+ unset($data[$i]); // 鏃犳潈闄愮殑涓嶈
+ continue;
+ }
+ $data[$i]['url'] = urldecode($data[$i]['url']);
+ } else {
+ if (!$t['murl']) {
+ unset($data[$i]); // 闈炲悗鍙板繀椤婚獙璇乵url
+ CI_DEBUG && log_message('debug', 'Cbottom锛'.$t['name'].'锛夋病鏈夎缃甿url鍙傛暟');
+ continue;
+ }
+ $data[$i]['url'] = urldecode($data[$i]['murl']);
+ }
+ }
+ }
+
+ return $data;
+ }
+}
diff --git a/dayrui/App/Cms/Extends/Home/Module.php b/dayrui/App/Cms/Extends/Home/Module.php
new file mode 100644
index 0000000..2568476
--- /dev/null
+++ b/dayrui/App/Cms/Extends/Home/Module.php
@@ -0,0 +1,858 @@
+_json(0, '绂佹鎻愪氦锛岃妫鏌ユ彁浜ゅ湴鍧鏄惁鏈夎');
+ }
+
+ // 鍒濆鍖栨ā鍧
+ $this->_module_init();
+
+ // 鎵ц鑷畾涔夋柟娉
+ $this->content_model->_call_index();
+
+ // 鍏变韩妯″潡鏃剁姝㈣闂椤
+ if ($this->module['share']) {
+ $this->goto_404_page(dr_lang('鍏变韩妯″潡娌℃湁棣栭〉鍔熻兘'));
+ }
+
+ if ($this->module['setting']['search']['indexsync']) {
+ // 闆嗘垚鎼滅储
+ return $this->_Search(0);
+ } else {
+ // 鍒ゆ柇URL閲嶅闂
+ if (!$html) {
+ \Phpcmf\Service::L('Router')->is_redirect_url(dr_url_prefix(MODULE_URL, $this->module['dirname']), 1);
+ }
+
+ // 妯℃澘鍙橀噺
+ \Phpcmf\Service::V()->assign([
+ 'indexm' => 1,
+ 'pageid' => max(1, max(1, (int)\Phpcmf\Service::L('input')->get('page'))),
+ 'fix_html_now_url' => defined('IS_MOBILE') && IS_MOBILE ? $this->module['murl'] : $this->module['url'],
+ ]);
+ \Phpcmf\Service::V()->assign($this->content_model->_format_home_seo($this->module));
+ \Phpcmf\Hooks::trigger('module_index');
+
+ // 绯荤粺寮鍚潤鎬侀椤
+ if (!defined('SC_HTML_FILE') && $this->module['setting']['module_index_html']) {
+
+ ob_start();
+ \Phpcmf\Service::V()->display('index.html');
+ $html = ob_get_clean();
+
+ if ($this->module['domain']) {
+ // 缁戝畾鍩熷悕鏃
+ $file = 'index.html';
+ } else {
+ $file = ltrim(\Phpcmf\Service::L('Router')->remove_domain(MODULE_URL), '/'); // 浠庡湴鍧涓幏鍙栬鐢熸垚鐨勬枃浠跺悕;
+ }
+
+ if (!$file) {
+ // 闈欐佹枃浠跺け璐ュ氨杈撳嚭褰撳墠椤甸潰
+ echo $html;exit;
+ }
+
+ if (IS_CLIENT) {
+ // 缁堢涓嬩笉鐢熸垚
+ } elseif (defined('IS_MOBILE') && IS_MOBILE) {
+ // 绉诲姩绔闂
+ if (SITE_IS_MOBILE || $this->module['mobile_domain']) {
+ file_put_contents(dr_is_app('chtml') ? \Phpcmf\Service::L('html', 'chtml')->get_webpath(SITE_ID, $this->module['dirname'], SITE_MOBILE_DIR.'/'.$file) : WEBPATH.SITE_MOBILE_DIR.'/'.$file, $html);
+ }
+ } else {
+ // 鐢佃剳绔闂
+ file_put_contents(dr_is_app('chtml') ? \Phpcmf\Service::L('html', 'chtml')->get_webpath(SITE_ID, $this->module['dirname'], $file) : WEBPATH.$file, $html);
+ }
+ echo $html;
+ } else {
+ \Phpcmf\Service::V()->display('index.html');
+ }
+ }
+ }
+
+ // 妯″潡鎼滅储
+ protected function _Search($_catid = 0, $rt = 0) {
+
+ if (IS_POST) {
+ $this->_json(0, '绂佹鎻愪氦锛岃妫鏌ユ彁浜ゅ湴鍧鏄惁鏈夎');
+ }
+
+ // 妯″瀷绫
+ $search = \Phpcmf\Service::M('Search', $this->module['dirname'])->init($this->module['dirname']);
+
+ // 鎼滅储鍙傛暟
+ list($catid, $get) = $search->get_param($this->module);
+ !$catid && $_catid && $catid = $_catid;
+ $catid = intval($catid);
+
+ // 闈瀐ttp璇锋眰涔嬩笅
+ if (!IS_API_HTTP) {
+ if (!isset($this->module['setting']['search']['use']) || !$this->module['setting']['search']['use']) {
+ $this->_msg(0, dr_lang('姝ゆā鍧楀凡缁忓叧闂簡鎼滅储鍔熻兘'));
+ } elseif (IS_USE_MEMBER && \Phpcmf\Service::M('member_auth', 'cms')->module_auth($this->module['dirname'], 'search', $this->member)) {
+ $this->_msg(0, dr_lang('鎮ㄧ殑鐢ㄦ埛缁勬棤鏉冮檺鎼滅储'), $this->uid || !defined('SC_HTML_FILE') ? '' : dr_member_url('login/index'));
+ } elseif ($get['keyword'] && $this->module['setting']['search']['length']
+ && dr_strlen($get['keyword']) < (int)$this->module['setting']['search']['length']) {
+ $this->_msg(0, dr_lang('鍏抽敭瀛椾笉寰楀皯浜庣郴缁熻瀹氱殑闀垮害'));
+ } elseif ($get['keyword'] && $this->module['setting']['search']['maxlength']
+ && dr_strlen($get['keyword']) > (int)$this->module['setting']['search']['maxlength']) {
+ $this->_msg(0, dr_lang('鍏抽敭瀛椾笉寰楀ぇ浜庣郴缁熻瀹氱殑闀垮害'));
+ }
+ }
+
+ //鎼滅储鍙傛暟涓虹┖鏃朵笉鏄剧ず缁撴灉
+ $null = 0;
+ if (isset($this->module['setting']['search']['search_param']) && $this->module['setting']['search']['search_param']) {
+ if (!$get) {
+ $null = 1;
+ } else {
+ $null = 1;
+ foreach ($get as $t) {
+ if ($t) {
+ $null = 0;
+ break;
+ }
+ }
+ }
+ }
+
+ if ($null) {
+ $data = [
+ 'id' => 0,
+ 'catid' => $catid,
+ 'params' => $get,
+ 'keyword' => $get['keyword'],
+ 'contentid' => 0,
+ 'inputtime' => SYS_TIME
+ ];
+ } else {
+ // 鎼滅储鏁版嵁
+ $data = $search->get_data();
+ if (isset($data['code']) && $data['code'] == 0 && $data['msg']) {
+ $this->_msg(0, $data['msg']);
+ }
+ unset($data['params']['page']);
+ }
+
+ // 鏍煎紡鍖栨暟鎹
+ $data = $this->content_model->_call_search($data);
+
+ // 鎸傞挬鐐 鎼滅储瀹屾垚涔嬪悗
+ $rt2 = \Phpcmf\Hooks::trigger_callback('module_search_data', $data);
+ if ($rt2 && isset($rt2['code']) && $rt2['code']) {
+ $data = $rt2['data'];
+ }
+
+ // 鑾峰彇鍚岀骇鏍忕洰鍙婄埗绾ф爮鐩
+ list($parent, $related) = dr_related_cat(
+ !$this->module['share'] ? $this->module['category'] : \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-share', 'category'),
+ $catid
+ );
+
+ // 鑾峰彇鎼滅储鎬婚噺
+ $sototal = intval($data['contentid']);
+
+ //寮鍚悗閬囧埌鎼滅储鍐呭涓虹┖鏃剁洿鎺ヨ烦杞404椤甸潰
+ if (!$null && !$sototal && isset($this->module['setting']['search']['search_404']) && $this->module['setting']['search']['search_404']) {
+ \Phpcmf\Service::C()->goto_404_page('鍐呭鍖归厤缁撴灉涓虹┖');
+ }
+
+ // 瀛樺偍缂撳瓨浠ヤ究鏍囩涓娇鐢
+ if ($data['id'] && $sototal) {
+ \Phpcmf\Service::L('cache')->set_data('module-search-'.$this->module['dirname'].'-'.$data['id'], $data, 3600);
+ }
+
+ $list = [];
+ // 绉诲姩绔姹傛椂
+ if (IS_API_HTTP && $data['id']) {
+ $rt2 = \Phpcmf\Service::V()->list_tag('search module='.$this->module['dirname']
+ .' id='.$data['id'].' total='.$sototal
+ .' order='.$data['params']['order'].' catid='.$catid
+ .(isset($_GET['more']) && $_GET['more'] ? ' more=1' : '')
+ .' page=1 pagesize='.intval(\Phpcmf\Service::L('input')->request('pagesize'))
+ .' urlrule=test');
+ $list = $rt2['return'];
+ }
+
+ // 鏍忕洰鏍煎紡鍖
+ $cat = $catid && $this->module['category'][$catid] ? $this->module['category'][$catid] : [];
+ $cat && $cat['url'] = dr_url_prefix($cat['url'], MOD_DIR);
+ $top = $cat;
+ if ($catid && $cat['topid']) {
+ $top = $this->module['category'][$cat['topid']];
+ $cat['url'] = dr_url_prefix($cat['url'], MOD_DIR);
+ }
+
+ // 鍒嗛〉鍦板潃
+ $urlrule = dr_module_search_url($data['params'], 'page', '{page}');
+
+ // 璇嗗埆鑷畾涔夊湴鍧锛301瀹氬悜
+ if (dr_is_sys_301() && !IS_API_HTTP && !isset($_GET['ajax_page'])
+ && strpos(FC_NOW_URL, 'index.php') !== false && strpos($urlrule, 'index.php') === false) {
+ $get['page'] > 1 && $data['params']['page'] = $get['page'];
+ dr_redirect(dr_module_search_url($data['params']), 'auto', 301);exit;
+ }
+
+ \Phpcmf\Service::V()->assign($this->content_model->_format_search_seo(
+ $this->module,
+ $catid,
+ ($sototal or (!$sototal && isset($this->module['setting']['search']['show_seo']) && $this->module['setting']['search']['show_seo'])) ? $data['params'] : [],
+ $get['page'])
+ );
+
+ $search_data = [
+ 'cat' => $cat,
+ 'top' => $top,
+ 'get' => $get,
+ 'list' => $list,
+ 'catid' => $catid,
+ 'parent' => $parent,
+ 'pageid' => max(1, $get['page']),
+ 'params' => dr_htmlspecialchars($data['params']),
+ 'keyword' => dr_htmlspecialchars($data['keyword']),
+ 'related' => $related,
+ 'urlrule' => $urlrule,
+ 'sototal' => $sototal,
+ 'searchid' => $data['id'],
+ 'search_id' => $data['id'],
+ 'search_sql' => $data['sql'],
+ 'is_search_page' => 1,
+ ];
+ \Phpcmf\Service::V()->assign($search_data);
+ \Phpcmf\Service::V()->module($this->module['dirname']);
+
+ $tpl = '';
+ if (isset($_GET['ajax_page']) && $_GET['ajax_page']) {
+ $tpl = dr_safe_filename($_GET['ajax_page']);
+ if (!is_file(\Phpcmf\Service::V()->get_dir().$tpl)) {
+ log_message('debug', '鎼滅储妯℃澘鍙傛暟ajax_page鍊煎搴旂殑妯℃澘锛'.\Phpcmf\Service::V()->get_dir().$tpl.'锛変笉瀛樺湪锛屽皢鍔犺浇榛樿鐨勬悳绱㈡ā鏉');
+ $tpl = ''; // 鑷畾涔夋ā鏉夸笉瀛樺湪
+ }
+ } elseif (isset($this->module['setting']['search']['tpl_field'])
+ && $this->module['setting']['search']['tpl_field']
+ && isset($get[$this->module['setting']['search']['tpl_field']])
+ && $get[$this->module['setting']['search']['tpl_field']]
+ ) {
+ $tpl = dr_safe_filename('search_'.$get[$this->module['setting']['search']['tpl_field']].'.html');
+ if (!is_file(\Phpcmf\Service::V()->get_dir().$tpl)) {
+ $msg = '鎼滅储妯℃澘瀛楁'.$this->module['setting']['search']['tpl_field'].'鍙傛暟鍊煎搴旂殑妯℃澘锛'.\Phpcmf\Service::V()->get_dir().$tpl.'锛変笉瀛樺湪锛屽皢鍔犺浇榛樿鐨勬悳绱㈡ā鏉';
+ log_message('debug', $msg);
+ //\Phpcmf\Service::V()->add_load_tips($tpl, $msg);
+ }
+ }
+ if (!$tpl) {
+ $tpl = $catid && $this->module['category'][$catid]['setting']['template']['search'] ? $this->module['category'][$catid]['setting']['template']['search'] : 'search.html';
+ }
+
+ // 杈撳嚭鏂瑰紡
+ if (!$rt) {
+ \Phpcmf\Service::V()->display($tpl);
+ } else {
+ $search_data['phpcmf_tpl'] = $search_data['tpl'] = $tpl;
+ return $search_data;
+ }
+ }
+
+ // 妯″潡鏍忕洰椤
+ public function _Category($catid = 0, $catdir = null, $page = 1, $rt = 0) {
+
+ if (IS_POST) {
+ $this->_json(0, '绂佹鎻愪氦锛岃妫鏌ユ彁浜ゅ湴鍧鏄惁鏈夎');
+ }
+
+ if ($catid) {
+ $category = $this->module['category'][$catid];
+ if (!$category) {
+ $this->goto_404_page(dr_lang('妯″潡銆%s銆戞爮鐩紙%s锛変笉瀛樺湪', $this->module['dirname'], $catid));
+ return;
+ }
+ } elseif ($catdir) {
+ $catid = intval($this->module['category_dir'][$catdir]);
+ $category = $this->module['category'][$catid];
+ if (!$category) {
+ // 鏃犳硶閫氳繃鐩綍鎵惧埌鏍忕洰鏃讹紝灏濊瘯澶氬強鐩綍
+ foreach ($this->module['category'] as $t) {
+ if ($t['setting']['urlrule']) {
+ $rule = \Phpcmf\Service::L('cache')->get('urlrule', $t['setting']['urlrule']);
+ $rule['value']['catjoin'] = '/';
+ if ($rule['value']['catjoin'] && strpos($catdir, $rule['value']['catjoin'])) {
+ $catdir = trim(strchr($catdir, $rule['value']['catjoin']), $rule['value']['catjoin']);
+ if (isset($this->module['category_dir'][$catdir])) {
+ $catid = $this->module['category_dir'][$catdir];
+ $category = $this->module['category'][$catid];
+ break;
+ }
+ }
+ }
+ }
+ // 杩斿洖鏃犳硶鎵惧埌鏍忕洰
+ if (!$category) {
+ $this->goto_404_page(dr_lang('妯″潡銆%s銆戞爮鐩紙%s锛変笉瀛樺湪', $this->module['dirname'], $catdir));
+ return;
+ }
+ }
+ } else {
+ $this->goto_404_page(dr_lang('妯″潡銆%s銆戞爮鐩笉瀛樺湪', $this->module['dirname']));
+ return;
+ }
+
+ // 鏍煎紡鍖栨爮鐩暟鎹
+ $category = $this->content_model->_call_category($category);
+
+ // 鎸傞挬鐐 鏍煎紡鍖栨爮鐩暟鎹
+ $rt2 = \Phpcmf\Hooks::trigger_callback('module_category_data', $category);
+ if ($rt2 && isset($rt2['code']) && $rt2['code']) {
+ $category = $rt2['data'];
+ }
+
+ // 鍒ゆ柇鏄惁澶栭摼
+ if ($category['tid'] == 2) {
+ dr_redirect(dr_url_prefix($category['url'], $this->module['dirname'], SITE_ID), 'refresh');exit;
+ }
+
+ // 楠岃瘉鏄惁瀛樺湪瀛愭爮鐩紝鏄惁灏嗕笅绾х涓涓爮鐩綔涓哄綋鍓嶉〉
+ if ($category['tid'] != 2 && $category['child'] && $category['setting']['getchild']) {
+ $temp = explode(',', $category['childids']);
+ if ($temp) {
+ foreach ($temp as $i) {
+ if ($i != $catid && $this->module['category'][$i]['show']
+ && $this->module['category'][$i]['tid'] != 2
+ && !$this->module['category'][$i]['setting']['getchild']) {
+ $catid = $i;
+ $category = $this->module['category'][$i];
+ if (!$rt) {
+ $url = dr_url_prefix($category['url'], $this->module['dirname']);
+ if (defined('IS_MY_ADMIN')) {
+ // 鏄惁鑷畾涔夊悗鍙板煙鍚
+ }
+ if (SITE_ID > 1) {
+ // 澶氱珯鐐
+ $url = str_replace(SITE_URL, trim(FC_NOW_HOST, '/').WEB_DIR, $url);
+ } elseif (IS_CLIENT) {
+ // 鑷敱鍙傛暟鏃 缁堢鏃 鏇挎崲褰撳墠鍩熷悕
+ $url = str_replace(SITE_URL, FC_NOW_HOST, $url);
+ } elseif (SYS_301) {
+ // 鑷敱鍙傛暟鏃 鏇挎崲褰撳墠鍩熷悕
+ $url = str_replace(SITE_URL, WEB_DIR, $url);
+ }
+ if (defined('SC_HTML_FILE')) {
+ \Phpcmf\Service::V()->assign('goto_url', $url);
+ \Phpcmf\Service::V()->display('goto_url');
+ return $category;
+ } elseif (!IS_API_HTTP){
+ if (IS_DEV) {
+ // 鑷姩璇嗗埆
+ \Phpcmf\Service::C()->_admin_msg(1, '寮鍙戣呮ā寮忥細 褰撳墠URL['.dr_now_url().'] 宸插紑鍚泦鎴愪笅绾ф爮鐩甗'.$url.'] 姝e湪鑷姩璺宠浆涓嬬骇鏍忕洰鍦板潃锛堝叧闂紑鍙戣呮ā寮忔椂鍗冲彲鑷姩璺宠浆锛', $url, 9);
+ }
+ dr_redirect($url, 'location', '301');
+ exit;
+ }
+ }
+ // 鍒濆鍖栨ā鍧
+ $this->_module_init($category['mid'] ? $category['mid'] : 'share');
+ break;
+ }
+ }
+ }
+ }
+
+ // 璺宠浆鍒版悳绱㈤〉闈
+ if (!defined('SC_HTML_FILE')
+ && isset($this->module['setting']['search']['catsync'])
+ && $this->module['setting']['search']['catsync']
+ && $category['tid'] == 1) {
+ $_GET = [
+ 'catid' => $catid
+ ];
+ return $this->_Search($catid);
+ }
+
+ // 鏃犳潈闄愯闂爮鐩
+ if (IS_USE_MEMBER && !defined('SC_HTML_FILE')) {
+ if (($this->module['share']) && $category['tid'] == 0) {
+ // 璇嗗埆鏍忕洰鍗曠綉椤
+ if (!\Phpcmf\Service::M('member_auth', 'cms')->category_auth($this->module, $catid, 'show', $this->member)) {
+ $this->_msg(0, dr_lang('鎮ㄧ殑鐢ㄦ埛缁勬棤鏉冮檺璁块棶鏍忕洰'), $this->uid || !defined('SC_HTML_FILE') ? '' : dr_member_url('login/index'));
+ return;
+ }
+ } else {
+ if (!\Phpcmf\Service::M('member_auth', 'cms')->category_auth($this->module, $catid, 'show', $this->member)) {
+ $this->_msg(0, dr_lang('鎮ㄧ殑鐢ㄦ埛缁勬棤鏉冮檺璁块棶鏍忕洰'), $this->uid || !defined('SC_HTML_FILE') ? '' : dr_member_url('login/index'));
+ return;
+ }
+ }
+ }
+
+ $category['url'] = dr_url_prefix($category['url'], $this->module['dirname']);
+ $top = $category;
+ if ($catid && $category['topid']) {
+ $top = $this->module['category'][$category['topid']];
+ $top['url'] = dr_url_prefix($top['url'], $this->module['dirname']);
+ }
+
+ // 鍒ゆ柇鍐呭鍞竴鎬
+ !$rt && \Phpcmf\Service::L('Router')->is_redirect_url(
+ $page > 1 ? dr_url_prefix(dr_module_category_url($this->module, $category, $page), $this->module['dirname']) : $category['url'],
+ 1,
+ 1
+ );
+
+ // 鑾峰彇鍚岀骇鏍忕洰鍙婄埗绾ф爮鐩
+ list($parent, $related) = dr_related_cat(
+ !$this->module['share'] ? $this->module['category'] : \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-share', 'category'),
+ $catid
+ );
+
+ // 浼犲叆妯℃澘
+ \Phpcmf\Service::V()->assign($this->content_model->_format_category_seo($this->module, $catid, $page));
+ \Phpcmf\Service::V()->assign(array(
+ 'id' => $catid,
+ 'cat' => $category,
+ 'top' => $top,
+ 'catid' => $catid,
+ 'params' => ['catid' => $catid],
+ 'pageid' => max(1, $page),
+ 'parent' => $parent,
+ 'related' => $related,
+ 'urlrule' => \Phpcmf\Service::L('Router')->category_url($this->module, $category, '[page]'),
+ 'fix_html_now_url' => defined('SC_HTML_FILE') ? dr_url_prefix(\Phpcmf\Service::L('Router')->category_url($this->module, $category, $page), $this->module['dirname'], SITE_ID, \Phpcmf\Service::IS_MOBILE_TPL()) : '', // 淇闈欐佷笅鐨勫綋鍓島rl鍙橀噺
+ ));
+
+ // 璇嗗埆鏍忕洰鍗曠綉椤垫ā鏉
+ if (($this->module['share'] || (isset($this->module['config']['scategory']) && $this->module['config']['scategory'])) && $category['tid'] == 0) {
+ \Phpcmf\Service::V()->assign($category);
+ $tpl = !$category['setting']['template']['page'] ? 'page.html' : $category['setting']['template']['page'];
+ } else {
+ if ($this->module['dirname'] != 'share') {
+ \Phpcmf\Service::V()->module($this->module['dirname']);
+ }
+ if ($category['child']) {
+ $tpl = $category['setting']['template']['category'] ? $category['setting']['template']['category'] : 'category.html';
+ } else {
+ $tpl = $category['setting']['template']['list'] ? $category['setting']['template']['list'] : 'list.html';
+ }
+ }
+
+ // 杈撳嚭鏂瑰紡
+ if (!$rt) {
+ \Phpcmf\Service::V()->display($tpl);
+ } else {
+ $category['phpcmf_tpl'] = $category['tpl'] = $tpl;
+ return $category;
+ }
+ }
+
+ // 妯″潡鍐呭椤
+ // $param 鑷畾涔夊瓧娈垫绱
+ public function _Show($id = 0, $param = [], $page = 1, $rt = 0) {
+
+ if (IS_POST) {
+ $this->_json(0, '绂佹鎻愪氦锛岃妫鏌ユ彁浜ゅ湴鍧鏄惁鏈夎');
+ }
+
+ // 閫氳繃鑷畾涔夊瓧娈垫煡鎵緄d
+ $is_id = 1;
+ if (!$id && isset($param['field']) && isset($param['value'])) {
+ $id = md5($param['field'].$param['value']);
+ $is_id = 0;
+ }
+
+ $name = 'module_'.$this->module['dirname'].'_show_id_'.$id.($this->is_mobile ? '_m' : '').($page > 1 ? '_p'.$page : '');
+ $data = \Phpcmf\Service::L('cache')->get_data($name);
+ if (!$data) {
+ $data = $this->content_model->get_data($is_id ? $id : 0, 0, $param);
+ if (!$data) {
+ $this->goto_404_page(dr_lang('%s鍐呭(#%s)涓嶅瓨鍦', $this->module['name'], $id));
+ return;
+ }
+
+ // 妫娴嬭浆鍚戝瓧娈
+ if (!$rt) {
+ foreach ($this->module['field'] as $t) {
+ if ($t['fieldtype'] == 'Redirect' && $data[$t['fieldname']]) {
+ // 瀛樺湪杞悜瀛楁鏃剁殑鎯呭喌
+ \Phpcmf\Service::M()->db->table(dr_module_table_prefix($this->module['dirname']))->where('id', $id)->set('hits', 'hits+1', FALSE)->update();
+ \Phpcmf\Service::V()->assign('goto_url', $data[$t['fieldname']]);
+ \Phpcmf\Service::V()->display('goto_url');
+ return $data;
+ }
+ }
+ }
+
+ // 鏍煎紡鍖栧瓧娈
+ $data = $this->_Show_Data($data, $page);
+
+ // 缂撳瓨缁撴灉
+ if ($data['uid'] != $this->uid && SYS_CACHE) {
+ if ($this->member && $this->member['is_admin']) {
+ // 绠$悊鍛樻椂涓嶈繘琛岀紦瀛
+ \Phpcmf\Service::L('cache')->init()->delete($name);
+ } else {
+ \Phpcmf\Service::L('cache')->set_data($name, $data, SYS_CACHE_SHOW * 3600);
+ if (!$is_id) {
+ // 琛ㄧず鑷畾涔夋煡璇紝鍐嶇紦瀛樹竴娆D
+ \Phpcmf\Service::L('cache')->set_data(str_replace($id, $data['id'], $name), $data, SYS_CACHE_SHOW * 3600);
+ }
+ }
+ }
+ }
+
+ /*
+ if ($data['status'] == 10 && !($this->uid == $data['uid'] || $this->member['is_admin'])) {
+ $this->goto_404_page(dr_lang('鍐呭琚垹闄わ紝鏆傛椂鏃犳硶璁块棶'));
+ return $data;
+ }*/
+
+ $catid = $data['catid'];
+
+ if ($this->is_hcategory) {
+ $parent = $related = [];
+ $rt2 = $this->content_model->_hcategory_member_show_auth();
+ if (!$rt2['code']) {
+ $this->_msg(0, $rt2['msg'], $rt2['data']);
+ }
+ } else {
+ // 鏃犳潈闄愯闂爮鐩唴瀹
+ if (IS_USE_MEMBER && !defined('SC_HTML_FILE')
+ && !\Phpcmf\Service::M('member_auth', 'cms')->category_auth($this->module, $catid, 'show', $this->member)) {
+ $this->_msg(0, dr_lang('鎮ㄧ殑鐢ㄦ埛缁勬棤鏉冮檺璁块棶鏍忕洰'), $this->uid ? '' : dr_member_url('login/index'));
+ return $data;
+ }
+ // 鍒ゆ柇鏄惁鍚屾鏍忕洰
+ if ($data['link_id'] && $data['link_id'] > 0) {
+ \Phpcmf\Service::V()->assign('gotu_url', dr_url_prefix($data['url'], $this->module['dirname']));
+ \Phpcmf\Service::V()->display('go.html', 'admin');
+ return $data;
+ }
+ // 鑾峰彇鍚岀骇鏍忕洰鍙婄埗绾ф爮鐩
+ list($parent, $related) = dr_related_cat(
+ !$this->module['share'] ? $this->module['category'] : \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-share', 'category'),
+ $data['catid']
+ );
+ }
+
+ // 鍒ゆ柇鍒嗛〉
+ if ($page && $data['content_page'] && !$data['content_page'][$page]) {
+ $this->goto_404_page(dr_lang('鍐呭锛#%s锛夊垎椤礫%s]涓嶅瓨鍦', $id, $page));
+ return $data;
+ }
+
+ // 鍒ゆ柇鍐呭鍞竴鎬
+ !$rt && \Phpcmf\Service::L('Router')->is_redirect_url(
+ dr_url_prefix($page > 1 ? dr_module_show_url($this->module, $data, $page) : $data['url'], $this->module['dirname']),
+ 1,
+ 1
+ );
+
+ $cat = $this->module['category'][$catid];
+ $cat['url'] = dr_url_prefix($cat['url'], $this->module['dirname']);
+ $top = $cat;
+ if ($catid && $cat['topid']) {
+ $top = $this->module['category'][$cat['topid']];
+ $top['url'] = dr_url_prefix($top['url'], $this->module['dirname']);
+ }
+
+ if (method_exists($this->content_model, '_call_show_after')) {
+ $data = $this->content_model->_call_show_after($data);
+ }
+
+ // 鎸傞挬鐐
+ $data['cat'] = $cat;
+ $rt2 = \Phpcmf\Hooks::trigger_callback('module_show', $data);
+ if ($rt2 && isset($rt2['code']) && $rt2['code']) {
+ $data = $rt2['data'];
+ }
+
+ $data = dr_array22array($data, $this->content_model->_format_show_seo($this->module, $data, $page));
+
+ // 浼犲叆妯℃澘
+ \Phpcmf\Service::V()->assign($data);
+ \Phpcmf\Service::V()->assign([
+ 'top' => $top,
+ 'pageid' => max(1, $page),
+ 'params' => ['catid' => $catid],
+ 'parent' => $parent,
+ 'related' => $related,
+ 'urlrule' => \Phpcmf\Service::L('Router')->show_url($this->module, $data, '[page]'),
+ 'fix_html_now_url' => defined('SC_HTML_FILE') ? dr_url_prefix(\Phpcmf\Service::L('Router')->show_url($this->module, $data, $page), $this->module['dirname'], SITE_ID, \Phpcmf\Service::IS_MOBILE_TPL()) : '', // 淇闈欐佷笅鐨勫綋鍓島rl鍙橀噺
+ ]);
+ \Phpcmf\Service::V()->module($this->module['dirname']);
+
+ $data['phpcmf_tpl'] = isset($data['template']) && strpos($data['template'], '.html') !== FALSE && is_file(\Phpcmf\Service::V()->get_dir().$data['template']) ? $data['template'] : ($cat['setting']['template']['show'] ? $cat['setting']['template']['show'] : 'show.html');
+ !$rt && \Phpcmf\Service::V()->display($data['phpcmf_tpl']);
+
+ return $data;
+ }
+
+ // 妯″潡鑽夌ǹ銆佸鏍搞佸畾鏃躲佸唴瀹归〉
+ protected function _MyShow($type, $id = 0, $page = 1) {
+
+ if (IS_POST) {
+ $this->_json(0, '绂佹鎻愪氦锛岃妫鏌ユ彁浜ゅ湴鍧鏄惁鏈夎');
+ }
+
+ // 鏍囪瀛楃
+ define('MODULE_MYSHOW', $type);
+
+ // 鎸夌被鍨嬪姞杞藉唴瀹
+ switch($type) {
+
+ case 'time':
+ $row = \Phpcmf\Service::M()->table(dr_module_table_prefix($this->module['dirname']).'_time')->get($id);
+ $data = dr_string2array($row['content']);
+ if (!$data) {
+ $this->goto_404_page(dr_lang('瀹氭椂鍐呭#%s涓嶅瓨鍦', $id));
+ } elseif (($this->uid != $data['uid'] && !$this->member['is_admin'])) {
+ $this->goto_404_page(dr_lang('瀹氭椂鍐呭鍙兘鑷繁璁块棶'));
+ }
+ break;
+
+ case 'recycle':
+ $row = \Phpcmf\Service::M()->table(dr_module_table_prefix($this->module['dirname']).'_recycle')->get($id);
+ $row = dr_string2array($row['content']);
+ if (!$row) {
+ $this->goto_404_page(dr_lang('鍥炴敹绔欏唴瀹#%s涓嶅瓨鍦', $id));
+ } elseif (!$row[SITE_ID.'_'.$this->module['dirname']]) {
+ $this->goto_404_page(dr_lang('鍥炴敹绔欏唴瀹#%s鏍煎紡涓嶈鑼', $id));
+ } elseif (!$this->member['is_admin']) {
+ $this->goto_404_page(dr_lang('鏃犳潈闄愯闂洖鏀剁珯鐨勫唴瀹'));
+ }
+ $data = $row[SITE_ID.'_'.$this->module['dirname']];
+ if (isset($row[SITE_ID.'_'.$this->module['dirname'].'_data_'.intval($data['tableid'])])
+ && $row[SITE_ID.'_'.$this->module['dirname'].'_data_'.intval($data['tableid'])]) {
+ $data = array_merge($data, $row[SITE_ID.'_'.$this->module['dirname'].'_data_'.intval($data['tableid'])]);
+ }
+ break;
+
+ case 'verify':
+ $row = \Phpcmf\Service::M()->table(dr_module_table_prefix($this->module['dirname']).'_verify')->get($id);
+ $data = dr_string2array($row['content']);
+ if (!$data) {
+ $this->goto_404_page(dr_lang('瀹℃牳鍐呭#%s涓嶅瓨鍦', $id));
+ } elseif (!$this->uid) {
+ $this->goto_404_page(dr_lang('闇瑕佺櫥褰曚箣鍚庢墠鑳芥煡鐪'));
+ } elseif (($this->uid != $data['uid'] && !$this->member['is_admin'])) {
+ $this->goto_404_page(dr_lang('鏃犳潈闄愯闂鏍镐腑鐨勫唴瀹'));
+ }
+ break;
+
+ case 'draft':
+ $row = \Phpcmf\Service::M()->table(dr_module_table_prefix($this->module['dirname']).'_draft')->get($id);
+ $data = dr_string2array($row['content']);
+ if (!$data) {
+ $this->goto_404_page( dr_lang('鑽夌ǹ鍐呭#%s涓嶅瓨鍦', $id));
+ } elseif (!$this->uid) {
+ $this->goto_404_page(dr_lang('闇瑕佺櫥褰曚箣鍚庢墠鑳芥煡鐪'));
+ } elseif (($this->uid != $data['uid'] && !$this->member['is_admin'])) {
+ $this->goto_404_page(dr_lang('鏃犳潈闄愯闂埆浜虹殑鑽夌ǹ绠卞唴瀹'));
+ }
+ break;
+
+ default:
+ $this->goto_404_page(dr_lang('鏈畾涔夌殑鎿嶄綔'));exit;
+ }
+
+ $data['id'] = 0;
+
+ // 鏍煎紡鍖栧瓧娈
+ $data = $this->_Show_Data($data, $page);
+
+ // 鍒ゆ柇鍒嗛〉
+ if ($page && $data['content_page'] && !$data['content_page'][$page]) {
+ $this->goto_404_page(dr_lang('璇ュ垎椤典笉瀛樺湪'));
+ return;
+ }
+
+ // 鑾峰彇鍚岀骇鏍忕洰鍙婄埗绾ф爮鐩
+ list($parent, $related) = dr_related_cat(
+ !$this->module['share'] ? $this->module['category'] : \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-share', 'category'),
+ $data['catid']
+ );
+
+ \Phpcmf\Service::V()->assign($data);
+ \Phpcmf\Service::V()->assign(\Phpcmf\Service::L('Seo')->show($this->module, $data, $page));
+ \Phpcmf\Service::V()->assign([
+ 'cat' => $this->module['category'][$data['catid']],
+ 'pageid' => max(1, $page),
+ 'params' => ['catid' => $data['catid']],
+ 'parent' => $parent,
+ 'related' => $related,
+ 'urlrule' => \Phpcmf\Service::L('Router')->show_url($this->module, $data, '[page]'),
+ ]);
+ \Phpcmf\Service::V()->module($this->module['dirname']);
+ \Phpcmf\Service::V()->display(is_file(dr_tpl_path().'show_'.$type.'.html') ? 'show_'.$type.'.html' : 'show.html');
+ return $data;
+ }
+
+ // 鍐呭椤甸潰鐨勫瓧娈垫牸寮忓寲澶勭悊
+ protected function _Show_Data($data, $page) {
+
+
+ // 鏍煎紡鍖栬緭鍑鸿嚜瀹氫箟瀛楁
+ $fields = $this->module['category_data_field'] ? array_merge($this->module['field'], $this->module['category_data_field']) : $this->module['field'];
+ $fields['inputtime'] = ['fieldtype' => 'Date'];
+ $fields['updatetime'] = ['fieldtype' => 'Date'];
+
+ // 鏍煎紡鍖栧瓧娈
+ $data = \Phpcmf\Service::L('Field')->app($this->module['dirname'])->format_value($fields, $data, $page);
+
+ // 澶勭悊鍏抽敭瀛楁爣绛
+ $data['tag'] = $data['keywords'] = isset($data['keywords']) && $data['keywords'] ? trim((string)$data['keywords']) : '';
+ $data['kws'] = [];
+ $data['tags'] = [];
+
+ if (dr_is_app('tag')) {
+ // 鏄惁瀹夎tag
+ $obj = \Phpcmf\Service::M('tag', 'tag');
+ if (!method_exists($obj, 'get_tag_url')) {
+ $obj = false;
+ }
+ $tfield = 'keywords';
+ if (method_exists($obj, 'tag_field')) {
+ $tfield = \Phpcmf\Service::M('tag', 'tag')->tag_field(MOD_DIR);
+ }
+ if ($tfield && isset($data[$tfield]) && $data[$tfield]) {
+ $tag = explode(',', (string)$data[$tfield]);
+ foreach ($tag as $t) {
+ $t = trim($t);
+ if ($t) {
+ // 璇荤紦瀛
+ if ($obj) {
+ $url = $obj->get_tag_url($t);
+ if ($url) {
+ $data['tags'][$t] = dr_url_rel($url);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if ($data['keywords']) {
+ $kw = explode(',', $data['keywords']);
+ foreach ($kw as $t) {
+ $t = trim($t);
+ if ($t) {
+ $data['kws'][$t] = dr_module_search_url([], 'keyword', $t, MOD_DIR);
+ }
+ }
+ }
+
+ // 鎸傞挬鐐 鍐呭璇诲彇涔嬪悗
+ $rt2 = \Phpcmf\Hooks::trigger_callback('module_show_data', $data);
+ if ($rt2 && isset($rt2['code']) && $rt2['code']) {
+ $data = $rt2['data'];
+ }
+
+ // 妯″潡鐨勫洖璋冨鐞
+ $data = $this->content_model->_call_show($data);
+
+ // 闃叉琚閮ㄤ慨鏀
+ if ($this->is_prev_next_page) {
+ // 鍏抽棴鎻掍欢宓屽叆
+ $is_fstatus = dr_is_app('fstatus') && isset($this->module['field']['fstatus']) && $this->module['field']['fstatus']['ismain'] ? 1 : 0;
+
+ // 涓婁竴绡囨枃绔
+ $builder = \Phpcmf\Service::M()->db->table($this->content_model->mytable);
+ $builder->where('catid', (int)$data['catid']);//->where('status', 9)
+ $is_fstatus && $builder->where('fstatus', 1);
+ $builder->where('id<'. (int)$data['id'])->orderBy('id desc');
+ $data['prev_page'] = $builder->limit(1)->get()->getRowArray();
+ if (isset($data['prev_page']['url']) && $data['prev_page']['url']) {
+ $data['prev_page']['url'] = dr_url_rel(dr_url_prefix($data['prev_page']['url'], $this->module['dirname'], SITE_ID, $this->is_mobile));
+ }
+
+ // 涓嬩竴绡囨枃绔
+ $builder = \Phpcmf\Service::M()->db->table($this->content_model->mytable);
+ $builder->where('catid', (int)$data['catid']);//->where('status', 9)
+ $is_fstatus && $builder->where('fstatus', 1);
+ $builder->where('id>'. (int)$data['id'])->orderBy('id asc');
+ $data['next_page'] = $builder->limit(1)->get()->getRowArray();
+ if (isset($data['next_page']['url']) && $data['next_page']['url']) {
+ $data['next_page']['url'] = dr_url_rel(dr_url_prefix($data['next_page']['url'], $this->module['dirname'], SITE_ID, $this->is_mobile));
+ }
+ }
+
+ return $data;
+ }
+
+ // 鍓嶇妯″潡鍥炶皟澶勭悊绫
+ protected function _Call_Show($data) {
+ return $data;
+ }
+
+ // 妯″潡鎵撹祻
+ protected function _Donation($id = 0, $rt = 0) {
+ // 浠庢鏋朵腑绉婚櫎鎵撹祻鎻掍欢鐨勬敮鎸佷唬鐮
+ $this->goto_404_page('璇峰崌绾ф墦璧忔彃浠讹紝姝ゅ姛鑳戒笉鍐嶆敮鎸');
+ }
+
+
+ //==================鐢熸垚闈欐侀儴鍒 - 鍗曚釜鏂囦欢鐢熸垚锛堢户鎵匡紝鐢ㄤ簬澧炲姞淇敼鏃跺疄鏃剁敓鎴愶級=========================
+
+
+ // 鐢熸垚鏍忕洰闈欐侀〉
+ protected function _Category_Html_File() {
+ if (dr_is_app('chtml')) {
+ \Phpcmf\Service::L('html', 'chtml')->_Category_Html_File($this, APP_DIR);
+ } else {
+ $this->_json(0, '娌℃湁瀹夎瀹樻柟鐗堛愰潤鎬佺敓鎴愩戞彃浠');
+ }
+ }
+
+ // 鐢熸垚鍐呭闈欐佸崟椤
+ protected function _Show_Html_File() {
+ if (dr_is_app('chtml')) {
+ \Phpcmf\Service::L('html', 'chtml')->_Show_Html_File($this, APP_DIR);
+ } else {
+ $this->_json(0, '娌℃湁瀹夎瀹樻柟鐗堛愰潤鎬佺敓鎴愩戞彃浠');
+ }
+ }
+
+
+ //==================鐢熸垚闈欐侀儴鍒 - 鍚庡彴鎿嶄綔Ajax鐢熸垚鎵ц=========================
+
+
+ // 鐢熸垚棣栭〉闈欐侀夐」鍒楄〃
+ protected function _Index_Html() {
+ if (dr_is_app('chtml')) {
+ \Phpcmf\Service::L('html', 'chtml')->_Index_Html($this);
+ } else {
+ $this->_json(0, '娌℃湁瀹夎瀹樻柟鐗堛愰潤鎬佺敓鎴愩戞彃浠');
+ }
+ }
+
+ // 鐢熸垚鍐呭闈欐侀夐」鍒楄〃
+ protected function _Show_Html() {
+ if (dr_is_app('chtml')) {
+ \Phpcmf\Service::L('html', 'chtml')->_Show_Html($this, APP_DIR);
+ } else {
+ $this->_json(0, '娌℃湁瀹夎瀹樻柟鐗堛愰潤鎬佺敓鎴愩戞彃浠');
+ }
+ }
+
+ // 鐢熸垚鍐呭闈欐侀夐」鍒楄〃
+ protected function _Category_Html() {
+ if (dr_is_app('chtml')) {
+ \Phpcmf\Service::L('html', 'chtml')->_Category_Html($this, APP_DIR);
+ } else {
+ $this->_json(0, '娌℃湁瀹夎瀹樻柟鐗堛愰潤鎬佺敓鎴愩戞彃浠');
+ }
+ }
+
+}
diff --git a/dayrui/App/Cms/Extends/Member/Module.php b/dayrui/App/Cms/Extends/Member/Module.php
new file mode 100644
index 0000000..d93a6c7
--- /dev/null
+++ b/dayrui/App/Cms/Extends/Member/Module.php
@@ -0,0 +1,1052 @@
+_admin_msg(0, dr_lang('闇瑕佸畨瑁呫愮敤鎴风郴缁熴戞彃浠'));
+ }
+ $this->_Extend_Init();
+ }
+
+ // 缁ф壙绫诲垵濮嬪寲
+ protected function _Extend_Init() {
+ // 鍒濆鍖栨ā鍧
+ $this->_module_init(APP_DIR);
+ // 鏀寔闄勮〃瀛樺偍
+ $this->is_data = 1;
+ // 鏄惁鏀寔妯″潡琛
+ $this->is_module_index = 1;
+ // 鏄惁鏀寔妯″瀷瀛楁
+ $this->is_category_data_field = $this->module['category_data_field'] ? 1 : 0;
+ // 妯℃澘鍓嶇紑(閬垮厤娣锋穯)
+ $this->tpl_prefix = 'module_';
+ // 鍗曠嫭妯℃澘鍛藉悕
+ $this->tpl_name = 'content';
+ // 妯″潡鏄剧ず鍚嶇О
+ $this->name = dr_lang('鍐呭妯″潡[%s]锛%s锛', $this->module['dirname'], $this->module['title']);
+ // 鍒濆鍖栨暟鎹〃
+ $this->_init([
+ 'table' => dr_module_table_prefix($this->module['dirname']),
+ 'field' => $this->module['field'],
+ 'date_field' => 'updatetime',
+ 'show_field' => 'title',
+ 'where_list' => 'uid='.$this->uid,
+ 'order_by' => 'updatetime desc',
+ ]);
+ // 鍐欏叆妯℃澘
+ if (is_file(dr_get_app_dir('cms').'Libraries/Category.php')) {
+ $this->module['category'] = \Phpcmf\Service::L('category', 'cms')->get_category($this->module['dirname']);
+ }
+ $is_right_field = 1;
+ if (isset($this->module['setting']['right_field']) && $this->module['setting']['right_field']) {
+ if ($this->module['setting']['right_field'] == 2) {
+ $is_right_field = 0;
+ }
+ }
+ \Phpcmf\Service::V()->assign([
+ 'field' => $this->init['field'],
+ 'module' => $this->module,
+ 'module_memu' => $this->content_model->module_menu(),
+ 'is_right_field' => $is_right_field,
+ ]);
+
+ }
+
+ // ========================
+
+ // 鏌ョ湅鍒楄〃
+ protected function _Member_List($rt = 0) {
+
+ // 鍒ゆ柇鏍忕洰鍒嗚〃
+ if ($this->module['is_ctable']) {
+ $catid = intval(\Phpcmf\Service::L('input')->get('catid'));
+ if ($catid) {
+ $this->init['table'] = dr_module_ctable(dr_module_table_prefix(APP_DIR), dr_cat_value($catid));
+ }
+ }
+
+ list($tpl) = $this->_List();
+
+ // 鍙敤鐨勬ā鍧楄〃鍗
+ $mform = [];
+ if ($this->module['form']) {
+ foreach ($this->module['form'] as $tid => $t) {
+ if ($t['setting']['is_member']) {
+ $mform[$tid] = $t;
+ }
+ }
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'mcid' => 'list',
+ 'mform' => $mform,
+ 'clink' => $this->_app_clink(), //)杩欓噷鍚庨潰鍋氭潈闄愬垽鏂
+ ]);
+
+ // 瀹㈡埛绔 API锛氱簿绠鍒楄〃锛屽苟鎸夋爮鐩垽鏂慨鏀/鍒犻櫎鏉冮檺锛堝榻 PC module_list 妯℃澘锛
+ if (!$rt && defined('IS_API_HTTP') && IS_API_HTTP) {
+ $this->_api_json_member_content_list('home');
+ }
+
+ if ($rt) {
+ return $tpl;
+ } else {
+ return \Phpcmf\Service::V()->display($tpl);
+ }
+ }
+
+ /**
+ * 浼氬憳鍙敤鏍忕洰锛堜慨澶 mid 涓虹┖琚鍓斻佷互鍙婅嚜鍔ㄩ夊彇绗竴涓彲鍙戝竷鏍忕洰锛
+ */
+ public function _get_module_member_category($module, $name) {
+
+ if (!$module) {
+ return [];
+ }
+
+ $cache_key = $module['dirname'].$name;
+ if (!empty($this->temp['_get_module_member_category'][$cache_key])) {
+ return $this->temp['_get_module_member_category'][$cache_key];
+ }
+
+ if (isset($module['category'][0]) && dr_is_module($module['category'][0])) {
+ $module['category'] = \Phpcmf\Service::L('category', 'cms')->get_category($module['dirname']);
+ }
+
+ $category = is_array($module['category']) ? $module['category'] : [];
+ $mid = $module['dirname'];
+ foreach ($category as $id => $t) {
+ if (!is_array($t)) {
+ continue;
+ }
+ // 鍙鏈缁堟爮鐩墠鏍¢獙 mid / 鏉冮檺锛涚埗鏍忕洰淇濈暀缁欎笅鎷夋爲
+ if (!$t['child']) {
+ // 鐙珛妯″潡鏍忕洰缂撳瓨閲 mid 鍙兘涓虹┖锛岀┖ mid 瑙嗕负褰撳墠妯″潡
+ $cat_mid = isset($t['mid']) ? (string)$t['mid'] : '';
+ if ($cat_mid !== '' && $cat_mid !== (string)$mid) {
+ unset($category[$id]);
+ continue;
+ }
+ if (IS_USE_MEMBER && !\Phpcmf\Service::M('member_auth', 'cms')->category_auth($module, $id, $name, $this->member)) {
+ unset($category[$id]);
+ }
+ }
+ }
+
+ $this->temp['_get_module_member_category'][$cache_key] = $category;
+ return $category;
+ }
+
+ // 浠庡彲鐢ㄦ爮鐩腑鍙栫涓涓彲鍙戝竷鐨勫彾瀛愭爮鐩
+ protected function _first_post_catid($category) {
+
+ if (!$category || !is_array($category)) {
+ return 0;
+ }
+ foreach ($category as $cid => $c) {
+ if (!is_array($c)) {
+ continue;
+ }
+ // child=0 涓烘渶缁堟爮鐩紱tid=1 涓烘ā鍧楀唴瀹规爮鐩
+ if (!$c['child'] && (int)$c['tid'] == 1) {
+ return intval(isset($c['id']) ? $c['id'] : $cid);
+ }
+ }
+ return 0;
+ }
+
+ // 娣诲姞鍐呭
+ protected function _Member_Add($rt = 0) {
+
+ $return_tpl = $rt;
+ $id = 0;
+ $did = intval(\Phpcmf\Service::L('input')->get('did'));
+ $catid = intval(\Phpcmf\Service::L('input')->get('catid'));
+ $category = [];
+
+ $did && $this->auto_save = 0; // 鑽夌ǹ鏁版嵁鏃朵笉鍔犺浇
+ $draft = $did ? $this->content_model->get_draft($did) : [];
+ $catid = $draft['catid'] ? $draft['catid'] : $catid;
+ $select = '';
+
+ if (!$this->is_hcategory) {
+ // 璧版爮鐩潈闄
+ $category = $this->_get_module_member_category($this->module, 'add');
+ // 鏍忕洰id涓嶅瓨鍦ㄦ椂灏卞幓绗竴涓彲鐢ㄦ爮鐩负catid
+ if (!$catid) {
+ list($select, $catid) = \Phpcmf\Service::L('Tree')->select_category(
+ $category,
+ $catid,
+ 'id=\'dr_catid\' name=\'catid\' onChange="show_category_field(this.value)"',
+ '', 1, 1, 1
+ );
+ // Tree 缂撳瓨/瑙f瀽澶辫触鏃讹紝鐩存帴鍙栫涓涓彲鍙戝竷鍙跺瓙鏍忕洰
+ if (!$catid) {
+ $catid = $this->_first_post_catid($category);
+ }
+ } else {
+ $select = \Phpcmf\Service::L('Tree')->select_category(
+ $category,
+ $catid,
+ 'id=\'dr_catid\' name=\'catid\' onChange="show_category_field(this.value)"',
+ '', 1, 1
+ );
+ }
+ if (!$catid) {
+ if ($this->uid) {
+ $this->_msg(0, dr_lang('娌℃湁鍙敤鐨勬爮鐩彂甯冩潈闄'));
+ } else {
+ $this->_msg(0, dr_lang('鎮ㄦ病鏈夌櫥褰'), dr_member_url('login/index'));
+ }
+ } elseif (!$category[$catid]) {
+ if ($this->uid) {
+ $this->_msg(0, dr_lang('褰撳墠鏍忕洰(%s)娌℃湁鍙戝竷鏉冮檺', $this->module['category'][$catid]['name']));
+ } else {
+ $this->_msg(0, dr_lang('褰撳墠鏍忕洰(%s)娌℃湁鍙戝竷鏉冮檺', $this->module['category'][$catid]['name']), dr_member_url('login/index'));
+ }
+ }
+ $this->is_post_code = \Phpcmf\Service::M('member_auth', 'cms')->category_auth($this->module, $catid, 'code', $this->member);
+ } else {
+ // 涓嶈蛋鏍忕洰鏉冮檺锛岃蛋鑷畾涔夋潈闄
+ $auth_rt = $this->content_model->_hcategory_member_add_auth();
+ if (!$auth_rt['code']) {
+ $this->_msg(0, $auth_rt['msg'], $auth_rt['data']);
+ }
+ $this->is_post_code = $this->content_model->_hcategory_member_post_code();
+ }
+
+ $this->is_get_catid = $catid;
+ $draft && $draft['catid'] = $catid;
+
+ list($tpl) = $this->_Post($id, $draft);
+
+ \Phpcmf\Service::V()->assign([
+ 'did' => $did,
+ 'mcid' => 'add',
+ 'form' => dr_form_hidden(['is_draft' => 0, 'module' => $this->module['dirname'], 'id' => $id]),
+ 'catid' => 0,
+ 'select' => $select,
+ 'draft_url' => \Phpcmf\Service::L('Router')->member_url($this->module['dirname'].'/home/add'),
+ 'draft_list' => $this->content_model->get_draft_list('cid='.$id),
+ 'is_post_code' => $this->is_post_code,
+ 'category_field_url' => $this->is_post_code || $this->module['category_data_field'] ? dr_member_url($this->module['dirname'].'/home/add') : ''
+ ]);
+ if (!$this->uid && is_file(dr_tpl_path().'guest_post.html')) {
+ $tpl = 'guest_post.html';
+ }
+ // 瀹㈡埛绔細GET 杩斿洖瀛楁/鏍忕洰锛汸OST 宸插湪 _Post 鍐 _json
+ if (!$return_tpl && defined('IS_API_HTTP') && IS_API_HTTP) {
+ $this->_api_json_member_content_form(0, $catid, $category, is_array($draft) ? $draft : []);
+ }
+ if ($return_tpl) {
+ return $tpl;
+ } else {
+ return \Phpcmf\Service::V()->display($tpl);
+ }
+ }
+
+ // 淇敼鍐呭
+ protected function _Member_Edit($rt = 0) {
+
+ $return_tpl = $rt;
+ $id = intval(\Phpcmf\Service::L('input')->get('id'));
+ $did = 0;
+ $this->is_get_catid = intval(\Phpcmf\Service::L('input')->get('catid'));
+ if (defined('IS_MODULE_VERIFY')) {
+ $draft = [];
+ } else {
+ $did = intval(\Phpcmf\Service::L('input')->get('did'));
+ $did && $this->auto_save = 0; // 鑽夌ǹ鏁版嵁鏃朵笉鍔犺浇
+ $draft = $did ? $this->content_model->get_draft($did) : [];
+ }
+
+ list($tpl, $data) = $this->_Post($id, $draft);
+ if (!$data) {
+ $this->_msg(0, dr_lang('鍐呭涓嶅瓨鍦'));
+ } elseif ($this->uid != $data['uid']) {
+ $this->_msg(0, dr_lang('鏃犳潈闄愭搷浣'));
+ } elseif (defined('IS_MODULE_VERIFY') && $data['status'] != 0 && $data['islock']) {
+ // 鍒ゆ柇鏄惁鏉ヨ嚦瀹℃牳
+ $this->_msg(0, dr_lang('姝e湪瀹℃牳涔嬩腑'));
+ }
+
+ $category = [];
+ if (defined('IS_MODULE_VERIFY')) {
+ // 瀹℃牳鏂囩珷缂栬緫鏃堕噰鐢ㄦ姇绋挎潈闄愬垽鏂
+ // 鍙紪杈戠殑鏍忕洰
+ $category = $this->_get_module_member_category($this->module, 'add');
+ if (!$category[$data['catid']]) {
+ $this->_msg(0, dr_lang('褰撳墠鏍忕洰[%s]娌℃湁鍙戝竷鏉冮檺', $this->module['category'][$data['catid']]['name']));
+ }
+ } else {
+ if (!$this->is_hcategory) {
+ // 鍙紪杈戠殑鏍忕洰
+ $category = $this->_get_module_member_category($this->module, 'edit');
+ if (!$category[$data['catid']]) {
+ $this->_msg(0, dr_lang('褰撳墠鏍忕洰[%s]娌℃湁淇敼鏉冮檺', $this->module['category'][$data['catid']]['name']));
+ }
+ } else {
+ $auth_rt = $this->content_model->_hcategory_member_edit_auth();
+ if (!$auth_rt['code']) {
+ $this->_msg(0, $auth_rt['msg'], $auth_rt['data']);
+ }
+ }
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'did' => $did,
+ 'form' => dr_form_hidden(['is_draft' => 0, 'module' => $this->module['dirname'], 'id' => $id]),
+ 'select' => \Phpcmf\Service::L('Tree')->select_category(
+ $category,
+ $data['catid'],
+ 'id=\'dr_catid\' name=\'catid\' onChange="show_category_field(this.value)"',
+ '--', 1, 1
+ ),
+ 'is_verify' => defined('IS_MODULE_VERIFY') ? 1 : 0,
+ 'is_sync_cat' => defined('IS_MODULE_VERIFY') ? $data['sync_cat'] : '',
+ 'draft_url' =>\Phpcmf\Service::L('Router')->member_url($this->module['dirname'].'/home/edit', ['id' => $id]),
+ 'draft_list' => $this->content_model->get_draft_list('cid='.$id),
+ 'is_post_code' => $this->is_hcategory ? $this->content_model->_hcategory_member_post_code() : $this->is_post_code,
+ 'category_field_url' => $this->is_post_code || $this->module['category_data_field'] ? dr_member_url($this->module['dirname'].'/'.(defined('IS_MODULE_VERIFY') ? 'verify' : 'home').'/edit', ['id' => $id]) : ''
+ ]);
+ // 瀹㈡埛绔細GET 杩斿洖瀛楁/鏍忕洰锛汸OST 宸插湪 _Post 鍐 _json
+ if (!$return_tpl && defined('IS_API_HTTP') && IS_API_HTTP) {
+ $this->_api_json_member_content_form($id, intval($data['catid'] ?? 0), $category, is_array($draft) ? $draft : []);
+ }
+ if ($return_tpl) {
+ return $tpl;
+ } else {
+ return \Phpcmf\Service::V()->display($tpl);
+ }
+ }
+
+ // 鍒犻櫎鍐呭
+ protected function _Member_Del() {
+
+ $id = (int)\Phpcmf\Service::L('input')->get('id');
+ if (!$id) {
+ $this->_json(0, dr_lang('id涓嶅瓨鍦'));
+ }
+
+ $row = \Phpcmf\Service::M()->table(dr_module_table_prefix($this->module['dirname']).'_index')->get($id);
+ if (!$row) {
+ $this->_json(0, dr_lang('鍐呭涓嶅瓨鍦'));
+ } elseif ($row['uid'] != $this->uid) {
+ $this->_json(0, dr_lang('涓嶈兘鍒犻櫎鍒汉鐨勫唴瀹'));
+ }
+
+ if (!$this->is_hcategory) {
+ $cat = $this->_get_module_member_category($this->module, 'del');
+ if (!isset($cat[$row['catid']])) {
+ $this->_json(0, dr_lang('褰撳墠鏍忕洰[%s]娌℃湁鍒犻櫎鏉冮檺', $this->module['category'][$row['catid']]['name']));
+ }
+ } else {
+ $rt = $this->content_model->_hcategory_member_del_auth();
+ if (!$rt['code']) {
+ $this->_msg(0, $rt['msg'], $rt['data']);
+ }
+ }
+
+ $rt = $this->content_model->delete_to_recycle([$id]);
+ if ($rt['code']) {
+ $this->_json(1, dr_lang('鍒犻櫎鎴愬姛'));
+ } else {
+ $this->_json(0, $rt['msg']);
+ }
+ }
+
+ // ===========================
+
+ // 鏌ョ湅瀹℃牳鍒楄〃
+ protected function _Member_Verify_List($rt = 0) {
+
+ if (isset($this->field['content'])) {
+ $this->field['content']['fieldtype'] = 'Text'; // 闃叉璇嗗埆涓虹紪杈戝櫒瀛楁琚浆涔
+ }
+
+ $this->_init([
+ 'table' => dr_module_table_prefix($this->module['dirname']).'_verify',
+ 'date_field' => 'inputtime',
+ 'order_by' => 'inputtime desc',
+ 'where_list' => 'uid='.$this->uid,
+ ]);
+
+ $this->_List();
+
+ \Phpcmf\Service::V()->assign([
+ 'mcid' => 'verify',
+ 'clink' => $this->_app_clink(), //)杩欓噷鍚庨潰鍋氭潈闄愬垽鏂
+ ]);
+ $tpl = 'module_verify.html';
+ if (!$rt && defined('IS_API_HTTP') && IS_API_HTTP) {
+ $this->_api_json_member_content_list('verify');
+ }
+ if ($rt) {
+ return $tpl;
+ } else {
+ return \Phpcmf\Service::V()->display($tpl);
+ }
+ }
+
+ // 淇敼瀹℃牳鍐呭
+ protected function _Member_Verify_Edit($rt = 0) {
+
+ // 璇存槑鏉ヨ嚜瀹℃牳椤甸潰
+ define('IS_MODULE_VERIFY', 1);
+ return $this->_Member_Edit($rt);
+ }
+
+ // 鍒犻櫎瀹℃牳鍐呭
+ protected function _Member_Verify_Del() {
+
+ // 鏀寔闄勮〃瀛樺偍
+ $this->is_data = 0;
+ $this->_init([
+ 'table' => dr_module_table_prefix($this->module['dirname']).'_verify',
+ ]);
+
+ // 鍒犻櫎鏉′欢
+ $this->delete_where = 'uid='.$this->uid;
+
+ // 鎵ц鍒犻櫎
+ $this->_Del(\Phpcmf\Service::L('input')->get_post_ids(), null, function($rows) {
+ foreach ($rows as $t) {
+ // 鍒犻櫎绱㈠紩
+ $t['isnew'] && \Phpcmf\Service::M()->table(dr_module_table_prefix($this->module['dirname']).'_index')->delete($t['id']);
+ // 鍒犻櫎瀹℃牳鎻愰啋
+ \Phpcmf\Service::M('member')->delete_admin_notice($this->module['dirname'].'/verify/edit:id/'.$t['id'], SITE_ID);
+ }
+ return dr_return_data(1, 'ok');
+ });
+ }
+
+ // ===========================
+
+
+ // 鏌ョ湅鑽夌ǹ鍒楄〃
+ protected function _Member_Draft_List($rt = 0) {
+
+ if (isset($this->field['content'])) {
+ $this->field['content']['fieldtype'] = 'Text'; // 闃叉璇嗗埆涓虹紪杈戝櫒瀛楁琚浆涔
+ }
+
+ $this->_init([
+ 'db' => SITE_ID,
+ 'table' => dr_module_table_prefix($this->module['dirname']).'_draft',
+ 'order_by' => 'inputtime desc',
+ 'date_field' => 'inputtime',
+ 'where_list' => 'uid='.$this->uid,
+ ]);
+
+ $this->_List();
+
+ \Phpcmf\Service::V()->assign([
+ 'mcid' => 'draft'
+ ]);
+ $tpl = 'module_draft.html';
+ if (!$rt && defined('IS_API_HTTP') && IS_API_HTTP) {
+ $this->_api_json_member_content_list('draft');
+ }
+ if ($rt) {
+ return $tpl;
+ } else {
+ return \Phpcmf\Service::V()->display($tpl);
+ }
+ }
+
+ // 鍒犻櫎鑽夌ǹ鍐呭
+ protected function _Member_Draft_Del() {
+
+ // 鏀寔闄勮〃瀛樺偍
+ $this->is_data = 0;
+ $this->_init([
+ 'table' => dr_module_table_prefix($this->module['dirname']).'_draft',
+ ]);
+
+ // 鍒犻櫎鏉′欢
+ $this->delete_where = 'uid='.$this->uid;
+
+ // 鎵ц鍒犻櫎
+ $this->_Del(\Phpcmf\Service::L('input')->get_post_ids());
+ }
+
+ // 鍚屾鍒板涓爮鐩
+ public function syncat_edit() {
+
+ $sync = \Phpcmf\Service::L('input')->get('catid');
+
+ $category = $this->_get_module_member_category($this->module, 'add');
+
+ if (IS_AJAX_POST) {
+
+ $catid = \Phpcmf\Service::L('input')->post('catid');
+ $catid = dr_string2array($catid);
+ if (!$catid) {
+ $this->_json(0, dr_lang('浣犳病鏈夐夋嫨鍚屾鐨勬爮鐩'));
+ }
+
+ $syncat = [];
+ foreach ($catid as $i) {
+ //if ($this->where_list_sql && $this->content_model->admin_is_edit(['catid' => $i])) {
+ //$this->_json(0, dr_lang('褰撳墠瑙掕壊鏃犳潈闄愮鐞嗘鏍忕洰'));
+ //}
+ if (!$category[$i]) {
+ exit($this->_json(0, dr_lang('褰撳墠鏍忕洰[%s]娌℃湁鍙戝竷鏉冮檺', $this->module['category'][$i]['name'])));
+ } elseif (!$this->module['category'][$i]) {
+ continue;
+ } elseif ($this->module['category'][$i]['tid'] != 1) {
+ continue;
+ } elseif (!$this->module['category'][$i]['is_post']) {
+ continue;
+ } else {
+ $syncat[] = $i;
+ }
+ }
+
+ if (!$syncat) {
+ $this->_json(0, dr_lang('鎵閫夋爮鐩棤鏁'));
+ } else {
+ $this->_json(1, dr_count($syncat), implode(',', $syncat));
+ }
+ }
+
+ \Phpcmf\Service::V()->admin(dr_get_app_dir('Module').'/Views/');
+ \Phpcmf\Service::V()->assign([
+ 'menu' => '',
+ 'form' => dr_form_hidden(),
+ 'select' => \Phpcmf\Service::L('Tree')->select_category(
+ $category,
+ $sync ? explode(',', $sync) : 0,
+ 'id=\'dr_catid\' name=\'catid[]\' multiple="multiple" data-actions-box="true"',
+ '', 1, 1
+ ),
+ ]);
+ \Phpcmf\Service::V()->display('share_syncat.html');exit;
+
+ }
+
+ // ===========================
+
+ /**
+ * 鑾峰彇鍐呭
+ * $id 鍐呭id,鏂板涓0
+ * */
+ protected function _Data($id = 0) {
+
+ // 鍒ゆ柇鏄惁鏉ヨ嚦瀹℃牳
+ if (defined('IS_MODULE_VERIFY')) {
+ $row = \Phpcmf\Service::M()->table(dr_module_table_prefix($this->module['dirname']).'_verify')->get($id);
+ if (!$row) {
+ return [];
+ } elseif ($this->uid != $row['uid']) {
+ return [];
+ }
+ $data = dr_string2array($row['content']);
+ $data['islock'] = $row['islock'];
+ define('IS_MODULE_VERIFY_NEW', $row['isnew']);
+ $data['backinfo'] = dr_string2array($row['backinfo']);
+ !$this->is_get_catid && $this->is_get_catid = (int)$row['catid'];
+ // 鏍忕洰楠岃瘉鐮
+ $this->is_post_code = $this->is_hcategory ? $this->content_model->_hcategory_member_post_code() : \Phpcmf\Service::M('member_auth', 'cms')->category_auth($this->module, $this->is_get_catid, 'code', $this->member);
+ return $data;
+ }
+
+ $row = $this->content_model->get_data($id);
+ if (!$row) {
+ return [];
+ } elseif ($this->uid != $row['uid']) {
+ return [];
+ }
+
+ if ($this->module['is_ctable']) {
+ $this->init['table'] = dr_module_ctable($this->init['table'], dr_cat_value($row['catid']));
+ }
+
+ // 鍒ゆ柇鏄悓姝ユ爮鐩暟鎹
+ if ($row['link_id'] > 0) {
+ $row = $this->content_model->get_data($row['link_id']);
+ if (!$row) {
+ return [];
+ }
+ $this->replace_id = $id = $row['id'];
+ }
+
+ !$this->is_get_catid && $this->is_get_catid = (int)$row['catid'];
+
+ // 鏍忕洰楠岃瘉鐮
+ $this->is_post_code = $this->is_hcategory ? $this->content_model->_hcategory_member_post_code() : \Phpcmf\Service::M('member_auth', 'cms')->category_auth($this->module, $this->is_get_catid, 'code', $this->member);
+
+ // 鏇存柊鏃堕棿
+ $row['updatetime'] = SYS_TIME;
+
+ return $row;
+ }
+
+ // 鏍煎紡鍖栦繚瀛樻暟鎹
+ protected function _Format_Data($id, $data, $old) {
+
+ // 楠岃瘉鏍忕洰 楠岃瘉鐮
+ $catid = (int)\Phpcmf\Service::L('input')->post('catid');
+ if (!$this->module['category'][$catid] && !$this->is_hcategory) {
+ $this->_json(0, dr_lang('鏍忕洰[%s]涓嶅瓨鍦', $catid), ['field' => 'catid']);
+ }
+
+ // 鍒ゆ柇鏍忕洰鍒嗚〃
+ $this->module['is_ctable'] && $this->init['table'] = dr_module_ctable(dr_module_table_prefix(APP_DIR), dr_cat_value($catid));
+
+ // 榛樿鏁版嵁
+ $data[1]['uid'] = $data[0]['uid'] = $this->uid;
+ $data[1]['catid'] = $data[0]['catid'] = $catid;
+ $data[1]['updatetime'] = SYS_TIME;
+
+ // 绗竴娆′繚瀛樺垵濮嬪寲淇℃伅
+ if (!$id) {
+ $data[1]['inputip'] = \Phpcmf\Service::L('input')->ip_info();
+ $data[1]['inputtime'] = SYS_TIME;
+ $data[1]['displayorder'] = 0;
+ }
+
+ // 鍒ゆ柇鏄惁鏉ヨ嚦瀹℃牳
+ if (defined('IS_MODULE_VERIFY')) {
+ $data[1]['status'] = 1;
+ // 瀹℃牳鏃
+ } else {
+ // 鍒ゆ柇鏉冮檺
+ // 楠岃瘉鐘舵
+ $data[1]['status'] = $this->is_hcategory ? $this->content_model->_hcategory_member_post_status($id) : $this->content_model->get_verify_status($id,
+ $this->member,
+ \Phpcmf\Service::M('member_auth', 'cms')->category_auth($this->module, $catid, 'verify', $this->member)
+ );
+ }
+
+ // 榛樿鏁版嵁
+ $data = $this->content_model->format_data($data);
+
+ return $data;
+ }
+
+ /**
+ * 淇濆瓨鍐呭
+ * $id 鍐呭id,鏂板涓0
+ * $data 鎻愪氦鍐呭鏁扮粍,鐣欑┖涓鸿嚜鍔ㄨ幏鍙
+ * $func 鏍煎紡鍖栨彁浜ょ殑鏁版嵁
+ * */
+ protected function _Save($id = 0, $data = [], $old = [], $func = null, $func2 = null) {
+
+ $did = intval(\Phpcmf\Service::L('input')->get('did'));
+ $is_draft = intval(\Phpcmf\Service::L('input')->post('is_draft'));
+ if (!defined('IS_MODULE_VERIFY') && $is_draft) {
+ // 鑽夌ǹ绠卞瓨鍌
+ $data[1]['id'] = $id;
+ return $this->content_model->insert_draft($did, $data);
+ } else {
+ // 鍒犻櫎鑽夌ǹ
+ $did && $this->content_model->delete_draft($did);
+ // 姝e父瀛樺偍
+ return parent::_Save($id, $data, $old,
+ // 淇濆瓨涔嬪墠
+ function ($id, $data, $old) {
+ // 鍒ゆ柇鏄惁鏉ヨ嚦瀹℃牳
+ if (defined('IS_MODULE_VERIFY')) {
+ if ($old['status'] != 0 && $old['islock']) {
+ return dr_return_data(0, dr_lang('鍐呭姝e湪瀹℃牳涔嬩腑锛屾棤娉曞啀娆′慨鏀'));
+ }
+ }
+ if ($this->is_hcategory) {
+ // 娌℃湁寮閫氭爮鐩椂
+ $data = $this->content_model->_hcategory_member_save_before($data);
+ return dr_return_data(1, '', $data);
+ }
+ if ($old) {
+ // 琛ㄧず淇敼
+ if (defined('IS_MODULE_VERIFY')) {
+ // 瀹℃牳鏂囩珷缂栬緫鏃堕噰鐢ㄦ姇绋挎潈闄愬垽鏂
+ $cat = $this->_get_module_member_category($this->module, 'add');
+ if (!$cat[$old['catid']]) {
+ return dr_return_data(0, dr_lang('褰撳墠鏍忕洰[%s]娌℃湁鍙戝竷鏉冮檺', $this->module['category'][$old['catid']]['name']));
+ }
+ } else {
+ $cat = $this->_get_module_member_category($this->module, 'edit');
+ if (!$cat[$old['catid']]) {
+ return dr_return_data(0, dr_lang('褰撳墠鏍忕洰[%s]娌℃湁淇敼鏉冮檺', $this->module['category'][$old['catid']]['name']));
+ }
+ }
+ // 绂佹淇敼鏍忕洰
+ if ($this->module['category'][$old['catid']]['setting']['notedit']) {
+ $data[1]['catid'] = $old['catid'];
+ }
+ } else {
+ // 琛ㄧず鏂板
+ $cat = $this->_get_module_member_category($this->module, 'add');
+ if (!$cat[$data[1]['catid']]) {
+ return dr_return_data(0, dr_lang('褰撳墠鏍忕洰[%s]娌℃湁鍙戝竷鏉冮檺', $this->module['category'][(int)$data[1]['catid']]['name']));
+ }
+ if ($this->uid) {
+ // 鍒ゆ柇鏃ュ彂甯冮噺
+ $type_post = \Phpcmf\Service::M('member_auth', 'cms')->category_auth($this->module, $data[1]['catid'], 'type_post', $this->member);
+ $day_post = \Phpcmf\Service::M('member_auth', 'cms')->category_auth($this->module, $data[1]['catid'], 'day_post', $this->member);
+ if ($day_post) {
+ if ($type_post && \Phpcmf\Service::M('member_auth', 'cms')->is_category_public) {
+ // 鎸夊叏灞绠
+ if (\Phpcmf\Service::M()->db
+ ->table(dr_module_table_prefix($this->module['dirname']).'_index')
+ ->where('uid', $this->uid)
+ ->where('DATEDIFF(from_unixtime(inputtime),now())=0')
+ ->countAllResults() >= $day_post) {
+ return dr_return_data(0, dr_lang('褰撳墠妯″潡姣忓ぉ鍙戝竷鏁伴噺涓嶈兘瓒呰繃%s涓', $day_post));
+ }
+ } else {
+ // 鎸夋爮鐩畻
+ if (\Phpcmf\Service::M()->db
+ ->table(dr_module_table_prefix($this->module['dirname']).'_index')
+ ->where('uid', $this->uid)
+ ->where('DATEDIFF(from_unixtime(inputtime),now())=0')
+ ->where('catid', $data[1]['catid'])
+ ->countAllResults() >= $day_post) {
+ return dr_return_data(0, dr_lang('褰撳墠鏍忕洰[%s]姣忓ぉ鍙戝竷鏁伴噺涓嶈兘瓒呰繃%s涓', $this->module['category'][$data[1]['catid']]['name'], $day_post));
+ }
+ }
+ }
+ // 鍒ゆ柇鍙戝竷鎬婚噺
+ $total_post = \Phpcmf\Service::M('member_auth', 'cms')->category_auth($this->module, $data[1]['catid'], 'total_post', $this->member);
+ if ($total_post) {
+ if ($type_post && \Phpcmf\Service::M('member_auth', 'cms')->is_category_public) {
+ // 鎸夊叏灞绠
+ /*
+ $my_total = 0;
+ $modules = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content');
+ foreach ($modules as $m) {
+ if ($m['share']) {
+ $my_total+= \Phpcmf\Service::M()->db
+ ->table(dr_module_table_prefix($m['dirname']).'_index')
+ ->where('uid', $this->uid)
+ ->countAllResults();
+ }
+ }
+ if ($my_total >= $total_post) {
+ return dr_return_data(0, dr_lang('鍙戝竷鏁伴噺涓嶈兘瓒呰繃%s涓', $total_post));
+ }*/
+ if (\Phpcmf\Service::M()->db
+ ->table(dr_module_table_prefix($this->module['dirname']).'_index')
+ ->where('uid', $this->uid)
+ ->countAllResults() >= $total_post) {
+ return dr_return_data(0, dr_lang('褰撳墠妯″潡鍙戝竷鏁伴噺涓嶈兘瓒呰繃%s涓', $total_post));
+ }
+ } else {
+ // 鎸夋爮鐩畻
+ if (\Phpcmf\Service::M()->db
+ ->table(dr_module_table_prefix($this->module['dirname']).'_index')
+ ->where('uid', $this->uid)
+ ->where('catid', $data[1]['catid'])
+ ->countAllResults() >= $total_post) {
+ return dr_return_data(0, dr_lang('褰撳墠鏍忕洰[%s]鍙戝竷鏁伴噺涓嶈兘瓒呰繃%s涓', $this->module['category'][$data[1]['catid']]['name'], $total_post));
+ }
+ }
+ }
+ // 閲戝竵楠岃瘉
+ $score = \Phpcmf\Service::M('member_auth', 'cms')->category_auth($this->module, $data[1]['catid'], 'score', $this->member);
+ if ((int)$score + (int)$this->member['score'] < 0) {
+ $attr = dr_is_app('scorelog') ? [
+ 'button' => [ 'name' => dr_lang('鍏呭'), 'url' => dr_member_url('scorelog/home/pay')]
+ ] : [];
+ return dr_return_data(0, dr_lang(SITE_SCORE.'涓嶈冻锛屽綋鍓嶆爮鐩甗%s]闇瑕%s'.SITE_SCORE, $this->module['category'][$data[1]['catid']]['name'], abs($score)), $attr);
+ }
+ // 閲戦楠岃瘉
+ $money = \Phpcmf\Service::M('member_auth', 'cms')->category_auth($this->module, $data[1]['catid'], 'money', $this->member);
+ if ((float)$money + (float)$this->member['money'] < 0) {
+ $attr = dr_is_app('pay') ? [
+ 'button' => [ 'name' => dr_lang('鍏呭'), 'url' => dr_member_url('pay/recharge/index')]
+ ] : [];
+ return dr_return_data(0, dr_lang('浣欓涓嶈冻锛屽綋鍓嶆爮鐩甗%s]闇瑕%s鍏', $this->module['category'][$data[1]['catid']]['name'], abs($money)), $attr);
+ }
+ }
+ }
+ return dr_return_data(1, '', $data);
+ },
+ // 淇濆瓨涔嬪悗
+ function ($id, $data, $old) {
+ // 鍚屾鍙戦佸埌鍏朵粬鏍忕洰
+ if ($data[1]['status'] == 9 && \Phpcmf\Service::L('input')->post('sync_cat')) {
+ $this->content_model->sync_cat(\Phpcmf\Service::L('input')->post('sync_cat'), $data);
+ }
+ return $data;
+ }
+ );
+ }
+ }
+
+ protected function _api_json_member_content_list($list_type = 'home') {
+
+ $list_type = in_array($list_type, ['home', 'verify', 'draft'], true) ? $list_type : 'home';
+ $list = \Phpcmf\Service::V()->get_value('list');
+ $total = intval(\Phpcmf\Service::V()->get_value('total'));
+ $param = \Phpcmf\Service::V()->get_value('param');
+ $category = is_array($this->module['category'] ?? null) ? $this->module['category'] : [];
+ $auth_edit = [];
+ $auth_del = [];
+ $rows = [];
+
+ if (is_array($list)) {
+ foreach ($list as $t) {
+ if (!is_array($t) || empty($t['id'])) {
+ continue;
+ }
+ $catid = intval($t['catid'] ?? 0);
+ $catname = '';
+ if ($catid && isset($category[$catid]['name'])) {
+ $catname = (string)$category[$catid]['name'];
+ } elseif (!empty($t['catname'])) {
+ $catname = (string)$t['catname'];
+ }
+
+ // 瀹℃牳/鑽夌ǹ锛氫富棰樺湪 content 搴忓垪鍖栧瓧娈典腑
+ $content = [];
+ if ($list_type === 'verify' || $list_type === 'draft') {
+ $raw = $t['content'] ?? [];
+ if (is_string($raw)) {
+ $content = dr_string2array($raw);
+ } elseif (is_array($raw)) {
+ $content = $raw;
+ }
+ if (!is_array($content)) {
+ $content = [];
+ }
+ }
+
+ if ($list_type === 'home') {
+ if (!isset($auth_edit[$catid])) {
+ $auth_edit[$catid] = $this->content_model->check_member_auth($catid, 'edit') ? 1 : 0;
+ $auth_del[$catid] = $this->content_model->check_member_auth($catid, 'del') ? 1 : 0;
+ }
+ $rows[] = [
+ 'id' => intval($t['id']),
+ 'title' => (string)($t['title'] ?? ''),
+ 'catid' => $catid,
+ 'catname' => $catname,
+ 'author' => (string)($t['author'] ?? ''),
+ 'url' => (string)($t['url'] ?? ''),
+ 'uid' => intval($t['uid'] ?? 0),
+ 'status' => intval($t['status'] ?? 0),
+ 'inputtime' => $t['inputtime'] ?? '',
+ 'updatetime' => $t['updatetime'] ?? '',
+ 'can_edit' => $auth_edit[$catid],
+ 'can_del' => $auth_del[$catid],
+ ];
+ } elseif ($list_type === 'verify') {
+ $status = intval($t['status'] ?? 0);
+ $rows[] = [
+ 'id' => intval($t['id']),
+ 'title' => (string)($content['title'] ?? $t['title'] ?? ''),
+ 'catid' => $catid,
+ 'catname' => $catname,
+ 'author' => (string)($content['author'] ?? $t['author'] ?? ''),
+ 'uid' => intval($t['uid'] ?? 0),
+ 'status' => $status,
+ 'status_text' => $status ? dr_lang('%s瀹′腑', $status) : dr_lang('琚嫆缁'),
+ 'inputtime' => $t['inputtime'] ?? '',
+ 'updatetime' => $t['updatetime'] ?? ($t['inputtime'] ?? ''),
+ 'isnew' => intval($t['isnew'] ?? 0),
+ 'can_edit' => 1,
+ 'can_del' => 1,
+ ];
+ } else { // draft
+ $cid = intval($t['cid'] ?? 0);
+ $rows[] = [
+ 'id' => intval($t['id']),
+ 'did' => intval($t['id']),
+ 'cid' => $cid,
+ 'title' => (string)($content['title'] ?? $t['title'] ?? ''),
+ 'catid' => $catid,
+ 'catname' => $catname,
+ 'author' => (string)($content['author'] ?? ''),
+ 'uid' => intval($t['uid'] ?? 0),
+ 'inputtime' => $t['inputtime'] ?? '',
+ 'updatetime' => $t['inputtime'] ?? '',
+ 'can_edit' => 1,
+ 'can_del' => 1,
+ ];
+ }
+ }
+ }
+
+ $page = is_array($param) ? intval($param['page'] ?? 1) : intval(\Phpcmf\Service::L('input')->get('page'));
+ !$page && $page = 1;
+ $pagesize = intval(\Phpcmf\Service::V()->get_value('mytable_pagesize'));
+ if (!$pagesize) {
+ $pagesize = intval($this->member_cache['config']['pagesize_api'] ?? 0);
+ }
+ !$pagesize && $pagesize = 10;
+
+ $this->_json(1, 'ok', [
+ 'mid' => (string)($this->module['dirname'] ?? APP_DIR),
+ 'module_name' => (string)($this->module['name'] ?? $this->module['cname'] ?? ''),
+ 'list_type' => $list_type,
+ 'list' => $rows,
+ 'total' => $total,
+ 'page' => $page,
+ 'pagesize' => $pagesize,
+ 'param' => is_array($param) ? [
+ 'field' => (string)($param['field'] ?? ''),
+ 'keyword' => (string)($param['keyword'] ?? ''),
+ 'catid' => intval($param['catid'] ?? 0),
+ ] : [],
+ ]);
+ }
+
+ /**
+ * 瀹㈡埛绔唴瀹瑰彂甯/缂栬緫琛ㄥ崟锛圛S_API_HTTP GET锛
+ * 瀛楁灏介噺缁 member_api 鐨 dr_member_api_format_client_fields 闄勫姞涓婁紶/缂栬緫鍣ㄥ弬鏁
+ * @param array $fill 鑽夌ǹ绛夊唴瀹瑰~鍏呭硷紙add&did= 鏃跺繀浼狅紝鍚﹀垯鏃 client_value锛
+ */
+ protected function _api_json_member_content_form($id, $catid, $category = [], $fill = []) {
+
+ $id = intval($id);
+ $catid = intval($catid);
+ $did = intval(\Phpcmf\Service::L('input')->get('did'));
+
+ $mydata = $id ? $this->_Data($id) : [];
+ if (!is_array($mydata)) {
+ $mydata = [];
+ }
+ // 鑽夌ǹ / 棰濆濉厖锛氳鐩栧埌瀛楁鍊硷紙鑽夌ǹ缂栬緫 id=0锛屽繀椤婚潬 fill 鍥炲~ client_value锛
+ if (is_array($fill) && $fill) {
+ if (!$id) {
+ $mydata = $fill;
+ } else {
+ $mydata = array_merge($mydata, $fill);
+ }
+ } elseif (!$id && $did) {
+ $draft = $this->content_model->get_draft($did);
+ if (is_array($draft) && $draft) {
+ $mydata = $draft;
+ }
+ }
+ if ($catid) {
+ $mydata['catid'] = $catid;
+ } elseif (!empty($mydata['catid'])) {
+ $catid = intval($mydata['catid']);
+ }
+
+ list($my_field, $sys_field, $diy_field, $cat_field) = $this->_field_group($mydata);
+ $field = [];
+ foreach ([$my_field, $sys_field, $diy_field, $cat_field] as $group) {
+ if (!is_array($group)) {
+ continue;
+ }
+ foreach ($group as $name => $t) {
+ if (is_array($t)) {
+ $field[$name] = $t;
+ }
+ }
+ }
+ if (function_exists('dr_array_sort')) {
+ $field = dr_array_sort($field, 'displayorder', 'asc');
+ }
+
+ $filtered = [];
+ $member = is_array($this->member) ? $this->member : [];
+ $groupids = isset($member['groupid']) ? $member['groupid'] : [];
+ foreach ($field as $name => $t) {
+ if (!is_array($t)) {
+ continue;
+ }
+ // 瀵归綈 Field::toform 浼氬憳渚у彲瑙佽鍒
+ if (empty($t['ismember'])) {
+ continue;
+ }
+ if (!empty($t['setting']['show_member']) && $groupids
+ && function_exists('dr_array_intersect')
+ && dr_array_intersect($groupids, $t['setting']['show_member'])) {
+ continue;
+ }
+ $ftype = (string)($t['fieldtype'] ?? '');
+ if (in_array($ftype, ['Group', 'Merge', 'Diy', 'Related', 'Catids'], true)) {
+ continue;
+ }
+ $fname = (string)($t['fieldname'] ?? $name);
+ $filtered[$fname] = $t;
+ }
+
+ if (function_exists('dr_member_api_format_client_fields')) {
+ $client_field = dr_member_api_format_client_fields($filtered, $mydata, [
+ 'check_allow' => false,
+ 'check_support' => true,
+ ]);
+ } else {
+ $client_field = $filtered;
+ }
+
+ $cats = [];
+ if (!$this->is_hcategory && is_array($category)) {
+ foreach ($category as $cid => $c) {
+ if (!is_array($c) || !empty($c['child'])) {
+ continue;
+ }
+ if (isset($c['tid']) && (int)$c['tid'] != 1) {
+ continue;
+ }
+ $cats[] = [
+ 'id' => intval(isset($c['id']) ? $c['id'] : $cid),
+ 'name' => (string)($c['name'] ?? ''),
+ 'pid' => intval($c['pid'] ?? 0),
+ ];
+ }
+ }
+
+ $is_post_code = $this->is_hcategory
+ ? ($this->content_model->_hcategory_member_post_code() ? 1 : 0)
+ : ($this->is_post_code ? 1 : 0);
+
+ $this->_json(1, 'ok', [
+ 'mid' => (string)($this->module['dirname'] ?? APP_DIR),
+ 'module_name' => (string)($this->module['name'] ?? $this->module['cname'] ?? ''),
+ 'id' => $id,
+ 'did' => $did,
+ 'is_edit' => $id ? 1 : 0,
+ 'is_draft' => $did ? 1 : 0,
+ 'catid' => $catid,
+ 'category' => $cats,
+ 'field' => $client_field,
+ 'is_post_code' => $is_post_code,
+ 'need_catid' => $this->is_hcategory ? 0 : 1,
+ ]);
+ }
+
+ /**
+ * 鍥炶皟澶勭悊缁撴灉
+ * $data
+ * */
+ protected function _Call_Post($data) {
+
+ if ($data[1]['status'] == 9) {
+ $list = $html = '';
+ if ($this->module['category'][$data[1]['catid']]['setting']['html']) {
+ // 鐢熸垚鏉冮檺鏂囦欢
+ if (!dr_html_auth(1)) {
+ return dr_return_data(0, dr_lang('/cache/html/ 鏃犳硶鍐欏叆鏂囦欢'));
+ }
+ $list = WEB_DIR.'index.php?s='.$this->module['dirname'].'&c=html&m=categoryfile&id='.$data[1]['catid'];
+ }
+ if ($this->module['category'][$data[1]['catid']]['setting']['chtml']) {
+ // 鐢熸垚鏉冮檺鏂囦欢
+ if (!dr_html_auth(1)) {
+ return dr_return_data(0, dr_lang('/cache/html/ 鏃犳硶鍐欏叆鏂囦欢'));
+ }
+ $html = WEB_DIR.'index.php?s='.$this->module['dirname'].'&c=html&m=showfile&id='.$data[1]['id'];
+ }
+ return dr_return_data(1, dr_lang('鎿嶄綔鎴愬姛'), ['id' => $data[1]['id'], 'catid' => $data[1]['catid'], 'htmlfile' => $html, 'htmllist' => $list]);
+ } else {
+ if (\Phpcmf\Service::L('input')->post('is_draft')) {
+ return dr_return_data(1, dr_lang('鎿嶄綔鎴愬姛锛屽凡瀛樺偍鍒拌崏绋跨'));
+ } else {
+ return dr_return_data(1, dr_lang('鎿嶄綔鎴愬姛锛岀瓑寰呯鐞嗗憳瀹℃牳'), ['id' => $data[1]['id'], 'catid' => (int)$data[1]['catid']]);
+ }
+ }
+ }
+}
diff --git a/dayrui/App/Cms/Fields/Cat.php b/dayrui/App/Cms/Fields/Cat.php
new file mode 100644
index 0000000..ae5f096
--- /dev/null
+++ b/dayrui/App/Cms/Fields/Cat.php
@@ -0,0 +1,128 @@
+fieldtype = ['INT' => 10];
+ $this->defaulttype = 'INT';
+ }
+
+ /**
+ * 瀛楁鐩稿叧灞炴у弬鏁
+ *
+ * @param array $value 鍊
+ * @return string
+ */
+ public function option($option) {
+
+ $_option = '';
+ $_module = \Phpcmf\Service::C()->get_cache('module-'.SITE_ID.'-content');
+ if ($_module) {
+ $_option.= ''.dr_lang('鍏变韩鏍忕洰').' ';
+ foreach ($_module as $dir => $t) {
+ if (!$t['share']) {
+ $_option.= ''.$t['name'].' ';
+ }
+ }
+ }
+
+ return ['', ''];
+ }
+
+
+ /**
+ * 瀛楁杈撳嚭
+ */
+ public function output($value) {
+ return intval($value);
+ }
+
+ /**
+ * 瀛楁鍏ュ簱鍊
+ *
+ * @param array $field 瀛楁淇℃伅
+ * @return void
+ */
+ public function insert_value($field) {
+ \Phpcmf\Service::L('Field')->data[$field['ismain']][$field['fieldname']] = intval(\Phpcmf\Service::L('Field')->post[$field['fieldname']]);
+ }
+
+ /**
+ * 瀛楁琛ㄥ崟杈撳叆
+ *
+ * @param string $field 瀛楁鏁扮粍
+ * @param array $value 鍊
+ * @return string
+ */
+ public function input($field, $value = null) {
+
+ // 瀛楁绂佹淇敼鏃跺氨杩斿洖鏄剧ず瀛楃涓
+ if ($this->_not_edit($field, $value)) {
+ return $this->show($field, $value);
+ }
+
+ // 瀛楁瀛樺偍鍚嶇О
+ $name = $field['fieldname'];
+
+ // 瀛楁鏄剧ず鍚嶇О
+ $text = ($field['setting']['validate']['required'] ? ' * ' : '').dr_lang($field['name']);
+
+ // 瀛楁鎻愮ず淇℃伅
+ $tips = ($name == 'title' && APP_DIR) || $field['setting']['validate']['tips'] ? ''.$field['setting']['validate']['tips'].' ' : '';
+
+ // 寮濮嬭緭鍑
+ $str = '';
+ $str.= ''.\Phpcmf\Service::L('category', 'module')->select(
+ $field['setting']['option']['module'],
+ intval($value),
+ ' name=\'data['.$field['fieldname'].']\' data-actions-box="true" '.(isset($field['setting']['option']['is_search']) && $field['setting']['option']['is_search'] ? ' data-live-search="true" ' : ''),
+ '', (isset($field['setting']['option']['parent']) && $field['setting']['option']['parent'] ? 0 : 1), 0
+ ).' ';
+ $str.= ''.$tips.' ';
+ return $this->input_format($name, $text, $str);
+ }
+
+ /**
+ * 瀛楁琛ㄥ崟鏄剧ず
+ *
+ * @param string $field 瀛楁鏁扮粍
+ * @param array $value 鍊
+ * @return string
+ */
+ public function show($field, $value = null) {
+
+ return $this->input_format($field['fieldname'], $field['name'], ''.dr_catpos($value, ' - ', false, '', $field['setting']['option']['module']).'
');
+ }
+
+}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Fields/Catids.php b/dayrui/App/Cms/Fields/Catids.php
new file mode 100644
index 0000000..11c10a1
--- /dev/null
+++ b/dayrui/App/Cms/Fields/Catids.php
@@ -0,0 +1,136 @@
+fieldtype = ['TEXT' => ''];
+ $this->defaulttype = 'TEXT';
+ }
+
+ /**
+ * 瀛楁鐩稿叧灞炴у弬鏁
+ *
+ * @param array $value 鍊
+ * @return string
+ */
+ public function option($option) {
+
+
+ return ['
+
+ ', ''];
+ }
+
+
+ /**
+ * 瀛楁杈撳嚭
+ */
+ public function output($value) {
+ return dr_string2array($value);
+ }
+
+ /**
+ * 瀛楁鍏ュ簱鍊
+ *
+ * @param array $field 瀛楁淇℃伅
+ * @return void
+ */
+ public function insert_value($field) {
+ $save = [];
+ $data = \Phpcmf\Service::L('Field')->post[$field['fieldname']];
+ if ($data) {
+ $data = dr_string2array($data);
+ if (!IS_ADMIN) {
+ // 楠岃瘉鍙戝竷鏉冮檺
+ $category = \Phpcmf\Service::C()->_get_module_member_category(\Phpcmf\Service::C()->module, 'add');
+ if (!$category) {
+ \Phpcmf\Service::C()->_json(1, dr_lang('妯″潡[%s]娌℃湁鍙敤鏍忕洰鏉冮檺', \Phpcmf\Service::C()->module['dirname']));
+ }
+ foreach ($data as $t) {
+ if ($t) {
+ $save[] = $t;
+ if (!$category[$t]) {
+ \Phpcmf\Service::C()->_json(1, dr_lang('妯″潡[%s]娌℃湁鏍忕洰(%s)鏉冮檺', \Phpcmf\Service::C()->module['dirname'], $t));
+ }
+ }
+ }
+ } else {
+ foreach ($data as $t) {
+ if ($t) {
+ $save[] = $t;
+ }
+ }
+ }
+ $save = array_unique($save);
+ }
+ \Phpcmf\Service::L('Field')->data[$field['ismain']][$field['fieldname']] = dr_array2string($save);
+ }
+
+ /**
+ * 瀛楁琛ㄥ崟杈撳叆
+ *
+ * @param string $field 瀛楁鏁扮粍
+ * @param array $value 鍊
+ * @return string
+ */
+ public function input($field, $value = null) {
+
+ // 瀛楁绂佹淇敼鏃跺氨杩斿洖鏄剧ず瀛楃涓
+ if ($this->_not_edit($field, $value)) {
+ return $this->show($field, $value);
+ }
+
+ // 瀛楁瀛樺偍鍚嶇О
+ $name = $field['fieldname'];
+
+ // 瀛楁鏄剧ず鍚嶇О
+ $text = ($field['setting']['validate']['required'] ? ' * ' : '').dr_lang($field['name']);
+
+ // 瀛楁鎻愮ず淇℃伅
+ $tips = ($name == 'title' && APP_DIR) || $field['setting']['validate']['tips'] ? ''.$field['setting']['validate']['tips'].' ' : '';
+
+ // 寮濮嬭緭鍑
+ $str = '';
+ $str.= ''.\Phpcmf\Service::L('category', 'module')->select(
+ \Phpcmf\Service::C()->module['dirname'],
+ dr_string2array($value),
+ ' name=\'data['.$field['fieldname'].'][]\' multiple="multiple" data-actions-box="true"',
+ '', 1, 1
+ ).' ';
+ $str.= ''.$tips.' ';
+ return $this->input_format($name, $text, $str);
+ }
+
+ /**
+ * 瀛楁琛ㄥ崟鏄剧ず
+ *
+ * @param string $field 瀛楁鏁扮粍
+ * @param array $value 鍊
+ * @return string
+ */
+ public function show($field, $value = null) {
+
+
+ return $this->input_format($field['fieldname'], $field['name'], ''.dr_linkagepos($field['setting']['option']['linkage'], $value, ' - ').'
');
+ }
+
+}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Fields/Cats.php b/dayrui/App/Cms/Fields/Cats.php
new file mode 100644
index 0000000..ac84a81
--- /dev/null
+++ b/dayrui/App/Cms/Fields/Cats.php
@@ -0,0 +1,96 @@
+fieldtype = ['TEXT' => ''];
+ $this->defaulttype = 'TEXT';
+ }
+
+ /**
+ * 瀛楁杈撳嚭
+ */
+ public function output($value) {
+ return dr_string2array($value);
+ }
+
+ /**
+ * 瀛楁鍏ュ簱鍊
+ *
+ * @param array $field 瀛楁淇℃伅
+ * @return void
+ */
+ public function insert_value($field) {
+ $value = \Phpcmf\Service::L('Field')->post[$field['fieldname']];
+ if (is_array($value)) {
+ $value = dr_array2string($value);
+ }
+ \Phpcmf\Service::L('Field')->data[$field['ismain']][$field['fieldname']] = $value;
+ }
+
+ /**
+ * 瀛楁琛ㄥ崟杈撳叆
+ *
+ * @param string $field 瀛楁鏁扮粍
+ * @param array $value 鍊
+ * @return string
+ */
+ public function input($field, $value = null) {
+
+ // 瀛楁绂佹淇敼鏃跺氨杩斿洖鏄剧ず瀛楃涓
+ if ($this->_not_edit($field, $value)) {
+ return $this->show($field, $value);
+ }
+
+ // 瀛楁瀛樺偍鍚嶇О
+ $name = $field['fieldname'];
+
+ // 瀛楁鏄剧ず鍚嶇О
+ $text = ($field['setting']['validate']['required'] ? ' * ' : '').dr_lang($field['name']);
+
+ // 瀛楁鎻愮ず淇℃伅
+ $tips = ($name == 'title' && APP_DIR) || $field['setting']['validate']['tips'] ? ''.$field['setting']['validate']['tips'].' ' : '';
+
+ // 寮濮嬭緭鍑
+ $str = '';
+ $str.= ''.\Phpcmf\Service::L('category', 'module')->select(
+ $field['setting']['option']['module'],
+ dr_string2array($value),
+ ' name=\'data['.$field['fieldname'].'][]\' multiple="multiple" data-actions-box="true" '.(isset($field['setting']['option']['is_search']) && $field['setting']['option']['is_search'] ? ' data-live-search="true" ' : ''),
+ '', (isset($field['setting']['option']['parent']) && $field['setting']['option']['parent'] ? 0 : 1), 0
+ ).' ';
+ $str.= \Phpcmf\Service::L('Field')->get('select')->get_select_search_code().''.$tips.' ';
+ return $this->input_format($name, $text, $str);
+ }
+
+ /**
+ * 瀛楁琛ㄥ崟鏄剧ず
+ *
+ * @param string $field 瀛楁鏁扮粍
+ * @param array $value 鍊
+ * @return string
+ */
+ public function show($field, $value = null) {
+
+ $html = '';
+ $value = dr_string2array($value);
+ if ($value) {
+ foreach ($value as $t) {
+ $html.= ''.dr_catpos($t, ' - ', false, '', $field['setting']['option']['module']).' ';
+ }
+ }
+
+ return $this->input_format($field['fieldname'], $field['name'], ''.$html.'
');
+ }
+
+}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Fields/Field.php b/dayrui/App/Cms/Fields/Field.php
new file mode 100644
index 0000000..36f7e0c
--- /dev/null
+++ b/dayrui/App/Cms/Fields/Field.php
@@ -0,0 +1,32 @@
+ 'Redirect',
+ 'name' => '杞悜閾炬帴',
+ 'used' => ['module'],
+ ],
+
+ [
+ 'id' => 'Catids',
+ 'name' => '鍓爮鐩',
+ 'used' => ['module'],
+ ],
+
+ [
+ 'id' => 'Cat',
+ 'name' => '妯″潡鏍忕洰锛堝崟閫夛級',
+ ],
+
+ [
+ 'id' => 'Cats',
+ 'name' => '妯″潡鏍忕洰锛堝閫夛級',
+ ],
+
+ [
+ 'id' => 'Related',
+ 'name' => '鍐呭鍏宠仈',
+ ],
+
+];
\ No newline at end of file
diff --git a/dayrui/App/Cms/Fields/Redirect.php b/dayrui/App/Cms/Fields/Redirect.php
new file mode 100644
index 0000000..b3e3107
--- /dev/null
+++ b/dayrui/App/Cms/Fields/Redirect.php
@@ -0,0 +1,112 @@
+fieldtype = TRUE;
+ $this->defaulttype = 'TEXT';
+ }
+
+ /**
+ * 瀛楁鐩稿叧灞炴у弬鏁
+ *
+ * @param array $value 鍊
+ * @return string
+ */
+ public function option($option) {
+ $option['width'] = isset($option['width']) ? $option['width'] : 400;
+ return ['', '
+
+ '];
+ }
+
+ /**
+ * 瀛楁鍏ュ簱鍊
+ *
+ * @param array $field 瀛楁淇℃伅
+ * @return void
+ */
+ public function insert_value($field) {
+
+ $value = \Phpcmf\Service::L('Field')->post[$field['fieldname']];
+ $value && $value = stripos($value, 'https://') === 0 || stripos($value, 'http://') === 0 ? $value : 'http://'.$value;
+ \Phpcmf\Service::L('Field')->data[$field['ismain']][$field['fieldname']] = $value;
+ }
+
+ /**
+ * 瀛楁琛ㄥ崟杈撳叆
+ *
+ * @param string $field 瀛楁鏁扮粍
+ * @param array $value 鍊
+ * @return string
+ */
+ public function input($field, $value = null) {
+
+ // 瀛楁绂佹淇敼鏃跺氨杩斿洖鏄剧ず瀛楃涓
+ if ($this->_not_edit($field, $value)) {
+ return $this->show($field, $value);
+ }
+
+ // 瀛楁瀛樺偍鍚嶇О
+ $name = $field['fieldname'];
+
+ // 瀛楁鏄剧ず鍚嶇О
+ $text = ($field['setting']['validate']['required'] ? ' * ' : '').dr_lang($field['name']);
+
+ // 琛ㄥ崟瀹藉害璁剧疆
+ $width = \Phpcmf\Service::IS_MOBILE_USER() ? '100%' : ($field['setting']['option']['width'] ? $field['setting']['option']['width'] : 200);
+
+ // 椋庢牸
+ $style = 'style="width:'.$width.(is_numeric($width) ? 'px' : '').';"';
+
+ // 琛ㄥ崟闄勫姞鍙傛暟
+ $attr = $field['setting']['validate']['formattr'];
+
+ // 瀛楁鎻愮ず淇℃伅
+ $tips = isset($field['setting']['validate']['tips']) && $field['setting']['validate']['tips'] ? ''.$field['setting']['validate']['tips'].' ' : '';
+
+ // 瀛楁榛樿鍊
+ $value = $value && strlen($value) ? $value : $this->get_default_value($field['setting']['option']['value']);
+
+ // 褰撳瓧娈靛繀濉椂锛屽姞鍏tml5楠岃瘉鏍囩
+ isset($field['setting']['validate']['required']) && $field['setting']['validate']['required'] == 1 && $attr.= ' required="required"';
+
+ $str = ' '.$tips;
+ return $this->input_format($name, $text, $str);
+ }
+
+ /**
+ * 瀛楁琛ㄥ崟鏄剧ず
+ *
+ * @param string $field 瀛楁鏁扮粍
+ * @param array $value 鍊
+ * @return string
+ */
+ public function show($field, $value = null) {
+
+
+ return $this->input_format($field['fieldname'], $field['name'], '');
+ }
+
+}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Fields/Related.php b/dayrui/App/Cms/Fields/Related.php
new file mode 100644
index 0000000..ef7b832
--- /dev/null
+++ b/dayrui/App/Cms/Fields/Related.php
@@ -0,0 +1,310 @@
+fieldtype = ['TEXT' => '']; // TRUE琛ㄥ叏閮ㄥ彲鐢ㄥ瓧娈电被鍨,鑷畾涔夋牸寮忎负 array('鍙敤瀛楁绫诲瀷鍚嶇О' => '榛樿闀垮害', ... )
+ $this->defaulttype = 'TEXT'; // 褰撶敤鎴锋病鏈夐夋嫨瀛楁绫诲瀷鏃剁殑缂虹渷鍊
+ }
+
+ /**
+ * 瀛楁鐩稿叧灞炴у弬鏁
+ *
+ * @param array $value 鍊
+ * @return string
+ */
+ public function option($option) {
+
+ $_option = '';
+ $_module = \Phpcmf\Service::C()->get_cache('module-'.SITE_ID.'-content');
+ if ($_module) {
+ foreach ($_module as $dir => $t) {
+ $_option.= ''.$t['name'].' ';
+ }
+ }
+
+ return [$this->_search_field().'
+
+
+
+ '];
+ }
+
+ /**
+ * 瀛楁杈撳嚭
+ */
+ public function output($value) {
+ return $value;
+ }
+
+ /**
+ * 瀛楁鍏ュ簱鍊
+ */
+ public function insert_value($field) {
+
+ $data = \Phpcmf\Service::L('Field')->post[$field['fieldname']];
+ $limit = intval($field['setting']['option']['limit']);
+ if ($limit && $data && count($data) > $limit) {
+ // 瓒呴檺浜
+ $value = implode(',', dr_arraycut($data, $limit));
+ } else {
+ $value = !$data ? '' : implode(',', $data);
+ }
+
+ \Phpcmf\Service::L('Field')->data[$field['ismain']][$field['fieldname']] = $value;
+ }
+
+ /**
+ * 瀛楁琛ㄥ崟杈撳叆
+ *
+ * @param string $cname 瀛楁鍒悕
+ * @param string $name 瀛楁鍚嶇О
+ * @param array $cfg 瀛楁閰嶇疆
+ * @param string $value 鍊
+ * @return string
+ */
+ public function input($field, $value = '') {
+
+ // 瀛楁绂佹淇敼鏃跺氨杩斿洖鏄剧ず瀛楃涓
+ if ($this->_not_edit($field, $value)) {
+ return $this->show($field, $value);
+ }
+
+ if (!IS_USE_MODULE) {
+ return '浣跨敤鏈瓧娈电被鍒渶瑕佸畨瑁呫愬缓绔欑郴缁熴戞彃浠';
+ }
+
+ $is_show = 0;
+
+ // 瀛楁瀛樺偍鍚嶇О
+ $name = $field['fieldname'];
+ // 瀛楁鎻愮ず淇℃伅
+ $tips = isset($field['setting']['validate']['tips']) && $field['setting']['validate']['tips'] ? ''.$field['setting']['validate']['tips'].' ' : '';
+ // 鍖哄煙澶у皬
+ $area = \Phpcmf\Service::IS_MOBILE_USER() ? '["95%", "90%"]' : '["50%", "65%"]';
+ // 妯″潡鍚嶇О
+ $module = $mid = isset($field['setting']['option']['module']) ? $field['setting']['option']['module'] : '';
+ // 瀛楁鏄剧ず鍚嶇О
+ $text = ($field['setting']['validate']['required'] ? ' * ' : '').dr_lang($field['name']);
+ // 閫夋嫨鏁伴噺闄愬埗
+ $limit = intval($field['setting']['option']['limit']);
+ !$limit && $limit = 99999;
+ // 杈撳嚭淇℃伅
+ $cname = ($field['setting']['option']['title'] ? $field['setting']['option']['title'] : dr_lang('涓婚'));
+
+ if (!$module) {
+ if (CI_DEBUG) {
+ return $this->input_format($name, $text, '鍏宠仈瀛楁娌℃湁璁剧疆鍏宠仈妯″潡
');
+ }
+ return $this->input_format($name, $text, '');
+ } elseif (!dr_is_module($module)) {
+ if (CI_DEBUG) {
+ return $this->input_format($name, $text, '鍏宠仈瀛楁璁剧疆鐨勬ā鍧椼'.$module.'銆戞病鏈夎瀹夎
');
+ }
+ return $this->input_format($name, $text, '');
+ }
+
+ $value = $value ? trim($value, ',') : '';
+ $mylist = [];
+ if ($value && is_string($value)) {
+ $arr = explode(',', $value);
+ if ($arr) {
+ $value = '';
+ foreach ($arr as $a) {
+ $a = intval($a);
+ if ($a) {
+ $value.= ','.$a;
+ }
+ }
+ if ($value) {
+ $value = trim($value, ',');
+ $db = \Phpcmf\Service::M()->db->query('select id,title,catid,updatetime,uid,url from '.\Phpcmf\Service::M()->dbprefix(dr_module_table_prefix($module)).' where id IN ('.$value.') order by FIELD(id, '.$value.')');
+ $mylist = $db ? $db->getResultArray() : [];
+ }
+ }
+ }
+
+ $tpl = is_file(MYPATH.'View/api_related_field_'.$field['fieldname'].'.html') ? MYPATH.'View/api_related_field_'.$field['fieldname'].'.html' : COREPATH.'View/api_related_field.html';
+ if (!is_file($tpl)) {
+ if (CI_DEBUG) {
+ return $this->input_format($name, $text, '妯℃澘鏂囦欢銆'.$tpl.'銆戜笉瀛樺湪
');
+ }
+ return $this->input_format($name, $text, '');
+ }
+ $code = file_get_contents($tpl);
+ if (!$code) {
+ if (CI_DEBUG) {
+ return $this->input_format($name, $text, '妯℃澘鏂囦欢銆'.$tpl.'銆戝唴瀹逛负绌
');
+ }
+ return $this->input_format($name, $text, '');
+ }
+ $file = \Phpcmf\Service::V()->code2php($code);
+ ob_start();
+ require $file;
+ $str = ob_get_clean();
+
+ $str.= $tips;
+ $js = \Phpcmf\Service::L('js_packer');
+ $str.= $js->pack('
+ ', 0);
+
+ return $this->input_format($name, $text, $str);
+ }
+
+ /**
+ * 瀛楁琛ㄥ崟鏄剧ず
+ *
+ * @param string $field 瀛楁鏁扮粍
+ * @param array $value 鍊
+ * @return string
+ */
+ public function show($field, $value = null) {
+
+
+ $cname = ($field['setting']['option']['title'] ? $field['setting']['option']['title'] : dr_lang('涓婚'));
+ $value = @trim($value, ',');
+ $mylist = [];
+ $is_show = 1;
+ $module = $mid = isset($field['setting']['option']['module']) ? $field['setting']['option']['module'] : '';
+ if ($value && is_string($value) && $module) {
+ $arr = explode(',', $value);
+ if ($arr) {
+ $value = '';
+ foreach ($arr as $a) {
+ $a = intval($a);
+ if ($a) {
+ $value.= ','.$a;
+ }
+ }
+ if ($value) {
+ $value = trim($value, ',');
+ $db = \Phpcmf\Service::M()->db->query('select id,title,catid,updatetime,uid,url from '.\Phpcmf\Service::M()->dbprefix(dr_module_table_prefix($module)).' where id IN ('.$value.') order by FIELD(id, '.$value.')');
+ $mylist = $db ? $db->getResultArray() : [];
+ }
+ }
+ }
+
+ $tpl = $field['fieldname'];
+ $file = \Phpcmf\Service::V()->code2php(
+ file_get_contents(is_file(MYPATH.'View/api_related_field_'.$tpl.'.html') ? MYPATH.'View/api_related_field_'.$tpl.'.html' : COREPATH.'View/api_related_field.html')
+ );
+ ob_start();
+ require $file;
+ $str = ob_get_clean();
+
+ return $this->input_format($field['fieldname'], $field['name'], $str);
+ }
+}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Libraries/Category.php b/dayrui/App/Cms/Libraries/Category.php
new file mode 100644
index 0000000..a208833
--- /dev/null
+++ b/dayrui/App/Cms/Libraries/Category.php
@@ -0,0 +1,90 @@
+ismain = $v;
+ return $this;
+ }
+
+ public function site($v) {
+ $this->siteid = $v;
+ return $this;
+ }
+
+ public function select($mid, $id = '', $str = '', $default = ' -- ', $onlysub = 0, $is_push = 0, $is_first = 0) {
+ $siteid = $this->siteid ? $this->siteid : SITE_ID;
+ $select = \Phpcmf\Service::L('Tree')->ismain($this->ismain)->select_category($this->get_category($mid, $siteid), $id, $str, $default, $onlysub, $is_push, $is_first);
+ $this->siteid = 0;
+ return $select;
+ }
+
+ // 鑾峰彇鍏ㄩ儴鏍忕洰
+ public function get_category($mid, $siteid = SITE_ID) {
+ return \Phpcmf\Service::C()->get_cache('module-'.$siteid.'-'.$mid, 'category');
+ }
+
+ // 鑾峰彇鏍忕洰鑷畾涔夊瓧娈
+ public function get_category_field($cdir) {
+
+ $category_field = [];
+
+ $field = $this->db->table('field')
+ ->where('disabled', 0)
+ ->where('relatedname', 'category-'.$cdir)
+ ->orderBy('displayorder ASC, id ASC')->get()->getResultArray();
+ if ($field) {
+ foreach ($field as $f) {
+ $f['setting'] = dr_string2array($f['setting']);
+ $category_field[$f['fieldname']] = $f;
+ }
+ }
+
+ return $category_field;
+ }
+
+ // 鑾峰彇涓嬬骇瀛愭爮鐩
+ public function get_child($mid, $catid, $siteid = SITE_ID) {
+
+ $cats = \Phpcmf\Service::C()->get_cache('module-'.$siteid.'-'.$mid, 'category');
+ if (!$cats) {
+ return [];
+ }
+
+ $rt = [];
+ foreach ($cats as $c) {
+ if ($c['pid'] == $catid) {
+ $rt[] = $c['id'];
+ }
+ }
+
+ return $rt;
+ }
+
+ // 閫氳繃鐩綍鎵緄d
+ public function get_catid($mid, $dir, $siteid = SITE_ID) {
+
+ $cats = \Phpcmf\Service::C()->get_cache('module-'.$siteid.'-'.$mid, 'category_dir');
+ if (!$cats) {
+ return [];
+ }
+
+ return isset($cats[$dir]) ? $cats[$dir] : 0;
+ }
+
+ // 鏌ヨ鎵灞炰富鏍忕洰
+ public function get_ismain_id($mid, $cat) {
+
+ return $cat['id'];
+ }
+
+}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Libraries/Tree.php b/dayrui/App/Cms/Libraries/Tree.php
new file mode 100644
index 0000000..27dbc65
--- /dev/null
+++ b/dayrui/App/Cms/Libraries/Tree.php
@@ -0,0 +1,466 @@
+icon();
+ }
+
+ // 閲婃斁鍙橀噺
+ public function __destruct()
+ {
+ unset($this->data);
+ unset($this->cache);
+ unset($this->ret);
+ unset($this->icon);
+ unset($this->result_array);
+ unset($this->nbsp_str);
+ unset($this->nbsp);
+ unset($this->result);
+ }
+
+ /**
+ * 璁剧疆html鏍囩
+ */
+ public function html_icon() {
+ $this->nbsp_str = ' ';
+ $this->icon = [
+ $this->nbsp_str,
+ '鈹 ',
+ '鈹 '
+ ];
+ return $this;
+ }
+
+ /**
+ * 璁剧疆鏅氭爣绛
+ */
+ public function icon() {
+ $this->nbsp_str = ' ';
+ $this->icon = [
+ $this->nbsp_str,
+ '鈹 ',
+ '鈹 '
+ ];
+ return $this;
+ }
+
+ /**
+ * 鍒濆鍖栫被
+ */
+ public function init($arr) {
+ $this->ret = '';
+ $this->data = $arr;
+ $this->result = [];
+ return $this;
+ }
+
+ // 鍒涘缓鏁版嵁
+ public function get($data) {
+ $this->data = $data;
+ $this->result = [];
+ $this->create(0);
+ return $this->result_array;
+ }
+
+ // 璁剧疆鏁版嵁
+ protected function _data($data) {
+ $this->ret = '';
+ $this->data = $data;
+ $this->deep = 1;
+ return $this;
+ }
+
+ // 璁剧疆缂撳瓨
+ public function cache($is) {
+ $this->cache = $is;
+ return $this;
+ }
+
+ /**
+ * 寰楀埌瀛愮骇鏁扮粍
+ * @param int
+ * @return array
+ */
+ protected function get_child($k_id) {
+
+ $arrays = [];
+
+ if ($this->mid) {
+ $child = \Phpcmf\Service::L('category', 'module')->get_child($this->mid, $k_id);
+ if ($child) {
+ foreach ($child as $id) {
+ $this->data[$id] && $arrays[$id] = $this->data[$id];
+ }
+ return $arrays;
+ }
+ }
+
+ if (is_array($this->data)) {
+ foreach($this->data as $id => $a) {
+ if ($a['pid'] == $k_id) {
+ $arrays[$id] = $a;
+ }
+ }
+ }
+
+ $this->deep++;
+
+ return $arrays;
+ }
+
+ /**
+ * 寰楀埌鏍戝瀷鏁扮粍
+ */
+ public function create($k_id = 0, $adds = '') {
+
+ if ($this->deep > 5000) {
+ return; // 闃叉姝诲惊鐜
+ }
+
+ $child = $this->get_child($k_id); // 鑾峰彇瀛愭暟鎹
+ $number = 1;
+
+ if (is_array($child)) {
+ $total = dr_count($child);
+ foreach($child as $id => $a) {
+ $k = $adds ? $this->nbsp : '';
+ $j = $number == $total ? $this->icon[2] : $this->icon[1];
+ $a['spacer'] = $this->_get_spacer($adds ? $adds.$j : '');
+ $this->result_array[] = $a;
+ $this->create($a['id'], $adds.$k.$this->nbsp);
+ $number++;
+ }
+ }
+
+ $this->deep = 1;
+ }
+
+ // 鏇挎崲绌烘牸濉厖绗﹀彿
+ protected function _get_spacer($str) {
+ $num = substr_count($str, $this->nbsp) * 2;
+ if ($num) {
+ $str = str_replace($this->nbsp, '', $str);
+ for ($i = 0; $i < $num; $i ++) {
+ $str = $this->nbsp_str.$str;
+ }
+
+ }
+ return $str;
+ }
+
+ // 鏇挎崲閫楀彿
+ protected function _have($list, $item){
+ return(strpos(',,'.$list.',', ','.$item.','));
+ }
+
+ public function ismain($v) {
+ $this->ismain = $v;
+ return $this;
+ }
+
+ public function mid($v) {
+ $this->mid = $v;
+ return $this;
+ }
+
+
+ /**
+ * 鏍忕洰閫夋嫨
+ *
+ * @param array $data 鏍忕洰鏁版嵁
+ * @param intval/array $id 琚変腑鐨処D
+ * @param string $str 灞炴
+ * @param string $default 榛樿閫夐」
+ * @param intval $onlysub 鍙彲閫夋嫨瀛愭爮鐩
+ * @param intval $is_push 鏄惁楠岃瘉鏉冮檺
+ * @param intval $is_first 鏄惁杩斿洖绗竴涓彲鐢ㄦ爮鐩甶d
+ * @return string
+ */
+ public function select_category($data, $id = '', $str = '', $default = ' -- ', $onlysub = 0, $is_push = 0, $is_first = 0) {
+
+ if (dr_count($data) > 30) {
+ $string = ''.PHP_EOL;
+ } else {
+ $string = ''.PHP_EOL;
+ }
+
+ $default && $string.= "$default ".PHP_EOL;
+
+ $tree = [];
+ $first = 0; // 绗竴涓彲鐢ㄦ爮鐩
+ if (is_array($data)) {
+ foreach($data as $t) {
+ // 鍙樉绀轰富鏍忕洰
+ if ($this->ismain && !$t['ismain']) {
+ continue;
+ }
+ // 鐢ㄤ簬鍙戝竷鍐呭鏃躲愬崟椤靛拰澶栭摼銆戜笖涓烘渶缁堟爮鐩椂锛屼笉鏄剧ず
+ if ($is_push && in_array($t['tid'], [2, 0]) && !$t['child']) {
+ continue;
+ }
+ // 楠岃瘉鏉冮檺
+ if (IS_ADMIN && dr_is_app('cqx') && \Phpcmf\Service::M('content', 'cqx')->is_edit($t['id'])) {
+ continue;
+ }
+
+ // 鏍忕洰鍙戝竷鏉冮檺鍒ゆ柇,涓昏绛涢夋爮鐩笅鏄惁鏈夌┖鐧介夐」
+ if ($is_push && $t['child'] == 1 && $t['catids']) {
+ if ($t['is_post']) {
+ $ispost = 1; // 鍏佽鍙戝竷鐨勭埗鏍忕洰
+ } else {
+ $ispost = 0;
+ foreach ($t['catids'] as $i) {
+ // 褰撴鏍忕洰杩樺瓨鍦ㄤ笅绾ф爮鐩椂,閫愭鍒ゆ柇鍏ㄩ儴涓嬬骇鏍忕洰鏄惁鍏峰鍙戝竷鏉冮檺
+ if (isset($data[$i]) && $data[$i]['child'] == 0) {
+ $ispost = 1; // 鍙互鍙戝竷 琛ㄧず姝ゆ爮鐩彲鐢
+ break;
+ }
+ }
+ }
+ if (!$ispost) {
+ // ispost = 0 琛ㄧず姝ゆ爮鐩病鏈夊彂甯冩潈闄
+ continue;
+ }
+ }
+ // 閫変腑鎿嶄綔
+ $t['selected'] = (is_array($id) ? dr_in_array($t['id'], $id) : $id == $t['id']) ? 'selected' : '';
+ //$t['selected'] = '_selected_'.$t['id'].'_';
+ // 鏄惁鍙夊瓙鏍忕洰
+ if (isset($t['pcatpost']) && $t['pcatpost']) {
+ $t['html_disabled'] = 0;
+ } else {
+ $t['html_disabled'] = $onlysub && $t['child'] ? 1 : 0;
+ }
+ if (isset($t['setting'])) {
+ unset($t['setting']);
+ }
+ $tree[$t['id']] = $t;
+ }
+ }
+
+ $string.= $this->icon()->_data($tree)->_category_tree_result(0, "\$spacer\$name ".PHP_EOL);
+ $string.= ' '.PHP_EOL;
+
+ if ($is_first) {
+ // 绗竴涓瓙鏍忕洰
+ $temp = str_replace("disabled value='", '', $string);
+ $mark = "value='";
+ $first = (int)substr($temp, strpos($temp, $mark) + strlen($mark));
+ }
+
+ $data = $is_first ? [$string, $first] : $string;
+
+ unset($this->ret);
+ unset($this->data);
+
+ $this->ismain = 0;
+ $this->mid = '';
+
+ return $data;
+ }
+
+ /**
+ * 鐢ㄤ簬鏍忕洰閫夋嫨妗
+ *
+ * @param integer $myid 瑕佹煡璇㈢殑ID
+ * @param string $str HTML浠g爜鏂瑰紡
+ * @param integer $sid 榛樿閫変腑
+ * @param integer $adds 鍓嶇紑
+ */
+ protected function _category_tree_result($myid, $str, $str2 = '', $sid = 0, $adds = '') {
+
+ if ($this->deep > 5000) {
+ return $this->ret; // 闃叉姝诲惊鐜
+ }
+
+ $number = 1;
+ $mychild = $this->get_child($myid);
+
+ if (is_array($mychild)) {
+
+ $mytotal = count($mychild);
+ foreach ($mychild as $id => $phpcmf_a) {
+
+ $j = $k = '';
+ if ($number == $mytotal) {
+ $j.= $this->icon[2];
+ } else {
+ $j.= $this->icon[1];
+ $k = $adds ? $this->icon[0] : '';
+ }
+
+ $spacer = $this->_get_spacer($adds ? $adds.$j : '');
+ $selected = $this->_have($sid, $id) ? 'selected' : '';
+ $html_disabled = '';
+ extract($phpcmf_a);
+
+ //$now = $this->get_child($id);
+ // 濡傛灉娌℃湁瀛愭爮鐩笖褰撳墠绂佺敤灏变笉鍐嶆樉绀
+ //if (!$now && $html_disabled) continue;
+
+ if ($html_disabled) {
+ $selected = ' disabled';
+ }
+
+ eval("\$this->ret.= \"$str\";");
+
+ $number++;
+
+ // 濡傛灉鏈変笅绾ц彍鍗曞氨閫掑綊
+ if ($phpcmf_a['child']) {
+ $this->_category_tree_result($id, $str, null, $sid, $adds.$k.$this->nbsp);
+ }
+ }
+ }
+
+ return $this->ret;
+ }
+
+ /**
+ * 寰楀埌鏍戝瀷缁撴瀯
+ *
+ * @param int ID锛岃〃绀鸿幏寰楄繖涓狪D涓嬬殑鎵鏈夊瓙绾
+ * @param string 鐢熸垚鏍戝瀷缁撴瀯鐨勫熀鏈唬鐮侊紝渚嬪锛"\$spacer\$name "
+ * @param int 琚変腑鐨処D锛屾瘮濡傚湪鍋氭爲鍨嬩笅鎷夋鐨勬椂鍊欓渶瑕佺敤鍒
+ * @return string
+ */
+ public function get_tree($myid, $str, $sid = 0, $adds = '', $str_group = '') {
+
+ if ($this->deep > 5000) {
+ return $this->ret; // 闃叉姝诲惊鐜
+ }
+
+ $pid = 0;
+ $nstr = '';
+ $number = 1;
+ $mychild = $this->get_child($myid);
+ //$mychild = $this->data[$myid]['catids'];
+ $mytotal = dr_count($mychild);
+
+ if (is_array($mychild)) {
+ foreach ($mychild as $id => $phpcmf_a) {
+ $j = $k = '';
+ if ($number == $mytotal) {
+ $j.= $this->icon[2];
+ } else {
+ $j.= $this->icon[1];
+ $k = $adds ? $this->nbsp : '';
+ }
+
+ $spacer = $this->_get_spacer($adds ? $adds.$j : '');
+ $selected = $id == $sid ? 'selected' : '';
+ $class = 'dr_catid_'.$phpcmf_a['id'];
+ $childs = isset($phpcmf_a['childids']) ? $phpcmf_a['childids'] : (implode(',', $phpcmf_a['catids']));
+ $parent = defined('SYS_CAT_ZSHOW') && SYS_CAT_ZSHOW ? (!$phpcmf_a['child'] ? '' : '[-] ') : '';
+
+ extract($phpcmf_a);
+
+ $pid == 0 && $str_group ? eval("\$nstr = \"$str_group\";") : eval("\$nstr = \"$str\";");
+ $this->ret.= $nstr;
+ $this->get_tree($id, $str, $sid, $adds.$k.$this->nbsp, $str_group);
+ $number++;
+ }
+ }
+
+ return $this->ret;
+ }
+
+ /**
+ * 寰楀埌鏍戝瀷缁撴瀯
+ *
+ * @param int ID锛岃〃绀鸿幏寰楄繖涓狪D涓嬬殑鎵鏈夊瓙绾
+ * @return array
+ */
+ public function get_tree_array($myid, $str = '', $sid = 0, $adds = '', $str_group = '') {
+
+ if ($this->deep > 5000) {
+ return $this->result; // 闃叉姝诲惊鐜
+ }
+
+ $mychild = $this->get_child($myid);
+ $mytotal = dr_count($mychild);
+ $number = 1;
+
+ if (is_array($mychild)) {
+ foreach ($mychild as $id => $value) {
+ $j = $k = '';
+ if ($number == $mytotal) {
+ $j.= $this->icon[2];
+ } else {
+ $j.= $this->icon[1];
+ $k = $adds ? $this->icon[0] : '';
+ }
+
+ $value['spacer'] = $this->_get_spacer($adds ? $adds.$j : '');
+
+ $this->result[$id] = $value;
+ $this->get_tree_array($id, $str, $sid, $adds.$k.$this->nbsp, $str_group);
+ $number++;
+ }
+ }
+
+ return $this->result;
+ }
+
+ /**
+ * 鍚屼笂涓鏂规硶绫讳技,浣嗗厑璁稿閫
+ */
+ public function get_tree_multi($myid, $str, $sid = 0, $adds = '') {
+
+ if ($this->deep > 5000) {
+ return $this->ret; // 闃叉姝诲惊鐜
+ }
+
+ $nstr = '';
+ $number = 1;
+ $mychild = $this->get_child($myid);
+
+ if (is_array($mychild)) {
+ $mytotal = count($mychild);
+ foreach ($mychild as $id => $phpcmf_a) {
+
+ $j = $k = '';
+ if ($number == $mytotal) {
+ $j.= $this->icon[2];
+ } else {
+ $j.= $this->icon[1];
+ $k = $adds ? $this->icon[0] : '';
+ }
+
+ $spacer = $this->_get_spacer($adds ? $adds.$j : '');
+ $selected = $this->_have($sid, $id) ? 'selected' : '';
+
+ extract($phpcmf_a);
+
+ eval("\$nstr = \"$str\";");
+ $this->ret.= $nstr;
+ $this->get_tree_multi($id, $str, $sid, $adds.$k.$this->nbsp);
+ $number++;
+
+ }
+ }
+
+ return $this->ret;
+ }
+
+}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Models/Category.php b/dayrui/App/Cms/Models/Category.php
new file mode 100644
index 0000000..2253338
--- /dev/null
+++ b/dayrui/App/Cms/Models/Category.php
@@ -0,0 +1,489 @@
+tablename = $data['table'];
+ return $this;
+ }
+
+ // 妫鏌ョ洰褰曟槸鍚﹀彲鐢
+ public function check_dirname($id, $pid, $value) {
+
+ if (!$value) {
+ return dr_return_data(0, dr_lang('鐩綍涓嶈兘涓虹┖'));
+ } elseif (!preg_match('/^[a-z0-9 \_\-]*$/i', $value)) {
+ return dr_return_data(0, dr_lang('鐩綍鏍煎紡涓嶈兘鍖呭惈鐗规畩绗﹀彿鎴栨枃瀛'));
+ } elseif ($this->table($this->tablename)->counts() > MAX_CATEGORY) {
+ return dr_return_data(0, dr_lang('缃戠珯鏍忕洰鏁伴噺宸茶揪鍒颁笂闄'));
+ } elseif (defined('SYS_CAT_RNAME') && SYS_CAT_RNAME) {
+ return dr_return_data(1);
+ } else {
+ if ($pid) {
+ $pcat = $this->table($this->tablename)->get($pid);
+ if ($pcat && $this->table($this->tablename)->where('id<>'.$id)
+ ->where('pdirname', $pcat['dirname'].'/')
+ ->where('dirname', $value)->counts()) {
+ return dr_return_data(0, dr_lang('鐩綍涓嶈兘閲嶅锛堝彲浠ュ湪鏍忕洰灞炴ц缃腑鍏抽棴閲嶅楠岃瘉锛'));
+ }
+ } elseif ($this->table($this->tablename)->where('id<>'.$id)
+ ->where('pdirname=""')->where('dirname', $value)->counts()) {
+ return dr_return_data(0, dr_lang('鐩綍涓嶈兘閲嶅锛堝彲浠ュ湪鏍忕洰灞炴ц缃腑鍏抽棴閲嶅楠岃瘉锛'));
+ }
+ }
+
+ return dr_return_data(1);
+ }
+
+ // 妫鏌ユ爮鐩笂闄
+ public function check_counts($id, $fix = 0) {
+
+ if ($id) {
+ return 0;
+ }
+
+ return 0;
+ }
+
+ /**
+ * 鎵惧嚭瀛愮洰褰曞垪琛
+ *
+ * @param array $data
+ * @return bool
+ */
+ protected function get_categorys($data = array()) {
+
+ if (is_array($data) && !empty($data)) {
+ foreach ($data as $catid => $c) {
+ $result = [];
+ $this->categorys[$catid] = $c;
+ foreach ($this->categorys as $_k => $_v) {
+ if ($_v['pid']) {
+ $result[] = $_v;
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * 鑾峰彇鐖舵爮鐩甀D鍒楄〃
+ *
+ * @param integer $catid 鏍忕洰ID
+ * @param array $pids 鐖剁洰褰旾D
+ * @param integer $n 鏌ユ壘鐨勫眰娆
+ * @return string
+ */
+ protected function get_pids($catid, $pids = '', $n = 1) {
+
+ if ($n > 100 || !is_array($this->categorys)
+ || !isset($this->categorys[$catid])) {
+ return FALSE;
+ }
+
+ $pid = $this->categorys[$catid]['pid'];
+ $pids = $pids ? $pid.','.$pids : $pid;
+ if ($pid) {
+ $pids = $this->get_pids($pid, $pids, ++$n);
+ }
+ // : $this->categorys[$catid]['pids'] = $pids;
+
+ return $pids;
+ }
+
+ /**
+ * 鑾峰彇瀛愭爮鐩甀D鍒楄〃
+ *
+ * @param $catid 鏍忕洰ID
+ * @return string
+ */
+ protected function get_childids($catid, $n = 1) {
+
+ $childids = $catid;
+
+ if ($n > 100 || !is_array($this->categorys) || !isset($this->categorys[$catid])) {
+ return $childids;
+ }
+
+ if (is_array($this->categorys)) {
+ foreach ($this->categorys as $id => $cat) {
+ if ($cat['pid'] && $id != $catid && $cat['pid'] == $catid) {
+ $childids.= ','.$this->get_childids($id, ++$n);
+ }
+ }
+ }
+
+ return $childids;
+ }
+
+ // 鑾峰彇鏍忕洰涓嬬骇ids
+ protected function _get_next_ids($catid) {
+
+ $rt = [];
+
+ if (is_array($this->categorys)) {
+ foreach ($this->categorys as $id => $cat) {
+ if ($cat['pid'] == $catid) {
+ $rt[] = $id;
+ }
+ }
+ }
+
+ return $rt;
+ }
+
+ /**
+ * 鎵鏈夌埗鐩綍
+ *
+ * @param $catid 锟斤拷目ID
+ * @return string
+ */
+ public function get_pdirname($catid) {
+
+ if ($this->categorys[$catid]['pid']==0) {
+ return '';
+ }
+
+ $t = $this->categorys[$catid];
+ $pids = $t['pids'];
+ $pids = explode(',', $pids);
+ $catdirs = [];
+ krsort($pids);
+
+ foreach ($pids as $id) {
+ if ($id == 0) {
+ continue;
+ }
+ $catdirs[] = $this->categorys[$id]['dirname'];
+ if ($this->categorys[$id]['pdirname'] == '') {
+ break;
+ }
+ }
+ krsort($catdirs);
+
+ return implode('/', $catdirs).'/';
+ }
+
+ /**
+ * 鑾峰彇鍏ㄩ儴鐖剁骇鐨刴id鍊, 鎴栬呮洿鏂
+ */
+ public function get_parent_mid($category, $id, $update = 0) {
+
+ if (!isset($category[$id])) {
+ return [];
+ }
+
+ $mid = '';
+ $ids = dr_array2array(explode(',', $category[$id]['childids']), explode(',', $category[$id]['pids']));
+ foreach ($ids as $id) {
+ if ($id && $category[$id] && $category[$id]['mid']) {
+ $mid = $category[$id]['mid'];
+ break;
+ }
+ }
+
+ return [$mid, $ids];
+ }
+
+ /**
+ * 鏍煎紡鍖栫埗绾ф爮鐩ā鍧梞id
+ */
+ public function update_parent_mid($category, $catid) {
+
+ if (!isset($category[$catid])) {
+ return;
+ }
+
+ $ids = explode(',', $category[$catid]['childids']);
+ if (!$ids) {
+ return;
+ }
+
+ $mid = [];
+
+ foreach ($ids as $id) {
+ $id
+ && $category[$id]
+ && $category[$id]['tid'] == 1
+ && $category[$id]['mid']
+ && $mid[] = $category[$id]['mid'];
+ }
+
+ /* 褰撴爮鐩笅闈㈠瓨鍦ㄥ涓ā鍧楁椂
+ $mid && dr_count(array_unique($mid)) > 1 && $this->table($this->tablename)->update((int)$catid, array(
+ 'mid' => '',
+ 'tid' => 0
+ ));*/
+ }
+
+ /**
+ * 鑾峰彇鑿滃崟鏁版嵁
+ */
+ public function cat_data($pid) {
+ return $this->table($this->tablename)->where('pid', $pid)->order_by('displayorder ASC,id ASC')->getAll();
+ }
+
+ /**
+ * 淇鑿滃崟鏁版嵁
+ */
+ public function repair($_data = [], $dirname = '') {
+
+ $this->categorys = $this->categorys_dir = $categorys = [];
+ !$_data && $_data = $this->table($this->tablename)->where('disabled', 0)->order_by('displayorder ASC,id ASC')->getAll();
+ if (!$_data) {
+ return;
+ }
+
+ // 鍏ㄩ儴鏍忕洰鏁版嵁
+ foreach ($_data as $t) {
+ $t['setting'] = dr_string2array($t['setting']);
+ $this->categorys[$t['id']] = $categorys[$t['id']] = $t;
+ }
+
+ foreach ($this->categorys as $catid => $cat) {
+
+ $this->categorys[$catid]['pids'] = $this->get_pids($catid);
+ $this->categorys[$catid]['childids'] = $this->get_childids($catid);
+ $this->categorys[$catid]['child'] = is_numeric($this->categorys[$catid]['childids']) ? 0 : 1;
+ $this->categorys[$catid]['pdirname'] = $this->get_pdirname($catid);
+ //$this->categorys[$catid]['next_ids'] = $this->_get_next_ids($catid);
+
+ if ($cat['pdirname'] != $this->categorys[$catid]['pdirname']
+ || $cat['pids'] != $this->categorys[$catid]['pids']
+ || $cat['childids'] != $this->categorys[$catid]['childids']
+ || $cat['child'] != $this->categorys[$catid]['child']) {
+ // 褰撳簱涓笌瀹為檯涓嶇鍚堟墠鏇存柊鏁版嵁琛
+ // 鏇存柊鏁版嵁搴
+ $this->table($this->tablename)->update($cat['id'], [
+ 'pids' => $this->categorys[$catid]['pids'],
+ 'child' => $this->categorys[$catid]['child'],
+ 'childids' => $this->categorys[$catid]['childids'],
+ 'pdirname' => $this->categorys[$catid]['pdirname']
+ ]);
+ }
+
+ if ($this->categorys[$catid]['child'] == 1 && $this->categorys[$catid]['catids']) {
+ $ispost = 0;
+ foreach ($t['catids'] as $i) {
+ // 褰撴鏍忕洰杩樺瓨鍦ㄤ笅绾ф爮鐩椂,閫愭鍒ゆ柇鍏ㄩ儴涓嬬骇鏍忕洰鏄惁鍏峰鍙戝竷鏉冮檺
+ if (isset($cat[$i]) && $cat[$i]['child'] == 0) {
+ $ispost = 1; // 鍙互鍙戝竷 琛ㄧず姝ゆ爮鐩彲鐢
+ break;
+ }
+ }
+ if (!$ispost) {
+ // ispost = 0 琛ㄧず姝ゆ爮鐩病鏈夊彂甯冩潈闄
+ //$is_cks = 1;
+ continue;
+ }
+ }
+
+ // 鍏变韩鏍忕洰鏄洿鏂癿id鍊
+ if ($dirname == 'share' && $this->categorys[$catid]['child']) {
+ $this->update_parent_mid($this->categorys, $catid);
+ }
+ $this->categorys_dir[$t['dirname']] = $t['id'];
+ }
+
+ return $this->categorys;
+ }
+
+ // 鐢ㄤ簬鍒犻櫎鏃惰幏鍙栫殑鏁版嵁
+ public function data_for_delete() {
+
+ $cache = [];
+ // 鍏ㄩ儴鏍忕洰
+ $data = $this->db->table($this->tablename)->orderBy('displayorder ASC,id ASC')->get()->getResultArray();
+ if ($data) {
+ foreach ($data as $t) {
+ $cache[$t['id']] = $t;
+ }
+ }
+
+ return $cache;
+ }
+
+ // 鐢ㄤ簬绉诲姩鏃惰幏鍙栫殑鏁版嵁
+ public function data_for_move() {
+
+ $cache = [];
+ // 鍏ㄩ儴鏍忕洰
+ $data = $this->db->table($this->tablename)->orderBy('displayorder ASC,id ASC')->get()->getResultArray();
+ if ($data) {
+ foreach ($data as $t) {
+ $cache[$t['id']] = $t;
+ }
+ }
+
+ return $cache;
+ }
+
+ // 澶嶅埗灞炴
+ public function copy_value($at, $setting, $id) {
+
+ $row = $this->table($this->tablename)->get($id);
+ if (!$row) {
+ return;
+ }
+
+ $save = $row['setting'] = dr_string2array($row['setting']);
+ $arr = explode(',', $at);
+ foreach ($arr as $at) {
+ if ($at == 'tpl') {
+ $save['template'] = $setting['template'];
+ $save['template']['pagesize'] = $row['setting']['template']['pagesize'];
+ $save['template']['mpagesize'] = $row['setting']['template']['mpagesize'];
+ } elseif ($at == 'url') {
+ $save['urlrule'] = $setting['urlrule'];
+ } elseif ($at == 'html') {
+ $save['html'] = $setting['html'];
+ $save['chtml'] = $setting['chtml'];
+ } elseif ($at == 'seo') {
+ $save['seo'] = $setting['seo'];
+ } elseif ($at == 'size') {
+ $save['template']['pagesize'] = $setting['template']['pagesize'];
+ $save['template']['mpagesize'] = $setting['template']['mpagesize'];
+ } elseif ($at == 'cat_field') {
+ $save['cat_field'] = $setting['cat_field'];
+ }
+ }
+
+ $this->table($this->tablename)->update($id, [
+ 'setting' => dr_array2string($save),
+ ]);
+ }
+
+ // 鍒犻櫎鍐呭妯″潡
+ public function delete_content($cats, $module) {
+
+ if (!$cats) {
+ return;
+ }
+
+ if ($module['share']) {
+ // 鍏变韩妯″潡鍗曠嫭鍒犻櫎
+ foreach ($cats as $t) {
+ $mod = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content', $t['mid']);
+ if ($mod && $t['mid']) {
+ // 鍒犻櫎鏍忕洰妯″瀷瀛楁
+ $this->db->table('field')->where('relatedid', $t['id'])
+ ->where('relatedname', 'share-'.SITE_ID)->delete();
+ if (!$this->db->tableExists($this->dbprefix(dr_module_table_prefix($t['mid'])))) {
+ continue;
+ }
+ // 鍒犻櫎鍐呭
+ $this->table(dr_module_table_prefix($t['mid']))->where('catid', $t['id'])->delete();
+ $this->table(dr_module_table_prefix($t['mid']).'_draft')->where('catid', $t['id'])->delete();
+ $this->table(dr_module_table_prefix($t['mid']).'_flag')->where('catid', $t['id'])->delete();
+ $this->table(dr_module_table_prefix($t['mid']).'_index')->where('catid', $t['id'])->delete();
+ $this->table(dr_module_table_prefix($t['mid']).'_time')->where('catid', $t['id'])->delete();
+ $this->table(dr_module_table_prefix($t['mid']).'_verify')->where('catid', $t['id'])->delete();
+ $this->table(dr_module_table_prefix($t['mid']).'_category_data')->where('catid', $t['id'])->delete();
+ // 闄勮〃鍒嗚〃鍒犻櫎
+ for ($i = 0; $i <= 255 ;$i++) {
+ $table = $this->dbprefix(dr_module_table_prefix($t['mid']).'_data_'.$i);
+ if (!$this->db->tableExists($table)) {
+ continue;
+ }
+ $this->table($table)->where('catid', $t['id'])->delete();
+ }
+ for ($i = 0; $i <= 255 ;$i++) {
+ $table = $this->dbprefix(dr_module_table_prefix($t['mid']).'_category_data_'.$i);
+ if (!$this->db->tableExists($table)) {
+ continue;
+ }
+ $this->table($table)->where('catid', $t['id'])->delete();
+ }
+ // 鍒犻櫎琛ㄥ崟
+ if ($mod['form']) {
+ foreach ($mod['form'] as $form) {
+ $ftable = dr_module_table_prefix($t['mid']).'_form_'.$form['table'];
+ $this->table($ftable)->where('catid', $t['id'])->delete();
+ for ($i = 0; $i <= 255 ;$i++) {
+ $table = $this->dbprefix($ftable.'_data_'.$i);
+ if (!$this->db->tableExists($table)) {
+ continue;
+ }
+ $this->table($table)->where('catid', $t['id'])->delete();
+ }
+ }
+ }
+ }
+
+ }
+ } else {
+ // 鐙珛妯″潡鎵归噺鍒犻櫎
+ $catids = [];
+ foreach ($cats as $t) {
+ $catids[] = $t['id'];
+ // 鍒犻櫎鏍忕洰妯″瀷瀛楁
+ $this->db->table('field')->where('relatedid', $t['id'])
+ ->where('relatedname', APP_DIR.'-'.SITE_ID)->delete();
+ }
+ // 鎵归噺鍒犻櫎
+ $this->table(dr_module_table_prefix(APP_DIR))->where_in('catid', $catids)->delete();
+ $this->table(dr_module_table_prefix(APP_DIR).'_draft')->where_in('catid', $catids)->delete();
+ $this->table(dr_module_table_prefix(APP_DIR).'_flag')->where_in('catid', $catids)->delete();
+ $this->table(dr_module_table_prefix(APP_DIR).'_index')->where_in('catid', $catids)->delete();
+ $this->table(dr_module_table_prefix(APP_DIR).'_time')->where_in('catid', $catids)->delete();
+ $this->table(dr_module_table_prefix(APP_DIR).'_verify')->where_in('catid', $catids)->delete();
+ $this->table(dr_module_table_prefix(APP_DIR).'_category_data')->where_in('catid', $catids)->delete();
+ // 闄勮〃鍒嗚〃鍒犻櫎
+ for ($i = 0; $i <= 255 ;$i++) {
+ $table = $this->dbprefix(dr_module_table_prefix(APP_DIR).'_data_'.$i);
+ if (!$this->db->tableExists($table)) {
+ continue;
+ }
+ $this->table($table)->where_in('catid', $catids)->delete();
+ }
+ for ($i = 0; $i <= 255 ;$i++) {
+ $table = $this->dbprefix(dr_module_table_prefix(APP_DIR).'_category_data_'.$i);
+ if (!$this->db->tableExists($table)) {
+ continue;
+ }
+ $this->table($table)->where_in('catid', $catids)->delete();
+ }
+ // 鍒犻櫎琛ㄥ崟
+ if ($module['form']) {
+ foreach ($module['form'] as $form) {
+ $ftable = dr_module_table_prefix(APP_DIR).'_form_'.$form['table'];
+ $this->table($ftable)->where_in('catid', $catids)->delete();
+ for ($i = 0; $i <= 255 ;$i++) {
+ $table = $this->dbprefix($ftable.'_data_'.$i);
+ if (!$this->db->tableExists($table)) {
+ continue;
+ }
+ $this->table($table)->where_in('catid', $catids)->delete();
+ }
+ }
+ }
+ }
+ }
+
+ // 鍏煎鑰佺増鏈
+ public function get_tree_category($data) {
+ return [];
+ }
+
+ // 鎵惧埌涓绘爮鐩甶d
+ public function get_ismain_id($cats, $id) {
+ return $id;
+ }
+
+}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Models/Content.php b/dayrui/App/Cms/Models/Content.php
new file mode 100644
index 0000000..09672af
--- /dev/null
+++ b/dayrui/App/Cms/Models/Content.php
@@ -0,0 +1,2103 @@
+siteid = $siteid;
+ $this->dirname = $dir;
+ $this->mytable = dr_module_table_prefix($dir, $siteid);
+ $this->mysharetable = $siteid.'_share';
+ if ($is_share == 'null') {
+ $this->is_share = (int)\Phpcmf\Service::L('cache')->get('module-'.$siteid.'-'.$dir, 'share');
+ } else {
+ $this->is_share = $is_share;
+ }
+ return $this;
+ }
+
+ // 鍏煎鎻愮ず
+ public function save($id, $name, $value, $where = '') {
+ log_message('error', FC_NOW_URL.'->save()鏂规硶宸茬粡澶辨晥锛岃鏀逛负->save_content()锛屾煡鐪嬫暀绋嬶細https://www.xunruicms.com/doc/1076.html');
+ return dr_return_data(0, '->save()鏂规硶宸茬粡澶辨晥锛岃鏀逛负->save_content()');
+ }
+
+ // 淇濆瓨鍐呭
+ public function save_content($id, $data, $old = []) {
+
+ // 浜屾寮鍙戝嚱鏁
+ $rt = $this->_content_post_before($id, $data, $old);
+
+ // 鐗规畩杩斿洖鍊
+ if (isset($rt['code']) && isset($rt['msg'])) {
+ if ($rt['code'] == 0) {
+ return dr_return_data(0, $rt['msg']);
+ }
+ $data = $rt['data'];
+ } else {
+ // 鍏煎涔嬪墠鐨勫啓娉
+ $data = $rt;
+ }
+
+ // 鎸傞挬鐐 妯″潡鍐呭鍙戝竷鎴栦慨鏀逛箣鍓
+ $rt = \Phpcmf\Hooks::trigger_callback('module_content_before', $data);
+ if ($rt && isset($rt['code'])) {
+ // 閽╁瓙涓瓨鍦ㄧ壒娈婅繑鍥炲
+ if ($rt['code'] == 0) {
+ return dr_return_data(0, $rt['msg']);
+ }
+ $data = $rt['data'];
+ }
+
+ // 闃叉鏃堕棿瀛楁鍏ュ簱涓虹┖
+ !$data[1]['updatetime'] && $data[1]['updatetime'] = SYS_TIME;
+
+ $data[1]['uid'] = intval($data[1]['uid']);
+ $data[1]['author'] = (string)$data[1]['author'];
+
+ // 鏄电О涓虹┖鐨勬儏鍐典笅
+ /*
+ if (!$data[1]['author'] && $data[1]['uid']) {
+ $user = $this->table('member')->get($data[1]['uid']);
+ if ($user) {
+ $data[1]['author'] = $user['username'];
+ }
+ }*/
+
+ if (!$id) {
+ // 鏂板
+ !$data[1]['inputtime'] && $data[1]['inputtime'] = $data[1]['updatetime']; // 闃叉鏃堕棿瀛楁鍏ュ簱涓虹┖
+ // 鐢熸垚绱㈠紩id
+ $nid = $this->index($id, $data);
+ if (!$nid) {
+ return dr_return_data(0, dr_lang('鍐呭绱㈠紩id鐢熸垚澶辫触'));
+ }
+ $data[0]['id'] = $data[1]['id'] = $nid;
+ $is_add = 1;
+ } else {
+ // 鏇存柊
+ $is_add = 0;
+ $this->index($id, array( 1 => array(
+ 'uid' => $data[1]['uid'],
+ 'catid' => $data[1]['catid'],
+ 'status' => $data[1]['status'],
+ 'inputtime' => $data[1]['updatetime'],
+ )));
+ $data[0]['id'] = $data[1]['id'] = $id;
+ // 濡傛灉鏉ヨ嚜瀹℃牳椤甸潰,涓旀湰娆¢氳繃
+ if (defined('IS_MODULE_VERIFY') && $data[1]['status'] == 9
+ && !$this->db->table($this->mytable)->where('id', $id)->countAllResults()) {
+ $id = 0;
+ }
+ }
+
+ // 琛ㄧず瀹℃牳鏂囩珷鏈哄埗
+ if ($data[1]['status'] >= 0 && $data[1]['status'] < 9) {
+ // 瀛樺偍鍒板鏍歌〃涓幓
+ if (\Phpcmf\Service::L('input')->post('sync_cat')) {
+ // 鍚屾鏍忕洰璁剧疆杩涘鏍歌〃
+ $data[0]['sync_cat'] = \Phpcmf\Service::L('input')->post('sync_cat');
+ }
+ $backinfo = '';
+ if (IS_ADMIN) {
+ if (!\Phpcmf\Service::M('auth')->is_post_user()) {
+ $backinfo = dr_array2string([
+ 'uid' => $this->uid,
+ 'author' => \Phpcmf\Service::C()->admin['username'],
+ 'optiontime' => SYS_TIME,
+ 'flag' => $_POST['flag'],
+ 'backcontent' => $_POST['verify']['msg']
+ ]);
+ } else {
+ $backinfo = dr_array2string([
+ 'flag' => $_POST['flag'],
+ ]);
+ }
+ }
+ $verify = $this->table($this->mytable.'_verify')->get($data[1]['id']);
+ if ($verify) {
+ // 淇敼瀹℃牳
+ // 闃叉绌烘爣棰橀氱煡
+ if (!$data[1]['title']) {
+ if (isset($old['title']) && $old['title']) {
+ $data[1]['title'] = $old['title'];
+ } else {
+ $data[1]['title'] = '鏈煡涓婚';
+ }
+ }
+ $value = array_merge($data[0], $data[1]);
+ $update = [
+ 'catid' => $data[1]['catid'],
+ 'status' => (int)$data[1]['status'],
+ 'isnew' => $id && $this->table($this->mytable)->where('id', $id)->counts() ? 0 : 1,
+ 'islock' => IS_ADMIN ? 1 : 0,
+ 'content' => dr_array2string($value),
+ 'backuid' => IS_ADMIN && !\Phpcmf\Service::M('auth')->is_post_user() ? $this->uid : 0,
+ 'backinfo' => $backinfo,
+ ];
+ $rt = $this->table($this->mytable.'_verify')->update($data[1]['id'], $update);
+ if (!$rt['code']) {
+ return $rt;
+ }
+ // 娓呴櫎浠ュ墠鐨勬彁閱
+ $this->db->table('admin_notice')->where('uri', $this->dirname.'/verify/edit:id/'.$data[1]['id'])->update([
+ 'status' => 3,
+ 'updatetime' => SYS_TIME,
+ ]);
+
+ // 鎸傞挬鐐 妯″潡鍐呭瀹℃牳澶勭悊涔嬪悗
+ $verify['old'] = $old;
+ $verify = array_merge($verify, $update);
+ \Phpcmf\Hooks::trigger('module_verify_after', $verify);
+ // 鎵ц瀹℃牳鍚庣殑鍥炶皟
+ $this->_call_verify($value, $verify);
+ // 閫氱煡绠$悊鍛
+ if ($data[1]['status'] > 0) {
+ \Phpcmf\Service::M('member')->admin_notice(
+ $this->siteid,
+ 'content',
+ IS_ADMIN ? dr_member_info($data[1]['uid']) : \Phpcmf\Service::C()->member,
+ dr_lang('%s銆%s銆戝鏍', \Phpcmf\Service::C()->module['name'], $data[1]['title']), $this->dirname.'/verify/edit:id/'.$data[1]['id'],
+ $this->_get_verify_roleid($data[1]['catid'], $data[1]['status'], IS_ADMIN ? dr_member_info($data[1]['uid']) : \Phpcmf\Service::C()->member)
+ );
+ }
+ // 閫氱煡鐢ㄦ埛
+ if (IS_ADMIN && !\Phpcmf\Service::M('auth')->is_post_user() && $data[1]['status'] == 0) {
+ \Phpcmf\Service::M('member')->notice(
+ $data[1]['uid'],
+ 3,
+ dr_lang('銆%s銆嬪鏍歌鎷掔粷', $data[1]['title']),
+ \Phpcmf\Service::L('router')->member_url($this->dirname.'/verify/index')
+ );
+ }
+ } else {
+ // 鏂板瀹℃牳
+ $role = $this->_get_verify_roleid($data[1]['catid'], $data[1]['status'], IS_ADMIN ? dr_member_info($data[1]['uid']) : \Phpcmf\Service::C()->member);
+
+ // 闃叉绌烘爣棰橀氱煡
+ if (!$data[1]['title']) {
+ if (isset($old['title']) && $old['title']) {
+ $data[1]['title'] = $old['title'];
+ } else {
+ $data[1]['title'] = '鏈煡涓婚';
+ }
+ }
+ $value = array_merge($data[0], $data[1]);
+ $verify = [
+ 'id' => (int)$data[1]['id'],
+ 'uid' => (int)$data[1]['uid'],
+ 'vid' => (int)$role['verify_id'],
+ 'isnew' => $id && $this->table($this->mytable)->where('id', $id)->counts() ? 0 : 1,
+ 'islock' => 0,
+ 'catid' => (int)$data[1]['catid'],
+ 'author' => $data[1]['author'],
+ 'status' => (int)$data[1]['status'],
+ 'content' => dr_array2string($value),
+ 'backuid' => IS_ADMIN ? $this->uid : 0,
+ 'backinfo' => $backinfo,
+ 'inputtime' => SYS_TIME
+ ];
+ $rt = $this->table($this->mytable.'_verify')->replace($verify);
+ if (!$rt['code']) {
+ // 鍒犻櫎绱㈠紩
+ $this->table($this->mytable.'_index')->delete($data[1]['id']);
+ return $rt;
+ }
+ if (IS_ADMIN && defined('IS_MODULE_TG') && $data[1]['status'] == 0) {
+ // 鍚庡彴閫绋
+ if (\Phpcmf\Service::L('input')->get('clear')) {
+ $this->table($this->mytable)->delete($data[1]['id']);
+ // 鍒犻櫎鏂囦欢
+ $this->_delete_show_file($old);
+ }
+ // 閫氱煡鐢ㄦ埛
+ \Phpcmf\Service::M('member')->notice(
+ $data[1]['uid'],
+ 3,
+ dr_lang('銆%s銆嬪鏍歌鎷掔粷', $data[1]['title']),
+ \Phpcmf\Service::L('router')->member_url($this->dirname.'/verify/index')
+ );
+
+ } else {
+ // 閫氱煡绠$悊鍛
+ \Phpcmf\Service::M('member')->admin_notice(
+ $this->siteid,
+ 'content',
+ \Phpcmf\Service::C()->member,
+ dr_lang('%s銆%s銆戝鏍', \Phpcmf\Service::C()->module['name'], $data[1]['title']), $this->dirname.'/verify/edit:id/'.$data[1]['id'],
+ $role
+ );
+ }
+ // 鎸傞挬鐐 妯″潡鍐呭瀹℃牳澶勭悊涔嬪悗
+ $verify['old'] = $old;
+ \Phpcmf\Hooks::trigger('module_verify_after', $verify);
+ // 鎵ц瀹℃牳鍚庣殑鍥炶皟
+ $this->_call_verify($value, $verify);
+ }
+ return dr_return_data($verify['id'], 'ok', $verify);
+ } elseif (defined('IS_MODULE_VERIFY') && $data[1]['status'] == 9 &&
+ isset($_POST['verify_posttime']) && $_POST['verify_posttime'] ) {
+ // 瀹℃牳瀹屾垚杩涜瀹氭椂鍙戝竷鐨勫姩浣
+ $post_time = (int)strtotime(\Phpcmf\Service::L('input')->post('verify_posttime'));
+ if (SYS_TIME > $post_time) {
+ return dr_return_data(0, dr_lang('瀹氭椂鍙戝竷鏃堕棿涓嶆纭'), $data);
+ }
+ // 淇濆瓨瀹氭椂鍙戝竷鏁版嵁
+ $rt = $this->save_post_time($id, $data, $post_time);
+ if ($rt['code']) {
+ $rs = $this->_verify_post($data);
+ if ($rs) {
+ return dr_return_data(0, $rs, $data);
+ }
+ $rs = $this->_verify_success($data, $old);
+ if ($rs) {
+ return dr_return_data(0, $rs, $data);
+ }
+ \Phpcmf\Service::C()->_json(1, dr_lang('鎿嶄綔鎴愬姛锛屽凡璁句负瀹氭椂鍙戝竷'));
+ }
+ return $rt;
+ }
+
+ if (defined('IS_MODULE_VERIFY') && isset($old['verify']['isnew']) && $old['verify']['isnew']) {
+ // 鏂板瀹℃牳鎴愬姛鐨
+ $rs = $this->_verify_post($data);
+ if ($rs) {
+ return dr_return_data(0, $rs, $data);
+ }
+ }
+
+ $cdata = [];
+
+ // 绛涢夊嚭鏉ユ爮鐩ā鍨嬪瓧娈
+ if (!$this->is_hcategory && $catfield = \Phpcmf\Service::C()->module['category_data_field']) {
+ foreach ($data[1] as $i => $t) {
+ if (strpos($i, '_lng') || strpos($i, '_lat')) {
+ $i = str_replace(array('_lng', '_lat'), '', $i);
+ if (isset($catfield[$i]) && $catfield[$i]['ismain'] == 1 && !isset($cdata[$i.'_lng'])) {
+ $cdata[$i.'_lng'] = $data[1][$i.'_lng'];
+ $cdata[$i.'_lat'] = $data[1][$i.'_lat'];
+ unset($data[1][$i.'_lng'], $data[1][$i.'_lat']);
+ }
+ } else {
+ if (isset($catfield[$i]) && $catfield[$i]['ismain'] == 1) {
+ $cdata[$i] = $t;
+ unset($data[1][$i]);
+ }
+ }
+ }
+ }
+
+ // 涓昏〃鏁版嵁
+ $main = isset($data[1]) ? $data[1] : $data;
+ if ($id) {
+ // 鏇存柊鏁版嵁
+ //$main['hits'] = 0;
+ $rt = $this->table($this->mytable)->update($id, $main);
+ if (!$rt['code']) {
+ return $rt;
+ }
+ $tid = intval($old['tableid']);
+ } else {
+ // 鏂板鏁版嵁
+ $main['hits'] = (int)$main['hits'];
+ $main['tableid'] = $tid = 0;
+ $main['displayorder'] = (int)$main['displayorder'];
+ $rt = $this->table($this->mytable)->replace($main);
+ if (!$rt['code']) {
+ // 鍒犻櫎绱㈠紩
+ $this->table($this->mytable.'_index')->delete($data[1]['id']);
+ return $rt;
+ }
+ }
+
+ // 鍒ゆ柇闄勮〃鏄惁瀛樺湪,涓嶅瓨鍦ㄥ垯鍒涘缓
+ $this->is_data_table($this->mytable.'_data_', $tid);
+ $table = $this->mytable.'_data_'.$tid;
+ if ($id) {
+ if ($data[0]) {
+ $rt = $this->table($table)->update($id, $data[0]);
+ if ($rt['msg']) {
+ // 鍒犻櫎涓昏〃
+ $this->table($this->mytable)->delete($id);
+ // 鍒犻櫎绱㈠紩
+ $this->table($this->mytable.'_index')->delete($id);
+ return $rt;
+ }
+ } else {
+ // 鏈夌鎯呭喌灏辨槸闄勮〃娌℃湁鏁版嵁;
+ }
+ } else {
+ $data[0]['id'] = $data[1]['id']; // 褰曞叆涓昏〃id
+ $rt = $this->table($table)->replace($data[0]);
+ if ($rt['msg']) {
+ // 鍒犻櫎涓昏〃
+ $this->table($this->mytable)->delete($data[1]['id']);
+ // 鍒犻櫎绱㈠紩
+ $this->table($this->mytable.'_index')->delete($data[1]['id']);
+ return $rt;
+ }
+ }
+
+ // 瀛樺偍鏍忕洰琛
+ if ($cdata) {
+ $cdata['id'] = $cid = $data[1]['id'];
+ $cdata['uid'] = $data[1]['uid'];
+ $cdata['catid'] = $data[1]['catid'];
+ // 鏌ヨ鏍忕洰鏁版嵁琛ㄦ槸鍚﹀瓨鍦ㄨ鏁版嵁
+ $table = $this->mytable.'_category_data';
+ $is_update = $this->db->table($table)->where('id', $cid)->countAllResults();
+ if ($is_update) {
+ // 鏇存柊
+ $this->table($table)->update($cid, $cdata);
+ } else {
+ // 鏂板
+ $this->table($table)->replace($cdata);
+ }
+ }
+
+ // 鏇存柊url
+ $data[1]['url'] = $this->update_url($data[1], \Phpcmf\Service::L('router')->show_url(\Phpcmf\Service::C()->module, $data[1]));
+
+ // 淇敼鍐呭鏄洿鏂板悓姝ユ爮鐩浉鍏虫暟鎹
+ if ($id && $old['link_id']) {
+ $this->sync_update_cat($old['link_id'], $data);
+ }
+
+ // 鏉ユ簮鍒ゆ柇
+ if (defined('IS_MODULE_VERIFY')) {
+ // 濡傛灉鏉ヨ嚜瀹℃牳椤甸潰,琛ㄧず瀹屾垚瀹℃牳
+
+ $rs = $this->_verify_success($data, $old);
+ if ($rs) {
+ return dr_return_data(0, $rs, $data);
+ }
+ if (isset($old['verify']['isnew']) && $old['verify']['isnew']) {
+ $is_add = 1; // 鏂板瀹℃牳鎴愬姛鐨
+ }
+ } elseif (defined('IS_MODULE_RECYCLE')) {
+ // 濡傛灉鏉ヨ嚜鍥炴敹绔欏氨鍒犻櫎鍥炴敹绔欏唴瀹
+ $this->db->table($this->mytable.'_recycle')->where('cid', $id)->delete();
+ }
+
+ // 琛ㄧず鏂板彂甯
+ if ($is_add) {
+ $member = dr_member_info($data[1]['uid']);
+ if ($member && IS_USE_MEMBER) {
+ $this->module_content_after(\Phpcmf\Service::C()->module, $data, $member);
+ }
+ } else {
+ // 淇敼鍐呭
+ if ($data[1]['catid'] != $old['catid']) {
+ // 鍙樻洿鏍忕洰鐨勪竴浜涜仈鍔ㄦ搷浣
+ $this->_edit_category_id($data[1], $data[1]['catid']);
+ }
+ if ($data[1]['uid'] != $old['uid']) {
+ // 鍙樻洿浣滆呯殑涓浜涜仈鍔ㄦ搷浣
+ $this->_edit_author_id($data[1]);
+ }
+ }
+
+ // 鎸傞挬鐐 妯″潡鍐呭鍙戝竷鎴栦慨鏀瑰畬鎴愪箣鍚
+ \Phpcmf\Hooks::trigger('module_content_after', $data, $old);
+
+ // 浜屾寮鍙戝嚱鏁
+ $this->_content_post_after($id, $data, $old);
+
+ \Phpcmf\Service::L('cache')->clear('module_'.$this->dirname.'_show_id_'.$id);
+
+ return dr_return_data($data[1]['id'], 'ok', $data);
+ }
+
+ /**
+ * 鍐呭鍙戝竷涔嬪悗锛堥噾甯 / 浜烘皯甯 / 缁忛獙锛
+ */
+ public function module_content_after($module, $data, $member) {
+
+ // 澧炲噺閲戝竵
+ $score = \Phpcmf\Service::M('member_auth', 'cms')->category_auth($module, $data[1]['catid'], 'score', $member);
+ $score && \Phpcmf\Service::M('member')->add_score($data[1]['uid'], $score, dr_lang('%s鍐呭銆%s銆嬪彂甯', $module['name'], $data[1]['title']), $data[1]['url']);
+ // 澧炲噺浜烘皯甯
+ $money = \Phpcmf\Service::M('member_auth', 'cms')->category_auth($module, $data[1]['catid'], 'money', $member);
+ if ($money) {
+ $rr = \Phpcmf\Service::M('member')->add_money($data[1]['uid'], $money);
+ if ($rr['code']) {
+ if (!dr_is_app('pay')) {
+ log_message('error', '妯″潡銆'.$module['name'].'銆戝彂甯冨唴瀹癸紙'.$data[1]['id'].'锛夋墸鍑忎汉姘戝竵澶辫触锛氭病鏈夊畨瑁呫屾敮浠樼郴缁熴嶆彃浠');
+ } else {
+ \Phpcmf\Service::M('Pay', 'pay')->add_paylog([
+ 'uid' => $member['id'],
+ 'touid' => 0,
+ 'mid' => 'system',
+ 'title' => dr_lang('%s鍐呭銆%s銆嬪彂甯', $module['name'], $data[1]['title']),
+ 'value' => $money,
+ 'type' => 'finecms',
+ 'status' => 1,
+ 'result' => dr_url_prefix($data[1]['url'], $module['dirname'], SITE_ID, ''),
+ 'paytime' => SYS_TIME,
+ 'inputtime' => SYS_TIME,
+ ]);
+ }
+ } else {
+ log_message('error', '妯″潡銆'.$module['name'].'銆戝彂甯冨唴瀹癸紙'.$data[1]['id'].'锛夋墸鍑忎汉姘戝竵澶辫触锛'.$rr['msg']);
+ }
+ }
+ // 澧炲噺缁忛獙
+ $exp = \Phpcmf\Service::M('member_auth', 'cms')->category_auth($module, $data[1]['catid'], 'exp', $member);
+ $exp && \Phpcmf\Service::M('member')->add_experience($data[1]['uid'], $exp, dr_lang('%s鍐呭銆%s銆嬪彂甯', $module['name'], $data[1]['title']), $data[1]['url']);
+ }
+
+ // 瀹氭椂鍙戝竷
+ public function post_time($row) {
+
+ if (!$row) {
+ return dr_return_data(0, dr_lang('鍐呭涓嶅瓨鍦'));
+ }
+
+ $data = dr_string2array($row['content']);
+ if (!$data) {
+ return dr_return_data(0, dr_lang('鍐呭涓嶅瓨鍦'));
+ }
+
+ // 涓昏〃瀛楁
+ $fields[1] = \Phpcmf\Service::C()->get_cache('table-'.$this->siteid, $this->dbprefix($this->siteid.'_'.$this->dirname));
+ $cache = \Phpcmf\Service::C()->get_cache('table-'.$this->siteid, $this->dbprefix($this->siteid.'_'.$this->dirname.'_category_data'));
+ $cache && $fields[1] = array_merge($fields[1], $cache);
+ // 闄勮〃瀛楁
+ $fields[0] = \Phpcmf\Service::C()->get_cache('table-'.$this->siteid, $this->dbprefix($this->siteid.'_'.$this->dirname.'_data_0'));
+
+ // 鍘婚噸澶
+ $fields[0] = array_unique($fields[0]);
+ $fields[1] = array_unique($fields[1]);
+
+ $save = [];
+
+ // 涓昏〃闄勮〃褰掔被
+ foreach ($fields as $ismain => $field) {
+ foreach ($field as $name) {
+ isset($data[$name]) && $save[$ismain][$name] = $data[$name];
+ }
+ }
+
+ // 绯荤粺瀛楁
+ foreach (['inputip', 'hits', 'displayorder', 'author', 'uid', 'catid'] as $name) {
+ $save[1][$name] = $data[$name];
+ }
+
+ $save[0]['uid'] = $data['uid'];
+ $save[0]['catid'] = $data['catid'];
+
+ $save[1]['url'] = '';
+ $save[1]['status'] = 9;
+ $save[1]['link_id'] = 0;
+
+ $time = min(SYS_TIME, $row['posttime']);
+ !$time && $time = SYS_TIME;
+ $save[1]['updatetime'] = $save[1]['inputtime'] = $time;
+
+ if ($save[1]['title'] && $this->db->table($this->mytable)->where('title', $save[1]['title'])->countAllResults()) {
+ $msg = dr_lang('宸茬粡鏈夌浉鍚岀殑%s瀛樺湪', isset(\Phpcmf\Service::C()->module['field']['title']['name']) ? \Phpcmf\Service::C()->module['field']['title']['name'] : dr_lang('涓婚'));
+ $this->db->table($this->mytable.'_time')->where('id', $row['id'])->update(['result' => $msg]);
+ return dr_return_data(0, $msg);
+ }
+
+ $rt = $this->save_content(0, $save);
+ if ($rt['code']) {
+ // 鍙戝竷鎴愬姛
+ $save[1]['id'] = $rt['code'];
+ $this->db->table($this->mytable.'_time')->where('id', $row['id'])->delete();
+ $prefix = $this->dbprefix($this->siteid.'_'.$this->dirname);
+ $this->db->table('attachment')->where('related', $prefix.'_time-'.$row['id'])->update([
+ 'related' => $prefix.'-'.$rt['code']
+ ]);
+ $this->db->table('attachment_data')->where('related', $prefix.'_time-'.$row['id'])->update([
+ 'related' => $prefix.'-'.$rt['code']
+ ]);
+ if ($data['flag']) {
+ $this->delete_flag($save[1]['id'], 'all');
+ foreach ($data['flag'] as $i) {
+ if (isset(\Phpcmf\Service::C()->module['setting']['flag'][$i])) {
+ $this->insert_flag((int)$i, $save[1]['id'], $save[1]['uid'], $save[1]['catid']);
+ }
+ }
+ }
+ // 鐢熸垚鏉冮檺鏂囦欢
+ if (\Phpcmf\Service::C()->module['category'][$data['catid']]['setting']['html']) {
+ // 鐢熸垚鍒楄〃
+ $atcode = 'chtml_cat_'.$this->siteid.'_'.$this->dirname.'_'.$data['catid'];
+ \Phpcmf\Service::L('cache')->set_auth_data($atcode, $data['catid'], $this->siteid);
+ dr_catcher_data(SITE_URL.'index.php?s='.MOD_DIR.'&c=html&m=categoryfile&id='.$data['catid'].'&atcode='.$atcode);
+ }
+ if (\Phpcmf\Service::C()->module['category'][$data['catid']]['setting']['chtml']) {
+ //$rt['data'] = dr_web_prefix('index.php?'.($this->is_share ? '' : 's='.$this->dirname.'&').'c=html&m=showfile&id='.$rt['code']);
+ // 鐢熸垚鍐呭
+ $atcode = 'chtml_'.$this->siteid.'_'.$this->dirname.'_'.$rt['code'];
+ \Phpcmf\Service::L('cache')->set_auth_data($atcode, $rt['code'], $this->siteid);
+ dr_catcher_data(SITE_URL.'index.php?s='.MOD_DIR.'&c=html&m=showfile&id='.$rt['code'].'&atcode='.$atcode);
+
+ }
+ } else {
+ $this->db->table($this->mytable.'_time')->where('id', $row['id'])->update(['result' => $rt['msg']]);
+ }
+
+ return $rt;
+ }
+
+ // 浜屾楠岃瘉
+ protected function _verify_post($data) {
+
+ // 鏂板瀹℃牳鎴愬姛鐨 浜屾楠岃瘉
+ $member = \Phpcmf\Service::M('member')->member_info($data[1]['uid']);
+ if ($member) {
+ // 閲戝竵楠岃瘉
+ $score = \Phpcmf\Service::M('member_auth', 'cms')->category_auth(\Phpcmf\Service::C()->module, $data[1]['catid'], 'score', $member);
+ if ((int)$score + (int)$member['score'] < 0) {
+ return dr_lang(SITE_SCORE.'涓嶈冻锛屽綋鍓嶆爮鐩渶瑕%s'.SITE_SCORE, abs($score));
+ }
+ // 閲戦楠岃瘉
+ $money = \Phpcmf\Service::M('member_auth', 'cms')->category_auth(\Phpcmf\Service::C()->module, $data[1]['catid'], 'money', $member);
+ if ((float)$money + (float)$member['money'] < 0) {
+ return dr_lang('浣欓涓嶈冻锛屽綋鍓嶆爮鐩渶瑕%s鍏', abs($money));
+ }
+ }
+
+ return '';
+ }
+ // 瀹℃牳鎴愬姛鎵ц
+ protected function _verify_success($data, $old) {
+
+ // 閫氱煡鐢ㄦ埛
+ \Phpcmf\Service::L('Notice')->send_notice('module_content_verify_1', $data[1]);
+ $value = array_merge($data[1], $data[0]);
+ $verify = $this->table($this->mytable.'_verify')->get($data[1]['id']);
+ $verify['status'] = 9;
+ $verify['content'] = dr_array2string($value);
+ $verify['backuid'] = IS_ADMIN ? $this->uid : 0;
+ $verify['backinfo'] = dr_array2string($old['verify']['backinfo']);
+
+ // 鍒犻櫎瀹℃牳琛
+ $this->table($this->mytable.'_verify')->delete($data[1]['id']);
+
+ // 鎸傞挬鐐 妯″潡鍐呭瀹℃牳澶勭悊涔嬪悗
+ \Phpcmf\Hooks::trigger('module_verify_after', $verify);
+
+ // 鎵ц瀹℃牳鍚庣殑鍥炶皟
+ $this->_call_verify($value, $verify);
+
+ return '';
+ }
+
+ // 楠岃瘉鏍忕洰鎿嶄綔鏉冮檺 鍚庡彴
+ public function admin_category_auth($cat, $act) {
+ return 1;
+ }
+
+ // 楠岃瘉鏍忕洰鎿嶄綔鏉冮檺 浼氬憳
+ public function member_category_auth($cat, $act) {
+ return 1;
+ }
+
+ // 鏌ヨid
+ public function find_id($field, $value) {
+
+ $row = $this->db->table($this->mytable)->select('id')->where($field, $value)->get()->getRowArray();
+
+ return $row ? intval($row['id']) : 0;
+ }
+
+ // 鍒犻櫎鎺ㄨ崘浣
+ public function delete_flag($id, $flag) {
+ if (is_array($flag)) {
+ $this->db->table($this->mytable.'_flag')->where('id', $id)->whereIn('flag', $flag)->delete();
+ } elseif ($flag == 'all') {
+ $this->db->table($this->mytable.'_flag')->where('id', $id)->delete();
+ } else {
+ $this->db->table($this->mytable.'_flag')->where('id', $id)->where('flag', (int)$flag)->delete();
+ }
+ }
+
+ // 鏂板鎺ㄨ崘浣
+ public function insert_flag($flag, $id, $uid, $catid) {
+
+ if ($this->table($this->mytable.'_flag')
+ ->where('id', $id)
+ ->where('uid', $uid)
+ ->where('flag', $flag)
+ ->where('catid', $catid)->counts()) {
+ return;
+ }
+
+ $this->db->table($this->mytable.'_flag')->replace([
+ 'id' => $id,
+ 'uid' => $uid,
+ 'flag' => $flag,
+ 'catid' => $catid,
+ ]);
+ }
+
+ // 鑾峰彇鎺ㄨ崘浣
+ public function get_flag($id) {
+
+ $rt = [];
+ $data = $this->table($this->mytable.'_flag')->where('id', $id)->getAll();
+ if ($data) {
+ foreach ($data as $t) {
+ $rt[] = $t['flag'];
+ }
+ }
+
+ return $rt;
+ }
+
+ // 鑾峰彇鍏抽敭璇嶅垪琛
+ public function get_tag_url($name) {
+ return \Phpcmf\Service::L('router')->get_tag_url($name, $this->dirname);
+ }
+
+ /**
+ * 淇濆瓨鍐呭鐨勮崏绋
+ *
+ * @param intval $id 鑽夌ǹid
+ * @param array $data 鏁版嵁鏁扮粍
+ * @return intval $id 鑽夌ǹid
+ */
+ public function insert_draft($id, $data) {
+
+ $save = [
+ 'uid' => $this->uid,
+ 'cid' => intval($data[1]['id']),
+ 'catid' => intval($data[1]['catid']),
+ 'content' => dr_array2string($data[0] ? array_merge($data[0], $data[1]) : $data[1]),
+ 'inputtime' => SYS_TIME
+ ];
+
+ // 鍒ゆ柇鑽夌ǹ鏄惁瀛樺湪锛屼笉瀛樺湪灏辨彃鍏
+ if ($id && $this->db->table($this->mytable.'_draft')->where('id', $id)->countAllResults()) {
+ $rt = $this->table($this->mytable.'_draft')->update($id, $save);
+ } else {
+ $rt = $this->table($this->mytable.'_draft')->insert($save);
+ }
+
+ return $rt;
+ }
+
+ /**
+ * 淇濆瓨瀹氭椂鍙戝竷鍐呭
+ *
+ * @param intval $id id
+ * @param array $data 鏁版嵁鏁扮粍
+ * @param intval $time 鍙戝竷鏃堕棿
+ */
+ public function save_post_time($id, $data, $time) {
+
+ $post = $data[0] ? array_merge($data[0], $data[1]) : $data[1];
+ $post['flag'] = \Phpcmf\Service::L('input')->post('flag');
+
+ $save = [
+ 'uid' => intval($data[1]['uid']),
+ 'catid' => intval($data[1]['catid']),
+ 'content' => dr_array2string($post),
+ 'result' => '',
+ 'posttime' => $time,
+ 'inputtime' => SYS_TIME
+ ];
+
+ // 鍒ゆ柇鏄惁瀛樺湪锛屼笉瀛樺湪灏辨彃鍏
+ if ($id) {
+ $rt = $this->table($this->mytable.'_time')->update($id, $save);
+ } else {
+ $rt = $this->table($this->mytable.'_time')->insert($save);
+ }
+
+ return dr_return_data($rt['code'], $rt['code'] ? dr_lang('瀹氭椂鍐呭淇濆瓨鎴愬姛') : $rt['msg']);
+ }
+
+ // 鏇存柊闃呰閲
+ public function update_hits($id, $is_qx = 0) {
+
+ $data = $this->db->table($this->mytable)->where('id', $id)->select('hits,updatetime')->get()->getRowArray();
+ if (!$data) {
+ return dr_return_data(0, dr_lang('闃呰缁熻: 妯″潡鍐呭涓嶅瓨鍦'));
+ }
+
+ $name = 'module-'.md5($this->mytable).'-'.$id;
+ if (!$is_qx && \Phpcmf\Service::L('input')->get_cookie($name)) {
+ return dr_return_data(1, $data['hits'], '涓嶉噸澶嶇粺璁');
+ }
+
+ $plus = max(1, defined('IS_HITS_PLUS') && is_numeric(IS_HITS_PLUS) ? intval(IS_HITS_PLUS) : 1);
+ $hits = (int)$data['hits'] + $plus;
+
+ // 鏇存柊涓昏〃
+ $this->db->table($this->mytable)->where('id', $id)->set('hits', $hits)->update();
+
+ // 鑾峰彇缁熻鏁版嵁
+ $total = $this->db->table($this->mytable.'_hits')->where('id', $id)->get()->getRowArray();
+ if (!$total) {
+ $total['day_hits'] = $total['week_hits'] = $total['month_hits'] = $total['year_hits'] = 0;
+ $total['day_time'] = $total['week_time'] = $total['month_time'] = $total['year_time'] = SYS_TIME;
+ } else {
+ // 鎸夌被鍒綊闆
+ if (date('Ymd', $total['day_time']) != date('Ymd', SYS_TIME)) {
+ $total['day_time'] = SYS_TIME;
+ $total['day_hits'] = 0;
+ }
+ if (date('YW', $total['week_time']) != date('YW', SYS_TIME)) {
+ $total['week_time'] = SYS_TIME;
+ $total['week_hits'] = 0;
+ }
+ if (date('Ym', $total['month_time']) != date('Ym', SYS_TIME)) {
+ $total['month_time'] = SYS_TIME;
+ $total['month_hits'] = 0;
+ }
+ if (date('Y', $total['year_time']) != date('Y', SYS_TIME)) {
+ $total['year_time'] = SYS_TIME;
+ $total['year_hits'] = 0;
+ }
+ }
+
+ // 鏇存柊鍒扮粺璁¤〃
+ $save = [
+ 'id' => $id,
+ 'hits' => $hits,
+ 'day_hits' => $total['day_hits'] + $plus,
+ 'day_time' => $total['day_time'],
+ 'week_hits' => $total['week_hits'] + $plus,
+ 'week_time' => $total['week_time'],
+ 'month_hits' => $total['month_hits'] + $plus,
+ 'month_time' => $total['month_time'],
+ 'year_hits' => $total['year_hits'] + $plus,
+ 'year_time' => $total['year_time'],
+ ];
+ \Phpcmf\Service::M()->table($this->mytable.'_hits')->replace($save);
+
+ //session()->save($name, $id, 300); 鑰冭檻骞跺彂鎬ц兘杩樻槸涓嶇敤session浜
+ \Phpcmf\Service::L('input')->set_cookie($name, $id, 300);
+
+ // 杈撳嚭
+ return dr_return_data(1, $hits);
+
+ }
+
+ // 鏇存柊url
+ public function update_url($row, $url) {
+ if (!$url) {
+ $url = \Phpcmf\Service::L('router')->url_prefix('module_php', \Phpcmf\Service::C()->module, []) . 'c=show&id=' .$row['id'];
+ }
+ $this->table($this->mytable)->update((int)$row['id'], ['url' => $url]);
+ return $url;
+ }
+
+ // 鑾峰彇鑽夌ǹ鍒楄〃
+ public function get_draft_list($where) {
+
+ $rt = [];
+ $data = $this->table($this->mytable.'_draft')->where('uid', $this->uid)->where($where)->order_by('inputtime desc')->getAll(10);
+ if ($data) {
+ foreach ($data as $t) {
+ $rt[$t['id']] = dr_string2array($t['content']);
+ $rt[$t['id']]['id'] = $t['id'];
+ $rt[$t['id']]['inputtime'] = $t['inputtime'];
+ }
+ }
+
+ return $rt;
+ }
+
+ // 鑾峰彇鑽夌ǹ鍐呭
+ public function get_draft($id) {
+
+ $data = $this->db
+ ->table($this->mytable.'_draft')
+ ->where('uid', $this->uid)
+ ->where('id', $id)
+ ->get()->getRowArray();
+ if (!$data) {
+ return NULL;
+ }
+
+ $body = dr_string2array($data['content']);
+ $body['draft']['cid'] = $data['cid'];
+ $body['draft']['catid'] = $body['catid'] = $data['catid'];
+
+ return $body;
+ }
+
+ // 鍒犻櫎鑽夌ǹ
+ public function delete_draft($id) {
+ $this->table($this->mytable.'_draft')->delete($id, 'uid='.$this->uid);
+ // 鍒犻檮浠
+ SYS_ATTACHMENT_DB && \Phpcmf\Service::M('Attachment')->id_delete(
+ $this->member,
+ [$id],
+ $this->dbprefix($this->mytable.'_draft-'.$id)
+ );
+ }
+
+ /**
+ * 鐢熸垚/鏇存柊绱㈠紩鏁版嵁
+ *
+ * @param array $data
+ * @return array
+ */
+ public function index($id, $data) {
+
+ $in = [
+ 'uid' => (int)$data[1]['uid'],
+ 'catid' => (int)$data[1]['catid'],
+ 'status' => (int)$data[1]['status'],
+ 'inputtime' => (int)$data[1]['inputtime'],
+ ];
+
+ if ($this->is_share) {
+ // 鍏变韩妯″潡
+ if ($id) {
+ // 淇敼
+ //$this->table($this->mysharetable.'_index')->replace(['id' => $id, 'mid' => $this->dirname ]);
+ $in['id'] = $id;
+ } else {
+ // 鏂板
+ $rt = $this->table($this->mysharetable.'_index')->replace(['mid' => $this->dirname]);
+ $id = $in['id'] = (int)$rt['code'];
+ }
+ // 鏇存柊妯″潡绱㈠紩
+ $this->table($this->mytable.'_index')->replace($in);
+ } else {
+ // 鐙珛妯″潡
+ if ($id) {
+ // 淇敼
+ $in['id'] = $id;
+ $this->table($this->mytable.'_index')->replace($in);
+ } else {
+ // 鏂板
+ $rt = $this->table($this->mytable.'_index')->replace($in);
+ $id = (int)$rt['code'];
+ }
+ }
+
+ return $id;
+ }
+
+ // 鎸夎嚜瀹氫箟瀛楁鑾峰彇鍐呭
+ public function find_row($field, $value) {
+
+ if (!$field) {
+ return [];
+ } elseif (!strlen($value)) {
+ return [];
+ } elseif (!$this->is_field_exists($this->mytable, $field)) {
+ return [];
+ }
+
+ return $this->db->table($this->mytable)->where($field, dr_safe_replace($value))->get()->getRowArray();
+ }
+
+ // 鑾峰彇鍐呭
+ public function get_data($id, $is_table = 0, $param = [], $is_more = 0) {
+
+ $cdata = $tables = $row = [];
+
+ // 涓昏〃
+ $tables[] = $table = $this->mytable;
+
+ if (!$id) {
+ if (!$param) {
+ return [];
+ } elseif (!$param['field']) {
+ return [];
+ }
+ $row = $this->find_row($param['field'], $param['value']);
+ if (!$row) {
+ return [];
+ }
+ $id = $row['id'];
+ } else {
+ $row = $this->table($table)->get($id);
+ if (!$row) {
+ return [];
+ }
+ }
+
+ $cdata[$table] = $row;
+
+ // 闄勮〃id
+ $tableid = intval($row['tableid']);
+
+ // 鍓〃
+ $tables[] = $table = $this->mytable.'_data_'.$tableid;
+ $cdata[$table] = $data = $this->table($table)->get($id);
+ $data && $row = $row + $data;
+
+ // 鏍忕洰妯″瀷鏁版嵁
+ if ((!$this->is_hcategory && \Phpcmf\Service::C()->module['category_data_field']) or $is_more) {
+ $tables[] = $table = $this->mytable.'_category_data';
+ $cdata[$table] = $data = $this->table($table)->get($id);
+ if ($data) {
+ $row = $row + $data;
+ }
+ }
+
+ $row = $this->_format_content_data($row);
+
+ if ($is_table) {
+ return [$row, $tables, $cdata];
+ }
+
+ return $row;
+ }
+
+ // 鍒ゆ柇鐢ㄦ埛鍓嶇鏉冮檺
+ public function check_member_auth($catid, $action) {
+
+ if (!$this->is_hcategory) {
+ $cat = \Phpcmf\Service::C()->_get_module_member_category(\Phpcmf\Service::C()->module, $action);
+ if (!isset($cat[$catid])) {
+ return 0;
+ }
+ } else {
+ $rt = $this->_hcategory_member_del_auth();
+ if (!$rt['code']) {
+ return 0;
+ }
+ }
+
+ return 1;
+ }
+
+ // 鏍煎紡鍖栧叆搴撴暟鎹
+ public function format_data($data) {
+
+ isset($data[1]['uid']) && $data[0]['uid'] = (int)$data[1]['uid'];
+ isset($data[1]['hits']) && $data[1]['hits'] = (int)$data[1]['hits'];
+
+ if (isset($data[1]['keywords']) && $data[1]['keywords']) {
+ // 涓嶈鑷姩鑾峰彇鍏抽敭璇嶏紝瀹规槗鍗¢】锛屽紩璧峰彂甯冨欢杩
+ $kws = array_unique(explode(',', trim(str_replace('"', '', $data[1]['keywords']))));
+ if (isset(\Phpcmf\Service::C()->module['setting']['kws_limit'])
+ && \Phpcmf\Service::C()->module['setting']['kws_limit']) {
+ $kws = dr_arraycut($kws, \Phpcmf\Service::C()->module['setting']['kws_limit']);
+ }
+ $data[1]['keywords'] = implode(',', $kws);
+ }
+ if (!$data[1]['description']) {
+ if (isset(\Phpcmf\Service::C()->module['setting']['desc_auto'])
+ && \Phpcmf\Service::C()->module['setting']['desc_auto']) {
+ // 鎵嬪姩濉厖鎻忚堪
+ } else {
+ // 鑷姩濉厖鎻忚堪
+ if (isset($data[0]['content']) && $data[0]['content']) {
+ $data[1]['description'] = dr_get_description($data[0]['content']);
+ } elseif (isset($data[1]['content']) && $data[1]['content']) {
+ $data[1]['description'] = dr_get_description($data[1]['content']);
+ }
+ }
+ }
+
+ return $data;
+ }
+
+ // 鍚屾鏇存柊鍏朵粬鏍忕洰
+ public function sync_update_cat($lid, $data) {
+
+ $id = $lid > 0 ? $lid : $data[1]['id'];
+
+ unset($data[1]['id'],$data[1]['catid']);
+ $this->db->table($this->mytable)->where('link_id', (int)$id)->update($data[1]);
+ }
+
+ // 鍚屾鍒板叾浠栨爮鐩
+ public function sync_cat($catid, $data) {
+
+ if (!$catid) {
+ return;
+ }
+
+ $id = (int)$data[1]['id'];
+ $sync = @explode(',', $catid);
+ if ($sync && $id) {
+ // 鏇存柊涓昏〃鐘舵佷富琛
+ $this->table($this->mytable)->update($id, ['link_id' => -1]);
+ // 鍚屾璁板綍
+ foreach ($sync as $catid) {
+ if ($catid && $catid != $data[1]['catid']) {
+ // 鎻掑叆鍒板悓姝ユ爮鐩腑
+ $new = $data;
+ $new[1]['catid'] = $catid;
+ $new[1]['link_id'] = $id;
+ $new[1]['tableid'] = 0;
+ $new[1]['id'] = $this->index(0, $new);
+ $new[1]['id'] && $this->table($this->mytable)->replace($new[1]);
+ }
+ }
+ }
+ }
+
+ // 鍒犻櫎鏁版嵁,鏀惧叆鍥炴敹绔
+ public function delete_to_recycle($ids, $note = '鏃') {
+
+ if (!$ids) {
+ return dr_return_data(1);
+ }
+
+ // 鏍煎紡鍖
+ foreach ($ids as $id) {
+
+ $id = intval($id);
+
+ \Phpcmf\Service::L('cache')->clear('module_'.$this->dirname.'_show_id_'.$id);
+
+ // 涓昏〃
+ $tables[$this->mytable] = $row = $this->table($this->mytable)->get($id);
+ if (!$row) {
+ return dr_return_data(0, dr_lang('鍐呭涓嶅瓨鍦: '.$id));
+ } elseif (dr_is_app('cqx') && \Phpcmf\Service::M('content', 'cqx')->is_edit($row['catid'], $row['uid'])) {
+ return dr_return_data(0, dr_lang('褰撳墠瑙掕壊鏃犳潈闄愮鐞嗘鏍忕洰'));
+ }
+
+ if ($row['link_id'] == '-1') {
+ // 琛ㄧず浣滀负姣嶅唴瀹
+ // 鏌ヨ鍏朵粬鏍忕洰鐨勫唴瀹
+ $ort = $this->table($this->mytable)->where('link_id', $id)->getAll();
+ if ($ort) {
+ $_ids = [];
+ foreach ($ort as $n) {
+ $_ids[] = $n['id'];
+ }
+ $this->delete_to_recycle($_ids, $note);
+ }
+ }
+
+ $row['url'] = dr_url_prefix($row['url'], $this->dirname, $this->siteid, 0);
+
+ // 绔欓暱宸ュ叿
+ if (dr_is_app('bdts')) {
+ \Phpcmf\Service::M('bdts', 'bdts')->module_bdts($this->dirname, $row['url'], 'del');
+ }
+ if (dr_is_app('bdxz')) {
+ \Phpcmf\Service::M('bdxz', 'bdxz')->module_bdxz($this->dirname, $row['url'], 'del');
+ }
+
+ // 闄勮〃id
+ $tableid = intval($row['tableid']);
+
+ // 鍓〃
+ $table = $this->mytable.'_data_'.$tableid;
+ $tables[$table] = $this->table($table)->get($id);
+
+ if (!$this->is_hcategory) {
+ // 鏍忕洰妯″瀷鏁版嵁
+ $table = $this->mytable.'_category_data';
+ $tables[$table] = $this->table($table)->get($id);
+ }
+
+ // 鍒犻櫎琛ㄦ暟鎹
+ foreach ($tables as $table => $t) {
+ if ($t) {
+ $rt = $this->table($table)->delete($id);
+ if (!$rt['code']) {
+ return $rt;
+ }
+ }
+ }
+
+ // 鏀规敼鐘舵
+ $rt = $this->table($this->mytable.'_index')->update($id, ['status' => 10]);
+ if (!$rt['code']) {
+ return $rt;
+ }
+
+ \Phpcmf\Service::M('member')->delete_admin_notice($this->dirname.'/verify/edit:id/'.$id, $this->siteid);
+ \Phpcmf\Service::L('cache')->clear('module_'.$this->dirname.'_show_id_'.$id);
+
+ // 鏀惧叆鍥炴敹绔
+ $rt = $this->table($this->mytable.'_recycle')->insert([
+ 'uid' => intval($row['uid']),
+ 'cid' => $id,
+ 'catid' => intval($row['catid']),
+ 'content' => dr_array2string($tables),
+ 'result' => $note,
+ 'inputtime' => SYS_TIME
+ ]);
+ if (!$rt['code']) {
+ return $rt;
+ }
+
+ $row['note'] = dr_clearhtml($note);
+
+ // 鍥炴敹绔欓挬瀛
+ \Phpcmf\Hooks::trigger('module_content_recycle', $row);
+
+ // 閫氱煡鐢ㄦ埛
+ $row['title'] = dr_strcut(dr_clearhtml($row['title']), 50);
+ \Phpcmf\Service::L('Notice')->send_notice('module_content_delete', $row);
+
+ // 鍒犻櫎鏂囦欢
+ $this->_delete_show_file($row);
+
+ // 鍒犻櫎鎵ц鐨勬柟娉
+ $this->_recycle_content($id, $row, $note);
+ }
+
+ return dr_return_data(1);
+ }
+
+ // 鍒犻櫎闈欐佹枃浠
+ protected function _delete_show_file($row) {
+
+ if (!$row['url']) {
+ return;
+ }
+
+ $file = \Phpcmf\Service::L('Router')->remove_domain($row['url']); // 浠庡湴鍧涓幏鍙栬鐢熸垚鐨勬枃浠跺悕
+ $root = dr_is_app('chtml') ? \Phpcmf\Service::L('html', 'chtml')->get_webpath($this->siteid, $this->dirname) : WEBPATH;
+
+ // 鍒犻櫎鏂囦欢
+ if (is_file($root.$file)) {
+ unlink($root.$file);
+ }
+ if (is_file($root.SITE_MOBILE_DIR.'/'.$file)) {
+ unlink($root.SITE_MOBILE_DIR.'/'.$file);
+ }
+ }
+
+ // 鍒犻櫎鍥炴敹绔欐暟鎹
+ public function delete_for_recycle($ids) {
+
+ foreach ($ids as $id) {
+ $id = intval($id);
+ $row = $this->table($this->mytable.'_recycle')->get($id);
+ if (!$row) {
+ return NULL;
+ } elseif (\Phpcmf\Service::M('auth')->is_post_user() && $row['uid'] != $this->uid) {
+ return NULL;
+ }
+ $cid = intval($row['cid']);
+ if (!$cid) {
+ return NULL;
+ }
+ \Phpcmf\Service::L('cache')->clear('module_'.$this->dirname.'_show_id_'.$cid);
+ // 鍒犻櫎鎵ц鐨勬柟娉
+ $this->_delete_content($cid, $row);
+ // 鍒犻櫎閽╁瓙
+ \Phpcmf\Hooks::trigger('module_content_delete', dr_string2array($row['content']));
+ // 鍒犻櫎鍥炴敹绔欒〃
+ $this->table($this->mytable.'_recycle')->delete($id);
+ // 鎵嶅交搴曞垹闄ゅ唴瀹规暟鎹
+ $this->delete_content($cid);
+ }
+
+ return dr_return_data(1);
+ }
+
+ // 鍒犻櫎鍏ㄩ儴鍐呭鏁版嵁
+ public function delete_content($cid) {
+
+ if (!$cid) {
+ return;
+ }
+
+ $module = \Phpcmf\Service::L('cache')->get('module-'.$this->siteid.'-'.$this->dirname);
+
+ // 鍒犻櫎绱㈠紩琛
+ $this->table($this->mytable.'_index')->delete($cid);
+
+ // 鍒犻櫎涓昏〃
+ $this->table($this->mytable)->delete($cid);
+
+ // 鍒犻櫎鏍囪琛
+ $this->table($this->mytable.'_flag')->delete($cid);
+
+ // 鍒犻櫎缁熻
+ $this->table($this->mytable.'_hits')->delete($cid);
+ $this->table($this->mytable.'_verify')->delete($cid);
+
+ // 鍏变韩妯″潡鍒犻櫎
+ if ($this->is_share) {
+ $this->table($this->mysharetable.'_index')->delete($cid);
+ }
+ // 鍒犻櫎鑽夌ǹ琛
+ $this->db->table($this->mytable.'_draft')->where('cid', $cid)->delete();
+ // 鍒犻櫎鐩稿叧鎻掍欢琛
+ if ($this->is_table_exists($this->mytable.'_favorite')) {
+ $this->db->table($this->mytable.'_favorite')->where('cid', $cid)->delete();
+ }
+ if ($this->is_table_exists($this->mytable.'_support')) {
+ $this->db->table($this->mytable.'_support')->where('cid', $cid)->delete();
+ }
+ if ($this->is_table_exists($this->mytable.'_oppose')) {
+ $this->db->table($this->mytable.'_oppose')->where('cid', $cid)->delete();
+ }
+ if ($this->is_table_exists($this->mytable.'_donation')) {
+ $this->db->table($this->mytable.'_donation')->where('cid', $cid)->delete();
+ }
+ // 鍒犻櫎鍐呭
+ $tid = $this->_table_id($cid);
+ if ($this->is_table_exists($this->mytable.'_data_'.$tid)) {
+ $this->table($this->mytable.'_data_'.$tid)->delete($cid);
+ }
+ if (!$this->is_hcategory) {
+ $this->table($this->mytable.'_category_data')->delete($cid);
+ }
+ // 妯″潡琛ㄥ崟
+ if ($module['form']) {
+ foreach ($module['form'] as $t) {
+ $table = $this->mytable.'_form_'.$t['table'];
+ if (!$this->is_table_exists($table)) {
+ break;
+ }
+ $this->db->table($table)->where('cid', $cid)->delete();
+ for ($i = 0; $i < 200; $i ++) {
+ if (!$this->db->query("SHOW TABLES LIKE '".$this->dbprefix($table).'_data_'.$i."'")->getRowArray()) {
+ break;
+ }
+ $this->db->table($table.'_data_'.$i)->where('cid', $cid)->delete();
+ }
+ //\Phpcmf\Service::M('attachment')->related_delete($this->dbprefix($table), );
+ }
+ }
+
+ // 鎵ц鍒犻櫎鍚屾
+ \Phpcmf\Service::M('Sync')->delete_content($cid, $this->siteid, $this->dirname);
+
+ // 鍒犻櫎褰掓。鐨勯檮浠
+ SYS_ATTACHMENT_DB && \Phpcmf\Service::M('attachment')->related_delete($this->dbprefix($this->mytable), $cid);
+ }
+
+ // 鎭㈠鏁版嵁
+ public function recovery($ids) {
+
+ $rt = [];
+ foreach ($ids as $id) {
+
+ $id = intval($id);
+ $row = $this->table($this->mytable.'_recycle')->get($id);
+ if (!$row) {
+ return NULL;
+ }
+
+ $rt[] = $cid = intval($row['cid']);
+ $tables = dr_string2array($row['content']);
+ if (!$tables) {
+ return NULL;
+ }
+ // 鍐呭鎭㈠
+ foreach ($tables as $table => $t) {
+ if ($t) {
+ $rt = $this->table($table)->replace($t);
+ if (!$rt['code']) {
+ return $rt;
+ }
+ }
+ }
+ $rt = $this->table($this->mytable.'_index')->update($cid, ['status' => 9]);
+ if (!$rt['code']) {
+ return $rt;
+ }
+
+ $this->db->table($this->mytable.'_recycle')->where('id', $id)->delete();
+ $this->_recovery_content($cid, $row);
+ }
+
+ return dr_return_data(1, 'ok', $rt);
+ }
+
+ // 绉诲姩鏍忕洰
+ public function move_category($ids, $catid) {
+
+ if (!$catid) {
+ return dr_return_data(0, dr_lang('鐩爣鏍忕洰涓嶅瓨鍦'));
+ }
+
+ $all = $this->table($this->mytable)->where_in('id', $ids)->getAll();
+ if ($all) {
+ foreach ($all as $t) {
+
+ $id = intval($t['id']);
+ $this->table($this->mytable)->update($id, ['catid' => $catid]);
+ $this->table($this->mytable.'_index')->update($id, ['catid' => $catid]);
+ // 鍒ゆ柇闄勮〃鏄惁瀛樺湪,涓嶅瓨鍦ㄥ垯鍒涘缓
+ $this->is_data_table($this->mytable.'_data_', $t['tableid']);
+ $this->db->table($this->mytable.'_data_'.intval($t['tableid']))->where('id', $id)->update(['catid' => $catid]);
+ $this->db->table($this->mytable.'_category_data')->where('id', $id)->update(['catid' => $catid]);
+
+ // 鍙樻洿鏍忕洰鐨勪竴浜涜仈鍔ㄦ搷浣
+ $this->_edit_category_id($t, $catid);
+ }
+ }
+
+ return dr_return_data(1);
+ }
+
+ // 鎵归噺鏇存柊鍏朵粬琛ㄧ殑鏍忕洰id鍙
+ public function update_catids($oid, $catid) {
+
+ if (!$catid) {
+ return;
+ } elseif (!$oid) {
+ return;
+ }
+
+ $all = $this->table($this->mytable)->where('catid', $oid)->getAll();
+ if ($all) {
+ foreach ($all as $t) {
+
+ $id = intval($t['id']);
+ $this->table($this->mytable)->update($id, ['catid' => $catid]);
+ $this->table($this->mytable.'_index')->update($id, ['catid' => $catid]);
+ $this->db->table($this->mytable.'_data_'.intval($t['tableid']))->where('id', $id)->update(['catid' => $catid]);
+ $this->db->table($this->mytable.'_category_data')->where('id', $id)->update(['catid' => $catid]);
+
+ // 鍙樻洿鏍忕洰鐨勪竴浜涜仈鍔ㄦ搷浣
+ $this->_edit_category_id($t, $catid);
+ }
+ }
+
+
+ }
+
+ // 鍙樻洿鏍忕洰鐨勪竴浜涜仈鍔ㄦ搷浣
+ protected function _edit_category_id($t, $catid) {
+
+ $id = intval($t['id']);
+ $this->db->table($this->mytable.'_time')->where('id', $id)->update(['catid' => $catid]);
+ $this->db->table($this->mytable.'_verify')->where('id', $id)->update(['catid' => $catid]);
+ // 鍚屾绉诲姩鐩稿叧琛ㄥ崟琛
+ $form = \Phpcmf\Service::L('cache')->get('module-'.$this->siteid.'-'.$this->dirname, 'form');
+ if ($form) {
+ foreach ($form as $r) {
+ $table = $this->mytable.'_form_'.$r['table'];
+ $this->db->table($table)->where('cid', $id)->update(['catid' => $catid]);
+ for ($i = 0; $i < 200; $i ++) {
+ if (!$this->db->query("SHOW TABLES LIKE '".$table.'_data_'.$i."'")->getRowArray()) {
+ break;
+ }
+ $this->db->table($table.'_data_'.$i)->where('cid', $id)->update(['catid' => $catid]);
+ }
+ }
+ }
+
+ // 鍚屾鑷畾涔夋帴鍙
+ $this->_edit_category_row($t, $catid);
+ }
+
+ // 绉诲姩鏍忕洰鏃剁殑鑱斿姩缁ф壙绫
+ protected function _edit_category_row($row, $catid) {
+
+ }
+
+ // 鍙樻洿浣滆呯殑涓浜涜仈鍔ㄦ搷浣
+ protected function _edit_author_id($t) {
+
+ $id = intval($t['id']);
+ $uid = intval($t['uid']);
+
+ $this->db->table($this->mytable.'_time')->where('id', $id)->update(['uid' => $uid]);
+ $this->db->table($this->mytable.'_verify')->where('id', $id)->update(['uid' => $uid]);
+
+ // 鍚屾鑷畾涔夋帴鍙
+ $this->_edit_author_row($t);
+ }
+
+ // 浣滆呮椂鐨勮仈鍔ㄧ户鎵跨被
+ protected function _edit_author_row($row) {
+
+ }
+
+ // 鐢ㄤ簬琛ㄥ崟鍜岃瘎璁虹殑鍏叡鏂规硶==========================================
+
+ // 鑾峰彇涓绘暟鎹
+ public function get_row($id, $myid = 'id') {
+
+ if (!$id) {
+ return [];
+ }
+
+ $data = $this->table($this->mytable)->get($id);
+ if (!$data) {
+ return [];
+ }
+
+ $data['url'] = dr_url_prefix($data['url'], $this->dirname, $this->siteid, 0);
+ $data['is_comment'] = isset($data['is_comment']) ? $data['is_comment'] : 0;
+
+ return $data;
+ }
+
+ // 鑾峰彇璇勮瀵硅薄
+ public function comment() {
+ return \Phpcmf\Service::M('comment', 'comment')->_init($this, \Phpcmf\Service::C()->module['comment']);
+ }
+
+ // 鑾峰彇璇勮绱㈠紩鏁版嵁
+ public function get_comment_index($cid, $catid = 0) {
+
+ if (!dr_is_app('comment')) {
+ return [];
+ }
+
+ return $this->comment()->get_comment_index($cid);
+ }
+
+ // 鎻愪氦璇勮
+ // $value 涓婚淇℃伅鍜屽洖澶嶄汉锛$data璇勮鍐呭鍜岀偣璇勫唴瀹癸紱$my鑷畾涔夊瓧娈
+ public function insert_comment($value, $data, $my = []) {
+
+ if (!dr_is_app('comment')) {
+ return dr_return_data(0, dr_lang('娌℃湁瀹夎璇勮鎻掍欢'));
+ }
+
+ return $this->comment()->insert_comment($value, $data, $my);
+ }
+
+ // 瀹℃牳璇勮
+ public function verify_comment($row) {
+
+ if (!dr_is_app('comment')) {
+ return dr_return_data(0, dr_lang('娌℃湁瀹夎璇勮鎻掍欢'));
+ }
+
+ return $this->comment()->verify_comment($row);
+ }
+
+ // 鑾峰彇璇勮鍒楄〃
+ public function get_comment_result($cid, $order, $page, $pagesize, $total, $field) {
+
+ if (!dr_is_app('comment')) {
+ return [];
+ }
+
+ return $this->comment()->get_comment_result($cid, $order, $page, $pagesize, $total, $field);
+ }
+
+ // 鍒犻櫎璇勮
+ public function delete_comment($id, $cid = 0) {
+
+ if (!dr_is_app('comment')) {
+ return 0;
+ }
+
+ return $this->comment()->delete_comment($id, $cid = 0);
+ }
+
+ // 鏇存柊缁熻
+ public function comment_update_total($row) {
+
+ if (!dr_is_app('comment')) {
+ return;
+ }
+
+ return $this->comment()->comment_update_total($row);
+ }
+
+ // 鏇存柊璇勫垎
+ public function comment_update_review($row) {
+
+ if (!dr_is_app('comment')) {
+ return;
+ }
+
+ return $this->comment()->comment_update_review($row);
+
+ }
+
+ // 鑾峰彇琛ㄥ崟鏁版嵁
+ public function get_form_row($id, $form) {
+
+ if (!$id || !$form) {
+ return [];
+ }
+
+ $rt = $this->table($this->mytable.'_form_'.$form)->get($id);
+ if (!$rt) {
+ return [];
+ }
+
+ $rt2 = $this->table($this->mytable.'_form_'.$form.'_data_'.intval($rt['tableid']))->get($id);
+ if (!$rt2) {
+ return $rt;
+ }
+
+ return $rt + $rt2;
+ }
+
+ // 鏇存柊缁熻瀛楁
+ public function update_form_total($cid, $form) {
+
+ $total = $this->table($this->mytable.'_form_'.$form)->where('status', 1)->where('cid', $cid)->counts();
+ $this->table($this->mytable)->update($cid, [
+ $form.'_total' => $total,
+ ]);
+ }
+
+ // 鐢ㄦ埛涓績璁$畻瀹℃牳id
+ public function get_verify_status($id, $member, $auth) {
+
+ $verify = \Phpcmf\Service::C()->get_cache('verify');
+ if (!$verify) {
+ return 9;
+ } elseif (!$auth) {
+ return 9; // 榛樿涓嶈蛋瀹℃牳
+ }
+
+ $v = $verify[$auth];
+ if (!$v) {
+ return 9;
+ } elseif ($id && !$v['value']['edit']) {
+ return 9; // 淇敼涓嶅鏍
+ }
+
+ return 1; // 1 琛ㄧず杩涘叆瀹℃牳娴佺▼
+ }
+
+ // 瀹℃牳鏃跺欑殑鏉冮檺缁,杩斿洖鍙敤鏉冮檺缁勭殑id
+ // array(
+ // * to_uid 鎸囧畾浜
+ // * to_rid 鎸囧畾瑙掕壊缁
+ // * )
+ protected function _get_verify_roleid($catid, $status, $member) {
+
+ $verify = \Phpcmf\Service::C()->get_cache('verify');
+ if (!$verify) {
+ return ['to_uid' => 0, 'to_rid' => 0, 'verify_id' => 0];
+ }
+
+ if (IS_MEMBER) {
+ // 鍓嶇鎵剧敤鎴疯缃
+ $auth = \Phpcmf\Service::M('member_auth', 'cms')->category_auth(\Phpcmf\Service::C()->module, $catid, 'verify', $member);
+ } else {
+ // 鍚庡彴鎶曠ǹ鑰
+ $auth = \Phpcmf\Service::M('auth')->is_post_user_status();
+ }
+
+ if ($auth) {
+ $v = $verify[$auth];
+ $status = max(1, $status);
+ if ($v && isset($v['value']['role'][$status]) && $v['value']['role'][$status]) {
+ return ['to_uid' => 0, 'to_rid' => $v['value']['role'][$status], 'verify_id' => $v['id']];
+ }
+ }
+
+ return ['to_uid' => 0, 'to_rid' => 0, 'verify_id' => 0];
+ }
+
+ // 鏇存柊鏃堕棿
+ public function update_time($ids) {
+ $this->db->table($this->mytable)->whereIn('id', $ids)->update([
+ 'updatetime' => SYS_TIME,
+ ]);
+ }
+
+ // 鐢ㄦ埛涓績鑿滃崟
+ public function module_menu() {
+
+ return [
+ 'list' => [
+ 'name' => dr_lang('鍐呭绠$悊'),
+ 'icon' => dr_icon(\Phpcmf\Service::C()->module['icon']),
+ 'url' => \Phpcmf\Service::L('router')->member_url($this->dirname.'/home/index'),
+ ],
+ 'verify' => [
+ 'name' => dr_lang('瀹℃牳绠$悊'),
+ 'icon' => 'fa fa-edit',
+ 'url' => \Phpcmf\Service::L('router')->member_url($this->dirname.'/verify/index'),
+ ],
+ 'draft' => [
+ 'name' => dr_lang('鑽夌ǹ绠'),
+ 'icon' => 'fa fa-pencil',
+ 'url' => \Phpcmf\Service::L('router')->member_url($this->dirname.'/draft/index'),
+ ],
+ 'add' => [
+ 'name' => dr_lang('鍙戝竷鍐呭'),
+ 'icon' => 'fa fa-plus',
+ 'url' => \Phpcmf\Service::L('router')->member_url($this->dirname.'/home/add'),
+ ],
+ ];
+
+ }
+
+ // 鎸夐檮琛ㄥ垎琛
+ public function _table_id($id) {
+ return $this->get_table_id($id);
+ }
+
+ ////////////////////鍚庡彴鏉冮檺寮鏀////////////////////
+
+ // 鍚庡彴瀹℃牳鍒楄〃鏉′欢
+ public function get_admin_list_verify_where($where) {
+ return '(' . (\Phpcmf\Service::M('auth')->is_post_user() ? 'uid='.$this->uid.' OR ' : '')
+ . $this->get_admin_verify_status_list().')' . ($where ? ' AND '.$where : '');
+ }
+
+ // 鍚庡彴鍐呭瀹℃牳鍒楄〃鐨勬潈闄愮殑sql璇彞
+ public function get_admin_verify_status_list() {
+
+ if (dr_in_array(1, \Phpcmf\Service::C()->admin['roleid'])) {
+ return '`status`>=0'; // 瓒呯鐢ㄦ埛
+ } elseif (!IS_USE_MEMBER && !\Phpcmf\Service::M('auth')->is_post_user()) {
+ return '`status`>=0'; // 鏅氱鐞嗗憳
+ }
+
+ $verify = \Phpcmf\Service::C()->get_cache('verify');
+ if (!$verify) {
+ return '`status`=0'; // 娌℃湁瀹℃牳娴佺▼鏃
+ }
+
+ $where = [];
+ foreach ($verify as $t) {
+ if ($t['value']['role']) {
+ foreach ($t['value']['role'] as $status => $rid) {
+ if (is_array($rid)) {
+ if (dr_array_intersect($rid, \Phpcmf\Service::C()->admin['roleid'])) {
+ $where[] = '(`status`='.$status.' and `vid`='.$t['id'].')';
+ }
+ } else {
+ if (dr_in_array($rid, \Phpcmf\Service::C()->admin['roleid'])) {
+ $where[] = '(`status`='.$status.' and `vid`='.$t['id'].')';
+ }
+ }
+ }
+ }
+ }
+
+ // 姝ょ鐞嗗憳娌℃湁绠$悊鏉冮檺
+ if (!$where) {
+ return 'status=0';
+ }
+
+ return '`status` = 0 OR '.implode(' OR ', $where);
+ }
+
+ // 鍚庡彴鍐呭鍒楄〃鏉′欢
+ public function get_admin_list_where($table = '') {
+
+ if (\Phpcmf\Service::M('auth')->is_post_user()) {
+ // 浣滀负鎶曠ǹ鑰呭彧鑳藉厑璁哥湅鑷繁鐨勮褰
+ return 'uid = '.$this->uid;
+ }
+
+ return dr_is_app('cqx') ? \Phpcmf\Service::M('content', 'cqx')->get_list_where($table) : '';
+ }
+
+ // 鍚庡彴鍐呭缂栬緫鏉冮檺
+ public function admin_is_edit($data) {
+
+ if (\Phpcmf\Service::M('auth')->is_post_user()) {
+ if ($data['uid'] == $this->uid) {
+ return false;
+ }
+ return !$data['uid'] ? false : true;
+ }
+
+ if (dr_is_app('cqx')) {
+ $cqx = \Phpcmf\Service::M('content', 'cqx');
+ if (method_exists($cqx, 'is_edit')) {
+ return $cqx->is_edit((int)$data['catid'], (int)$data['uid']);
+ } elseif (method_exists($cqx, 'is_edit_v2')) {
+ return $cqx->is_edit2($data);
+ }
+
+ }
+
+ return true;
+ }
+
+ ////////////////////浜屾寮鍙戣皟鐢////////////////////
+
+ // 鍐呭鍙戝竷涔嬪墠
+ // 閿欒淇℃伅杩斿洖鏍煎紡锛歳eturn dr_return_data(0, '閿欒淇℃伅')
+ public function _content_post_before($id, $data, $old) {
+ return $data;
+ }
+
+ // 鍐呭鍙戝竷涔嬪悗
+ public function _content_post_after($id, $data, $old) { }
+
+ // 鍐呭鍒犻櫎涔嬪悗
+ public function _delete_content($id, $row) { }
+
+ // 鍐呭鍥炴敹绔欎箣鍚
+ public function _recycle_content($id, $row, $note) { }
+
+ // 鍐呭鎭㈠涔嬪悗
+ public function _recovery_content($id, $row) { }
+
+ // 鎵撹祻鎴愬姛涔嬪悗
+ public function _content_donation_after($id, $pay) { }
+
+ // 鍐呭鍒舵垚鍔熶箣鍚
+ public function _content_copy_after($id, $save) { }
+
+ // 鍐呭瀹℃牳鎿嶄綔涔嬪悗
+ public function _call_verify($data, $verify) { }
+
+ // 璇勮鎴愬姛鎿嶄綔涔嬪悗
+ public function _comment_after($data) { }
+
+ // 鏍煎紡鍖栧鐞嗗唴瀹癸紝鐢ㄤ簬鑾峰彇鍐呭鏁版嵁鍚庣殑鏍煎紡鍖
+ public function _format_content_data($data) {
+ return $data;
+ }
+
+ // 鐢ㄤ簬鍓嶇妯″潡棣栭〉鐨勬墽琛屾柟娉
+ public function _call_index() { }
+
+ // 鏍煎紡鍖栨樉绀哄唴瀹,鐢ㄤ簬鍓嶇鍐呭鏍忕洰椤甸潰鐨勬牸寮忓寲
+ public function _call_category($data) {
+ return $data;
+ }
+
+ // 鏍煎紡鍖栨樉绀哄唴瀹,鐢ㄤ簬鍓嶇鍐呭鎼滅储椤甸潰鐨勬牸寮忓寲
+ public function _call_search($data) {
+ return $data;
+ }
+
+ // 鏍煎紡鍖栨樉绀哄唴瀹,鐢ㄤ簬鍓嶇鍐呭璇︽儏椤甸潰鐨勬牸寮忓寲
+ public function _call_show($data) {
+ return $data;
+ }
+
+ // 鏍煎紡鍖栨爮鐩畇eo淇℃伅
+ public function _format_category_seo($mod, $catid, $page) {
+
+ $cat = dr_cat_value($mod['mid'], $catid);
+ $cat['page'] = intval($page);
+ $cat['name'] = $cat['catname'] = $cat['name'];
+ $cat['catpname'] = dr_get_cat_pname($mod, $catid, SITE_SEOJOIN);
+ $cat['modulename'] = $cat['modname'] = $mod['dirname'] == 'share' ? '': dr_lang($mod['name']);
+
+ if (!$mod['share'] && (!isset($mod['site'][SITE_ID]['is_cat']) || !$mod['site'][SITE_ID]['is_cat'])) {
+ // 鐙珛妯″潡缁熶竴瑙勫垯妯″紡
+ $seo = $mod['site'][SITE_ID];
+ } else {
+ $seo = $cat['setting']['seo'];
+ }
+
+ $meta_title = $seo['list_title'] ? $seo['list_title'] : '['.dr_lang('绗%s椤', '{page}').'{join}]{SITE_NAME}';
+ $meta_title = $page > 1 ? str_replace(['[', ']'], '', $meta_title) : preg_replace('/\[(.+)\]/U', '', $meta_title);
+
+ return \Phpcmf\Service::L('Seo')->get_seo_value($cat, [
+ 'meta_title' => $meta_title,
+ 'meta_keywords' => isset($seo['list_keywords']) && $seo['list_keywords'] ? $seo['list_keywords'] : ($mod['site'][SITE_ID]['module_keywords'] ? $mod['site'][SITE_ID]['module_keywords'] : \Phpcmf\Service::C()->get_cache('site', SITE_ID, 'seo', 'SITE_KEYWORDS')),
+ 'meta_description' => isset($seo['list_description']) && $seo['list_description'] ? $seo['list_description'] : ($mod['site'][SITE_ID]['module_description'] ? $mod['site'][SITE_ID]['module_description'] : \Phpcmf\Service::C()->get_cache('site', SITE_ID, 'seo', 'SITE_DESCRIPTION')),
+ ]);
+
+
+ }
+
+ // 鏍煎紡鍖栭椤祍eo淇℃伅
+ public function _format_home_seo($mod) {
+
+ $seo = [];
+
+ $seo['meta_title'] = $mod['site'][SITE_ID]['module_title'] ? $mod['site'][SITE_ID]['module_title'] : $mod['name'].SITE_SEOJOIN.SITE_NAME;
+ $seo['meta_keywords'] = $mod['site'][SITE_ID]['module_keywords'];
+
+ $seo['meta_title'] = htmlspecialchars(dr_clearhtml($seo['meta_title']));
+ $seo['meta_description'] = $mod['site'][SITE_ID]['module_description'];
+ $seo['meta_description'] = htmlspecialchars(dr_clearhtml($seo['meta_description']));
+
+ if (strpos($seo['meta_title'], '{page}') !== false) {
+ $page = max(1, intval($_GET['page']));
+ if ($page > 1) {
+ $seo['meta_title'] = str_replace(array('[', ']'), '', $seo['meta_title']);
+ $seo['meta_title'] = str_replace('{join}', SITE_SEOJOIN, $seo['meta_title']);
+ $seo['meta_title'] = str_replace('{page}', $page, $seo['meta_title']);
+ } else {
+ $seo['meta_title'] = preg_replace('/\[.+\]/U', '', $seo['meta_title']);
+ }
+ }
+
+ if (!$seo['meta_keywords']) {
+ // 鐣欑┖鏃朵娇鐢ㄤ富绔檚eo
+ $seo['meta_keywords'] = \Phpcmf\Service::C()->get_cache('site', SITE_ID, 'seo', 'SITE_KEYWORDS');
+ }
+
+ if (!$seo['meta_description']) {
+ // 鐣欑┖鏃朵娇鐢ㄤ富绔檚eo
+ $seo['meta_description'] = \Phpcmf\Service::C()->get_cache('site', SITE_ID, 'seo', 'SITE_DESCRIPTION');
+ }
+
+ return \Phpcmf\Service::L('Seo')->get_seo_value([], $seo);
+ }
+
+ // 鏍煎紡鍖栧唴瀹归〉seo淇℃伅
+ public function _format_show_seo($mod, $data, $page) {
+
+ $data['cat'] = $cat = dr_cat_value($mod['mid'], $data['catid']);
+ $data['page'] = $page;
+ $data['name'] = $data['catname'] = $cat['name'];
+ //$data['title'] = dr_clearhtml($data['title']);
+ $data['catname'] = $data['cat.name'] = $cat['name'];
+ $data['catpname'] = $data['cat.pname'] = dr_get_cat_pname($mod, $data['catid'], SITE_SEOJOIN);
+ foreach ($cat as $i => $t) {
+ $data['cat.'.$i] = $t;
+ }
+ $data['modulename'] = $data['modname'] = dr_lang($mod['name']);
+ $data['modulename'] = $data['modname'] = $mod['dirname'] == 'share' ? '': dr_lang($mod['name']);
+
+ $data['keywords'] = htmlspecialchars(dr_safe_replace(dr_clearhtml($data['keywords'])));
+ $data['description'] = htmlspecialchars(dr_safe_replace(dr_clearhtml($data['description'])));
+
+ $meta_title = isset($mod['site'][SITE_ID]['show_title']) && $mod['site'][SITE_ID]['show_title'] ? $mod['site'][SITE_ID]['show_title'] : '['.dr_lang('绗%s椤', '{page}').'{join}]{title}{join}{catpname}{join}{SITE_NAME}';
+ $meta_title = $page > 1 ? str_replace(['[', ']'], '', $meta_title) : preg_replace('/\[(.+)\]/U', '', $meta_title);
+
+ return \Phpcmf\Service::L('Seo')->get_seo_value($data, [
+ 'meta_title' => $meta_title,
+ 'meta_keywords' => isset($mod['site'][SITE_ID]['show_keywords']) && $mod['site'][SITE_ID]['show_keywords'] ? $mod['site'][SITE_ID]['show_keywords'] : $data['keywords'],
+ 'meta_description' => isset($mod['site'][SITE_ID]['show_description']) && $mod['site'][SITE_ID]['show_description'] ? $mod['site'][SITE_ID]['show_description'] : $data['description'],
+ ]);
+
+ }
+
+ // 鏍煎紡鍖栧唴瀹规悳绱eo淇℃伅
+ public function _format_search_seo($mod, $catid, $param, $page) {
+
+ $seo = [];
+ $seo['meta_keywords'] = '';
+
+ $data['page'] = $page > 1 ? $page : '';
+ $data['param'] = '';
+ $data['keyword'] = '';
+ $data['modulename'] = $data['modname'] = $mod['dirname'] == 'share' ? '': dr_lang($mod['name']);
+
+ $param_value = [];
+ if ($param['keyword']) {
+ $param_value['keyword'] = $data['keyword'] = urldecode($param['keyword']);
+ unset($param['keyword']);
+ }
+ if ($param['groupid']) {
+ $data['groupid'] = $param['groupid'];
+ }
+ if ($param['updatetime']) {
+ $param_value['updatetime'] = $param['updatetime'];
+ }
+
+ if ($catid) {
+ $t = dr_get_cat_pname($mod, $catid, SITE_SEOJOIN);
+ if ($t) {
+ $param_value['catid'] = $t;
+ }
+ unset($param['catid']);
+ unset($param['catdir']);
+ }
+
+ if ($param) {
+ $myfield = $mod['field'];
+ if ($catid) {
+ $cat_field = $mod['category_data_field'];
+ $cat_field && $myfield = dr_array22array($myfield, $cat_field);
+ }
+
+ $seofield = $myfield;
+ foreach ($param as $name => $value) {
+ $now_field = [];
+ if (isset($myfield[$name])) {
+ // 妯″潡瀛楁
+ $now_field = $myfield[$name];
+ } elseif ($name == 'flag') {
+ // 鎺ㄨ崘浣
+ if ($value) {
+ $flag = $mod['setting']['flag'];
+ $arr = explode('|', $value);
+ if ($arr) {
+ foreach ($arr as $a) {
+ if (isset($flag[$a]) && $flag[$a]) {
+ $param_value[$name][] = $flag[$a]['name'];
+ }
+ }
+ }
+ }
+ continue;
+ } elseif ($name == 'groupid') {
+ // 浼氬憳缁勫悕绉
+ if ($value) {
+ $param_value[$name] = \Phpcmf\Service::C()->member_cache['group'][$value]['name'];
+ }
+ continue;
+ } elseif (isset(\Phpcmf\Service::C()->member_cache['field'][$name])) {
+ // 浼氬憳瀛楁
+ $now_field = \Phpcmf\Service::C()->member_cache['field'][$name];
+ $seofield[$name] = $now_field;
+ }
+ // 鎸夊瓧娈靛睘鎬х粍鍚
+ if ($now_field) {
+ switch ($now_field['fieldtype']) {
+
+ case 'Radio':
+ case 'Select':
+ case 'Selects':
+ case 'Checkbox':
+ $opt = dr_format_option_array($now_field['setting']['option']['options']);
+ $arr = explode('|', $value);
+ if ($arr) {
+ foreach ($arr as $a) {
+ if (isset($opt[$a]) && $opt[$a]) {
+ $param_value[$name][] = $opt[$a];
+ }
+ }
+ }
+ break;
+
+ case 'Linkages':
+ case 'Linkage':
+ $arr = explode('|', $value);
+ if ($arr) {
+ foreach ($arr as $a) {
+ $param_value[$name][] = dr_linkagepos($now_field['setting']['option']['linkage'], $a, SITE_SEOJOIN);
+ }
+ }
+ break;
+
+
+ case 'Cat':
+ case 'Cats':
+ case 'Catid':
+ $arr = explode('|', $value);
+ if ($arr) {
+ foreach ($arr as $a) {
+ $param_value[$name][] = dr_cat_value($now_field['setting']['option']['module'], $a, 'name');
+ }
+ }
+ break;
+ case 'Related':
+ if ($now_field['setting']['option']['module']) {
+ $arr = explode('|', $value);
+ if ($arr) {
+ foreach ($arr as $a) {
+ $row = $this->table_site($now_field['setting']['option']['module'])->get($a);
+ $row && $param_value[$name][] = $row['title'];
+ }
+ }
+ }
+ break;
+
+ default:
+ $value && $param_value[$name] = $value;
+ break;
+ }
+ }
+ }
+ }
+
+ $meta_title = $mod['site'][SITE_ID]['search_title'] ? $mod['site'][SITE_ID]['search_title'] : '['.dr_lang('绗%s椤', '{page}').'{join}][{keyword}{join}][{param}{join}]{SITE_NAME}';
+ $seo['param_value'] = [];
+ if ($param_value) {
+ $str = [];
+ $seofield['catid'] = $seofield['catdir'] = [ 'name' => dr_lang('鏍忕洰') ];
+ $seofield['groupid'] = ['name' => dr_lang('鐢ㄦ埛缁')];
+ $seofield['flag'] = ['name' => dr_lang('鎺ㄨ崘浣')];
+ $seofield['keyword'] = ['name' => dr_lang('鍏抽敭璇')];
+ $seofield['updatetime'] = ['name' => dr_lang('鏇存柊鏃堕棿')];
+ $db = \Phpcmf\Service::C()->content_model;
+ if ($db) {
+ list($seofield, $param_value) = $db->_format_search_param_value($seofield, $param_value);
+ }
+ foreach ($param_value as $f => $t) {
+ $seo['param_value'][$f] = [
+ 'name' => $seofield[$f]['name'],
+ 'value' => is_array($t) ? implode('|', $t) : $t,
+ 'value_array' => is_array($t) ? $t : [],
+ ];
+ $str[$f] = is_array($t) ? implode('|', $t) : $t;
+ }
+
+ // 閬垮厤閲嶅keyword
+ if (isset($str['keyword']) && strpos($meta_title, 'keyword') !== false) {
+ unset($str['keyword']);
+ }
+ $data['param'] = implode(SITE_SEOJOIN, $str);
+ }
+
+ if (preg_match_all('/\[.*\{(.+)\}.*\]/U', $meta_title, $m)) {
+ $new = '';
+ $replace = '';
+ foreach ($m[1] as $i => $field) {
+ $replace.= $m[0][$i];
+ if (isset($data[$field]) && strlen($data[$field])) {
+ $new.= str_replace(['[', ']'], '', $m[0][$i]);
+ }
+ }
+ $meta_title = str_replace($replace, $new, $meta_title);
+ }
+ return \Phpcmf\Service::L('Seo')->get_seo_value($data, [
+ 'meta_title' => $meta_title,
+ 'param_value' => $seo['param_value'],
+ 'meta_keywords' => $seo['meta_keywords'] ? $seo['meta_keywords'] : (isset($mod['site'][SITE_ID]['search_keywords']) && $mod['site'][SITE_ID]['search_keywords'] ? $mod['site'][SITE_ID]['search_keywords'] : \Phpcmf\Service::C()->get_cache('site', SITE_ID, 'seo', 'SITE_KEYWORDS')),
+ 'meta_description' => isset($mod['site'][SITE_ID]['search_description']) && $mod['site'][SITE_ID]['search_description'] ? $mod['site'][SITE_ID]['search_description'] : \Phpcmf\Service::C()->get_cache('site', SITE_ID, 'seo', 'SITE_DESCRIPTION'),
+ ]);
+ }
+
+
+ // 鏍煎紡鍖栧唴瀹规悳绱㈢殑param鍙傛暟鍚嶇О鍊
+ public function _format_search_param_value($myfield, $param) {
+ return [$myfield, $param];
+ }
+
+ ////////////////////绂佺敤鏍忕洰鏃讹紝浜屾寮鍙戣皟鐢////////////////////
+
+ // 绂佺敤鏍忕洰鏃讹紝鐢ㄦ埛淇濆瓨鍐呭涔嬪墠鐨勬潈闄愰獙璇
+ public function _hcategory_member_save_before($data) {
+ return $data;
+ }
+
+ // 绂佺敤鏍忕洰鏃讹紝鐢ㄦ埛淇濆瓨鍐呭鏃剁殑鍐呭鏂囩珷鐘舵 $id 鍐呭id
+ public function _hcategory_member_post_status($id) {
+ return 9;
+ }
+
+ // 绂佺敤鏍忕洰鏃讹紝鐢ㄦ埛璇勮鏃剁殑鐘舵
+ public function _hcategory_member_comment_status() {
+ return 1;
+ }
+
+ // 绂佺敤鏍忕洰鏃讹紝鐢ㄦ埛淇濆瓨鍐呭鏃舵槸鍚﹀惎鐢ㄩ獙璇佺爜
+ public function _hcategory_member_post_code() {
+ return 0;
+ }
+
+ // 绂佺敤鏍忕洰鏃讹紝鐢ㄦ埛鍙戝竷鍐呭鏃剁殑鏉冮檺楠岃瘉
+ public function _hcategory_member_add_auth() {
+ return dr_return_data(1, 'ok');
+ }
+
+ // 绂佺敤鏍忕洰鏃讹紝鐢ㄦ埛璇勮鏃剁殑鏉冮檺楠岃瘉
+ public function _hcategory_member_comment_auth() {
+ return dr_return_data(1, 'ok');
+ }
+
+ // 绂佺敤鏍忕洰鏃讹紝鐢ㄦ埛淇敼鍐呭鏃剁殑鏉冮檺楠岃瘉
+ public function _hcategory_member_edit_auth() {
+ return dr_return_data(1, 'ok');
+ }
+
+ // 绂佺敤鏍忕洰鏃讹紝鐢ㄦ埛鍒犻櫎鍐呭鏃剁殑鏉冮檺楠岃瘉
+ public function _hcategory_member_del_auth() {
+ return dr_return_data(1, 'ok');
+ }
+
+ // 绂佺敤鏍忕洰鏃讹紝鐢ㄦ埛闃呰鍐呭鏃剁殑鏉冮檺楠岃瘉
+ public function _hcategory_member_show_auth() {
+ return dr_return_data(1, 'ok');
+ }
+
+}
+
+
+namespace Phpcmf\Model;
+class Content extends \Phpcmf\Model\Cms\Content {
+
+}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Models/Member_auth.php b/dayrui/App/Cms/Models/Member_auth.php
new file mode 100644
index 0000000..f361f34
--- /dev/null
+++ b/dayrui/App/Cms/Models/Member_auth.php
@@ -0,0 +1,139 @@
+_reload_auth();
+ }
+
+ // 姣忔浠庝細鍛樼紦瀛橀噸鏂拌鍙栵紝閬垮厤鍗曚緥鏋勯犺繃鏃╁鑷 auth 涓虹┖
+ protected function _reload_auth() {
+ $this->auth = isset(\Phpcmf\Service::C()->member_cache['auth2'][SITE_ID])
+ ? \Phpcmf\Service::C()->member_cache['auth2'][SITE_ID] : [];
+ $auth_type = \Phpcmf\Service::C()->member_cache['auth_type'] ?? 0;
+ // [] / null / "" 閮芥寜鍏ㄥ眬 0 澶勭悊锛坉r_string2array("0") 浼氬緱鍒 []锛
+ $this->auth_type = is_numeric($auth_type) ? intval($auth_type) : 0;
+ }
+
+ // 褰撳墠鐧诲綍浼氬憳鐨勬潈闄愭爣璇
+ protected function _get_groupid($member) {
+
+ $auth_type = is_numeric($this->auth_type) ? intval($this->auth_type) : 0;
+
+ if ($auth_type == 1) {
+ $groupid = $member && !empty($member['groupid']) ? $member['groupid'] : [0];
+ } elseif ($auth_type == 2) {
+ $groupid = $member && !empty($member['authid']) ? $member['authid'] : [0];
+ } else {
+ $groupid = ['public'];
+ }
+
+ if (!is_array($groupid)) {
+ $groupid = [$groupid];
+ }
+
+ return $groupid ? array_values($groupid) : [0];
+ }
+
+ // 鍙栨煇涓 aid 涓嬬殑鏍忕洰鏉冮檺閰嶇疆
+ protected function _category_auth_row($gid, $module, $catid) {
+
+ $mid = isset($module['dirname']) ? $module['dirname'] : '';
+ if (!$mid && defined('APP_DIR')) {
+ $mid = APP_DIR;
+ }
+
+ if (!empty($module['share'])) {
+ if (!empty($this->auth[$gid]['home']['is_category'])) {
+ $this->is_category_public = 0;
+ return isset($this->auth[$gid]['share_category'][$catid])
+ ? $this->auth[$gid]['share_category'][$catid] : [];
+ }
+ $this->is_category_public = 1;
+ return isset($this->auth[$gid]['share_category_public'])
+ ? $this->auth[$gid]['share_category_public'] : [];
+ }
+
+ if (!empty($this->auth[$gid]['module'][$mid]['is_category'])) {
+ $this->is_category_public = 0;
+ return isset($this->auth[$gid]['category'][$mid][$catid])
+ ? $this->auth[$gid]['category'][$mid][$catid] : [];
+ }
+ $this->is_category_public = 1;
+ return isset($this->auth[$gid]['category_public'][$mid])
+ ? $this->auth[$gid]['category_public'][$mid] : [];
+ }
+
+ // 绔欑偣鏉冮檺
+ public function home_auth($name, $member = []) {
+
+ $this->_reload_auth();
+ $values = [];
+ foreach ($this->_get_groupid($member) as $gid) {
+ if (isset($this->auth[$gid]['home'][$name])) {
+ $values[] = $this->auth[$gid]['home'][$name];
+ }
+ }
+
+ return $values ? max($values) : null;
+ }
+
+ // 妯″潡鏉冮檺
+ public function module_auth($mid, $name, $member = []) {
+
+ $this->_reload_auth();
+ $values = [];
+ foreach ($this->_get_groupid($member) as $gid) {
+ if (isset($this->auth[$gid]['module'][$mid][$name])) {
+ $values[] = $this->auth[$gid]['module'][$mid][$name];
+ }
+ }
+
+ return $values ? max($values) : null;
+ }
+
+ // 鏍忕洰鏉冮檺
+ public function category_auth($module, $catid, $name, $member = []) {
+
+ $this->_reload_auth();
+ $values = [];
+ $this->is_category_public = 0;
+ $groupid = $this->_get_groupid($member);
+ $has_config = false;
+
+ foreach ($groupid as $gid) {
+ $auth = $this->_category_auth_row($gid, $module, $catid);
+ if ($auth) {
+ // 鏈粍宸叉湁鏍忕洰鏉冮檺閰嶇疆锛氭湭鍕鹃夌殑椤硅涓哄叧闂紝涓嶈兘鍐嶅洖閫 public
+ $has_config = true;
+ if (isset($auth[$name])) {
+ $values[] = $auth[$name];
+ }
+ } elseif ($name === 'show') {
+ $values[] = 1; // 榛樿娌″嬀閫夋椂璁块棶寮鏀
+ }
+ }
+
+ // 鎸夌敤鎴风粍/绛夌骇鏃讹紝浠呭綋鏈粍瀹屽叏娌℃湁鏍忕洰鏉冮檺閰嶇疆锛屾墠鍥為 public
+ if (!$has_config && !$values && !in_array('public', $groupid, true) && isset($this->auth['public'])) {
+ $auth = $this->_category_auth_row('public', $module, $catid);
+ if (isset($auth[$name])) {
+ $values[] = $auth[$name];
+ } elseif (!$auth && $name === 'show') {
+ $values[] = 1;
+ }
+ }
+
+ return $values ? max($values) : null;
+ }
+
+}
diff --git a/dayrui/App/Cms/Models/Menu.php b/dayrui/App/Cms/Models/Menu.php
new file mode 100644
index 0000000..1a0ef90
--- /dev/null
+++ b/dayrui/App/Cms/Models/Menu.php
@@ -0,0 +1,88 @@
+is_table_exists('member_menu') && $this->db->query('UPDATE `'.$this->dbprefix('member_menu').'` SET '.$replace.' WHERE uri="'.$mid.'/home/index"');
+
+ $this->db->query('UPDATE `'.$this->dbprefix('admin_menu').'` SET '.$replace.' WHERE uri="'.$mid.'/home/index"');
+ $this->db->query('UPDATE `'.$this->dbprefix('admin_menu').'` SET '.$replace.' WHERE uri="'.$mid.'/verify/index"');
+ $this->db->query('UPDATE `'.$this->dbprefix('admin_menu').'` SET '.$replace.' WHERE uri="'.$mid.'/comment_verify/index"');
+
+ $this->db->query('UPDATE `'.$this->dbprefix('admin_min_menu').'` SET '.$replace.' WHERE uri="'.$mid.'/home/index"');
+ $this->db->query('UPDATE `'.$this->dbprefix('admin_min_menu').'` SET '.$replace.' WHERE uri="'.$mid.'/verify/index"');
+ $this->db->query('UPDATE `'.$this->dbprefix('admin_min_menu').'` SET '.$replace.' WHERE uri="'.$mid.'/comment_verify/index"');
+ }
+
+ // 浠庢ā鍧椾腑鏇存柊鑿滃崟
+ public function update_module($mdir, $config, $form) {
+
+ // 浣滀负搴旂敤妯″潡鏃朵笖涓嶆搷浣渕enu.php鏃,涓嶉渶瑕佽彍鍗
+ if (isset($config['ftpye']) && $config['ftpye'] == 'module'
+ && is_file(dr_get_app_dir($mdir).'Config/Menu.php')) {
+ return;
+ }
+
+ // 鍐呭妯″潡 鍏ュ簱鍚庡彴鑿滃崟
+ if ($config['system'] == 1) {
+ foreach (['admin', 'admin_min'] as $table) {
+ $left = $this->db->table($table.'_menu')->where('mark', 'content-module')->get()->getRowArray();
+ if ($left) {
+ // 鏌ヨ妯″潡鑿滃崟
+ $menu = $this->db->table($table.'_menu')->where('mark', 'module-'.$mdir)->get()->getRowArray();
+ $save = [
+ 'uri' => $mdir.'/home/index',
+ 'mark' => 'module-'.$mdir,
+ 'name' => $menu && $menu['name'] ? $menu['name'] : dr_lang('%s绠$悊', $config['name']),
+ 'icon' => $menu && $menu['icon'] ? $menu['icon'] : dr_icon($config['icon']),
+ 'displayorder' => $menu ? intval($menu['displayorder']) : '-1',
+ ];
+ $menu ? \Phpcmf\Service::M('menu')->_edit($table, $menu['id'], $save) : \Phpcmf\Service::M('menu')->_add($table, $left['id'], $save);
+ }
+ // 鍏ュ簱鍚庡彴瀹℃牳鑿滃崟
+ $left = $this->db->table($table.'_menu')->where('mark', 'content-verify')->get()->getRowArray();
+ if ($left) {
+ // 鍐呭妯″潡鍏ュ簱
+ if ($config['system'] == 1) {
+ $menu = $this->db->table($table.'_menu')->where('mark', 'verify-module-'.$mdir)->get()->getRowArray();
+ $save = [
+ 'uri' => $mdir.'/verify/index',
+ 'mark' => 'verify-module-'.$mdir,
+ 'name' => $menu && $menu['name'] ? $menu['name'] : dr_lang('%s瀹℃牳', $config['name']),
+ 'icon' => $menu && $menu['icon'] ? $menu['icon'] : dr_icon($config['icon']),
+ 'displayorder' => $menu ? intval($menu['displayorder']) : '-1',
+ ];
+ $menu ? \Phpcmf\Service::M('menu')->_edit($table, $menu['id'], $save) : \Phpcmf\Service::M('menu')->_add($table, $left['id'], $save);
+ }
+ // 琛ㄥ崟鍏ュ簱
+ if ($form && dr_is_app('mform')) {
+ \Phpcmf\Service::M('mform', 'mform')->link_menu($form, $table, $mdir, $config, $left);
+ }
+ }
+ }
+ }
+
+ // 鍐呭妯″潡鍏ュ簱鐢ㄦ埛鑿滃崟
+ if ($config['system'] == 1 && $this->is_table_exists('member_menu')) {
+ $left = $this->db->table('member_menu')->where('mark', 'content-module')->get()->getRowArray();
+ if ($left) {
+ // 鏌ヨ妯″潡鑿滃崟
+ $menu = $this->db->table('member_menu')->where('mark', 'module-'.$mdir)->get()->getRowArray();
+ $save = [
+ 'uri' => $mdir.'/home/index',
+ 'mark' => 'module-'.$mdir,
+ 'name' => $menu && $menu['name'] ? $menu['name'] : dr_lang('%s绠$悊', $config['name']),
+ 'icon' => $menu && $menu['icon'] ? $menu['icon'] : dr_icon($config['icon']),
+ 'displayorder' => $menu ? intval($menu['displayorder']) : '-1',
+ ];
+ $menu ? \Phpcmf\Service::M('menu')->_edit('member', $menu['id'], $save) : \Phpcmf\Service::M('menu')->_add('member', $left['id'], $save);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Models/Module.php b/dayrui/App/Cms/Models/Module.php
new file mode 100644
index 0000000..0eb1427
--- /dev/null
+++ b/dayrui/App/Cms/Models/Module.php
@@ -0,0 +1,1248 @@
+table('module')->order_by('displayorder ASC,id ASC')->getAll();
+ if ($list && $is_file_name) {
+ foreach ($list as $i => $t) {
+ if (is_file(dr_get_app_dir($t['dirname']).'Config/App.php')) {
+ $cfg = require dr_get_app_dir($t['dirname']).'Config/App.php';
+ if ($cfg['type'] == 'module' || $cfg['ftype'] == 'module') {
+ $list[$i]['name'] = $cfg['name'];
+ }
+ }
+ }
+ }
+ return $list;
+ }
+
+ // 鏉冮檺鍒掑垎鎿嶄綔鏉冮檺
+ public function module_auth() {
+
+ $module = \Phpcmf\Service::M()->db->table('module')->get()->getResultArray();
+ $module_auth = [];
+ if ($module) {
+ foreach ($module as $t) {
+ $mdir = $t['dirname'];
+ $path = dr_get_app_dir($mdir);
+ if (!is_file($path.'Config/App.php')) {
+ continue;
+ }
+ $config = require $path.'Config/App.php';
+ $module_auth[$mdir] = [
+ 'name' => dr_lang($config['name']),
+ 'auth' => [],
+ ];
+ if (!$t['share']) {
+ $module_auth[$mdir]['auth'][$mdir.'/category/'] = dr_lang('鏍忕洰');
+ }
+ if ($config['system']) {
+ // 鍐呭妯″潡
+ $module_auth[$mdir]['auth'][$mdir.'/home/'] = dr_lang('鍐呭');
+ $module_auth[$mdir]['auth'][$mdir.'/draft/'] = dr_lang('鑽夌ǹ绠');
+ $module_auth[$mdir]['auth'][$mdir.'/recycle/'] = dr_lang('鍥炴敹绔');
+ $module_auth[$mdir]['auth'][$mdir.'/time/'] = dr_lang('瀹氭椂鍙戝竷');
+ $module_auth[$mdir]['auth'][$mdir.'/verify/'] = dr_lang('寰呭鏍');
+ } else {
+ // 鑷畾涔夋ā鍧
+ }
+ if (dr_is_app('comment')) {
+ $module_auth[$mdir]['auth'][$mdir.'/comment/'] = dr_lang('鍐呭璇勮');
+ }
+ $mform = \Phpcmf\Service::M()->is_table_exists('module_form') ? \Phpcmf\Service::M()->db->table('module_form')->where('module', $mdir)->get()->getResultArray() : [];
+ if ($mform) {
+ foreach ($mform as $c) {
+ $module_auth[$mdir]['auth'][$mdir.'/'.$c['table'].'/'] = dr_lang($c['name']);
+ }
+ }
+ }
+ }
+
+ return $module_auth;
+ }
+
+ // 瀛樺偍閰嶇疆淇℃伅
+ public function config($data, $post, $value = []) {
+
+ $update = $post ? [ 'setting' => $post['setting'] ] : [ 'setting' => $data['setting'] ];
+
+ // 鎺ㄨ崘浣嶆洿鏂
+ if ($value['flag']) {
+ $update['setting']['flag'] = [];
+ foreach ($value['flag'] as $i => $t) {
+ $t['name'] && $update['setting']['flag'][$i] = $t;
+ }
+ } else {
+ $update['setting']['flag'] = $data['setting']['flag'];
+ }
+
+ // 杩欓噷涓嶆洿鏂扮珯鐐
+ $update['setting']['param'] = $data['setting']['param'];
+ $update['setting']['search'] = $data['setting']['search'];
+
+ // 绔欑偣鏇存柊
+ if ($value['site']) {
+ $site = $data['site'];
+ $value['site']['use'] = 1;
+ $site[SITE_ID] = $value['site'];
+ $update['site'] = dr_array2string($site);
+ }
+
+ // 鎺掑垪table瀛楁椤哄簭
+ $update['setting']['list_field'] = dr_list_field_order($update['setting']['list_field']);
+
+ $update['setting'] = dr_array2string($update['setting']);
+
+ // 鏇存柊琛
+ return $this->table('module')->update(intval($data['id']), $update);
+ }
+
+ // 鑾峰彇褰掑睘浜庢湰妯″潡鐨勬爮鐩叧绯
+ protected function _get_my_category($mdir, $CAT) {
+
+ foreach ($CAT as $i => $t) {
+ if (!$t['child'] && $t['tid'] == 1 && $t['mid'] != $mdir) {
+ unset($CAT[$i]);
+ }
+ // 楠岃瘉mid
+ if ($CAT[$t['id']]['catids']) {
+ $mid = [];
+ foreach ($CAT[$t['id']]['catids'] as $c_catid) {
+ if ($CAT[$c_catid]['mid']) {
+ $mid[$CAT[$c_catid]['mid']] = 1;
+ }
+ }
+ if (!$mid) {
+ unset($CAT[$t['id']]);
+ } elseif (!isset($mid[$mdir])) {
+ unset($CAT[$t['id']]);
+ }
+ }
+ }
+
+ return $CAT;
+ }
+
+ // 瀹夎妯″潡
+ public function install($dir, $config = [], $is_app = 0, $is_share = 0) {
+
+ $dir = strtolower($dir);
+ $mpath = dr_get_app_dir($dir);
+ $spath = dr_get_app_dir('module');
+ if (!$config) {
+ if (!is_file($mpath.'Config/App.php')) {
+ return dr_return_data(0, dr_lang('妯″潡閰嶇疆鏂囦欢涓嶅瓨鍦'));
+ }
+ $config = require $mpath.'Config/App.php';
+ }
+
+ // 瀹夎鍓嶇殑鍒ゆ柇
+ if (is_file($mpath.'Config/Before.php')) {
+ $rt = require $mpath.'Config/Before.php';
+ if (!$rt['code']) {
+ return dr_return_data(0, $rt['msg']);
+ }
+ }
+
+ $table = $this->dbprefix(dr_module_table_prefix($dir)); // 褰撳墠琛ㄥ墠缂
+ $system_table = require $spath.'Config/SysTable.php';
+ if (!$system_table ) {
+ return dr_return_data(0, dr_lang('绯荤粺琛ㄩ厤缃枃浠朵笉瀛樺湪'));
+ }
+
+ // 鍒ゆ柇鏄惁寮哄埗鐙珛妯″潡鎴栧叡浜ā鍧
+ if ($is_share) {
+ $config['share'] = $is_share == 1 ? 1 : 0; // 寮哄埗鍏变韩瀹夎
+ } elseif (isset($config['mtype']) && $config['mtype']) {
+ $config['share'] = $config['mtype'] == 2 ? 0 : 1;
+ }
+
+ // 妯″潡鍐呭琛ㄧ粨鏋勫拰瀛楁缁撴瀯
+ if (is_file($mpath.'Config/Content.php')) {
+ $content_table = require $mpath.'Config/Content.php';
+ } else {
+ $content_table = require $spath.'Config/Content.php';
+ }
+
+ $module = $this->db->table('module')->where('dirname', $dir)->get()->getRowArray();
+ if (!$module) {
+ if (isset($config['ftype']) && $config['ftype'] == 'module' && $is_app == 0) {
+ // 棣栨瀹夎妯″潡鏃讹紝楠岃瘉搴旂敤妯″潡
+ return dr_return_data(0, dr_lang('姝ゆā鍧楀睘浜庡簲鐢ㄧ被鍨嬶紝璇峰埌[鏈湴搴旂敤]涓幓瀹夎'));
+ }
+ $setting = '';
+ if (is_file($mpath.'Config/Setting.php')) {
+ $setting = require $mpath.'Config/Setting.php';
+ if (is_array($setting)) {
+ $setting = dr_array2string($setting);
+ }
+ }
+ if (!$setting) {
+ $setting = '{"order":"updatetime DESC","verify_msg":"","delete_msg":"","list_field":{"title":{"use":"1","order":"1","name":"涓婚","width":"","func":"title"},"catid":{"use":"1","order":"2","name":"鏍忕洰","width":"130","func":"catid"},"author":{"use":"1","order":"3","name":"绗斿悕","width":"120","func":"author"},"updatetime":{"use":"1","order":"4","name":"鏇存柊鏃堕棿","width":"160","func":"datetime"}},"comment_list_field":{"content":{"use":"1","order":"1","name":"璇勮","width":"","func":"comment"},"author":{"use":"1","order":"3","name":"浣滆","width":"100","func":"author"},"inputtime":{"use":"1","order":"4","name":"璇勮鏃堕棿","width":"160","func":"datetime"}},"flag":null,"param":null,"search":{"use":"1","field":"title,keywords","total":"500","length":"4","param_join":"-","param_rule":"0","param_field":"","param_join_field":["","","","","","",""],"param_join_default_value":"0"}}';
+ }
+ $module = [
+ 'site' => dr_array2string([
+ SITE_ID => [
+ 'html' => 0,
+ 'theme' => 'default',
+ 'domain' => '',
+ 'template' => 'default',
+ ]
+ ]),
+ 'share' => intval($config['share']),
+ 'dirname' => $dir,
+ 'setting' => $setting,
+ 'comment' => '',
+ 'disabled' => 0,
+ 'displayorder' => 0,
+ ];
+ $rt = $this->table('module')->insert($module);
+ if (!$rt['code']) {
+ return dr_return_data(0, $rt['msg']);
+ }
+ $module['id'] = $rt['code'];
+ $module['site'] = dr_string2array($module['site']);
+ } else {
+ $module['site'] = dr_string2array($module['site']);
+ $module['site'][SITE_ID] = [
+ 'html' => 0,
+ 'theme' => 'default',
+ 'domain' => '',
+ 'template' => 'default',
+ ];
+ $this->table('module')->update($module['id'], [
+ 'site' => dr_array2string($module['site'])
+ ]);
+ }
+
+ $siteid = 1;
+ if (dr_count($module['site']) > 1) {
+ // 澶氱珯鐐圭殑鎯呭喌涓嬩綔涓虹珯鐐瑰畨瑁
+ foreach ($module['site'] as $sid => $t) {
+ if ($sid != SITE_ID) {
+ $siteid = $sid;
+ break;
+ }
+ }
+ // 澶氱珯鐐规椂鐨勫鍒剁珯鐐硅〃$siteid
+ } else {
+ // 鍒涘缓鍐呭琛ㄥ瓧娈
+ foreach ([1, 0] as $is_main) {
+ $t = $content_table['field'][$is_main];
+ if ($t) {
+ foreach ($t as $field) {
+ $this->_add_field($field, $is_main, $module['id'], 'module');
+ }
+ }
+ }
+ }
+
+ $system_table[''] = $content_table['table'][1];
+ $system_table['_data_0'] = $content_table['table'][0];
+ // 鍒涘缓绯荤粺琛
+ foreach ($system_table as $name => $def) {
+ if (dr_count($module['site']) > 1) {
+ // 琛ㄧず瀛樺湪澶氫釜绔
+ foreach ($module['site'] as $sid => $t) {
+ $root = dr_module_table_prefix($dir, $sid).$name;
+ if ($this->is_table_exists($root)) {
+ // 琛ㄧず宸茬粡鍦ㄥ叾浠栫珯鍒涘缓杩囦簡,鎴戜滑灏卞鍒跺畠浠ュ墠鍒涘缓鐨勮〃缁撴瀯
+ list($sql) = \Phpcmf\Service::M('table')->create_table_sql($this->dbprefix($root));
+ $def = str_replace($this->dbprefix($root), '{tablename}', $sql);
+ break;
+ }
+ }
+ }
+ $tablename = $table.$name;
+ if (is_array($def) && isset($def['fields'])) {
+ \Phpcmf\Service::M('table')->create_table(
+ $tablename,
+ $def['fields'],
+ $def['indexes'] ?? [],
+ $def['comment'] ?? ''
+ );
+ } else {
+ $sql = str_replace('{tablename}', $tablename, dr_format_create_sql((string) $def));
+ $this->db->simpleQuery($sql);
+ }
+ }
+
+ // 鍒涘缓鐩稿叧鏍忕洰琛ㄥ瓧娈
+ if (isset($config['scategory']) && $config['scategory']) {
+ if (!\Phpcmf\Service::M()->db->fieldExists('tid', $table.'_category')) {
+ \Phpcmf\Service::M('table')->add_field($table.'_category', 'tid', 'tinyint(1)', 'NOT NULL', '鏍忕洰绫诲瀷锛0鍗曢〉锛1妯″潡锛2澶栭摼');
+ }
+ if (!\Phpcmf\Service::M()->db->fieldExists('content', $table.'_category')) {
+ \Phpcmf\Service::M('table')->add_field($table.'_category', 'content', 'mediumtext', 'NOT NULL', '鍗曢〉鍐呭');
+ }
+ }
+ // 绗竴娆″畨瑁呮ā鍧
+ // system = 2 2鑿滃崟涓嶅嚭鐜板湪鍐呭涓嬶紝鐢卞紑鍙戣呰嚜瀹氫箟
+ if ($config['system'] == 2 && dr_count($module['site']) == 1 && $is_app == 0 && is_file($mpath.'Config/Menu.php')) {
+ \Phpcmf\Service::M('Menu')->add_app($dir);
+ }
+
+ // =========== 杩欓噷鏄叕鍏遍儴鍒 ===========
+
+ if (dr_is_app('mform')) {
+ \Phpcmf\Service::M('mform', 'mform')->link_install($module, $mpath, $dir, $table);
+ }
+
+ // 妯″潡瀹夎鏃舵墽琛岀殑鑱斿姩
+ \Phpcmf\Hooks::trigger('module_install_data', [$module, $mpath, $dir, $table]);
+
+ if (is_file($mpath.'Config/Install.php')) {
+ require $mpath.'Config/Install.php';
+ }
+
+ // 棣栨瀹夎妯″潡鎵ц瀹
+ if (dr_count($module['site']) == 1) {
+ // 鎵ц鑷畾涔塻ql
+ if (is_file($mpath.'Config/Install.sql')) {
+ $sql = file_get_contents($mpath.'Config/Install.sql');
+ $sql && \Phpcmf\Service::M('table')->_query(
+ $sql,
+ [
+ [
+ '{moduleid}',
+ '{dbprefix}',
+ '{tablename}',
+ '{dirname}',
+ '{siteid}'
+ ],
+ [
+ $module['id'],
+ $this->dbprefix(),
+ $table,
+ $dir,
+ $siteid
+ ],
+ ]
+ );
+ }
+ }
+
+ // 鎵ц绔欑偣sql璇彞
+ if (is_file($mpath.'Config/Install_site.sql')) {
+ $sql = file_get_contents($mpath.'Config/Install_site.sql');
+ $rt = $this->query_all(str_replace('{dbprefix}', $this->dbprefix(dr_site_table_prefix('')), $sql));
+ if ($rt) {
+ return dr_return_data(0, $rt);
+ }
+ }
+
+ $module['url'] = dr_url('module/module/index');
+ return dr_return_data(1, dr_lang('鎿嶄綔鎴愬姛锛岃鍒锋柊鍚庡彴椤甸潰'), $module);
+ }
+
+ // 鍗歌浇妯″潡
+ public function uninstall($dir, $config = [], $is_app = 0) {
+
+ $module = $this->db->table('module')->where('dirname', $dir)->get()->getRowArray();
+ if (!$module) {
+ return dr_return_data(0, dr_lang('妯″潡灏氭湭瀹夎'));
+ }
+
+ $mpath = dr_get_app_dir($dir);
+ $table = $this->dbprefix(dr_module_table_prefix($dir)); // 褰撳墠琛ㄥ墠缂
+ $system_table = require IS_USE_MODULE.'Config/SysTable.php';
+
+ $site = dr_string2array($module['site']);
+ if (count($site) == 1 && isset($config['ftype']) && $config['ftype'] == 'module' && $is_app == 0) {
+ // 鍙湁涓涓珯鐐规椂锛屽嵏杞介渶瑕 楠岃瘉搴旂敤妯″潡
+ return dr_return_data(0, dr_lang('姝ゆā鍧楀睘浜庡簲鐢ㄧ被鍨嬶紝璇峰埌[鏈湴搴旂敤]涓幓鍗歌浇'));
+ }
+
+ if (isset($site[SITE_ID]) && $site[SITE_ID]) {
+ // 鍒犻櫎褰撳墠绔欑偣涓殑鍏ㄩ儴妯″潡琛
+ if (IS_USE_MEMBER) {
+ $row = $this->db->table('member_setting')->where('name', 'auth_module')->get()->getRowArray();
+ $auth_module = dr_string2array($row['value']);
+ if (isset($auth_module[SITE_ID][$dir])) {
+ unset($auth_module[SITE_ID][$dir]);
+ $this->db->table('member_setting')->replace([
+ 'name' => 'auth_module',
+ 'value' => dr_array2string($auth_module)
+ ]);
+ }
+ }
+ // 绯荤粺妯″潡
+ // 鍒犻櫎绯荤粺琛
+ foreach ($system_table as $name => $sql) {
+ \Phpcmf\Service::M('table')->drop_table($table.$name, true);
+ }
+ // 鍒犻櫎涓昏〃
+ \Phpcmf\Service::M('table')->drop_table($table, true);
+ // 鍒犻櫎鍏ㄩ儴瀛愯〃
+ for ($i = 0; $i < 200; $i ++) {
+ if (!$this->is_table_exists($table.'_data_'.$i)) {
+ break;
+ }
+ \Phpcmf\Service::M('table')->drop_table($table.'_data_'.$i, true);
+ }
+
+ if (dr_is_app('mform')) {
+ \Phpcmf\Service::M('mform', 'mform')->link_uninstall($table, $dir);
+ }
+
+ // 妯″潡鍗歌浇鏃舵墽琛岀殑鑱斿姩
+ \Phpcmf\Hooks::trigger('module_uninstall_data', [$module, $mpath, $dir, $table]);
+
+ // 鎵ц妯″潡鑷繁鐨勫嵏杞界▼搴
+ if (is_file($mpath.'Config/Uninstall.php')) {
+ require $mpath.'Config/Uninstall.php';
+ }
+
+ // 鎵ц鑷畾涔塻ql
+ if (is_file($mpath.'Config/Uninstall.sql')) {
+ $sql = file_get_contents($mpath.'Config/Uninstall.sql');
+ $sql && \Phpcmf\Service::M('table')->_query(
+ $sql,
+ [
+ [
+ '{moduleid}',
+ '{dbprefix}',
+ '{tablename}',
+ '{dirname}',
+ '{siteid}'
+ ],
+ [
+ $module['id'],
+ $this->dbprefix(),
+ $table,
+ $dir,
+ SITE_ID
+ ],
+ ]
+ );
+ }
+
+ // 鎵ц绔欑偣sql璇彞
+ if (is_file($mpath.'Config/Uninstall_site.sql')) {
+ $sql = file_get_contents($mpath.'Config/Uninstall_site.sql');
+ foreach ($this->site as $siteid) {
+ $rt = $this->query_all(str_replace('{dbprefix}', $this->dbprefix($siteid.'_'), $sql));
+ if ($rt) {
+ return dr_return_data(0, $rt);
+ }
+ }
+ }
+
+ // 鍒犻櫎鏍忕洰妯″瀷瀛楁
+ $this->db->table('field')->where('relatedname', $dir.'-'.SITE_ID)->delete();
+ // 鍒犻櫎缂撳瓨
+ \Phpcmf\Service::L('cache')->clear('module-'.$siteid.'-'.$dir);
+ unset($site[SITE_ID]);
+ }
+
+ if (empty($site)) {
+ // 娌℃湁绔欑偣浜嗗氨鍒犻櫎杩欐潯妯″潡璁板綍
+ $this->table('module')->delete($module['id']);
+ // 鍒犻櫎瀛楁
+ $this->db->table('field')->where('relatedname', $dir.'-1')->delete();
+ $this->db->table('field')->where('relatedname', 'category-'.$dir)->delete();
+ $this->db->table('field')->where('relatedid', $module['id'])->where('relatedname', 'module')->delete();
+ // 鍒犻櫎鑿滃崟
+ $this->db->table('admin_menu')->like('mark', 'module-'.$dir)->delete();
+ IS_USE_MEMBER && $this->db->table('member_menu')->like('mark', 'module-'.$dir)->delete();
+ // 鍒犻櫎鑷畾涔夎彍鍗
+ \Phpcmf\Service::M('Menu')->delete_app($dir);
+ // 鍒犻櫎鑷畾涔夎〃鍗
+ if (dr_is_app('mform')) {
+ \Phpcmf\Service::M('mform', 'mform')->link_delete($module, $dir);
+ }
+ } else {
+ // 鍒犻櫎褰撳墠绔欑偣閰嶇疆
+ $this->table('module')->update($module['id'], ['site' => dr_array2string($site)]);
+ }
+
+ return dr_return_data(1, dr_lang('鍗歌浇鎴愬姛'));
+ }
+
+ /**
+ * 瀛楁鍏ュ簱
+ * @return bool
+ */
+ public function _add_field($field, $ismain, $rid, $rname) {
+
+ if ($this->db->table('field')
+ ->where('fieldname', $field['fieldname'])
+ ->where('relatedid', $rid)
+ ->where('relatedname', $rname)->countAllResults()) {
+ return;
+ }
+
+ $this->db->table('field')->insert(array(
+ 'name' => (string)($field['name'] ? $field['name'] : $field['textname']),
+ 'ismain' => $ismain,
+ 'setting' => dr_array2string($field['setting']),
+ 'issystem' => isset($field['issystem']) ? (int)$field['issystem'] : 1,
+ 'ismember' => isset($field['ismember']) ? (int)$field['ismember'] : 1,
+ 'disabled' => isset($field['disabled']) ? (int)$field['disabled'] : 0,
+ 'fieldname' => $field['fieldname'],
+ 'fieldtype' => $field['fieldtype'],
+ 'relatedid' => $rid,
+ 'relatedname' => $rname,
+ 'displayorder' => (int)$field['displayorder'],
+ ));
+ }
+
+ // 鍐呭妯″潡
+ public function get_module_info($module = null) {
+
+ $rt = [];
+ !$module && $module = $this->table('module')->order_by('displayorder ASC,id ASC')->getAll();
+ if ($module) {
+ foreach ($module as $data) {
+ $mdir = $data['dirname'];
+ // 濡傛灉娌℃湁閰嶇疆鏂囦欢灏变笉鏇存柊缂撳瓨
+ if (!is_file(dr_get_app_dir($mdir).'Config/App.php') || $data['disabled']) {
+ continue;
+ }
+ $config = require dr_get_app_dir($mdir).'Config/App.php';
+ $setting = dr_string2array($data['setting']);
+ $data['site'] = dr_string2array($data['site']);
+ $setting['list_field'] = dr_list_field_order($setting['list_field']);
+ $rt[$mdir] = [
+ 'id' => $data['id'],
+ 'name' => $config['name'],
+ 'icon' => $config['icon'],
+ 'site' => $data['site'],
+ 'config' => $config,
+ 'share' => $data['share'],
+ 'comment' => dr_string2array($data['comment']),
+ 'setting' => $setting,
+ 'dirname' => $mdir,
+ 'domain' => $data['site'][SITE_ID]['domain'] ? dr_http_prefix($data['site'][SITE_ID]['domain'].'/') : '',
+ 'mobile_domain' => $data['site'][SITE_ID]['mobile_domain'] ? dr_http_prefix($data['site'][SITE_ID]['mobile_domain'].'/') : '',
+ ];
+ }
+ }
+
+ return $rt;
+ }
+
+ // 妯″潡鐨勫叡浜爮鐩暟鎹
+ protected function _get_share_category($siteid, $dir = '') {
+
+ !$this->cat_share[$siteid] && $this->cat_share[$siteid] = $this->db->table($siteid.'_share_category')->orderBy('displayorder ASC, id ASC')->get()->getResultArray();
+
+ if (!$this->cat_share[$siteid]) {
+ return [];
+ }
+
+ if (!$dir) {
+ return $this->cat_share[$siteid];
+ }
+
+ $category = [];
+ foreach ($this->cat_share[$siteid] as $i => $t) {
+ if (!$t['child'] && $t['tid'] == 1 && $t['mid'] != $dir) {
+ continue;
+ }
+ $category[$i] = $t;
+ }
+
+ return $category;
+ }
+
+ public function update_category_cache($siteid, $cdir) {
+
+ // 淇浼樺寲鏍忕洰
+ $category = \Phpcmf\Service::M()->db->table($siteid.'_'.$cdir.'_category')
+ ->where('disabled', 0)->orderBy('displayorder ASC, id ASC')->limit(MAX_CATEGORY)->get()->getResultArray();
+
+ $category = \Phpcmf\Service::M('category')->init(['table' => $siteid.'_'.$cdir.'_category'])->repair($category);
+ \Phpcmf\Service::L('Config')->file(WRITEPATH.'config/category_'.$siteid.'_'.$cdir.'.php', '绔欑偣鏍忕洰閰嶇疆鏂囦欢', 32)->to_require($category);
+
+ return $category;
+ }
+
+ // 鏍忕洰缂撳瓨鏁版嵁
+ protected function _get_category_cache($siteid, $cache, $mdir, $is_seo = 0) {
+
+ if ($cache['share']) {
+ $cdir = 'share';
+ if (!\Phpcmf\Service::M()->db->tableExists($this->dbprefix($siteid.'_share_category'))) {
+ return $cache;
+ }
+ if ($this->cat_share[$siteid]) {
+ $category = $this->cat_share[$siteid];
+ } else {
+ $category = $this->cat_share[$siteid] = $this->update_category_cache($siteid, $cdir);
+ }
+ } else {
+ $cdir = $cache['dirname'];
+ $category = $this->update_category_cache($siteid, $cdir);
+ }
+
+ $file = WRITEPATH.'config/category.php';
+ $cat_config = [];
+ if (is_file($file)) {
+ $cat_config = require $file;
+ }
+ $linkfix = 0;
+ if (isset($cat_config[$cdir]['linkfix']) && $cat_config[$cdir]['linkfix']) {
+ $linkfix = 1;
+ }
+
+ // 鏍忕洰寮濮
+ $CAT = $CAT_DIR = $level = [];
+
+ // 鏍忕洰鐨勫畾涔夊瓧娈
+ $field = $this->db->table('field')
+ ->where('disabled', 0)
+ ->where('relatedname', 'category-'.$cdir)
+ ->orderBy('displayorder ASC, id ASC')->get()->getResultArray();
+ if ($field) {
+ foreach ($field as $f) {
+ $f['setting'] = dr_string2array($f['setting']);
+ $cache['category_field'][$f['fieldname']] = $f;
+ }
+ }
+ if (!isset($cache['category_field']['thumb'])) {
+ $this->_add_field([
+ 'name' => dr_lang('缂╃暐鍥'),
+ 'ismain' => 1,
+ 'ismember' => 1,
+ 'fieldtype' => 'File',
+ 'fieldname' => 'thumb',
+ 'setting' => array(
+ 'option' => array(
+ 'ext' => 'jpg,gif,png,jpeg',
+ 'size' => 10,
+ 'input' => 1,
+ 'attachment' => 0,
+ )
+ )
+ ], 1, 0, 'category-'.$cdir);
+ }
+ if ($cache['share'] && !isset($cache['category_field']['content'])) {
+ $this->_add_field([
+ 'name' => dr_lang('鏍忕洰鍐呭'),
+ 'ismain' => 1,
+ 'fieldtype' => 'Ueditor',
+ 'fieldname' => 'content',
+ 'setting' => array(
+ 'option' =>
+ array (
+ 'mode' => 1,
+ 'show_bottom_boot' => 1,
+ 'div2p' => 1,
+ 'width' => '100%',
+ 'height' => 400,
+ ),
+ 'validate' =>
+ array (
+ 'xss' => 1,
+ 'required' => 1,
+ ),
+ ),
+ ], 1, 0, 'category-'.$cdir);
+ }
+ // 鏍忕洰瀛楁
+ if ($category) {
+ $cache['category'] = $category;
+ foreach ($category as $i => $c) {
+ $category[$i]['setting'] = $c['setting'] = dr_string2array($c['setting']);
+ $pid = explode(',', $c['pids']);
+ $level[] = substr_count((string)$c['pids'], ',');
+ $c['mid'] = isset($c['mid']) ? $c['mid'] : $cache['dirname'];
+ if (isset($cache['setting']['pcatpost']) && $cache['setting']['pcatpost']) {
+ // 鍏佽鐖舵爮鐩彂甯
+ $c['pcatpost'] = 1;
+ } else {
+ $c['pcatpost'] = 0;
+ }
+ $cache['category'][$i]['topid'] = $c['topid'] = isset($pid[1]) ? $pid[1] : $c['id'];
+ $c['catids'] = explode(',', $c['childids']);
+ $c['is_post'] = $c['pcatpost'] ? 1 : ($c['child'] ? 0 : 1); // 鏄惁鍏佽鍙戝竷鍐呭
+ if ($cache['share']) {
+ // 鍏变韩鏍忕洰鏃
+ //浠ユ湰鏍忕洰涓哄噯
+ $c['setting']['html'] = intval($c['setting']['html']);
+ $c['setting']['chtml'] = intval($c['setting']['chtml']);
+ $c['setting']['urlrule'] = intval($c['setting']['urlrule']);
+ } else {
+ // 鐙珛妯″潡鏍忕洰
+ //浠ョ珯鐐逛负鍑
+ if (!isset($c['tid'])) {
+ $c['tid'] = $c['setting']['linkurl'] ? 2 : 1; // 鍒ゆ柇鏍忕洰绫诲瀷 2琛ㄧず澶栭摼
+ }
+ $c['setting']['html'] = intval($cache['html']);
+ $c['setting']['chtml'] = intval($cache['html']);
+ $c['setting']['urlrule'] = intval($cache['site'][$siteid]['urlrule']);
+ }
+ // 鑾峰彇鏍忕洰url
+ if ($c['tid'] == 2 && $c['setting']['linkurl']) {
+ // 澶栭摼鏍忕洰
+ $c['url'] = $linkfix ? dr_url_prefix($c['setting']['linkurl'], '', $siteid, 0) : $c['setting']['linkurl'];
+ } else {
+ $c['url'] = \Phpcmf\Service::L('router')->category_url($cache, $c);
+ }
+ $c['ismain'] = 1;
+ // 缁熻鏍忕洰鏂囩珷鏁伴噺
+ $c['total'] = '璇蜂娇鐢╟ount鏍囩鏌ヨ';
+ /*
+ if (in_array($c['tid'], [2, 0]) || $c['child'] || !$c['mid'] || !$this->db->tableExists($this->dbprefix($siteid.'_'.$c['mid'].'_index'))) {
+ $c['total'] = 0;
+ } else {
+ $c['total'] = $this->db->table($siteid.'_'.$c['mid'].'_index')->where('status', 9)->where('catid', intval($c['id']))->countAllResults();
+ }*/
+ if ($is_seo) {
+ $c['setting']['seo'] = [];
+ }
+ // 鏍煎紡鍖栨爮鐩
+ $c['field'] = [];
+ $CAT[$c['id']] = \Phpcmf\Service::L('Field')->app($cdir)->format_value($cache['category_field'], $c, 1);
+ if ($c['pid']) {
+ $CAT_DIR[$c['pdirname'].$c['dirname']] = $c['id'];
+ }
+ $CAT_DIR[$c['dirname']] = $c['id'];
+ }
+ // 褰掔被鏍忕洰妯″瀷瀛楁
+ foreach ($category as $c) {
+ if ($c['setting']['module_field']) {
+ foreach ($c['setting']['module_field'] as $_fname => $o) {
+ $CAT[$c['id']]['field'][] = $_fname;
+ }
+ }
+ }
+
+ // 鑷畾涔夋爮鐩ā鍨嬪瓧娈碉紝鎶婄埗绾ф爮鐩殑瀛楁鍚堝苟鑷冲綋鍓嶆爮鐩
+ $like = ['catmodule-'.$mdir];
+ if ($cache['share']) {
+ $like[] = 'catmodule-share';
+ }
+
+ // 妯″瀷瀛楁鏌ヨ
+ $cat_data_field = [];
+ $field = $this->db->table('field')
+ ->where('ismain', 1)
+ ->where('disabled', 0)
+ ->whereIn('relatedname', $like)
+ ->orderBy('displayorder ASC, id ASC')
+ ->get()->getResultArray();
+ if ($field) {
+ foreach ($field as $f) {
+ $f['setting'] = dr_string2array($f['setting']);
+ $cat_data_field[$f['fieldname']] = $f;
+ }
+ }
+ $cache['category_data_field'] = $cat_data_field;
+
+ // 鏍忕洰缁撴潫
+ if (!$cache['share']) {
+ // 姝ゅ彉閲忚鏄庢湰妯″潡瀛樺湪鏍忕洰妯″瀷瀛楁
+ $cache['category'] = $CAT;
+ } else {
+ // 鍏变韩妯″潡闇瑕佺瓫閫夊嚭鑷繁鐨勬ā鍧楃殑鏍忕洰
+ $cache['category'] = $this->_get_my_category($cache['dirname'], $CAT);
+ }
+ $cache['category_dir'] = $CAT_DIR;
+ $cache['category_level'] = $level ? max($level) : 0;
+ }
+
+ // 鍏变韩妯″潡
+ if ($cache['share'] && $this->cat_share_lock[$siteid]) {
+ // 鍒犻櫎缂撳瓨
+ \Phpcmf\Service::L('cache')->clear('module-'.$siteid.'-share');
+ // 鍐欏叆缂撳瓨
+ \Phpcmf\Service::L('cache')->set_file('module-'.$siteid.'-share', [
+ 'id' => 0,
+ 'mid' => 'share',
+ 'name' => '鍏变韩',
+ 'share' => 1,
+ 'dirname' => 'share',
+ 'category' => $CAT,
+ 'category_dir' => $CAT_DIR,
+ 'category_field' => $cache['category_field'],
+ 'category_level' => $cache['category_level'],
+ 'category_data_field' => $cache['category_data_field'],
+ ]);
+ $this->cat_share_lock[$siteid] = 0;
+ }
+ return $cache;
+ }
+
+ public function sync_site_cache($module, $webpath, $site_domain, $app_domain, $sso_domain, $client_domain, $module_cache_file, $site=[]) {
+ // 寰幆妯″潡鍩熷悕
+ !$module && $module = $this->table('module')->getAll();
+ if ($module) {
+ foreach ($module as $t) {
+ if (!is_file(APPSPATH.ucfirst($t['dirname']).'/Config/App.php')) {
+ continue;
+ }
+ $t['site'] = dr_string2array($t['site']);
+ if (!$t['site']) {
+ // 琛ㄧず娌℃湁杩涜绔欑偣瀹夎
+ continue;
+ }
+ // 寰幆绔欑偣淇℃伅
+ foreach ($t['site'] as $sid => $v) {
+ if (!$t['share']) {
+ // 鐙珛妯″潡鎵嶆湁鍩熷悕
+ $webpath[$sid][$t['dirname']] = $webpath[$sid]['site'];
+ if ($v['domain']) {
+ $site_domain[$v['domain']] = $sid;
+ $app_domain[$v['domain']] = $t['dirname'];
+ $sso_domain[] = $v['domain'];
+ // 缃戠珯璺緞
+ if ($v['webpath']) {
+ $webpath[$sid][$t['dirname']] = dr_get_dir_path($v['webpath']);
+ }
+ }
+ if ($v['mobile_domain']) {
+ $site_domain[$v['mobile_domain']] = $sid;
+ $app_domain[$v['mobile_domain']] = $t['dirname'];
+ $client_domain[$v['domain']] = $v['mobile_domain'];
+ $sso_domain[] = $v['mobile_domain'];
+ }
+ }
+ }
+ }
+ }
+
+ return [$webpath, $site_domain, $app_domain, $sso_domain, $client_domain];
+ }
+
+ public function domian($value, $my, $data) {
+
+ $module = $this->table('module')->getAll();
+ foreach ($module as $t) {
+ if (!is_file(APPSPATH.ucfirst($t['dirname']).'/Config/App.php')) {
+ continue;
+ }
+ $cfg = require APPSPATH.ucfirst($t['dirname']).'/Config/App.php';
+ $t['site'] = dr_string2array($t['site']);
+ $my[$t['dirname']] = [
+ 'share' => $t['share'],
+ 'name' => dr_lang($cfg['name']),
+ 'error' => '',
+ ];
+ if ($t['share']) {
+ unset($my[$t['dirname']]);
+ continue;
+ }
+ if ($t['site'][SITE_ID]) {
+ if ($value) {
+ $t['site'][SITE_ID]['domain'] = strtolower((string)$value['module_'.$t['dirname']]);
+ $t['site'][SITE_ID]['mobile_domain'] = $value['module_mobile_'.$t['dirname']];
+ $t['site'][SITE_ID]['webpath'] = $value['webpath_'.$t['dirname']];
+ $this->db->table('module')->where('id', $t['id'])->update([
+ 'site' => dr_array2string($t['site'])
+ ]);
+ }
+ $data['module_'.$t['dirname']] = strtolower((string)$t['site'][SITE_ID]['domain']);
+ $data['module_mobile_'.$t['dirname']] = strtolower((string)$t['site'][SITE_ID]['mobile_domain']);
+ $data['webpath_'.$t['dirname']] = $t['site'][SITE_ID]['webpath'];
+ } else {
+ $my[$t['dirname']]['error'] = dr_lang('褰撳墠绔欑偣鏈畨瑁');
+ }
+ }
+
+ return [$my, $data];
+ }
+
+ // 缂栬緫鍣ㄦ洿鏂
+ public function update_ueditor($site) {
+ $module = $this->table('module')->getAll();
+ foreach ($module as $t) {
+ if (!is_file(APPSPATH.ucfirst($t['dirname']).'/Config/App.php')) {
+ continue;
+ } elseif ($t['share']) {
+ continue;
+ }
+ $t['site'] = dr_string2array($t['site']);
+ foreach ($site as $r) {
+ $siteid = $r['id'];
+ if (isset($t['site'][$siteid]['domain']) && $t['site'][$siteid]['domain'] && $t['site'][$siteid] && $t['site'][$siteid]['webpath']) {
+ $path = rtrim($t['site'][$siteid]['webpath'], '/').'/';
+ // 澶嶅埗鐧惧害缂栬緫鍣ㄥ埌褰撳墠鐩綍
+ \Phpcmf\Service::M('cache')->cp_ueditor_file($path);
+ // 澶嶅埗鐧惧害缂栬緫鍣ㄥ埌绉诲姩绔」鐩
+ \Phpcmf\Service::M('cache')->cp_ueditor_file($path.'mobile/');
+ }
+ }
+ }
+ }
+
+ // 閲嶅缓瀛愮珯閰嶇疆鏂囦欢
+ public function update_site_config($t) {
+ if (!is_array($t)) {
+ return;
+ } elseif (!$t['dirname']) {
+ return;
+ }
+ if (!is_file(APPSPATH.ucfirst($t['dirname']).'/Config/App.php')) {
+ return;
+ } elseif ($t['share']) {
+ return;
+ }
+ $t['site'] = dr_string2array($t['site']);
+ foreach ($this->site as $siteid) {
+ if (isset($t['site'][$siteid]['domain']) && $t['site'][$siteid]['domain'] && $t['site'][$siteid] && $t['site'][$siteid]['webpath']) {
+ $rt = \Phpcmf\Service::M('cache')->update_webpath('Module_Domain', $t['site'][$siteid]['webpath'], [
+ 'SITE_ID' => $siteid,
+ 'MOD_DIR' => $t['dirname'],
+ ], IS_USE_MODULE . 'Temps/');
+ if ($rt) {
+ \Phpcmf\Service::M('cache')->_error_msg('妯″潡[' . $t['site'][$siteid]['domain'] . ']: ' . $rt);
+ }
+ }
+ }
+ }
+
+ public function paytable($cache, $paytable, $module, $siteid) {
+
+ !$module && $module = $this->table('module')->getAll();
+ if ($module) {
+ $this->db->resetDataCache();// 娓呴櫎缂撳瓨锛屽奖鍝嶅瓧娈靛瓨鍦ㄧ殑閲嶅
+ $is_module_form = $this->is_table_exists('module_form');
+ foreach ($module as $t) {
+ // 妯″潡涓昏〃
+ $table = dr_module_table_prefix($t['dirname'], $siteid);
+ $prefix = $this->dbprefix($table);
+ // 鍒ゆ柇鏄惁瀛樺湪琛
+ if (!$this->db->tableExists($prefix)) {
+ continue;
+ }
+ $main_field = $this->db->getFieldNames($prefix);
+ if ($main_field) {
+ // 浠樻琛
+ $paytable['module-'.$t['id']] = [
+ 'table' => $table,
+ 'name' => 'title',
+ 'thumb' => 'thumb',
+ 'url' => dr_web_prefix('index.php?s='.$t['dirname'].'&c=show&id='),
+ 'username' => 'author',
+ ];
+ // 妯″潡琛
+ $cache[$prefix] = $main_field;
+ // 妯″潡闄勮〃
+ $table = $prefix.'_data_0';
+ $this->db->tableExists($table) && $cache[$table] = $this->db->getFieldNames($table);
+ // 鏍忕洰妯″瀷涓昏〃
+ $table = $prefix.'_category_data';
+ $this->db->tableExists($table) && $cache[$table] = $this->db->getFieldNames($table);
+ // 妯″潡鐐瑰嚮閲忚〃
+ $table = $prefix.'_hits';
+ $this->db->tableExists($table) && $cache[$table] = $this->db->getFieldNames($table);
+ // 妯″潡璇勮琛
+ $table = $prefix.'_comment';
+ $this->db->tableExists($table) && $cache[$table] = $this->db->getFieldNames($table);
+ // 妯″潡琛ㄥ崟
+ if ($is_module_form) {
+ $form = $this->table('module_form')->where('module', $t['dirname'])->order_by('id ASC')->getAll();
+ if ($form) {
+ foreach ($form as $f) {
+ // 涓昏〃
+ $table = $prefix . '_form_' . $f['table'];
+ $this->db->tableExists($table) && $cache[$table] = $this->db->getFieldNames($table);
+ // 浠樻琛
+ $paytable['mform-' . $t['dirname'] . '-' . $f['id']] = [
+ 'table' => $table,
+ 'name' => 'title',
+ 'thumb' => 'thumb',
+ 'url' => dr_web_prefix('index.php?s=' . $t['dirname'] . '&c=' . $f['table'] . '&m=show&id='),
+ 'username' => 'author',
+ ];
+ }
+ }
+ }
+ }
+ }
+ }
+ return [$cache, $paytable];
+ }
+
+ // 缂撳瓨
+ public function cache($siteid = SITE_ID, $module = null) {
+
+ if (is_file(IS_USE_MODULE.'Models/Repair.php')) {
+ unlink(IS_USE_MODULE.'Models/Repair.php');
+ }
+
+ if ($siteid == 1) {
+ // 瑙勫垯缂撳瓨
+ $data = $this->table('urlrule')->getAll();
+ $cache = [];
+ if ($data) {
+ foreach ($data as $t) {
+ $t['value'] = dr_string2array($t['value']);
+ $cache[$t['id']] = $t;
+ }
+ }
+
+ \Phpcmf\Service::L('cache')->set_file('urlrule', $cache);
+
+ // 瀹℃牳娴佺▼
+ $verify = [];
+ if ($this->is_table_exists('admin_verify')) {
+ $data = $this->table('admin_verify')->getAll();
+ if ($data) {
+ foreach ($data as $t) {
+ $t['value'] = dr_string2array($t['verify']);
+ unset($t['verify']);
+ $verify[$t['id']] = $t;
+ }
+ }
+ }
+ \Phpcmf\Service::L('cache')->set_file('verify', $verify);
+
+ $table = $this->dbprefix($siteid.'_share_category');
+ if (!$this->is_table_exists($table)) {
+ \Phpcmf\Service::M('table')->create_table(
+ $table,
+ [
+ 'id' => 'smallint(5) unsigned NOT NULL AUTO_INCREMENT',
+ 'tid' => 'tinyint(1) NOT NULL COMMENT \'鏍忕洰绫诲瀷锛0鍗曢〉锛1妯″潡锛2澶栭摼\'',
+ 'pid' => 'smallint(5) unsigned NOT NULL DEFAULT \'0\' COMMENT \'涓婄骇id\'',
+ 'mid' => 'varchar(20) NOT NULL COMMENT \'妯″潡鐩綍\'',
+ 'pids' => 'varchar(255) NOT NULL COMMENT \'鎵鏈変笂绾d\'',
+ 'name' => 'varchar(255) NOT NULL COMMENT \'鏍忕洰鍚嶇О\'',
+ 'dirname' => 'varchar(255) NOT NULL COMMENT \'鏍忕洰鐩綍\'',
+ 'pdirname' => 'varchar(255) NOT NULL COMMENT \'涓婄骇鐩綍\'',
+ 'child' => 'tinyint(1) unsigned NOT NULL DEFAULT \'0\' COMMENT \'鏄惁鏈変笅绾'',
+ 'disabled' => 'tinyint(1) unsigned NOT NULL DEFAULT \'0\' COMMENT \'鏄惁绂佺敤\'',
+ 'ismain' => 'tinyint(1) unsigned NOT NULL DEFAULT \'1\' COMMENT \'鏄惁涓绘爮鐩甛'',
+ 'childids' => 'text NOT NULL COMMENT \'涓嬬骇鎵鏈塱d\'',
+ 'thumb' => 'varchar(255) NOT NULL COMMENT \'鏍忕洰鍥剧墖\'',
+ 'show' => 'tinyint(1) unsigned NOT NULL DEFAULT \'1\' COMMENT \'鏄惁鏄剧ず\'',
+ 'content' => 'mediumtext NOT NULL COMMENT \'鍗曢〉鍐呭\'',
+ 'setting' => 'mediumtext NOT NULL COMMENT \'灞炴ч厤缃甛'',
+ 'displayorder' => 'smallint(5) NOT NULL DEFAULT \'0\'',
+ ],
+ [
+ 'PRIMARY KEY (`id`)',
+ 'KEY `mid` (`mid`)',
+ 'KEY `tid` (`tid`)',
+ 'KEY `show` (`show`)',
+ 'KEY `disabled` (`disabled`)',
+ 'KEY `ismain` (`ismain`)',
+ 'KEY `dirname` (`dirname`)',
+ 'KEY `module` (`pid`,`displayorder`,`id`)',
+ ],
+ '鍏变韩妯″潡鏍忕洰琛'
+ );
+ }
+ } else {
+ $table = $this->dbprefix($siteid.'_share_category');
+ if (!$this->is_table_exists($table)) {
+ $src = $this->dbprefix('1_share_category');
+ list($sql) = \Phpcmf\Service::M('table')->create_table_sql($src);
+ $sql = str_replace($src, $table, $sql);
+ $this->db->simpleQuery(dr_format_create_sql($sql));
+ $short = substr($table, strlen($this->prefix));
+ $this->table($short)->clear_all();
+ }
+ }
+
+ $table = $this->dbprefix($siteid.'_share_index');
+ if (!$this->is_table_exists($table)) {
+ \Phpcmf\Service::M('table')->create_table(
+ $table,
+ [
+ 'id' => 'int(10) unsigned NOT NULL AUTO_INCREMENT',
+ 'mid' => 'varchar(20) NOT NULL COMMENT \'妯″潡鐩綍\'',
+ ],
+ [
+ 'PRIMARY KEY (`id`)',
+ 'KEY `mid` (`mid`)',
+ ],
+ '鍏变韩妯″潡鍐呭绱㈠紩琛'
+ );
+ }
+
+ // 閲嶇疆缂撳瓨
+ $this->cat_share_lock[$siteid] = 1;
+
+ \Phpcmf\Service::L('cache')->set_file('module-'.$siteid, []);
+ \Phpcmf\Service::L('cache')->set_file('module-'.$siteid.'-share', []);
+ \Phpcmf\Service::L('cache')->set_file('module-'.$siteid.'-content', []);
+
+ $all = $content = [];
+ $module = $this->get_module_info($module);
+ $menu_model = \Phpcmf\Service::M('menu');
+ if ($module) {
+ foreach ($module as $mdir => $data) {
+ //unset($cache['config']);
+ // 褰撳墠绔欑偣瀹夎杩囧氨缂撳瓨瀹
+ if (isset($data['site'][$siteid]) && $data['site'][$siteid]) {
+ $cache = $data;
+ $config = $data['config'];
+ $cache['cname'] = isset($config['cname']) && $config['cname'] ? $config['cname'] : $cache['name'];
+ $cache['html'] = $data['site'][$siteid]['html'];
+ $cache['title'] = $data['site'][$siteid]['module_title'] ? $data['site'][$siteid]['module_title'] : $data['name'];
+ $cache['urlrule'] = $data['site'][$siteid]['urlrule'];
+ // 缁戝畾鐨勫煙鍚
+ $cache['domain'] = $data['site'][$siteid]['domain'] ? dr_http_prefix($data['site'][$siteid]['domain'].'/') : '';
+ $cache['mobile_domain'] = $data['site'][$siteid]['mobile_domain'] ? dr_http_prefix($data['site'][$siteid]['mobile_domain'].'/') : '';
+ // 琛ュ叏url
+ $cache['url'] = \Phpcmf\Service::L('router')->module_url($cache, $siteid); // 妯″潡鐨刄RL鍦板潃
+ $cache['murl'] = $data['site'][$siteid]['mobile_domain'] ? $cache['mobile_domain'] : dr_url_prefix($cache['url'], '', $siteid, 1); // 妯″潡鐨刄RL鍦板潃
+ // 妯″潡鐨勮嚜瀹氫箟瀛楁
+ $cache['field'] = [];
+ $field = $this->db->table('field')
+ ->where('disabled', 0)
+ ->where('relatedid', intval($data['id']))
+ ->where('relatedname', 'module')
+ ->orderBy('displayorder ASC, id ASC')->get()->getResultArray();
+ if ($field) {
+ foreach ($field as $f) {
+ $f['setting'] = dr_string2array($f['setting']);
+ $cache['field'][$f['fieldname']] = $f;
+ }
+ }
+
+ // 绯荤粺妯″潡
+ $cache['system'] = $config['system'];
+
+ // 妯″潡鐨勬爮鐩垎绫
+ $cache['category'] = [];
+ $cache['category_dir'] = [];
+ $cache['category_field'] = [];
+ $cache['category_level'] = 0;
+ $cache['category_data_field'] = 0;
+
+ if (isset($config['hcategory']) && $config['hcategory']) {
+ // 涓嶄娇鐢ㄦ爮鐩姛鑳
+ } else {
+ // 濡傛灉鏄叡浜叡浜爮鐩氨鏌ヨshare琛
+ if (!$data['share'] && (!isset($data['site'][$siteid]['is_cat']) || !$data['site'][$siteid]['is_cat'])) {
+ // 鐙珛妯″潡缁熶竴瑙勫垯妯″紡
+ $cache = $this->_get_category_cache($siteid, $cache, $mdir, 1);
+ } else {
+ $cache = $this->_get_category_cache($siteid, $cache, $mdir, 0);
+ }
+ }
+
+ // 妯″潡琛ㄥ崟
+ $cache['form'] = [];
+ if (dr_is_app('mform')) {
+ $cache = \Phpcmf\Service::M('mform', 'mform')->link_cache($mdir, $cache);
+ }
+
+ // 鎼滅储楠岃瘉
+ !$cache['setting']['search']['use'] && $cache['setting']['search'] = [];
+
+ // 璇勮缂撳瓨 杞Щ璇勮
+ if ($cache['comment'] && dr_is_app('comment')) {
+ $ct = $this->table('app_comment')->where('name', 'module')->getRow();
+ // 杞Щ璇勮
+ if ($ct) {
+ $ct_cfg = dr_string2array($ct['value']);
+ if (!$ct_cfg[$mdir]) {
+ $this->db->table('app_comment')->where('name', 'module')->update([
+ 'value' => dr_array2string([
+ $mdir => $cache['comment'],
+ ]),
+ ]);
+ }
+ } else {
+ $this->db->table('app_comment')->insert([
+ 'name' => 'module',
+ 'value' => dr_array2string([
+ $mdir => $cache['comment'],
+ ]),
+ ]);
+ }
+ $this->db->table('module')->where('dirname', $mdir)->update(['comment' => '']);
+ }
+ unset($cache['comment']);
+
+ // 鏇存柊鍐呭妯″潡鑿滃崟
+ \Phpcmf\Service::M('menu', 'cms')->update_module($mdir, $config, $cache['form']);
+ !$cache['title'] && $cache['title'] = $cache['name'];
+
+ // 鎵ц妯″潡鑷繁鐨勭紦瀛樼▼搴
+ if (is_file(dr_get_app_dir($mdir).'Config/Cache.php')) {
+ require dr_get_app_dir($mdir).'Config/Cache.php';
+ }
+
+ $cache['mid'] = $cache['share'] ? 'share' : $mdir;
+
+ // 鍏ㄩ儴妯″潡
+ $all[$mdir] = [
+ 'mid' => $cache['mid'],
+ 'url' => $cache['url'],
+ 'murl' => $cache['murl'],
+ 'name' => $cache['name'],
+ 'icon' => $cache['icon'],
+ 'title' => $cache['title'],
+ 'share' => $cache['share'],
+ 'system' => $config['system'],
+ 'hlist' => (int)$config['hlist'],
+ 'hcategory' => (int)$config['hcategory'],
+ 'scategory' => (int)$config['scategory'],
+ 'search' => $cache['setting']['search']['use'] ? 1 : 0,
+ 'dirname' => $mdir,
+ 'is_index_html' => $cache['setting']['module_index_html'] ? 1 : 0,
+ 'pcatpost' => isset($cache['setting']['pcatpost']) && $cache['setting']['pcatpost'] ? 1 : 0,
+ ];
+
+ // 鍐呭妯″潡
+ if (in_array($config['system'], [1, 2])) {
+ $content[$mdir] = $all[$mdir];
+ }
+
+ // 鍒犻櫎缂撳瓨
+ //\Phpcmf\Service::L('cache')->clear('module-'.$siteid.'-'.$mdir);
+
+ // 鍐欏叆缂撳瓨
+ \Phpcmf\Service::L('cache')->set_file('module-'.$siteid.'-'.$mdir, $cache);
+ } else {
+ }
+ }
+ }
+
+ // 鍐欏叆缂撳瓨
+ \Phpcmf\Service::L('cache')->set_file('module-'.$siteid, $all);
+ \Phpcmf\Service::L('cache')->set_file('module-'.$siteid.'-content', $content);
+
+ if (!$this->table('admin_menu')->where('uri', 'cms/module/index')->counts()) {
+ // 鍒犻櫎楂樼骇鑿滃崟
+ $this->table('admin_menu')->where('mark', 'config-content')->delete();
+ $this->table('admin_menu')->where('mark', 'config-seo')->delete();
+ $this->table('admin_menu')->where('mark', 'content-verify')->delete();
+ unlink(WRITEPATH.'is_module_install.lock');
+ } else {
+ $this->table('admin_menu')->where('mark', 'config-study-1')->delete();
+ $this->table('admin_menu')->where('mark', 'config-study-2')->delete();
+ $this->table('admin_menu')->where('mark', 'config-study-3')->delete();
+ }
+
+ foreach ([
+ 'site_config/index',
+ 'site_mobile/index',
+ 'site_domain/index',
+ //'site_image/index',
+ 'site_param/index',
+ ] as $ui) {
+ $main = $this->table('admin_menu')->where('uri', $ui)->getRow();
+ if ($main) {
+ if ($this->table('admin_menu')->where('uri', 'cms/'.$ui)->counts()) {
+ $this->table('admin_menu')->where('uri', $ui)->delete();
+ } else {
+ $this->table('admin_menu')->update($main['id'], ['uri' => 'cms/'.$ui]);
+ }
+ }
+ }
+
+ $this->table('admin_menu')->update(0, ['name' => '缃戠珯璁剧疆'], 'mark="config-web"');
+ return;
+ }
+
+}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Models/Search.php b/dayrui/App/Cms/Models/Search.php
new file mode 100644
index 0000000..65f55ed
--- /dev/null
+++ b/dayrui/App/Cms/Models/Search.php
@@ -0,0 +1,345 @@
+mytable = dr_module_table_prefix($table, SITE_ID);
+ return $this;
+ }
+
+ // 鑾峰彇鎼滅储鍙傛暟
+ public function get_param($module) {
+
+ $get = $_GET;
+ $get = isset($get['rewrite']) ? dr_search_rewrite_decode($get['rewrite'], $module['setting']['search']) : $get;
+ if ($get) {
+ $get = \Phpcmf\Service::L('input')->xss_clean($get);
+ }
+
+ $get['s'] = $get['c'] = $get['m'] = $get['id'] = null;
+ unset($get['s'], $get['c'], $get['m'], $get['id']);
+ if (!$get && IS_API_HTTP) {
+ $get = \Phpcmf\Service::L('input')->xss_clean($_POST);
+ }
+
+ $_GET['page'] = $get['page'] = (int)$get['page'];
+ if (isset($get['catdir']) && $get['catdir']) {
+ $catid = (int)$module['category_dir'][$get['catdir']];
+ unset($get['catid']);
+ } else {
+ $catid = (int)$get['catid'];
+ isset($get['catid']) && $get['catid'] = $catid;
+ }
+
+ // 鍥哄畾妯″紡涓嬬殑濉厖
+ if ($get && $this->module['setting']['search']['param_rule']) {
+ foreach ($get as $i => $t) {
+ if ((string)$this->module['setting']['search']['param_join_default_value'] === $t) {
+ unset($get[$i]);
+ }
+ }
+ }
+
+ $this->get = $get;
+ $this->catid = $catid;
+ $this->module = $module;
+
+ // 鎸傞挬鐐 鎼滅储涔嬪墠瀵瑰弬鏁板鐞
+ \Phpcmf\Hooks::trigger('search_param', $get);
+
+ return [$catid, $get];
+ }
+
+ /**
+ * 鏌ヨ鏁版嵁骞惰缃紦瀛
+ */
+ public function get_data() {
+
+ // 妯″潡琛ㄥ悕绉
+ $table = $this->dbprefix($this->mytable);
+
+ // 鎸傞挬鐐 鑷畾涔夎繑鍥炴暟鎹
+ $rt2 = \Phpcmf\Hooks::trigger_callback('module_search_get_data');
+ if ($rt2 && isset($rt2['code']) && $rt2['code']) {
+ return $rt2['data'];
+ }
+
+ // 鎺掑簭鏌ヨ鍙傛暟
+ ksort($this->get);
+ $param = $this->get;
+ $catid = $this->catid;
+ $param_new = [];
+ $this->get['order'] = $this->get['page'] = null;
+ unset($this->get['order'], $this->get['page']);
+
+ // 鏌ヨ缂撳瓨
+ $id = md5($table.dr_array2string($this->get).$catid);
+ if (!IS_DEV && SYS_CACHE_SEARCH) {
+ $data = $this->db->table($this->mytable.'_search')->where('id', $id)->get()->getRowArray();
+ $time = SYS_CACHE_SEARCH * 3600;
+ if ($data && $data['inputtime'] + $time < SYS_TIME) {
+ $data = [];
+ }
+ $this->db->table($this->mytable.'_search')->where('inputtime <'. (SYS_TIME - $time))->delete();
+ } else {
+ $data = [];
+ $this->db->table($this->mytable.'_search')->where('inputtime <'. (SYS_TIME - 3600))->delete();
+ }
+
+ $is_like = intval($this->module['setting']['search']['is_like']);
+
+ // 缂撳瓨涓嶅瓨鍦ㄩ噸鏂板叆搴撴洿鏂扮紦瀛
+ if (!$data) {
+
+ $this->get['keyword'] = $this->get['catid'] = null;
+ unset($this->get['keyword'], $this->get['catid']);
+
+ // 涓昏〃鐨勫瓧娈
+ $field = \Phpcmf\Service::L('cache')->get('table-'.SITE_ID, $this->dbprefix($this->mytable));
+ if (!$field) {
+ return dr_return_data(0, dr_lang('涓昏〃銆%s銆戝瓧娈典笉瀛樺湪', $this->mytable));
+ }
+
+ $mod_field = $this->module['field'];
+ foreach ($field as $i) {
+ if (!isset($mod_field[$i])) {
+ $mod_field[$i] = ['ismain' => 1];
+ }
+ }
+
+ // 榛樿鎼滅储鏉′欢
+ $where = [
+ //'status' => '`'.$table.'`.`status` = 9'
+ ];
+
+ // 鏍忕洰鐨勫瓧娈
+ if ($catid) {
+ $more = 0;
+ $cat_field = $this->module['category'][$catid]['field'];
+ // 鍓爮鐩垽鏂
+ if (isset($this->module['field']['catids']) && $this->module['field']['catids']['fieldtype'] == 'Catids') {
+ $fwhere = [];
+ if ($this->module['category'][$catid]['child'] && $this->module['category'][$catid]['childids']) {
+ $fwhere[] = '`'.$table.'`.`catid` IN ('.$this->module['category'][$catid]['childids'].')';
+ $catids = explode(',', $this->module['category'][$catid]['childids']);
+ } else {
+ $fwhere[] = '`'.$table.'`.`catid` = '.$catid;
+ $catids = [ $catid ];
+ }
+ foreach ($catids as $c) {
+ $fwhere[] = \Phpcmf\Service::M()->where_json($table, 'catids', intval($c));
+ }
+ $fwhere && $where['catid'] = '('.implode(' OR ', $fwhere).')';
+ } else {
+ // 鏃犲壇鏍忕洰鏃
+ $where['catid'] = '`'.$table.'`.`catid`'.($this->module['category'][$catid]['child'] ? 'IN ('.$this->module['category'][$catid]['childids'].')' : '='.(int)$catid);
+ }
+
+ if ($cat_field) {
+ // 鏍忕洰妯″瀷琛
+ $more_where = [];
+ $table_more = $this->dbprefix($this->mytable.'_category_data');
+ foreach ($cat_field as $name) {
+ if (isset($this->get[$name]) && strlen($this->get[$name])) {
+ $more = 1;
+ $r = $this->mywhere($table_more, $name, $this->get[$name], $this->module['category_data_field'][$name], $is_like);
+ if ($r) {
+ $more_where[] = $r;
+ $param_new[$name] = $this->get[$name];
+ }
+ }
+ /*
+ if (isset($_order_by[$name])) {
+ $more = 1;
+ $order_by[] = '`'.$table.'`.`'.$name.'` '.$_order_by[$name];
+ }*/
+ }
+ $more && $where[] = '`'.$table.'`.`id` IN (SELECT `id` FROM `'.$table_more.'` WHERE '.implode(' AND ', $more_where).')';
+ }
+ }
+ /*
+ if (dr_is_app('fstatus') && isset($this->module['field']['fstatus']) && $this->module['field']['fstatus']['ismain']) {
+ $where[] = [ '`'.$table.'`.`fstatus` = 1' ];
+ }*/
+ // 鏌ユ壘mwhere鐩綍
+ $mwhere = \Phpcmf\Service::Mwhere_Apps();
+ if ($mwhere) {
+ list($siteid, $mid) = explode('_', $this->mytable);
+ foreach ($mwhere as $mapp) {
+ $w = require dr_get_app_dir($mapp).'Config/Mwhere.php';
+ if ($w) {
+ $where[] = $w;
+ }
+ }
+ }
+
+ // 鍏抽敭瀛楀尮閰嶆潯浠
+ if ($param['keyword'] != '') {
+ $temp = [];
+ $sfield = explode(',', $this->module['setting']['search']['field'] ? $this->module['setting']['search']['field'] : 'title,keywords');
+ $search_keyword = explode('|', addslashes((string)$param['keyword']));
+ foreach ($search_keyword as $kw) {
+ $is = 0;
+ if ($sfield) {
+ foreach ($sfield as $t) {
+ if ($t && dr_in_array($t, $field)) {
+ $is = 1;
+ $temp[] = $this->module['setting']['search']['complete'] ? '`'.$table.'`.`'.$t.'` = "'.$kw.'"' : '`'.$table.'`.`'.$t.'` LIKE "%'.$kw.'%"';
+ }
+ }
+ }
+ if (!$is) {
+ $temp[] = $this->module['setting']['search']['complete'] ? '`'.$table.'`.`title` = "'.$kw.'"' : '`'.$table.'`.`title` LIKE "%'.$kw.'%"';
+ }
+ }
+ $where['keyword'] = $temp ? '('.implode(' OR ', $temp).')' : '';
+ $param_new['keyword'] = $search_keyword;
+ }
+
+ // 妯″潡瀛楁杩囨护
+ foreach ($mod_field as $name => $field) {
+ if (isset($field['ismain']) && !$field['ismain']) {
+ continue;
+ }
+ if (isset($this->get[$name]) && strlen($this->get[$name])) {
+ $r = $this->mywhere($table, $name, $this->get[$name], $field, $is_like);
+ if ($r) {
+ $where[$name] = $r;
+ $param_new[$name] = $this->get[$name];
+ }
+ }
+ }
+
+ if (IS_USE_MEMBER) {
+ // 浼氬憳瀛楁杩囨护
+ $member_where = [];
+ if (\Phpcmf\Service::C()->member_cache['field']) {
+ foreach (\Phpcmf\Service::C()->member_cache['field'] as $name => $field) {
+ if (isset($field['ismain']) && !$field['ismain']) {
+ continue;
+ }
+ if (!isset($mod_field[$name]) && isset($this->get[$name]) && strlen($this->get[$name])) {
+ $r = $this->mywhere($this->dbprefix('member_data'), $name, $this->get[$name], $field, $is_like);
+ if ($r) {
+ $member_where[] = $r;
+ $param_new[$name] = $this->get[$name];
+ }
+ }
+ }
+ }
+ // 鎸変細鍛樼粍鎼滅储鏃
+ if ($param['groupid'] != '') {
+ $member_where[] = '`'.$this->dbprefix('member_data').'`.`id` IN (SELECT `uid` FROM `'.$this->dbprefix('member').'_group_index` WHERE gid='.intval($param['groupid']).')';
+ $param_new['groupid'] = $this->get['groupid'];
+ }
+ // 缁勫悎浼氬憳瀛楁
+ if ($member_where) {
+ $where[] = '`'.$table.'`.`uid` IN (select `id` from `'.$this->dbprefix('member_data').'` where '.implode(' AND ', $member_where).')';
+ }
+ }
+
+ // flag
+ if (isset($param['flag']) && $param['flag']) {
+ $wh = [];
+ $arr = explode('|', $param['flag']);
+ foreach ($arr as $k) {
+ $wh[] = intval($k);
+ }
+ $where[] = '`'.$table.'`.`id` IN (select `id` from `'.$table.'_flag` where `flag` in ('.implode(',', $wh).'))';
+ $param_new['flag'] = $param['flag'];
+ }
+
+ // 绛涢夌┖鍊
+ foreach ($where as $i => $t) {
+ if (dr_strlen($t) == 0) {
+ unset($where[$i]);
+ }
+ }
+
+ // 鑷畾涔夌粍鍚堟煡璇
+ isset($param['catid']) && $param_new['catid'] = $param['catid'];
+ isset($param['catdir']) && $param_new['catdir'] = $param['catdir'];
+ isset($param['keyword']) && $param_new['keyword'] = $param['keyword'];
+ $param_new = $this->myparam($param_new);
+ $where = $this->mysearch($this->module, $where, $param_new);
+ $where = $where ? implode(' AND ', $where) : '';
+ $where_sql = $where ? 'WHERE '.$where : '';
+
+ // 缁勫悎sql鏌ヨ缁撴灉
+ $sql = "SELECT `{$table}`.`id` FROM `".$table."` {$where_sql} ORDER BY NULL ";
+
+ // 缁熻鎼滅储鏁伴噺
+ $ct = $this->db->query("SELECT count(*) as t FROM `".$table."` {$where_sql} ORDER BY NULL ")->getRowArray();
+ $data = [
+ 'id' => $id,
+ 'catid' => intval($catid),
+ 'params' => dr_array2string(['param' => $param_new, 'sql' => $sql, 'where' => $where]),
+ 'keyword' => $param['keyword'] ? $param['keyword'] : '',
+ 'contentid' => intval($ct['t']),
+ 'inputtime' => SYS_TIME
+ ];
+ if ($ct['t']) {
+ // 瀛樺偍鏁版嵁
+ $this->db->table($this->mytable.'_search')->replace($data);
+ }
+ } else {
+ $this->db->table($this->mytable.'_search')->where('id', $data['id'])->update([
+ 'inputtime' => SYS_TIME
+ ]);
+ }
+
+ // 鏍煎紡鍖栧
+ $p = dr_string2array($data['params']);
+ $data['sql'] = $p['sql'];
+ $data['where'] = $p['where'];
+ $data['params'] = $p['param'];
+ if (isset($param['catdir']) && $param['catdir'] && $catid) {
+ # 鐩綍鏍忕洰妯″紡
+ unset($data['params']['catid']);
+ } elseif ($catid) {
+ $data['params']['catid'] = $catid;
+ }
+ // order 鍙傛暟
+ if (isset($param['order']) && $param['order']) {
+ $data['params']['order'] = dr_rp(dr_safe_filename($param['order']), '`', '');
+ }
+
+ return $data;
+ }
+
+ // 閲嶇粍鎼滅储鏉′欢
+ protected function mywhere($table, $name, $value, $field, $is_like = false) {
+ $is_double_like = intval($this->module['setting']['search']['is_double_like']);
+ if ($is_double_like && isset($field['fieldtype']) && in_array($field['fieldtype'], [
+ 'Selects' , 'Checkbox', 'Cats', 'Radio', 'Select', 'Linkages', 'Linkage'
+ ])) {
+ $value.= '||';
+ }
+ $where = $this->_where($table, $name, $value, $field, $is_like);
+ return $where;
+ }
+
+ // 鑷畾涔夌粍鍚堝弬鏁
+ protected function myparam($get) {
+ return $get;
+ }
+
+ // 鑷畾涔夌粍鍚堟煡璇㈡潯浠
+ protected function mysearch($module, $where, $get) {
+ return $where;
+ }
+
+}
+
+
+namespace Phpcmf\Model;
+class Search extends \Phpcmf\Model\Cms\Search {
+
+}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Models/Site.php b/dayrui/App/Cms/Models/Site.php
new file mode 100644
index 0000000..cf97993
--- /dev/null
+++ b/dayrui/App/Cms/Models/Site.php
@@ -0,0 +1,680 @@
+table('site')->get($siteid);
+ if (!$site) {
+ return [];
+ }
+
+ $site['setting'] = dr_string2array($site['setting']);
+ $site['setting']['config']['SITE_THEME'] = $name;
+
+ $this->table('site')->update($siteid, [
+ 'setting' => dr_array2string($site['setting']),
+ ]);
+ }
+
+ // 璁剧疆妯℃澘
+ public function set_template($name, $siteid) {
+
+ $site = $this->table('site')->get($siteid);
+ if (!$site) {
+ return [];
+ }
+
+ $site['setting'] = dr_string2array($site['setting']);
+ $site['setting']['config']['SITE_TEMPLATE'] = $name;
+
+ $this->table('site')->update($siteid, [
+ 'setting' => dr_array2string($site['setting']),
+ ]);
+ }
+
+ // 鑾峰彇缃戠珯閰嶇疆
+ public function config($siteid, $name = '', $data = []) {
+
+ !$siteid && $siteid = SITE_ID;
+ $site = $this->table('site')->get($siteid);
+ if (!$site) {
+ return [];
+ }
+
+ $site['setting'] = dr_string2array($site['setting']);
+ $site['setting']['config']['SITE_NAME'] = $site['name'];
+ $site['setting']['config']['SITE_DOMAIN'] = strtolower((string)$site['domain']);
+
+ if ($name && $data) {
+ // 鏇存柊鏁版嵁
+ if ($data['SITE_NAME']) {
+ $site['name'] = $data['SITE_NAME'];
+ }
+ if ($data['SITE_DOMAIN']) {
+ $site['domain'] = $data['SITE_DOMAIN'];
+ }
+ $site['setting'][$name] = $data;
+ $this->table('site')->update($siteid, [
+ 'name' => $site['name'],
+ 'domain' => strtolower((string)$site['domain']),
+ 'setting' => dr_array2string($site['setting']),
+ ]);
+ }
+
+ return $site['setting'];
+ }
+
+ // 瀛樺偍缃戠珯閰嶇疆
+ public function save_config($siteid, $name, $data) {
+
+ !$siteid && $siteid = SITE_ID;
+ $site = $this->table('site')->get($siteid);
+ if (!$site) {
+ return [];
+ }
+
+ $site['setting'] = dr_string2array($site['setting']);
+ $site['setting']['config']['SITE_NAME'] = $site['name'];
+ $site['setting']['config']['SITE_DOMAIN'] = strtolower((string)$site['domain']);
+
+ // 鏇存柊鏁版嵁
+ if ($data['SITE_NAME']) {
+ $site['name'] = $data['SITE_NAME'];
+ }
+ if ($data['SITE_DOMAIN']) {
+ $site['domain'] = $data['SITE_DOMAIN'];
+ }
+ $site['setting'][$name] = $data;
+ $this->table('site')->update($siteid, [
+ 'name' => $site['name'],
+ 'domain' => strtolower((string)$site['domain']),
+ 'setting' => dr_array2string($site['setting']),
+ ]);
+
+ return $site['setting'];
+ }
+
+ // 璁剧疆缃戠珯鍗曚釜閰嶇疆
+ public function config_value($siteid, $group, $value) {
+
+ !$siteid && $siteid = SITE_ID;
+ $site = $this->table('site')->get($siteid);
+ if (!$site || !$value) {
+ return;
+ }
+
+ $site['setting'] = dr_string2array($site['setting']);
+
+ foreach ($value as $n => $v) {
+ $site['setting'][$group][$n] = $v;
+ }
+
+ $this->table('site')->update($siteid, [
+ 'setting' => dr_array2string($site['setting']),
+ ]);
+
+ return;
+ }
+
+ // 鏂板
+ public function create($data) {
+
+ $save = [
+ 'name' => $data['name'],
+ 'domain' => (string)$data['domain'],
+ 'setting' => dr_array2string([
+ 'webpath' => $data['webpath'],
+ ]),
+ 'disabled' => 0,
+ 'displayorder' => 0,
+ ];
+ if (defined('IS_INSTALL')) {
+ $save['id'] = 1;
+ }
+ $this->db->table('site')->replace($save);
+
+ $siteid = $this->db->insertID();
+
+ if ($siteid == 1) {
+ return $siteid; // 瀹夎涓嶆墽琛屽悗闈㈡搷浣
+ }
+
+ if (dr_is_app('sites')) {
+ $obj = \Phpcmf\Service::M('sites', 'sites');
+ if (method_exists($obj, 'create')) {
+ $obj->create($siteid, $data);
+ }
+ }
+
+ return $siteid;
+ }
+
+ // 鍙樻洿涓诲煙鍚
+ public function edit_domain($value) {
+
+ $site = $this->config(1);
+ $value = trim(strtolower($value), '/');
+ $this->db->table('site')->where('id', 1)->update([
+ 'domain' => $value,
+ 'setting' => dr_array2string($site),
+ ]);
+ // 鏇挎崲鏍忕洰缂栬緫鍣ㄥ煙鍚
+ $table = $this->dbprefix(SITE_ID.'_share_category');
+ if ($this->is_table_exists($table)) {
+ $this->db->query('UPDATE `'.$table.'` SET `content`=REPLACE(`content`, \''.$site['config']['SITE_DOMAIN'].'\', \''.$value.'\')');
+ }
+ }
+
+ // 璁剧疆鍩熷悕
+ public function domain($value = []) {
+
+ $data = [];
+ $site = $this->config(SITE_ID);
+ if ($value) {
+ $site['webpath'] = $value['webpath'];
+ $this->db->table('site')->where('id', SITE_ID)->update([
+ 'domain' => trim(strtolower($value['site_domain'] ? $value['site_domain'] : $site['domain']), '/'),
+ 'setting' => dr_array2string($site),
+ ]);
+ }
+
+ $data['webpath'] = $site['webpath'];
+ $data['site_domain'] = strtolower((string)$site['config']['SITE_DOMAIN']);
+
+ // 璇嗗埆鎵嬫満鍩熷悕
+ if (isset($site['mobile']['mode']) && $site['mobile']['mode'] != -1) {
+ if (!$site['mobile']['mode']) {
+ $data['mobile_domain'] = $site['mobile']['domain'];
+ } else {
+ $data['mobile_domain'] = $site['config']['SITE_DOMAIN'].'/'.trim($site['mobile']['dirname'] ? $site['mobile']['dirname'] : 'mobile');
+ }
+ } else {
+ $data['mobile_domain'] = $site['mobile']['domain'];
+ }
+
+ if ($site['client']) {
+ foreach ($site['client'] as $c) {
+ if ($c['name'] && $c['domain']) {
+ $data['client_'.$c['name']] = $c['domain'];
+ }
+ }
+ }
+
+ // 妯″潡鍩熷悕
+ $my = [];
+ if (IS_USE_MODULE) {
+ list($my, $data) = \Phpcmf\Service::M('module', 'cms')->domian($value, $my, $data);
+ }
+
+ return [$my, $data];
+ }
+
+ // 绔欑偣缂撳瓨缂撳瓨
+ public function cache($siteid = null, $data = null, $module = null) {
+
+ !$data && $data = $this->table('site')->where('disabled', 0)->order_by('displayorder ASC,id ASC')->getAll();
+ $sso_domain = $client_domain = $webpath = $app_domain = $site_domain = $config = $cache = [];
+ if ($data) {
+ foreach ($data as $t) {
+ if ($t['id'] > 1 && !dr_is_app('sites')) {
+ break;
+ }
+
+ $t['setting'] = dr_string2array($t['setting']);
+ $mobile_dirname = 'mobile';
+
+ // 璇嗗埆鎵嬫満鍩熷悕
+ if (isset($t['setting']['mobile']['mode']) && $t['setting']['mobile']['mode'] != -1) {
+ if (!$t['setting']['mobile']['mode']) {
+ $mobile_domain = (string)$t['setting']['mobile']['domain'];
+ } else {
+ $mobile_dirname = trim($t['setting']['mobile']['dirname'] ? $t['setting']['mobile']['dirname'] : 'mobile');
+ $mobile_domain = $t['domain'].'/'.$mobile_dirname;
+ }
+ } else {
+ $mobile_domain = (string)$t['setting']['mobile']['domain'];
+ }
+
+ $config[$t['id']] = [
+ 'SITE_NAME' => $t['name'],
+ 'SITE_DOMAIN' => strtolower($t['domain']),
+ 'SITE_LOGO' => $t['setting']['config']['logo'] ? dr_get_file($t['setting']['config']['logo']) : ROOT_THEME_PATH.'assets/logo-web.png',
+ 'SITE_MOBILE' => $mobile_domain,
+ 'SITE_MOBILE_DIR' => $mobile_dirname,
+ 'SITE_AUTO' => (string)$t['setting']['mobile']['auto'],
+ 'SITE_IS_MOBILE_HTML' => (string)$t['setting']['mobile']['tohtml'],
+ 'SITE_MOBILE_NOT_PAD' => (string)$t['setting']['mobile']['not_pad'],
+ 'SITE_CLOSE' => $t['setting']['config']['SITE_CLOSE'],
+ 'SITE_THEME' => $t['setting']['config']['SITE_THEME'],
+ 'SITE_TEMPLATE' => $t['setting']['config']['SITE_TEMPLATE'],
+ 'SITE_REWRITE' => $t['setting']['seo']['SITE_REWRITE'],
+ 'SITE_SEOJOIN' => $t['setting']['seo']['SITE_SEOJOIN'],
+ 'SITE_LANGUAGE' => $t['setting']['config']['SITE_LANGUAGE'],
+ 'SITE_TIMEZONE' => $t['setting']['config']['SITE_TIMEZONE'],
+ 'SITE_TIME_FORMAT' => $t['setting']['config']['SITE_TIME_FORMAT'],
+ 'SITE_INDEX_HTML' => (string)$t['setting']['config']['SITE_INDEX_HTML'],
+ 'SITE_THUMB_WATERMARK' => (int)$t['setting']['watermark']['thumb'],
+ ];
+ unset($t['setting']['mobile']['auto'],
+ $t['setting']['mobile']['domain'],
+ $t['setting']['seo']['SITE_REWRITE'],
+ $t['setting']['seo']['SITE_SEOJOIN'],
+ $t['setting']['config']['SITE_THEME'],
+ $t['setting']['config']['SITE_TEMPLATE'],
+ $t['setting']['config']['SITE_LANGUAGE'],
+ $t['setting']['config']['SITE_TIME_FORMAT'],
+ $t['setting']['config']['SITE_NAME'],
+ $t['setting']['config']['SITE_TIMEZONE'],
+ $t['setting']['config']['SITE_DOMAIN'],
+ $t['setting']['config']['SITE_CLOSE']
+ );
+ // 鏈珯鐨勫叏閮ㄥ煙鍚嶅綊灞
+ $site_domain[$t['domain']] = $t['id'];
+ $sso_domain[] = $t['domain'];
+ if ($config[$t['id']]['SITE_MOBILE']) {
+ $site_domain[$config[$t['id']]['SITE_MOBILE']] = $t['id'];
+ $client_domain[$t['domain']] = $config[$t['id']]['SITE_MOBILE'];
+ $sso_domain[] = $config[$t['id']]['SITE_MOBILE'];
+ }
+ // 鑷畾涔夌粓绔
+ if ($t['setting']['client']) {
+ $_save = [];
+ foreach ($t['setting']['client'] as $c) {
+ $site_domain[$c['domain']] = $t['id'];
+ $_save[$c['name']] = $sso_domain[] = $c['domain'];
+ }
+ $t['setting']['client'] = $_save;
+ }
+
+ // 缃戠珯璺緞
+ $webpath[$t['id']] = [
+ 'site' => ROOTPATH,
+ ];
+ if ($t['id'] > 1 && $t['setting']['webpath']) {
+ $webpath[$t['id']]['site'] = dr_get_dir_path($t['setting']['webpath']);
+ if (!is_dir($webpath[$t['id']]['site'])) {
+ log_message('error', '澶氱珯鐐癸細绔欑偣銆'.$t['id'].'銆戠洰褰曘'.$webpath[$t['id']]['site'].'銆戜笉瀛樺湪');
+ //continue;
+ }
+ }
+
+ // 鑷畾涔夌珯鐐瑰瓧娈
+ $field = \Phpcmf\Service::M('field')->get_mysite_field($t['id']);
+ if ($field && $t['setting']['param']) {
+ $t['setting']['param'] = \Phpcmf\Service::L('Field')->app('')->format_value($field, $t['setting']['param'], 1);
+ }
+
+ // 鍒犻櫎棣栭〉闈欐佹枃浠
+ //unlink($webpath[$t['id']]['site'].'index.html');
+ //unlink($webpath[$t['id']]['site'].$mobile_dirname.'/index.html');
+
+ $cache[$t['id']] = $t['setting'];
+ }
+
+ list($webpath, $site_domain, $app_domain, $sso_domain, $client_domain) = \Phpcmf\Service::M('module', 'cms')->sync_site_cache(
+ $module,
+ $webpath,
+ $site_domain,
+ $app_domain,
+ $sso_domain,
+ $client_domain,
+ [],
+ $data
+ );
+ }
+
+ \Phpcmf\Service::L('Cache')->set_file('site', $cache);
+ \Phpcmf\Service::L('Config')->file(WRITEPATH.'config/site.php', '绔欑偣閰嶇疆鏂囦欢', 32)->to_require($config);
+ \Phpcmf\Service::L('Config')->file(WRITEPATH.'config/domain_sso.php', '鍚屾鍩熷悕閰嶇疆鏂囦欢', 32)->to_require_one($sso_domain);
+ \Phpcmf\Service::L('Config')->file(WRITEPATH.'config/domain_app.php', '缃戠珯鍩熷悕閰嶇疆鏂囦欢', 32)->to_require_one($app_domain);
+ \Phpcmf\Service::L('Config')->file(WRITEPATH.'config/domain_site.php', '绔欑偣鍩熷悕閰嶇疆鏂囦欢', 32)->to_require_one($site_domain);
+ \Phpcmf\Service::L('Config')->file(WRITEPATH.'config/domain_client.php', '瀹㈡埛绔煙鍚嶉厤缃枃浠', 32)->to_require_one($client_domain);
+ \Phpcmf\Service::L('Config')->file(WRITEPATH.'config/webpath.php', '鍏ュ彛鏂囦欢鐩綍閰嶇疆鏂囦欢', 32)->to_require($webpath);
+ }
+
+
+ // 鏇存柊鍏ㄩ儴缃戠珯缂撳瓨
+ public function update_site_cache() {
+
+ $site_cache = $this->table('site')->where('disabled', 0)->order_by('displayorder ASC,id ASC')->getAll();
+ $module_cache = $this->table('module')->order_by('displayorder ASC,id ASC')->getAll();
+
+ // 鎸夌綉绔欐洿鏂扮殑缂撳瓨
+ $cache = [];
+
+ if (is_file(MYPATH.'/Config/Cache.php')) {
+ $_cache = require MYPATH.'/Config/Cache.php';
+ $_cache && $cache = dr_array22array($cache, $_cache);
+ }
+
+ // 鎵ц鎻掍欢鑷繁鐨勭紦瀛樼▼搴
+ $menu = \Phpcmf\Service::M('menu');
+ $local = \Phpcmf\Service::Apps(1);
+ $app_cache = [];
+ foreach ($local as $dir => $path) {
+ if (is_file($path.'Config/Cache.php')) {
+ $_cache = require $path.'Config/Cache.php';
+ $_cache && $app_cache[$dir] = $_cache;
+ }
+ // 鏇存柊鏂板鑿滃崟
+ if (method_exists($menu, 'update_app')) {
+ $menu->update_app($dir);
+ }
+ }
+
+ $page = intval($_GET['page']);
+ $tpage = dr_count($site_cache);
+
+ if (!$page) {
+ // 鍏ㄥ眬绯荤粺缂撳瓨
+ #dr_dir_delete(WRITEPATH.'data');
+ \Phpcmf\Service::M('site')->cache(0, $site_cache, $module_cache);
+ foreach (['auth', 'email', 'member', 'attachment', 'system'] as $m) {
+ \Phpcmf\Service::M($m)->cache();
+ }
+ \Phpcmf\Service::C()->_json(1, dr_lang('姝e湪缂撳瓨鏁版嵁'), 1);
+ }
+
+ $key = $page - 1;
+ if (!isset($site_cache[$key])) {
+ \Phpcmf\Service::M('menu')->cache();
+ \Phpcmf\Service::M('cache')->update_data_cache();
+ \Phpcmf\Service::C()->_json(1, dr_lang('鏇存柊瀹屾垚'));
+ }
+
+ foreach ([ $site_cache[$key] ] as $t) {
+
+ \Phpcmf\Service::M('table')->cache($t['id'], $module_cache);
+ \Phpcmf\Service::M('module')->cache($t['id'], $module_cache);
+
+ foreach ($cache as $m => $namespace) {
+ \Phpcmf\Service::M($m, $namespace)->cache($t['id']);
+ }
+
+ // 鎻掍欢缂撳瓨
+ $apps = [];
+ if ($app_cache) {
+ foreach ($app_cache as $namespace => $c) {
+ \Phpcmf\Service::C()->init_file($namespace);
+ foreach ($c as $i => $apt) {
+ $class = is_numeric($i) ? $apt : $i;
+ $apps[] = '['.$namespace.'-'.$class.']';
+ \Phpcmf\Service::M($class, $namespace)->cache($t['id']);
+ }
+ }
+ }
+
+ // 璁板綍鏃ュ織
+ CI_DEBUG && \Phpcmf\Service::L('input')->system_log('鏇存柊[缃戠珯#'.$t['id'].']缂撳瓨锛 '.implode(' - ', $apps));
+ }
+
+ \Phpcmf\Service::C()->_json(1, dr_lang('姝e湪鏇存柊涓紙%s/%s锛', $page+1, $tpage), $page + 1);
+ }
+
+ // 鏇存柊褰撳墠缃戠珯缂撳瓨
+ public function update_cache() {
+
+ $site_cache = $this->table('site')->where('disabled', 0)->order_by('displayorder ASC,id ASC')->getAll();
+ $module_cache = $this->table('module')->order_by('displayorder ASC,id ASC')->getAll();
+ \Phpcmf\Service::M('site')->cache(0, $site_cache, $module_cache);
+
+ // 鍏ㄥ眬缂撳瓨
+ foreach (['auth', 'email', 'member', 'attachment', 'system'] as $m) {
+ \Phpcmf\Service::M($m)->cache();
+ }
+
+ // 鎸夌綉绔欐洿鏂扮殑缂撳瓨
+ $cache = [];
+
+ if (is_file(MYPATH.'/Config/Cache.php')) {
+ $_cache = require MYPATH.'/Config/Cache.php';
+ $_cache && $cache = dr_array22array($cache, $_cache);
+ }
+
+ // 鎵ц鎻掍欢鑷繁鐨勭紦瀛樼▼搴
+ $menu = \Phpcmf\Service::M('menu');
+ $local = \Phpcmf\Service::Apps(1);
+ $app_cache = [];
+ foreach ($local as $dir => $path) {
+ if (is_file($path.'Config/Cache.php')) {
+ $_cache = require $path.'Config/Cache.php';
+ $_cache && $app_cache[$dir] = $_cache;
+ }
+ // 鏇存柊鏂板鑿滃崟
+ if (method_exists($menu, 'update_app')) {
+ $menu->update_app($dir);
+ }
+ }
+
+ foreach ($site_cache as $t) {
+
+ if (!in_array($t['id'], [SITE_ID, 1])) {
+ continue;
+ }
+
+ \Phpcmf\Service::M('table')->cache($t['id'], $module_cache);
+ \Phpcmf\Service::M('module')->cache($t['id'], $module_cache);
+
+ if ($cache) {
+ foreach ($cache as $m => $namespace) {
+ $obj = \Phpcmf\Service::M($m, $namespace);
+ if ($obj && method_exists($obj, 'cache')) {
+ $obj->cache($t['id']);
+ }
+ }
+ }
+
+ // 鎻掍欢缂撳瓨
+ $apps = [];
+ if ($app_cache) {
+ foreach ($app_cache as $namespace => $c) {
+ \Phpcmf\Service::C()->init_file($namespace);
+ foreach ($c as $i => $apt) {
+ $class = is_numeric($i) ? $apt : $i;
+ $obj = \Phpcmf\Service::M($class, $namespace);
+ if ($obj && method_exists($obj, 'cache')) {
+ $apps[] = '['.$namespace.'-'.$class.']';
+ $obj->cache($t['id']);
+ }
+ }
+ }
+ }
+
+ // 璁板綍鏃ュ織
+ CI_DEBUG && \Phpcmf\Service::L('input')->system_log('鏇存柊[缃戠珯#'.$t['id'].']缂撳瓨锛 '.implode(' - ', $apps));
+ }
+
+ \Phpcmf\Service::M('menu')->cache();
+
+ }
+
+
+ // 閲嶅缓绱㈠紩
+ public function update_search_index() {
+
+ $site_cache = $this->table('site')->where('disabled', 0)->getAll();
+ $module_cache = $this->table('module')->getAll();
+ if (!$module_cache) {
+ return;
+ }
+
+ foreach ($site_cache as $t) {
+ foreach ($module_cache as $m ) {
+ $table = dr_module_table_prefix($m['dirname'], $t['id']);
+ // 鍒ゆ柇鏄惁瀛樺湪琛
+ if (!$this->db->tableExists($table)) {
+ continue;
+ }
+ $this->db->table($table.'_search')->truncate();
+ }
+ }
+ }
+
+
+ // 閲嶅缓瀛愮珯閰嶇疆鏂囦欢
+ public function update_site_config() {
+
+ $page = intval($_GET['page']);
+ if (!$page) {
+ $site_cache = $this->table('site')->where('disabled', 0)->getAll();
+ foreach ($site_cache as $t) {
+ $t['setting'] = dr_string2array($t['setting']);
+ if ($t['id'] > 1 && $t['setting']['webpath']) {
+ $rt = $this->update_webpath('Web', $t['setting']['webpath'], [
+ 'SITE_ID' => $t['id'],
+ 'FIX_WEB_DIR' => strpos($t['setting']['webpath'], '/') === false && strpos($t['domain'], $t['setting']['webpath']) !== false ? $t['setting']['webpath'] : '',
+ 'MOBILE_DIR' => $t['setting']['mobile']['mode'] == 1 ? $t['setting']['mobile']['dirname'] : '',
+ ]);
+ if ($rt) {
+ $this->_error_msg('缃戠珯['.$t['domain'].']: '.$rt);
+ }
+ $path = rtrim($t['setting']['webpath'], '/').'/';
+ } else {
+ $path = ROOTPATH;
+ }
+ if ($t['setting']['client'] && !dr_is_app('client')) {
+ foreach ($t['setting']['client'] as $c) {
+ if ($c['name'] && $c['domain']) {
+ $rt = $this->update_webpath('Client', $path.$c['name'].'/', [
+ 'CLIENT' => $c['name'],
+ 'SITE_ID' => $t['id'],
+ 'FIX_WEB_DIR' => $c['domain'] == $t['domain'].'/'.$c['name'] ? $c['name'] : '',
+ 'SITE_FIX_WEB_DIR' => $t['setting']['webpath'] && strpos($t['setting']['webpath'], '/') === false && strpos($t['domain'], $t['setting']['webpath']) !== false ? $t['setting']['webpath'] : '',
+ ]);
+ if ($rt) {
+ $this->_error_msg('缃戠珯['.$t['domain'].']鐨勭粓绔痆'.$c['name'].']: '.$rt);
+ }
+ }
+ }
+ }
+ }
+ \Phpcmf\Service::L('cache')->set_auth_data('update_site_config', $this->table('module')->where('share', 0)->getAll());
+ \Phpcmf\Service::C()->_json(1, dr_lang('姝e湪鍑嗗鏇存柊'), 1);
+ }
+
+ $module = \Phpcmf\Service::L('cache')->get_auth_data('update_site_config');
+ if (!$module) {
+ \Phpcmf\Service::C()->_json(1, dr_lang('鏃犲彲鐢ㄦ洿鏂'), 0);
+ }
+
+ $key = $page - 1;
+ if (!isset($module[$key])) {
+ \Phpcmf\Service::C()->_json(1, dr_lang('鏇存柊瀹屾垚'), 0);
+ }
+
+ \Phpcmf\Service::M('module', 'cms')->update_site_config($module[$key]);
+
+ \Phpcmf\Service::C()->_json(1, dr_lang('姝e湪鏇存柊涓紙%s锛', $page), $page + 1);
+ }
+
+ // 鐢熸垚鐩綍寮忔墜鏈虹洰褰
+ public function update_mobile_webpath($path, $dirname) {
+
+ foreach (['api.php', 'index.php'] as $file) {
+ if (is_file(IS_USE_MODULE.'Temps/Web/mobile/'.$file)) {
+ $dst = $path.$dirname.'/'.$file;
+ dr_mkdirs(dirname($dst));
+ $size = file_put_contents($dst, str_replace([
+ '{FIX_WEB_DIR}'
+ ], [
+ (defined('FIX_WEB_DIR') && FIX_WEB_DIR ? FIX_WEB_DIR.'/' : '').$dirname
+ ], file_get_contents(IS_USE_MODULE.'Temps/Web/mobile/'.$file)));
+ if (!$size) {
+ return '鏂囦欢['.$dst.']鏃犳硶鍐欏叆';
+ }
+ }
+ }
+
+ return;
+ }
+
+ // 鏇存柊缃戠珯
+ public function update_webpath($name, $path, $value, $root = IS_USE_MODULE.'Temps/') {
+
+ if (!$path) {
+ return '鐩綍涓虹┖';
+ } elseif (strpos($path, ' ') === 0) {
+ return '涓嶈兘鐢ㄧ┖鏍煎紑澶';
+ }
+
+ $path = dr_get_dir_path($path);
+ if (!$path) {
+ return '鐩綍涓虹┖';
+ }
+
+ dr_mkdirs($path);
+ if (!is_dir($path)) {
+ return '鐩綍['.$path.']涓嶅瓨鍦';
+ }
+
+ // 鍒涘缓鍏ュ彛鏂囦欢
+ //(defined('FIX_WEB_DIR') && FIX_WEB_DIR ? FIX_WEB_DIR.'/' : '').
+
+ foreach ([
+ 'admin.php',
+ 'index.php',
+ 'api.php',
+ 'mobile/api.php',
+ 'mobile/index.php',
+ ] as $file) {
+ if (is_file($root.$name.'/'.$file)) {
+ if ($file == 'admin.php') {
+ $dst = $path.(SELF == 'index.php' ? 'admin.php' : SELF);
+ } else {
+ $dst = $path.$file;
+ }
+ $fix_web_dir = isset($value['FIX_WEB_DIR']) && $value['FIX_WEB_DIR'] ? $value['FIX_WEB_DIR'] : '';
+ if (isset($value['SITE_ID']) && $value['SITE_ID'] > 1) {
+ if (strpos($file, 'mobile') !== false
+ && isset($value['MOBILE_DIR']) && $value['MOBILE_DIR']) {
+ $fix_web_dir.= '/'.$value['MOBILE_DIR'];
+ } elseif ($fix_web_dir) {
+ // 绉诲姩绔姞浜岀骇
+ if (strpos($file, 'mobile/') !== false) {
+ $fix_web_dir.= '/mobile';
+ }
+ // 缁堢鍔犱簩绾
+ if ( $name == 'Client') {
+ $fix_web_dir= (isset($value['SITE_FIX_WEB_DIR']) && $value['SITE_FIX_WEB_DIR'] ? $value['SITE_FIX_WEB_DIR'].'/' : '').$fix_web_dir;
+ }
+ }
+ }
+ dr_mkdirs(dirname($dst));
+ $size = file_put_contents($dst, str_replace([
+ '{CLIENT}',
+ '{ROOTPATH}',
+ '{MOD_DIR}',
+ '{SITE_ID}',
+ '{FIX_WEB_DIR}'
+ ], [
+ $value['CLIENT'],
+ ROOTPATH,
+ $value['MOD_DIR'],
+ $value['SITE_ID'],
+ trim($fix_web_dir, '/')
+ ], file_get_contents($root.$name.'/'.$file)));
+ if (!$size) {
+ return '鏂囦欢['.$dst.']鏃犳硶鍐欏叆';
+ }
+ }
+ }
+
+ // 澶嶅埗鐧惧害缂栬緫鍣ㄥ埌褰撳墠鐩綍
+ //$this->cp_ueditor_file($path);
+
+ // 澶嶅埗鐧惧害缂栬緫鍣ㄥ埌绉诲姩绔綉绔
+ //if (is_dir($path.'mobile')) {
+ //$this->cp_ueditor_file($path.'mobile/');
+ //}
+
+ return '';
+ }
+
+ // 閿欒杈撳嚭
+ public function _error_msg($msg) {
+ echo dr_array2string(dr_return_data(0, $msg));exit;
+ }
+}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Models/Urlrule.php b/dayrui/App/Cms/Models/Urlrule.php
new file mode 100644
index 0000000..89be33e
--- /dev/null
+++ b/dayrui/App/Cms/Models/Urlrule.php
@@ -0,0 +1,21 @@
+admin['roleid'])) {
+ return 1; // 瓒呯鐢ㄦ埛
+ } elseif ($status == 0) {
+ return 1; // 閫绋跨殑鍙互鐪嬪埌
+ } elseif (\Phpcmf\Service::M('auth')->is_post_user()) {
+ return 0; // 鎶曠ǹ鑰呬笉鍏佽缂栬緫瀹℃牳
+ }
+
+ if (!IS_USE_MEMBER) {
+ return 1;
+ }
+
+ $verify = \Phpcmf\Service::C()->get_cache('verify');
+ if (!$verify) {
+ return 0; // 娌℃湁瀹℃牳娴佺▼鏃
+ }
+
+ $my = [];
+ foreach ($verify as $t) {
+ if ($t['value']['role']) {
+ $rid = [];
+ foreach ($t['value']['role'] as $c) {
+ if (is_array($c)) {
+ $rid = array_merge($rid, $c);
+ } elseif (is_numeric($c)) {
+ $rid[] = $c;
+ }
+ }
+ if (dr_array_intersect($rid, $this->admin['roleid'])) {
+ $my[] = $t['id'];
+ }
+ }
+ }
+
+ if (!$my) {
+ // 姝ょ鐞嗗憳娌℃湁绠$悊鏉冮檺
+ return 0;
+ }
+
+ // 鏈夋潈闄愪簡
+ if (dr_in_array($vid, $my)) {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ // 鑾峰彇褰撳墠鏍忕洰鐨勬椂鍊欐祦绋
+ public function _get_verify($vid) {
+
+ $rt = [];
+ $cache = \Phpcmf\Service::C()->get_cache('verify');
+ if ($cache && $vid && $cache[$vid]) {
+ $verify = $cache[$vid];
+ if ($verify['value']['role']) {
+ $role = \Phpcmf\Service::C()->get_cache('auth');
+ foreach ($verify['value']['role'] as $id => $rid) {
+ if (!is_array($rid)) {
+ if (isset($role[$rid]) && $role[$rid]) {
+ $rt[$id] = [
+ 'rid' => $rid,
+ 'name' => dr_lang($role[$rid]['name'] ? $role[$rid]['name'] : '绠$悊鍛'),
+ ];
+ }
+ } else {
+ $ns = [];
+ foreach ($rid as $r) {
+ if (isset($role[$r]) && $role[$r]) {
+ $ns[] = dr_lang($role[$r]['name'] ? $role[$r]['name'] : '绠$悊鍛');
+ }
+ }
+ if ($ns) {
+ $ns = array_unique($ns);
+ $rt[$id] = [
+ 'rid' => $r,
+ 'name' => implode('銆', $ns),
+ ];
+ }
+ }
+ }
+ }
+ }
+
+ $rt[9] = [
+ 'name' => dr_lang('瀹屾垚'),
+ ];
+
+ return $rt;
+ }
+
+ // 瀹℃牳鏃跺欑殑鏉冮檺缁,杩斿洖鍙敤鏉冮檺缁勭殑id
+ // array(
+ // * to_uid 鎸囧畾浜
+ // * to_rid 鎸囧畾瑙掕壊缁
+ // * )
+ public function _get_verify_roleid($catid, $status, $member) {
+
+ $verify = \Phpcmf\Service::C()->get_cache('verify');
+ if (!$verify) {
+ return ['to_uid' => 0, 'to_rid' => 0, 'verify_id' => 0];
+ }
+
+ if (IS_MEMBER) {
+ // 鍓嶇鎵剧敤鎴疯缃
+ $auth = \Phpcmf\Service::M('member_auth', 'cms')->category_auth(\Phpcmf\Service::C()->module, $catid, 'verify', $member);
+ } else {
+ // 鍚庡彴鎶曠ǹ鑰
+ $auth = \Phpcmf\Service::M('auth')->is_post_user_status();
+ }
+
+ if ($auth && isset($verify[$auth]) && $verify[$auth]) {
+ $v = $verify[$auth];
+ $status = max(1, $status);
+ if (isset($v['value']['role'][$status]) && $v['value']['role'][$status]) {
+ if (is_array($v['value']['role'][$status])) {
+ return ['to_uid' => 0, 'to_rid' => implode(',', $v['value']['role'][$status]), 'verify_id' => $v['id']];
+ } else {
+ return ['to_uid' => 0, 'to_rid' => $v['value']['role'][$status], 'verify_id' => $v['id']];
+ }
+ }
+ }
+
+ return ['to_uid' => 0, 'to_rid' => 0, 'verify_id' => 0];
+ }
+
+ // 鍚庡彴鍐呭瀹℃牳鍒楄〃鐨勬潈闄愮殑sql璇彞
+ public function get_admin_verify_status_list() {
+
+ if (dr_in_array(1, \Phpcmf\Service::C()->admin['roleid'])) {
+ return '`status`>=0'; // 瓒呯鐢ㄦ埛
+ } elseif (!IS_USE_MEMBER && !\Phpcmf\Service::M('auth')->is_post_user()) {
+ return '`status`>=0'; // 鏅氱鐞嗗憳
+ }
+
+ $verify = \Phpcmf\Service::C()->get_cache('verify');
+ if (!$verify) {
+ return '`status`=0'; // 娌℃湁瀹℃牳娴佺▼鏃
+ }
+
+ $where = [];
+ foreach ($verify as $t) {
+ if ($t['value']['role']) {
+ foreach ($t['value']['role'] as $status => $rid) {
+ if (is_array($rid)) {
+ if (dr_array_intersect($rid, \Phpcmf\Service::C()->admin['roleid'])) {
+ $where[] = '(`status`='.$status.' and `vid`='.$t['id'].')';
+ }
+ } else {
+ if (dr_in_array($rid, \Phpcmf\Service::C()->admin['roleid'])) {
+ $where[] = '(`status`='.$status.' and `vid`='.$t['id'].')';
+ }
+ }
+ }
+ }
+ }
+
+ // 姝ょ鐞嗗憳娌℃湁绠$悊鏉冮檺
+ if (!$where) {
+ return 'status=0';
+ }
+
+ return '`status` = 0 OR '.implode(' OR ', $where);
+ }
+
+}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Temps/Module/Config/App.php b/dayrui/App/Cms/Temps/Module/Config/App.php
new file mode 100644
index 0000000..3d00117
--- /dev/null
+++ b/dayrui/App/Cms/Temps/Module/Config/App.php
@@ -0,0 +1,10 @@
+ 'module',
+ 'name' => '{name}',
+ 'icon' => '{icon}',
+ 'system' => '1',
+
+];
\ No newline at end of file
diff --git a/dayrui/App/Cms/Temps/Module/Config/Routes.php b/dayrui/App/Cms/Temps/Module/Config/Routes.php
new file mode 100644
index 0000000..ef3217b
--- /dev/null
+++ b/dayrui/App/Cms/Temps/Module/Config/Routes.php
@@ -0,0 +1,4 @@
+_Admin_List();
+ }
+
+ public function all_add() {
+ $this->_Admin_All_Add();
+ }
+
+ public function add() {
+ $this->_Admin_Add();
+ }
+
+ public function edit() {
+ $this->_Admin_Edit();
+ }
+
+ public function url_edit() {
+ $this->_Admin_Url_Edit();
+ }
+
+ public function move_edit() {
+ $this->_Admin_Move_Edit();
+ }
+
+ public function show_edit() {
+ $this->_Admin_Show_Edit();
+ }
+
+ public function displayorder_edit() {
+ $this->_Admin_Order();
+ }
+
+ public function html_edit() {
+ $this->_Admin_Html_Edit();
+ }
+
+ public function del() {
+ $this->_Admin_Del();
+ }
+}
diff --git a/dayrui/App/Cms/Temps/Module/Controllers/Admin/Draft.php b/dayrui/App/Cms/Temps/Module/Controllers/Admin/Draft.php
new file mode 100644
index 0000000..1e095ee
--- /dev/null
+++ b/dayrui/App/Cms/Temps/Module/Controllers/Admin/Draft.php
@@ -0,0 +1,17 @@
+_Admin_Draft_List();
+ }
+
+ public function del() {
+ $this->_Admin_Draft_Del();
+ }
+}
diff --git a/dayrui/App/Cms/Temps/Module/Controllers/Admin/Flag.php b/dayrui/App/Cms/Temps/Module/Controllers/Admin/Flag.php
new file mode 100644
index 0000000..b013175
--- /dev/null
+++ b/dayrui/App/Cms/Temps/Module/Controllers/Admin/Flag.php
@@ -0,0 +1,17 @@
+_Admin_Flag_List();
+ }
+
+ public function edit() {
+ $this->_Admin_Edit();
+ }
+}
diff --git a/dayrui/App/Cms/Temps/Module/Controllers/Admin/Home.php b/dayrui/App/Cms/Temps/Module/Controllers/Admin/Home.php
new file mode 100644
index 0000000..ea88c1b
--- /dev/null
+++ b/dayrui/App/Cms/Temps/Module/Controllers/Admin/Home.php
@@ -0,0 +1,41 @@
+_Admin_List();
+ }
+
+ public function add() {
+ $this->_Admin_Add();
+ }
+
+ public function edit() {
+ $this->_Admin_Edit();
+ }
+
+ public function show_index() {
+ $this->_Admin_Show();
+ }
+
+ public function move_edit() {
+ $this->_Admin_Move();
+ }
+
+ public function tui_edit() {
+ $this->_Admin_Send();
+ }
+
+ public function syncat_edit() {
+ $this->_Admin_Syncat();
+ }
+
+ public function del() {
+ $this->_Admin_Del();
+ }
+}
diff --git a/dayrui/App/Cms/Temps/Module/Controllers/Admin/Html.php b/dayrui/App/Cms/Temps/Module/Controllers/Admin/Html.php
new file mode 100644
index 0000000..ec58288
--- /dev/null
+++ b/dayrui/App/Cms/Temps/Module/Controllers/Admin/Html.php
@@ -0,0 +1,18 @@
+_Admin_Recycle_List();
+ }
+
+ public function del() {
+ $this->_Admin_Recycle_Del();
+ }
+
+ public function show() {
+ $this->_Admin_Recycle_Show();
+ }
+
+ public function recovery_add() {
+ $this->_Admin_Recovery();
+ }
+
+ public function edit() {
+ $this->_Admin_Recycle_Edit();
+ }
+}
diff --git a/dayrui/App/Cms/Temps/Module/Controllers/Admin/Time.php b/dayrui/App/Cms/Temps/Module/Controllers/Admin/Time.php
new file mode 100644
index 0000000..3c270ee
--- /dev/null
+++ b/dayrui/App/Cms/Temps/Module/Controllers/Admin/Time.php
@@ -0,0 +1,25 @@
+_Admin_Time_List();
+ }
+
+ public function add() {
+ $this->_Admin_Time_add();
+ }
+
+ public function edit() {
+ $this->_Admin_Time_Edit();
+ }
+
+ public function del() {
+ $this->_Admin_Time_Del();
+ }
+}
diff --git a/dayrui/App/Cms/Temps/Module/Controllers/Admin/Verify.php b/dayrui/App/Cms/Temps/Module/Controllers/Admin/Verify.php
new file mode 100644
index 0000000..0cb4181
--- /dev/null
+++ b/dayrui/App/Cms/Temps/Module/Controllers/Admin/Verify.php
@@ -0,0 +1,21 @@
+_Admin_Verify_List();
+ }
+
+ public function edit() {
+ $this->_Admin_Verify_Edit();
+ }
+
+ public function del() {
+ $this->_Admin_Verify_Del();
+ }
+}
diff --git a/dayrui/App/Cms/Temps/Module/Controllers/Category.php b/dayrui/App/Cms/Temps/Module/Controllers/Category.php
new file mode 100644
index 0000000..2e55bdf
--- /dev/null
+++ b/dayrui/App/Cms/Temps/Module/Controllers/Category.php
@@ -0,0 +1,21 @@
+_module_init();
+ // 璋冪敤鏍忕洰鏂规硶
+ $this->_Category(
+ (int)\Phpcmf\Service::L('Input')->get('id'),
+ dr_safe_replace(\Phpcmf\Service::L('Input')->get('dir')),
+ max(1, (int)\Phpcmf\Service::L('Input')->get('page'))
+ );
+ }
+
+}
diff --git a/dayrui/App/Cms/Temps/Module/Controllers/Home.php b/dayrui/App/Cms/Temps/Module/Controllers/Home.php
new file mode 100644
index 0000000..483e14b
--- /dev/null
+++ b/dayrui/App/Cms/Temps/Module/Controllers/Home.php
@@ -0,0 +1,14 @@
+_Index();
+ }
+
+}
diff --git a/dayrui/App/Cms/Temps/Module/Controllers/Html.php b/dayrui/App/Cms/Temps/Module/Controllers/Html.php
new file mode 100644
index 0000000..1b62028
--- /dev/null
+++ b/dayrui/App/Cms/Temps/Module/Controllers/Html.php
@@ -0,0 +1,36 @@
+_Member_Draft_List();
+ }
+
+ public function del() {
+ $this->_Member_Draft_Del();
+ }
+}
diff --git a/dayrui/App/Cms/Temps/Module/Controllers/Member/Home.php b/dayrui/App/Cms/Temps/Module/Controllers/Member/Home.php
new file mode 100644
index 0000000..86921fc
--- /dev/null
+++ b/dayrui/App/Cms/Temps/Module/Controllers/Member/Home.php
@@ -0,0 +1,22 @@
+_Member_List();
+ }
+
+ public function add() {
+ $this->_Member_Add();
+ }
+
+ public function edit() {
+ $this->_Member_Edit();
+ }
+
+ public function del() {
+ $this->_Member_Del();
+ }
+}
diff --git a/dayrui/App/Cms/Temps/Module/Controllers/Member/Verify.php b/dayrui/App/Cms/Temps/Module/Controllers/Member/Verify.php
new file mode 100644
index 0000000..2a3cfce
--- /dev/null
+++ b/dayrui/App/Cms/Temps/Module/Controllers/Member/Verify.php
@@ -0,0 +1,18 @@
+_Member_Verify_List();
+ }
+
+ public function edit() {
+ $this->_Member_Verify_Edit();
+ }
+
+ public function del() {
+ $this->_Member_Verify_Del();
+ }
+}
diff --git a/dayrui/App/Cms/Temps/Module/Controllers/Search.php b/dayrui/App/Cms/Temps/Module/Controllers/Search.php
new file mode 100644
index 0000000..ec69929
--- /dev/null
+++ b/dayrui/App/Cms/Temps/Module/Controllers/Search.php
@@ -0,0 +1,17 @@
+_module_init();
+ // 璋冪敤鎼滅储鏂规硶
+ $this->_Search();
+ }
+
+}
diff --git a/dayrui/App/Cms/Temps/Module/Controllers/Show.php b/dayrui/App/Cms/Temps/Module/Controllers/Show.php
new file mode 100644
index 0000000..4768f9f
--- /dev/null
+++ b/dayrui/App/Cms/Temps/Module/Controllers/Show.php
@@ -0,0 +1,58 @@
+_module_init();
+ $this->_Show(
+ (int)\Phpcmf\Service::L('Input')->get('id'),
+ [
+ 'field' => dr_safe_replace(\Phpcmf\Service::L('Input')->get('field')),
+ 'value' => dr_safe_replace(\Phpcmf\Service::L('Input')->get('value')),
+ ],
+ max(1, (int)\Phpcmf\Service::L('Input')->get('page'))
+ );
+ }
+
+ public function time() {
+ $this->_module_init();
+ $this->_MyShow(
+ 'time',
+ (int)\Phpcmf\Service::L('Input')->get('id'),
+ max(1, (int)\Phpcmf\Service::L('Input')->get('page'))
+ );
+ }
+
+ public function recycle() {
+ $this->_module_init();
+ $this->_MyShow(
+ 'recycle',
+ (int)\Phpcmf\Service::L('Input')->get('id'),
+ max(1, (int)\Phpcmf\Service::L('Input')->get('page'))
+ );
+ }
+
+ public function draft() {
+ $this->_module_init();
+ $this->_MyShow(
+ 'draft',
+ (int)\Phpcmf\Service::L('Input')->get('id'),
+ max(1, (int)\Phpcmf\Service::L('Input')->get('page'))
+ );
+ }
+
+ public function verify() {
+ $this->_module_init();
+ $this->_MyShow(
+ 'verify',
+ (int)\Phpcmf\Service::L('Input')->get('id'),
+ max(1, (int)\Phpcmf\Service::L('Input')->get('page'))
+ );
+ }
+
+}
diff --git a/dayrui/App/Cms/Temps/Module_Domain/api.php b/dayrui/App/Cms/Temps/Module_Domain/api.php
new file mode 100644
index 0000000..516dc9e
--- /dev/null
+++ b/dayrui/App/Cms/Temps/Module_Domain/api.php
@@ -0,0 +1,15 @@
+
+ $(function() { //闃叉鍥炶溅鎻愪氦琛ㄥ崟
+ document.onkeydown = function(e){
+ var ev = document.all ? window.event : e;
+ if (ev.keyCode==13) {
+ return false;
+ }
+ }
+ });
+
+
+
+ {dr_form_hidden()}
+ {/if}
+
+
+ {dr_lang('璁块棶')}
+
+
+
+
+
+ {dr_lang('鍙戝竷')}
+
+
+
+
+
+ {dr_lang('淇敼')}
+
+
+
+
+ {dr_lang('鍒犻櫎')}
+
+
+
+
+ {dr_lang('楠岃瘉鐮')}
+
+
+
+
+
+
+
+ {dr_lang('涓嶅鏍')}
+ {loop $verify $v}
+ {dr_lang($v.name)}
+ {/loop}
+
+
+ {if dr_is_app('explog')}
+
+ {/if}
+ {if dr_is_app('scorelog')}
+
+ {/if}
+
+
+
+
+ {loop $diy.category $d}
+
+ {php $dfile=$d.file;}
+ {load "$dfile"}
+
+ {/loop}
+
+ {if $is_ajax_edit}
+
+
+{/if}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/auth_copy_category.html b/dayrui/App/Cms/Views/auth_copy_category.html
new file mode 100644
index 0000000..99f906e
--- /dev/null
+++ b/dayrui/App/Cms/Views/auth_copy_category.html
@@ -0,0 +1,29 @@
+{template "header.html"}
+
+
+ {dr_form_hidden()}
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/auth_copy_group.html b/dayrui/App/Cms/Views/auth_copy_group.html
new file mode 100644
index 0000000..b80f07d
--- /dev/null
+++ b/dayrui/App/Cms/Views/auth_copy_group.html
@@ -0,0 +1,29 @@
+{template "header.html"}
+
+
+ {dr_form_hidden()}
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/auth_index.html b/dayrui/App/Cms/Views/auth_index.html
new file mode 100644
index 0000000..46d7ed1
--- /dev/null
+++ b/dayrui/App/Cms/Views/auth_index.html
@@ -0,0 +1,145 @@
+{template "header.html"}
+
+
+ {dr_form_hidden(['page' => $page])}
+
+
+
+ {dr_lang('鍐呭鏉冮檺')}
+
+
+
+
+
+
+
+
+
+ {dr_lang('鎸夋ā鍧楀垎鍒缃闂笌鎼滅储鏉冮檺锛涙爮鐩彂甯冦佸鏍搞佹姇绋跨瓑璇风偣鍑汇岃缃嶅脊绐楅厤缃傜敤鎴蜂晶鏉冮檺璇峰埌鐢ㄦ埛绯荤粺閰嶇疆銆')}
+
+
+
+
+
+
+
+
+
+
+ {loop $tabs $tid $tab}
+
+ {$tab.html}
+
+ {/loop}
+
+
+
+
+
+
+
+ {dr_lang('淇濆瓨鏉冮檺閰嶇疆')}
+
+
+
+
+
+
+
+{template "footer.html"}
diff --git a/dayrui/App/Cms/Views/auth_setting.html b/dayrui/App/Cms/Views/auth_setting.html
new file mode 100644
index 0000000..e439662
--- /dev/null
+++ b/dayrui/App/Cms/Views/auth_setting.html
@@ -0,0 +1,144 @@
+{template "header.html"}
+
+
+ {dr_form_hidden(['page' => $page])}
+
+
+
+
+ {$page_name} - {dr_lang('鏍忕洰鏉冮檺')}
+
+
+
+
+
+
+ {if $is_share_page}
+ {if $share_categroy}
+
+ {else}
+
{dr_lang('鏆傛棤鍏变韩鏍忕洰')}
+ {/if}
+
+ {else}
+
+
+
+ {loop $diy.module $d}
+
+ {php $dfile=$d.file;}
+ {load "$dfile"}
+
+ {/loop}
+
+ {/if}
+
+
+
+
+
+
+
+ {dr_lang('淇濆瓨鏉冮檺閰嶇疆')}
+
+
+
+
+
+
+{template "footer.html"}
diff --git a/dayrui/App/Cms/Views/auth_share_category.html b/dayrui/App/Cms/Views/auth_share_category.html
new file mode 100644
index 0000000..42cd988
--- /dev/null
+++ b/dayrui/App/Cms/Views/auth_share_category.html
@@ -0,0 +1,103 @@
+{if $is_ajax_edit}
+{template "header.html"}
+
+
+
+ {dr_form_hidden()}
+{/if}
+
+ {dr_lang('璁块棶')}
+
+
+
+
+
+ {dr_lang('鍙戝竷')}
+
+
+
+
+
+ {dr_lang('淇敼')}
+
+
+
+
+ {dr_lang('鍒犻櫎')}
+
+
+
+
+ {dr_lang('楠岃瘉鐮')}
+
+
+
+
+
+
+ {dr_lang('涓嶅鏍')}
+ {loop $verify $v}
+ {dr_lang($v.name)}
+ {/loop}
+
+
+ {if dr_is_app('explog')}
+
+ {/if}
+ {if dr_is_app('scorelog')}
+
+ {/if}
+
+ {if !$is_ajax_edit}
+
+
+ {dr_lang('鎸夋爮鐩')}
+ {dr_lang('鎸夋ā鍧')}
+
+
+ {/if}
+
+
+
+{if $is_ajax_edit}
+
+
+{/if}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/field.html b/dayrui/App/Cms/Views/field.html
new file mode 100644
index 0000000..9da63c9
--- /dev/null
+++ b/dayrui/App/Cms/Views/field.html
@@ -0,0 +1,81 @@
+{template "header.html"}
+
+
+
+
+ {dr_form_hidden()}
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/help_index.html b/dayrui/App/Cms/Views/help_index.html
new file mode 100644
index 0000000..7e9637a
--- /dev/null
+++ b/dayrui/App/Cms/Views/help_index.html
@@ -0,0 +1,367 @@
+{template "header.html"}
+
+
+
+
+
+
+
+
+ {if $page==0}
+
+
CMS寤虹珯绯荤粺鎻掍欢锛圡odule锛夋彁渚涖绔欑偣 鈫 妯″潡 鈫 鏍忕洰 鈫 鍐呭 銆嶅洓灞傛灦鏋勶紝鏄繀鐫跨敓鎬佷腑鐨 L1 鏍稿績鎻掍欢锛屾敮鎾戜紒涓氬畼缃戙佹柊闂婚棬鎴枫佷骇鍝佸睍绀虹瓑甯歌寤虹珯鍦烘櫙銆
+
+
+
1. 绔欑偣
+
+
澶氱珯鐐圭幆澧冧笅锛屾瘡涓珯鐐规嫢鏈夌嫭绔嬬殑閰嶇疆銆佹ā鏉夸笌鍐呭鏁版嵁銆傚崟绔欑偣浣跨敤鏃讹紝榛樿鎿嶄綔褰撳墠绔欑偣鍗冲彲銆
+
鍏稿瀷閰嶇疆锛氱珯鐐瑰悕绉般丩ogo銆佹ā鏉块鏍笺佹椂鍖恒佸叧绔欐彁绀猴紱鎵嬫満绔嫭绔嬪煙鍚/妯℃澘锛涚珯鐐圭骇鍩熷悕缁戝畾銆
+
+
+
+
+
2. 妯″潡
+
+
妯″潡浠h〃涓绉鍐呭绫诲瀷 锛屽鏂伴椈锛坣ews锛夈佷骇鍝侊紙product锛夈佹渚嬶紙case锛夈傚畨瑁呭寘鑷甫绀轰緥 News 妯″潡锛屼篃鍙氳繃銆屽垱寤烘ā鍧椼嶄竴閿敓鎴愭柊绫诲瀷銆
+
+ 鍏变韩妯″潡 锛氬涓唴瀹圭被鍨嬪叡鐢ㄤ竴濂楁爮鐩爲锛岄傚悎甯歌寤虹珯锛圢ews 鍗充负姝ゆā寮忥級銆
+ 鐙珛妯″潡 锛氭ā鍧楄嚜甯︽爮鐩紝浜掍笉骞叉壈锛岄傚悎澶у瀷鎴栧鏉傜珯鐐广
+
+
+
+
+
+
3. 鏍忕洰
+
+
銆屽叡浜爮鐩嶆槸鍏ㄧ珯缁熶竴鐨勬爮鐩爲锛岀粦瀹氭ā鍧楀悗褰㈡垚鍓嶅彴瀵艰埅涓庡垪琛ㄥ叆鍙c傛爮鐩被鍨嬪寘鎷細
+
+ 鍒楄〃鏍忕洰 锛氬睍绀烘煇妯″潡涓嬬殑鍐呭鍒楄〃
+ 鍗曢〉鏍忕洰 锛氬睍绀哄浐瀹氬崟椤靛唴瀹癸紙鍏充簬鎴戜滑绛夛級
+ 澶栭摼鏍忕洰 锛氳烦杞埌澶栭儴 URL
+
+
+
+
+
+
4. 鍐呭
+
+
鍏蜂綋鏂囩珷銆佷骇鍝併佹渚嬬瓑鏁版嵁锛屽彂甯冨湪瀵瑰簲妯″潡鐨勬爮鐩笅銆傛敮鎸佽崏绋裤佸洖鏀剁珯銆佸鏍搞佹帹鑽愪綅銆佸悓姝ュ鏍忕洰绛夎繍钀ヨ兘鍔涖
+
+
+
+
+
5. 鐢熸佽仈鍔
+
+
寤虹珯绯荤粺鏄繀鐫跨敓鎬佺殑 L1 鏍稿績锛屽鏁颁笟鍔℃彃浠跺洿缁曘屾ā鍧楀唴瀹广嶅睍寮锛屽彲鎸夐渶缁勫悎瀹夎锛
+
+
鐢ㄦ埛涓庢潈闄
+
+ 鐢ㄦ埛绯荤粺锛圡ember锛 锛氫細鍛樻敞鍐岀櫥褰曘佺敤鎴风粍銆佹姇绋裤佹爮鐩潈闄愩佸唴瀹瑰鏍搞佺敤鎴蜂腑蹇
+ 閫氱煡锛圢otice锛 锛氬鏍哥粨鏋溿佺郴缁熸秷鎭佷細鍛樼珯鍐呴氱煡
+ 绉垎/缁忛獙锛圫corelog / Explog锛 锛氭姇绋裤佽瘎璁虹瓑琛屼负濂栧姳锛屼笌鐢ㄦ埛缁勫崌绾ц仈鍔
+ 绗笁鏂圭櫥褰曪紙Ucsso 绛夛級 锛氬井淇/QQ 绛 OAuth 鐧诲綍锛屽叧鑱斾細鍛樿处鍙
+
+
+
鍐呭浜掑姩
+
+ 璇勮锛圕omment锛 锛氬唴瀹硅鎯呴〉璇勮銆佸鏍搞佸洖澶
+ 琛ㄥ崟锛團orm / Mform锛 锛氱嫭绔嬭〃鍗曟垨妯″潡绾ц〃鍗曪紝鏀堕泦鐣欒█銆佹姤鍚嶃侀绾︾瓑
+ TAG 鏍囩 锛氬唴瀹规墦鏍囩銆佹爣绛捐仛鍚堥〉銆佺浉鍏虫帹鑽
+ 鎶曠エ锛圴ote锛 锛氳皟鏌ラ棶鍗枫佹姇绁ㄦ椿鍔ㄦ寕鎺ュ唴瀹规垨鐙珛鍙戝竷
+ 闂瓟 / 璁哄潧锛圵enda / Bbs / Ask锛 锛氫互妯″潡鎴栨爮鐩壙杞界ぞ鍖轰簰鍔ㄥ唴瀹
+
+
+
闈欐佸寲涓 SEO
+
+ 闈欐佺敓鎴愶紙Chtml锛 锛氭爮鐩〉銆佸唴瀹归〉銆佹ā鍧楅椤垫壒閲忛潤鎬佸寲锛涙敮鎸佸垎绂婚儴缃查潤鎬佺洰褰
+ 澶氳瑷锛圖uoyuyan / Website锛 锛氬璇绔欑偣銆佸唴瀹圭炕璇戙佺嫭绔 SEO
+ 鍒嗙珯锛團enzhan锛 锛氬煄甯傜珯/鍖哄煙绔欙紝鐙珛鍩熷悕涓庢爮鐩唴瀹
+
+
+
鐢靛晢涓庝粯璐
+
+ 鏀粯锛圥ay锛 锛氬井淇/鏀粯瀹濈瓑鏀舵锛岄厤鍚堜細鍛樺厖鍊笺佽鍗
+ 鍟嗗煄锛圫tore锛 锛氬晢鍝佹ā鍧椼佽喘鐗╄溅銆佽鍗曘佸敭鍚
+ 涓嬭浇锛圔ook / Xiazaisf锛 锛氫粯璐逛笅杞姐侀檮浠堕攢鍞侀槄璇绘潈闄
+ 铏氭嫙甯 / 鍗″瘑 锛氱Н鍒嗗厬鎹€佸崱瀵嗗彂鏀剧瓑铏氭嫙鍟嗗搧鍦烘櫙
+
+
+
杩愯惀涓庡睍绀
+
+ 骞垮憡锛圓dcontent锛 锛氬够鐏佹í骞呯瓑骞垮憡浣嶏紝鎸傛帴妯℃澘灞曠ず
+ 涓撻锛圫pecial锛 锛氳仛鍚堝绡囧唴瀹瑰仛涓撻椤点佹椿鍔ㄩ〉
+ 纰庣墖锛圔lock锛 锛氬彲澶嶇敤鍐呭鍧楋紝妯℃澘涓伒娲昏皟鐢
+ 褰掓。锛圓rchive锛 锛氬巻鍙插唴瀹瑰綊妗f绱
+
+
+
澶氱涓庢墿灞
+
+ 灏忕▼搴忥紙Xcx锛 锛氬井淇″皬绋嬪簭瀵规帴妯″潡鍐呭涓庝細鍛
+ 澶氱浜掕仈锛圕lient锛 锛歅C/鎵嬫満/APP 绛夊缁堢缁熶竴鍐呭
+ API锛圚ttpapi锛 锛氬澶栨彁渚涘唴瀹广佹爮鐩暟鎹帴鍙
+ 瀛楁鏍囩锛圡bdy锛 锛氭ā鏉挎爣绛惧彲瑙嗗寲鐢熸垚锛岄厤鍚堝墠鍙板紑鍙
+ AI 鍔╂墜锛圓i_helper 绛夛級 锛欰I 鍒涗綔銆佸彂甯冨埌鎸囧畾妯″潡鏍忕洰
+
+
+
浠ヤ笂鎻掍欢鍧囧彲鍦ㄣ屽簲鐢ㄦ彃浠 鈫 搴旂敤甯傚満銆嶆悳绱㈠畨瑁咃紱鍏蜂綋鑳藉姏浠ュ悇鎻掍欢鏂囨。涓哄噯銆
+
+
+
+ {/if}
+
+ {if $page==1}
+
+
绠$悊鍛樿礋璐e缓绔欎笌鍐呭杩愯惀锛涜瀹㈡祻瑙堢珯鐐癸紱浼氬憳锛堥渶鐢ㄦ埛绯荤粺锛夊湪鏈夋潈闄愭椂鍙姇绋裤備互涓嬫寜瑙掕壊璇存槑鍏稿瀷璺緞銆
+
+
+ 绗竴姝ワ細绔欑偣鍩虹閰嶇疆
+
+ 鍦 缃戠珯璁剧疆 瀹屾垚绔欑偣鍙傛暟锛
+ 鍦 缃戠珯淇℃伅 缁存姢骞荤伅銆佸弸閾剧瓑锛
+ 鎸夐渶閰嶇疆 鎵嬫満璁剧疆 銆
+ 鍩熷悕缁戝畾 銆
+ 鍥剧墖璁剧疆 銆
+
+
+
+ 绗簩姝ワ細鎼缓鍐呭缁撴瀯
+
+ 鍦 鍒涘缓妯″潡 涓柊寤哄唴瀹圭被鍨嬶紙鎴栦娇鐢ㄨ嚜甯 News 妯″潡锛夛紱
+ 鍦 妯″潡绠$悊 涓皟鏁村鏍搞佸垪琛ㄥ瓧娈点佹帓搴忚鍒欑瓑锛
+ 鍦 鍏变韩鏍忕洰 涓缓绔嬫爮鐩爲骞剁粦瀹氭ā鍧楋紝褰㈡垚鍓嶅彴鑿滃崟涓庡垪琛ㄣ
+
+
+
+ 绗笁姝ワ細SEO 涓 URL
+
+ 鍦 SEO 璁剧疆涓厤缃
+ 绔欑偣 SEO 銆
+ 妯″潡 SEO 銆
+ 鏍忕洰 SEO 锛
+ 鍦 URL 瑙勫垯 涓
+ 浼潤鎬佽В鏋 涓缃摼鎺ユ牸寮忥紝骞堕儴缃插埌 Web 鏈嶅姟鍣ㄣ
+
+
+
+ 绗洓姝ワ細鍙戝竷涓庡鏍稿唴瀹
+
+ 鍦 鍐呭绠$悊 涓寜鏍忕洰鍙戝竷銆佺紪杈戙佹帓搴忓唴瀹癸紱
+ 浣跨敤鑽夌ǹ绠/鍥炴敹绔欑鐞嗘湭瀹屾垚鎴栬鍒犳暟鎹紱
+ 鍦ㄥ唴瀹瑰鏍镐腑澶勭悊浼氬憳鎴栫紪杈戞彁浜ょ殑寰呭绋匡紱
+ 鍙夐厤缃 妯″潡鎼滅储 銆
+
+
+
+ 绗簲姝ワ細妯℃澘涓庡墠鍙
+
+ 鍦ㄦā鏉跨洰褰曚腑璋冩暣 index銆乴ist銆乻how銆乻earch 绛夐〉闈紱
+ 閫氳繃妯℃澘鏍囩璋冪敤鏍忕洰涓庡唴瀹规暟鎹紱
+ 寮鍚ā鍧楅椤甸潤鎬佹垨瀹夎闈欐佹彃浠跺仛鍏ㄧ珯闈欐佸寲銆
+
+
+
+ 璁垮锛氭祻瑙堜笌鎼滅储
+ 璁块棶缃戠珯棣栭〉涓庡悇鏍忕洰鍒楄〃锛涚偣鍑昏繘鍏ュ唴瀹硅鎯咃紱浣跨敤鎼滅储鍔熻兘鏌ユ壘鏂囩珷锛堝彈鍚庡彴鎼滅储閰嶇疆鎺у埗锛夈
+
+
+ 浼氬憳锛氭姇绋夸笌绠$悊锛堝彲閫夛級
+ 鐧诲綍鐢ㄦ埛涓績锛岃繘鍏ュ凡鎺堟潈妯″潡锛涢夋嫨鏈夋潈闄愭爮鐩~鍐欏唴瀹瑰苟鎻愪氦鎴栧瓨鑽夌ǹ锛涚瓑寰呯鐞嗗憳瀹℃牳閫氳繃鍚庡墠鍙板睍绀恒
+
+
+
+ {dr_lang('绠瑕佹祦绋')}锛
+ {dr_lang('绔欑偣閰嶇疆 鈫 鍒涘缓妯″潡涓庢爮鐩 鈫 SEO/URL 鈫 鍙戝唴瀹逛笌瀹℃牳 鈫 妯℃澘涓婄嚎')}
+
+
+ {/if}
+
+ {if $page==2}
+
+
浠ヤ笅瀵圭収鍚庡彴銆岃缃嶄笌銆屽唴瀹广嶈彍鍗曪紝渚夸簬蹇熸壘鍒板搴斿姛鑳藉叆鍙c
+
+
{dr_lang('璁剧疆')}
+
+
+
+ {dr_lang('鑿滃崟')}
+ {dr_lang('鍔熻兘')}
+ {dr_lang('鍏ュ彛')}
+
+
+
+
+ {dr_lang('缃戠珯璁剧疆')}
+ {dr_lang('绔欑偣鍚嶇О銆丩ogo銆佹ā鏉裤佹椂鍖恒佸叧绔欑瓑鍩虹鍙傛暟')}
+ {dr_lang('杩涘叆')}
+
+
+ {dr_lang('鎵嬫満璁剧疆')}
+ {dr_lang('鎵嬫満绔嫭绔嬪煙鍚嶄笌妯℃澘閰嶇疆')}
+ {dr_lang('杩涘叆')}
+
+
+ {dr_lang('鍩熷悕缁戝畾')}
+ {dr_lang('绔欑偣绾с佹爮鐩骇鍩熷悕缁戝畾')}
+ {dr_lang('杩涘叆')}
+
+
+ {dr_lang('鍒涘缓妯″潡')}
+ {dr_lang('鏂板缓鍐呭绫诲瀷锛堟柊闂汇佷骇鍝佺瓑锛')}
+ {dr_lang('杩涘叆')}
+
+
+ {dr_lang('妯″潡绠$悊')}
+ {dr_lang('妯″潡瀹夎/鍗歌浇銆佸鏍搞佸垪琛ㄥ瓧娈点佹帹鑽愪綅绛')}
+ {dr_lang('杩涘叆')}
+
+
+ {dr_lang('妯″潡鎼滅储')}
+ {dr_lang('鎼滅储瀛楁銆佹帓搴忋佹椂闂磋寖鍥寸瓑瑙勫垯')}
+ {dr_lang('杩涘叆')}
+
+
+ {dr_lang('绔欑偣 SEO')}
+ {dr_lang('鍏ㄧ珯 title/keywords/description 妯℃澘')}
+ {dr_lang('杩涘叆')}
+
+
+ {dr_lang('妯″潡 SEO')}
+ {dr_lang('鍚勬ā鍧楅椤点佸垪琛ㄣ佽鎯 SEO 妯℃澘')}
+ {dr_lang('杩涘叆')}
+
+
+ {dr_lang('鏍忕洰 SEO')}
+ {dr_lang('鍚勬爮鐩殑 SEO 妯℃澘')}
+ {dr_lang('杩涘叆')}
+
+
+ {dr_lang('URL 瑙勫垯')}
+ {dr_lang('鍐呭椤点佸垪琛ㄩ〉閾炬帴鏍煎紡')}
+ {dr_lang('杩涘叆')}
+
+
+ {dr_lang('浼潤鎬佽В鏋')}
+ {dr_lang('鐢熸垚 Nginx/Apache 浼潤鎬佽鍒')}
+ {dr_lang('杩涘叆')}
+
+
+
+
+
{dr_lang('鍐呭')}
+
+
+
+ {dr_lang('鑿滃崟')}
+ {dr_lang('鍔熻兘')}
+ {dr_lang('鍏ュ彛')}
+
+
+
+
+ {dr_lang('鍐呭绠$悊')}
+ {dr_lang('鎸夋ā鍧/鏍忕洰娴忚銆佸彂甯冦佺紪杈戙佹帓搴忓唴瀹')}
+ {dr_lang('杩涘叆')}
+
+
+ {dr_lang('缃戠珯淇℃伅')}
+ {dr_lang('骞荤伅鐗囥佸弸鎯呴摼鎺ョ瓑绔欑偣鑷畾涔夊弬鏁')}
+ {dr_lang('杩涘叆')}
+
+
+ {dr_lang('鍏变韩鏍忕洰')}
+ {dr_lang('鏍忕洰鏍戠鐞嗐佺粦瀹氭ā鍧椼佹爮鐩瓧娈典笌鏉冮檺')}
+ {dr_lang('杩涘叆')}
+
+
+
+
+ {/if}
+
+ {if $page==3}
+
+
棣栨瀹夎寤虹珯绯荤粺鍚庯紝鎸変互涓嬫竻鍗曢愰」瀹屾垚锛屽嵆鍙揩閫熶笂绾夸竴涓彲璁块棶鐨勫唴瀹圭珯鐐广
+
+
+
{dr_lang('瀹夎涓庡垵濮嬪寲')}
+
+
+ 纭銆屽缓绔欑郴缁熴嶆彃浠跺凡瀹夎锛屽苟鍦 妯″潡绠$悊 涓杞藉叡浜ā鍧楀埌褰撳墠绔欑偣
+ 纭绀轰緥 News 妯″潡宸插畨瑁咃紙鎴栬嚜琛 鍒涘缓妯″潡 锛
+ 淇敼妯″潡銆佹爮鐩垨 URL 瑙勫垯鍚庯紝鎵ц绯荤粺缂撳瓨鏇存柊
+
+
+
+
+
+
{dr_lang('寤虹珯浜旀璧')}
+
+
+ 缃戠珯璁剧疆 锛氬~鍐欑珯鐐瑰悕绉帮紝閫夋嫨妯℃澘鐩綍锛{SITE_TEMPLATE} 锛変笌涓婚椋庢牸锛{SITE_THEME} 锛
+ 鍏变韩鏍忕洰 锛氬缓绔嬫爮鐩爲锛屽皢鍒楄〃鏍忕洰缁戝畾鍒 news 绛夋ā鍧
+ 鍐呭绠$悊 锛氬湪瀵瑰簲鏍忕洰涓嬪彂甯冩祴璇曟枃绔
+ URL 瑙勫垯 + 浼潤鎬佽В鏋 锛氶厤缃苟閮ㄧ讲鏈嶅姟鍣ㄨ鍒
+ 璁块棶鍓嶅彴棣栭〉涓庢爮鐩垪琛紝纭鍐呭姝e父灞曠ず
+
+
+
+
+
+
{dr_lang('甯歌闂')}
+
+
+ {dr_lang('鍓嶅彴 404 鎴栨ā鍧椾笉瀛樺湪')} 锛氭鏌ユā鍧楁槸鍚﹀凡瀹夎鍒板綋鍓嶇珯鐐癸紝骞舵洿鏂扮郴缁熺紦瀛
+ {dr_lang('鏍忕洰鏃犳硶浣跨敤')} 锛氱‘璁ゅ叡浜ā鍧楋紙Module锛夊凡瑁呰浇锛涘绔欑偣鏃舵敞鎰忓湪瀵瑰簲绔欑偣鎿嶄綔
+ {dr_lang('浼潤鎬佷笉鐢熸晥')} 锛氬悗鍙拌鍒欓厤缃悗锛岃繕闇鍦 Nginx/Apache 涓啓鍏ュ搴 rewrite 瑙勫垯
+ {dr_lang('淇敼妯℃澘鏃犲彉鍖')} 锛歿dr_lang('纭妯℃澘鐩綍锛圫ITE_TEMPLATE锛変笌涓婚椋庢牸锛圫ITE_THEME锛夋纭紱娓呴櫎娴忚鍣ㄧ紦瀛橈紱鑻ュ紑鍚潤鎬佸寲闇閲嶆柊鐢熸垚')}
+
+
+
+
+ {/if}
+
+
+
+
+
+{template "footer.html"}
diff --git a/dayrui/App/Cms/Views/help_seo.html b/dayrui/App/Cms/Views/help_seo.html
new file mode 100644
index 0000000..e1ec17b
--- /dev/null
+++ b/dayrui/App/Cms/Views/help_seo.html
@@ -0,0 +1,212 @@
+{template "header.html"}
+
+
+
+
+
+
+
+
+ {if $page==0}
+
+
{dr_lang('SEO 鎸夈岀珯鐐 鈫 妯″潡 鈫 鏍忕洰銆嶅垎灞傞厤缃紝涓嬪眰鍙鐩栦笂灞傝鍒欙紱鍐呭椤佃繕鍙娇鐢ㄦ枃绔犺嚜韬殑 title/keywords/description 瀛楁銆')}
+
+
+
+ {dr_lang('灞傜骇')} {dr_lang('閰嶇疆鑼冨洿')} {dr_lang('鍚庡彴鍏ュ彛')}
+
+
+
+ {dr_lang('绔欑偣 SEO')}
+ {dr_lang('鍏ㄧ珯棣栭〉 title/keywords/description锛汼EO 杩炴帴绗︼紱鍏ㄧ珯 URL 瑙勫垯锛涚綉绔欓椤甸潤鎬')}
+ {dr_lang('绔欑偣SEO')}
+
+
+ {dr_lang('妯″潡 SEO')}
+ {dr_lang('妯″潡棣栭〉銆佹爮鐩垪琛ㄣ佸唴瀹硅鎯呫佹悳绱㈤〉鐨 SEO 妯℃澘锛涙ā鍧 URL 瑙勫垯锛堢嫭绔嬫ā鍧楋級')}
+ {dr_lang('妯″潡SEO')}
+
+
+ {dr_lang('鏍忕洰 SEO')}
+ {dr_lang('涓哄崟涓爮鐩崟鐙缃垪琛ㄩ〉/鍐呭椤 SEO锛堟ā鍧 SEO 涓紑鍚屽垎鍒缃嶅悗鐢熸晥锛')}
+ {dr_lang('鏍忕洰SEO')}
+
+
+ {dr_lang('鍐呭 SEO')}
+ {dr_lang('鍙戝竷鍐呭鏃跺~鍐欐爣棰樸佸叧閿瘝銆佹弿杩帮紱浼樺厛浜庢ā鍧楁ā鏉夸腑鐨勯氶厤绗')}
+ {dr_lang('鍐呭绠$悊')}
+
+
+
+
+
+
{dr_lang('SEO 杩炴帴绗')}
+
+
{dr_lang('鍦')} {dr_lang('绔欑偣SEO')} {dr_lang('涓缃')} SITE_SEOJOIN 锛坽dr_lang('榛樿')} _ 锛夛紝{dr_lang('鐢ㄤ簬鎷兼帴鏍囬涓殑澶氫釜閮ㄥ垎銆')}
+
{dr_lang('妯℃澘涓殑')} {code}{join}{/code} {dr_lang('浼氳鏇挎崲涓鸿杩炴帴绗︼紝渚嬪锛')} {code}鏂囩珷鏍囬{join}鏍忕洰鍚嶇О{join}缃戠珯鍚嶇О{/code}
+
+
+
+
+
{dr_lang('鍓嶅彴杈撳嚭')}
+
+
{dr_lang('绯荤粺璁$畻鍚庣殑 SEO 浼氳祴鍊肩粰妯℃澘鍙橀噺锛')}
+
+ {code}{$meta_title}{/code} 鈥 {dr_lang('椤甸潰 title')}
+ {code}{$meta_keywords}{/code} 鈥 {dr_lang('keywords')}
+ {code}{$meta_description}{/code} 鈥 {dr_lang('description')}
+
+
{dr_lang('涓鑸湪')} {code}header.html{/code} {dr_lang('鐨 head 鍖哄煙杈撳嚭銆')}
+
+
+
+ {/if}
+
+ {if $page==1}
+
+
{dr_lang('SEO 妯℃澘涓娇鐢ㄨ姳鎷彿閫氶厤绗︼紝淇濆瓨鍚庣郴缁熻嚜鍔ㄦ浛鎹负瀹為檯鍊笺傚垎椤甸〉鐮佺敤')} {code}[绗{page}椤{join}]{/code} {dr_lang('鏍煎紡锛堟柟鎷彿琛ㄧず浠呭垎椤垫椂鏄剧ず锛夈')}
+
+
+
{dr_lang('閫氱敤閫氶厤绗')}
+
+
+
+ {dr_lang('閫氶厤绗')} {dr_lang('璇存槑')}
+
+
+ {code}{SITE_NAME}{/code} {dr_lang('缃戠珯鍚嶇О')}
+ {code}{join}{/code} {dr_lang('SEO 杩炴帴绗︼紙绔欑偣 SEO 涓缃級')}
+ {code}{page}{/code} {dr_lang('鍒嗛〉椤电爜')}
+ {code}{modname}{/code} {dr_lang('妯″潡鍚嶇О')}
+ {code}{name}{/code} / {code}{catname}{/code} {dr_lang('鏍忕洰鍚嶇О')}
+ {code}{catpname}{/code} {dr_lang('鏍忕洰灞傜骇璺緞鍚嶇О锛堝惈涓婄骇锛')}
+ {code}{title}{/code} {dr_lang('鍐呭鏍囬')}
+ {code}{keyword}{/code} {dr_lang('鎼滅储鍏抽敭璇')}
+ {code}{param}{/code} {dr_lang('鎼滅储闄勫姞鍙傛暟')}
+
+
+
+
+
+
+
{dr_lang('甯哥敤妯℃澘绀轰緥')}
+
+
{dr_lang('鍐呭椤垫爣棰橈紙榛樿锛')}
+
{code}[绗瑊page}椤祘join}]{title}{join}{catpname}{join}{SITE_NAME}{/code}
+
{dr_lang('鏍忕洰鍒楄〃椤垫爣棰橈紙榛樿锛')}
+
{code}[绗瑊page}椤祘join}]{catpname}{join}{SITE_NAME}{/code}
+
{dr_lang('鎼滅储椤垫爣棰橈紙榛樿锛')}
+
{code}[绗瑊page}椤祘join}][{keyword}{join}][{param}{join}]{SITE_NAME}{/code}
+
{dr_lang('妯″潡 SEO 閰嶇疆椤典腑鐐瑰嚮銆屽彲鐢ㄩ氶厤绗︽爣绛俱嶆寜閽紝鍙煡鐪嬪綋鍓嶉〉闈㈡敮鎸佺殑鍏ㄩ儴閫氶厤绗︺')}
+
+
+
+
+
{dr_lang('鍐呭鑷畾涔夊瓧娈')}
+
+
{dr_lang('妯″潡鍐呭瀛楁銆佹爮鐩瓧娈典篃鍙弬涓 SEO 閫氶厤绗︽浛鎹紙鍦ㄦā鍧 SEO 鐨勯氶厤绗﹀垪琛ㄤ腑鏌ョ湅锛夈傝嚜瀹氫箟瀛楁闇鍦ㄥ瓧娈电鐞嗕腑鍕鹃夊弬涓 SEO銆')}
+
+
+
+ {/if}
+
+ {if $page==2}
+
+
{dr_lang('寤鸿鎸変互涓嬮『搴忛厤缃 SEO锛屼慨鏀瑰悗鎵ц绯荤粺缂撳瓨鏇存柊锛屽苟璁块棶鍓嶅彴楠岃瘉椤甸潰 source 涓殑 title/meta 鏍囩銆')}
+
+
+
+ {dr_lang('绗竴姝ワ細绔欑偣 SEO')}
+
+ 杩涘叆 {dr_lang('绔欑偣SEO')} 锛
+ 濉啓棣栭〉 title/keywords/description锛岃缃 SEO 杩炴帴绗︼紱
+ 濡傞渶鍏ㄧ珯缁熶竴 URL 鏍煎紡锛岄夋嫨鍏ㄥ眬 URL 瑙勫垯銆
+
+
+
+ {dr_lang('绗簩姝ワ細妯″潡 SEO')}
+
+ 杩涘叆 {dr_lang('妯″潡SEO')} 锛
+ 鎸夋ā鍧 Tab 鍒嗗埆璁剧疆棣栭〉銆佹爮鐩垪琛ㄣ佸唴瀹硅鎯呫佹悳绱㈤〉鐨 SEO 妯℃澘锛
+ 鐙珛妯″潡鍙湪姝ょ粦瀹氭ā鍧 URL 瑙勫垯銆
+
+
+
+ {dr_lang('绗笁姝ワ細鏍忕洰 SEO锛堝彲閫夛級')}
+
+ 鑻ユ煇鏍忕洰闇鐙珛 SEO锛屽湪妯″潡 SEO 涓皢銆屾寜鏍忕洰璁剧疆 SEO銆嶆敼涓恒屽垎鍒缃嶏紝
+ 鍐嶅埌 {dr_lang('鏍忕洰SEO')} 閫愭爮閰嶇疆銆
+
+
+
+ {dr_lang('绗洓姝ワ細鍐呭 SEO')}
+
+ 鍙戝竷/缂栬緫鍐呭鏃跺~鍐 SEO 鏍囬銆佸叧閿瘝銆佹弿杩帮紱
+ 鐣欑┖鍒欎娇鐢ㄦā鍧 SEO 妯℃澘閫氶厤绗﹁嚜鍔ㄧ敓鎴愩
+
+
+
+ {dr_lang('绗簲姝ワ細鏇存柊涓庨獙璇')}
+
+ 淇敼 SEO 瑙勫垯鎴 URL 瑙勫垯鍚庯紝鐐瑰嚮鍚 SEO 椤甸《閮ㄧ殑銆岃缃叏绔橲EO瑙勫垯銆嶆垨鎵ц绯荤粺缂撳瓨鏇存柊锛
+ 璁块棶棣栭〉銆佸垪琛ㄣ佽鎯呫佹悳绱㈤〉锛屾煡鐪嬫祻瑙堝櫒鏍囬涓 meta 鏄惁绗﹀悎棰勬湡銆
+
+
+
+
+
+
{dr_lang('甯歌闂')}
+
+
+ {dr_lang('淇敼鍚庡墠鍙版棤鍙樺寲')} 锛歿dr_lang('鏇存柊绯荤粺缂撳瓨锛涙竻闄ゆ祻瑙堝櫒缂撳瓨锛涜嫢寮鍚潤鎬佸寲闇閲嶆柊鐢熸垚')}
+ {dr_lang('鍒嗛〉鏍囬鏃犻〉鐮')} 锛歿dr_lang('纭妯℃澘鍚')} {code}[绗{page}椤{join}]{/code} {dr_lang('涓斿綋鍓嶄负绗 2 椤靛強浠ヤ笂')}
+ {dr_lang('鏍忕洰 SEO 涓嶇敓鏁')} 锛歿dr_lang('妫鏌ユā鍧 SEO 鏄惁宸插紑鍚屽垎鍒缃嶏紱鍏变韩妯″潡闇鍦ㄦ爮鐩 SEO 椤垫搷浣')}
+
+
+
+
+
+
+ {/if}
+
+
+
+
+
+{template "footer.html"}
diff --git a/dayrui/App/Cms/Views/help_template.html b/dayrui/App/Cms/Views/help_template.html
new file mode 100644
index 0000000..2a3339a
--- /dev/null
+++ b/dayrui/App/Cms/Views/help_template.html
@@ -0,0 +1,374 @@
+{template "header.html"}
+
+
+
+
+
+
+
+
+ {if $page==0}
+
+
+ 鍓嶅彴妯℃澘瀛樻斁鍦 {TPLPATH}pc/{SITE_TEMPLATE}/home/ 锛
+ 闈欐佽祫婧愬湪 static/{SITE_THEME}/ 锛坽dr_lang('妯℃澘涓氳繃')} {code}{HOME_THEME_PATH}{/code} {dr_lang('寮曠敤')}锛夈
+ 褰撳墠绔欑偣妯℃澘鐩綍涓 {SITE_TEMPLATE} 锛屼富棰橀鏍间负 {SITE_THEME} 锛屽彲鍦 缃戠珯璁剧疆 涓慨鏀广
+
+
+
template/
+鈹溾攢鈹 pc/
+鈹 鈹斺攢鈹 {SITE_TEMPLATE}/ # 褰撳墠 PC 妯℃澘鐩綍
+鈹 鈹斺攢鈹 home/
+鈹 鈹溾攢鈹 index.html # 缃戠珯棣栭〉
+鈹 鈹溾攢鈹 list.html # 鏍忕洰鍒楄〃椤
+鈹 鈹溾攢鈹 show.html # 鍐呭璇︽儏椤
+鈹 鈹溾攢鈹 category.html # 鏍忕洰灏侀潰椤
+鈹 鈹溾攢鈹 page.html # 鍗曢〉鏍忕洰
+鈹 鈹溾攢鈹 search.html # 妯″潡鎼滅储椤
+鈹 鈹溾攢鈹 header.html # 鍏叡椤靛ご
+鈹 鈹溾攢鈹 footer.html # 鍏叡椤佃剼
+鈹 鈹溾攢鈹 404.html # 404 椤甸潰
+鈹 鈹斺攢鈹 msg.html # 鎻愮ず淇℃伅椤
+鈹斺攢鈹 mobile/
+ 鈹斺攢鈹 {SITE_TEMPLATE}/home/ # 鎵嬫満绔紝鏂囦欢缁撴瀯涓 PC 鐩稿悓
+
+static/{SITE_THEME}/ # 涓婚椋庢牸闈欐佽祫婧愶紙CSS/JS/鍥剧墖锛
+鈹溾攢鈹 pc/css/
+鈹溾攢鈹 pc/plugins/
+鈹斺攢鈹 swiper/
+
+
+
{dr_lang('妯℃澘鏂囦欢璇存槑')}
+
+
+
+ {dr_lang('鏂囦欢')} {dr_lang('瑙﹀彂鍦烘櫙')} {dr_lang('璇存槑')}
+
+
+ index.html {dr_lang('缃戠珯棣栭〉')} {dr_lang('鍏ㄧ珯棣栭〉锛屽彲璋冪敤鍚勬ā鍧楁暟鎹潡')}
+ list.html {dr_lang('鍒楄〃鏍忕洰')} {dr_lang('鏍忕洰鍐呭鍒嗛〉鍒楄〃锛岃緭鍑')} {code}{$pages}{/code} {dr_lang('鍒嗛〉')}
+ show.html {dr_lang('鍐呭璇︽儏')} {dr_lang('鏍囬銆佹鏂囥佷笂涓嬬瘒銆佸叧鑱斿唴瀹圭瓑')}
+ category.html {dr_lang('灏侀潰鏍忕洰')} {dr_lang('灞曠ず瀛愭爮鐩強姣忎釜瀛愭爮鐩殑閮ㄥ垎鍐呭')}
+ page.html {dr_lang('鍗曢〉鏍忕洰')} {dr_lang('杈撳嚭鏍忕洰鍚嶇О涓庢鏂')} {code}{$content}{/code}
+ search.html {dr_lang('妯″潡鎼滅储')} {dr_lang('鎼滅储琛ㄥ崟涓庣粨鏋滃垪琛')}
+ header.html / footer.html {dr_lang('鍏叡寮曞叆')} {dr_lang('閫氳繃')} {code}{template "header.html"}{/code} {dr_lang('澶嶇敤')}
+
+
+
+
+
+
+
{dr_lang('妯″潡鐙珛妯℃澘锛堝彲閫夛級')}
+
+
鍦 妯″潡绠$悊 涓彲涓哄崟涓ā鍧楃粦瀹氱嫭绔嬮鏍肩洰褰曪紱鏍忕洰缂栬緫椤典篃鍙崟鐙寚瀹 list/show/page 绛夋ā鏉挎枃浠跺悕銆
+
浼樺厛绾э細鍐呭鑷畾涔夋ā鏉 > 鏍忕洰妯℃澘璁剧疆 > 妯″潡椋庢牸 > 绔欑偣榛樿椋庢牸銆
+
+
+
+ {/if}
+
+ {if $page==1}
+
+
杩呯澘妯℃澘璇硶鐢辫姳鎷彿鏍囩涓 PHP 娣峰悎缁勬垚锛屽惊鐜綋鍐呭綋鍓嶈鏁版嵁閫氬父鐢 $t 琛ㄧず銆
+
+
+
{dr_lang('寮曞叆瀛愭ā鏉')}
+
+
{code}{template "header.html"}
+{template "footer.html"}{/code}
+
{dr_lang('寮曞叆鍚岀洰褰曚笅鐨勯〉澶淬侀〉鑴氾紱涔熷彲寮曞叆瀛愯矾寰勬ā鏉匡紝濡')} {code}{template "index_data.html"}{/code}銆
+
+
+
+
+
{dr_lang('SEO 涓庨〉闈㈠彉閲')}
+
+
+
+ {dr_lang('鍙橀噺')} {dr_lang('璇存槑')}
+
+
+ {code}{$meta_title}{/code} {dr_lang('椤甸潰鏍囬')}
+ {code}{$meta_keywords}{/code} {dr_lang('椤甸潰鍏抽敭璇')}
+ {code}{$meta_description}{/code} {dr_lang('椤甸潰鎻忚堪')}
+ {code}{$indexc}{/code} {dr_lang('棣栭〉鏍囪锛堜粎棣栭〉涓 1锛')}
+ {code}{$catid}{/code} {dr_lang('褰撳墠鏍忕洰 ID')}
+ {code}{$cat.name}{/code} / {code}{$cat.url}{/code} {dr_lang('褰撳墠鏍忕洰鍚嶇О涓庨摼鎺')}
+ {code}{$title}{/code} / {code}{$content}{/code} {dr_lang('璇︽儏椤垫爣棰樹笌姝f枃')}
+ {code}{$updatetime}{/code} {dr_lang('鏇存柊鏃堕棿锛堝凡鏍煎紡鍖栵級')}
+ {code}{$pages}{/code} {dr_lang('鍒楄〃鍒嗛〉 HTML')}
+ {code}{MOD_DIR}{/code} {dr_lang('褰撳墠妯″潡鐩綍鍚')}
+ {code}{SITE_LOGO}{/code} {dr_lang('绔欑偣 LOGO 鍦板潃')}
+ {code}{HOME_THEME_PATH}{/code} {dr_lang('褰撳墠椋庢牸闈欐佽祫婧愯矾寰')}
+
+
+
+
+
+
+
{dr_lang('鍒ゆ柇涓庡惊鐜')}
+
+
{code}{if $indexc} class="is-active"{/if}
+
+{if $catid && dr_in_array($catid, $t.catids)} class="is-active"{/if}
+
+{/code}
+
+
+
+
+
{dr_lang('绔欑偣鑷畾涔夊弬鏁')}
+
+
鍦 缃戠珯淇℃伅 涓淮鎶ょ殑瀛楁锛屾ā鏉夸腑璇诲彇锛
+
{code}{php $mysite=dr_site_value('hdtp');}
+{loop $mysite $v}
+{dr_get_file($v[1])}
+{/loop}{/code}
+
瀹夎鏃堕粯璁ゅ寘鍚 hdtp 锛堝够鐏墖锛夈yqlj 锛堝弸鎯呴摼鎺ワ級绛夊瓧娈点
+
+
+
+ {/if}
+
+ {if $page==2}
+
+
{dr_lang('浠ヤ笅涓哄缓绔欑郴缁熸渶甯哥敤鐨勫墠鍙版爣绛撅紱涓嶇啛鎮夎娉曟椂锛屽彲浼樺厛浣跨敤涓嬫柟鏍囩鐢熸垚宸ュ叿锛屽啀绮樿创鍒版ā鏉夸腑璋冭瘯銆傚畬鏁存枃妗h')} {dr_lang('瀹樻柟妯℃澘鎵嬪唽')} 銆
+
+
+
{dr_lang('鏍囩鐢熸垚宸ュ叿锛堟帹鑽愶級')}
+
+
{dr_lang('鍒朵綔妯℃澘鏃朵笉蹇呮墜鍐欏叏閮ㄦ爣绛撅紝浠ヤ笅涓や釜宸ュ叿鍙彲瑙嗗寲鐢熸垚璋冪敤浠g爜锛屽鍒跺埌妯℃澘鍗冲彲浣跨敤銆')}
+
+
+ {dr_lang('宸ュ叿')} {dr_lang('璇存槑')} {dr_lang('鍏ュ彛')}
+
+
+
+ Mbdy {dr_lang('瀛楁鏍囩璋冪敤宸ュ叿')}
+
+ {dr_lang('瀹樻柟搴旂敤甯傚満鍏嶈垂鎻掍欢銆傛敮鎸佸瓧娈佃皟鐢ㄣ侀〉闈㈡爣绛俱佸惊鐜爣绛俱佹悳绱㈡潯浠剁瓑锛屽彲鎸夋ā鍧/鏍忕洰/瀛楁鐐归夌敓鎴愪唬鐮侊紝閫傚悎鍚庡彴寮鍙戞椂浣跨敤銆')}
+
+ {dr_lang('瀹夎锛氬悗鍙般屽簲鐢ㄦ彃浠 鈫 搴旂敤甯傚満銆嶆悳绱')} Mbdy {dr_lang('鎴栥屽瓧娈垫爣绛捐皟鐢ㄥ伐鍏枫')}
+ {dr_lang('瀹夎鍚庤彍鍗曪細搴旂敤鎻掍欢 鈫 妯℃澘璋冪敤宸ュ叿')}
+
+
+
+ {if dr_is_app('mbdy')}
+ {dr_lang('鎵撳紑 Mbdy')}
+ {else}
+ {dr_lang('闇鍏堝畨瑁呮彃浠')}
+ {/if}
+
+
+
+ {dr_lang('鍦ㄧ嚎鏍囩鐢熸垚鍣')}
+
+ {dr_lang('杩呯澘瀹樻柟鍦ㄧ嚎宸ュ叿锛屾棤闇瀹夎鎻掍欢銆傚彲鐢熸垚甯哥敤鏍囩銆佸鑸惊鐜乵odule/category 鍐呭寰幆銆佽嚜瀹氫箟瀛楁璋冪敤绛変唬鐮侊紝閫傚悎蹇熸煡闃呬笌澶嶅埗銆')}
+
+
+ {dr_lang('鎵撳紑鍦ㄧ嚎宸ュ叿')}
+
+
+
+
+
{dr_lang('鎻愮ず锛氬湪绾垮伐鍏烽儴鍒嗐岃嚜瀹氫箟瀛楁璋冪敤銆嶅姛鑳介渶鍚庡彴瀹夎銆婂瓧娈垫爣绛剧敓鎴愬伐鍏枫嬫彃浠跺悗閰嶅悎浣跨敤锛岃瑙')} xunruicms.com/doc/code 銆
+
+
+
+
+
{dr_lang('鍐呭鍒楄〃')} {code}{module}{/code}
+
+
{code}{module module=news num=6 order=updatetime}
+{$t.url} {$t.title}
+{/module}
+
+{module catid=$catid order=updatetime page=1}
+{$t.url} {$t.title}
+{/module}
+{$pages}{/code}
+
+ module 鈥 {dr_lang('妯″潡鐩綍锛屽 news銆乸roduct')}
+ catid 鈥 {dr_lang('鏍忕洰 ID锛屾敮鎸侀楀彿澶氭爮鐩')}
+ num 鈥 {dr_lang('鏉℃暟锛涘垪琛ㄩ〉鐢 page=1 寮鍚垎椤')}
+ order 鈥 {dr_lang('鎺掑簭锛歶pdatetime銆乭its銆乨isplayorder 绛')}
+ flag 鈥 {dr_lang('鎺ㄨ崘浣嶇紪鍙')}
+ {dr_lang('甯哥敤瀛楁')}锛$t.title 銆$t.url 銆$t.thumb 銆$t.description 銆$t.hits
+
+
+
+
+
+
{dr_lang('鏍忕洰瀵艰埅')} {code}{category}{/code}
+
+
{code}{category module=share pid=0}
+{$t.url} {$t.title}
+{/category}
+
+{category module=share pid=$t.id return=t2}
+{$t.url} {$t.title}
+{/category}{/code}
+
+ module=share 鈥 {dr_lang('鍏变韩鏍忕洰鏍')}
+ pid=0 鈥 {dr_lang('涓绾ф爮鐩紱pid=$catid 鍙栧瓙鏍忕洰')}
+ return=t2 鈥 {dr_lang('鑷畾涔夊惊鐜彉閲忓悕锛岄伩鍏嶅祵濂楀啿绐')}
+
+
+
+
+
+
{dr_lang('鍏宠仈鍐呭')} {code}{related}{/code}
+
+
{code}{related module=MOD_DIR tag=$tag num=6}
+{$t.url} {$t.title}
+{/related}{/code}
+
{dr_lang('鎸 Tag 鎴栧叧閿瘝鍏宠仈鎺ㄨ崘锛屽父鐢ㄤ簬璇︽儏椤靛簳閮ㄣ岀浉鍏冲唴瀹广嶃')}
+
+
+
+
+
{dr_lang('甯哥敤鍑芥暟')}
+
+
+
+ {dr_lang('鍑芥暟')} {dr_lang('璇存槑')}
+
+
+ dr_catpos($catid, ...) {dr_lang('闈㈠寘灞戝鑸')}
+ dr_module_url($dir) {dr_lang('妯″潡棣栭〉鍦板潃')}
+ dr_thumb($thumb) {dr_lang('缂╃暐鍥惧湴鍧')}
+ dr_get_file($id) {dr_lang('闄勪欢/鍥剧墖瀹屾暣 URL')}
+ dr_show_hits($id) {dr_lang('璇︽儏椤垫祻瑙堥噺锛堣嚜鍔ㄨ鏁帮級')}
+ dr_strcut($str, $len) {dr_lang('瀛楃涓叉埅鏂')}
+ dr_site_value('瀛楁鍚') {dr_lang('璇诲彇缃戠珯淇℃伅鑷畾涔夊瓧娈')}
+ dr_get_content_kws($keywords) {dr_lang('鍏抽敭璇嶈浆 Tag 閾炬帴鏁扮粍')}
+
+
+
+
+
+
+
{dr_lang('闈欐佽祫婧愬紩鐢')}
+
+
<link href="{HOME_THEME_PATH}pc/css/style.bundle.css" rel="stylesheet" />
+<script src="{HOME_THEME_PATH}swiper/js/swiper.min.js"></script>
+<link href="{THEME_PATH}assets/icon/css/icon.css" rel="stylesheet" />
+
{code}{HOME_THEME_PATH}{/code} {dr_lang('鎸囧綋鍓嶉鏍肩洰褰曚笅鐨 static 璧勬簮锛')}{code}{THEME_PATH}{/code} {dr_lang('鎸囩郴缁熷悗鍙板叕鍏辫祫婧愩')}
+
+
+
+ {/if}
+
+ {if $page==3}
+
+
{dr_lang('鎺ㄨ崘澶嶅埗褰撳墠')} {SITE_TEMPLATE} {dr_lang('妯℃澘鍐嶄慨鏀癸紝鍙渶澶х▼搴︿繚璇侀〉闈㈢被鍨嬪畬鏁淬佹爣绛捐皟鐢ㄦ纭')}
+
+
+
+ {dr_lang('绗竴姝ワ細澶嶅埗妯℃澘鐩綍')}
+
+ 灏 template/pc/{SITE_TEMPLATE}/ 澶嶅埗涓烘柊鐩綍锛堝 mytpl 锛夛紱
+ 鎵嬫満绔悓姝ュ鍒 template/mobile/{SITE_TEMPLATE}/ 鈫 template/mobile/mytpl/ 銆
+
+
+
+ {dr_lang('绗簩姝ワ細澶嶅埗闈欐佽祫婧')}
+
+ 灏 static/{SITE_THEME}/ 澶嶅埗涓 static/mytpl/ 锛
+ 淇敼妯℃澘涓殑鏍峰紡銆佸浘鐗囪矾寰勫潎鐩稿浜 {code}{HOME_THEME_PATH}{/code} 銆
+
+
+
+ {dr_lang('绗笁姝ワ細淇敼妯℃澘鏂囦欢')}
+
+ 鑷冲皯淇濈暀 index.html 銆list.html 銆
+ show.html 銆header.html 銆footer.html 锛
+ 鎸夐渶璋冩暣 HTML 缁撴瀯涓 {code}{module}{/code} 銆{code}{category}{/code} {dr_lang('鏍囩璋冪敤')}銆
+
+
+
+ {dr_lang('绗洓姝ワ細鍚庡彴鍚敤')}
+
+ 杩涘叆 缃戠珯璁剧疆 锛
+ 灏嗐屾ā鏉跨洰褰曘嶆敼涓 mytpl 锛屻屼富棰橀鏍笺嶆敼涓 mytpl 骞朵繚瀛橈紱
+ 鎵嬫満璁剧疆 涓悓姝ラ夋嫨瀵瑰簲椋庢牸銆
+
+
+
+ {dr_lang('绗簲姝ワ細楠岃瘉鍓嶅彴')}
+
+ 渚濇璁块棶棣栭〉銆佹爮鐩垪琛ㄣ佸唴瀹硅鎯呫佹悳绱㈤〉锛岀‘璁ゅ竷灞涓庢暟鎹甯革紱
+ 淇敼妯℃澘鍚庡埛鏂版祻瑙堝櫒鍗冲彲锛屾棤闇鏇存柊绯荤粺缂撳瓨锛圲RL/鏍忕洰缁撴瀯鍙樻洿闄ゅ锛夈
+
+
+
+ {dr_lang('绗叚姝ワ細妯″潡/鏍忕洰瀹氬埗锛堝彲閫夛級')}
+
+ 鏌愭ā鍧楅渶鐙珛椋庢牸鏃讹紝鍦 妯″潡绠$悊 璁剧疆妯″潡涓婚椋庢牸锛
+ 鏌愭爮鐩渶鐗规畩鍒楄〃/璇︽儏椤垫椂锛屽湪鏍忕洰缂栬緫鐨勩屾ā鏉胯缃嶄腑鎸囧畾妯℃澘鏂囦欢鍚嶃
+
+
+
+
+
+
{dr_lang('甯歌闂')}
+
+
+ {dr_lang('淇敼鍚庢棤鍙樺寲')} 锛歿dr_lang('纭妯℃澘鐩綍锛圫ITE_TEMPLATE锛変笌涓婚椋庢牸锛圫ITE_THEME锛夋纭紱娓呴櫎娴忚鍣ㄧ紦瀛橈紱鑻ュ紑鍚潤鎬佸寲闇閲嶆柊鐢熸垚')}
+ {dr_lang('鏍峰紡涓㈠け')} 锛歿dr_lang('妫鏌 static/')}{SITE_THEME} {dr_lang('/ 鏄惁瀛樺湪锛涙ā鏉夸腑')} {code}{HOME_THEME_PATH}{/code} {dr_lang('璺緞鏄惁姝g‘')}
+ {dr_lang('鍒楄〃鏃犳暟鎹')} 锛歿dr_lang('妫鏌')} {code}{module}{/code} {dr_lang('鐨 module/catid 鍙傛暟锛涚‘璁ゆ爮鐩凡缁戝畾瀵瑰簲妯″潡涓旀湁鍐呭')}
+ {dr_lang('瀵艰埅涓嶆樉绀')} 锛歿dr_lang('鍏变韩鏍忕洰闇 module=share锛涙鏌ユ爮鐩屾槸鍚︽樉绀恒嶅紑鍏')}
+
+
+
+
+
+ {dr_lang('鍙傝')}锛
+ {dr_lang('褰撳墠绔欑偣妯℃澘浣嶄簬')} {TPLPATH}pc/{SITE_TEMPLATE}/home/ 锛
+ {dr_lang('鍙洿鎺ユ墦寮 index.html銆乴ist.html銆乻how.html 瀵圭収瀛︿範銆')}
+
+
+ {/if}
+
+
+
+
+
+{template "footer.html"}
diff --git a/dayrui/App/Cms/Views/help_url.html b/dayrui/App/Cms/Views/help_url.html
new file mode 100644
index 0000000..f7d9cdd
--- /dev/null
+++ b/dayrui/App/Cms/Views/help_url.html
@@ -0,0 +1,240 @@
+{template "header.html"}
+
+
+
+
+
+
+
+
+ {if $page==0}
+
+
{dr_lang('鑷畾涔 URL 鍙皢鍔ㄦ佸湴鍧锛堝 index.php?s=news&c=show&id=1锛夎浆鎹负浼潤鎬佸弸濂介摼鎺ワ紙濡 news/show-1.html锛夈傞渶鍚屾椂閰嶇疆銆孶RL 瑙勫垯銆嶄笌鏈嶅姟鍣ㄣ屼吉闈欐佽В鏋愩嶃')}
+
+
+
{dr_lang('鍔ㄦ佸湴鍧 vs 鑷畾涔 URL')}
+
+
+
+ {dr_lang('绫诲瀷')} {dr_lang('绀轰緥')} {dr_lang('璇存槑')}
+
+
+
+ {dr_lang('鍔ㄦ佸湴鍧')}
+ index.php?s=news&c=show&id=1
+ {dr_lang('鏃犻渶鏈嶅姟鍣 rewrite锛屽紑绠卞彲鐢')}
+
+
+ {dr_lang('鑷畾涔 URL')}
+ news/show-1.html
+ {dr_lang('闇 URL 瑙勫垯 + 浼潤鎬佽В鏋 + 鏈嶅姟鍣ㄩ厤缃')}
+
+
+
+
+
+
+
+
{dr_lang('瑙勫垯缁戝畾浣嶇疆')}
+
+
+
+ {dr_lang('缁戝畾浣嶇疆')} {dr_lang('閫傜敤')} {dr_lang('鍏ュ彛')}
+
+
+
+ {dr_lang('鍏ㄧ珯 URL 瑙勫垯')}
+ {dr_lang('鍏变韩妯″潡鏍忕洰椤点佸唴瀹归〉锛坱ype=3锛')}
+ {dr_lang('绔欑偣SEO')}
+
+
+ {dr_lang('妯″潡 URL 瑙勫垯')}
+ {dr_lang('鐙珛妯″潡棣栭〉銆佹爮鐩佸唴瀹广佹悳绱紙type=1锛')}
+ {dr_lang('妯″潡SEO')}
+
+
+ {dr_lang('鎼滅储 URL 瑙勫垯')}
+ {dr_lang('鍏变韩妯″潡鎼滅储椤碉紙type=2锛')}
+ {dr_lang('妯″潡SEO')} 锛坽dr_lang('鍏变韩妯″潡')}锛
+
+
+ {dr_lang('URL 瑙勫垯绠$悊')}
+ {dr_lang('鍒涘缓銆佺紪杈戙佸鍏ュ鍑鸿鍒')}
+ {dr_lang('URL瑙勫垯')}
+
+
+
+
+
+
+
+ {dr_lang('娉ㄦ剰')}锛
+ {dr_lang('浣跨敤鑷畾涔 URL 鍚庡繀椤婚厤缃吉闈欐佽В鏋愶紝鍚﹀垯椤甸潰鏃犳硶姝e父鎵撳紑銆傞厤缃枃浠讹細')} /config/rewrite.php
+
+
+ {/if}
+
+ {if $page==1}
+
+
{dr_lang('鍦')} {dr_lang('URL瑙勫垯')} {dr_lang('涓坊鍔犺鍒欐椂锛屾寜绫诲埆濉啓鍚勯〉闈 URL 鏍煎紡锛涜緭鍏ユ鏃佺殑銆屾彁绀恒嶆寜閽彲鏌ョ湅閫氶厤绗﹁鏄庛')}
+
+
+
{dr_lang('URL 瑙勫垯绫诲埆')}
+
+
+
+ {dr_lang('绫诲埆')} {dr_lang('鍖呭惈椤甸潰')}
+
+
+ {dr_lang('鐙珛妯″潡')}锛坱ype=1锛 {dr_lang('妯″潡棣栭〉銆佹爮鐩〉銆佹爮鐩垎椤点佸唴瀹归〉銆佸唴瀹瑰垎椤点佹悳绱㈤〉銆佹悳绱㈠垎椤')}
+ {dr_lang('鍏变韩妯″潡鎼滅储')}锛坱ype=2锛 {dr_lang('鎼滅储椤点佹悳绱㈠垎椤')}
+ {dr_lang('鍏变韩鏍忕洰鍜屽唴瀹归〉')}锛坱ype=3锛 {dr_lang('鏍忕洰椤点佹爮鐩垎椤点佸唴瀹归〉銆佸唴瀹瑰垎椤')}
+
+
+
+
+
+
+
{dr_lang('甯哥敤閫氶厤绗')}
+
+
+
+ {dr_lang('閫氶厤绗')} {dr_lang('璇存槑')}
+
+
+ {code}{modname}{/code} {dr_lang('妯″潡鐩綍鍚')}
+ {code}{id}{/code} {dr_lang('鏍忕洰 ID 鎴栧唴瀹 ID')}
+ {code}{dirname}{/code} {dr_lang('鏍忕洰鐩綍鍚嶇О')}
+ {code}{pdirname}{/code} {dr_lang('鍚笂绾х殑鏍忕洰鐩綍璺緞')}
+ {code}{opdirname}{/code} {dr_lang('鐖剁骇鏍忕洰鐩綍鍚')}
+ {code}{otdirname}{/code} {dr_lang('椤剁骇鏍忕洰鐩綍鍚')}
+ {code}{page}{/code} {dr_lang('鍒嗛〉椤电爜')}
+ {code}{y}{/code} / {code}{m}{/code} / {code}{d}{/code} {dr_lang('鍐呭鍙戝竷骞/鏈/鏃')}
+
+
+
{dr_lang('杩炴帴绗﹀彿')} catjoin {dr_lang('鐢ㄤ簬')} {code}{pdirname}{/code} {dr_lang('澶氱骇鐩綍杩炴帴锛岄粯璁や负')} / 锛坽dr_lang('濡')} china/beijing锛夈
+
+
+
+
+
{dr_lang('瑙勫垯绀轰緥')}
+
+
{dr_lang('鍐呭椤')} 鈥 {dr_lang('榛樿')} index.php?s=news&c=show&id=1
+
{code}show/{id}.html
+{modname}/{y}/{m}{id}.html
+{pdirname}/{id}.html{/code}
+
{dr_lang('鏍忕洰椤')} 鈥 {dr_lang('榛樿')} index.php?s=news&c=category&id=1
+
{code}{dirname}/{id}.html
+{pdirname}/index.html
+{modname}/list-{page}.html{/code}
+
{dr_lang('鎼滅储椤')}
+
{code}{modname}/search.html
+{modname}/search-{page}.html{/code}
+
+
+
+ {/if}
+
+ {if $page==2}
+
+
{dr_lang('瀹屾暣鍚敤鑷畾涔 URL 闇鍥涙锛氬垱寤鸿鍒 鈫 缁戝畾鍒扮珯鐐/妯″潡 鈫 鐢熸垚浼潤鎬佽В鏋 鈫 閮ㄧ讲鍒 Web 鏈嶅姟鍣ㄣ')}
+
+
+
+ {dr_lang('绗竴姝ワ細鍒涘缓 URL 瑙勫垯')}
+
+ 杩涘叆 {dr_lang('URL瑙勫垯')} 鈫 {dr_lang('娣诲姞')}锛
+ 閫夋嫨绫诲埆锛堢嫭绔嬫ā鍧 / 鍏变韩鎼滅储 / 鍏变韩鏍忕洰鍐呭锛夛紝
+ 鎸夐〉闈㈢被鍨嬪~鍐 URL 鏍煎紡锛屼繚瀛樿鍒欍
+
+
+
+ {dr_lang('绗簩姝ワ細缁戝畾瑙勫垯')}
+
+ 鍏变韩妯″潡锛氬湪 {dr_lang('绔欑偣SEO')} 鐨勩屽叏灞璁剧疆URL瑙勫垯銆嶄腑閫夋嫨 type=3 瑙勫垯锛
+ 鐙珛妯″潡锛氬湪 {dr_lang('妯″潡SEO')} 鍚勬ā鍧 Tab 鐨勩屾ā鍧桿RL瑙勫垯銆嶄腑閫夋嫨 type=1 瑙勫垯锛
+ 鍏变韩鎼滅储锛氬湪妯″潡 SEO锛堝叡浜ā鍧楋級鐨勩屾悳绱RL瑙勫垯銆嶄腑閫夋嫨 type=2 瑙勫垯銆
+
+
+
+ {dr_lang('绗笁姝ワ細鏇存柊缂撳瓨')}
+
+ 缁戝畾瑙勫垯鍚庢墽琛岀郴缁熺紦瀛樻洿鏂帮紱
+ 鍙湪绔欑偣 SEO 椤典娇鐢ㄣ屾壒閲忔洿鏂板唴瀹筓RL銆嶆寜妯″潡鍒锋柊宸叉湁鍐呭鐨勯摼鎺ュ湴鍧銆
+
+
+
+ {dr_lang('绗洓姝ワ細浼潤鎬佽В鏋')}
+
+ 杩涘叆 {dr_lang('浼潤鎬佽В鏋')} 锛
+ 鐐瑰嚮銆岀敓鎴愯В鏋愯鍒欍嶏紝灏嗕唬鐮佸啓鍏 /config/rewrite.php 锛
+ 鍐嶆寜椤甸潰鎻愮ず鍦 Nginx / Apache / IIS 涓厤缃 rewrite 瑙勫垯锛
+ 浣跨敤銆岀幆澧冩娴嬨嶉獙璇佸悇鍩熷悕鏄惁鏀寔浼潤鎬併
+
+
+
+ {dr_lang('绗簲姝ワ細楠岃瘉')}
+
+ 璁块棶鍓嶅彴鏍忕洰鍒楄〃銆佸唴瀹硅鎯呫佹悳绱㈤〉锛岀‘璁ら摼鎺ュ凡涓鸿嚜瀹氫箟鏍煎紡涓旈〉闈㈡甯告墦寮锛
+ 鑻 404锛屾鏌 rewrite 閰嶇疆涓 rewrite.php 鏄惁鍖归厤褰撳墠 URL 瑙勫垯銆
+
+
+
+
+
+
{dr_lang('甯歌闂')}
+
+
+ {dr_lang('鑷畾涔 URL 鍚 404')} 锛歿dr_lang('妫鏌ヤ吉闈欐佽В鏋愭槸鍚︾敓鎴愬苟閮ㄧ讲锛汵ginx 闇 reload锛汚pache 闇寮鍚 mod_rewrite')}
+ {dr_lang('閾炬帴浠嶆槸鍔ㄦ佸湴鍧')} 锛歿dr_lang('纭瑙勫垯宸茬粦瀹氾紱鏇存柊缂撳瓨锛涙壒閲忔洿鏂板唴瀹 URL')}
+ {dr_lang('閮ㄥ垎椤甸潰姝e父閮ㄥ垎 404')} 锛歿dr_lang('妫鏌ヨ鍒欑被鍒槸鍚﹂夊锛堢嫭绔嬫ā鍧楃敤 type=1锛屽叡浜唴瀹圭敤 type=3锛')}
+ {dr_lang('澶氱珯鐐/澶氬煙鍚')} 锛歿dr_lang('浼潤鎬佽В鏋愰〉鎸夊煙鍚嶅垎鍒娴嬶紱鍚勫煙鍚 rewrite 閰嶇疆闇涓鑷')}
+
+
+
+
+
+
+ {/if}
+
+
+
+
+
+{template "footer.html"}
diff --git a/dayrui/App/Cms/Views/module_category_field.html b/dayrui/App/Cms/Views/module_category_field.html
new file mode 100644
index 0000000..7232110
--- /dev/null
+++ b/dayrui/App/Cms/Views/module_category_field.html
@@ -0,0 +1,70 @@
+{template "header.html"}
+
+
+
+
+
{dr_lang('鏍忕洰妯″瀷瀛楁闇瑕佸垝鍒嗗埌鍏蜂綋鐨勬煇涓涓爮鐩笂')}
+
+
+
+
+ {dr_form_hidden()}
+
+
+
+
+
+
+ {loop $list $t}
+
+ {/loop}
+
+
+
+ {if !$list}
+
{dr_lang('浣犳病鏈夊垱寤鸿嚜瀹氫箟鏍忕洰妯″瀷瀛楁')}
+ {/if}
+
+
+
+
+
+
+{php echo \Phpcmf\Service::L('Field')->get('select')->get_select_search_code();}
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/module_create.html b/dayrui/App/Cms/Views/module_create.html
new file mode 100644
index 0000000..a033703
--- /dev/null
+++ b/dayrui/App/Cms/Views/module_create.html
@@ -0,0 +1,76 @@
+{template "header.html"}
+
+{if IS_DEV}
+
+ {$form}
+
+
+
+ {dr_lang('鍒涘缓妯″潡')}
+
+
+
+{else}
+
+
褰撳墠鐜娌℃湁寮鍚紑鍙戣呮ā寮忥紝涓嶅厑璁稿垱寤烘ā鍧楋紱
+
鏂版墜鐢ㄦ埛涓嶅缓璁垱寤哄涓ā鍧楋紝涓涓猲ews妯″潡瓒充互杩涜寤虹珯椤圭洰銆
+
+{/if}
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/module_edit.html b/dayrui/App/Cms/Views/module_edit.html
new file mode 100644
index 0000000..9410bed
--- /dev/null
+++ b/dayrui/App/Cms/Views/module_edit.html
@@ -0,0 +1,331 @@
+{template "header.html"}
+
+
+ {$form}
+
+
+
+
+
+
+
+
+
+ {if !$data.share}
+
+ {/if}
+ {if !$is_hcategory}
+
+
+ {/if}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{dr_lang('涓婚椋庢牸')}
+
+
+ --
+ {loop $theme $t}
+ {$t}
+ {/loop}
+
+ {dr_lang('浣嶄簬椤圭洰涓荤珯鏍圭洰褰曚笅锛/static/椋庢牸鍚嶇О/')}
+
+
+
+
{dr_lang('杩滅▼璧勬簮')}
+
+
+ {dr_lang('椤圭洰灏嗚皟鐢ㄦ鍦板潃鐨刢ss,js,鍥剧墖绛夐潤鎬佽祫婧')}
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/module_flag.html b/dayrui/App/Cms/Views/module_flag.html
new file mode 100644
index 0000000..da75437
--- /dev/null
+++ b/dayrui/App/Cms/Views/module_flag.html
@@ -0,0 +1,105 @@
+{template "header.html"}
+
+
{dr_lang('鎺ㄨ崘浣嶆槸瀵瑰唴瀹硅繘琛屾帹鑽愬垎绫伙紝鏂逛究鍓嶇鏁版嵁璋冪敤锛屼緥濡傦細棣栭〉澶存潯銆佸够鐏帹鑽愩侀閬撴帹鑽愮瓑')}
+
+{php echo \Phpcmf\Service::L('Field')->get('select')->get_select_search_code();}
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/module_list.html b/dayrui/App/Cms/Views/module_list.html
new file mode 100644
index 0000000..c0f84a9
--- /dev/null
+++ b/dayrui/App/Cms/Views/module_list.html
@@ -0,0 +1,87 @@
+{template "header.html"}
+
+
+
+
+ {dr_form_hidden()}
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/module_name_edit.html b/dayrui/App/Cms/Views/module_name_edit.html
new file mode 100644
index 0000000..b8a140c
--- /dev/null
+++ b/dayrui/App/Cms/Views/module_name_edit.html
@@ -0,0 +1,33 @@
+{template "header.html"}
+
+
+ {$form}
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/module_search.html b/dayrui/App/Cms/Views/module_search.html
new file mode 100644
index 0000000..5781c1d
--- /dev/null
+++ b/dayrui/App/Cms/Views/module_search.html
@@ -0,0 +1,238 @@
+{template "header.html"}
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/seo.html b/dayrui/App/Cms/Views/seo.html
new file mode 100644
index 0000000..6c3f5f6
--- /dev/null
+++ b/dayrui/App/Cms/Views/seo.html
@@ -0,0 +1,190 @@
+{template "header.html"}
+
+
+
+ {$form}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/seo_category.html b/dayrui/App/Cms/Views/seo_category.html
new file mode 100644
index 0000000..b5b65e2
--- /dev/null
+++ b/dayrui/App/Cms/Views/seo_category.html
@@ -0,0 +1,187 @@
+{template "header.html"}
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/seo_category_edit.html b/dayrui/App/Cms/Views/seo_category_edit.html
new file mode 100644
index 0000000..7888064
--- /dev/null
+++ b/dayrui/App/Cms/Views/seo_category_edit.html
@@ -0,0 +1,94 @@
+{template "header.html"}
+
+
+ {dr_form_hidden()}
+
+
+ {if $dirname == 'share'}
+ {if dr_is_app('chtml')}
+
+
+ {else}
+
+ {/if}
+
+ {/if}
+
+
+
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/seo_module.html b/dayrui/App/Cms/Views/seo_module.html
new file mode 100644
index 0000000..031692f
--- /dev/null
+++ b/dayrui/App/Cms/Views/seo_module.html
@@ -0,0 +1,289 @@
+{template "header.html"}
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/seo_site.html b/dayrui/App/Cms/Views/seo_site.html
new file mode 100644
index 0000000..7ee8ac9
--- /dev/null
+++ b/dayrui/App/Cms/Views/seo_site.html
@@ -0,0 +1,123 @@
+{template "header.html"}
+
+
+
+ {$form}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/share_category_all.html b/dayrui/App/Cms/Views/share_category_all.html
new file mode 100644
index 0000000..32fb4a5
--- /dev/null
+++ b/dayrui/App/Cms/Views/share_category_all.html
@@ -0,0 +1,97 @@
+{template "header.html"}
+
+
+
+
+
+
+ {$form}
+
+
+
+
+
+
+
+
+
+ {if $module.share}
+
+
+ {/if}
+
+
+
+
+
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/share_category_config.html b/dayrui/App/Cms/Views/share_category_config.html
new file mode 100644
index 0000000..af634ae
--- /dev/null
+++ b/dayrui/App/Cms/Views/share_category_config.html
@@ -0,0 +1,174 @@
+{template "header.html"}
+
+
+
+
+
+
+ {dr_form_hidden()}
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/share_category_content.html b/dayrui/App/Cms/Views/share_category_content.html
new file mode 100644
index 0000000..f0e5c5a
--- /dev/null
+++ b/dayrui/App/Cms/Views/share_category_content.html
@@ -0,0 +1,9 @@
+{template "header.html"}
+
+
+ {dr_form_hidden()}
+
+ {$myfield}
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/share_category_copy.html b/dayrui/App/Cms/Views/share_category_copy.html
new file mode 100644
index 0000000..b967f1b
--- /dev/null
+++ b/dayrui/App/Cms/Views/share_category_copy.html
@@ -0,0 +1,35 @@
+{template "header.html"}
+
+
+ {$form}
+
+
+
+{php echo \Phpcmf\Service::L('Field')->get('select')->get_select_search_code();}
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/share_category_field.html b/dayrui/App/Cms/Views/share_category_field.html
new file mode 100644
index 0000000..f7c322b
--- /dev/null
+++ b/dayrui/App/Cms/Views/share_category_field.html
@@ -0,0 +1,54 @@
+{template "header.html"}
+
+
{dr_lang('鍕鹃夌姸鎬佺殑瀛楁鍙互鏄剧ず鍦ㄦ湰鏍忕洰鐨勭紪杈戦〉闈腑')}
+
+
+
+ {dr_form_hidden()}
+
+
+
+
{dr_lang('灏嗕互涓婄殑瀛楁閰嶇疆瑕嗙洊鍒颁互涓嬬殑閫変腑鏍忕洰涔嬩腑')}
+
+
+
+
+ {php echo \Phpcmf\Service::L('Field')->get('select')->get_select_search_code();}
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/share_category_linkurl.html b/dayrui/App/Cms/Views/share_category_linkurl.html
new file mode 100644
index 0000000..3f97bcf
--- /dev/null
+++ b/dayrui/App/Cms/Views/share_category_linkurl.html
@@ -0,0 +1,9 @@
+{template "header.html"}
+
+
+ {dr_form_hidden()}
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/share_category_list.html b/dayrui/App/Cms/Views/share_category_list.html
new file mode 100644
index 0000000..728758d
--- /dev/null
+++ b/dayrui/App/Cms/Views/share_category_list.html
@@ -0,0 +1,272 @@
+{template "header.html"}
+
+
+
+
+
+
+
+ {dr_form_hidden()}
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/share_category_post.html b/dayrui/App/Cms/Views/share_category_post.html
new file mode 100644
index 0000000..7001b2b
--- /dev/null
+++ b/dayrui/App/Cms/Views/share_category_post.html
@@ -0,0 +1,415 @@
+{template "header.html"}
+
+
+{if !isset($_GET['isedit'])}
+
+{/if}
+
+
+
+ {$form}
+
+
+
+
+ {if !isset($_GET['isedit'])}
+
+
+ {else}
+
+ {/if}
+
+
+
+
+
+
+
+ {if $is_scategory}
+
+ {/if}
+ {if $module.share}
+
+ {/if}
+
+
+
+
+
+
+
+
+
+
+
+ {if $module.share}
+ {if dr_is_app('chtml')}
+
+ {/if}
+
+ {/if}
+
+
+
+
+ {if $id}
+
+ {/if}
+
+
+
+
+
+ {php $catsync = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-'.$mid, 'setting', 'search', 'catsync');}
+ {if $catsync}
+
+ {else}
+
+ {if SITE_IS_MOBILE || $ci->site_info[SITE_ID]['SITE_AUTO']}
+
+ {else}
+
+ {/if}
+ {/if}
+ {if $is_scategory}
+
+ {/if}
+
+ {if $catsync}
+
+
+
+
+ {else}
+
+
+ {/if}
+
+
+ {if $id}
+
+ {/if}
+
+
+
+
+
+ {$sysfield}
+ {$myfield}
+ {$diyfield}
+
+
+
+
+
+
+
+ {if !isset($_GET['isedit'])}
+
+
+
{dr_lang('淇濆瓨鍐呭')}
+ {if !isset($_GET['isedit'])}
+
{dr_lang('淇濆瓨鍐嶆坊鍔')}
+
{dr_lang('淇濆瓨骞惰繑鍥')}
+ {/if}
+ {if $web_url}
+
{dr_lang('娴忚')}
+ {/if}
+
+
{/if}
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/share_category_url.html b/dayrui/App/Cms/Views/share_category_url.html
new file mode 100644
index 0000000..f7c95c9
--- /dev/null
+++ b/dayrui/App/Cms/Views/share_category_url.html
@@ -0,0 +1,54 @@
+{template "header.html"}
+
+
+ {$form}
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/share_delete.html b/dayrui/App/Cms/Views/share_delete.html
new file mode 100644
index 0000000..4203e6f
--- /dev/null
+++ b/dayrui/App/Cms/Views/share_delete.html
@@ -0,0 +1,40 @@
+{template "header.html"}
+
+
+ {dr_form_hidden()}
+
+
+
+ {if $delete_msg}
+
+ {/if}
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/share_list.html b/dayrui/App/Cms/Views/share_list.html
new file mode 100644
index 0000000..8d33a89
--- /dev/null
+++ b/dayrui/App/Cms/Views/share_list.html
@@ -0,0 +1,135 @@
+{template "header.html"}
+
+{template "api_list_date_search.html"}
+
+
+
+
+
+
+
+ {$mytable.foot_tpl}
+
+ {template "mytable.html"}
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/share_list_draft.html b/dayrui/App/Cms/Views/share_list_draft.html
new file mode 100644
index 0000000..44ee1ed
--- /dev/null
+++ b/dayrui/App/Cms/Views/share_list_draft.html
@@ -0,0 +1,114 @@
+{template "header.html"}
+
+{template "api_list_date_search.html"}
+
+
+
+
+
+
+
+ {dr_form_hidden()}
+ {if $ci->_is_admin_auth('del')}
+
+
+ {dr_lang('鍒犻櫎')}
+
+
+
+ {/if}
+
+
+ {if $mypages}
+
+ {/if}
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/share_list_recycle.html b/dayrui/App/Cms/Views/share_list_recycle.html
new file mode 100644
index 0000000..aff7b65
--- /dev/null
+++ b/dayrui/App/Cms/Views/share_list_recycle.html
@@ -0,0 +1,119 @@
+{template "header.html"}
+
+{template "api_list_date_search.html"}
+
+
+
+
+
+
+
+
+ {dr_form_hidden()}
+
+
+
+
+ {if $ci->_is_admin_auth('edit')}
+ {dr_lang('鎭㈠')}
+ {/if}
+ {if $ci->_is_admin_auth('del')}
+ {dr_lang('鍒犻櫎')}
+ {dr_lang('娓呯┖鍥炴敹绔')}
+ {/if}
+
+
+
+
+
+
+
+ {if $mypages}
+
+ {/if}
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/share_list_time.html b/dayrui/App/Cms/Views/share_list_time.html
new file mode 100644
index 0000000..a8d666b
--- /dev/null
+++ b/dayrui/App/Cms/Views/share_list_time.html
@@ -0,0 +1,116 @@
+{template "header.html"}
+
+{template "api_list_date_search.html"}
+
+
+
+
+
+
+
+ {dr_form_hidden()}
+
+
+ {if $ci->_is_admin_auth('del')}
+ {dr_lang('鍒犻櫎')}
+ {/if}
+ {if $ci->_is_admin_auth('edit')}
+ {dr_lang('鎵归噺绔嬪嵆鍙戝竷')}
+ {/if}
+
+
+
+
+
+ {if $mypages}
+
+ {/if}
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/share_list_verify.html b/dayrui/App/Cms/Views/share_list_verify.html
new file mode 100644
index 0000000..675cf6d
--- /dev/null
+++ b/dayrui/App/Cms/Views/share_list_verify.html
@@ -0,0 +1,304 @@
+{template "header.html"}
+
+{template "api_list_date_search.html"}
+
+
+
+ --
+ {loop $verify_msg $t}
+ {$t}
+ {/loop}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {dr_form_hidden()}
+
+ {if $ci->_is_admin_auth('del') || $ci->_is_admin_auth('edit')}
+
+
+ {if $ci->_is_admin_auth('del')}
+ {dr_lang('鍒犻櫎')}
+ {/if}
+ {if !$is_post_user}
+ {dr_lang('閫氳繃')}
+ {dr_lang('鎷掔粷')}
+ {/if}
+
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/share_list_verify_all.html b/dayrui/App/Cms/Views/share_list_verify_all.html
new file mode 100644
index 0000000..e2cb633
--- /dev/null
+++ b/dayrui/App/Cms/Views/share_list_verify_all.html
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+ {dr_clearhtml($msg)}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {dr_form_hidden()}
+
+
+
+ {loop $list $id $t}
+
+ {$t.title}
+
+
+
+ {/loop}
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/share_post.html b/dayrui/App/Cms/Views/share_post.html
new file mode 100644
index 0000000..cd051f8
--- /dev/null
+++ b/dayrui/App/Cms/Views/share_post.html
@@ -0,0 +1,726 @@
+{template "header.html"}
+
+
+{if $post_notice_msg}
+
+{/if}
+
+ {$form}
+
+ {if $mymerge && $ci->module['setting']['merge']}
+
+
+ {/if}
+
+
+
+
+
+
+ {dr_lang('鍩烘湰鍐呭')}
+
+
+
+ {if $draft_list}
+
+ {/if}
+
+
+
+
+
+
+ {if $diyfield}
+
+
+
+ {dr_lang('鍏朵粬鍐呭')}
+
+
+
+
+ {/if}
+
+
+
+
+
+
+ {dr_rp($sysfield, ['md-2', 'md-10'], 'md-12')}
+ {if $is_flag}
+
+ {/if}
+ {if !$is_verify && $is_post_time}
+
+ {/if}
+
+
+
+
+
+
+
+ {if $is_verify}
+
+
+
+
+
+ {dr_lang('鍐呭瀹℃牳')}
+
+
+
+
+
+ {if $status}
+
+ {else}
+
+
+
+ {if $verify.backinfo.backcontent}
+
+ {/if}
+ {/if}
+ {if $verify_step[$status]['name']}
+
+ {/if}
+
+ {if $is_post_user}
+
+
+ {if $verify.backinfo.backcontent}
+
+ {/if}
+ {else}
+
+ {if $verify_next == 9}
+
+ {/if}
+
+
+ {/if}
+
+
+
+
+
+
+
+
+ {/if}
+
+
+
+
+
+
+ {if !defined('IS_MODULE_RECYCLE')}
+ {if $is_verify}
+ {if dr_is_app('ai_helper')}
+
{dr_lang('AI瀹℃牳')}
+
+
+ {/if}
+
{dr_lang('鎻愪氦瀹℃牳')}
+ {else if $is_post_time}
+
{dr_lang('淇濆瓨鍐呭')}
+ {else}
+ {if dr_is_app('ai_helper')}
+
{dr_lang('AI鍒涗綔')}
+
+
+ {/if}
+
{dr_lang('淇濆瓨鍐呭')}
+
{dr_lang('淇濆瓨鍐嶆坊鍔')}
+
{dr_lang('淇濆瓨骞惰繑鍥')}
+ {if $ci->_is_admin_auth(MOD_DIR.'/draft/add')}
+
{dr_lang('淇濆瓨鑽夌ǹ')}
+ {/if}
+ {if !$id && $ci->_is_admin_auth(MOD_DIR.'/time/add')}
+
{dr_lang('瀹氭椂鍙戝竷')}
+ {/if}
+ {if $is_form_cache}
+
{dr_lang('鍒犻櫎鍘嗗彶缂撳瓨')}
+ {/if}
+ {/if}
+ {if $id && !$is_verify && !$is_post_user && $ci->_is_admin_auth(MOD_DIR.'/verify/index')}
+
{dr_lang('閫绋')}
+ {/if}
+ {else}
+
{dr_lang('杩斿洖鍒楄〃')}
+
{dr_lang('鎭㈠姝ゅ唴瀹')}
+ {/if}
+ {if $web_url}
+
{dr_lang('娴忚')}
+ {/if}
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/share_send.html b/dayrui/App/Cms/Views/share_send.html
new file mode 100644
index 0000000..a60335e
--- /dev/null
+++ b/dayrui/App/Cms/Views/share_send.html
@@ -0,0 +1,73 @@
+{template "header.html"}
+
+
+ {$form}
+
+ {if $page==0}
+
+
+ {if $module['setting']['flag']}
+
+ {else}
+
{dr_lang('鎺ㄨ崘浣嶅皻鏈缃')}
+ {/if}
+
+ {else if $page==1}
+
+ {else if $page==5}
+
+
+ {/if}
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/share_syncat.html b/dayrui/App/Cms/Views/share_syncat.html
new file mode 100644
index 0000000..a1acf01
--- /dev/null
+++ b/dayrui/App/Cms/Views/share_syncat.html
@@ -0,0 +1,20 @@
+{template "header.html"}
+
+
+ {$form}
+
+
+{php echo \Phpcmf\Service::L('Field')->get('select')->get_select_search_code();}
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/share_time.html b/dayrui/App/Cms/Views/share_time.html
new file mode 100644
index 0000000..0287bb7
--- /dev/null
+++ b/dayrui/App/Cms/Views/share_time.html
@@ -0,0 +1,50 @@
+{template "header.html"}
+
+
+ {$form}
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/site_config.html b/dayrui/App/Cms/Views/site_config.html
new file mode 100644
index 0000000..a0014d1
--- /dev/null
+++ b/dayrui/App/Cms/Views/site_config.html
@@ -0,0 +1,238 @@
+{template "header.html"}
+
+
+
{dr_lang('涓婚椋庢牸')}
+
+
+ --
+ {loop $theme $t}
+ {$t}
+ {/loop}
+
+ {dr_lang('浣嶄簬缃戠珯涓荤珯鏍圭洰褰曚笅锛/static/椋庢牸鍚嶇О/')}
+
+
+
+
{dr_lang('杩滅▼璧勬簮')}
+
+
+ {dr_lang('缃戠珯灏嗚皟鐢ㄦ鍦板潃鐨刢ss銆乯s銆佸浘鐗囩瓑闈欐佽祫婧愶紝浠ttp寮澶村苟浠/缁撳熬')}
+
+
+
+
+ {$form}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/site_domain.html b/dayrui/App/Cms/Views/site_domain.html
new file mode 100644
index 0000000..95467b5
--- /dev/null
+++ b/dayrui/App/Cms/Views/site_domain.html
@@ -0,0 +1,248 @@
+{template "header.html"}
+
+
+
+ {$form}
+
+
+
+
+
+
+
+
+
+
+
+
+ {if SITE_ID > 1}
+
+ {/if}
+
+
+
+
+
+
+
+ {loop $module $dir $t}
+ {if !$t.share}
+
+
+
+ {/if}
+ {/loop}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {dr_lang('鏈嶅姟鍣ㄧ粦瀹氬煙鍚嶈鏄')}
+ {dr_lang('浠ヤ笅鍩熷悕闇瑕佸湪鏈嶅姟鍣ㄤ笂杩涜缁戝畾锛屼篃鍙互鎵剧┖闂村晢甯綘鎿嶄綔')}
+
+
+
+
+
+
+ {if $data['site_domain']}
+
+ {/if}
+ {if $data['mobile_domain']}
+
+ {/if}
+
+
+ {loop $module $dir $t}
+ {if !$t.error}
+ {if $data['module_'.$dir]}
+
+ {/if}
+ {if $data['module_mobile_'.$dir]}
+
+ {/if}
+
+ {/if}
+ {/loop}
+
+
+
+
+
+
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/site_domain_edit.html b/dayrui/App/Cms/Views/site_domain_edit.html
new file mode 100644
index 0000000..2d20aa7
--- /dev/null
+++ b/dayrui/App/Cms/Views/site_domain_edit.html
@@ -0,0 +1,56 @@
+{template "header.html"}
+
+
+ {$form}
+
+
+ {if $is_fclient}
+ {dr_lang('褰撳墠缃戠珯涓嶈兘淇敼涓诲煙鍚嶏紝璇峰埌[%s]涓婁慨鏀逛富鍩熷悕鍐嶈繘琛屾暟鎹氫俊鎿嶄綔', $fcname)}
+ {else}
+
+
+
+ {/if}
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/site_image.html b/dayrui/App/Cms/Views/site_image.html
new file mode 100644
index 0000000..e307fde
--- /dev/null
+++ b/dayrui/App/Cms/Views/site_image.html
@@ -0,0 +1,393 @@
+{template "header.html"}
+
+
{dr_lang('姘村嵃浠呴檺浜庢湰鍦板瓨鍌ㄧ殑鍥剧墖鏂囦欢锛屾澶勮缃拡瀵硅繙绋嬪浘鐗囨棤鏁')}
+
+
+
+
+
+
+
+ {$form}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{dr_lang('鐩綍妫娴嬬粨鏋')}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {dr_lang('淇濆瓨')}
+ {dr_lang('棰勮姘村嵃')}
+
+
+
+
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/site_mobile.html b/dayrui/App/Cms/Views/site_mobile.html
new file mode 100644
index 0000000..4c5729f
--- /dev/null
+++ b/dayrui/App/Cms/Views/site_mobile.html
@@ -0,0 +1,182 @@
+{template "header.html"}
+
+
+ {$form}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {if !$is_tpl}
+
+ {/if}
+
+
+
+
+
+
+
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/site_param.html b/dayrui/App/Cms/Views/site_param.html
new file mode 100644
index 0000000..d9e8576
--- /dev/null
+++ b/dayrui/App/Cms/Views/site_param.html
@@ -0,0 +1,102 @@
+{template "header.html"}
+
+
+
+ {$form}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {if $my_site_info}
+ {load "$my_site_info"}
+ {/if}
+
+ {$myfield}
+
+
+
+
+
+
+
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/urlrule_add.html b/dayrui/App/Cms/Views/urlrule_add.html
new file mode 100644
index 0000000..09ebb62
--- /dev/null
+++ b/dayrui/App/Cms/Views/urlrule_add.html
@@ -0,0 +1,246 @@
+{template "header.html"}
+
+
+
+ {$form}
+
+
+
+
+
+ {dr_lang('URL瑙勫垯')}
+
+
+
+
+
+
+
+ {$myfield}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {dr_lang('淇濆瓨鍐呭')}
+ {dr_lang('淇濆瓨鍐嶆坊鍔')}
+ {dr_lang('淇濆瓨骞惰繑鍥')}
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/urlrule_code.html b/dayrui/App/Cms/Views/urlrule_code.html
new file mode 100644
index 0000000..96cc7b7
--- /dev/null
+++ b/dayrui/App/Cms/Views/urlrule_code.html
@@ -0,0 +1,77 @@
+{template header.html}
+
+
+
+
+
{dr_lang('褰撳墠鏈嶅姟鍣ㄦ槸锛%s ', $name)}
+
+
+
+
+
+ {$name}
+ 闇瑕佸湪鏈嶅姟鍣ㄤ腑閰嶇疆锛屼笉鎳傜殑鍙互鍜ㄨ鏈嶅姟鍣ㄧ┖闂村晢
+
+
+
+
{$note}
+ {if $code}
+
{$code}
+ {/if}
+
+
+ {loop $domain $name $cname}
+ {$cname}锛歿$name}
+ {dr_lang('鐜妫娴')}
+
+ {/loop}
+
+
+
+
+
+{template footer.html}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/urlrule_index.html b/dayrui/App/Cms/Views/urlrule_index.html
new file mode 100644
index 0000000..cf3eb17
--- /dev/null
+++ b/dayrui/App/Cms/Views/urlrule_index.html
@@ -0,0 +1,70 @@
+{template "header.html"}
+
+
+
+
+
+ {dr_form_hidden()}
+ {if $ci->_is_admin_auth('del')}
+
+
+ {dr_lang('鍒犻櫎')}
+
+ {if !IS_OEM_CMS}
+ {dr_lang('甯哥敤鐨勮鍒欎唬鐮')}
+
+ {/if}
+
+
{/if}
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Cms/Views/urlrule_rewrite.html b/dayrui/App/Cms/Views/urlrule_rewrite.html
new file mode 100644
index 0000000..5e68a7b
--- /dev/null
+++ b/dayrui/App/Cms/Views/urlrule_rewrite.html
@@ -0,0 +1,113 @@
+{template header.html}
+
+
+
+
+
{dr_lang('褰撳墠鏈嶅姟鍣ㄦ槸锛%s ', $name)}
+
+
+
+
+
+ {$name}
+ 闇瑕佸湪鏈嶅姟鍣ㄤ腑閰嶇疆锛屼笉鎳傜殑鍙互鍜ㄨ鏈嶅姟鍣ㄧ┖闂村晢
+
+
+
+
{$note}
+ {if $code}
+
{$code}
+ {/if}
+
+
+ {loop $domain $name $cname}
+ {$cname}锛歿$name}
+ {dr_lang('鐜妫娴')}
+
+ {/loop}
+
+
+
浼潤鎬乁RL瑙f瀽瑙勫垯閰嶇疆鏂囦欢锛/config/rewrite.php
+
浣跨敤鑷畾涔塙RL涔嬪悗蹇呴』瑕佽缃В鏋愯鍒欙紝鍚﹀垯鏄棤娉曟甯告墦寮椤甸潰鐨
+
+ {dr_lang('鐢熸垚瑙f瀽瑙勫垯')}
+ {dr_lang('鍦ㄧ嚎甯姪')}
+
+
+
+
+
+
+
+ {dr_form_hidden()}
+ {if $ci->_is_admin_auth('del')}
+
+
+ {dr_lang('鍒犻櫎')}
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/member_apply_post.html b/dayrui/App/Member/Views/member_apply_post.html
new file mode 100644
index 0000000..19c3c5e
--- /dev/null
+++ b/dayrui/App/Member/Views/member_apply_post.html
@@ -0,0 +1,97 @@
+{template "header.html"}
+
+
{dr_lang('鐢ㄦ埛鑷姪鐢宠鐢ㄦ埛缁勬潈闄')}
+
+
+
+ {$form}
+
+
+
+
+
+
+ {dr_lang('鐢宠璇︽儏')}
+
+
+
+
+
+
+
+
+
+
+
+
+ {$myfield}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {dr_lang('鎻愪氦瀹℃牳')}
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/member_auth.html b/dayrui/App/Member/Views/member_auth.html
new file mode 100644
index 0000000..964ca08
--- /dev/null
+++ b/dayrui/App/Member/Views/member_auth.html
@@ -0,0 +1,152 @@
+{template "header.html"}
+
+
+ {dr_form_hidden()}
+
+
+
+ {dr_lang('鐢ㄦ埛鏉冮檺')}
+
+
+
+
+
+ {if $is_cms}
+
+ {/if}
+
+
+
+
+
+ {if $is_single}
+ {$form_html}
+ {else}
+
+ {/if}
+
+
+
+
+
+
+
+
+ {dr_lang('淇濆瓨鏉冮檺閰嶇疆')}
+
+
+
+
+
+
+
+{template "footer.html"}
diff --git a/dayrui/App/Member/Views/member_auth_category.html b/dayrui/App/Member/Views/member_auth_category.html
new file mode 100644
index 0000000..1a71d47
--- /dev/null
+++ b/dayrui/App/Member/Views/member_auth_category.html
@@ -0,0 +1,104 @@
+{if $is_ajax_edit}
+{template "header.html"}
+
+
+
+ {dr_form_hidden()}
+ {/if}
+
+
+ {dr_lang('璁块棶')}
+
+
+
+
+
+ {dr_lang('鍙戝竷')}
+
+
+
+
+
+ {dr_lang('淇敼')}
+
+
+
+
+ {dr_lang('鍒犻櫎')}
+
+
+
+
+ {dr_lang('楠岃瘉鐮')}
+
+
+
+
+
+
+
+ {dr_lang('涓嶅鏍')}
+ {loop $verify $v}
+ {dr_lang($v.name)}
+ {/loop}
+
+
+ {if dr_is_app('explog')}
+
+ {/if}
+ {if dr_is_app('scorelog')}
+
+ {/if}
+
+
+
+
+ {loop $diy.category $d}
+
+ {php $dfile=$d.file;}
+ {load "$dfile"}
+
+ {/loop}
+
+ {if $is_ajax_edit}
+
+
+{/if}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/member_auth_copy_category.html b/dayrui/App/Member/Views/member_auth_copy_category.html
new file mode 100644
index 0000000..99f906e
--- /dev/null
+++ b/dayrui/App/Member/Views/member_auth_copy_category.html
@@ -0,0 +1,29 @@
+{template "header.html"}
+
+
+ {dr_form_hidden()}
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/member_auth_copy_form.html b/dayrui/App/Member/Views/member_auth_copy_form.html
new file mode 100644
index 0000000..ee23f3f
--- /dev/null
+++ b/dayrui/App/Member/Views/member_auth_copy_form.html
@@ -0,0 +1,29 @@
+{template "header.html"}
+
+
+ {dr_form_hidden()}
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/member_auth_copy_group.html b/dayrui/App/Member/Views/member_auth_copy_group.html
new file mode 100644
index 0000000..b80f07d
--- /dev/null
+++ b/dayrui/App/Member/Views/member_auth_copy_group.html
@@ -0,0 +1,29 @@
+{template "header.html"}
+
+
+ {dr_form_hidden()}
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/member_auth_form.html b/dayrui/App/Member/Views/member_auth_form.html
new file mode 100644
index 0000000..02253da
--- /dev/null
+++ b/dayrui/App/Member/Views/member_auth_form.html
@@ -0,0 +1,104 @@
+{if $is_ajax_edit}
+{template "header.html"}
+
+
+
+ {dr_form_hidden()}
+ {/if}
+
+
+ {dr_lang('璁块棶')}
+
+
+
+
+ {dr_lang('鍙戝竷')}
+
+
+
+
+
+ {dr_lang('淇敼')}
+
+
+
+
+ {dr_lang('鍒犻櫎')}
+
+
+
+
+
+ {dr_lang('楠岃瘉鐮')}
+
+
+
+
+ {dr_lang('鍙戝竷瀹℃牳')}
+
+
+
+
+ {dr_lang('淇敼瀹℃牳')}
+
+
+
+
+
+
+ {if dr_is_app('explog')}
+
+ {/if}
+ {if dr_is_app('scorelog')}
+
+ {/if}
+
+
+
+
+ {loop $diy.form $d}
+
+ {php $dfile=$d.file;}
+ {load "$dfile"}
+
+ {/loop}
+
+
+
+ {if $is_ajax_edit}
+
+
+{/if}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/member_auth_mform.html b/dayrui/App/Member/Views/member_auth_mform.html
new file mode 100644
index 0000000..8fbb243
--- /dev/null
+++ b/dayrui/App/Member/Views/member_auth_mform.html
@@ -0,0 +1,109 @@
+{if $is_ajax_edit}
+{template "header.html"}
+
+
+
+ {dr_form_hidden()}
+ {/if}
+
+
+
+ {dr_lang('璁块棶')}
+
+
+
+
+ {dr_lang('鍙戝竷')}
+
+
+
+
+
+ {dr_lang('淇敼')}
+
+
+
+
+ {dr_lang('鍒犻櫎')}
+
+
+
+
+
+ {dr_lang('楠岃瘉鐮')}
+
+
+
+
+ {dr_lang('鍙戝竷瀹℃牳')}
+
+
+
+
+ {dr_lang('淇敼瀹℃牳')}
+
+
+
+
+
+ {if dr_is_app('explog')}
+
+ {/if}
+ {if dr_is_app('scorelog')}
+
+ {/if}
+
+
+
+ {loop $diy.mform $d}
+
+ {php $dfile=$d.file;}
+ {load "$dfile"}
+
+ {/loop}
+
+
+ {if $is_ajax_edit}
+
+
+{/if}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/member_auth_setting.html b/dayrui/App/Member/Views/member_auth_setting.html
new file mode 100644
index 0000000..16f68f2
--- /dev/null
+++ b/dayrui/App/Member/Views/member_auth_setting.html
@@ -0,0 +1,49 @@
+{template "header.html"}
+
+
+
+ {dr_form_hidden(['page' => $page])}
+
+
+
+
+
+
+ {if $diy.app}
+ {loop $diy.app $d}
+
+ {php $dfile=$d.file;}
+ {load "$dfile"}
+
+ {/loop}
+ {else}
+
{dr_lang('鏆傛棤搴旂敤鎻掍欢鏉冮檺椤癸紝鐢ㄦ埛鏉冮檺璇疯繑鍥炲垪琛ㄩ〉缁熶竴璁剧疆')}
+ {/if}
+
+
+
+
+
+
+
+
+
+
+{template "footer.html"}
diff --git a/dayrui/App/Member/Views/member_auth_share_category.html b/dayrui/App/Member/Views/member_auth_share_category.html
new file mode 100644
index 0000000..42cd988
--- /dev/null
+++ b/dayrui/App/Member/Views/member_auth_share_category.html
@@ -0,0 +1,103 @@
+{if $is_ajax_edit}
+{template "header.html"}
+
+
+
+ {dr_form_hidden()}
+{/if}
+
+ {dr_lang('璁块棶')}
+
+
+
+
+
+ {dr_lang('鍙戝竷')}
+
+
+
+
+
+ {dr_lang('淇敼')}
+
+
+
+
+ {dr_lang('鍒犻櫎')}
+
+
+
+
+ {dr_lang('楠岃瘉鐮')}
+
+
+
+
+
+
+ {dr_lang('涓嶅鏍')}
+ {loop $verify $v}
+ {dr_lang($v.name)}
+ {/loop}
+
+
+ {if dr_is_app('explog')}
+
+ {/if}
+ {if dr_is_app('scorelog')}
+
+ {/if}
+
+ {if !$is_ajax_edit}
+
+
+ {dr_lang('鎸夋爮鐩')}
+ {dr_lang('鎸夋ā鍧')}
+
+
+ {/if}
+
+
+
+{if $is_ajax_edit}
+
+
+{/if}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/member_avatar.html b/dayrui/App/Member/Views/member_avatar.html
new file mode 100644
index 0000000..e69de29
diff --git a/dayrui/App/Member/Views/member_edit.html b/dayrui/App/Member/Views/member_edit.html
new file mode 100644
index 0000000..87a80ae
--- /dev/null
+++ b/dayrui/App/Member/Views/member_edit.html
@@ -0,0 +1,323 @@
+{template "header.html"}
+
+
{dr_lang('鐢ㄦ埛璇︾粏璧勬枡')}
+
+
+{template "api_list_date_search.html"}
+
+
+ {$form}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {$myfield}
+ {$diyfield}
+
+ {if $field}
+
+ {/if}
+
+
+
+
+
+
+
+
+
+ {loop $oauth $t}
+
+ {/loop}
+
+
+
+
+
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/member_edit_username.html b/dayrui/App/Member/Views/member_edit_username.html
new file mode 100644
index 0000000..9dee4c0
--- /dev/null
+++ b/dayrui/App/Member/Views/member_edit_username.html
@@ -0,0 +1,24 @@
+{template "header.html"}
+
+
+ {$form}
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/member_field.html b/dayrui/App/Member/Views/member_field.html
new file mode 100644
index 0000000..6bc01cb
--- /dev/null
+++ b/dayrui/App/Member/Views/member_field.html
@@ -0,0 +1,109 @@
+{template "header.html"}
+
+{php echo \Phpcmf\Service::L('Field')->get('select')->get_select_search_code();}
+
+
+
+
+
+ {dr_form_hidden()}
+ {if $ci->_is_admin_auth('add')}
+
+
+ {dr_lang('鎵归噺鍒掑垎')}
+
+
+ {loop $group $t}
+ {dr_lang($t.name)}
+ {/loop}
+
+
+
+
+ {/if}
+
+
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/member_group.html b/dayrui/App/Member/Views/member_group.html
new file mode 100644
index 0000000..b0749cf
--- /dev/null
+++ b/dayrui/App/Member/Views/member_group.html
@@ -0,0 +1,157 @@
+{template "header.html"}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {$form}
+
+
+
+ --
+ {loop $group $t}
+ {dr_lang($t.name)}
+ {/loop}
+
+
+ {dr_lang('娣诲姞鐢ㄦ埛缁')}
+
+
+
+ {$form}
+
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/member_group_list.html b/dayrui/App/Member/Views/member_group_list.html
new file mode 100644
index 0000000..1005cfc
--- /dev/null
+++ b/dayrui/App/Member/Views/member_group_list.html
@@ -0,0 +1,84 @@
+{template "header.html"}
+
+
+
+
+
+ {dr_form_hidden()}
+ {if $ci->_is_admin_auth('del')}
+
+
+ {dr_lang('鍒犻櫎')}
+
+
+
+ {/if}
+
+
+
+ {if $mypages}
+
+ {/if}
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/member_group_post.html b/dayrui/App/Member/Views/member_group_post.html
new file mode 100644
index 0000000..c505336
--- /dev/null
+++ b/dayrui/App/Member/Views/member_group_post.html
@@ -0,0 +1,272 @@
+{template "header.html"}
+
+
+ {$form}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/member_level_list.html b/dayrui/App/Member/Views/member_level_list.html
new file mode 100644
index 0000000..0cdb70f
--- /dev/null
+++ b/dayrui/App/Member/Views/member_level_list.html
@@ -0,0 +1,80 @@
+{template "header.html"}
+
+
+
+
+
+
+ {dr_form_hidden()}
+ {if $ci->_is_admin_auth('del')}
+
+
+ {dr_lang('鍒犻櫎')}
+
+
+
+ {/if}
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/member_level_post.html b/dayrui/App/Member/Views/member_level_post.html
new file mode 100644
index 0000000..0d6ddc0
--- /dev/null
+++ b/dayrui/App/Member/Views/member_level_post.html
@@ -0,0 +1,92 @@
+{template "header.html"}
+
+
+ {$form}
+
+
+
+
+ {dr_lang('绛夌骇鍒跺害')}
+
+
+
+
+
+
+
+
+ {$myfield}
+
+ {if $group.setting.timetype && !$group['setting']['level']['auto']}
+
+
+ {/if}
+
+
+
+
+
+
+
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/member_list.html b/dayrui/App/Member/Views/member_list.html
new file mode 100644
index 0000000..9fce6ec
--- /dev/null
+++ b/dayrui/App/Member/Views/member_list.html
@@ -0,0 +1,185 @@
+{template "header.html"}
+{php echo \Phpcmf\Service::L('Field')->get('select')->get_select_search_code();}
+
+
+
+
+
+ {$mytable.foot_tpl}
+
+
+
+ {template "mytable.html"}
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/member_login.html b/dayrui/App/Member/Views/member_login.html
new file mode 100644
index 0000000..18f8300
--- /dev/null
+++ b/dayrui/App/Member/Views/member_login.html
@@ -0,0 +1,31 @@
+{template "header.html"}
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/member_menu_add.html b/dayrui/App/Member/Views/member_menu_add.html
new file mode 100644
index 0000000..e1eb506
--- /dev/null
+++ b/dayrui/App/Member/Views/member_menu_add.html
@@ -0,0 +1,82 @@
+{template "header.html"}
+
+
+ {$form}
+
+ {if $type}
+
+ {/if}
+
+
+
+ {if $type}
+
+
+ {/if}
+
+
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/member_menu_list.html b/dayrui/App/Member/Views/member_menu_list.html
new file mode 100644
index 0000000..55fc1d6
--- /dev/null
+++ b/dayrui/App/Member/Views/member_menu_list.html
@@ -0,0 +1,239 @@
+{template "header.html"}
+
+{php echo \Phpcmf\Service::L('Field')->get('select')->get_select_search_code();}
+
+
+ {dr_form_hidden()}
+
+
+
+ {if $ci->_is_admin_auth('edit')}
+
+
+ {loop $group $t}
+ {dr_lang($t.name)}
+ {/loop}
+
+ {dr_lang('鎵归噺鍒掑垎鐢ㄦ埛缁勫彲瑙佹潈闄')}
+
+
+
+
+ {loop $client $i $t}
+ {dr_lang($t)}
+ {/loop}
+
+ {dr_lang('鎵归噺鍒掑垎缁堢鍙鏉冮檺')}
+
+
+ {if dr_count($ci->site_info) > 1}
+
+
+ {loop $ci->site_info $t}
+ {$t.SITE_NAME}
+ {/loop}
+
+ {dr_lang('鎵归噺鍒掑垎绔欑偣鍙鏉冮檺')}
+
+ {/if}
+ {/if}
+
+
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/member_oauth.html b/dayrui/App/Member/Views/member_oauth.html
new file mode 100644
index 0000000..6184509
--- /dev/null
+++ b/dayrui/App/Member/Views/member_oauth.html
@@ -0,0 +1,98 @@
+{template "header.html"}
+
+
+
+
+
+ {dr_form_hidden()}
+ {if $ci->_is_admin_auth('del')}
+
+
+ {dr_lang('鍒犻櫎')}
+
+
+
+ {/if}
+
+
+ {if $mypages}
+
+ {/if}
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/member_setting.html b/dayrui/App/Member/Views/member_setting.html
new file mode 100644
index 0000000..ffd3866
--- /dev/null
+++ b/dayrui/App/Member/Views/member_setting.html
@@ -0,0 +1,596 @@
+{template "header.html"}
+
+
+
+
+
+
+
+
+ {$form}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {if ($data['register']['sms'] || $data['register']['email']) && !SYS_SMS_IMG_CODE}
+
+ {else}
+
+ {/if}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/member_setting_notice.html b/dayrui/App/Member/Views/member_setting_notice.html
new file mode 100644
index 0000000..5566d03
--- /dev/null
+++ b/dayrui/App/Member/Views/member_setting_notice.html
@@ -0,0 +1,196 @@
+{template "header.html"}
+
+
+
+ {dr_form_hidden()}
+
+
+
+
+
+ {dr_lang('閫氱煡璁剧疆')}
+
+
+
+
+
+
+
+
+ {php $dr_notice_n = 0;}
+ {loop $notice_config $ni $t}
+
+
+
{$t.name}
+ {php echo dr_count($t['value']);} {dr_lang('椤')}
+
+
+
+
+ {loop $t.value $name $v}
+
+ {/loop}
+
+ {php $dr_notice_n++;}
+ {/loop}
+
+
+
+
+
+
+
+
+
+
+{template "footer.html"}
diff --git a/dayrui/App/Member/Views/member_setting_notice_edit.html b/dayrui/App/Member/Views/member_setting_notice_edit.html
new file mode 100644
index 0000000..8e6ffa7
--- /dev/null
+++ b/dayrui/App/Member/Views/member_setting_notice_edit.html
@@ -0,0 +1,75 @@
+{template "header.html"}
+
+{if !IS_DEV}
+
+
+
+
+
+{/if}
+
+
+ {dr_form_hidden()}
+
+
+
+ {loop $list $sid $t}
+
+ {$t.name}
+
+ {/loop}
+
+
+
+
+
+ {loop $list $sid $t}
+
+
+
+ {loop $t.data $id $m}
+
+
+ {if !IS_DEV}
+ {/if}
+ {/loop}
+
+
+
+
+ {/loop}
+
+
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/verify_add.html b/dayrui/App/Member/Views/verify_add.html
new file mode 100644
index 0000000..1f35a26
--- /dev/null
+++ b/dayrui/App/Member/Views/verify_add.html
@@ -0,0 +1,111 @@
+{template "header.html"}
+
+
+
+ {$form}
+
+
+
+
+ {dr_lang('瀹℃牳娴佺▼')}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {php echo \Phpcmf\Service::L('Field')->get('select')->get_select_search_code();}
+ {php for($i = 1; $i < 9; $i++) { }
+
+ {php } }
+
+
+
+
+
+
+
+
+ {dr_lang('淇濆瓨鍐呭')}
+ {dr_lang('淇濆瓨鍐嶆坊鍔')}
+ {dr_lang('淇濆瓨骞惰繑鍥')}
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/verify_index.html b/dayrui/App/Member/Views/verify_index.html
new file mode 100644
index 0000000..e3b3249
--- /dev/null
+++ b/dayrui/App/Member/Views/verify_index.html
@@ -0,0 +1,72 @@
+{template "header.html"}
+
+
+
+
+ {dr_form_hidden()}
+ {if $ci->_is_admin_auth('del')}
+
+
+ {dr_lang('鍒犻櫎')}
+
+
+
+ {/if}
+
+
+
+ {if $mypages}
+
+ {/if}
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Member/Views/verify_show.html b/dayrui/App/Member/Views/verify_show.html
new file mode 100644
index 0000000..18a8b9f
--- /dev/null
+++ b/dayrui/App/Member/Views/verify_show.html
@@ -0,0 +1,25 @@
+{template "header.html"}
+
+
+
+ {loop $value.role $i $rid}
+
+
+ {dr_lang('绗%s娆″鏍', $i)} {$ns}
+ {/loop}
+ {dr_lang('绗%s娆″鏍', $i+1)} {dr_lang('瀹℃牳瀹屾垚')}
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Mform/Action/Mform.php b/dayrui/App/Mform/Action/Mform.php
new file mode 100644
index 0000000..d48c352
--- /dev/null
+++ b/dayrui/App/Mform/Action/Mform.php
@@ -0,0 +1,147 @@
+get('module-'.$system['site'].'-'.$dirname);
+// 鍒ゆ柇鏄惁瀛樺湪
+if (!isset($module['form'][$mid]) || !$module['form'][$mid]) {
+ return $this->_return($system['return'], "妯″潡{$dirname}琛ㄥ崟({$mid})涓嶅瓨鍦"); // 鍙傛暟鍒ゆ柇
+}
+
+$form = $module['form'][$mid];
+$tableinfo = \Phpcmf\Service::L('cache')->get('table-'.$system['site']);
+if (!$tableinfo) {
+ // 娌℃湁琛ㄧ粨鏋勭紦瀛樻椂杩斿洖绌
+ return $this->_return($system['return'], '琛ㄧ粨鏋勭紦瀛樹笉瀛樺湪');
+}
+
+if (isset($param['cid']) && $param['cid']) {
+ $table = \Phpcmf\Service::M()->dbprefix(dr_mform_ctable($dirname, $form['table'], $param['cid'], $system['site'])); // 妯″潡涓昏〃
+} else {
+ $table = \Phpcmf\Service::M()->dbprefix(dr_mform_table_prefix($dirname, $form['table'], $system['site'])); // 妯″潡涓昏〃
+}
+
+if (!isset($tableinfo[$table])) {
+ return $this->_return($system['return'], '琛紙'.$table.'锛夌粨鏋勭紦瀛樹笉瀛樺湪');
+}
+
+// 榛樿鏉′欢
+$where[] = array(
+ 'adj' => '',
+ 'name' => 'status',
+ 'value' => 1
+);
+
+// 鏄惁鎿嶄綔鑷畾涔墂here
+if ($param['where']) {
+ $where[] = [
+ 'adj' => 'SQL',
+ 'value' => urldecode($param['where'])
+ ];
+ unset($param['where']);
+}
+
+if ($system['catid']) {
+ $fwhere = [];
+ if (strpos($system['catid'], ',') !== FALSE) {
+ $temp = explode(',', $system['catid']);
+ if ($temp) {
+ $catids = [];
+ foreach ($temp as $i) {
+ $cat = dr_cat_value($system['site'], $module['mid'], $i);
+ $catids = $cat['child'] ? array_merge($catids, $cat['catids']) : array_merge($catids, array($i));
+ }
+ $catids && $fwhere[] = '`'.$table.'`.`catid` IN ('.implode(',', $catids).')';
+ }
+ unset($temp);
+ } else {
+ $cat = dr_cat_value($system['site'], $module['mid'], $system['catid']);
+ if ($cat['child']) {
+ $catids = explode(',', $cat['childids']);
+ $fwhere[] = '`'.$table.'`.`catid` IN ('.$cat['childids'].')';
+ } else {
+ $fwhere[] = '`'.$table.'`.`catid` = '.(int)$system['catid'];
+ $catids = [$system['catid']];
+ }
+ }
+
+ $fwhere && $where[] = [
+ 'adj' => 'SQL',
+ 'value' => urldecode(count($fwhere) == 1 ? $fwhere[0] : '('.implode(' OR ', $fwhere).')')
+ ];
+ unset($fwhere);
+ unset($catids);
+}
+
+$fields = $form['fields'];
+$system['order'] = !$system['order'] ? 'inputtime_desc' : $system['order']; // 榛樿鎺掑簭鍙傛暟
+
+$where = $this->_set_where_field_prefix($where, $tableinfo[$table], $table, $fields); // 缁欐潯浠跺瓧娈靛姞涓婅〃鍓嶇紑
+$system['field'] = $this->_set_select_field_prefix($system['field'], $tableinfo[$table], $table); // 缁欐樉绀哄瓧娈靛姞涓婅〃鍓嶇紑
+$system['order'] = $this->_set_order_field_prefix($system['order'], $tableinfo[$table], $table); // 缁欐帓搴忓瓧娈靛姞涓婅〃鍓嶇紑
+
+// 澶氳〃缁勫悎鎺掑簭
+$_order = [];
+$_order[$table] = $tableinfo[$table];
+
+$sql_from = $table; // sql鐨刦rom瀛愬彞
+// 鍏宠仈琛
+if ($system['join'] && $system['on']) {
+ $rt = $this->_join_table($table, $system, $where, $_order, $sql_from);
+ if (!$rt['code']) {
+ return $this->_return($system['return'], $rt['msg']);
+ }
+ list($system, $where, $_order, $sql_from) = $rt['data'];
+}
+
+$total = 0;
+$fields = $form['field']; // 涓昏〃鐨勫瓧娈
+$sql_where = $this->_get_where($where); // sql鐨剋here瀛愬彞
+$sql_limit = $pages = '';
+
+// 缁熻鏍囩
+if ($this->_return_sql) {
+ $sql = "SELECT _XUNRUICMS_RT_ FROM $sql_from ".($sql_where ? "WHERE $sql_where" : "")." ORDER BY NULL";
+} else {
+ if ($system['page']) {
+ $page = $this->_get_page_id($system['page']);
+ $pagesize = (int)$system['pagesize'];
+ $pagesize = $pagesize ? $pagesize : 10;
+ $sql = "SELECT count(*) as c FROM $sql_from " . ($sql_where ? "WHERE $sql_where" : "") . " ORDER BY NULL";
+ $row = $this->_query($sql, $system, FALSE);
+ $total = (int)$row['c'];
+ // 娌℃湁鏁版嵁鏃惰繑鍥炵┖
+ if (!$total) {
+ return $this->_return($system['return'], '娌℃湁鏌ヨ鍒板唴瀹', $sql, 0);
+ }
+ $sql_limit = 'LIMIT ' . $pagesize * ($page - 1) . ',' . $pagesize;
+ $pages = $this->_get_pagination($system['urlrule'], $pagesize, $total, $system['pagefile']);
+ } elseif ($system['num']) {
+ $sql_limit = "LIMIT {$system['num']}";
+ }
+ $system['order'] = $this->_set_orders_field_prefix($system['order'], $_order); // 缁欐帓搴忓瓧娈靛姞涓婅〃鍓嶇紑
+ $sql = "SELECT " . $this->_get_select_field($system['field'] ? $system['field'] : "*") . " FROM $sql_from " . ($sql_where ? "WHERE $sql_where" : "") . " " . ($system['order'] ? "ORDER BY {$system['order']}" : "") . " $sql_limit";
+}
+
+$data = $this->_query($sql, $system);
+
+if (is_array($data) && $data) {
+ // 琛ㄧ殑绯荤粺瀛楁
+ $fields['inputtime'] = array('fieldtype' => 'Date');
+ $dfield = \Phpcmf\Service::L('Field')->app($dirname);
+ foreach ($data as $i => $t) {
+ $data[$i] = $dfield->format_value($fields, $t, 1);
+ }
+
+ // 瀛樺偍缂撳瓨
+ $system['cache'] && $this->_save_cache_data($cache_name, [
+ 'data' => $data,
+ 'sql' => $sql,
+ 'total' => $total,
+ 'pages' => $pages,
+ 'pagesize' => $pagesize,
+ 'page_used' => $this->_page_used,
+ 'page_urlrule' => $this->_page_urlrule,
+ ], $system['cache']);
+}
+
+return $this->_return($system['return'], $data, $sql, $total, $pages, $pagesize);
\ No newline at end of file
diff --git a/dayrui/App/Mform/Code/$NAME$.php b/dayrui/App/Mform/Code/$NAME$.php
new file mode 100644
index 0000000..47702c3
--- /dev/null
+++ b/dayrui/App/Mform/Code/$NAME$.php
@@ -0,0 +1,21 @@
+_Home_List();
+ }
+
+ public function show() {
+ $this->_Home_Show();
+ }
+
+ public function post() {
+ $this->_Home_Post();
+ }
+}
diff --git a/dayrui/App/Mform/Code/Admin$NAME$.php b/dayrui/App/Mform/Code/Admin$NAME$.php
new file mode 100644
index 0000000..a28fc9f
--- /dev/null
+++ b/dayrui/App/Mform/Code/Admin$NAME$.php
@@ -0,0 +1,33 @@
+_Admin_List();
+ }
+
+ public function add() {
+ $this->_Admin_Add();
+ }
+
+ public function edit() {
+ $this->_Admin_Edit();
+ }
+
+ public function show_index() {
+ $this->_Admin_Show();
+ }
+
+ public function order_edit() {
+ $this->_Admin_Order();
+ }
+
+ public function del() {
+ $this->_Admin_Del();
+ }
+}
diff --git a/dayrui/App/Mform/Code/Admin$NAME$_verify.php b/dayrui/App/Mform/Code/Admin$NAME$_verify.php
new file mode 100644
index 0000000..2032863
--- /dev/null
+++ b/dayrui/App/Mform/Code/Admin$NAME$_verify.php
@@ -0,0 +1,33 @@
+_Admin_List();
+ }
+
+ public function edit() {
+ $this->_Admin_Edit();
+ }
+
+ public function show_index() {
+ $this->_Admin_Show();
+ }
+
+ public function order_edit() {
+ $this->_Admin_Order();
+ }
+
+ public function del() {
+ $this->_Admin_Del();
+ }
+
+ public function status_index() {
+ $this->_Admin_Status();
+ }
+}
diff --git a/dayrui/App/Mform/Code/Member$NAME$.php b/dayrui/App/Mform/Code/Member$NAME$.php
new file mode 100644
index 0000000..2ba1d7d
--- /dev/null
+++ b/dayrui/App/Mform/Code/Member$NAME$.php
@@ -0,0 +1,29 @@
+_Member_List();
+ }
+
+ public function add() {
+ $this->_Member_Add();
+ }
+
+ public function edit() {
+ $this->_Member_Edit();
+ }
+
+ public function order_edit() {
+ $this->_Member_Order();
+ }
+
+ public function del() {
+ $this->_Member_Del();
+ }
+}
diff --git a/dayrui/App/Mform/Config/App.php b/dayrui/App/Mform/Config/App.php
new file mode 100644
index 0000000..c39ffda
--- /dev/null
+++ b/dayrui/App/Mform/Config/App.php
@@ -0,0 +1,11 @@
+ 'app',
+ 'name' => '妯″潡鍐呭琛ㄥ崟',
+ 'author' => '杩呯澘浜戣蒋浠',
+ 'icon' => 'fa fa-table',
+ 'uri' => 'mform/module/index'
+
+];
\ No newline at end of file
diff --git a/dayrui/App/Mform/Config/Auto.php b/dayrui/App/Mform/Config/Auto.php
new file mode 100644
index 0000000..62f43b6
--- /dev/null
+++ b/dayrui/App/Mform/Config/Auto.php
@@ -0,0 +1,27 @@
+ [
+
+
+ ],
+
+ /**
+ * 绫诲悕鏄犲皠鍏崇郴
+ */
+ 'classmap' => [
+
+ 'Phpcmf\Admin\Mform' => dr_get_app_dir('mform').'Control/Admin/Mform.php',
+ 'Phpcmf\Member\Mform' => dr_get_app_dir('mform').'Control/Member/Mform.php',
+ 'Phpcmf\Home\Mform' => dr_get_app_dir('mform').'Control/Home/Mform.php',
+
+ ],
+
+
+];
\ No newline at end of file
diff --git a/dayrui/App/Mform/Config/Before.php b/dayrui/App/Mform/Config/Before.php
new file mode 100644
index 0000000..fcf7b3f
--- /dev/null
+++ b/dayrui/App/Mform/Config/Before.php
@@ -0,0 +1,7 @@
+ '.dr_lang('寰呭鏍').' ';
+ } elseif ($value == 1) {
+ //宸查氳繃
+ return '
'.dr_lang('宸查氳繃').' ';
+ } else {
+ //鏈氳繃
+ return '
'.dr_lang('鏈氳繃').' ';
+ }
+ }
+}
+
+if (!function_exists('dr_mform_ctable')) {
+ function dr_mform_ctable($mid, $tid, $cid, $siteid = SITE_ID) {
+
+ return ($siteid ? $siteid.'_' : '').$mid.'_form_'.$tid;
+
+ if ($cid && $tid && $mid) {
+ $tableid = substr($cid, -1, 1);
+ return ($siteid ? $siteid.'_' : '').$mid.'_form_'.$tid.'_'.($tableid ? $tableid : 0);
+ }
+
+ return ($siteid ? $siteid.'_' : '').$mid.'_form_'.$tid;
+ }
+}
\ No newline at end of file
diff --git a/dayrui/App/Mform/Config/Init.php b/dayrui/App/Mform/Config/Init.php
new file mode 100644
index 0000000..a4abe2d
--- /dev/null
+++ b/dayrui/App/Mform/Config/Init.php
@@ -0,0 +1,2 @@
+install_schema([
+ 'tables' => [
+ 'module_form' => [
+ 'comment' => '妯″潡琛ㄥ崟琛',
+ 'fields' => [
+ 'id' => 'smallint(5) unsigned NOT NULL AUTO_INCREMENT',
+ 'name' => 'varchar(50) NOT NULL COMMENT \'琛ㄥ崟鍚嶇О\'',
+ 'table' => 'varchar(50) NOT NULL COMMENT \'琛ㄥ崟琛ㄥ悕绉癨'',
+ 'module' => 'varchar(50) NOT NULL COMMENT \'妯″潡鐩綍\'',
+ 'disabled' => 'tinyint(1) unsigned NOT NULL COMMENT \'鏄惁绂佺敤\'',
+ 'setting' => 'text NOT NULL COMMENT \'琛ㄥ崟閰嶇疆\'',
+ ],
+ 'indexes' => [
+ 'PRIMARY KEY (`id`)',
+ 'KEY `table` (`table`)',
+ 'KEY `disabled` (`disabled`)',
+ ],
+ ],
+ ],
+ 'seeds' => [],
+]);
+if (empty($rt['code'])) {
+ log_message('error', 'Mform install_schema: '.($rt['msg'] ?? ''));
+}
diff --git a/dayrui/App/Mform/Config/Install.sql b/dayrui/App/Mform/Config/Install.sql
new file mode 100644
index 0000000..e69de29
diff --git a/dayrui/App/Mform/Config/Menu.php b/dayrui/App/Mform/Config/Menu.php
new file mode 100644
index 0000000..01778c5
--- /dev/null
+++ b/dayrui/App/Mform/Config/Menu.php
@@ -0,0 +1,30 @@
+ [
+
+ 'config' => [
+
+ 'left' => [
+ 'config-content' => [
+ 'link' => [
+ 'app-mform' => [
+ 'name' => '妯″潡鍐呭琛ㄥ崟',
+ 'icon' => 'fa fa-list-alt',
+ 'uri' => 'mform/module/index',
+ ],
+ ],
+ ],
+ ],
+ ],
+
+ ],
+
+
+];
\ No newline at end of file
diff --git a/dayrui/App/Mform/Config/Notice.php b/dayrui/App/Mform/Config/Notice.php
new file mode 100644
index 0000000..1bcb9d9
--- /dev/null
+++ b/dayrui/App/Mform/Config/Notice.php
@@ -0,0 +1,28 @@
+ 鍔ㄤ綔鍚嶇О
+ *
+ **/
+
+$cfg = [
+
+
+ 'module_form_verify_1' => '[鎵鏈塢瀹℃牳鍚庨氱煡琛ㄥ崟浣滆',
+ 'module_form_verify_0' => '[鎵鏈塢琚嫆缁濆悗閫氱煡琛ㄥ崟浣滆',
+
+ 'module_form_verify_2' => '[鎵鏈塢瀹℃牳鍚庨氱煡涓讳綋浣滆',
+ 'module_form_post_2' => '[鎵鏈塢鍓嶅彴鎻愪氦锛堢洿鎺ラ氳繃鏃讹級閫氱煡涓讳綋浣滆',
+ 'module_form_post_1' => '[鎵鏈塢鍓嶅彴鎻愪氦锛堢洿鎺ラ氳繃鏃讹級閫氱煡琛ㄥ崟浣滆',
+
+
+];
+
+return $cfg;
\ No newline at end of file
diff --git a/dayrui/App/Mform/Config/Routes.php b/dayrui/App/Mform/Config/Routes.php
new file mode 100644
index 0000000..ef3217b
--- /dev/null
+++ b/dayrui/App/Mform/Config/Routes.php
@@ -0,0 +1,4 @@
+ [
+ 'mform' => 'delete_content',
+ // 妯″瀷鏂囦欢 => 鏂规硶鍚嶇О
+ ],
+];
\ No newline at end of file
diff --git a/dayrui/App/Mform/Config/Uninstall.php b/dayrui/App/Mform/Config/Uninstall.php
new file mode 100644
index 0000000..b3d8ec5
--- /dev/null
+++ b/dayrui/App/Mform/Config/Uninstall.php
@@ -0,0 +1,2 @@
+drop_table(\Phpcmf\Service::M()->dbprefix('module_form'), true);
diff --git a/dayrui/App/Mform/Config/Uninstall.sql b/dayrui/App/Mform/Config/Uninstall.sql
new file mode 100644
index 0000000..e69de29
diff --git a/dayrui/App/Mform/Config/Version.php b/dayrui/App/Mform/Config/Version.php
new file mode 100644
index 0000000..2b8153a
--- /dev/null
+++ b/dayrui/App/Mform/Config/Version.php
@@ -0,0 +1,13 @@
+ '711',
+ 'vip' => '',
+ 'cms' => '4.7.3',
+ 'version' => '1.28',
+ 'license' => '375C71349B295FBE2DCDCA9206F20A1703',
+ 'updatetime' => '2026-06-01 17:45:05',
+ 'downtime' => '2026-08-08 00:54:28',
+
+];
diff --git a/dayrui/App/Mform/Control/Admin/Mform.php b/dayrui/App/Mform/Control/Admin/Mform.php
new file mode 100644
index 0000000..d374d48
--- /dev/null
+++ b/dayrui/App/Mform/Control/Admin/Mform.php
@@ -0,0 +1,479 @@
+_Extend_Init();
+ $this->fix_admin_tpl_path = dr_get_app_dir('mform').'Views/';
+ }
+
+ // 缁ф壙绫诲垵濮嬪寲
+ protected function _Extend_Init() {
+ // 鍒濆鍖栨ā鍧
+ $this->_module_init(APP_DIR);
+ // 鍒ゆ柇鏄惁鏉ヨ嚜瀹℃牳鎺у埗鍣
+ $this->is_verify = strpos(\Phpcmf\Service::L('Router')->class, '_verify') !== false;
+ // 鍒ゆ柇琛ㄥ崟鏄惁鎿嶄綔
+ $this->form = $this->module['form'][str_replace('_verify', '',\Phpcmf\Service::L('Router')->class)];
+ if (!$this->form) {
+ $this->_admin_msg(0, dr_lang('妯″潡琛ㄥ崟銆%s銆戜笉瀛樺湪', str_replace('_verify', '',\Phpcmf\Service::L('Router')->class)));
+ }
+ // 鏀寔闄勮〃瀛樺偍
+ $this->is_data = 1;
+ // 妯℃澘鍓嶇紑(閬垮厤娣锋穯)
+ $this->tpl_prefix = 'share_mform_';
+ // 鍗曠嫭妯℃澘鍛藉悕
+ $this->tpl_name = $this->form['table'];
+ // 妯″潡鏄剧ず鍚嶇О
+ $this->name = dr_lang('鍐呭妯″潡[%s]琛ㄥ崟锛%s锛', APP_DIR, $this->form['name']);
+ // 鑾峰彇鐖剁骇鍐呭
+ $this->url_params['cid'] = $this->cid = intval(\Phpcmf\Service::L('input')->get('cid'));
+ $this->index = $this->cid ? $this->content_model->get_data( $this->cid) : [];
+ // 鑷畾涔夋潯浠
+ $where = $this->is_verify ? 'status<>1' : 'status=1';
+ $this->cid && $where.= ' and cid='. $this->cid;
+ $cwhere = $this->content_model->get_admin_list_where();
+ $cwhere && $where.= ' AND '. $cwhere;
+ $sysfield = ['inputtime', 'inputip', 'displayorder', 'uid', 'status'];
+ if ($this->is_verify) {
+ if (is_array($this->form['setting']['list_field'])) {
+ $this->form['setting']['list_field']['status'] = [
+ 'use' => '1', // 1鏄樉绀猴紝0鏄笉鏄剧ず
+ 'name' => dr_lang('鐘舵'), //鏄剧ず鍚嶇О
+ 'width' => '100', // 鏄剧ず瀹藉害
+ 'func' => 'dr_mform_status_name', // 鍥炶皟鍑芥暟瑙侊細http://help.xunruicms.com/463.html
+ 'center' => '1', // 1鏄眳涓紝0鏄粯璁
+ ];
+ }
+ }
+
+ // 鍒濆鍖栨暟鎹〃
+ $this->_init([
+ 'field' => $this->form['field'],
+ 'table' => SITE_ID.'_'.APP_DIR.'_form_'.$this->form['table'],
+ 'sys_field' => $sysfield,
+ 'date_field' => $this->form['setting']['search_time'] ? $this->form['setting']['search_time'] : 'inputtime',
+ 'show_field' => 'title',
+ 'list_field' => $this->form['setting']['list_field'],
+ 'order_by' => $this->form['setting']['order'] ? dr_safe_replace($this->form['setting']['order']) : 'displayorder DESC,inputtime DESC',
+ 'where_list' => $where,
+ ]);
+
+ // 鍐欏叆妯℃澘
+ \Phpcmf\Service::V()->assign([
+ 'menu' => $this->_get_menu(),
+ 'mform' => $this->form,
+ 'index' => $this->index,
+ 'field' => $this->init['field'],
+ 'form_url' => \Phpcmf\Service::L('Router')->url(APP_DIR.'/'.$this->form['table'].'/index', ['cid' => $this->cid]),
+ 'is_verify' => $this->is_verify,
+ 'form_table' => $this->form['table'],
+ ]);
+
+ if ($this->module['setting']['is_hide_search_bar']) {
+ $this->is_show_search_bar = 0;
+ }
+ }
+
+ protected function _get_menu() {
+ if ($this->is_verify) {
+ if ($this->cid) {
+ $menu = [
+ dr_lang('%s绠$悊', $this->module['name']) => [MOD_DIR.'/home/index', dr_icon($this->module['setting']['icon'])],
+ dr_lang('%s绠$悊', $this->form['name']) => [MOD_DIR.'/'.$this->form['table'].'/index{cid='.$this->cid.'}', dr_icon($this->form['setting']['icon'])],
+ dr_lang('%s瀹℃牳', $this->form['name']) => [MOD_DIR.'/'.$this->form['table'].'_verify/index{cid='.$this->cid.'}', dr_icon($this->form['setting']['icon'])],
+ ];
+ } else {
+ $menu = [
+ dr_lang('%s瀹℃牳', $this->form['name']) => [MOD_DIR.'/'.$this->form['table'].'/index', 'fa fa-edit'],
+ ];
+ }
+ } else {
+ $menu = [
+ dr_lang('%s绠$悊', $this->module['name']) => [MOD_DIR.'/home/index', dr_icon($this->module['setting']['icon'])],
+ dr_lang('%s绠$悊', $this->form['name']) => [MOD_DIR.'/'.$this->form['table'].'/index{cid='.$this->cid.'}', dr_icon($this->form['setting']['icon'])],
+ dr_lang('%s瀹℃牳', $this->form['name']) => [MOD_DIR.'/'.$this->form['table'].'_verify/index{cid='.$this->cid.'}', dr_icon($this->form['setting']['icon'])],
+ ];
+ if ($this->cid && $this->is_add_menu) {
+ $menu[dr_lang('娣诲姞')] = [APP_DIR.'/'.$this->form['table'].'/add{cid='.$this->cid.'}', 'fa fa-plus'];
+ $menu[dr_lang('淇敼')] = ['hide:'.APP_DIR.'/'.$this->form['table'].'/edit', 'fa fa-edit'];
+ }
+ }
+ return \Phpcmf\Service::M('auth')->_admin_menu($menu);
+ }
+
+ // ========================
+
+ // 鍚庡彴鏌ョ湅鍒楄〃
+ protected function _Admin_List() {
+
+ $this->init['table'] = dr_mform_ctable(APP_DIR, $this->form['table'], $this->index['id']);
+ list($tpl) = $this->_List(['cid' => $this->cid]);
+
+ if ($this->_is_admin_auth('edit')) {
+ if ($this->is_verify) {
+ } else {
+ $this->mytable['link_var'].= 'html = html.replace(/\{cid\}/g, "'.$this->index['id'].'");';
+ $this->mytable['link_var'].= 'html = html.replace(/\{mid\}/g, "'.APP_DIR.'");';
+ $this->mytable['link_var'].= 'html = html.replace(/\{fid\}/g, "'.$this->form['table'].'");';
+ $clink = $this->_app_clink('mform');
+ if ($clink) {
+ foreach ($clink as $a) {
+ if ($a['model'] && $a['check']
+ && method_exists($a['model'], $a['check'])
+ && call_user_func(array($a['model'], $a['check']), APP_DIR, []) == 0) {
+ continue;
+ }
+ $this->mytable['link_tpl'].= '
'.dr_lang($a['name']);
+ if ($a['field'] && \Phpcmf\Service::M()->is_field_exists($this->init['table'], $a['field'])) {
+ $this->mytable['link_tpl'].= '锛坽'.$a['field'].'}锛';
+ $this->mytable['link_var'].= 'html = html.replace(/\{'.$a['field'].'\}/g, row.'.$a['field'].');';
+ }
+ $this->mytable['link_tpl'].= '';
+ }
+ }
+
+ $cbottom = $this->_app_cbottom('mform');
+ if ($cbottom) {
+ $this->mytable['foot_tpl'].= '
+
+ ';
+ }
+ }
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'mytable' => $this->mytable,
+ ]);
+
+ \Phpcmf\Service::V()->assign([
+ 'p' => ['cid' => $this->cid],
+ ]);
+ return \Phpcmf\Service::V()->display($tpl);
+ }
+
+ // 鍚庡彴娣诲姞鍐呭
+ protected function _Admin_Add() {
+
+ if (!$this->cid) {
+ $this->_admin_msg(0, dr_lang('缂哄皯cid鍙傛暟'));
+ }
+
+ list($tpl) = $this->_Post(0);
+
+ \Phpcmf\Service::V()->assign([
+ 'form' => dr_form_hidden(),
+ ]);
+ \Phpcmf\Service::V()->display($tpl);
+ }
+
+ // 鍚庡彴淇敼鍐呭
+ protected function _Admin_Edit() {
+
+
+ $id = intval(\Phpcmf\Service::L('input')->get('id'));
+ list($tpl, $data) = $this->_Post($id);
+
+
+ if (!$this->cid) {
+ $this->_admin_msg(0, dr_lang('缂哄皯cid鍙傛暟'));
+ }
+
+ if (!$data) {
+ $this->_admin_msg(0, dr_lang('鏁版嵁涓嶅瓨鍦: '.$id));
+ } elseif ($this->cid != $data['cid']) {
+ $this->_admin_msg(0, dr_lang('cid涓嶅尮閰'));
+ } elseif ($this->is_verify && $data['status'] == 1) {
+ $this->_admin_msg(0, dr_lang('宸茬粡閫氳繃浜嗗鏍'));
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'form' => dr_form_hidden(),
+ ]);
+ \Phpcmf\Service::V()->display($tpl);
+ }
+
+ // 鍚庡彴鏌ョ湅鍐呭
+ protected function _Admin_Show() {
+
+ $id = intval(\Phpcmf\Service::L('input')->get('id'));
+ list($tpl, $data) = $this->_Show($id);
+
+ if (!$this->cid) {
+ $this->_admin_msg(0, dr_lang('缂哄皯cid鍙傛暟'));
+ }
+
+ if (!$data) {
+ $this->_admin_msg(0, dr_lang('鏁版嵁涓嶅瓨鍦: '.$id));
+ } elseif ($this->cid != $data['cid']) {
+ $this->_admin_msg(0, dr_lang('cid涓嶅尮閰'));
+ } elseif ($this->is_verify && $data['status']) {
+ $this->_admin_msg(0, dr_lang('宸茬粡閫氳繃浜嗗鏍'));
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'form' => dr_form_hidden(),
+ ]);
+ \Phpcmf\Service::V()->display($tpl);
+ }
+
+ // 鍚庡彴鎵归噺淇濆瓨鎺掑簭鍊
+ protected function _Admin_Order() {
+ $this->_Display_Order(
+ intval(\Phpcmf\Service::L('input')->get('id')),
+ intval(\Phpcmf\Service::L('input')->get('value')),
+ function ($t) {
+ $table = dr_mform_ctable(APP_DIR, $this->form['table'], $t['cid']);
+ if ($table != $this->init['table']) {
+ // 澶囩敤琛
+ $value = intval(\Phpcmf\Service::L('input')->get('value'));
+ \Phpcmf\Service::M()->table($table)->update($t['id'], ['displayorder' => $value]);
+ }
+ }
+ );
+ }
+
+ // 鍚庡彴鍒犻櫎鍐呭
+ protected function _Admin_Del() {
+ $this->_Del(
+ \Phpcmf\Service::L('input')->get_post_ids(),
+ null,
+ function ($rows) {
+ // 瀵瑰簲鍒犻櫎鎻愰啋
+ foreach ($rows as $t) {
+ \Phpcmf\Service::M('member')->delete_admin_notice(MOD_DIR.'/'.$this->form['table'].'_verify/edit:cid/'.$t['cid'].'/id/'.$t['id'], SITE_ID);// clear
+ \Phpcmf\Service::L('cache')->clear('module_'.MOD_DIR.'_from_'.$this->form['table'].'_show_id_'.$t['id']);
+ // 缁熻鏁伴噺
+ \Phpcmf\Service::M('mform', 'mform')->update_form_total($t['cid'], $this->form['table']);
+ $table = dr_mform_ctable(APP_DIR, $this->form['table'], $t['cid']);
+ if ($table != $this->init['table']) {
+ // 澶囩敤琛
+ \Phpcmf\Service::M()->table($table)->delete($t['id']);
+ }
+ }
+ },
+ \Phpcmf\Service::M()->dbprefix($this->init['table'])
+ );
+ }
+
+ // 鍚庡彴鎵归噺瀹℃牳
+ protected function _Admin_Status() {
+
+ $tid = intval(\Phpcmf\Service::L('input')->get('tid'));
+ $ids = \Phpcmf\Service::L('input')->get_post_ids();
+ if (!$ids) {
+ $this->_json(0, dr_lang('鎵閫夋暟鎹笉瀛樺湪'));
+ }
+
+ // 鏍煎紡鍖
+ $in = [];
+ foreach ($ids as $i) {
+ $i && $in[] = intval($i);
+ }
+ if (!$in) {
+ $this->_json(0, dr_lang('鎵閫夋暟鎹笉瀛樺湪'));
+ }
+
+ $rows = \Phpcmf\Service::M()->db->table($this->init['table'])->whereIn('id', $in)->get()->getResultArray();
+ if (!$rows) {
+ $this->_json(0, dr_lang('鎵閫夋暟鎹笉瀛樺湪'));
+ }
+
+ foreach ($rows as $row) {
+ if ($row['status'] != 1) {
+ if ($tid) {
+ // 鎷掔粷
+ $this->_verify_refuse($row);
+ } else {
+ // 閫氳繃
+ $this->_verify($row);
+ }
+ \Phpcmf\Service::M('mform', 'mform')->update_form_total($row['cid'], $this->form['table']);
+ }
+
+ }
+
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ // ===========================
+
+ /**
+ * 鑾峰彇鍐呭
+ * $id 鍐呭id,鏂板涓0
+ * */
+ protected function _Data($id = 0) {
+
+ $row = $this->content_model->get_form_row($id, $this->form['table']);
+ if (!$row) {
+ return [];
+ }
+
+ $this->cid = $row['cid'];
+ if (!$this->index) {
+ $this->index = $this->content_model->get_data($row['cid']);
+ \Phpcmf\Service::V()->assign([
+ 'menu' => $this->_get_menu(),
+ 'index' => $this->index,
+ ]);
+ }
+
+
+ return $row;
+ }
+
+ // 鏍煎紡鍖栦繚瀛樻暟鎹 淇濆瓨涔嬪墠
+ protected function _Format_Data($id, $data, $old) {
+
+ // 楠岃瘉鐖舵暟鎹
+ if (!$this->index) {
+ $this->_json(0, dr_lang('鍏宠仈鍐呭涓嶅瓨鍦'));
+ }
+
+ // 榛樿鏁版嵁
+ $data[1]['uid'] = intval($data[1]['uid']);
+ $data[0]['uid'] = (int)$data[1]['uid'];
+ $data[1]['cid'] = $data[0]['cid'] = $this->cid;
+ $data[1]['catid'] = $data[0]['catid'] = (int)$this->index['catid'];
+
+ // 鍚庡彴娣诲姞鏃堕粯璁ら氳繃
+ if (!$id) {
+ // !$this->is_verify &&
+ $data[1]['status'] = 1;
+ $data[1]['tableid'] = 0;
+ }
+
+ return $data;
+ }
+
+ /**
+ * 淇濆瓨鍐呭
+ * $id 鍐呭id,鏂板涓0
+ * $data 鎻愪氦鍐呭鏁扮粍,鐣欑┖涓鸿嚜鍔ㄨ幏鍙
+ * $func 鏍煎紡鍖栨彁浜ょ殑鏁版嵁
+ * */
+ protected function _Save($id = 0, $data = [], $old = [], $func = null, $func2 = null) {
+
+ return parent::_Save($id, $data, $old, null,
+ function ($id, $data, $old) {
+ if ($this->is_verify) {
+ if ($data[1]['status'] == 1) {
+ // 瀹℃牳閫氳繃鏃
+ $data[1]['status'] = 0;
+ $this->_verify($data[1]);
+ } elseif ($data[1]['status'] == 2) {
+ $data[1]['status'] = 0;
+ $this->_verify_refuse($data[1]);
+ }
+ }
+ // 淇濆瓨涔嬪悗鐨勬洿鏂皌otal瀛楁
+ \Phpcmf\Service::M('mform', 'mform')->update_form_total( $this->cid, $this->form['table']);
+ \Phpcmf\Service::M('member')->todo_admin_notice(MOD_DIR.'/'.$this->form['table'].'_verify/edit:cid/'.$old['cid'].'/id/'.$old['id'], SITE_ID);
+ // clear
+ \Phpcmf\Service::L('cache')->clear('module_'.MOD_DIR.'_from_'.$this->form['table'].'_show_id_'.$id);
+
+ $table = dr_mform_ctable(APP_DIR, $this->form['table'], $this->index['id']);
+ if ($table != $this->init['table']) {
+ // 澶囩敤琛
+ \Phpcmf\Service::M()->table($table)->replace($data[1]);
+ }
+
+ $row = dr_array2array($data[1], $data[0]);
+ $row['index'] = $this->index;
+ if (!$old) {
+ // 鎸傞挬鐐
+ \Phpcmf\Hooks::trigger('module_form_post_after', $row);
+ } else {
+ \Phpcmf\Hooks::trigger('module_form_edit_after', $row, $old);
+ }
+ }
+ );
+ }
+
+ // 瀹℃牳鎷掔粷
+ protected function _verify_refuse($row) {
+
+ if ($row['status'] == 2) {
+ return;
+ }
+
+ $row['form'] = $this->form;
+ $row['index'] = $this->index;
+ $row['module'] = $this->module;
+ \Phpcmf\Service::M()->db->table($this->init['table'])->where('id', $row['id'])->update(['status' => 2]);
+
+ $table = dr_mform_ctable(APP_DIR, $this->form['table'], $this->index['id']);
+ if ($table != $this->init['table']) {
+ // 澶囩敤琛
+ $value = intval(\Phpcmf\Service::L('input')->get('value'));
+ \Phpcmf\Service::M()->table($table)->update($row['id'], ['status' => 2]);
+ }
+
+ \Phpcmf\Service::M('member')->todo_admin_notice(MOD_DIR.'/'.$this->form['table'].'_verify/edit:cid/'.$row['cid'].'/id/'.$row['id'], SITE_ID);
+ \Phpcmf\Service::L('Notice')->send_notice('module_form_verify_0', $row);
+ }
+
+ // 瀹℃牳閫氳繃
+ protected function _verify($row) {
+
+ if ($row['status'] == 1) {
+ return;
+ }
+
+ /*
+ // 澧炲噺閲戝竵
+ $score = \Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'score', $this->member);
+ $score && \Phpcmf\Service::M('member')->add_score($row['uid'], $score, dr_lang('%s: %s鍙戝竷', MODULE_NAME, $this->form['name']), $row['curl']);
+
+ // 澧炲噺缁忛獙
+ $exp = \Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'exp', $this->member);
+ $exp && \Phpcmf\Service::M('member')->add_experience($row['uid'], $exp, dr_lang('%s: %s鍙戝竷', MODULE_NAME, $this->form['name']), $row['curl']);
+*/
+ \Phpcmf\Service::M('member')->todo_admin_notice(MOD_DIR.'/'.$this->form['table'].'_verify/edit:cid/'.$row['cid'].'/id/'.$row['id'], SITE_ID);
+
+ \Phpcmf\Service::M()->db->table($this->init['table'])->where('id', $row['id'])->update(['status' => 1]);
+
+ $table = dr_mform_ctable(APP_DIR, $this->form['table'], $this->index['id']);
+ if ($table != $this->init['table']) {
+ // 澶囩敤琛
+ $value = intval(\Phpcmf\Service::L('input')->get('value'));
+ \Phpcmf\Service::M()->table($table)->update($row['id'], ['status' => 1]);
+ }
+
+ if (!$this->index) {
+ $this->index = $this->content_model->get_data($row['cid']);
+ }
+
+
+ $row['form'] = $this->form;
+ $row['index'] = $this->index;
+ $row['module'] = $this->module;
+ \Phpcmf\Service::L('Notice')->send_notice('module_form_verify_1', $row);
+
+ $row['muid'] = $row['uid'];
+ $row['uid'] = $this->index['uid'];
+ \Phpcmf\Service::L('Notice')->send_notice('module_form_verify_2', $row);
+ }
+}
diff --git a/dayrui/App/Mform/Control/Home/Mform.php b/dayrui/App/Mform/Control/Home/Mform.php
new file mode 100644
index 0000000..c78d8d1
--- /dev/null
+++ b/dayrui/App/Mform/Control/Home/Mform.php
@@ -0,0 +1,406 @@
+_Extend_Init();
+ }
+
+ // 缁ф壙绫诲垵濮嬪寲
+ protected function _Extend_Init() {
+ // 鍒濆鍖栨ā鍧
+ $this->_module_init(APP_DIR);
+
+ // 鍒ゆ柇琛ㄥ崟鏄惁鎿嶄綔
+ $this->form = $this->module['form'][\Phpcmf\Service::L('Router')->class];
+ if (!$this->form) {
+ $this->_msg(0, dr_lang('妯″潡琛ㄥ崟銆%s銆戜笉瀛樺湪',\Phpcmf\Service::L('Router')->class));
+ }
+
+ // 鏀寔闄勮〃瀛樺偍
+ $this->is_data = 1;
+ // 妯℃澘鍓嶇紑(閬垮厤娣锋穯)
+ $this->tpl_name = $this->form['table'];
+ $this->tpl_prefix = 'mform_';
+ // 棰勭暀cid
+ $this->cid = intval(\Phpcmf\Service::L('input')->get('cid'));
+ \Phpcmf\Service::V()->module(MOD_DIR);
+ }
+
+ // ========================
+
+ // 鍐呭鍒楄〃
+ protected function _Home_List() {
+
+ // 鏃犳潈闄愯闂〃鍗
+ /*
+ if (!\Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'show', $this->member)) {
+ $this->_msg(0, dr_lang('鎮ㄧ殑鐢ㄦ埛缁勬棤鏉冮檺璁块棶琛ㄥ崟'), $this->uid ? '' : dr_member_url('login/index'));
+ return;
+ }*/
+
+ // 鑾峰彇鐖剁骇鍐呭
+ $this->index = $this->_Module_Row($this->cid);
+ if (!$this->index) {
+ $this->_msg(0, dr_lang('妯″潡鍐呭銆恑d#%s銆戜笉瀛樺湪', $this->cid));
+ }
+
+ // 鍒濆鍖栨暟鎹〃
+ $this->_init([
+ 'table' => dr_mform_ctable(APP_DIR, $this->form['table'], $this->index['cid']),
+ 'field' => $this->form['field'],
+ 'show_field' => 'title'
+ ]);
+
+ // 鍐欏叆妯℃澘
+ \Phpcmf\Service::V()->assign([
+ 'form_name' => $this->form['name'],
+ 'form_table' => $this->form['table'],
+ ]);
+
+ // seo
+ \Phpcmf\Service::V()->assign([
+ 'meta_title' => dr_lang($this->form['name']).SITE_SEOJOIN.$this->index['title'],
+ 'meta_keywords' => $this->index['keywords'],
+ 'meta_description' => $this->index['description'],
+ ]);
+
+ \Phpcmf\Service::V()->assign([
+ 'index' => $this->index,
+ 'catid' => intval($this->index['catid']),
+ 'markid' => 'module-'.MOD_DIR.'-'.intval($this->index['catid']),
+ 'urlrule' =>\Phpcmf\Service::L('Router')->mform_list_url($this->form['table'], $this->index['id'], MOD_DIR, '[page]'),
+ ]);
+ \Phpcmf\Service::V()->display($this->_tpl_filename('list'));
+ }
+
+ // 娣诲姞鍐呭
+ protected function _Home_Post() {
+
+ if ($this->form['setting']['is_close_post']) {
+ $this->_msg(0, dr_lang('绂佹鍓嶇鎻愪氦琛ㄥ崟'));
+ }
+
+ // 鏃犳潈闄愯闂〃鍗
+ /*
+ if (!\Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'add', $this->member)) {
+ $this->_msg(0, dr_lang('鎮ㄧ殑鐢ㄦ埛缁勬棤鍙戝竷鏉冮檺'), $this->uid ? '' : dr_member_url('login/index'));
+ return;
+ }*/
+
+ // 鍒ゆ柇浼氬憳鏉冮檺
+ //$this->member && $this->_member_option(0);
+
+ // 鏄惁鏈夐獙璇佺爜
+ $this->is_post_code = $this->form['setting']['is_post_code'] ? 0 : 1;
+
+ // 鑾峰彇鐖剁骇鍐呭
+ $this->index = $this->_Module_Row($this->cid);
+ if (!$this->index) {
+ $this->_msg(0, dr_lang('鎵灞炰富棰樸恈id#%s銆戜笉瀛樺湪', $this->cid));
+ };
+
+
+ // 鍒濆鍖栨暟鎹〃
+ $this->_init([
+ 'table' => dr_mform_ctable(APP_DIR, $this->form['table'], $this->index['cid']),
+ 'field' => $this->form['field'],
+ 'show_field' => 'title'
+ ]);
+ list($tpl) = $this->_Post(0);
+
+ // seo
+ \Phpcmf\Service::V()->assign([
+ 'meta_title' => dr_lang($this->form['name']).SITE_SEOJOIN.$this->index['title'],
+ 'meta_keywords' => $this->index['keywords'],
+ 'meta_description' => $this->index['description'],
+ ]);
+
+ \Phpcmf\Service::V()->assign([
+ 'form' => dr_form_hidden(),
+ 'index' => $this->index,
+ 'catid' => intval($this->index['catid']),
+ 'markid' => 'module-'.MOD_DIR.'-'.intval($this->index['catid']),
+ 'rt_url' => $this->form['setting']['rt_url'] ? '' : dr_now_url(),
+ 'is_post_code' => $this->is_post_code,
+ ]);
+ \Phpcmf\Service::V()->display($tpl);
+ }
+
+ // 鏄剧ず鍐呭
+ protected function _Home_Show() {
+
+ /*
+ if (!\Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'show', $this->member)) {
+ $this->_msg(0, dr_lang('鎮ㄧ殑鐢ㄦ埛缁勬棤鏉冮檺璁块棶琛ㄥ崟'), $this->uid ? '' : dr_member_url('login/index'));
+ return;
+ }*/
+
+ $id = intval(\Phpcmf\Service::L('input')->get('id'));
+ $name = 'module_'.MOD_DIR.'_form_'.$this->form['table'].'_show_id_'.$id;
+ $cache = \Phpcmf\Service::L('cache')->get_data($name);
+ if (!$cache) {
+ // 鍒濆鍖栨暟鎹〃
+ $this->_init([
+ 'table' => dr_mform_ctable(APP_DIR, $this->form['table'], 0),
+ 'field' => $this->form['field'],
+ 'show_field' => 'title'
+ ]);
+ list($tpl, $data) = $this->_Show($id);
+ if (!$data) {
+ $this->_msg(0, dr_lang('琛ㄥ崟鍐呭銆恑d#%s銆戜笉瀛樺湪', $id));
+ }
+ // 鑾峰彇鐖剁骇鍐呭
+ $this->cid = intval($data['cid']);
+ $this->index = $this->_Module_Row($this->cid);
+ if (!$this->index) {
+ $this->_msg(0, dr_lang('妯″潡鍐呭銆恑d#%s銆戜笉瀛樺湪', $this->cid));
+ }
+ // 妯″潡鐨勫鐞
+ $data = $this->_Call_Show($data);
+ $cache = [
+ $tpl,
+ $data,
+ $this->cid,
+ $this->index,
+ ];
+ // 缂撳瓨缁撴灉
+ if ($data['uid'] != $this->uid && SYS_CACHE) {
+ if ($this->member && $this->member['is_admin']) {
+ // 绠$悊鍛樻椂涓嶈繘琛岀紦瀛
+ \Phpcmf\Service::L('cache')->init()->delete($name);
+ } else {
+ \Phpcmf\Service::L('cache')->set_data($name, $cache, SYS_CACHE_SHOW * 3600);
+ }
+ }
+ } else {
+ list($tpl, $data, $this->cid, $this->index) = $cache;
+ }
+
+ // 鏃犳潈闄愯闂〃鍗
+ if ($this->form['setting']['is_read'] && !in_array($this->uid, [$data['uid'], $this->index['uid']])) {
+ $this->_msg(0, dr_lang('鏃犳潈闄愯闂〃鍗'));
+ }
+
+ if ($data['status'] != 1) {
+ $this->_msg(0, dr_lang('鍐呭姝e湪瀹℃牳涓'));
+ }
+
+ $data['cat'] = [];
+ if (isset($data['catid']) && $data['catid']) {
+ $data['cat'] = dr_cat_value($this->module['mid'], $data['catid']);
+ }
+
+ \Phpcmf\Service::V()->assign($data);
+
+ $data['cat'] = [];
+ $data['catname'] = $data['catpname'] = '';
+ if (isset($data['catid']) && $data['catid']) {
+ $data['cat'] = dr_cat_value($this->module['mid'], $data['catid']);
+ $data['catname'] = $data['cat']['name'];
+ $data['catpname'] = dr_get_cat_pname($this->module, $data['catid'], SITE_SEOJOIN);
+ } else {
+
+ }
+
+ $data['formname'] = dr_lang($this->form['name']);
+ $data['modulename'] = $data['modname'] = dr_lang($this->module['name']);
+
+ // seo
+ \Phpcmf\Service::V()->assign(\Phpcmf\Service::L('Seo')->get_seo_value($data, [
+ 'meta_title' => isset($this->form['setting']['seo']['title']) && $this->form['setting']['seo']['title'] ? $this->form['setting']['seo']['title'] : $data['title'].SITE_SEOJOIN.dr_lang($this->form['name']),
+ 'meta_keywords' => isset($this->form['setting']['seo']['keywords']) && $this->form['setting']['seo']['keywords'] ? $this->form['setting']['seo']['keywords'] : $data['title'].SITE_SEOJOIN.dr_lang($this->form['name']),
+ 'meta_description' => isset($this->form['setting']['seo']['description']) && $this->form['setting']['seo']['description'] ? $this->form['setting']['seo']['description'] : $data['title'].SITE_SEOJOIN.dr_lang($this->form['name']),
+ ]));
+
+ \Phpcmf\Service::V()->assign([
+ 'index' => $this->index,
+ 'catid' => intval($this->index['catid']),
+ 'markid' => 'module-'.MOD_DIR.'-'.intval($this->index['catid']),
+ 'urlrule' =>\Phpcmf\Service::L('Router')->mform_show_url($this->form['table'], $this->index['id'], MOD_DIR, '[page]'),
+ ]);
+ \Phpcmf\Service::V()->display($tpl);
+ }
+
+ // ===========================
+
+ /**
+ * 鑾峰彇鍐呭
+ * $id 鍐呭id,鏂板涓0
+ * */
+ /*
+ protected function _Data($id = 0) {
+
+ if (!$id) {
+ return [];
+ }
+
+ $name = 'module_'.MOD_DIR.'_formxx_'.$this->form['table'].'_show_id_'.$id;
+ $data = \Phpcmf\Service::L('cache')->get_data($name);
+ if (!$data) {
+ // 澶勭悊缂撳瓨鏈哄埗
+ $data = $this->content_model->get_form_row($id, $this->form['table']);
+ if (!$data) {
+ return [];
+ }
+ if ($data['uid'] != $this->uid && SYS_CACHE) {
+ if ($this->member && $this->member['is_admin']) {
+ // 绠$悊鍛樻椂涓嶈繘琛岀紦瀛
+ \Phpcmf\Service::L('cache')->init()->delete($name);
+ } else {
+ \Phpcmf\Service::L('cache')->set_data($name, $data, SYS_CACHE_SHOW * 3600);
+ }
+ }
+ }
+
+
+ return $data;
+ }*/
+
+ // 鏍煎紡鍖栦繚瀛樻暟鎹 淇濆瓨涔嬪墠
+ protected function _Format_Data($id, $data, $old) {
+
+ // 楠岃瘉鐖舵暟鎹
+ if (!$this->index) {
+ $this->_json(0, dr_lang('鍏宠仈鍐呭涓嶅瓨鍦'));
+ }
+
+ if ($this->uid) {
+
+ // 鍒ゆ柇鏃ュ彂甯冮噺
+ /*
+ $day_post = \Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'day_post', $this->member);
+ if ($day_post && \Phpcmf\Service::M()->db
+ ->table($this->init['table'])
+ ->where('uid', $this->uid)
+ ->where('DATEDIFF(from_unixtime(inputtime),now())=0')
+ ->countAllResults() >= $day_post) {
+ $this->_json(0, dr_lang('姣忓ぉ鍙戝竷鏁伴噺涓嶈兘瓒呰繃%s涓', $day_post));
+ }
+
+ // 鍒ゆ柇鍙戝竷鎬婚噺
+ $total_post = \Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'total_post', $this->member);
+ if ($total_post && \Phpcmf\Service::M()->db
+ ->table($this->init['table'])
+ ->where('uid', $this->uid)
+ ->countAllResults() >= $total_post) {
+ $this->_json(0, dr_lang('鍙戝竷鏁伴噺涓嶈兘瓒呰繃%s涓', $total_post));
+ }*/
+ }
+
+ // 瀹℃牳鐘舵
+ $data[1]['status'] = $this->form['setting']['is_verify'] ? 1 : 0;
+
+ // 榛樿鏁版嵁
+ $data[0]['uid'] = $data[1]['uid'] = (int)$this->member['uid'];
+ //$data[1]['author'] = $this->member['username'] ? $this->member['username'] : 'guest';
+ $data[1]['cid'] = $data[0]['cid'] = $this->cid;
+ $data[1]['catid'] = $data[0]['catid'] = (int)$this->index['catid'];
+ $data[1]['inputip'] = \Phpcmf\Service::L('input')->ip_info();
+ $data[1]['inputtime'] = SYS_TIME;
+ $data[1]['tableid'] = $data[1]['displayorder'] = 0;
+
+ return $data;
+ }
+
+ /**
+ * 淇濆瓨鍐呭
+ * $id 鍐呭id,鏂板涓0
+ * $data 鎻愪氦鍐呭鏁扮粍,鐣欑┖涓鸿嚜鍔ㄨ幏鍙
+ * $func 鏍煎紡鍖栨彁浜ょ殑鏁版嵁
+ * */
+ protected function _Save($id = 0, $data = [], $old = [], $func = null, $func2 = null) {
+
+ return parent::_Save($id, $data, $old, null,
+ function ($id, $data, $old) {
+ // 淇濆瓨涔嬪悗
+ //瀹℃牳閫氱煡
+ if ($data[1]['status']) {
+ /*
+ // 澧炲噺閲戝竵
+ $score = \Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'score', $this->member);
+ $score && \Phpcmf\Service::M('member')->add_score($this->member['uid'], $score, dr_lang('%s[%s]: %s鍙戝竷', MODULE_NAME, $this->index['title'], $this->form['name']), $this->index['curl']);
+ // 澧炲噺缁忛獙
+ $exp = \Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'exp', $this->member);
+ $exp && \Phpcmf\Service::M('member')->add_experience($this->member['uid'], $exp, dr_lang('%s[%s]: %s鍙戝竷', MODULE_NAME, $this->index['title'], $this->form['name']), $this->index['curl']);
+ */
+ $row = dr_array2array($data[1], $data[0]);
+ $row['muid'] = $row['uid'];
+ $row['form'] = $this->form;
+ $row['index'] = $this->index;
+ $row['module'] = $this->module;
+ \Phpcmf\Service::L('Notice')->send_notice('module_form_post_1', $row);
+ $row['uid'] = $this->index['uid'];
+ \Phpcmf\Service::L('Notice')->send_notice('module_form_post_2', $row);
+ } else {
+ \Phpcmf\Service::M('member')->admin_notice(SITE_ID, 'content', $this->member, dr_lang('%s[%s]: %s鎻愪氦鍐呭瀹℃牳', MODULE_NAME, $this->index['title'], $this->form['name']), MOD_DIR.'/'.$this->form['table'].'_verify/edit:cid/'. $this->cid.'/id/'.$id);
+ }
+ $table = dr_mform_ctable(APP_DIR, $this->form['table'], $this->index['id']);
+ if ($table != $this->init['table']) {
+ // 澶囩敤琛
+ \Phpcmf\Service::M()->table($table)->replace($data[1]);
+ }
+ //鏇存柊total瀛楁
+ \Phpcmf\Service::M('mform', 'mform')->update_form_total( $this->cid, $this->form['table']);
+ // 鎸傞挬鐐
+ $row = dr_array2array($data[1], $data[0]);
+ $row['index'] = $this->index;
+ \Phpcmf\Hooks::trigger('module_form_post_after', $row);
+ }
+ );
+ }
+
+ // 鎿嶄綔涓诲唴瀹
+ protected function _Module_Row($id) {
+
+ $data = \Phpcmf\Service::L('cache')->get_data('module_'.MOD_DIR.'_show_id_'.$id);
+ if ($data) {
+ return $data;
+ }
+
+ $data = $this->content_model->get_data($id);
+ if (!$data) {
+ return [];
+ }
+
+ // 鏍煎紡鍖栬緭鍑鸿嚜瀹氫箟瀛楁
+ $cat = dr_cat_value($this->module['mid'], $data['catid']);
+ $fields = $cat['field'] ? array_merge($this->module['field'], $cat['field']) : $this->module['field'];
+ $fields['inputtime'] = ['fieldtype' => 'Date'];
+ $fields['updatetime'] = ['fieldtype' => 'Date'];
+
+ $data['url'] = dr_url_prefix($data['url'], MOD_DIR);
+ return \Phpcmf\Service::L('Field')->app(MOD_DIR)->format_value($fields, $data);
+ }
+
+ /**
+ * 鍥炶皟澶勭悊缁撴灉
+ * $data
+ * */
+ protected function _Call_Post($data) {
+
+ $data['url'] = $this->form['setting']['rt_url'] ? str_replace(['{id}', '{cid}'], [$data[1]['id'], $data[1]['cid']], $this->form['setting']['rt_url']) : '';
+ if ($data[1]['status']) {
+ return dr_return_data($data[1]['id'], dr_lang($this->form['setting']['rt_text'] ? $this->form['setting']['rt_text'] : '鎿嶄綔鎴愬姛'), $data);
+ } else {
+ return dr_return_data($data[1]['id'], dr_lang($this->form['setting']['rt_text2'] ? $this->form['setting']['rt_text2'] : '鎿嶄綔鎴愬姛锛岀瓑寰呯鐞嗗憳瀹℃牳'), $data);
+ }
+ }
+
+ // 鍓嶇鍥炶皟澶勭悊绫
+ protected function _Call_Show($data) {
+ return $data;
+ }
+}
diff --git a/dayrui/App/Mform/Control/Member/Mform.php b/dayrui/App/Mform/Control/Member/Mform.php
new file mode 100644
index 0000000..9aa4a77
--- /dev/null
+++ b/dayrui/App/Mform/Control/Member/Mform.php
@@ -0,0 +1,333 @@
+_Extend_Init();
+ }
+
+ // 缁ф壙绫诲垵濮嬪寲
+ protected function _Extend_Init() {
+ // 鍒濆鍖栨ā鍧
+ $this->_module_init(APP_DIR);
+ // 鍒ゆ柇琛ㄥ崟鏄惁鎿嶄綔
+ $this->form = $this->module['form'][\Phpcmf\Service::L('Router')->class];
+ if (!$this->form) {
+ $this->_msg(0, dr_lang('妯″潡琛ㄥ崟銆%s銆戜笉瀛樺湪', \Phpcmf\Service::L('Router')->class));
+ } elseif (!$this->form['setting']['is_member']) {
+ $this->_msg(0, dr_lang('妯″潡琛ㄥ崟銆%s銆戞病鏈夊紑鍚鐞嗗唴瀹瑰姛鑳', \Phpcmf\Service::L('Router')->class));
+ }
+ // 鏀寔闄勮〃瀛樺偍
+ $this->is_data = 1;
+ // 妯℃澘鍓嶇紑(閬垮厤娣锋穯)
+ $this->tpl_prefix = 'mform_';
+ // 鍗曠嫭妯℃澘鍛藉悕
+ $this->tpl_name = $this->form['table'];
+ // 妯″潡鏄剧ず鍚嶇О
+ $this->name = dr_lang('鍐呭妯″潡[%s]琛ㄥ崟锛%s锛', APP_DIR, $this->form['name']);
+ // 鑾峰彇鐖剁骇鍐呭
+ $this->url_params['cid'] = $this->cid = intval(\Phpcmf\Service::L('input')->get('cid'));
+ if ($this->cid) {
+ $this->index = $this->content_model->get_data($this->cid);
+ } else {
+ //$this->_msg(0, dr_lang('妯″潡琛ㄥ崟銆%s銆戞病鏈塩id鍙傛暟', $this->form['name']));
+ }
+
+ // 鍒濆鍖栨暟鎹〃
+ $this->_init([
+ 'field' => $this->form['field'],
+ 'table' => dr_mform_ctable(APP_DIR, $this->form['table'], $this->cid),
+ 'date_field' => 'inputtime',
+ 'show_field' => 'title',
+ 'list_field' => $this->form['setting']['list_field'],
+ 'order_by' => 'displayorder DESC,inputtime DESC',
+ 'where_list' => $this->cid ? 'cid='. $this->cid : ($this->form['setting']['is_member_user'] ? ' cid in (select id from '.
+ \Phpcmf\Service::M()->dbprefix(SITE_ID.'_'.APP_DIR.'_index').' where uid='.$this->uid.')' : 'uid='.$this->uid), // 鑷畾涔夋潯浠讹紝鏄剧ず鏈唴瀹圭殑琛ㄥ崟
+ ]);
+ $this->edit_where = $this->delete_where = $this->cid ? 'cid='. $this->cid : 'uid='.$this->uid;
+ // 鏄惁鏈夐獙璇佺爜
+ $this->is_post_code = $this->form['setting']['is_post_code'] ? 0 : 1;
+
+ // 鍐欏叆妯℃澘
+ \Phpcmf\Service::V()->assign([
+ 'mform' => $this->form,
+ 'index' => $this->index,
+ 'field' => $this->init['field'],
+ 'form_url' => dr_member_url(APP_DIR.'/'.$this->form['table'].'/index', ['cid' => $this->cid]),
+ 'is_verify' => $this->is_verify,
+ 'is_post_code' => $this->is_post_code,
+ ]);
+ }
+
+ // ========================
+
+ // 鏌ョ湅鍒楄〃
+ protected function _Member_List() {
+
+ if ($this->cid) {
+ if ($this->index) {
+ if (!$this->form['setting']['is_member_user'] && $this->index['uid'] != $this->uid) {
+ $this->_msg(0, dr_lang('妯″潡琛ㄥ崟銆%s銆戠埗鍐呭[%s]涓嶆槸浣犲垱寤', $this->form['name'], $this->cid));
+ }
+ } else {
+ $this->_msg(0, dr_lang('妯″潡琛ㄥ崟銆%s銆戠埗鍐呭[%s]涓嶅瓨鍦', $this->form['name'], $this->cid));
+ }
+ }
+
+ $this->init['table'] = dr_mform_ctable(APP_DIR, $this->form['table'], $this->index['id']);
+ list($tpl) = $this->_List(['cid' => $this->cid]);
+
+ \Phpcmf\Service::V()->assign([
+ 'p' => ['cid' => $this->cid],
+ 'is_delete' => 0,
+ ]);
+ return \Phpcmf\Service::V()->display($tpl);
+ }
+
+ // 娣诲姞鍐呭
+ protected function _Member_Add() {
+
+ /*
+ if (!\Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'add', $this->member)) {
+ $this->_msg(0, dr_lang('鎮ㄧ殑鐢ㄦ埛缁勬棤鍙戝竷鏉冮檺'));
+ }*/
+
+ list($tpl) = $this->_Post(0);
+
+ \Phpcmf\Service::V()->assign([
+ 'form' => dr_form_hidden(),
+ ]);
+ \Phpcmf\Service::V()->display($tpl);
+ }
+
+ // 淇敼鍐呭
+ protected function _Member_Edit() {
+
+ /*
+ if (!\Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'edit', $this->member)) {
+ $this->_msg(0, dr_lang('鎮ㄧ殑鐢ㄦ埛缁勬棤淇敼鏉冮檺'));
+ }*/
+
+ $id = intval(\Phpcmf\Service::L('input')->get('id'));
+ list($tpl, $data) = $this->_Post($id);
+
+ if (!$data) {
+ $this->_msg(0, dr_lang('鏁版嵁涓嶅瓨鍦: '.$id));
+ } elseif ($this->cid != $data['cid']) {
+ $this->_msg(0, dr_lang('鎵灞炰富棰榗id涓嶅尮閰'));
+ }
+ if ($this->form['setting']['is_member_user']) {
+ if (!in_array($this->uid, [$data['uid'], $this->index['uid']])) {
+ $this->_msg(0, dr_lang('鏃犳潈闄愪慨鏀'));
+ }
+ } elseif ($this->uid != $data['uid']) {
+ $this->_msg(0, dr_lang('鏃犳潈闄愪慨鏀'));
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'form' => dr_form_hidden(),
+ ]);
+ \Phpcmf\Service::V()->display($tpl);
+ }
+
+ // 鎵归噺淇濆瓨鎺掑簭鍊
+ protected function _Member_Order() {
+ $this->_Display_Order(
+ intval(\Phpcmf\Service::L('input')->get('id')),
+ intval(\Phpcmf\Service::L('input')->get('value')),
+ function ($t) {
+ $table = dr_mform_ctable(APP_DIR, $this->form['table'], $t['cid']);
+ if ($table != $this->init['table']) {
+ // 澶囩敤琛
+ $value = intval(\Phpcmf\Service::L('input')->get('value'));
+ \Phpcmf\Service::M()->table($table)->update($t['id'], ['displayorder' => $value]);
+ }
+ }
+ );
+ }
+
+ // 鍒犻櫎鍐呭
+ protected function _Member_Del() {
+
+ /*
+ if (!\Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'del', $this->member)) {
+ $this->_msg(0, dr_lang('鎮ㄧ殑鐢ㄦ埛缁勬棤鍒犻櫎鏉冮檺'));
+ }*/
+
+ $this->_Del(
+ \Phpcmf\Service::L('input')->get_post_ids(),
+ null,
+ function ($rows) {
+ // 瀵瑰簲鍒犻櫎鎻愰啋
+ foreach ($rows as $t) {
+ \Phpcmf\Service::M('member')->delete_admin_notice(MOD_DIR.'/'.$this->form['table'].'_verify/edit:cid/'.$t['cid'].'/id/'.$t['id'], SITE_ID);// clear
+ \Phpcmf\Service::L('cache')->clear('module_'.MOD_DIR.'_from_'.$this->form['table'].'_show_id_'.$t['id']);
+ // 缁熻鏁伴噺
+ \Phpcmf\Service::M('mform', 'mform')->update_form_total($t['cid'], $this->form['table']);
+ $table = dr_mform_ctable(APP_DIR, $this->form['table'], $t['cid']);
+ if ($table != $this->init['table']) {
+ // 澶囩敤琛
+ \Phpcmf\Service::M()->table($table)->delete($t['id']);
+ }
+ }
+ },
+ \Phpcmf\Service::M()->dbprefix($this->init['table'])
+ );
+ }
+
+ // ===========================
+
+ /**
+ * 鑾峰彇鍐呭
+ * $id 鍐呭id,鏂板涓0
+ * */
+ protected function _Data($id = 0) {
+
+ $row = $this->content_model->get_form_row($id, $this->form['table']);
+ if (!$row) {
+ return [];
+ }
+
+ return $row;
+ }
+
+ // 鏍煎紡鍖栦繚瀛樻暟鎹 淇濆瓨涔嬪墠
+ protected function _Format_Data($id, $data, $old) {
+
+ if (!$this->cid) {
+ $this->_json(0, dr_lang('鎵灞炰富棰榗id鍙傛暟涓嶈兘涓虹┖'));
+ }
+
+ // 榛樿鏁版嵁
+ $data[0]['uid'] = (int)$data[1]['uid'];
+ $data[1]['cid'] = $data[0]['cid'] = $this->cid;
+ $data[1]['catid'] = $data[0]['catid'] = (int)$this->index['catid'];
+
+ if (!$id) {
+ // 鍙戝竷鏃
+
+ if ($this->uid) {
+ /*
+ // 鍒ゆ柇鏃ュ彂甯冮噺
+ $day_post = \Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'day_post', $this->member);
+ if ($day_post && \Phpcmf\Service::M()->db
+ ->table($this->init['table'])
+ ->where('uid', $this->uid)
+ ->where('DATEDIFF(from_unixtime(inputtime),now())=0')
+ ->countAllResults() >= $day_post) {
+ $this->_json(0, dr_lang('姣忓ぉ鍙戝竷鏁伴噺涓嶈兘瓒呰繃%s涓', $day_post));
+ }
+
+ // 鍒ゆ柇鍙戝竷鎬婚噺
+ $total_post = \Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'total_post', $this->member);
+ if ($total_post && \Phpcmf\Service::M()->db
+ ->table($this->init['table'])
+ ->where('uid', $this->uid)
+ ->countAllResults() >= $total_post) {
+ $this->_json(0, dr_lang('鍙戝竷鏁伴噺涓嶈兘瓒呰繃%s涓', $total_post));
+ }
+ */
+ }
+
+ // 瀹℃牳鐘舵
+ $data[1]['status'] = $this->form['setting']['is_verify'] ? 1 : 0;
+
+ // 榛樿鏁版嵁
+ $data[0]['uid'] = $data[1]['uid'] = (int)$this->member['uid'];
+ //$data[1]['author'] = $this->member['username'] ? $this->member['username'] : 'guest';
+ $data[1]['cid'] = $data[0]['cid'] = $this->cid;
+ $data[1]['catid'] = $data[0]['catid'] = (int)$this->index['catid'];
+ $data[1]['inputip'] = \Phpcmf\Service::L('input')->ip_info();
+ $data[1]['inputtime'] = SYS_TIME;
+ $data[1]['tableid'] = $data[1]['displayorder'] = 0;
+ } else {
+ // 淇敼鏃
+ // 瀹℃牳鐘舵
+ $data[1]['status'] = $this->form['setting']['is_verify'] ? 1 : 0;
+ }
+
+ return $data;
+ }
+
+ /**
+ * 淇濆瓨鍐呭
+ * $id 鍐呭id,鏂板涓0
+ * $data 鎻愪氦鍐呭鏁扮粍,鐣欑┖涓鸿嚜鍔ㄨ幏鍙
+ * $func 鏍煎紡鍖栨彁浜ょ殑鏁版嵁
+ * */
+ protected function _Save($id = 0, $data = [], $old = [], $func = null, $func2 = null) {
+
+ return parent::_Save($id, $data, $old, null,
+ function ($id, $data, $old) {
+ // 淇濆瓨涔嬪悗
+ $member = dr_member_info($data[1]['uid']);
+ //瀹℃牳閫氱煡
+ if ($data[1]['status']) {
+ // 澧炲噺閲戝竵
+ /*
+ $score = \Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'score', $member);
+ $score && \Phpcmf\Service::M('member')->add_score($member['uid'], $score, dr_lang('%s[%s]: %s鍙戝竷', MODULE_NAME, $this->index['title'], $this->form['name']), $this->index['curl']);
+ // 澧炲噺缁忛獙
+ $exp = \Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'exp', $member);
+ $exp && \Phpcmf\Service::M('member')->add_experience($member['uid'], $exp, dr_lang('%s[%s]: %s鍙戝竷', MODULE_NAME, $this->index['title'], $this->form['name']), $this->index['curl']);
+ */
+ $row = dr_array2array($data[1], $data[0]);
+ $row['muid'] = $row['uid'];
+ $row['form'] = $this->form;
+ $row['index'] = $this->index;
+ $row['module'] = $this->module;
+ \Phpcmf\Service::L('Notice')->send_notice('module_form_post_1', $row);
+ $row['uid'] = $this->index['uid'];
+ \Phpcmf\Service::L('Notice')->send_notice('module_form_post_2', $row);
+ } else {
+ \Phpcmf\Service::M('member')->admin_notice(SITE_ID, 'content', $member, dr_lang('%s[%s]: %s鎻愪氦鍐呭瀹℃牳', MODULE_NAME, $this->index['title'], $this->form['name']), MOD_DIR.'/'.$this->form['table'].'_verify/edit:cid/'. $this->cid.'/id/'.$id);
+ }
+ $table = dr_mform_ctable(APP_DIR, $this->form['table'], $this->index['id']);
+ if ($table != $this->init['table']) {
+ // 澶囩敤琛
+ \Phpcmf\Service::M()->table($table)->replace($data[1]);
+ }
+
+ //鏇存柊total瀛楁
+ \Phpcmf\Service::M('mform', 'mform')->update_form_total( $this->cid, $this->form['table']);
+ $row = dr_array2array($data[1], $data[0]);
+ $row['index'] = $this->index;
+ if (!$old) {
+ // 鎸傞挬鐐
+ \Phpcmf\Hooks::trigger('module_form_post_after', $row);
+ } else {
+ \Phpcmf\Hooks::trigger('module_form_edit_after', $row, $old);
+ }
+ }
+ );
+ }
+
+ /**
+ * 鍥炶皟澶勭悊缁撴灉
+ * $data
+ * */
+ protected function _Call_Post($data) {
+
+ $data['url'] = $this->form['setting']['rt_url'] ? str_replace(['{id}', '{cid}'], [$data[1]['id'], $data[1]['cid']], $this->form['setting']['rt_url']) : '';
+ if ($data[1]['status']) {
+ return dr_return_data($data[1]['id'], dr_lang($this->form['setting']['rt_text'] ? $this->form['setting']['rt_text'] : '鎿嶄綔鎴愬姛'), $data);
+ } else {
+ return dr_return_data($data[1]['id'], dr_lang($this->form['setting']['rt_text2'] ? $this->form['setting']['rt_text2'] : '鎿嶄綔鎴愬姛锛岀瓑寰呯鐞嗗憳瀹℃牳'), $data);
+ }
+ }
+
+}
diff --git a/dayrui/App/Mform/Controllers/Admin/Module.php b/dayrui/App/Mform/Controllers/Admin/Module.php
new file mode 100644
index 0000000..3aa4e88
--- /dev/null
+++ b/dayrui/App/Mform/Controllers/Admin/Module.php
@@ -0,0 +1,280 @@
+dir = dr_safe_replace(\Phpcmf\Service::L('input')->get('dir'));
+
+ $menu = [
+ '鍐呭妯″潡' => ['module/module/index', 'fa fa-cogs'],
+ '妯″潡琛ㄥ崟' => ['mform/module/index', 'fa fa-cogs'],
+ ];
+
+ $menu['琛ㄥ崟閰嶇疆'] = ['hide:mform/module/form_edit', 'fa fa-cog'];
+ $menu['閲嶅缓琛ㄥ崟'] = ['ajax:mform/module/form_init_index', 'fa fa-refresh'];
+ $menu['help'] = [98];
+
+ \Phpcmf\Service::V()->assign('menu', \Phpcmf\Service::M('auth')->_admin_menu($menu));
+
+ // 琛ㄥ崟楠岃瘉閰嶇疆
+ $this->form = [
+ 'name' => [
+ 'name' => '琛ㄥ崟鍚嶇О',
+ 'rule' => [
+ 'empty' => dr_lang('琛ㄥ崟鍚嶇О涓嶈兘涓虹┖')
+ ],
+ 'filter' => [],
+ 'length' => '200'
+ ],
+ 'table' => [
+ 'name' => '琛ㄥ崟鍒悕',
+ 'rule' => [
+ 'empty' => dr_lang('琛ㄥ崟鍒悕涓嶈兘涓虹┖'),
+ 'table' => dr_lang('琛ㄥ崟鍒悕鏍煎紡涓嶆纭'),
+ ],
+ 'filter' => [],
+ 'length' => '200'
+ ],
+ ];
+ }
+
+ // 妯″潡绠$悊
+ public function index() {
+
+ $module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content');
+ if (!$module) {
+ $this->_admin_msg(0, dr_lang('鏈畨瑁呬换浣曞唴瀹规ā鍧'));
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'module' => $module,
+ ]);
+ \Phpcmf\Service::V()->display('module.html');
+ }
+
+ // 闅愯棌鎴栬呭惎鐢
+ public function mhidden_edit() {
+
+ $id = (int)\Phpcmf\Service::L('input')->get('id');
+ $row = \Phpcmf\Service::M()->table('module_form')->get($id);
+ if (!$row) {
+ $this->_json(0, dr_lang('鏁版嵁#%s涓嶅瓨鍦', $id));
+ }
+
+ $v = $row['disabled'] ? 0 : 1;
+ \Phpcmf\Service::M()->table('module_form')->update($id, ['disabled' => $v]);
+
+ \Phpcmf\Service::M('cache')->sync_cache(''); // 鑷姩鏇存柊缂撳瓨
+ $this->_json(1, dr_lang($v ? '妯″潡琛ㄥ崟宸茶绂佺敤' : '妯″潡琛ㄥ崟宸茶鍚敤'), ['value' => $v]);
+ }
+
+ // 鍒涘缓妯″潡琛ㄥ崟
+ public function form_add() {
+
+ if (IS_AJAX_POST) {
+ $data = \Phpcmf\Service::L('input')->post('data');
+ if (!preg_match('/^[a-z]+[a-z0-9\_]+$/i', $data['table'])) {
+ $this->_json(0, dr_lang('琛ㄥ崟鍒悕涓嶈鑼'));
+ } elseif (\Phpcmf\Service::M('app')->is_sys_dir($data['table'])) {
+ $this->_json(0, dr_lang('鍚嶇О[%s]鏄郴缁熶繚鐣欏悕绉帮紝璇烽噸鍛藉悕', $data['table']));
+ }
+ $this->_validation(0, $data);
+ \Phpcmf\Service::L('input')->system_log('鍒涘缓妯″潡['.$this->dir.']琛ㄥ崟('.$data['name'].')');
+ $rt = \Phpcmf\Service::M('mform', 'mform')->create_form($this->dir, $data);
+ if ($rt['code']) {
+ \Phpcmf\Service::M('cache')->sync_cache(''); // 鑷姩鏇存柊缂撳瓨
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛锛岃鍒锋柊鍚庡彴椤甸潰'));
+ } else {
+ $this->_json(0, $rt['msg']);
+ }
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'form' => dr_form_hidden()
+ ]);
+ \Phpcmf\Service::V()->display('module_form_add.html');
+ exit;
+ }
+
+ // 淇敼妯″潡琛ㄥ崟
+ public function form_edit() {
+
+ $id = intval(\Phpcmf\Service::L('input')->get('id'));
+ $data = \Phpcmf\Service::M()->table('module_form')->get($id);
+ if (!$data) {
+ $this->_admin_msg(0, dr_lang('妯″潡琛ㄥ崟锛%s锛変笉瀛樺湪', $id));
+ }
+
+ $data['setting'] = dr_string2array($data['setting']);
+ !$data['setting']['list_field'] && $data['setting']['list_field'] = [
+ 'title' => [
+ 'use' => 1,
+ 'name' => dr_lang('涓婚'),
+ 'func' => 'title',
+ 'width' => 0,
+ 'order' => 1,
+ ],
+ 'uid' => [
+ 'use' => 1,
+ 'name' => dr_lang('璐﹀彿'),
+ 'func' => 'uid',
+ 'width' => 100,
+ 'order' => 2,
+ ],
+ 'inputtime' => [
+ 'use' => 1,
+ 'name' => dr_lang('褰曞叆鏃堕棿'),
+ 'func' => 'datetime',
+ 'width' => 160,
+ 'order' => 3,
+ ],
+ ];
+
+ if (IS_AJAX_POST) {
+ $data = \Phpcmf\Service::L('input')->post('data');
+ if ($data['setting']['list_field']) {
+ foreach ($data['setting']['list_field'] as $t) {
+ if ($t['func']) {
+ if (method_exists(\Phpcmf\Service::L('Function_list'), $t['func'])) {
+ } elseif (!function_exists($t['func'])) {
+ $this->_json(0, dr_lang('鍒楄〃鍥炶皟鍑芥暟[%s]鏈畾涔', $t['func']));
+ } elseif (strpos($t['func'], 'dr_') === false && strpos($t['func'], 'my_') === false) {
+ $this->_json(0, '鍑芥暟銆'.$t['func'].'銆戝繀椤讳互dr_鎴栬卪y_寮澶');
+ }
+ }
+ }
+ }
+ if ($data['setting']['order']) {
+ if (strpos($data['setting']['order'], '(') or strpos($data['setting']['order'], ')')) {
+ $this->_json(0, dr_lang('鍚庡彴鍒楄〃鐨勯粯璁ゆ帓搴忓瓧娈典笉鍏佽鐗规畩绗﹀彿'));
+ }
+ }
+ \Phpcmf\Service::M()->table('module_form')->update($id,
+ [
+ 'name' => $data['name'],
+ 'setting' => dr_array2string($data['setting'])
+ ]
+ );
+
+ \Phpcmf\Service::M('cache')->sync_cache(''); // 鑷姩鏇存柊缂撳瓨
+ \Phpcmf\Service::L('input')->system_log('淇敼妯″潡['.$this->dir.']琛ㄥ崟('.$data['name'].')閰嶇疆');
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ // 涓昏〃瀛楁
+ $field = \Phpcmf\Service::M()->db->table('field')
+ ->where('disabled', 0)
+ ->where('ismain', 1)
+ ->where('relatedname', 'mform-'.$this->dir)
+ ->where('relatedid', $id)
+ ->orderBy('displayorder ASC,id ASC')
+ ->get()->getResultArray();
+ $sys_field = \Phpcmf\Service::L('Field')->sys_field(['id', 'uid', 'inputtime', 'inputip', 'displayorder']);
+
+ // 鍏宠仈淇℃伅
+ $field['cid'] = [
+ 'name' => dr_lang('鍏宠仈'),
+ 'ismain' => 1,
+ 'ismember' => 1,
+ 'fieldtype' => 'Cid',
+ 'fieldname' => 'cid',
+ 'setting' => []
+ ];
+ if (!$data['setting']['list_field']['cid']['func']) {
+ $data['setting']['list_field']['cid']['func'] = 'ctitle';
+ }
+
+ $page = intval(\Phpcmf\Service::L('input')->get('page'));
+
+ \Phpcmf\Service::V()->assign([
+ 'data' => $data,
+ 'page' => $page,
+ 'form' => dr_form_hidden(['page' => $page]),
+ 'field' => dr_list_field_value($data['setting']['list_field'], $sys_field, $field),
+ 'diy_tpl' => is_file(dr_get_app_dir($this->dir).'Views/diy_'.$data['table'].'.html') ? dr_get_app_dir($this->dir).'Views/diy_'.$data['table'].'.html' : '',
+ ]);
+ \Phpcmf\Service::V()->display('module_form_edit.html');
+ }
+
+ // 鍒犻櫎琛ㄥ崟
+ public function del() {
+
+ $id = (int)\Phpcmf\Service::L('input')->get('id');
+ if (!$id) {
+ $this->_json(0, dr_lang('浣犺繕娌℃湁閫夋嫨鍛'));
+ }
+
+ $rt = \Phpcmf\Service::M('mform', 'mform')->delete_form([$id]);
+ if (!$rt['code']) {
+ $this->_json(0, $rt['msg']);
+ }
+
+ \Phpcmf\Service::M('cache')->sync_cache(''); // 鑷姩鏇存柊缂撳瓨
+ \Phpcmf\Service::L('input')->system_log('鍒犻櫎妯″潡琛ㄥ崟: '. $id);
+
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ // 楠岃瘉鏁版嵁
+ private function _validation($id, $data) {
+
+ list($data, $return) = \Phpcmf\Service::L('Form')->validation($data, $this->form);
+ if ($return) {
+ $this->_json(0, $return['error'], ['field' => $return['name']]);
+ }
+ if (\Phpcmf\Service::M()->table('module_form')->where('module', $this->dir)->is_exists($id, 'table', $data['table'])) {
+ $this->_json(0, dr_lang('鏁版嵁琛ㄥ悕绉板凡缁忓瓨鍦'), ['field' => 'table']);
+ }
+ }
+
+
+ // 琛ㄥ崟鍒濆鍖
+ public function form_init_index() {
+
+ $data = \Phpcmf\Service::M()->table('module_form')->getAll();
+ if (!$data) {
+ $this->_json(0, dr_lang('娌℃湁浠讳綍鍙敤琛ㄥ崟'));
+ }
+
+ $ct = $file = 0;
+ foreach ($data as $t) {
+ $par = \Phpcmf\Service::M()->dbprefix(dr_module_table_prefix($t['module'], SITE_ID)); // 鐖剁骇琛
+ if (!\Phpcmf\Service::M()->is_table_exists($par)) {
+ continue; // 褰撳墠绔欑偣娌℃湁瀹夎
+ }
+ $rt = \Phpcmf\Service::M('mform', 'mform')->create_form_file($t['module'], $t['table'], 1);
+ if (!$rt['code']) {
+ $this->_json(0, $rt['msg']);
+ }
+ $file+= (int)$rt['msg'];
+ $ct++;
+ // 鍒涘缓缁熻瀛楁
+ $fname = $t['table']."_total";
+ if (!\Phpcmf\Service::M()->is_field_exists($par, $fname)) {
+ \Phpcmf\Service::M('table')->add_field(
+ $par,
+ $fname,
+ 'INT(10) UNSIGNED',
+ 'NULL DEFAULT \'0\'',
+ '琛ㄥ崟'.$t['name'].'缁熻'
+ );
+ }
+ }
+
+ \Phpcmf\Service::M('cache')->sync_cache(''); // 鑷姩鏇存柊缂撳瓨
+ $this->_json(1, dr_lang('鏈珯鐐瑰叡锛%s锛変釜琛ㄥ崟锛岄噸寤猴紙%s锛変釜鏂囦欢', $ct, $file));
+ }
+
+
+}
diff --git a/dayrui/App/Mform/Models/Mform.php b/dayrui/App/Mform/Models/Mform.php
new file mode 100644
index 0000000..4053fc7
--- /dev/null
+++ b/dayrui/App/Mform/Models/Mform.php
@@ -0,0 +1,588 @@
+site_info as $sid => $v) {
+ $par = $this->dbprefix(dr_module_table_prefix($data['module'], $sid)); // 鐖剁骇琛
+ $pre = $par.'_form_'.$data['table']; // 褰撳墠琛
+ // 鍒ゆ柇妯″潡鏄惁瀹夎杩
+ if (!$this->is_table_exists($par)) {
+ continue;
+ }
+ \Phpcmf\Service::M('table')->create_table(
+ $pre,
+ [
+ 'id' => 'int(10) unsigned NOT NULL AUTO_INCREMENT',
+ 'cid' => 'int(10) unsigned NOT NULL COMMENT \'鍐呭id\'',
+ 'catid' => 'mediumint(8) unsigned NOT NULL COMMENT \'鏍忕洰id\'',
+ 'uid' => 'mediumint(8) unsigned NOT NULL COMMENT \'浣滆卛d\'',
+ 'author' => 'varchar(50) NOT NULL COMMENT \'浣滆呭悕绉癨'',
+ 'inputip' => 'varchar(200) DEFAULT NULL COMMENT \'褰曞叆鑰卛p\'',
+ 'inputtime' => 'int(10) unsigned NOT NULL COMMENT \'褰曞叆鏃堕棿\'',
+ 'title' => 'varchar(255) DEFAULT NULL COMMENT \'琛ㄥ崟涓婚\'',
+ 'status' => 'tinyint(1) DEFAULT NULL COMMENT \'鐘舵佸糪'',
+ 'tableid' => 'smallint(5) unsigned NOT NULL COMMENT \'闄勮〃id\'',
+ 'displayorder' => 'int(10) DEFAULT NULL COMMENT \'鎺掑簭鍊糪'',
+ ],
+ [
+ 'PRIMARY KEY (`id`)',
+ 'KEY `cid` (`cid`)',
+ 'KEY `uid` (`uid`)',
+ 'KEY `catid` (`catid`)',
+ 'KEY `author` (`author`)',
+ 'KEY `status` (`status`)',
+ 'KEY `displayorder` (`displayorder`)',
+ 'KEY `inputtime` (`inputtime`)',
+ ],
+ '妯″潡琛ㄥ崟'.$data['name'].'琛'
+ );
+ \Phpcmf\Service::M('table')->create_table(
+ $pre.'_data_0',
+ [
+ 'id' => 'int(10) unsigned NOT NULL',
+ 'cid' => 'int(10) unsigned NOT NULL COMMENT \'鍐呭id\'',
+ 'catid' => 'mediumint(8) unsigned NOT NULL COMMENT \'鏍忕洰id\'',
+ 'uid' => 'mediumint(8) unsigned NOT NULL COMMENT \'浣滆卛d\'',
+ ],
+ [
+ 'UNIQUE KEY `id` (`id`)',
+ 'KEY `cid` (`cid`)',
+ 'KEY `catid` (`catid`)',
+ 'KEY `uid` (`uid`)',
+ ],
+ '妯″潡琛ㄥ崟'.$data['name'].'闄勮〃'
+ );
+ // 鍔犱笂缁熻瀛楁
+ if ($this->is_field_exists($par, $data['table']."_total")) {
+ continue;
+ }
+ \Phpcmf\Service::M('table')->add_field(
+ $par,
+ $data['table'].'_total',
+ 'INT(10) UNSIGNED',
+ 'NULL DEFAULT \'0\'',
+ '琛ㄥ崟'.$data['name'].'缁熻'
+ );
+ }
+
+ // 鍒犻櫎鍘熸湁鐨勫啑浣欏瓧娈
+ $this->db->table('field')->where('relatedid', $data['id'])->where('relatedname', 'mform-'.$data['module'])->delete();
+
+ // 榛樿瀛楁
+ $this->db->table('field')->insert(array(
+ 'name' => '涓婚',
+ 'fieldname' => 'title',
+ 'fieldtype' => 'Text',
+ 'relatedid' => $data['id'],
+ 'relatedname' => 'mform-'.$data['module'],
+ 'isedit' => 1,
+ 'ismain' => 1,
+ 'ismember' => 1,
+ 'issystem' => 1,
+ 'issearch' => 1,
+ 'disabled' => 0,
+ 'setting' => dr_array2string(array(
+ 'option' => array(
+ 'width' => 300, // 琛ㄥ崟瀹藉害
+ 'fieldtype' => 'VARCHAR', // 瀛楁绫诲瀷
+ 'fieldlength' => '255' // 瀛楁闀垮害
+ ),
+ 'validate' => array(
+ 'xss' => 1, // xss杩囨护
+ 'required' => 1, // 琛ㄧず蹇呭~
+ )
+ )),
+ 'displayorder' => 0,
+ ));
+ $this->db->table('field')->insert(array(
+ 'name' => '浣滆',
+ 'fieldname' => 'author',
+ 'fieldtype' => 'Text',
+ 'relatedid' => $data['id'],
+ 'relatedname' => 'mform-'.$data['module'],
+ 'isedit' => 1,
+ 'ismain' => 1,
+ 'ismember' => 1,
+ 'issystem' => 1,
+ 'issearch' => 1,
+ 'disabled' => 0,
+ 'setting' => dr_array2string(array(
+ 'is_right' => 1,
+ 'option' => array(
+ 'width' => 200, // 琛ㄥ崟瀹藉害
+ 'fieldtype' => 'VARCHAR', // 瀛楁绫诲瀷
+ 'fieldlength' => '255' // 瀛楁闀垮害
+ ),
+ 'validate' => array(
+ 'xss' => 1, // xss杩囨护
+ )
+ )),
+ 'displayorder' => 0,
+ ));
+ }
+
+ // 鍒犻櫎妯″潡琛ㄥ崟
+ public function delete_module_form($data) {
+
+ $id = intval($data['id']);
+ $table = $this->dbprefix(dr_module_table_prefix($data['module']).'_form_'.$data['table']);
+ // 鍒ゆ柇妯″潡鏄惁瀛樺湪琛
+ if (!$this->is_table_exists($table)) {
+ return;
+ }
+
+ // 鍒犻櫎瀛楁
+ $this->db->table('field')->where('relatedid', $id)->where('relatedname', 'mform-'.$data['module'])->delete();
+
+ // 鍒犻櫎琛
+ \Phpcmf\Service::M('table')->drop_table($table, true);
+
+ // 鍒犻櫎闄勮〃
+ for ($i = 0; $i < 200; $i ++) {
+ if (!$this->is_table_exists($table.'_data_'.$i)) {
+ break;
+ }
+ \Phpcmf\Service::M('table')->drop_table($table.'_data_'.$i, true);
+ }
+
+ // 妯″潡琛ㄧ粺璁″瓧娈靛垹闄
+ $par = $this->dbprefix(dr_module_table_prefix($data['module']));
+ // 鍒ゆ柇妯″潡鏄惁瀛樺湪琛
+ if (!$this->is_table_exists($par)) {
+ return;
+ }
+
+ if ($this->is_field_exists($par, $data['table']."_total")) {
+ \Phpcmf\Service::M('table')->drop_field($par, $data['table'].'_total');
+ }
+
+ // 鎸傞挬鐐
+ \Phpcmf\Hooks::trigger('module_form_uninstall_after', $data);
+ }
+
+ // 鍒涘缓琛ㄥ崟鏂囦欢
+ public function create_form_file($dir, $table, $call = 0) {
+
+ $dir = ucfirst($dir);
+ $path = dr_get_app_dir($dir);
+ if (!is_dir($path)) {
+ return dr_return_data(1, 'ok');
+ }
+
+ $name = ucfirst($table);
+ $temp = dr_get_app_dir('mform').'Code/';
+ $files = [
+ $path.'Controllers/'.$name.'.php' => $temp.'$NAME$.php',
+ $path.'Controllers/Member/'.$name.'.php' => $temp.'Member$NAME$.php',
+ $path.'Controllers/Admin/'.$name.'.php' => $temp.'Admin$NAME$.php',
+ $path.'Controllers/Admin/'.$name.'_verify.php' => $temp.'Admin$NAME$_verify.php',
+ ];
+
+ $ok = 0;
+ foreach ($files as $file => $form) {
+ if (!is_file($file)) {
+ $c = file_get_contents($form);
+ $size = file_put_contents($file, str_replace('$NAME$', $name, $c));
+ if (!$size && $call) {
+ unlink($file);
+ return dr_return_data(0, dr_lang('鏂囦欢%s鍒涘缓澶辫触锛屾棤鍙啓鏉冮檺', str_replace(FCPATH, '', $file)));
+ }
+ $ok ++;
+ }
+ }
+
+ return dr_return_data(1, $ok);
+ }
+
+
+ // 鍒涘缓妯″潡琛ㄥ崟
+ public function create_form($dir, $data) {
+
+ // 鎻掑叆琛ㄥ崟鏁版嵁
+ $data['table'] = strtolower($data['table']);
+ $rt = $this->table('module_form')->insert([
+ 'name' => $data['name'],
+ 'table' => $data['table'],
+ 'module' => $dir,
+ 'setting' => '',
+ 'disabled' => 0,
+ ]);
+
+ if (!$rt['code']) {
+ return $rt;
+ }
+
+ $id = $data['id'] = $rt['code'];
+ $data['module'] = $dir;
+
+ // 鍒涘缓鏂囦欢
+ $rt = $this->create_form_file($dir, $data['table']);
+ if (!$rt['code']) {
+ $this->table('module_form')->delete($id);
+ return $rt;
+ }
+
+ // 鍒涘缓琛
+ $this->create_module_form($data);
+
+ return dr_return_data(1, 'ok');
+ }
+
+ // 鍒犻櫎妯″潡琛ㄥ崟
+ public function delete_form($ids) {
+
+ foreach ($ids as $id) {
+ $row = $this->table('module_form')->get(intval($id));
+ if (!$row) {
+ return dr_return_data(0, dr_lang('妯″潡琛ㄥ崟涓嶅瓨鍦(id:%s)', $id));
+ }
+ $rt = $this->table('module_form')->delete($id);
+ if (!$rt['code']) {
+ return dr_return_data(0, $rt['msg']);
+ }
+ $name = ucfirst($row['table']);
+ $path = dr_get_app_dir($row['module']);
+ unlink($path.'Controllers/'.$name.'.php');
+ unlink($path.'Controllers/Admin/'.$name.'.php');
+ unlink($path.'Controllers/Member/'.$name.'.php');
+ unlink($path.'Controllers/Admin/'.$name.'_verify.php');
+ // 鍒犻櫎琛ㄦ暟鎹
+ $this->delete_module_form($row);
+ }
+
+ return dr_return_data(1, '');
+ }
+
+ public function link_menu($form, $table, $mdir, $config, $left) {
+ // 琛ㄥ崟鍏ュ簱
+ if ($form) {
+ foreach ($form as $t) {
+ $mark = 'app-mform-verify-'.$mdir.'-'.$t['table'];
+ $menu = $this->db->table($table.'_menu')->where('mark', $mark)->get()->getRowArray();
+ $save = [
+ 'uri' => $mdir.'/'.$t['table'].'_verify/index',
+ 'mark' => $mark,
+ 'name' => $menu && $menu['name'] ? $menu['name'] : dr_lang('%s%s', $config['name'], $t['name']),
+ 'icon' => $menu && $menu['icon'] ? $menu['icon'] : dr_icon($t['setting']['icon']),
+ 'displayorder' => $menu ? intval($menu['displayorder']) : '-1',
+ ];
+ $menu ? \Phpcmf\Service::M('menu')->_edit($table, $menu['id'], $save) : \Phpcmf\Service::M('menu')->_add($table, $left['id'], $save);
+ }
+ }
+ }
+
+ public function link_delete($module, $dir) {
+
+ $this->db->table('field')->where('relatedid', $module['id'])->where('relatedname', 'mform-'.$dir)->delete();
+ $this->db->table('admin_menu')->like('mark', 'app-mform-verify-'.$dir)->delete();
+ $this->db->table('module_form')->where('module', $dir)->delete();
+ }
+
+ public function link_uninstall($table, $dir) {
+
+ // 鍒犻櫎琛ㄥ崟
+ $form = $this->db->table('module_form')->where('module', $dir)->get()->getResultArray();
+ if ($form) {
+ foreach ($form as $t) {
+ $mytable = $table.'_form_'.$t['table'];
+ // 涓昏〃
+ \Phpcmf\Service::M('table')->drop_table($mytable, true);
+ // 闄勮〃
+ for ($i = 0; $i < 200; $i ++) {
+ if (!$this->is_table_exists($mytable.'_data_'.$i)) {
+ break;
+ }
+ \Phpcmf\Service::M('table')->drop_table($mytable.'_data_'.$i, true);
+ }
+ }
+ }
+ }
+
+ private function _link_install($module, $mpath, $dir, $table) {
+ if (is_file($mpath.'Config/Form.php')) {
+ $form = require $mpath.'Config/Form.php';
+ if ($form) {
+ foreach ($form as $ftable => $t) {
+ // 鎻掑叆琛ㄥ崟鏁版嵁
+ $rt = $this->table('module_form')->insert([
+ 'name' => $t['form']['name'],
+ 'table' => $ftable,
+ 'module' => $dir,
+ 'setting' => $t['form']['setting'],
+ 'disabled' => 0,
+ ]);
+ if ($rt['code']) {
+ // 寤鸿〃锛圫chema 鈫 create_table锛涙棫鐗 CREATE SQL 鈫 formatCreateSql锛
+ foreach ([1 => $table.'_form_'.$ftable, 0 => $table.'_form_'.$ftable.'_data_0'] as $ti => $tablename) {
+ $def = $t['table'][$ti] ?? '';
+ if (is_array($def) && isset($def['fields'])) {
+ \Phpcmf\Service::M('table')->create_table(
+ $tablename,
+ $def['fields'],
+ $def['indexes'] ?? [],
+ $def['comment'] ?? ''
+ );
+ } elseif ($def) {
+ $this->db->simpleQuery(str_replace('{tablename}', $tablename, dr_format_create_sql((string) $def)));
+ }
+ }
+ // 鎻掑叆鑷畾涔夊瓧娈
+ foreach ([1, 0] as $is_main) {
+ $f = $t['field'][$is_main];
+ if ($f) {
+ foreach ($f as $field) {
+ \Phpcmf\Service::M('module')->_add_field($field, $is_main, $rt['code'], 'mform-'.$dir);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public function link_install($module, $mpath, $dir, $table) {
+ // 鍒涘缓琛ㄥ崟
+ if (dr_count($module['site']) == 1) {
+ // 琛ㄧず绗竴涓珯灏卞垱寤鸿〃鍗
+ $this->_link_install($module, $mpath, $dir, $table);
+ } else {
+ // 鍒涘缓妯″潡宸茬粡瀛樺湪鐨勮〃鍗
+ $form = $this->db->table('module_form')->where('module', $dir)->get()->getResultArray();
+ if ($form) {
+ $this->db->resetDataCache();// 娓呴櫎缂撳瓨锛屽奖鍝嶅瓧娈靛瓨鍦ㄧ殑閲嶅
+ foreach ($form as $t) {
+ // 琛ㄧず瀛樺湪澶氫釜绔
+ $sid = 0;
+ foreach ($module['site'] as $site => $tt) {
+ if ($this->is_table_exists($this->dbprefix($site.'_'.$dir).'_form_'.$t['table'])) {
+ // 琛ㄧず宸茬粡鍦ㄥ叾浠栫珯鍒涘缓杩囦簡,鎴戜滑灏卞鍒跺畠浠ュ墠鍒涘缓鐨勮〃缁撴瀯
+ $sid = $site;
+ break;
+ }
+ }
+ if ($sid) {
+ // 寮濮嬪垱寤鸿〃鍗
+ $mytable = $table.'_form_'.$t['table'];
+ $cptable = $this->dbprefix($sid.'_'.$dir).'_form_'.$t['table'];
+ // 涓昏〃
+ list($sql) = \Phpcmf\Service::M('table')->create_table_sql($cptable);
+ $sql = str_replace($cptable, $mytable, $sql);
+ $this->db->simpleQuery(dr_format_create_sql($sql));
+ // 闄勮〃
+ list($sql) = \Phpcmf\Service::M('table')->create_table_sql($cptable.'_data_0');
+ $sql = str_replace($cptable.'_data_0', $mytable.'_data_0', $sql);
+ $this->db->simpleQuery(dr_format_create_sql($sql));
+ } else {
+ // 娌℃湁琛ㄥ氨鍒犻櫎琛ㄥ崟
+ //log_message('error', '娌℃湁琛ㄥ氨鍒犻櫎琛ㄥ崟');
+ $this->db->table('module_form')->where('id', $t['id'])->delete();
+ }
+ }
+ } else {
+ $this->_link_install($module, $mpath, $dir, $table);
+ }
+ }
+ }
+
+ // 缂撳瓨
+ public function link_cache($mdir, $cache) {
+ $form = $this->table('module_form')->where('module', $mdir)->where('disabled', 0)->order_by('id ASC')->getAll();
+ if ($form) {
+ foreach ($form as $t) {
+ $t['field'] = [];
+ // 妯″潡琛ㄥ崟鐨勮嚜瀹氫箟瀛楁
+ if (!$this->table('field')
+ ->where('relatedname', 'mform-'.$mdir)
+ ->where('relatedid', intval($t['id']))
+ ->where('fieldname', 'author')->counts()) {
+ $this->db->table('field')->insert(array(
+ 'name' => '浣滆',
+ 'fieldname' => 'author',
+ 'fieldtype' => 'Text',
+ 'relatedid' => $t['id'],
+ 'relatedname' => 'mform-'.$mdir,
+ 'isedit' => 1,
+ 'ismain' => 1,
+ 'ismember' => 1,
+ 'issystem' => 1,
+ 'issearch' => 1,
+ 'disabled' => 0,
+ 'setting' => dr_array2string(array(
+ 'is_right' => 1,
+ 'option' => array(
+ 'width' => 200, // 琛ㄥ崟瀹藉害
+ 'fieldtype' => 'VARCHAR', // 瀛楁绫诲瀷
+ 'fieldlength' => '255' // 瀛楁闀垮害
+ ),
+ 'validate' => array(
+ 'xss' => 1, // xss杩囨护
+ )
+ )),
+ 'displayorder' => 0,
+ ));
+ }
+ $field = $this->db->table('field')->where('disabled', 0)->where('relatedid', intval($t['id']))->where('relatedname', 'mform-'.$mdir)->orderBy('displayorder ASC, id ASC')->get()->getResultArray();
+ if ($field) {
+ foreach ($field as $f) {
+ $f['setting'] = dr_string2array($f['setting']);
+ $t['field'][$f['fieldname']] = $f;
+ }
+ }
+ $t['setting'] = dr_string2array($t['setting']);
+ // 鎺掑垪table瀛楁椤哄簭
+ $t['setting']['list_field'] = dr_list_field_order($t['setting']['list_field']);
+ $cache['form'][$t['table']] = $t;
+ }
+ }
+ return $cache;
+ }
+
+ // 淇濆瓨鏁版嵁
+ public function save_content($mid, $tid, $index, $data, $data2 = []) {
+
+ $data['status'] = isset($data['status']) ? intval($data['status']) : 1;
+ $data['uid'] = isset($data['uid']) ? intval($data['uid']) : (int)$this->member['uid'];
+ $data['author'] = isset($data['author']) ? trim($data['author']) : $this->member['username'];
+ $data['inputip'] = isset($data['inputip']) ? $data['inputip'] : \Phpcmf\Service::L('input')->ip_info();
+ $data['inputtime'] = isset($data['inputtime']) ? $data['inputtime'] : SYS_TIME;
+ $data['tableid'] = 0;
+ $data['displayorder'] = isset($data['displayorder']) ? $data['displayorder'] : 0;
+ $data['cid'] = intval($index['id']); // 鍐呭id
+ $data['catid'] = intval($index['catid']); // 鏍忕洰id
+ // 鎻掑叆涓昏〃
+ $table = $mid.'_form_'.$tid;
+ $rt = $this->table_site($table)->insert($data);
+ if (!$rt['code']) {
+ return $rt;
+ }
+ $etable = dr_mform_ctable($mid, $tid, $data['cid'], 0);
+ if ($table != $etable) {
+ // 澶囩敤琛
+ $this->table_site($etable)->replace($data);
+ }
+ $data['id'] = $rt['code'];
+ if ($data2) {
+ // 濡傛灉瑕佷娇鐢ㄩ檮琛ㄥ垎琛ㄥ氨 鎸変竴瀹氶噺杩涜鍒嗚〃璁剧疆 姣斿50000
+ $data['tableid'] = \Phpcmf\Service::M()->get_table_id($rt['code']);
+ if ($data['tableid'] > 0) {
+ // 鍒ゆ柇闄勮〃鏄惁瀛樺湪,涓嶅瓨鍦ㄥ垯鍒涘缓
+ $this->is_data_table(SITE_ID.'_'.$mid.'_form_'.$tid.'_data_', $data['tableid']);
+ // 鏇存柊tableid鍒颁富琛
+ $this->table_site($mid.'_form_'.$tid)->update($data['id'], ['tableid' => $data['tableid']]);
+ if ($table != $etable) {
+ // 澶囩敤琛
+ $this->table_site($etable)->update($data['id'], ['tableid' => $data['tableid']]);
+ }
+ }
+ $data2['id'] = $data['id'];
+ $data2['uid'] = $data['uid'];
+ $data2['cid'] = $data['cid']; // 鍐呭id
+ $data2['catid'] = $data['catid']; // 鏍忕洰id
+ // 鎻掑叆闄勮〃
+ $rt2 = $this->table_site($mid.'_form_'.$tid.'_data_'.$data['tableid'])->insert($data2);
+ if (!$rt2['code']) {
+ // 鍒犻櫎涓昏〃
+ $this->table_site($mid.'_form_'.$tid)->delete($data['id']);
+ if ($table != $etable) {
+ // 澶囩敤琛
+ $this->table_site($etable)->delete($data['id']);
+ }
+ return $rt2;
+ }
+ }
+ if ($table != $etable) {
+ // 澶囩敤琛
+ $total = $this->table_site($etable)->where('status', 1)->where('cid', $data['cid'])->counts();
+ } else {
+ $total = $this->table_site($mid.'_form_'.$tid)->where('status', 1)->where('cid', $data['cid'])->counts();
+ }
+
+ $this->table_site($mid)->update($data['cid'], [
+ $tid.'_total' => $total,
+ ]);
+
+ return $rt;
+ }
+
+
+ // 妯″潡琛ㄥ崟鍐呭鍦板潃
+ public function show_url($form, $id, $mid = '', $page = 0) {
+
+ // 妯″潡鐩綍璇嗗埆
+ defined('MOD_DIR') && MOD_DIR && $dir = MOD_DIR;
+ $mid && $dir = $mid;
+
+ $module = \Phpcmf\Service::L('cache')->get('module-' . SITE_ID . '-' . $dir);
+
+ return \Phpcmf\Service::L('router')->url_prefix('php', $module, [], SITE_FID) . 'c=' . $form . '&m=show&id=' . $id . ($page > 1 || strlen($page) > 1 ? '&page=' . $page : '');
+ }
+
+
+ // 妯″潡琛ㄥ崟鎻愪氦鍦板潃
+ public function post_url($form, $cid, $mid = '') {
+
+ // 妯″潡鐩綍璇嗗埆
+ defined('MOD_DIR') && MOD_DIR && $dir = MOD_DIR;
+ $mid && $dir = $mid;
+
+ $module = \Phpcmf\Service::L('cache')->get('module-' . SITE_ID . '-' . $dir);
+
+ return \Phpcmf\Service::L('router')->url_prefix('php', $module, [], SITE_FID) . 'c=' . $form . '&m=post&cid=' . $cid;
+ }
+
+
+ // 妯″潡琛ㄥ崟鍒楄〃鍦板潃
+ public function list_url($form, $cid, $mid = '', $page = 0) {
+
+ // 妯″潡鐩綍璇嗗埆
+ defined('MOD_DIR') && MOD_DIR && $dir = MOD_DIR;
+ $mid && $dir = $mid;
+
+ $module = \Phpcmf\Service::L('cache')->get('module-' . SITE_ID . '-' . $dir);
+
+ return \Phpcmf\Service::L('router')->url_prefix('php', $module, [], SITE_FID) . 'c=' . $form . '&m=index&cid=' . $cid . ($page > 1 || strlen($page) > 1 ? '&page=' . $page : '');
+ }
+
+ /**
+ * 鍒犻櫎妯″潡鍐呭鏃剁殑鑱斿姩
+ */
+ public function delete_content($id, $siteid, $dirname) {
+
+ if (!$id) {
+ return;
+ }
+
+ $module = \Phpcmf\Service::L('cache')->get('module-' . SITE_ID . '-' . $dirname);
+ if ($module['form']) {
+ foreach ($module['form'] as $m) {
+ $table = $this->dbprefix(dr_module_table_prefix($dirname).'_form_'.$m['table']);
+ // 鍒ゆ柇妯″潡鏄惁瀛樺湪琛
+ if ($this->is_table_exists($table)) {
+ $this->db->table($table)->where('cid', $id)->delete();
+ $this->db->table($table.'_data_0')->where('cid', $id)->delete();
+ }
+ }
+ }
+
+ }
+
+ // 鏇存柊缁熻瀛楁
+ public function update_form_total($cid, $form) {
+ $total = $this->table(dr_mform_ctable(APP_DIR, $form, $cid))
+ ->where('status', 1)
+ ->where('cid', $cid)
+ ->counts();
+ $this->table(dr_module_table_prefix(APP_DIR))->update($cid, [
+ $form.'_total' => $total,
+ ]);
+ }
+}
\ No newline at end of file
diff --git a/dayrui/App/Mform/Views/module.html b/dayrui/App/Mform/Views/module.html
new file mode 100644
index 0000000..281b9c2
--- /dev/null
+++ b/dayrui/App/Mform/Views/module.html
@@ -0,0 +1,52 @@
+{template "header.html"}
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Mform/Views/module_form.html b/dayrui/App/Mform/Views/module_form.html
new file mode 100644
index 0000000..4ef062b
--- /dev/null
+++ b/dayrui/App/Mform/Views/module_form.html
@@ -0,0 +1,75 @@
+{template "header.html"}
+
+
{dr_lang('妯″潡琛ㄥ崟鏄妯″潡鍐呭鐨勬墿灞曪紝鐩稿綋浜庢ā鍧楃殑瀛愬唴瀹')}
+
+
+
+
+ {dr_form_hidden()}
+
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Mform/Views/module_form_add.html b/dayrui/App/Mform/Views/module_form_add.html
new file mode 100644
index 0000000..6dbcbe5
--- /dev/null
+++ b/dayrui/App/Mform/Views/module_form_add.html
@@ -0,0 +1,31 @@
+{template "header.html"}
+
+
+ {$form}
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Mform/Views/module_form_edit.html b/dayrui/App/Mform/Views/module_form_edit.html
new file mode 100644
index 0000000..6bfce10
--- /dev/null
+++ b/dayrui/App/Mform/Views/module_form_edit.html
@@ -0,0 +1,294 @@
+{template "header.html"}
+
+
+ {$form}
+
+
+
+
+
+
+
+
+ {if $diy_tpl}
+
+ {/if}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {if !IS_USE_MEMBER}
+
+ {else}
+
+
+
+
+ {/if}
+
+
+
+
+
+
+
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Mform/Views/share_mform_list.html b/dayrui/App/Mform/Views/share_mform_list.html
new file mode 100644
index 0000000..eec8fdd
--- /dev/null
+++ b/dayrui/App/Mform/Views/share_mform_list.html
@@ -0,0 +1,85 @@
+{template "header.html"}
+
+{template "api_list_date_search.html"}
+
+{if $index}
+
+{/if}
+
+
+
+
+
+
+ {dr_form_hidden()}
+
+
+ {template "mytable.html"}
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Mform/Views/share_mform_post.html b/dayrui/App/Mform/Views/share_mform_post.html
new file mode 100644
index 0000000..90ce78f
--- /dev/null
+++ b/dayrui/App/Mform/Views/share_mform_post.html
@@ -0,0 +1,99 @@
+{template "header.html"}
+
+
+
+ {$form}
+
+
+
+
+
+
+ {dr_lang('鍩烘湰鍐呭')}
+
+
+
+
+
+
+
+ {if $diyfield}
+
+
+
+ {dr_lang('鍏朵粬鍐呭')}
+
+
+
+
+ {/if}
+
+
+
+
+
+
+
+
+ {if $is_verify}
+
+ {dr_lang('鎻愪氦瀹℃牳')}
+ {else}
+ {dr_lang('淇濆瓨鍐呭')}
+ {dr_lang('淇濆瓨骞惰繑鍥')}
+ {if $is_form_cache}
+ {dr_lang('鍒犻櫎鍘嗗彶缂撳瓨')}
+ {/if}
+ {/if}
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Mform/Views/share_mform_show.html b/dayrui/App/Mform/Views/share_mform_show.html
new file mode 100644
index 0000000..7b8202a
--- /dev/null
+++ b/dayrui/App/Mform/Views/share_mform_show.html
@@ -0,0 +1,69 @@
+{template "header.html"}
+
+
+ {$form}
+
+
+
+
+
+
+ {dr_lang('鍩烘湰鍐呭')}
+
+
+
+
+
+
+
+ {if $diyfield}
+
+
+
+ {dr_lang('鍏朵粬鍐呭')}
+
+
+
+
+ {/if}
+
+
+
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/News/Config/App.php b/dayrui/App/News/Config/App.php
new file mode 100644
index 0000000..d5d6395
--- /dev/null
+++ b/dayrui/App/News/Config/App.php
@@ -0,0 +1,11 @@
+ 'module',
+ 'name' => '鍐呭',
+ 'icon' => 'fa fa-sticky-note',
+ 'system' => '1',
+ 'mtype' => '1'
+
+];
\ No newline at end of file
diff --git a/dayrui/App/News/Config/Routes.php b/dayrui/App/News/Config/Routes.php
new file mode 100644
index 0000000..ef3217b
--- /dev/null
+++ b/dayrui/App/News/Config/Routes.php
@@ -0,0 +1,4 @@
+_Admin_List();
+ }
+
+ public function all_add() {
+ $this->_Admin_All_Add();
+ }
+
+ public function add() {
+ $this->_Admin_Add();
+ }
+
+ public function edit() {
+ $this->_Admin_Edit();
+ }
+
+ public function url_edit() {
+ $this->_Admin_Url_Edit();
+ }
+
+ public function move_edit() {
+ $this->_Admin_Move_Edit();
+ }
+
+ public function show_edit() {
+ $this->_Admin_Show_Edit();
+ }
+
+ public function displayorder_edit() {
+ $this->_Admin_Order();
+ }
+
+ public function html_edit() {
+ $this->_Admin_Html_Edit();
+ }
+
+ public function del() {
+ $this->_Admin_Del();
+ }
+}
diff --git a/dayrui/App/News/Controllers/Admin/Draft.php b/dayrui/App/News/Controllers/Admin/Draft.php
new file mode 100644
index 0000000..1e095ee
--- /dev/null
+++ b/dayrui/App/News/Controllers/Admin/Draft.php
@@ -0,0 +1,17 @@
+_Admin_Draft_List();
+ }
+
+ public function del() {
+ $this->_Admin_Draft_Del();
+ }
+}
diff --git a/dayrui/App/News/Controllers/Admin/Flag.php b/dayrui/App/News/Controllers/Admin/Flag.php
new file mode 100644
index 0000000..b013175
--- /dev/null
+++ b/dayrui/App/News/Controllers/Admin/Flag.php
@@ -0,0 +1,17 @@
+_Admin_Flag_List();
+ }
+
+ public function edit() {
+ $this->_Admin_Edit();
+ }
+}
diff --git a/dayrui/App/News/Controllers/Admin/Home.php b/dayrui/App/News/Controllers/Admin/Home.php
new file mode 100644
index 0000000..db7ba90
--- /dev/null
+++ b/dayrui/App/News/Controllers/Admin/Home.php
@@ -0,0 +1,45 @@
+_Admin_List();
+ }
+
+ public function add() {
+ $this->_Admin_Add();
+ }
+
+ public function edit() {
+ $this->_Admin_Edit();
+ }
+
+ public function show_index() {
+ $this->_Admin_Show();
+ }
+
+ public function order_edit() {
+ $this->_Admin_Order();
+ }
+
+ public function move_edit() {
+ $this->_Admin_Move();
+ }
+
+ public function tui_edit() {
+ $this->_Admin_Send();
+ }
+
+ public function syncat_edit() {
+ $this->_Admin_Syncat();
+ }
+
+ public function del() {
+ $this->_Admin_Del();
+ }
+}
diff --git a/dayrui/App/News/Controllers/Admin/Html.php b/dayrui/App/News/Controllers/Admin/Html.php
new file mode 100644
index 0000000..ec58288
--- /dev/null
+++ b/dayrui/App/News/Controllers/Admin/Html.php
@@ -0,0 +1,18 @@
+_Index();
+ }
+}
diff --git a/dayrui/App/News/Controllers/Admin/Recycle.php b/dayrui/App/News/Controllers/Admin/Recycle.php
new file mode 100644
index 0000000..9fc417d
--- /dev/null
+++ b/dayrui/App/News/Controllers/Admin/Recycle.php
@@ -0,0 +1,29 @@
+_Admin_Recycle_List();
+ }
+
+ public function del() {
+ $this->_Admin_Recycle_Del();
+ }
+
+ public function show() {
+ $this->_Admin_Recycle_Show();
+ }
+
+ public function edit() {
+ $this->_Admin_Recycle_Edit();
+ }
+
+ public function recovery_add() {
+ $this->_Admin_Recovery();
+ }
+}
diff --git a/dayrui/App/News/Controllers/Admin/Time.php b/dayrui/App/News/Controllers/Admin/Time.php
new file mode 100644
index 0000000..3c270ee
--- /dev/null
+++ b/dayrui/App/News/Controllers/Admin/Time.php
@@ -0,0 +1,25 @@
+_Admin_Time_List();
+ }
+
+ public function add() {
+ $this->_Admin_Time_add();
+ }
+
+ public function edit() {
+ $this->_Admin_Time_Edit();
+ }
+
+ public function del() {
+ $this->_Admin_Time_Del();
+ }
+}
diff --git a/dayrui/App/News/Controllers/Admin/Verify.php b/dayrui/App/News/Controllers/Admin/Verify.php
new file mode 100644
index 0000000..fb57529
--- /dev/null
+++ b/dayrui/App/News/Controllers/Admin/Verify.php
@@ -0,0 +1,46 @@
+_Admin_Verify_List();
+ }
+
+ public function s9_index() {
+ $_GET['status'] = 9;
+ $this->_Admin_Verify_List();
+ }
+
+ public function s1_index() {
+ $_GET['status'] = 1;
+ $this->_Admin_Verify_List();
+ }
+
+ public function s2_index() {
+ $_GET['status'] = 2;
+ $this->_Admin_Verify_List();
+ }
+
+ public function s3_index() {
+ $_GET['status'] = 3;
+ $this->_Admin_Verify_List();
+ }
+
+ public function s4_index() {
+ $_GET['status'] = 4;
+ $this->_Admin_Verify_List();
+ }
+
+ public function edit() {
+ $this->_Admin_Verify_Edit();
+ }
+
+ public function del() {
+ $this->_Admin_Verify_Del();
+ }
+}
diff --git a/dayrui/App/News/Controllers/Category.php b/dayrui/App/News/Controllers/Category.php
new file mode 100644
index 0000000..2e55bdf
--- /dev/null
+++ b/dayrui/App/News/Controllers/Category.php
@@ -0,0 +1,21 @@
+_module_init();
+ // 璋冪敤鏍忕洰鏂规硶
+ $this->_Category(
+ (int)\Phpcmf\Service::L('Input')->get('id'),
+ dr_safe_replace(\Phpcmf\Service::L('Input')->get('dir')),
+ max(1, (int)\Phpcmf\Service::L('Input')->get('page'))
+ );
+ }
+
+}
diff --git a/dayrui/App/News/Controllers/Home.php b/dayrui/App/News/Controllers/Home.php
new file mode 100644
index 0000000..483e14b
--- /dev/null
+++ b/dayrui/App/News/Controllers/Home.php
@@ -0,0 +1,14 @@
+_Index();
+ }
+
+}
diff --git a/dayrui/App/News/Controllers/Html.php b/dayrui/App/News/Controllers/Html.php
new file mode 100644
index 0000000..1b62028
--- /dev/null
+++ b/dayrui/App/News/Controllers/Html.php
@@ -0,0 +1,36 @@
+_Member_Draft_List();
+ }
+
+ public function del() {
+ $this->_Member_Draft_Del();
+ }
+}
diff --git a/dayrui/App/News/Controllers/Member/Home.php b/dayrui/App/News/Controllers/Member/Home.php
new file mode 100644
index 0000000..86921fc
--- /dev/null
+++ b/dayrui/App/News/Controllers/Member/Home.php
@@ -0,0 +1,22 @@
+_Member_List();
+ }
+
+ public function add() {
+ $this->_Member_Add();
+ }
+
+ public function edit() {
+ $this->_Member_Edit();
+ }
+
+ public function del() {
+ $this->_Member_Del();
+ }
+}
diff --git a/dayrui/App/News/Controllers/Member/Verify.php b/dayrui/App/News/Controllers/Member/Verify.php
new file mode 100644
index 0000000..2a3cfce
--- /dev/null
+++ b/dayrui/App/News/Controllers/Member/Verify.php
@@ -0,0 +1,18 @@
+_Member_Verify_List();
+ }
+
+ public function edit() {
+ $this->_Member_Verify_Edit();
+ }
+
+ public function del() {
+ $this->_Member_Verify_Del();
+ }
+}
diff --git a/dayrui/App/News/Controllers/Search.php b/dayrui/App/News/Controllers/Search.php
new file mode 100644
index 0000000..ec69929
--- /dev/null
+++ b/dayrui/App/News/Controllers/Search.php
@@ -0,0 +1,17 @@
+_module_init();
+ // 璋冪敤鎼滅储鏂规硶
+ $this->_Search();
+ }
+
+}
diff --git a/dayrui/App/News/Controllers/Show.php b/dayrui/App/News/Controllers/Show.php
new file mode 100644
index 0000000..4768f9f
--- /dev/null
+++ b/dayrui/App/News/Controllers/Show.php
@@ -0,0 +1,58 @@
+_module_init();
+ $this->_Show(
+ (int)\Phpcmf\Service::L('Input')->get('id'),
+ [
+ 'field' => dr_safe_replace(\Phpcmf\Service::L('Input')->get('field')),
+ 'value' => dr_safe_replace(\Phpcmf\Service::L('Input')->get('value')),
+ ],
+ max(1, (int)\Phpcmf\Service::L('Input')->get('page'))
+ );
+ }
+
+ public function time() {
+ $this->_module_init();
+ $this->_MyShow(
+ 'time',
+ (int)\Phpcmf\Service::L('Input')->get('id'),
+ max(1, (int)\Phpcmf\Service::L('Input')->get('page'))
+ );
+ }
+
+ public function recycle() {
+ $this->_module_init();
+ $this->_MyShow(
+ 'recycle',
+ (int)\Phpcmf\Service::L('Input')->get('id'),
+ max(1, (int)\Phpcmf\Service::L('Input')->get('page'))
+ );
+ }
+
+ public function draft() {
+ $this->_module_init();
+ $this->_MyShow(
+ 'draft',
+ (int)\Phpcmf\Service::L('Input')->get('id'),
+ max(1, (int)\Phpcmf\Service::L('Input')->get('page'))
+ );
+ }
+
+ public function verify() {
+ $this->_module_init();
+ $this->_MyShow(
+ 'verify',
+ (int)\Phpcmf\Service::L('Input')->get('id'),
+ max(1, (int)\Phpcmf\Service::L('Input')->get('page'))
+ );
+ }
+
+}
diff --git a/dayrui/App/Pay/Config/App.php b/dayrui/App/Pay/Config/App.php
new file mode 100644
index 0000000..a1db58a
--- /dev/null
+++ b/dayrui/App/Pay/Config/App.php
@@ -0,0 +1,10 @@
+ 'app',
+ 'name' => '鏀粯',
+ 'author' => '杩呯澘浜戣蒋浠',
+ 'icon' => 'fa fa-rmb',
+
+];
\ No newline at end of file
diff --git a/dayrui/App/Pay/Config/Before.php b/dayrui/App/Pay/Config/Before.php
new file mode 100644
index 0000000..4d046ba
--- /dev/null
+++ b/dayrui/App/Pay/Config/Before.php
@@ -0,0 +1,11 @@
+鎻掍欢');
+//}
+
+return dr_return_data(1, 'ok');
diff --git a/dayrui/App/Pay/Config/Cache.php b/dayrui/App/Pay/Config/Cache.php
new file mode 100644
index 0000000..05de927
--- /dev/null
+++ b/dayrui/App/Pay/Config/Cache.php
@@ -0,0 +1,14 @@
+ 椤圭洰鐩綍
+ *
+ **/
+
+return [
+
+ //'妯″瀷鏂囦欢鍚',
+
+];
\ No newline at end of file
diff --git a/dayrui/App/Pay/Config/Cron.php b/dayrui/App/Pay/Config/Cron.php
new file mode 100644
index 0000000..36edf75
--- /dev/null
+++ b/dayrui/App/Pay/Config/Cron.php
@@ -0,0 +1,16 @@
+ 3600 * 24 * 3) {
+ // 鏈粯娆剧殑娓呯悊
+ \Phpcmf\Service::M('pay', 'pay')->clear_paylog();
+ file_put_contents(WRITEPATH.'config/run_auto_pay_time.php', SYS_TIME);
+}
diff --git a/dayrui/App/Pay/Config/Filters.php b/dayrui/App/Pay/Config/Filters.php
new file mode 100644
index 0000000..1288ab8
--- /dev/null
+++ b/dayrui/App/Pay/Config/Filters.php
@@ -0,0 +1,13 @@
+ [
+ 'pay/home/ajax'
+ ],
+
+];
\ No newline at end of file
diff --git a/dayrui/App/Pay/Config/Install.php b/dayrui/App/Pay/Config/Install.php
new file mode 100644
index 0000000..bdff949
--- /dev/null
+++ b/dayrui/App/Pay/Config/Install.php
@@ -0,0 +1,49 @@
+install_schema([
+ 'tables' => [
+ 'member_setting' => [
+ 'comment' => '鐢ㄦ埛灞炴у弬鏁拌〃',
+ 'fields' => [
+ 'name' => 'varchar(50) NOT NULL',
+ 'value' => 'mediumtext NOT NULL',
+ ],
+ 'indexes' => [
+ 'PRIMARY KEY (`name`)',
+ ],
+ ],
+ 'member_paylog' => [
+ 'comment' => '鐢ㄦ埛鏀粯璁板綍琛',
+ 'fields' => [
+ 'id' => 'bigint(18) unsigned NOT NULL AUTO_INCREMENT',
+ 'site' => 'int(10) NOT NULL COMMENT \'绔欑偣\'',
+ 'mid' => 'varchar(100) NOT NULL COMMENT \'鏀粯鏍囪瘑\'',
+ 'uid' => 'int(10) unsigned NOT NULL COMMENT \'浠樻浜篭'',
+ 'touid' => 'int(10) unsigned DEFAULT 0 COMMENT \'鏀舵浜篭'',
+ 'title' => 'varchar(255) NOT NULL COMMENT \'鏀粯鏍囬\'',
+ 'url' => 'varchar(255) NOT NULL COMMENT \'鐩稿叧閾炬帴\'',
+ 'value' => 'decimal(10,2) NOT NULL COMMENT \'鏀粯閲戦\'',
+ 'money' => 'decimal(10,2) NOT NULL COMMENT \'浣欓\'',
+ 'type' => 'varchar(20) NOT NULL COMMENT \'鏀粯鏂瑰紡\'',
+ 'status' => 'tinyint(1) unsigned NOT NULL COMMENT \'鏀粯鐘舵乗'',
+ 'result' => 'text NOT NULL COMMENT \'鏀粯缁撴灉\'',
+ 'paytime' => 'int(10) unsigned NOT NULL COMMENT \'鏀粯鏃堕棿\'',
+ 'inputtime' => 'int(10) unsigned NOT NULL COMMENT \'鍒涘缓鏃堕棿\'',
+ ],
+ 'indexes' => [
+ 'PRIMARY KEY (`id`)',
+ 'KEY `uid` (`uid`)',
+ 'KEY `touid` (`touid`)',
+ 'KEY `mid` (`mid`)',
+ 'KEY `status` (`status`)',
+ 'KEY `value` (`value`)',
+ 'KEY `paytime` (`paytime`)',
+ 'KEY `inputtime` (`inputtime`)',
+ ],
+ ],
+ ],
+ 'seeds' => [],
+]);
+if (empty($rt['code'])) {
+ log_message('error', 'Pay install_schema: '.($rt['msg'] ?? ''));
+ return dr_return_data(0, dr_lang('瀹夎澶辫触').'锛'.($rt['msg'] ?? ''));
+}
diff --git a/dayrui/App/Pay/Config/Install.sql b/dayrui/App/Pay/Config/Install.sql
new file mode 100644
index 0000000..e69de29
diff --git a/dayrui/App/Pay/Config/Menu.php b/dayrui/App/Pay/Config/Menu.php
new file mode 100644
index 0000000..a03252c
--- /dev/null
+++ b/dayrui/App/Pay/Config/Menu.php
@@ -0,0 +1,95 @@
+ [
+
+
+
+ 'app-pay' => [
+ 'name' => '鏀粯',
+ 'icon' => 'fa fa-rmb',
+ 'left' => [
+ 'app-pay-list' => [
+ 'name' => '鏀粯绠$悊',
+ 'icon' => 'fa fa-rmb',
+ 'link' => [
+ [
+ 'name' => '宸蹭粯娴佹按',
+ 'icon' => 'fa fa-calendar-check-o',
+ 'uri' => 'pay/paylog/index',
+ 'displayorder' => '-1',
+ ],
+ [
+ 'name' => '鏈粯娴佹按',
+ 'icon' => 'fa fa-calendar-times-o',
+ 'uri' => 'pay/paylog/not_index',
+ 'displayorder' => '-1',
+ ],
+ [
+ 'name' => '鍚庡彴鍏呭',
+ 'icon' => 'fa fa-plus',
+ 'uri' => 'pay/pay/index',
+ 'displayorder' => '-1',
+ ],
+ ]
+ ],
+
+ 'app-config-pay' => [
+ 'name' => '鏀粯璁剧疆',
+ 'icon' => 'fa fa-rmb',
+ 'link' => [
+ [
+ 'name' => '鏀粯璁剧疆',
+ 'icon' => 'fa fa-cog',
+ 'uri' => 'pay/payconfig/index',
+ ],
+ [
+ 'name' => '鏀粯鎺ュ彛',
+ 'icon' => 'fa fa-code',
+ 'uri' => 'pay/payapi/index',
+ ],
+ ],
+ ],
+
+ ],
+ ],
+
+
+
+
+ ],
+
+ 'member' => [
+
+
+
+ 'app-pay' => [
+ 'name' => '鏀粯绠$悊',
+ 'icon' => 'fa fa-rmb',
+ 'link' => [
+ [
+ 'name' => '鍦ㄧ嚎鍏呭',
+ 'icon' => 'fa fa-rmb',
+ 'uri' => 'pay/recharge/index',
+ 'displayorder' => '-1',
+ ],
+ [
+ 'name' => '鎴戠殑浜ゆ槗',
+ 'icon' => 'fa fa-calendar',
+ 'uri' => 'pay/paylog/index',
+ 'displayorder' => '-1',
+ ],
+ ],
+ ],
+
+ ],
+
+
+
+];
\ No newline at end of file
diff --git a/dayrui/App/Pay/Config/Notice.php b/dayrui/App/Pay/Config/Notice.php
new file mode 100644
index 0000000..5fadc10
--- /dev/null
+++ b/dayrui/App/Pay/Config/Notice.php
@@ -0,0 +1,20 @@
+ 鍔ㄤ綔鍚嶇О
+ *
+ **/
+
+return [
+
+ 'pay_success' => '鍓嶅彴鍏呭/浠樻',
+ 'pay_admin' => '鍚庡彴绠$悊鍛樺厖鍊',
+
+];
\ No newline at end of file
diff --git a/dayrui/App/Pay/Config/Routes.php b/dayrui/App/Pay/Config/Routes.php
new file mode 100644
index 0000000..ef3217b
--- /dev/null
+++ b/dayrui/App/Pay/Config/Routes.php
@@ -0,0 +1,4 @@
+drop_table(\Phpcmf\Service::M()->dbprefix('member_paylog'), true);
diff --git a/dayrui/App/Pay/Config/Uninstall.sql b/dayrui/App/Pay/Config/Uninstall.sql
new file mode 100644
index 0000000..e69de29
diff --git a/dayrui/App/Pay/Config/Update.php b/dayrui/App/Pay/Config/Update.php
new file mode 100644
index 0000000..62f5795
--- /dev/null
+++ b/dayrui/App/Pay/Config/Update.php
@@ -0,0 +1,12 @@
+dbprefix('member_paylog');
+if (\Phpcmf\Service::M()->is_table_exists($table)) {
+ if (!\Phpcmf\Service::M()->is_field_exists($table, 'money')) {
+ \Phpcmf\Service::M('table')->add_field($table, 'money', 'decimal(10,2)', 'NOT NULL', '浣欓');
+ }
+}
diff --git a/dayrui/App/Pay/Config/Version.php b/dayrui/App/Pay/Config/Version.php
new file mode 100644
index 0000000..4f9857c
--- /dev/null
+++ b/dayrui/App/Pay/Config/Version.php
@@ -0,0 +1,13 @@
+ '777',
+ 'vip' => '',
+ 'cms' => '4.7.3',
+ 'version' => '2.5',
+ 'license' => '375C71349B295FBE2DCDCA9206F20A1703',
+ 'updatetime' => '2026-08-04 07:49:13',
+ 'downtime' => '2026-08-08 00:54:28',
+
+];
diff --git a/dayrui/App/Pay/Controllers/Admin/Pay.php b/dayrui/App/Pay/Controllers/Admin/Pay.php
new file mode 100644
index 0000000..c275a27
--- /dev/null
+++ b/dayrui/App/Pay/Controllers/Admin/Pay.php
@@ -0,0 +1,222 @@
+sys_field(['uid']);
+ $fdata['uid']['name'] = dr_lang('鐢ㄦ埛璐﹀彿');
+ \Phpcmf\Service::V()->assign([
+ 'form' => dr_form_hidden(),
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '鐢ㄦ埛鍏呭' => ['pay/pay/index', 'fa fa-rmb'],
+ '璧勯噾鍐荤粨' => ['pay/pay/freeze_index', 'bi bi-dash-circle-fill'],
+ 'help' => [ 600 ],
+ ]
+ ),
+ 'myfield' => dr_rp(\Phpcmf\Service::L('Field')->toform(0, $fdata), 'width:100%;', 'width:300px;'),
+ ]);
+ }
+
+ public function index() {
+
+ if (IS_AJAX_POST) {
+ $post = \Phpcmf\Service::L('input')->post('data');
+ if (!$post['uid']) {
+ $this->_json(0, dr_lang('璐﹀彿涓嶈兘涓虹┖'), ['field' => 'uid']);
+ }
+ $user = \Phpcmf\Service::M()->db->table('member')->where('username', $post['uid'])->get()->getRowArray();
+ if (!$user) {
+ $this->_json(0, dr_lang('璐﹀彿[%s]涓嶅瓨鍦', $post['uid']), ['field' => 'uid']);
+ } elseif (!$post['value']) {
+ $this->_json(0, dr_lang('閲戦鍊兼湭濉啓'), ['field' => 'value']);
+ } elseif (!$post['unit']) {
+ $this->_json(0, dr_lang('鍏呭肩被鍨嬫湭閫夋嫨'), ['field' => 'unit']);
+ } elseif (!$post['note']) {
+ $this->_json(0, dr_lang('澶囨敞璇存槑鏈~鍐'), ['field' => 'note']);
+ }
+ if ($post['type'] == 1) {
+ // 澧炲姞
+ $post['value'] = abs($post['value']);
+ $msg = '鍏呭%s鎴愬姛';
+ } else {
+ // 鍑忓皯
+ $post['value'] = abs($post['value']) * -1;
+ $msg = '鎵e噺%s鎴愬姛';
+ }
+ if ($post['unit'] == 1) {
+ // 绉垎
+ if ($user['score'] + $post['value'] < 0) {
+ $this->_json(0, dr_lang('璐﹀彿%s涓嶈冻', SITE_SCORE), ['field' => 'value']);
+ }
+ // 浠樻鏂圭殑閽
+ $rt = \Phpcmf\Service::M('member')->add_score($user['id'], $post['value'], $post['note']);
+ if (!$rt['code']) {
+ $this->_json(0, $rt['msg']);
+ }
+ $this->_json(1, dr_lang($msg, SITE_SCORE.$post['value']));
+ } elseif ($post['unit'] == 3) {
+ // 鍗囩骇鍊
+ if ($user['experience'] + $post['value'] < 0) {
+ $this->_json(0, dr_lang('璐﹀彿%s涓嶈冻', SITE_EXPERIENCE), ['field' => 'value']);
+ }
+ // 浠樻鏂圭殑閽
+ $rt = \Phpcmf\Service::M('member')->add_experience($user['id'], $post['value'], $post['note']);
+ if (!$rt['code']) {
+ $this->_json(0, $rt['msg']);
+ }
+ $this->_json(1, dr_lang($msg, SITE_EXPERIENCE.$post['value']));
+ } else {
+ // rmb
+ if ($user['money'] + $post['value'] < 0) {
+ $this->_json(0, dr_lang('璐﹀彿浣欓涓嶈冻'), ['field' => 'value']);
+ }
+ // 浠樻鏂圭殑閽
+ $rt = \Phpcmf\Service::M('Pay')->add_money($user['id'], $post['value']);
+ if (!$rt['code']) {
+ $this->_json(0, $rt['msg']);
+ }
+ // 澧炲姞鍒颁氦鏄撴祦姘
+ $rt = \Phpcmf\Service::M('Pay')->add_paylog([
+ 'uid' => $user['id'],
+ 'touid' => $user['id'],
+ 'mid' => 'system',
+ 'title' => dr_lang('鍚庡彴鍏呭'),
+ 'value' => $post['value'],
+ 'type' => 'system',
+ 'status' => 1,
+ 'result' => $post['note'],
+ 'paytime' => SYS_TIME,
+ 'inputtime' => SYS_TIME,
+ ]);
+ if (!$rt['code']) {
+ $this->_json(0, $rt['msg']);
+ }
+ $call = [
+ 'uid' => $user['id'],
+ 'username' => $user['username'],
+ 'email' => $user['email'],
+ 'phone' => $user['phone'],
+ 'value' => $post['value'],
+ 'url' => \Phpcmf\Service::L('Router')->member_url('pay/paylog/show', ['id' => $rt['code']]),
+ 'result' => $post['note'],
+ ];
+ // 閫氱煡
+ \Phpcmf\Service::L('Notice')->send_notice('pay_admin', $call);
+ // 閽╁瓙
+ \Phpcmf\Hooks::trigger('pay_admin_after', $call);
+ $this->_json(1, dr_lang($msg, 'RMB'.$post['value']));
+ }
+ }
+
+ \Phpcmf\Service::V()->display('pay.html');
+ }
+
+ public function freeze_index() {
+
+ if (IS_AJAX_POST) {
+ $post = \Phpcmf\Service::L('input')->post('data');
+ if (!$post['uid']) {
+ $this->_json(0, dr_lang('璐﹀彿涓嶈兘涓虹┖'), ['field' => 'uid']);
+ }
+ $user = \Phpcmf\Service::M()->db->table('member')->where('username', $post['uid'])->get()->getRowArray();
+ if (!$user) {
+ $this->_json(0, dr_lang('璐﹀彿[%s]涓嶅瓨鍦', $post['uid']), ['field' => 'uid']);
+ } elseif (!$post['note']) {
+ $this->_json(0, dr_lang('澶囨敞璇存槑鏈~鍐'), ['field' => 'note']);
+ }
+
+ $post['value'] = abs($post['value']);
+ if ($post['type'] == 1) {
+ // 鍐荤粨
+ if (!$post['value']) {
+ $this->_json(0, dr_lang('閲戦鍊兼湭濉啓'), ['field' => 'value']);
+ } elseif ($user['money'] - $post['value'] < 0) {
+ $this->_json(0, dr_lang('璐﹀彿鍙敤閲戦涓嶈冻'), ['field' => 'value']);
+ }
+ \Phpcmf\Service::M('member')->add_freeze($user['id'], $post['value']);
+ // 澧炲姞鍒颁氦鏄撴祦姘
+ $rt = \Phpcmf\Service::M('Pay')->add_paylog([
+ 'uid' => $user['id'],
+ 'touid' => $user['id'],
+ 'mid' => 'admin-freeze',
+ 'title' => '鍚庡彴鍐荤粨璧勯噾',
+ 'value' => -$post['value'],
+ 'type' => 'system',
+ 'status' => 1,
+ 'result' => $post['note'],
+ 'paytime' => SYS_TIME,
+ 'inputtime' => SYS_TIME,
+ ]);
+ $msg = '鍐荤粨%s鎴愬姛';
+ } elseif ($post['type'] == 0) {
+ // 瑙e喕
+ if (!$post['value']) {
+ $this->_json(0, dr_lang('閲戦鍊兼湭濉啓'), ['field' => 'value']);
+ } elseif ($user['freeze'] - $post['value'] < 0) {
+ $this->_json(0, dr_lang('璐﹀彿鍙敤鍐荤粨閲戦涓嶈冻'), ['field' => 'value']);
+ }
+ \Phpcmf\Service::M('member')->cancel_freeze($user['id'], $post['value']);
+ // 澧炲姞鍒颁氦鏄撴祦姘
+ $rt = \Phpcmf\Service::M('Pay')->add_paylog([
+ 'uid' => $user['id'],
+ 'touid' => $user['id'],
+ 'mid' => 'admin-freeze',
+ 'title' => '鍚庡彴瑙e喕璧勯噾',
+ 'value' => abs($post['value']),
+ 'type' => 'system',
+ 'status' => 1,
+ 'result' => $post['note'],
+ 'paytime' => SYS_TIME,
+ 'inputtime' => SYS_TIME,
+ ]);
+ $msg = '瑙e喕%s鎴愬姛';
+ } else {
+ // 鎸囧畾浠绘剰鍊
+ \Phpcmf\Service::M()->table('member')->update($user['id'], ['freeze' => $post['value'] ]);
+ // 澧炲姞鍒颁氦鏄撴祦姘
+ $rt = \Phpcmf\Service::M('Pay')->add_paylog([
+ 'uid' => $user['id'],
+ 'touid' => $user['id'],
+ 'mid' => 'admin-freeze',
+ 'title' => '鍚庡彴璁剧疆鎸囧畾鍐荤粨璧勯噾',
+ 'value' => abs($post['value']),
+ 'type' => 'system',
+ 'status' => 1,
+ 'result' => $post['note'],
+ 'paytime' => SYS_TIME,
+ 'inputtime' => SYS_TIME,
+ ]);
+ $msg = '璁剧疆鎸囧畾鍐荤粨璧勯噾%s';
+ }
+
+ if (!$rt['code']) {
+ $this->_json(0, $rt['msg']);
+ }
+ $call = [
+ 'uid' => $user['id'],
+ 'username' => $user['username'],
+ 'email' => $user['email'],
+ 'phone' => $user['phone'],
+ 'value' => $post['value'],
+ 'url' => \Phpcmf\Service::L('Router')->member_url('pay/paylog/show', ['id' => $rt['code']]),
+ 'result' => $post['note'],
+ ];
+ // 閫氱煡
+ \Phpcmf\Service::L('Notice')->send_notice('pay_admin_freeze', $call);
+ // 閽╁瓙
+ \Phpcmf\Hooks::trigger('pay_admin_freeze', $call);
+ $this->_json(1, dr_lang($msg, abs($post['value'])));
+
+ }
+
+ \Phpcmf\Service::V()->display('pay_freeze.html');
+ }
+
+}
diff --git a/dayrui/App/Pay/Controllers/Admin/Payapi.php b/dayrui/App/Pay/Controllers/Admin/Payapi.php
new file mode 100644
index 0000000..dfd6535
--- /dev/null
+++ b/dayrui/App/Pay/Controllers/Admin/Payapi.php
@@ -0,0 +1,129 @@
+db->table('member_setting')->where('name', 'payapi')->get()->getRowArray();
+ $data = dr_string2array($data['value']);
+
+ if (IS_AJAX_POST) {
+ $post = \Phpcmf\Service::L('input')->post('data');
+
+ \Phpcmf\Service::M()->db->table('member_setting')->replace([
+ 'name' => 'payapi',
+ 'value' => dr_array2string($post)
+ ]);
+ \Phpcmf\Service::M('cache')->sync_cache('member'); // 鑷姩鏇存柊缂撳瓨
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ $local = dr_dir_map(ROOTPATH.'api/pay/', 1);
+ foreach ($local as $dir) {
+ if ($dir != 'finecms' && is_file(ROOTPATH.'api/pay/'.$dir.'/config.php')) {
+ $config = require ROOTPATH.'api/pay/'.$dir.'/config.php';
+ if ($data[$dir]) {
+ $data[$dir]['config'] = $config;
+ } else {
+ $data[$dir] = [
+ 'config' => $config,
+ ];
+ }
+ }
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'data' => $data,
+ 'form' => dr_form_hidden(),
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '鏀粯鎺ュ彛' => ['pay/payapi/index', 'fa fa-code'],
+ 'help' => [387]
+ ]
+ ),
+ ]);
+ \Phpcmf\Service::V()->display('payapi.html');
+ }
+
+ /**
+ * 妫娴嬪井淇¢娆 API 璇佷功鏄惁鍙敤
+ */
+ public function check_cert() {
+
+ $cert = trim((string)\Phpcmf\Service::L('input')->get('sslcert_path'));
+ $key = trim((string)\Phpcmf\Service::L('input')->get('sslkey_path'));
+
+ $default_cert = ROOTPATH.'api/pay/weixin/cert/apiclient_cert.pem';
+ $default_key = ROOTPATH.'api/pay/weixin/cert/apiclient_key.pem';
+
+ if ($cert === '') {
+ $row = \Phpcmf\Service::M()->db->table('member_setting')->where('name', 'payapi')->get()->getRowArray();
+ $payapi = dr_string2array($row['value']);
+ if (!empty($payapi['weixin']['sslcert_path'])) {
+ $cert = $payapi['weixin']['sslcert_path'];
+ }
+ }
+ if ($key === '') {
+ if (!isset($payapi)) {
+ $row = \Phpcmf\Service::M()->db->table('member_setting')->where('name', 'payapi')->get()->getRowArray();
+ $payapi = dr_string2array($row['value']);
+ }
+ if (!empty($payapi['weixin']['sslkey_path'])) {
+ $key = $payapi['weixin']['sslkey_path'];
+ }
+ }
+
+ if ($cert === '') {
+ $cert = $default_cert;
+ }
+ if ($key === '') {
+ $key = $default_key;
+ }
+
+ $errors = [];
+ if (!is_file($cert)) {
+ $errors[] = dr_lang('璇佷功鏂囦欢涓嶅瓨鍦').'锛'.$cert;
+ } elseif (!is_readable($cert)) {
+ $errors[] = dr_lang('璇佷功鏂囦欢涓嶅彲璇').'锛'.$cert;
+ } else {
+ $cert_body = (string)@file_get_contents($cert);
+ if (strpos($cert_body, 'BEGIN CERTIFICATE') === false) {
+ $errors[] = dr_lang('璇佷功鏂囦欢涓嶆槸鏈夋晥鐨 PEM 鏍煎紡').'锛'.$cert;
+ } elseif (function_exists('openssl_x509_read')) {
+ $x509 = @openssl_x509_read($cert_body);
+ if (!$x509) {
+ $errors[] = dr_lang('璇佷功鏂囦欢鏃犳硶琚 OpenSSL 瑙f瀽').'锛'.$cert;
+ }
+ }
+ }
+
+ if (!is_file($key)) {
+ $errors[] = dr_lang('瀵嗛挜鏂囦欢涓嶅瓨鍦').'锛'.$key;
+ } elseif (!is_readable($key)) {
+ $errors[] = dr_lang('瀵嗛挜鏂囦欢涓嶅彲璇').'锛'.$key;
+ } else {
+ $key_body = (string)@file_get_contents($key);
+ if (strpos($key_body, 'PRIVATE KEY') === false) {
+ $errors[] = dr_lang('瀵嗛挜鏂囦欢涓嶆槸鏈夋晥鐨 PEM 鏍煎紡').'锛'.$key;
+ } elseif (function_exists('openssl_pkey_get_private')) {
+ $pkey = @openssl_pkey_get_private($key_body);
+ if (!$pkey) {
+ $errors[] = dr_lang('瀵嗛挜鏂囦欢鏃犳硶琚 OpenSSL 瑙f瀽').'锛'.$key;
+ }
+ }
+ }
+
+ if ($errors) {
+ $this->_json(0, implode('
', $errors));
+ }
+
+ $this->_json(1, dr_lang('璇佷功鍙敤').'锛'.$cert.' / '.$key);
+ }
+
+}
diff --git a/dayrui/App/Pay/Controllers/Admin/Payconfig.php b/dayrui/App/Pay/Controllers/Admin/Payconfig.php
new file mode 100644
index 0000000..3cf5874
--- /dev/null
+++ b/dayrui/App/Pay/Controllers/Admin/Payconfig.php
@@ -0,0 +1,43 @@
+db->table('member_setting')->where('name', 'pay')->get()->getRowArray();
+ $data = dr_string2array($data['value']);
+
+ if (IS_AJAX_POST) {
+ $post = \Phpcmf\Service::L('input')->post('data', true);
+ \Phpcmf\Service::M()->db->table('member_setting')->replace([
+ 'name' => 'pay',
+ 'value' => dr_array2string($post)
+ ]);
+ \Phpcmf\Service::M('cache')->sync_cache('member'); // 鑷姩鏇存柊缂撳瓨
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ $page = intval(\Phpcmf\Service::L('input')->get('page'));
+
+ \Phpcmf\Service::V()->assign([
+ 'data' => $data,
+ 'page' => $page,
+ 'form' => dr_form_hidden(['page' => $page]),
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '鏀粯璁剧疆' => ['pay/payconfig/index', 'fa fa-cog'],
+ 'help' => [625],
+ ]
+ )
+ ]);
+ \Phpcmf\Service::V()->display('payconfig.html');
+ }
+
+
+}
diff --git a/dayrui/App/Pay/Controllers/Admin/Paylog.php b/dayrui/App/Pay/Controllers/Admin/Paylog.php
new file mode 100644
index 0000000..52a9708
--- /dev/null
+++ b/dayrui/App/Pay/Controllers/Admin/Paylog.php
@@ -0,0 +1,228 @@
+is_data = 0;
+ // 妯℃澘鍓嶇紑(閬垮厤娣锋穯)
+ $this->my_field = array(
+ 'title' => array(
+ 'ismain' => 1,
+ 'name' => dr_lang('鍏抽敭瀛'),
+ 'fieldname' => 'title',
+ 'fieldtype' => 'Text',
+ 'setting' => array(
+ 'option' => array(
+ 'width' => 200,
+ ),
+ )
+ ),
+ 'touid' => array(
+ 'ismain' => 1,
+ 'name' => dr_lang('鏀舵浜'),
+ 'fieldname' => 'touid',
+ 'fieldtype' => 'Uid',
+ 'setting' => array(
+ 'option' => array(
+ 'width' => 200,
+ ),
+ )
+ ),
+ 'uid' => array(
+ 'ismain' => 1,
+ 'isint' => 1,
+ 'name' => dr_lang('浠樻浜'),
+ 'fieldname' => 'uid',
+ 'fieldtype' => 'Uid',
+ 'setting' => array(
+ 'option' => array(
+ 'width' => 200,
+ ),
+ )
+ ),
+ );
+ // 琛ㄥ崟鏄剧ず鍚嶇О
+ $this->name = dr_lang('璧勯噾娴佹按');
+ // 鍒濆鍖栨暟鎹〃
+ $this->_init([
+ 'table' => 'member_paylog',
+ 'field' => $this->my_field,
+ 'order_by' => 'inputtime desc',
+ 'date_field' => 'inputtime',
+ ]);
+ \Phpcmf\Service::V()->assign([
+ 'field' => $this->my_field,
+ ]);
+ }
+
+ // index
+ public function index() {
+ \Phpcmf\Service::M()->set_where_list('`status`=1');
+ $this->_List();
+ \Phpcmf\Service::V()->assign([
+ 'not_pay' => 1,
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '宸蹭粯娴佹按' => [ 'pay/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-calendar'],
+ 'help' => [ 594 ],
+ ]
+ ),
+ ]);
+ \Phpcmf\Service::V()->display('paylog_list.html');
+ }
+
+ // index
+ public function not_index() {
+ \Phpcmf\Service::M()->set_where_list('`status`=0');
+ $this->_List();
+ \Phpcmf\Service::V()->assign([
+ 'not_pay' => 1,
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '鏈粯娴佹按' => ['pay/'.\Phpcmf\Service::L('Router')->class.'/not_index', 'fa fa-calendar'],
+ 'help' => [ 595 ],
+ ]
+ ),
+ ]);
+ \Phpcmf\Service::V()->display('paylog_list.html');
+ }
+
+ // edit
+ public function edit() {
+ list($tpl, $data) = $this->_Post((int)\Phpcmf\Service::L('input')->get('id'), [], 1);
+ if (!$data) {
+ $this->_admin_msg(0, dr_lang('鏀粯璁板綍涓嶅瓨鍦'));
+ }
+ if (!$data['status']) {
+ \Phpcmf\Service::V()->assign([
+ 'data' => $data,
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '鏈粯娴佹按' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/not_index', 'fa fa-calendar'],
+ '浠樻璇︽儏' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/edit', 'fa fa-edit'],
+ ]
+ ),
+ 'reply_url' => str_replace('m=index', 'm=not_index', \Phpcmf\Service::V()->get_value('reply_url'))
+ ]);
+ } else {
+ \Phpcmf\Service::V()->assign([
+ 'data' => $data,
+ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
+ [
+ '宸蹭粯娴佹按' => [ 'pay/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-calendar'],
+ 'help' => [ 594 ],
+ ]
+ ),
+ ]);
+ }
+
+ \Phpcmf\Service::V()->display('paylog_edit.html');
+ }
+
+ // 绯荤粺鍥炴敹
+ public function system_edit() {
+
+ $id = (int)\Phpcmf\Service::L('input')->get('id');
+ $data = \Phpcmf\Service::M('Pay')->table('member_paylog')->get($id);
+ if (!$data) {
+ $this->_json(0, dr_lang('鏀粯璁板綍涓嶅瓨鍦'));
+ } elseif (1 != $data['status']) {
+ $this->_json(0, dr_lang('鏀粯璁板綍涓嶆弧瓒冲洖鏀舵潯浠'));
+ } elseif ($data['value'] < 0) {
+ $this->_json(0, dr_lang('浠樻閲戦涓嶆弧瓒冲洖鏀舵潯浠'));
+ } elseif ($data['mid'] != 'recharge') {
+ $this->_json(0, dr_lang('鍙兘鍥炴敹鍏呭奸噾棰'));
+ } elseif (\Phpcmf\Service::M()->table('member_paylog')->where('mid', 'system-recovery-'.$id)->counts()) {
+ $this->_json(0, dr_lang('姝や氦鏄撳凡缁忚鍥炴敹杩'));
+ }
+
+ $user = \Phpcmf\Service::M('member')->table('member')->get($data['uid']);
+ if (!$user) {
+ $this->_json(0, dr_lang('鐢ㄦ埛璁板綍涓嶅瓨鍦'));
+ }
+
+ if (IS_AJAX_POST) {
+ $post = \Phpcmf\Service::L('input')->post('data');
+ if ($user['money'] - $data['value'] < 0) {
+ $this->_json(0, dr_lang('浠樻璐﹀彿浣欓涓嶈冻'));
+ } elseif (!$post['note']) {
+ $this->_json(0, dr_lang('鍥炴敹澶囨敞涓瀹氳濉啓'), ['field' => 'note']);
+ }
+ // 鎵i櫎浠樻鏂圭殑閽
+ $rt = \Phpcmf\Service::M('Pay')->add_money($data['uid'], -$data['value']);
+ if (!$rt['code']) {
+ $this->_json(0, $rt['msg']);
+ }
+ // 澧炲姞鍒颁氦鏄撴祦姘
+ $rt = \Phpcmf\Service::M('Pay')->add_paylog([
+ 'uid' => $data['uid'],
+ 'touid' => 0,
+ 'mid' => 'system-recovery-'.$id,
+ 'title' => dr_lang('绯荤粺鍥炴敹'),
+ 'value' => -$data['value'],
+ 'type' => 'finecms',
+ 'status' => 1,
+ 'result' => $post['note'],
+ 'paytime' => SYS_TIME,
+ 'inputtime' => SYS_TIME,
+ ]);
+ if (!$rt['code']) {
+ $this->_json(0, $rt['msg']);
+ }
+ $this->_json(1, dr_lang('鎿嶄綔鎴愬姛'));
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'data' => $data,
+ 'user' => $user,
+ 'form' => dr_form_hidden(),
+ ]);
+ \Phpcmf\Service::V()->display('paylog_system.html');exit;
+ }
+
+ // 鐭俊鍌粯
+ public function notice_del() {
+
+ $ids = \Phpcmf\Service::L('input')->get_post_ids();
+ if (!$ids) {
+ $this->_json(0, dr_lang('鎵閫夋暟鎹笉瀛樺湪'));
+ }
+
+ $sql = 'select phone from `'.\Phpcmf\Service::M()->dbprefix('member').'` where `id` in (select `uid` from `'.\Phpcmf\Service::M()->dbprefix('member_paylog').'` where `id` in ('.implode(',', $ids).') )';
+ $data = \Phpcmf\Service::M()->db->query($sql)->getResultArray();
+ if (!$data) {
+ $this->_json(0, dr_lang('鎵閫夋暟鎹笉瀛樺湪'));
+ }
+
+ $i = 0;
+ foreach ($data as $t) {
+ $rt = \Phpcmf\Service::M('member')->sendsms_text($t['phone'], dr_lang('鎮ㄨ繕鏈夋湭浠樻鐨勪氦鏄擄紝璇峰敖蹇粯娆撅紱鑻ュ凡浠橈紝璇峰拷鐣ユ娑堟伅'));
+ if ($rt['code']) {
+ $i ++;
+ }
+ }
+
+ $this->_json(1, dr_lang('宸插彂閫佺粰%s涓敤鎴', $i));
+ }
+
+ // 鍒犻櫎
+ public function del() {
+ $this->_Del(
+ \Phpcmf\Service::L('input')->get_post_ids(),
+ null,
+ null,
+ \Phpcmf\Service::M()->dbprefix($this->init['table'])
+ );
+ }
+
+}
diff --git a/dayrui/App/Pay/Controllers/Buy.php b/dayrui/App/Pay/Controllers/Buy.php
new file mode 100644
index 0000000..f5ce5de
--- /dev/null
+++ b/dayrui/App/Pay/Controllers/Buy.php
@@ -0,0 +1,53 @@
+get('id');
+ if (!$id) {
+ $this->_msg(0, dr_lang('鍟嗗搧id鍙傛暟涓嶈兘涓虹┖'));
+ }
+
+ $fid = (int)\Phpcmf\Service::L('input')->get('fid');
+ if (!$fid) {
+ $this->_msg(0, dr_lang('鏀粯瀛楁fid鍙傛暟涓嶈兘涓虹┖'));
+ }
+
+ $num = max(1, (int)\Phpcmf\Service::L('input')->get('num'));
+ $sku = dr_safe_replace(\Phpcmf\Service::L('input')->get('sku'), 'undefined');
+
+ $field = $this->get_cache('table-field', $fid);
+ if (!$field) {
+ $this->_msg(0, dr_lang('鏀粯瀛楁[%s]涓嶅瓨鍦', $fid));
+ }
+
+ // 鑾峰彇浠樻浠锋牸
+ $rt = \Phpcmf\Service::M('pay', 'pay')->get_pay_info($id, $field, $num, $sku);
+ if (isset($rt['code']) && !$rt['code']) {
+ $this->_msg(0, $rt['msg']);
+ }
+
+ // 鎸傞挬鐐 璐拱鍟嗗搧涔嬪墠
+ \Phpcmf\Hooks::trigger('member_buy_before', $rt);
+
+ \Phpcmf\Service::V()->assign($rt);
+ \Phpcmf\Service::V()->assign([
+ 'num' => $rt['num'],
+ 'price' => $rt['price'],
+ 'total' => $rt['total'],
+ 'total_price' => $rt['total'],
+ 'payform' => dr_payform($rt['mid'], $rt['total'], $rt['title'].$rt['sku_string'], $rt['url']),
+ 'meta_title' => dr_lang('鍦ㄧ嚎浠樻').SITE_SEOJOIN.SITE_NAME,
+ 'meta_keywords' => $this->get_cache('site', SITE_ID, 'config', 'SITE_KEYWORDS'),
+ 'meta_description' => $this->get_cache('site', SITE_ID, 'config', 'SITE_DESCRIPTION')
+ ]);
+ \Phpcmf\Service::V()->module('pay');
+ if (!is_file(\Phpcmf\Service::V()->get_dir().'buy.html')) {
+ \Phpcmf\Service::V()->module('api');
+ }
+ \Phpcmf\Service::V()->display('buy.html');
+ }
+}
diff --git a/dayrui/App/Pay/Controllers/Home.php b/dayrui/App/Pay/Controllers/Home.php
new file mode 100644
index 0000000..33ce862
--- /dev/null
+++ b/dayrui/App/Pay/Controllers/Home.php
@@ -0,0 +1,160 @@
+get('id');
+ $data = \Phpcmf\Service::M()->table('member_paylog')->get($id);
+ if (!$data) {
+ $this->_msg(0, dr_lang('璇ヨ处鍗曚笉瀛樺湪'));
+ } elseif ($data['status'] == 1) {
+ $this->_msg(0, dr_lang('璇ヨ处鍗曞凡琚敮浠'));
+ }
+
+ // 浠橀挶涔嬪墠鍐嶆楠岃瘉
+ if ($data['mid'] && strpos($data['mid'], 'my-') !== false) {
+ list($rname, $rid, $fid, $num, $sku) = explode('-', $data['mid']);
+ if ($rname == 'my') {
+ list($app, $class) = explode('_', $rid);
+ $classFile = dr_get_app_dir($app).'Models/'.ucfirst($class).'.php';
+ if (is_file($classFile)) {
+ $obj = \Phpcmf\Service::M($class, $app);
+ if (method_exists($obj, 'paylog_before')) {
+ $error = $obj->paylog_before($fid, $num, $sku, $data);
+ if ($error) {
+ $this->_msg(0, $error);
+ }
+ }
+ }
+ }
+ }
+
+ // 0鍏冩敮浠
+ if (empty($data['value'])) {
+ $rt = \Phpcmf\Service::M('Pay','pay')->paysuccess(
+ \Phpcmf\Service::M('Pay','pay')->get_pay_sn($data),
+ 0
+ );
+ if (!$rt['code']) {
+ $this->_msg(0, $rt['msg'], $rt['data']['url']);
+ }
+ dr_redirect(ROOT_URL.'index.php?s=api&c=pay&m=call&id='.$rt['code']);exit;
+ }
+
+ // 鏀粯鎺ュ彛鏂囦欢
+ $apifile = ROOTPATH.'api/pay/'.$data['type'].'/pay.php';
+ if (!is_file($apifile)) {
+ $this->_msg(0, dr_lang('鏀粯鎺ュ彛鏂囦欢锛%s锛変笉瀛樺湪', $data['type']));
+ } elseif ($data['type'] != 'finecms' && (!isset($this->member_cache['payapi'][$data['type']]) || !$this->member_cache['payapi'][$data['type']])) {
+ $this->_msg(0, dr_lang('鏀粯鎺ュ彛锛%s锛夋湭鍚敤', $data['type']));
+ }
+
+ // 鍙戣捣鏀粯
+ $rt = \Phpcmf\Service::M('pay', 'pay')->dopay($apifile, $data);
+ if (!$rt['code']) {
+ $this->_msg(0, $rt['msg'], $rt['data']['url']);
+ } elseif (isset($rt['data']['rturl']) && strlen($rt['data']['rturl']) > 10) {
+ $this->_msg(1, $rt['msg'], $rt['data']['rturl']);
+ }
+
+ // 璇锋眰妯″紡涓嬭繑鍥炵粨鏋
+ if (IS_API_HTTP || (\Phpcmf\Service::L('input')->get('is_ajax') || IS_API_HTTP || IS_AJAX)) {
+ $this->_json(1, $rt['msg'], $rt['data']);
+ }
+
+ // 杩愯妯″紡鐩存帴杈撳嚭浠g爜
+ switch ($rt['msg']) {
+ case 'html':
+ echo $rt['data'];
+ exit;
+
+ case 'url':
+ dr_redirect($rt['data']);
+ break;
+ }
+
+ $data['html'] = $rt['data'];
+ if (SITE_IS_MOBILE && \Phpcmf\Service::IS_MOBILE_TPL()) {
+ // 寮鍚簡绉诲姩绔椂锛屾敮浠樺垽鏂ā鏉挎槸鍚︽槸绉诲姩绔殑
+ \Phpcmf\Service::V()->init('mobile');
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'pay' => $data,
+ 'pay_name' => dr_pay_type_html($data['type']),
+ 'meta_title' => $data['title']
+ ]);
+
+ \Phpcmf\Service::V()->module('pay');
+ if (!is_file(\Phpcmf\Service::V()->get_dir().'pay.html')) {
+ \Phpcmf\Service::V()->module('api');
+ }
+ \Phpcmf\Service::V()->display('pay.html');exit;
+ }
+
+ /**
+ * 鏀粯鎺ュ彛js-ajax鍥炶皟
+ */
+ public function ajax() {
+
+ $id = (int)\Phpcmf\Service::L('input')->get('id');
+ $data = \Phpcmf\Service::M()->table('member_paylog')->get($id);
+ if (!$data) {
+ $this->_jsonp(0, dr_lang('鏀粯璁板綍涓嶅瓨鍦'));
+ } elseif ($data['status']) {
+ $this->_jsonp(1, dr_lang('宸茬粡鏀粯瀹屾垚'));
+ }
+
+ // 璋冪敤鎺ュ彛
+ $apifile = ROOTPATH.'api/pay/'.$data['type'].'/notify_js.php';
+ if (!is_file($apifile)) {
+ $this->_jsonp(0, dr_lang('鏀粯鎺ュ彛鏂囦欢涓嶅瓨鍦'));
+ }
+
+ $return = [];
+ $result = dr_string2array($data['result']);
+
+ // 鎺ュ彛閰嶇疆鍙傛暟
+ $config = $this->member_cache['payapi'][$data['type']];
+
+ require $apifile;
+
+ $this->_jsonp($return['code'], $return['msg']);
+ exit;
+ }
+
+ /**
+ * 鏀粯鎺ュ彛杩斿洖
+ */
+ public function call() {
+
+ $id = (int)\Phpcmf\Service::L('input')->get('id');
+ if (!$id) {
+ $this->_msg(0, dr_lang('鏀粯ID鍙蜂笉瀛樺湪'));
+ }
+
+ $data = \Phpcmf\Service::M()->table('member_paylog')->get($id);
+ if (!$data) {
+ $this->_msg(0, dr_lang('鏀粯璁板綍[%s]涓嶅瓨鍦', $id));
+ } elseif (!$data['status']) {
+ $this->_msg(0, dr_lang('鏀粯璁板綍[%s]鏈畬鎴愭敮浠', $id));
+ }
+
+ // 鏀粯鍥炶皟閽╁瓙
+ \Phpcmf\Hooks::trigger('pay_call', $data);
+
+ if (SITE_IS_MOBILE && \Phpcmf\Service::IS_MOBILE_TPL()) {
+ // 寮鍚簡绉诲姩绔椂锛屾敮浠樺垽鏂ā鏉挎槸鍚︽槸绉诲姩绔殑
+ \Phpcmf\Service::V()->init('mobile');
+ }
+
+ // 鑾峰彇鏀粯鍥炶皟鍦板潃
+ $url = \Phpcmf\Service::M('pay')->paycall_url($data);
+
+ $this->_msg(1, dr_lang('鏀粯鎴愬姛'), $url);
+ }
+
+}
diff --git a/dayrui/App/Pay/Controllers/Member/Pay.php b/dayrui/App/Pay/Controllers/Member/Pay.php
new file mode 100644
index 0000000..7c72023
--- /dev/null
+++ b/dayrui/App/Pay/Controllers/Member/Pay.php
@@ -0,0 +1,43 @@
+post('pay');
+ $pay['uid'] = (int)$this->member['uid'];
+ $pay['username'] = (string)$this->member['username'];
+ $money = floatval($pay['money']);
+ if (!$money) {
+ $this->_msg(0, dr_lang('閲戦(%s)涓嶆纭', $money));
+ exit;
+ }
+ $rt = \Phpcmf\Service::M('Pay')->post($pay);
+ if (!$rt['code']) {
+ $this->_msg(0, $rt['msg'], $rt['data']);
+ }
+ $url = PAY_URL.'index.php?s=pay&id='.$rt['code'];
+ if (IS_API_HTTP || (\Phpcmf\Service::L('input')->get('is_ajax') || IS_API_HTTP || IS_AJAX)) {
+ // 鍥炶皟椤甸潰
+ $this->_json($rt['code'], $url, $rt['data']);
+ } else {
+ // 璺宠浆鍒版敮浠橀〉闈紝蹇呴』璺宠浆鍒扮粺涓鐨勪富鍩熷悕涓粯娆
+ dr_redirect($url, 'auto');
+ }
+ exit;
+ } else {
+ $this->_msg(0, dr_lang('POST璇锋眰閿欒'));
+ }
+ }
+
+}
diff --git a/dayrui/App/Pay/Controllers/Member/Paylog.php b/dayrui/App/Pay/Controllers/Member/Paylog.php
new file mode 100644
index 0000000..05a9dc6
--- /dev/null
+++ b/dayrui/App/Pay/Controllers/Member/Paylog.php
@@ -0,0 +1,86 @@
+is_data = 0;
+ // 琛ㄥ崟鏄剧ず鍚嶇О
+ $this->name = dr_lang('璧勯噾娴佹按');
+ // 鍒濆鍖栨暟鎹〃
+ $this->_init([
+ 'table' => 'member_paylog',
+ 'order_by' => 'inputtime desc',
+ 'date_field' => 'inputtime',
+ ]);
+ }
+
+ // index
+ public function index() {
+
+ $tid = (int)\Phpcmf\Service::L('input')->get('tid');
+ $where = ['`uid`='.$this->uid];
+ switch ($tid) {
+ case 1: // 鏀跺叆
+ $where[] = '`value` > 0';
+ break;
+ case -1: // 娑堣垂
+ $where[] = '`value` < 0';
+ break;
+ default : // 鍏ㄩ儴
+ break;
+ }
+
+ if (isset($this->member_cache['pay']['year']) && $this->member_cache['pay']['year']) {
+ $year = (int)$this->member_cache['pay']['year'];
+ if ($year) {
+ $where[] = 'inputtime > '.strtotime('-'.$year.' year');
+ }
+ }
+
+ \Phpcmf\Service::M()->set_where_list(implode(' AND ', $where));
+ list($tpl, $data) = $this->_List(['tid' => $tid]);
+
+ // 鍒濆鍖
+ $data['param']['tid'] = $data['param']['total'] = 0;
+
+ // 鍒楀嚭绫诲埆
+ $my = [];
+ $type = ['0' => '鍏ㄩ儴', '1' => '鏀跺叆', '-1' => '娑堣垂'];
+ foreach ($type as $i => $t) {
+ $data['param']['tid'] = $i;
+ $my[$i] = [
+ 'name' => dr_lang($t),
+ 'url' => dr_member_url('pay/paylog/index', $data['param'])
+ ];
+ }
+
+ \Phpcmf\Service::V()->assign([
+ 'tid' => $tid,
+ 'type' => $my,
+ ]);
+
+ \Phpcmf\Service::V()->display('paylog_index.html');
+ }
+
+ public function show() {
+
+ $id = \Phpcmf\Service::L('input')->get('id');
+ if (strpos($id, '-') !== false) {
+ list($a, $id) = explode('-', $id);
+ }
+
+ list($a, $data) = $this->_Show((int)$id);
+ if (!$data) {
+ $this->_msg(0, dr_lang('浜ゆ槗璁板綍涓嶅瓨鍦'));exit;
+ } elseif ($data['uid'] != $this->uid) {
+ $this->_msg(0, dr_lang('鏃犳潈闄愭煡鐪'));exit;
+ }
+
+ \Phpcmf\Service::V()->display('paylog_show.html');
+ }
+
+}
diff --git a/dayrui/App/Pay/Controllers/Member/Recharge.php b/dayrui/App/Pay/Controllers/Member/Recharge.php
new file mode 100644
index 0000000..1aa693a
--- /dev/null
+++ b/dayrui/App/Pay/Controllers/Member/Recharge.php
@@ -0,0 +1,17 @@
+get('value')), floatval($this->member_cache['pay']['min']));
+ \Phpcmf\Service::V()->assign([
+ 'payfield' => dr_payform('recharge', $value ? $value : '', '', '', 1),
+ ]);
+ \Phpcmf\Service::V()->display('recharge_index.html');
+ }
+
+}
diff --git a/dayrui/App/Pay/Models/Pay.php b/dayrui/App/Pay/Models/Pay.php
new file mode 100644
index 0000000..f1addd9
--- /dev/null
+++ b/dayrui/App/Pay/Models/Pay.php
@@ -0,0 +1,1095 @@
+myfield = [
+ 'recharge' => [
+ 'fieldtype' => 'Pay',
+ 'fieldname' => 'pay',
+ 'setting' => [
+ 'option' => [
+ 'payfile' => 'pay.html', // 妯℃澘鏂囦欢
+ 'is_finecms' => 0, // 鏄惁鍚敤浣欓浠樻
+ ],
+ ]
+ ],
+ 'score' => [
+ 'fieldtype' => 'Pay',
+ 'fieldname' => 'pay',
+ 'setting' => [
+ 'option' => [
+ 'payfile' => 'score.html', // 妯℃澘鏂囦欢
+ 'is_finecms' => 1, // 鏄惁鍚敤浣欓浠樻
+ ],
+ ]
+ ],
+ 'donation' => [
+ 'fieldtype' => 'Pay',
+ 'fieldname' => 'pay',
+ 'setting' => [
+ 'option' => [
+ 'payfile' => 'donation.html', // 妯℃澘鏂囦欢
+ 'is_finecms' => 1, // 鏄惁鍚敤浣欓浠樻
+ ],
+ ]
+ ],
+ 'gathering' => [
+ 'fieldtype' => 'Pay',
+ 'fieldname' => 'price',
+ 'setting' => [
+ 'option' => [
+ 'payfile' => 'gathering.html', // 妯℃澘鏂囦欢
+ 'is_finecms' => 1, // 鏄惁鍚敤浣欓浠樻
+ ],
+ ]
+ ],
+ ];
+ }
+
+ // 鑾峰彇鏀粯鏂瑰紡
+ public function get_pay_type($is_finecms = 0) {
+
+ $pay_type = [];
+
+ $is_finecms && $pay_type['finecms'] = \Phpcmf\Service::R(ROOTPATH.'api/pay/finecms/config.php');
+
+ if (\Phpcmf\Service::C()->member_cache['payapi']) {
+ foreach (\Phpcmf\Service::C()->member_cache['payapi'] as $name => $t) {
+ if (!is_file(ROOTPATH.'api/pay/'.$name.'/config.php')) {
+ continue; // 鎺掗櫎鏄惁瀛樺湪閰嶇疆鏂囦欢
+ }
+ $pay_type[$name] = \Phpcmf\Service::R(ROOTPATH.'api/pay/'.$name.'/config.php');
+ }
+ }
+
+ if ($is_finecms) {
+ if (!$this->uid) {
+ unset($pay_type['finecms']);
+ } elseif ($this->member['money'] < 0.01) {
+ unset($pay_type['finecms']);
+ }
+ }
+
+ if (IS_DEV && !$pay_type) {
+ log_message('debug', '绯荤粺娌℃湁寮鍚敮浠樻帴鍙o紝鏃犳硶鑾峰彇鍒版敮浠樻柟寮');
+ }
+
+ return $pay_type;
+ }
+
+ // 鑾峰彇鎵撹祻妯″潡鍐呭
+ public function get_module_row($dir, $id, $siteid) {
+
+ $data = $this->table($siteid.'_'.$dir)->get($id);
+ if (!$data) {
+ return dr_return_data(0, dr_lang('鎵撹祻鍐呭涓嶅瓨鍦'));
+ }
+
+ return dr_return_data(1, 'ok', $data);
+ }
+
+ // 鑾峰彇浠锋牸鍊
+ public function get_price_value($data, $field, $sku = '') {
+
+ if ($sku && $sku != 'null' && isset($data[$field.'_sku']) && is_array($data[$field.'_sku'])) {
+ return (float)$data[$field.'_sku']['value'][$sku]['price'];
+ }
+ return (float)$data[$field];
+ }
+
+ // 鑾峰彇鏀粯浠锋牸鍜屽唴瀹
+ public function get_pay_info($id, $field, $num = 1, $sku = '') {
+
+ list($table, $name, $username, $thumb, $url) = $this->_get_table_name(
+ $field['relatedid'],
+ $field['relatedname']
+ );
+ if (!$table) {
+ return dr_return_data(0, dr_lang('鏀粯鍏宠仈琛ㄤ笉瀛樺湪'));
+ }
+
+ $rt = $this->table($table)->get($id);
+ if (!$rt) {
+ return dr_return_data(0, dr_lang('鏀粯鍏宠仈琛╗%s]鍐呭(#%s)涓嶅瓨鍦', $table, $id));
+ } elseif (!isset($rt[$field['fieldname']])) {
+ return dr_return_data(0, dr_lang('鏀粯鍏宠仈琛ㄧ殑鏀粯瀛楁[%s]涓嶅瓨鍦ㄤ簬涓昏〃', $field['fieldname']));
+ } elseif (isset($rt[$thumb]) && $rt[$thumb] && !is_numeric($rt[$thumb])) {
+ // 濡傛灉鏄鏂囦欢瀛楁鍙栫涓涓綔涓虹缉鐣ュ浘
+ $image = dr_string2array($rt[$thumb]);
+ isset($image['file'][0]) && $image['file'][0] && $rt[$thumb] = $image['file'][0];
+ }
+
+ if (isset($rt[$field['fieldname'].'_sku']) && $rt[$field['fieldname'].'_sku']) {
+ $rt[$field['fieldname'].'_sku'] = dr_string2array($rt[$field['fieldname'].'_sku']);
+ }
+
+ $obj = \Phpcmf\Service::L('field')->get($field['fieldtype']);
+ if (isset($rt[$field['fieldname'].'_sku']) && $rt[$field['fieldname'].'_sku']
+ && $obj && method_exists($obj, 'get_pay_info')) {
+ $rs = $obj->get_pay_info($rt, $field, $sku);
+ if (!$rs['code']) {
+ return $rs;
+ }
+ list($sn, $quantity, $sku_name, $sku_string) = $rs['data'];
+ } elseif ($field['fieldtype'] == 'Pays' && isset($rt[$field['fieldname'].'_sku']) && $rt[$field['fieldname'].'_sku']) {
+ // 鍏煎鑰佺増鏈啓娉
+ $rt[$field['fieldname'].'_sku'] = dr_string2array($rt[$field['fieldname'].'_sku']);
+ if (!$sku && $rt[$field['fieldname'].'_sku']) {
+ return dr_return_data(0, dr_lang('娌℃湁閫夋嫨鍟嗗搧灞炴'));
+ } elseif (!isset($rt[$field['fieldname'].'_sku']['value'][$sku]) || !$rt[$field['fieldname'].'_sku']['value'][$sku]) {
+ #print_r($rt[$field['fieldname'].'_sku']['value']);
+ return dr_return_data(0, dr_lang('鍟嗗搧(#'.$rt['id'].')灞炴э紙#'.$sku.'锛夋棤鏁'));
+ }
+ $sn = (string)$rt[$field['fieldname'].'_sku']['value'][$sku]['sn'];
+ $quantity = (int)$rt[$field['fieldname'].'_sku']['value'][$sku]['quantity'];
+ list($sku_name, $sku_string) = dr_sku_name($sku, $rt[$field['fieldname'].'_sku'], 1);
+ } else {
+ $sn = (string)$rt[$field['fieldname'].'_sn'];
+ $quantity = (int)$rt[$field['fieldname'].'_quantity'];
+ $sku_name = $sku_string = '';
+ }
+
+ // 鑾峰彇浠锋牸
+ $price = $this->get_price_value($rt, $field['fieldname'], $sku);
+
+ // buy-琛ㄥ悕-涓婚敭id-瀛楁id-鏁伴噺-sku
+ $mid = 'buy-'.$table .'-'. $id .'-'. $field['id'] .'-'. max(1, (int)$num) .'-'. ($sku ? $sku : 'null');
+
+ return [
+ 'sn' => $sn,
+ 'mid' => $mid,
+ 'num' => $num,
+ 'price' => $price,
+ 'price_sku' => isset($rt[$field['fieldname'].'_sku']) ? $rt[$field['fieldname'].'_sku'] : '',
+ 'total' => $price * $num,
+ 'table' => $table,
+ 'quantity' => $quantity,
+ 'sku_name' => $sku_name,
+ 'sku_string' => $sku_string,
+ 'sku_value' => $sku,
+ 'touid' => intval($rt['uid']),
+ 'tousername' => (string)$rt['username'],
+ 'title' => (string)$rt[$name],
+ 'thumb' => (string)$rt[$thumb],
+ 'url' => $url ? $url.$id : '',
+ 'data' => $rt,
+ ];
+ }
+
+ // 鑾峰彇鏀粯淇℃伅鐨勮〃鍚
+ public function _get_table_name($relatedid, $relatedname) {
+
+ $data = \Phpcmf\Service::C()->get_cache('table-pay-'.SITE_ID, $relatedname.'-'.$relatedid);
+ if (!$data) {
+ return [];
+ }
+
+ // 琛ㄥ悕 - 鏍囬瀛楁 - 鍗栧璐﹀彿 - 缂╃暐鍥 - 鍦板潃
+ return [$data['table'], $data['name'], $data['username'], $data['thumb'], $data['url']];
+ }
+
+ // 鏀粯鐘舵
+ public function paystatus($data) {
+
+ switch ($data['status']) {
+
+ case 0:
+ return '
'.dr_lang('鏈粯娆').' ';
+ break;
+
+ case 1:
+ return '
'.dr_lang('宸蹭粯娆').' ';
+ break;
+
+ case 2:
+ return '
'.dr_lang('姹囨涓').' ';
+ break;
+
+ case 5:
+ return '
'.dr_lang('涓婇棬浠').' ';
+ break;
+
+ case 3:
+ return '
'.dr_lang('琚嫆缁').' ';
+ break;
+
+ }
+
+ }
+
+ // 鐢ㄩ旂被鍨
+ public function paytype($mark) {
+
+ switch ($mark) {
+
+ // 鍦ㄧ嚎鍏呭
+ case 'recharge':
+ return '
'.dr_lang('鍏呭').' ';
+ break;
+
+ // 鍦ㄧ嚎鍏呭
+ case 'score':
+ return '
'.dr_lang(SITE_SCORE).' ';
+ break;
+
+ // 绯荤粺
+ case 'system':
+ return '
'.dr_lang('绯荤粺').' ';
+ break;
+
+ // 璁㈠崟
+ case 'order':
+ case 'orders':
+ return '
'.dr_lang('璁㈠崟').' ';
+ break;
+
+ // 鎻愮幇
+ case 'cash':
+ return '
'.dr_lang('鎻愮幇').' ';
+ break;
+
+ // 鍏朵粬鏉ヨ嚜鑷畾涔夊瓧娈
+ default:
+ list($rname, $rid, $fid) = explode('-', $mark);
+ switch ($rname) {
+
+ // 绯荤粺
+ case 'system':
+ return '
'.dr_lang('绯荤粺').' ';
+ break;
+
+ // 鐢ㄦ埛缁
+ case 'group':
+ return '
'.dr_lang('浼氬憳').' ';
+ break;
+ // 鐢ㄦ埛缁
+ case 'level':
+ return '
'.dr_lang('绛夌骇').' ';
+ break;
+
+ // 璁㈠崟
+ case 'order':
+ case 'orders':
+ return '
'.dr_lang('璁㈠崟').' ';
+ break;
+
+ case 'gathering':
+ // 鏀舵鎻掍欢
+ return '
'.dr_lang('鏀舵').' ';
+ break;
+
+ case 'buy':
+ // 蹇熶笅鍗
+ return '
'.dr_lang('涓嬪崟').' ';
+ break;
+
+ case 'my':
+ // 浜屾寮鍙
+ $obj = $this->my_pay_obj($rid);
+ if (!$obj) {
+ return '
'.dr_lang('鏈煡').' ';
+ } elseif (method_exists($obj, 'paytype')) {
+ return $obj->paytype();
+ } else {
+ return '
'.dr_lang('搴旂敤').' ';
+ }
+ break;
+
+ case 'donation':
+ // 鎵撹祻浣滆
+ return '
'.dr_lang('鎵撹祻').' ';
+ break;
+
+ default:
+ // 鏉ヨ嚜鑷畾涔夊瓧娈
+ /*
+ $field = \Phpcmf\Service::C()->get_cache('table-field', $fid);
+ if ($field['relatedname'] == 'module') {
+ // 妯″潡
+ return '
'.dr_lang('妯″潡').' ';
+ } elseif (function_exists('dr_paytype_'.$mark)) {
+ return call_user_func('dr_paytype_'.$mark);
+ }*/
+ return '
'.dr_lang('鍏朵粬').' ';
+ break;
+ }
+ break;
+ }
+ }
+
+ // 浠樻鍚嶇О
+ public function payname($name) {
+
+ switch ($name) {
+
+ case 'meet';
+ return '涓婇棬';
+ break;
+
+ case 'remit';
+ return '姹囨';
+ break;
+
+ case 'system';
+ return '绯荤粺';
+ break;
+
+ case 'admin';
+ return '鍚庡彴';
+ break;
+
+ case 'finecms';
+ return '浣欓';
+ break;
+
+ case 'weixin';
+ return '寰俊';
+ break;
+
+ case 'alipay';
+ return '鏀粯瀹';
+ break;
+
+ default;
+
+ if (!$this->payname[$name]) {
+ if (is_file(WEBPATH.'api/pay/'.$name.'/config.php')) {
+ $this->payname[$name] = require WEBPATH.'api/pay/'.$name.'/config.php';
+ } else {
+ return $name;
+ }
+
+ }
+
+ if (isset($this->payname[$name]['name']) && $this->payname[$name]['name']) {
+ return $this->payname[$name]['name'];
+ }
+
+ return $name;
+ break;
+ }
+ }
+
+ /**
+ * 鏀粯琛ㄥ崟璋冪敤
+ * mark 琛ㄥ悕-涓婚敭id-瀛楁id
+ * value 鏀粯閲戦
+ * title 鏀粯璇存槑
+ * */
+ public function payform($mark, $value = 0, $title = '', $url = '', $remove_div = 0, $tpl = '') {
+
+ switch ($mark) {
+
+ // 鍦ㄧ嚎鍏呭
+ case 'recharge':
+ $field = $this->myfield[$mark];
+ break;
+
+ // 閲戝竵鍏呭
+ case 'score':
+ $field = $this->myfield[$mark];
+ break;
+
+ // 鍏朵粬鏉ヨ嚜鑷畾涔夊瓧娈
+ default:
+ list($rname, $rid, $fid, $num, $sku) = explode('-', $mark);
+ switch ($rname) {
+
+ case 'gathering':
+ // 鏉ヨ嚜浠樻
+ $field = $this->myfield[$rname];
+ $value = ceil($value);
+ break;
+
+ case 'my':
+ // 鏉ヨ嚜浜屾寮鍙
+ $obj = $this->my_pay_obj($rid);
+ if (!$obj) {
+ return dr_lang('鑷畾涔夋敮浠樺璞$被鏂囦欢涓嶅瓨鍦');
+ }
+ if (method_exists($obj, 'get_myfield')) {
+ $field = $obj->get_myfield();
+ } else {
+ return dr_lang('鑷畾涔夌被鏂规硶get_myfield鏈畾涔');
+ }
+ if (method_exists($obj, 'pay_before')) {
+ $rt = $obj->pay_before($fid, $num, $sku, SITE_ID);
+ if ($rt) {
+ return $rt;
+ }
+ }
+ if (method_exists($obj, 'get_price')) {
+ $value = $obj->get_price($fid, $num, $sku, SITE_ID);
+ } else {
+ return dr_lang('鑷畾涔夌被鏂规硶get_price鏈畾涔');
+ }
+ break;
+
+ case 'buy':
+ // 蹇熶笅鍗
+ $field = \Phpcmf\Service::C()->get_cache('table-field', $num);
+ if (!$field) {
+ return dr_lang('鏀粯瀛楁[%s]涓嶅瓨鍦', $num);
+ }
+ break;
+
+ default:
+ return dr_return_data(0, dr_lang('鏈畾涔夌殑鏀粯鏂瑰紡[%s]', $rname));
+ break;
+ }
+ break;
+ }
+
+ $f = \Phpcmf\Service::L('Field')->get($field['fieldtype']);
+ $f->remove_div = $remove_div;
+ $html = $f->input($field, $value, [
+ 'mark' => $mark,
+ 'title' => $title,
+ 'url' => $url,
+ 'tpl' => $tpl,
+ ]);
+ return $html;
+ }
+
+ // 澧炲姞娴佹按璁板綍
+ public function add_paylog($data) {
+ $data = [
+ 'site' => SITE_ID,
+ 'mid' => $data['mid'],
+ 'uid' => $data['uid'],
+ 'touid' => (int)$data['touid'],
+ 'title' => $data['title'],
+ 'value' => $data['value'],
+ 'type' => dr_safe_replace($data['type']),
+ 'url' => !$data['url'] ? '' : dr_url_prefix($data['url']),
+ 'status' => (int)$data['status'],
+ 'result' => $data['result'] ? $data['result'] : '',
+ 'paytime' => $data['paytime'] ? $data['paytime'] : 0,
+ 'money' => 0,
+ 'inputtime' => SYS_TIME,
+ ];
+ if ($data['uid']) {
+ $user = $this->table('member')->get($data['uid']);
+ $user && $data['money'] = $user['money'];
+ }
+ $rt = $this->table('member_paylog')->insert($data);
+ $data['id'] = $rt['code'];
+ $rt['data'] = $data;
+ return $rt;
+ }
+
+ // 缁欒处鎴峰厖鍊糾oney
+ public function add_money($uid, $value) {
+ return \Phpcmf\Service::M('member')->add_money($uid, $value);
+ }
+
+ // 閫氳繃鏀粯娴佹按鍙疯幏鍙杋d鍙
+ public function get_pay_id($mark) {
+ if (strpos($mark, 'fc-') === 0) {
+ return intval(substr($mark, 3));
+ }
+ return (int)substr($mark, strlen(\Phpcmf\Service::C()->member_cache['pay']['prefix'].date('YmdHis', SYS_TIME))+2);
+ }
+
+ // 鐢熸垚鏀粯娴佹按id鍙
+ public function get_pay_sn($data) {
+ return trim((string)\Phpcmf\Service::C()->member_cache['pay']['prefix']).date('YmdHis', SYS_TIME).'00'.$data['id'];
+ }
+
+ // 鍏呭兼垚鍔熺殑杩斿洖
+ public function paysuccess($mark, $payid) {
+
+ // 鎵炬祦姘磇d
+ $id = $this->get_pay_id($mark);
+ if (!$id) {
+ return dr_return_data(0, dr_lang('娌℃湁鑾峰彇鍒版敮浠業D鍙'));
+ }
+
+ $data = $this->table('member_paylog')->get($id);
+ if (!$data) {
+ return dr_return_data(0, dr_lang('鏀粯璁板綍涓嶅瓨鍦'));
+ } elseif ($data['status'] == 1) {
+ return dr_return_data($id, dr_lang('姝よ处鍗曞凡缁忔敮浠'));
+ } else {
+ // 鍒嗘瀽璁㈠崟鏉ユ簮
+ $user = \Phpcmf\Service::M()->table('member')->get($data['uid']);
+ list($a, $b, $c, $d, $e, $f) = explode('-', $data['mid']);
+ // 浠樻鍒拌处鍙蜂綑棰濅腑 // touid涓虹┖琛ㄧず绯荤粺鏀舵鐩存帴鎵
+ if ($data['touid']) {
+ if ($data['touid'] == $data['uid']) {
+ // 琛ㄧず涓鸿嚜宸卞厖鍊
+ if ($data['type'] != 'finecms') {
+ // 鍏呭煎繀椤诲垽鏂璽ype涓嶆槸浣欓浠樻妯″紡
+ $this->add_money($data['uid'], $data['value']);
+ $user['money']+= $data['value'];
+ }
+ } else {
+ // 鎵i櫎鑷繁鐨勯挶
+ if ($data['type'] == 'finecms') {
+ // 鍒ゆ柇type鏄綑棰濅粯娆炬ā寮,鎵嶈繘琛屾墸娆
+ $this->add_money($data['uid'], -abs($data['value']));
+ $user['money']-= abs($data['value']);
+ } else {
+ // 璁板綍娑堣垂
+ if ($user) {
+ $this->table('member')->update($data['uid'], [
+ 'spend' => max(0, (float)$user['spend'] + abs($data['value'])),
+ ]);
+ }
+ }
+ }
+ } else {
+ // 鎵i櫎鑷繁鐨勯挶 touid涓虹┖琛ㄧず绯荤粺鏀舵鐩存帴鎵
+ if ($data['type'] == 'finecms') {
+ // 鍒ゆ柇type鏄綑棰濅粯娆炬ā寮,鎵嶈繘琛屾墸娆
+ $this->add_money($data['uid'], -abs($data['value']));
+ $user['money']-= abs($data['value']);
+ } else {
+ // 璁板綍娑堣垂
+ if ($user) {
+ $this->table('member')->update($data['uid'], [
+ 'spend' => max(0, (float)$user['spend'] + abs($data['value'])),
+ ]);
+ }
+ }
+ }
+
+ // 澶囦唤浣跨敤
+ $data['result_data'] = $result = $data['result'];
+
+ // 鏀粯鎴愬姛
+ $save = [
+ 'status' => 1,
+ 'result' => $payid,
+ 'paytime' => SYS_TIME,
+ ];
+ if ($payid == 0 && $payid == (int)$data['value']) {
+ // 琛ㄧず0鍏冩敮浠樿缃负浣欓鏂瑰紡
+ $save['type'] = 'finecms';
+ }
+
+ if ($user) {
+ $save['money'] = $user['money'];
+ }
+
+ $this->table('member_paylog')->update($id, $save);
+
+ $data['status'] = 1;
+ $data['result'] = $payid;
+ $data['paytime'] = SYS_TIME;
+ $data['url'] = \Phpcmf\Service::L('Router')->member_url('pay/paylog/show', ['id' => $data['id']]);
+
+ if ($user) {
+ $data['phone'] = $user['phone'];
+ $data['email'] = $user['email'];
+ // 閫氱煡
+ \Phpcmf\Service::L('Notice')->send_notice('pay_success', $data);
+ }
+
+ // 鎸傞挬
+ \Phpcmf\Hooks::trigger('pay_success', $data);
+
+ switch ($a) {
+
+ case 'recharge':
+ // 鍦ㄧ嚎鍏呭
+ break;
+
+ case 'group':
+ // 鐢ㄦ埛缁
+ \Phpcmf\Service::M('member')->notice(
+ $data['uid'],
+ 2,
+ $data['title'],
+ \Phpcmf\Service::L('Router')->member_url('pay/paylog/show', ['id'=>$data['id']])
+ );
+ $result = dr_string2array($result);
+ \Phpcmf\Service::M('member')->apply_group($d, $user, $b, $c, abs($data['value']), $result);
+ break;
+
+ case 'level':
+ // 鐢ㄦ埛缁勭瓑绾у崌绾
+ // 鎻愰啋閫氱煡
+ \Phpcmf\Service::M('member')->notice(
+ $data['uid'],
+ 2,
+ $data['title'],
+ \Phpcmf\Service::L('Router')->member_url('pay/paylog/show', ['id'=>$data['id']])
+ );
+ \Phpcmf\Service::M('member')->update_level($data['uid'], $b, $c);
+ break;
+
+ case 'score':
+ // 绉垎鍏呭
+ $value = abs($data['value']) * \Phpcmf\Service::C()->member_cache['pay']['convert'];
+ \Phpcmf\Service::M('member')->add_score($data['uid'], $value, dr_lang('鍦ㄧ嚎鍏呭'), $data['url']);
+ break;
+
+ case 'buy':
+ // 蹇熶笅鍗
+ \Phpcmf\Hooks::trigger('member_buy_after', $data);
+ break;
+
+ case 'order':
+ // 璁㈠崟浜ゆ槗
+ \Phpcmf\Service::M('order', 'order')->pay($c, $id);
+ break;
+
+ case 'orders':
+ // 璁㈠崟浜ゆ槗
+ $oids = explode(',', $c);
+ foreach ($oids as $oi) {
+ \Phpcmf\Service::M('order', 'order')->pay($oi, $id);
+ }
+ break;
+
+ case 'gathering':
+ // 鏉ヨ嚜鏀舵
+ $row = $this->table($c)->get($b);
+ if (!$row) {
+ log_message('error', '鏀舵(#'.$id.')鍥炶皟澶辫触锛氫富棰#'.$c.'涓嶅瓨鍦');
+ } else {
+ // 鏇存柊琛
+ $row['nums'] = (int)$row['nums'] + 1;
+ $row['total'] = $row['total'] + abs($data['value']);
+ $this->table($c)->update($b, [
+ 'total' => $row['total'],
+ 'nums' => $row['nums'],
+ 'updatetime' => SYS_TIME
+ ]);
+ // 鏀舵寮鍙戦挬瀛
+ \Phpcmf\Hooks::trigger('gathering_'.$c.'_success', $row, $data);
+ }
+ break;
+ case 'my':
+ // 鏉ヨ嚜浜屾寮鍙
+ $obj = $this->my_pay_obj($b);
+ if (method_exists($obj, 'success')) {
+ $obj->success($c, $data, $d, $e);
+ }
+ break;
+ }
+
+ return dr_return_data($id, dr_lang('鏀粯鎴愬姛'));
+ }
+ }
+
+ // 鏀粯閫娆
+ // $data 涓 member_paylog 娴佹按璁板綍
+ // 鎴愬姛鍚庝笉鏀瑰姩鍘熸祦姘达紝鍙﹀涓鏉℃鏁伴娆炬祦姘达紙mid = {鍘焟id}-refund锛
+ public function payrefund($data) {
+
+ if (!$data || empty($data['id'])) {
+ return dr_return_data(0, dr_lang('鏀粯璁板綍涓嶅瓨鍦'));
+ } elseif ((int)$data['status'] != 1) {
+ return dr_return_data(0, dr_lang('姝よ处鍗曟湭鏀粯锛屾棤娉曢娆'));
+ }
+
+ $origin_mid = trim((string)$data['mid']);
+ if ($origin_mid === '') {
+ return dr_return_data(0, dr_lang('鍘熸敮浠樻爣璁版棤鏁堬紝鏃犳硶閫娆'));
+ }
+ // 閬垮厤瀵归娆炬祦姘村啀娆¢娆
+ if (substr($origin_mid, -7) === '-refund') {
+ return dr_return_data(0, dr_lang('璇ユ祦姘翠负閫娆捐褰曪紝鏃犳硶鍐嶆閫娆'));
+ }
+ $refund_mid = $origin_mid.'-refund';
+ $exists = $this->table('member_paylog')->where('mid', $refund_mid)->where('status', 1)->getRow();
+ if ($exists) {
+ return dr_return_data(0, dr_lang('璇ユ祦姘村凡閫娆撅紝璇峰嬁閲嶅鎿嶄綔'));
+ }
+
+ $type = (string)$data['type'];
+ $money = abs($data['value']);
+ list($a, $b, $c, $d, $e, $f) = explode('-', (string)$data['mid']);
+ $return = [];
+
+ // 鎸夋敮浠樻柟寮忔墽琛屾笭閬撻娆
+ if ($type == 'finecms') {
+ // 璐﹀彿浣欓鏀粯锛氶鍥炰綑棰
+ if ($data['uid']) {
+ $rt = $this->add_money($data['uid'], $money);
+ if (!$rt['code']) {
+ return $rt;
+ }
+ }
+ } else {
+ // 鍦ㄧ嚎鏀粯锛堝 alipay锛夛細璋冪敤瀵瑰簲閫娆炬帴鍙
+ $apifile = ROOTPATH.'api/pay/'.$type.'/refund.php';
+ if (!is_file($apifile)) {
+ return dr_return_data(0, dr_lang('閫娆惧け璐ワ紝鎺ュ彛鏈畾涔'));
+ }
+ $config = [];
+ if (isset(\Phpcmf\Service::C()->member_cache['payapi'][$type])) {
+ $config = \Phpcmf\Service::C()->member_cache['payapi'][$type];
+ }
+ require $apifile;
+ if (!$return || !isset($return['code'])) {
+ return dr_return_data(0, dr_lang('閫娆惧け璐ワ紝鎺ュ彛鏈畾涔'));
+ } elseif (!$return['code']) {
+ return $return;
+ }
+ }
+
+ // 鍦ㄧ嚎鍏呭奸娆撅細鍏呭艰繘璐﹂渶鎵e洖浣欓锛堜笟鍔¤鍗曢娆剧敱璋冪敤鏂硅嚜琛屽鐞嗙姸鎬侊級
+ if ($a == 'recharge' && $type != 'finecms' && $data['uid'] && $data['touid'] == $data['uid']) {
+ $rt = $this->add_money($data['uid'], -$money);
+ if (!$rt['code']) {
+ return $rt;
+ }
+ }
+
+ // 鏂板閫娆炬祦姘达紙姝f暟锛夛紝涓嶄慨鏀瑰師鏀粯娴佹按
+ $title = isset($data['title']) && $data['title']
+ ? (dr_lang('閫娆').'锛'.$data['title'])
+ : dr_lang('閫娆');
+ $result = dr_lang('鍘熸祦姘村彿锛%s', $data['id']);
+ if (!empty($return) && is_array($return) && !empty($return['data'])) {
+ // 娓犻亾杩斿洖淇℃伅鍙夊啓鍏
+ if (!empty($return['data']['trade_no'])) {
+ $result .= ' / '.$return['data']['trade_no'];
+ } elseif (!empty($return['data']['out_request_no'])) {
+ $result .= ' / '.$return['data']['out_request_no'];
+ }
+ } elseif (!empty($data['result'])) {
+ $result .= ' / '.$data['result'];
+ }
+
+ $rt = $this->add_paylog([
+ 'mid' => $refund_mid,
+ 'uid' => (int)$data['uid'],
+ 'touid' => 0,
+ 'title' => $title,
+ 'value' => $money,
+ 'type' => $type,
+ 'url' => isset($data['url']) ? $data['url'] : '',
+ 'status' => 1,
+ 'result' => $result,
+ 'paytime' => SYS_TIME,
+ ]);
+ if (!$rt['code']) {
+ return dr_return_data(0, $rt['msg'] ?: dr_lang('閫娆炬祦姘村啓鍏ュけ璐'));
+ }
+
+ $data['refund_id'] = $rt['code'];
+ \Phpcmf\Hooks::trigger('pay_refund', $data);
+
+ return dr_return_data($rt['code'], dr_lang('閫娆炬垚鍔'), [
+ 'pay_id' => $data['id'],
+ 'refund_id' => $rt['code'],
+ ]);
+ }
+
+ // 鏀粯鎴愬姛鐨勫洖璋僽rl
+ public function paycall_url($data) {
+
+ // 榛樿鍦板潃
+ $url = dr_url_prefix('index.php?s=member&app=pay&c=paylog&m=show&id='.$data['id'], '', $data['site']);
+
+ list($rname, $rid, $fid, $num, $sku) = explode('-', $data['mid']);
+
+ switch ($rname) {
+
+ case 'my':
+ // 鏉ヨ嚜浜屾寮鍙
+ $obj = $this->my_pay_obj($rid);
+ if (method_exists($obj, 'call_url')) {
+ $row = $obj->call_url($fid, $data);
+ if ($row) {
+ $url = $row;
+ }
+ }
+
+ break;
+
+ case 'order':
+ // 鏉ヨ嚜鍗曠敤鎴峰晢鍩庤鍗曠郴缁
+ $url = dr_url_prefix('index.php?s=member&app=order&c=home&m=show&id='.$fid, '', $data['site']);
+ break;
+
+ case 'orders':
+ // 鏉ヨ嚜缁勫悎璁㈠崟鍟嗗煄璁㈠崟绯荤粺
+ $url = dr_url_prefix('index.php?s=member&app=order&c=home&m=index', '', $data['site']);
+ break;
+
+ case 'gathering':
+ // 鏉ヨ嚜鏀舵
+ $row = $this->table($fid)->get($rid);
+ if ($row && $row['url']) {
+ $url = $row['url'];
+ }
+
+ break;
+ }
+
+ return $url;
+ }
+
+ /**
+ * 鏀粯鎻愪氦
+ * */
+ public function post($post) {
+
+ if (strlen($post['money']) > 8) {
+ return dr_return_data(0, dr_lang('浠樻閲戦[%s]涓嶈鑼', $post['money']));
+ }
+
+ $post['uid'] = intval($post['uid']);
+ $post['username'] = (string)$post['username'];
+ $post['money'] = floatval(number_format($post['money'], 2, '.', ''));
+ $post['mark'] = dr_safe_filename($post['mark']);
+ $post['type'] = dr_safe_filename($post['type']);
+ if ($post['money'] <= 0) {
+ return dr_return_data(0, dr_lang('浠樻閲戦[%s]涓嶈鑼', $post['money']));
+ } elseif ((string)$post['money'] == 'INF') {
+ return dr_return_data(0, dr_lang('浠樻閲戦[%s]涓嶈鑼', $post['money']));
+ } elseif (!$post['type']) {
+ return dr_return_data(0, dr_lang('鏈煡鏀粯鎺ュ彛'));
+ }
+
+ // 鍒濆鍖栨暟鎹
+ $touid = $money = $fid = 0;
+ $tousername = $title = '';
+
+ // 鎸傞挬鐐 鎻愪氦涔嬪墠
+ \Phpcmf\Hooks::trigger('pay_post_before', $post);
+
+ switch ($post['mark']) {
+
+ // 鍦ㄧ嚎鍏呭
+ case 'recharge':
+ if (!$post['uid']) {
+ return dr_return_data(0, dr_lang('浠樻璐﹀彿涓嶅瓨鍦'));
+ }
+ $title = dr_lang('鐢ㄦ埛锛%s锛夊厖鍊', $post['username']);
+ $money = $post['money'];
+ if (\Phpcmf\Service::C()->member_cache['pay']['min'] && $money < \Phpcmf\Service::C()->member_cache['pay']['min']) {
+ return dr_return_data(0, dr_lang('绯荤粺鏈灏忓厖鍊奸噾棰濅负%s鍏', \Phpcmf\Service::C()->member_cache['pay']['min']));
+ }
+ $touid = $post['uid']; // 鏀舵鏂逛负鑷繁
+ $tousername = $post['username']; // 鏀舵鏂逛负鑷繁
+ if ($post['type'] == 'finecms') {
+ return dr_return_data(0, dr_lang('鍏呭间笉鑳戒娇鐢ㄤ綑棰濇敮浠'));
+ } elseif (floatval($post['money']) <= 0) {
+ return dr_return_data(0, dr_lang('閲戦涓嶈鑼'));
+ }
+ break;
+
+ // 閲戝竵鍏呭
+ case 'score':
+ if (!$post['uid']) {
+ return dr_return_data(0, dr_lang('浠樻璐﹀彿涓嶅瓨鍦'));
+ }
+ $money = (int)$post['money'];
+ if (\Phpcmf\Service::C()->member_cache['pay']['score_min'] && $money < \Phpcmf\Service::C()->member_cache['pay']['score_min']) {
+ return dr_return_data(0, dr_lang('绯荤粺鏈灏忓厖鍊%s涓%s', SITE_SCORE, \Phpcmf\Service::C()->member_cache['pay']['score_min']));
+ } elseif ($money == 0) {
+ return dr_return_data(0, dr_lang('閲戦涓嶈鑼'));
+ }
+ $title = dr_lang('鐢ㄦ埛锛%s锛夊厖鍊%s锛%s', $post['username'], SITE_SCORE, $money);
+ $touid = 0; // 灞炰簬娑堣垂锛屾敹娆炬柟涓虹郴缁
+ $tousername = '';
+ $money = - $money / \Phpcmf\Service::C()->member_cache['pay']['convert'];
+ break;
+
+ // 鍏朵粬鏉ヨ嚜鑷畾涔夊瓧娈
+ default:
+ list($rname, $rid, $fid, $num, $sku, $ff) = explode('-', $post['mark']);
+ switch ($rname) {
+
+ case 'group':
+ // 鏉ヨ嚜鐢ㄦ埛缁
+ $money = (float)$post['money'];
+ if ($money <= 0) {
+ return dr_return_data(0, dr_lang('閲戦[%s]涓嶈鑼', $money));
+ }
+ $title = $post['title'];
+ $money = -$money;
+ $touid = 0; // 鏀舵鏂逛负缁熺郴
+ $tousername = ''; // 鏀舵鏂逛负缁熺郴
+ break;
+
+ case 'level':
+ // 鏉ヨ嚜鐢ㄦ埛缁勭瓑绾
+ $money = (float)$post['money'];
+ if ($money <= 0) {
+ return dr_return_data(0, dr_lang('閲戦[%s]涓嶈鑼', $money));
+ }
+ $title = $post['title'];
+ $money = -$money;
+ $touid = 0; // 鏀舵鏂逛负缁熺郴
+ $tousername = ''; // 鏀舵鏂逛负缁熺郴
+ break;
+
+ case 'gathering':
+ // 鏉ヨ嚜鏀舵
+ $row = $this->table(dr_safe_replace($fid))->get($rid);
+ if (!$row) {
+ return dr_return_data(0, dr_lang('鏀舵涓婚涓嶅瓨鍦'));
+ }
+ $money = floatval($row['price'] > 0 ? $row['price'] : $post['money']);
+ if ($money <= 0) {
+ return dr_return_data(0, dr_lang('閲戦[%s]涓嶈鑼', $money));
+ }
+ $title = $row['title'];
+ $money = -$money;
+ $touid = 0; // 鏀舵鏂逛负缁熺郴
+ $tousername = ''; // 鏀舵鏂逛负缁熺郴
+ break;
+
+ case 'my':
+ // 鏉ヨ嚜浜屾寮鍙
+ $obj = $this->my_pay_obj($rid);
+ if (method_exists($obj, 'pay_after')) {
+ $rt = $obj->pay_after($fid, $num, $sku, SITE_ID);
+ if ($rt) {
+ return dr_return_data(0, $rt);
+ }
+ }
+ if (method_exists($obj, 'get_row')) {
+ $row = $obj->get_row($fid, $num, $sku, SITE_ID);
+ if (!$row) {
+ return dr_return_data(0, dr_lang('涓婚涓嶅瓨鍦'));
+ }
+ } else {
+ return dr_return_data(0, dr_lang('绫绘柟娉昜get_row]鏈畾涔'));
+ }
+ if (method_exists($obj, 'save_result')) {
+ $rt = $obj->save_result($fid, $num, $sku, SITE_ID);
+ if ($rt) {
+ $post['result'] = $rt;
+ }
+ }
+ $money = floatval($row['price']);
+ if ($money <= 0) {
+ return dr_return_data(0, dr_lang('閲戦[%s]涓嶈鑼', $money));
+ }
+ $title = $row['title'];
+ $money = -$money;
+ $touid = (int)$row['sell_uid']; // 鏀舵鏂
+ $tousername = (string)$row['sell_username']; // 鏀舵鏂
+ break;
+
+ case 'order':
+ // 鏉ヨ嚜鍗曠敤鎴峰晢鍩庤鍗曠郴缁
+ $title = dr_lang('璁㈠崟缂栧彿锛%s', $post['sn']);
+ $money = -(float)$post['money'];
+ $touid = 0; // 鏀舵鏂逛负缁熺郴
+ $tousername = ''; // 鏀舵鏂逛负缁熺郴
+ break;
+
+ case 'orders':
+ // 鏉ヨ嚜澶氱敤鎴峰晢鍩庤鍗曠郴缁
+ $title = dr_lang('璁㈠崟缂栧彿锛%s', $post['sn']);
+ $money = -(float)$post['money'];
+ $touid = 0; // 鏀舵鏂逛负缁熺郴
+ $tousername = ''; // 鏀舵鏂逛负缁熺郴
+ break;
+
+ case 'buy':
+ // 蹇熶笅鍗 buy-1_book-992-185-1-null" $rname-$rid-$fid- $num-$sku- $ff
+ $field = \Phpcmf\Service::C()->get_cache('table-field', $num);
+ if (!$field) {
+ return dr_return_data(0, dr_lang('鏀粯瀛楁[%s]涓嶅瓨鍦', $num));
+ }
+ // 鑾峰彇浠樻浠锋牸
+ $rt = $this->get_pay_info($fid, $field, $sku, $ff);
+ if ($rt['total'] <= 0) {
+ return dr_return_data(0, dr_lang('閲戦[%s]涓嶈鑼', $rt['total']));
+ } elseif ($rt['mid'] != $post['mark']) {
+ return dr_return_data(0, dr_lang('鏀粯淇℃伅楠岃瘉澶辫触'));
+ }
+ $touid = $rt['touid'];
+ $tousername = $rt['tousername'];
+ $title = $rt['title'];
+ $money = -(float)$rt['total'];
+ if ($this->uid == $touid) {
+ return dr_return_data(0, dr_lang('涓嶈兘瀵硅嚜宸变粯娆'));
+ }
+ break;
+
+ default:
+ return dr_return_data(0, dr_lang('鏈畾涔夌殑鏀粯鏂瑰紡[%s]', $rname));
+ break;
+ }
+
+ break;
+ }
+
+ // 鍒ゆ柇鎺ュ彛
+ $apifile = ROOTPATH.'api/pay/'.$post['type'].'/pay.php';
+ if (!is_file($apifile)) {
+ return dr_return_data(0, IS_DEV ? dr_lang('鏀粯鎺ュ彛鏂囦欢锛%s锛変笉瀛樺湪', $post['type']) : dr_lang('鏀粯鎺ュ彛鏂囦欢涓嶅瓨鍦'));
+ }
+
+ // 澧炲姞娴佹按璁板綍
+ return $this->add_paylog([
+ 'uid' => $post['uid'],
+ 'username' => $post['username'],
+ 'touid' => $touid,
+ 'tousername' => $tousername,
+ 'mid' => $post['mark'],
+ 'title' => $title,
+ 'value' => $money,
+ 'type' => $post['type'],
+ 'status' => 0,
+ 'url' => $post['url'],
+ 'result' => (string)$post['result'],
+ 'paytime' => 0,
+ 'inputtime' => SYS_TIME,
+ ]);
+ }
+
+ // 璋冪敤鏀粯鎺ュ彛
+ public function dopay($apifile, $data) {
+
+ $id = $data['id']; // 鏀粯璁板綍鐨刬d
+
+ // 鐢熸垚鍞竴鏀粯id 鎺ュ彛浣跨敤
+ $sn = $pid = $this->get_pay_sn($data);
+
+ // 鎺ュ彛閰嶇疆鍙傛暟
+ $config = \Phpcmf\Service::C()->member_cache['payapi'][$data['type']];
+
+ $return = [];
+ $data['value'] = abs($data['value']);
+ require $apifile;
+
+ return $return;
+ }
+
+ // 缂撳瓨鍙敤鐨勬敮浠樺瓧娈
+ public function cache() {
+
+ $cache = [];
+ \Phpcmf\Service::L('cache')->set_file('pay', $cache);
+ return;
+ }
+
+
+ // 鑾峰彇浜屾寮鍙戝璞
+ public function my_pay_obj($name) {
+ list($app, $class) = explode('_', $name);
+ $classFile = dr_get_app_dir($app).'Models/'.ucfirst($class).'.php';
+ if (!is_file($classFile)) {
+ CI_DEBUG && log_message('debug', '鏀粯瀵硅薄('.$name.')绫绘枃浠讹紙'.$classFile.'锛変笉瀛樺湪');
+ return;
+ }
+ return \Phpcmf\Service::M($class, $app);
+ }
+
+ // 娓呴櫎3澶╂湭浠樻鐨勬祦姘
+ public function clear_paylog() {
+ $this->db->table('member_paylog')->where('status', 0)->where('inputtime <'.(SYS_TIME - 3600*24*3))->delete();
+ }
+
+}
\ No newline at end of file
diff --git a/dayrui/App/Pay/Views/pay.html b/dayrui/App/Pay/Views/pay.html
new file mode 100644
index 0000000..02b063e
--- /dev/null
+++ b/dayrui/App/Pay/Views/pay.html
@@ -0,0 +1,59 @@
+{template "header.html"}
+
+
{dr_lang('涓烘寚瀹氳处鎴疯繘琛屽厖鍊奸噾棰')}
+
+
+ {$form}
+
+
+
+ {dr_lang('鐢ㄦ埛鍏呭')}
+
+
+
+
+
+
+ {dr_lang('纭畾鎿嶄綔')}
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Pay/Views/pay_freeze.html b/dayrui/App/Pay/Views/pay_freeze.html
new file mode 100644
index 0000000..6288081
--- /dev/null
+++ b/dayrui/App/Pay/Views/pay_freeze.html
@@ -0,0 +1,52 @@
+{template "header.html"}
+
+
{dr_lang('涓烘寚瀹氳处鎴疯繘琛屽喕缁撹祫閲')}
+
+
+ {$form}
+
+
+
+ {dr_lang('璧勯噾鍐荤粨')}
+
+
+
+
+
+
+ {dr_lang('纭畾鎿嶄綔')}
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Pay/Views/payapi.html b/dayrui/App/Pay/Views/payapi.html
new file mode 100644
index 0000000..9079357
--- /dev/null
+++ b/dayrui/App/Pay/Views/payapi.html
@@ -0,0 +1,252 @@
+{template "header.html"}
+
+
+
+
+
+ {$form}
+
+
+
+
+
+ {dr_lang('鏀粯鎺ュ彛')}
+
+
+
+
+
+
+
+
+ {php $dr_pay_n = 0;}
+ {loop $data $dir $t}
+ {if is_file(ROOTPATH.'api/pay/'.$dir.'/setting.php')}
+
+
+
{$t.config.icon} {dr_lang($t.config.name)}
+ {dr_lang('宸︿晶鍙嫋鍔ㄦ帓搴')}
+
+
+
+ {php $dr_pay_n++;}
+ {/if}
+ {/loop}
+
+
+
+
+
+
+
+
+
+
+{template "footer.html"}
diff --git a/dayrui/App/Pay/Views/payconfig.html b/dayrui/App/Pay/Views/payconfig.html
new file mode 100644
index 0000000..94a7302
--- /dev/null
+++ b/dayrui/App/Pay/Views/payconfig.html
@@ -0,0 +1,92 @@
+{template "header.html"}
+
+
+ {$form}
+
+
+
+
+
+
+
+
+
+ {if dr_is_app('explog')}
+
+ {/if}
+ {if dr_is_app('scorelog')}
+
+
+
+ {/if}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Pay/Views/paylog_edit.html b/dayrui/App/Pay/Views/paylog_edit.html
new file mode 100644
index 0000000..75fda72
--- /dev/null
+++ b/dayrui/App/Pay/Views/paylog_edit.html
@@ -0,0 +1,159 @@
+{template "header.html"}
+
+
{dr_lang('鍗曠瑪浜ゆ槗鐨勮缁嗗唴瀹')}
+
+
+ {dr_form_hidden()}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {if $data.paytime}
+
+ {/if}
+ {if $data.result}
+
+ {/if}
+
+ {if $is_remit && $data.status == 2 && $data.type == 'remit'}
+
+
+ {else if $is_meet && $data.status == 5 && $data.type == 'meet'}
+
+
+ {/if}
+
+
+
+
+
+
+ {if ($is_remit && $data.status == 2 && $data.type == 'remit') || ($is_meet && $data.status == 5 && $data.type == 'meet')}
+ {dr_lang('鎻愪氦')}
+ {/if}
+ {dr_lang('鍒犻櫎')}
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Pay/Views/paylog_list.html b/dayrui/App/Pay/Views/paylog_list.html
new file mode 100644
index 0000000..8341222
--- /dev/null
+++ b/dayrui/App/Pay/Views/paylog_list.html
@@ -0,0 +1,115 @@
+{template "header.html"}
+
+{template "api_list_date_search.html"}
+
+
+
+
+
+ {dr_form_hidden()}
+
+
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Pay/Views/paylog_system.html b/dayrui/App/Pay/Views/paylog_system.html
new file mode 100644
index 0000000..c267434
--- /dev/null
+++ b/dayrui/App/Pay/Views/paylog_system.html
@@ -0,0 +1,42 @@
+{template "header.html"}
+
+
+ {$form}
+
+
+
+
+{template "footer.html"}
\ No newline at end of file
diff --git a/dayrui/App/Weixin/Config/App.php b/dayrui/App/Weixin/Config/App.php
new file mode 100644
index 0000000..2c123d6
--- /dev/null
+++ b/dayrui/App/Weixin/Config/App.php
@@ -0,0 +1,10 @@
+ 'app',
+ 'name' => '寰俊',
+ 'author' => '杩呯澘浜戣蒋浠',
+ 'icon' => 'fa fa-weixin',
+
+];
\ No newline at end of file
diff --git a/dayrui/App/Weixin/Config/Before.php b/dayrui/App/Weixin/Config/Before.php
new file mode 100644
index 0000000..2e5f2bd
--- /dev/null
+++ b/dayrui/App/Weixin/Config/Before.php
@@ -0,0 +1,11 @@
+鎻掍欢');
+}
+
+return dr_return_data(1, 'ok');
diff --git a/dayrui/App/Weixin/Config/Cache.php b/dayrui/App/Weixin/Config/Cache.php
new file mode 100644
index 0000000..6bf59a1
--- /dev/null
+++ b/dayrui/App/Weixin/Config/Cache.php
@@ -0,0 +1,14 @@
+ 椤圭洰鐩綍
+ *
+ **/
+
+return [
+
+ 'weixin' => 'weixin',
+
+];
\ No newline at end of file
diff --git a/dayrui/App/Weixin/Config/Cbottom.php b/dayrui/App/Weixin/Config/Cbottom.php
new file mode 100644
index 0000000..58692db
--- /dev/null
+++ b/dayrui/App/Weixin/Config/Cbottom.php
@@ -0,0 +1,12 @@
+ 'fa fa-weixin',
+ 'name' => dr_lang('杞瓨涓哄井淇″唴瀹瑰簱'.WEIXIN_MORE_NAME),
+ 'uri' => 'weixin/content/module_add',
+ 'url' => 'javascript:;" onclick="dr_module_send_ajax(\''.dr_url('weixin/content/module_add', ['mid' => '{mid}']).'\')',
+ ],
+
+];
\ No newline at end of file
diff --git a/dayrui/App/Weixin/Config/Clink.php b/dayrui/App/Weixin/Config/Clink.php
new file mode 100644
index 0000000..8d974c3
--- /dev/null
+++ b/dayrui/App/Weixin/Config/Clink.php
@@ -0,0 +1,23 @@
+ '寰俊瀹㈡湇缇ゅ彂'.WEIXIN_MORE_NAME, // 绔欑偣鏉冮檺鏄彃浠剁殑閾炬帴鍚嶇О
+ 'icon' => 'fa fa-weixin', // 鍥炬爣
+ 'color' => 'green', // 棰滆壊class red green blue
+ 'url' => 'javascript:layer.confirm(\'鎮ㄧ‘瀹氳鎺ㄩ佸悧锛焅', { btn: [\'鏄痋',\'鍚'] }, function(){layer.closeAll(); dr_iframe_show(\'\', \''.SELF.'?s=weixin&c=send&m=show_add&mid={mid}&id={cid}\'); });', // 鍚庡彴閾炬帴锛氬浜庣偣鍑荤殑鍦板潃mid鏄ā鍧楃洰褰曪紝cid鏄唴瀹筰d
+ 'uri' => 'weixin/send/add', // 瀵瑰簲鐨剈ri鏉冮檺鍒ゆ柇锛屽悗闈㈢珷鑺備細浠嬬粛鏉冮檺鍐欐硶
+ 'field' => '', // 缁熻鏁伴噺鐨勫瓧娈碉紝濉啓妯″潡鍐呭鐨勪富琛ㄥ瓧娈碉紝鍙兘濉啓int鏁板瓧绫诲瀷鐨勫瓧娈
+ ],*/
+ [
+ 'name' => '寰俊妯℃澘娑堟伅'.WEIXIN_MORE_NAME, // 绔欑偣鏉冮檺鏄彃浠剁殑閾炬帴鍚嶇О
+ 'icon' => 'fa fa-weixin', // 鍥炬爣
+ 'color' => 'red', // 棰滆壊class red green blue
+ 'url' => 'javascript:layer.confirm(\'鎮ㄧ‘瀹氳鎺ㄩ佸悧锛焅', { btn: [\'鏄痋',\'鍚'] }, function(){ layer.closeAll(); dr_bfb_submit(\'\',\'myform\', \''.SELF.'?s=weixin&c=sendtpl&m=show_add&mid={mid}&id={cid}\') });', // 鍚庡彴閾炬帴锛氬浜庣偣鍑荤殑鍦板潃mid鏄ā鍧楃洰褰曪紝cid鏄唴瀹筰d
+ 'uri' => 'weixin/sendtpl/add', // 瀵瑰簲鐨剈ri鏉冮檺鍒ゆ柇锛屽悗闈㈢珷鑺備細浠嬬粛鏉冮檺鍐欐硶
+ 'field' => '', // 缁熻鏁伴噺鐨勫瓧娈碉紝濉啓妯″潡鍐呭鐨勪富琛ㄥ瓧娈碉紝鍙兘濉啓int鏁板瓧绫诲瀷鐨勫瓧娈
+ 'check' => 'is_tpl_use',
+ ],
+
+];
\ No newline at end of file
diff --git a/dayrui/App/Weixin/Config/Filters.php b/dayrui/App/Weixin/Config/Filters.php
new file mode 100644
index 0000000..7e508eb
--- /dev/null
+++ b/dayrui/App/Weixin/Config/Filters.php
@@ -0,0 +1,13 @@
+ [
+ 'weixin/home/index'
+ ],
+
+];
\ No newline at end of file
diff --git a/dayrui/App/Weixin/Config/Hooks.php b/dayrui/App/Weixin/Config/Hooks.php
new file mode 100644
index 0000000..fd14240
--- /dev/null
+++ b/dayrui/App/Weixin/Config/Hooks.php
@@ -0,0 +1,123 @@
+get_auth_data('more_weixin', 1);
+if (!$more) {
+ $more = 1;
+} else {
+ // 闃叉涓㈠け
+ \Phpcmf\Service::L('cache')->set_auth_data('more_weixin', $more, 1);
+}
+
+if (isset($_GET['gzh_id']) && $_GET['gzh_id']) {
+ $more = intval($_GET['gzh_id']);
+}
+
+$data = \Phpcmf\Service::L('cache')->get_file('app_weixin', $more); // 閰嶇疆
+if (!$data) {
+ $more = 1;
+}
+
+define('WEIXIN_MORE_ID', $more);
+define('WEIXIN_MORE_NAME', $data ? '銆'.$data.'銆' : '');
+
+\Phpcmf\Hooks::on('cms_init', function() {
+ // 寰俊涓闂綉绔欐椂锛屾湭鐧诲綍鏃剁洿鎺ユ巿鏉冨井淇$櫥褰
+ if (IS_API
+ || IS_API_HTTP
+ || in_array(APP_DIR, ['weixin', 'api', 'member'])
+ || in_array(\Phpcmf\Service::L('Router')->class, ['register', 'login', 'api', 'go'])) {
+ return;
+ } elseif (!IS_MEMBER && !\Phpcmf\Service::C()->uid) {
+ \Phpcmf\Service::C()->init_file('weixin');
+ $config = \Phpcmf\Service::M('Weixin', 'Weixin')->get_config('config'); // 閰嶇疆
+ if (isset($config['autologin']) && $config['autologin']
+ && strpos((string)$_SERVER['HTTP_USER_AGENT'], 'MicroMessenger')) {
+ // 鍏紬鍙峰唴鑷姩鐧婚檰
+ if ($config['autologin'] == 1) {
+ dr_redirect(SITE_URL.'index.php?s=weixin&c=go&url='.urlencode(FC_NOW_URL));
+ } else {
+ // 鎻愮ず缁戝畾锛氶潤榛樿幏鍙杘penid锛屽凡缁戝畾鍒欑洿鎺ョ櫥褰曪紝鏈粦瀹氬垯鎻愮ず
+ $openid = \Phpcmf\Service::L('input')->get_cookie('weixin_gzh_openid');
+ if (!$openid) {
+ dr_redirect(SITE_URL.'index.php?s=weixin&c=go&m=check&url='.urlencode(FC_NOW_URL));
+ } else {
+ $uid = 0;
+ $user = \Phpcmf\Service::M()->table(weixin_wxtable('user'))->where('openid', $openid)->getRow();
+ $oauth = \Phpcmf\Service::M()->table('member_oauth')->where('oauth', 'wechat')->where('oid', $openid)->getRow();
+ if (!$user || !$user['uid']) {
+ if ($oauth) {
+ $uid = $oauth['uid'];
+ }
+ } else {
+ $uid = $user['uid'];
+ }
+ if ($uid) {
+ $member = \Phpcmf\Service::M('member')->member_info($uid);
+ if ($member) {
+ $user && \Phpcmf\Service::M()->table(weixin_wxtable('user'))->update($user['id'], ['uid' => $uid]);
+ $oauth && \Phpcmf\Service::M()->table('member_oauth')->update($oauth['id'], ['uid' => $uid]);
+ \Phpcmf\Service::M('member')->save_cookie($member, 1);
+ XR_C()->_msg(1, dr_lang('鑷姩鐧诲綍鎴愬姛'), FC_NOW_URL);
+ } else {
+ $user && \Phpcmf\Service::M()->table(weixin_wxtable('user'))->update($user['id'], ['uid' => 0]);
+ $oauth && \Phpcmf\Service::M()->table('member_oauth')->update($oauth['id'], ['uid' => 0]);
+ $uid = 0;
+ XR_C()->_msg(0, dr_lang('璐﹀彿涓嶅瓨鍦紝瑙g粦鎴愬姛'));
+ }
+ }
+ if (!$uid) {
+ $text = $config['bang_text'] ? $config['bang_text'] : '鎮ㄨ繕娌℃湁缁戝畾鏈珯璐﹀彿锛屾槸鍚︾珛鍗崇粦瀹氾紵';
+ define('MY_WEIXIN_BIND_URL', SITE_URL.'index.php?s=weixin&c=go&url='.urlencode(FC_NOW_URL));
+ define('MY_WEIXIN_BIND_TEXT', $text);
+ }
+ }
+
+ }
+
+ }
+ }
+});
+
+
+
+\Phpcmf\Hooks::on('cms_view_end', function() {
+
+ if (!defined('MY_WEIXIN_BIND_URL') || !MY_WEIXIN_BIND_URL) {
+ return;
+ } elseif (IS_AJAX || IS_API_HTTP || defined('SC_HTML_FILE')) {
+ return;
+ }
+
+ $cookieName = 'weixin_bind_prompt';
+ $today = date('Ymd', SYS_TIME);
+ if (\Phpcmf\Service::L('input')->get_cookie($cookieName) == $today) {
+ return;
+ }
+ \Phpcmf\Service::L('input')->set_cookie($cookieName, $today, 86400);
+
+ $url = MY_WEIXIN_BIND_URL;
+ $text = json_encode(MY_WEIXIN_BIND_TEXT, JSON_UNESCAPED_UNICODE);
+ $script = '';
+
+ if (ob_get_level() > 0) {
+ $html = ob_get_clean();
+ if (stripos($html, '