Initial project files: BESCMS full source
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
'type' => 'app',
|
||||
'name' => '建站系统大众版',
|
||||
'author' => '迅睿云软件',
|
||||
'icon' => 'fa fa-th-large',
|
||||
|
||||
];
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
// 自动加载识别文件
|
||||
|
||||
return [
|
||||
|
||||
/**
|
||||
* 命名空间映射关系
|
||||
*/
|
||||
'psr4' => [
|
||||
|
||||
|
||||
],
|
||||
|
||||
/**
|
||||
* 类名映射关系
|
||||
*/
|
||||
'classmap' => [
|
||||
|
||||
'Phpcmf\Member\Module' => IS_USE_MODULE.'Extends/Member/Module.php',
|
||||
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
if (!method_exists(\Phpcmf\Service::M('table'), 'install_schema')) {
|
||||
return dr_return_data(0, '请先升级迅睿系统后再安装本插件');
|
||||
}
|
||||
|
||||
if (\Phpcmf\Service::M()->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');
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
$add = [];
|
||||
$module_more = $module = $cname = [];
|
||||
$cname[] = '更新模块域名目录';
|
||||
if (dr_is_app('module')) {
|
||||
$add['module1'] = ['手动重建内容搜索索引', 'update_search_index'];
|
||||
$cname[] = '更新模块域名目录';
|
||||
$module = \Phpcmf\Service::L('cache')->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}
|
||||
<tr>
|
||||
<td>
|
||||
<span class="badge badge-success"> {$key} </span>
|
||||
</td>
|
||||
<td>
|
||||
{dr_lang($t[0])}
|
||||
</td>
|
||||
<td style="overflow:auto">
|
||||
<label>
|
||||
<a href="javascript:my_update_cache('{$id}', '{$t[1]}');" class="btn red btn-xs"><i class="fa fa-refresh"></i> {dr_lang('立即执行')} </a>
|
||||
</label>
|
||||
<label id="dr_{$id}_result" >
|
||||
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
{php $key=$key+1;}
|
||||
{/loop}
|
||||
<tr>
|
||||
<td>
|
||||
<span class="badge badge-success">{$key++}</span>
|
||||
</td>
|
||||
<td>
|
||||
{dr_lang('新增或变更栏目后,需要更新栏目缓存数据')}
|
||||
</td>
|
||||
<td style="overflow:auto">
|
||||
<label>
|
||||
<a href="javascript:dr_iframe_show('{dr_lang('更新共享栏目')}', '{dr_url('module/api/update_category_repair')}&all=1&mid=share', '500px', '300px');" class="btn blue btn-xs"><i class="fa fa-cog"></i> {dr_lang('共享栏目')} </a>
|
||||
</label>
|
||||
{loop $module $c}
|
||||
{if !$c.share}
|
||||
<label>
|
||||
<a href="javascript:dr_iframe_show('{dr_lang($c.name)}', '{dr_url('module/api/update_category_repair')}&all=1&mid={$c.dirname}', '500px', '300px');" class="btn blue btn-xs"><i class="{dr_icon($c.icon)}"></i> {dr_lang($c.name)} </a>
|
||||
</label>
|
||||
{/if}
|
||||
{/loop}
|
||||
{if $module_more}
|
||||
<div class="btn-group" style="margin-top:0; margin-left: 10px">
|
||||
<button type="button" class="btn btn-xs btn-default ">{dr_lang('更多')}</button>
|
||||
<button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-angle-down"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
{loop $module_more $c}
|
||||
{if !$c.share}
|
||||
<li>
|
||||
<a href="javascript:dr_iframe_show('{dr_lang($c.name)}', '{dr_url('module/api/update_category_repair')}&all=1&mid={$c.dirname}', '500px', '300px');"><i class="{dr_icon($c.icon)}"></i> {dr_lang($c.name)} </a>
|
||||
</li>
|
||||
{/if}
|
||||
{/loop}
|
||||
</ul>
|
||||
</div>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="badge badge-success">{$key++}</span>
|
||||
</td>
|
||||
<td>
|
||||
{dr_lang('内容地址与设置地址不同步时,更新内容URL地址')}
|
||||
</td>
|
||||
<td style="overflow:auto">
|
||||
{loop $module $c}
|
||||
<label>
|
||||
<a href="javascript:dr_iframe_show('{dr_lang($c.name)}', '{dr_url('api/update_url')}&mid={$c.dirname}', '500px', '300px');" class="btn blue btn-xs"><i class="{dr_icon($c.icon)}"></i> {dr_lang($c.name)} </a>
|
||||
</label>
|
||||
{/loop}
|
||||
{if $module_more}
|
||||
<div class="btn-group" style="margin-top:0; margin-left: 10px">
|
||||
<button type="button" class="btn btn-xs btn-default ">{dr_lang('更多')}</button>
|
||||
<button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-angle-down"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
{loop $module_more $c}
|
||||
<li>
|
||||
<a href="javascript:dr_iframe_show('{dr_lang($c.name)}', '{dr_url('api/update_url')}&mid={$c.dirname}', '500px', '300px');"><i class="{dr_icon($c.icon)}"></i> {dr_lang($c.name)} </a>
|
||||
</li>
|
||||
{/loop}
|
||||
</ul>
|
||||
</div>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 缓存参数配置
|
||||
*
|
||||
* 模型名称 => 项目目录
|
||||
*
|
||||
**/
|
||||
|
||||
return [
|
||||
|
||||
|
||||
];
|
||||
@@ -0,0 +1,248 @@
|
||||
<?php
|
||||
/**
|
||||
* 本文件是框架系统文件,二次开发时不可以修改本文件
|
||||
**/
|
||||
|
||||
/**
|
||||
* 模块内容表结构及字段
|
||||
* table:规范化 Schema(fields / indexes / comment);亦兼容 Dever 导出的 CREATE SQL 字符串
|
||||
*/
|
||||
|
||||
return [
|
||||
|
||||
'table' => [
|
||||
|
||||
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 \'作者id\'',
|
||||
'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 \'录入者ip\'',
|
||||
'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 \'作者uid\'',
|
||||
'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('内容'),
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
];
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
$code = file_get_contents(CMSPATH.'Control/Api/Run.php');
|
||||
if ($code && strpos($code, 'post_time')) {
|
||||
return; // 老程序不执行
|
||||
}
|
||||
|
||||
// 批量执行站点动作
|
||||
foreach ($this->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) {
|
||||
// 获取锁成功,执行你的代码
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* CSRF过滤白名单
|
||||
*/
|
||||
|
||||
return [
|
||||
|
||||
'home' => [
|
||||
'cms/api/related',
|
||||
'cms/api/related',
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,948 @@
|
||||
<?php
|
||||
|
||||
\Phpcmf\Hooks::on('index_page', function() {
|
||||
if (is_file(COREPATH.'Control/Html.php')) {
|
||||
require COREPATH.'Control/Html.php';
|
||||
$ci = \Phpcmf\Service::C();
|
||||
// 跳过构造函数:避免 IS_COMMON 下重复初始化,且不覆盖 Common 单例
|
||||
$ref = new \ReflectionClass(\Phpcmf\Control\Html::class);
|
||||
$c = $ref->newInstanceWithoutConstructor();
|
||||
// 同步当前控制器的 public 属性(site_info、member 等)
|
||||
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);
|
||||
}
|
||||
// 获取所属站点id
|
||||
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) : '';
|
||||
}
|
||||
}
|
||||
|
||||
// 获取内容的tags
|
||||
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(
|
||||
'\'(?!((<.*?)|(<a.*?)|(<strong.*?)))('.str_replace(["'", '-'], ["\'", '\-'], preg_quote($name)).')(?!(([^<>]*?)>)|([^>]*?</a>)|([^>]*?</strong>))\'si',
|
||||
'<a title="'.$name.'" href="'.$url.'"'.($blank ? ' target="_blank"' : '').'>'.$name.'</a>',
|
||||
$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): "<a href=\"{$murl}\">{$cat[$id]['name']}</a>") : $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();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 模块内容阅读量显示js
|
||||
*
|
||||
* @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 ? "" : "<span class=\"{$dom}\">0</span>";
|
||||
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."<script type=\"text/javascript\">var apiurl=\"".dr_web_prefix("index.php?s=api&c=module&siteid=".dr_module_siteid()."&app=".$dir)."\"; $.ajax({ type: \"GET\", url:apiurl+\"&m=hits&id={$id}\", dataType: \"jsonp\", success: function(data){ if (data.code) { ".$rt." } else { dr_tips(0, data.msg); } } }); </script>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 栏目下级或者同级栏目
|
||||
* $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 : '');
|
||||
|
||||
// 获取自定义URL
|
||||
$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 '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
/**
|
||||
* Cms_free 安装:urlrule/module + 站点共享表 + 免费版默认数据
|
||||
*/
|
||||
$rt = \Phpcmf\Service::M('table')->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 \'所有上级id\'',
|
||||
'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 \'下级所有id\'',
|
||||
'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);
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 菜单配置
|
||||
*/
|
||||
|
||||
|
||||
return [
|
||||
|
||||
'admin' => [
|
||||
|
||||
'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' => '自定义URL',
|
||||
'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',
|
||||
],
|
||||
]
|
||||
],
|
||||
|
||||
]
|
||||
|
||||
];
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
!$dirname && $dirname = APP_DIR;
|
||||
|
||||
if ($this->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('系统未安装共享模块,无法使用栏目').'<br>'.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);
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* URL解析规则
|
||||
* 例如: 114.html 对应 index.php?s=demo&c=show&id=114
|
||||
* 可以解析: "114.html" => 'index.php?s=demo&c=show&id=114',
|
||||
* 动态id解析: "([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", //【不带栏目路径】模块栏目列表(分页)(list-{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", //【不带栏目路径】模块内容页(show-{id}.html)
|
||||
|
||||
"search\/([a-z]+)\/(.+)\.html" => "index.php?s=$1&c=search&rewrite=$2", //【共享模块搜索】模块搜索页(分页)(search/{modname}/{param}.html)
|
||||
"search\/([a-z]+)\.html" => "index.php?s=$1&c=search", //【共享模块搜索】模块搜索页(search/{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})
|
||||
|
||||
];
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
// 加载主程序的路由
|
||||
require COREPATH.'Config/Routes.php';
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
$client = \Phpcmf\Service::R(WRITEPATH.'config/domain_client.php'); // 电脑域名对应的手机域名
|
||||
|
||||
// 开启自动跳转手机端(api、admin、member不跳转)
|
||||
if (!IS_API // api不跳转
|
||||
&& !IS_ADMIN // 后台不跳转
|
||||
&& !IS_MEMBER // 会员中心不跳
|
||||
&& !IS_API_HTTP // API请求不跳
|
||||
&& !IS_CLIENT // 终端不跳
|
||||
//&& !defined('IS_NOT_301') // 定义禁止301不跳
|
||||
//&& !defined('IS_NOT_301') // 定义禁止301不跳
|
||||
&& $client // 没有客户端不跳
|
||||
&& $this->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, '网站已过期');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
<?php
|
||||
/**
|
||||
* 本文件是框架系统文件,二次开发时不可以修改本文件
|
||||
**/
|
||||
|
||||
/**
|
||||
* 系统模块表(规范化 Schema:fields / indexes / comment)
|
||||
* Module 安装时走 Table::create_table → 驱动 createTable
|
||||
*/
|
||||
|
||||
return [
|
||||
|
||||
'_draft' => [
|
||||
'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 \'作者uid\'',
|
||||
'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 \'作者uid\'',
|
||||
'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 \'操作人uid\'',
|
||||
'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 \'作者uid\'',
|
||||
'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 \'所有上级id\'',
|
||||
'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 \'下级所有id\'',
|
||||
'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 \'作者uid\'',
|
||||
'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 \'作者uid\'',
|
||||
'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 \'作者uid\'',
|
||||
'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 \'作者uid\'',
|
||||
'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`)',
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
// 无固定业务表;模块挂载表由插件后台卸载逻辑处理
|
||||
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 更新数据结构
|
||||
**/
|
||||
|
||||
$prefix = \Phpcmf\Service::M()->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)) {
|
||||
// 创建字段 代码
|
||||
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', '客户端ip信息');
|
||||
}
|
||||
$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 \'更新时间\'');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 程序版本控制
|
||||
*/
|
||||
|
||||
return [
|
||||
|
||||
'id' => '928',
|
||||
'version' => '4.1',
|
||||
'license' => '00000000000000000',
|
||||
'updatetime' => '2023-3-1',
|
||||
|
||||
];
|
||||
Reference in New Issue
Block a user