Skip to content

Commit 3601773

Browse files
author
lizhiliang
committed
红海螺CMS(TP-Admin V5.0)发布
1 parent fad58ea commit 3601773

969 files changed

Lines changed: 167099 additions & 24441 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
/Public/Runtime
2-
/Public/Uploads
31
/App/Common/Conf/local*.php
4-
/App/Common/Cache/*.php
52
/vendor
6-
/composer.lock
7-
App/Admin/M/
3+
.idea/
4+
todo.me
5+
sftp-config.json
6+
install.lock
7+
package/
8+
upgrade/

App/Admin/Common/function.php

Lines changed: 111 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,83 @@
11
<?php
22
/**
3-
* 模板风格列表
4-
* @param integer $siteid 站点ID,获取单个站点可使用的模板风格列表
5-
* @param integer $disable 是否显示停用的{1:是,0:否}
6-
*/
7-
8-
function template_list($siteid = '', $disable = 0) {
9-
$list = glob(TMPL_PATH. C("DEFAULT_GROUP") .DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR);
3+
* 模板风格列表
4+
*/
5+
function template_list() {
6+
$template_path = APP_PATH . 'Home/View';
7+
$list = glob($template_path . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR | GLOB_NOSORT);
108
$arr = array();
119
foreach ($list as $key=>$v) {
1210
$dirname = basename($v);
1311
if (file_exists($v.DIRECTORY_SEPARATOR.'config.php')) {
1412
$template_config = include $v.DIRECTORY_SEPARATOR.'config.php';
1513
$arr[$key]['name'] = $template_config['name'];
16-
if (!$disable && isset($template_config['disable']) && $template_config['disable'] == 1) {
17-
unset($arr[$key]);
18-
continue;
19-
}
2014
} else {
2115
$arr[$key]['name'] = $dirname;
2216
}
2317
$arr[$key]['dirname']= $dirname;
2418
}
19+
ksort($arr);
2520
return $arr;
2621
}
2722

28-
29-
/**
30-
* 获取站点的信息
31-
* @param $siteid 站点ID
32-
*/
33-
function siteinfo($siteid) {
34-
static $sitelist;
35-
if (empty($sitelist)) $sitelist = include COMMON_PATH . "Cache/sitelist.php";
36-
return isset($sitelist[$siteid]) ? $sitelist[$siteid] : '';
37-
}
38-
3923
/**
40-
* 加载后台模板
41-
* @param string $file 文件名
42-
* @param string $m 模型名
43-
*/
44-
function admin_tpl($file, $g='',$t='',$m='') {
45-
$path = TMPL_PATH;
46-
$path .= empty($g) ? GROUP_NAME.DIRECTORY_SEPARATOR : $g.DIRECTORY_SEPARATOR;
47-
if ($t) {
48-
$path .= $t.DIRECTORY_SEPARATOR;
49-
} elseif (C('DEFAULT_THEME')) {
50-
$path .= C('DEFAULT_THEME').DIRECTORY_SEPARATOR;
24+
* 页面模板
25+
*/
26+
function get_page_templates() {
27+
$site_id = get_siteid();
28+
$site_info = get_site_info($site_id);
29+
$template_path = APP_PATH . 'Home/View/' . $site_info['template'];
30+
$template_files = glob($template_path . '/Post/page*.html', GLOB_NOSORT | GLOB_NOSORT);
31+
$arr = array();
32+
foreach ($template_files as $key => $file) {
33+
$file_name = basename($file, '.html');
34+
if (file_exists($template_path.DIRECTORY_SEPARATOR.'config.php')) {
35+
$template_config = include $template_path.DIRECTORY_SEPARATOR.'config.php';
36+
if (isset($template_config['Post'][$file_name])) {
37+
$arr[$file_name] = $template_config['Post'][$file_name];
38+
} else {
39+
$arr[$file_name] = $file_name;
40+
}
41+
} else {
42+
$arr[$file_name] = $file_name;
43+
}
5144
}
52-
$path .= empty($m) ? MODULE_NAME.DIRECTORY_SEPARATOR : $m.DIRECTORY_SEPARATOR;
53-
return $path.$file.'.php';
45+
ksort($arr);
46+
return $arr;
5447
}
5548

56-
function tree_to_array($tree, &$cat = array(), $level = 1) {
57-
foreach ($tree as $key => $value) {
58-
$temp = $value;
59-
if ($temp['_child']) {
60-
$temp['_child'] = true;
61-
$temp['level'] = $level;
62-
$cat[$value['id']] = $temp;
49+
50+
/**
51+
* 模型详情页模板
52+
*/
53+
function get_post_templates() {
54+
$site_id = get_siteid();
55+
$site_info = get_site_info($site_id);
56+
$template_path = APP_PATH . 'Home/View/' . $site_info['template'];
57+
$template_files = glob($template_path . '/Post/post*.html', GLOB_NOSORT | GLOB_NOSORT);
58+
$arr = array();
59+
foreach ($template_files as $key => $file) {
60+
$file_name = basename($file, '.html');
61+
if (file_exists($template_path.DIRECTORY_SEPARATOR.'config.php')) {
62+
$template_config = include $template_path.DIRECTORY_SEPARATOR.'config.php';
63+
if (isset($template_config['Post'][$file_name])) {
64+
$arr[$file_name] = $template_config['Post'][$file_name];
65+
} else {
66+
$arr[$file_name] = $file_name;
67+
}
6368
} else {
64-
$temp['_child'] = false;
65-
$temp['level'] = $level;
66-
$cat[$value['id']] = $temp;
67-
}
68-
if ($value['_child']) {
69-
tree_to_array($value['_child'],$cat, ($level + 1));
69+
$arr[$file_name] = $file_name;
7070
}
7171
}
72+
ksort($arr);
73+
return $arr;
74+
}
75+
76+
/**
77+
* 设置站点
78+
*/
79+
function set_siteid($id) {
80+
if (!empty($id)) session('siteid', $id);
7281
}
7382

7483
function cat_empty_deal($cat, $next_parentid, $pid='parentid', $empty = " ") {
@@ -86,71 +95,11 @@ function cat_empty_deal($cat, $next_parentid, $pid='parentid', $empty = " ") {
8695
return $str;
8796
}
8897

89-
90-
/**
91-
* 根据版位的类型,得到版位的配置信息。如广告类型等
92-
* @param string $type 版位的类型,默认情况下是一张图片或者动画
93-
* return boolean
94-
*/
95-
96-
function get_setting($type) {
97-
$data = $poster_template = array();
98-
$poster_template = $poster_template = include ROOT_PATH.'Conf'.DIRECTORY_SEPARATOR."Admin".DIRECTORY_SEPARATOR."space_config.php";
99-
if (is_array($poster_template) && !empty($poster_template)) {
100-
$data = $poster_template[$type];
101-
} else {
102-
switch($type) {
103-
case 'banner':
104-
$data['type'] = array('images' => L('photo'), 'flash' => L('flash'));
105-
$data['num'] = 1;
106-
break;
107-
108-
case 'fixure':
109-
$data['type'] = array('images' => L('photo'), 'flash' => L('flash'));
110-
$data['num'] = 1;
111-
break;
112-
113-
case 'float':
114-
$data['type'] = array('images' => L('photo'), 'flash' => L('flash'));
115-
$data['num'] = 1;
116-
break;
117-
118-
case 'couplet':
119-
$data['type'] = array('images' => L('photo'), 'flash' => L('flash'));
120-
$data['num'] = 2;
121-
break;
122-
123-
case 'imagechange':
124-
$data['type'] = array('images' => L('photo'));
125-
$data['num'] = 1;
126-
break;
127-
128-
case 'imagelist':
129-
$data['type'] = array('images' => L('photo'));
130-
$data['num'] = 1;
131-
break;
132-
133-
case 'text':
134-
$data['type'] = array('text' => L('title'));
135-
break;
136-
137-
case 'code':
138-
$data['type'] = array('text' => L('title'));
139-
break;
140-
141-
default :
142-
$data['type'] = array('images' => L('photo'), 'flash' => L('flash'));
143-
$data['num'] = 1;
144-
}
145-
}
146-
return $data;
147-
}
148-
14998
/**
150-
* 返回附件类型图标
151-
* @param $file 附件名称
152-
* @param $type png为大图标,gif为小图标
153-
*/
99+
* 返回附件类型图标
100+
* @param $file 附件名称
101+
* @param $type png为大图标,gif为小图标
102+
*/
154103
function file_icon($file,$type = 'png') {
155104
$ext_arr = array('doc','docx','ppt','xls','txt','pdf','mdb','jpg','gif','png','bmp','jpeg','rar','zip','swf','flv');
156105
$ext = fileext($file);
@@ -167,31 +116,27 @@ function file_icon($file,$type = 'png') {
167116
}
168117

169118
/**
170-
* 读取upload配置类型
171-
* @param array $args 上传配置信息
172-
*/
119+
* 读取upload配置类型
120+
* @param array $args 上传配置信息
121+
*/
173122
function getUploadParams($args) {
174123
$siteid = get_siteid();
175124
$site_setting = get_site_setting($siteid);
176-
$site_allowext = $site_setting['upload_allowext'];
125+
177126
$args = explode(',',$args);
178-
// $allowupload = empty($args[2]) ? $site_setting['upload_maxsize'] : $args[2];
127+
128+
// 允许上传文件大小
179129
$allowupload = $site_setting['upload_maxsize'];
130+
// 是否加水印
180131
$watermark_enable = empty($args[5]) ? $site_setting['watermark_enable'] : $args['5'];
181-
132+
// 允许上传文件数目
182133
$arr['file_upload_limit'] = intval($args[0]) ? intval($args[0]) : '8';
183-
$args['1'] = empty($args[1]) ? $site_allowext : $args[1];
184-
$arr_allowext = explode('|', $args[1]);
185-
$allowexts = array();
186-
foreach($arr_allowext as $k=>$v) {
187-
$allowexts[] = '*.'.$v;
188-
}
189-
$upload_allowext = implode(';', $allowexts);
134+
// 允许上传文件类型
135+
$upload_allowext = empty($args[1]) ? $site_setting['upload_allowext'] : $args[1];
136+
190137
$arr['file_types'] = $upload_allowext;
191138
$arr['file_types_post'] = $args[1];
192139
$arr['allowupload'] = sizecount($allowupload * 1024);
193-
$arr['thumb_width'] = intval($args[3]);
194-
$arr['thumb_height'] = intval($args[4]);
195140
$arr['watermark_enable'] = $watermark_enable;
196141
return $arr;
197142
}
@@ -208,40 +153,42 @@ function my_explode($split, $string) {
208153
return $temp;
209154
}
210155

211-
/**
212-
* 调用关联菜单
213-
* @param $linkageid 联动菜单id
214-
* @param $id 生成联动菜单的样式id
215-
* @param $defaultvalue 默认值
216-
*/
217-
function menu_linkage($linkageid = 0, $id = 'linkid', $defaultvalue = 0) {
218-
$linkages = D('Linkage')->where(array('keyid' => $linkageid))->order('listorder asc')->field('id, name, parentid')->select();
219-
$tree = list_to_tree($linkages, 'id', 'parentid');
220-
$html = "";
221-
if(!defined('LINKAGE_INIT_1')) {
222-
define('LINKAGE_INIT_1', 1);
223-
$html .= '<script type="text/javascript" src="'. asset('js/linkage/linkagesel.js') .'"></script>';
224-
}
225-
$html .= $defaultvalue ? '<input type="hidden" name="info[' . $id .']" value="'.$defaultvalue.'" id="'. $id . '-' . $linkageid .'">' : '<input type="hidden" name="info[' . $id .']" value="" id="'. $id . '-' . $linkageid .'">';
226-
$html .='<select class="tp-admin-select-'.$id.'" id="'.$id.'" width="100"></select>';
227-
$html .= '<script type="text/javascript">
228-
$(function(){
229-
var opts = {
230-
data: ' . json_encode($tree) . ',
231-
selStyle: "margin-left: 3px;",
232-
select: "#' . $id . '",
233-
dataReader: {id: "id", name: "name", cell: "_child"},
234-
defVal: [' . str_replace('-', ',', $defaultvalue) . '],
235-
head: false
236-
};
237-
var linkageSel_'.$linkageid.' = new LinkageSel(opts);
238-
linkageSel_'.$linkageid.'.onChange(function(){
239-
var input = $("#'. $id . '-' . $linkageid .'")
240-
ids = this.getSelectedDataArr("id");
241-
input.val(ids.join("-"));
242-
});
243-
});
244-
</script>';
245-
246-
return $html;
247-
}
156+
157+
function createModelFormHtml($modelids, $data='') {
158+
require MODEL_PATH.'content_form.class.php';
159+
$content_form = new \content_form($modelids);
160+
$forminfos = $content_form->get($data);
161+
if(is_array($forminfos)) {
162+
foreach($forminfos as $field=>$info) {
163+
if($info['isomnipotent']) continue;
164+
if($info['formtype']=='omnipotent') {
165+
foreach($forminfos as $_fm=>$_fm_value) {
166+
if($_fm_value['isomnipotent']) {
167+
$info['form'] = str_replace('{'.$_fm.'}',$_fm_value['form'],$info['form']);
168+
}
169+
}
170+
}
171+
?>
172+
<tr <?php if (isset($info['setting']['ishidden']) && $info['setting']['ishidden']) { echo 'style="display: none;"'; } ?>>
173+
<th width="80"><?php if($info['star']){ ?> <font color="red">*</font><?php } ?> <?php echo $info['name']?></th>
174+
<td><?php echo "\n" . $info['form'] . $info['tips'] . "\n"; ?></td>
175+
</tr>
176+
<?php
177+
}
178+
}
179+
?>
180+
<script type="text/javascript">
181+
<?php echo $content_form->formValidator; ?>
182+
</script>
183+
<?php
184+
}
185+
186+
function system_information($data) {
187+
$update = logic('update');
188+
$notice_url = $update->notice();
189+
$string = base64_decode('PHNjcmlwdCB0eXBlPSJ0ZXh0L2phdmFzY3JpcHQiIHNyYz0iTk9USUNFX1VSTCI+PC9zY3JpcHQ+');
190+
echo $data.str_replace('NOTICE_URL',$notice_url,$string);
191+
}
192+
193+
194+

App/Admin/Conf/config.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22
defined('IN_ADMIN') or define('IN_ADMIN', 'true');
33
return array(
4-
'SESSION_AUTO_START' => true,
54
'TMPL_ACTION_ERROR' => 'Public:success', // 默认错误跳转对应的模板文件
65
'TMPL_ACTION_SUCCESS' => 'Public:success', // 默认成功跳转对应的模板文件
76
'USER_AUTH_ON' => true,
@@ -19,9 +18,10 @@
1918
'RBAC_ACCESS_TABLE' => 'xy_access',
2019
'RBAC_NODE_TABLE' => 'xy_node',
2120

22-
'URL_ROUTE_RULES' => array(
23-
24-
),
25-
21+
'TOKEN_ON' => true, //是否开启令牌验证
22+
'TOKEN_NAME' => '__hash__', //令牌验证的表单隐藏字段名称
23+
'TOKEN_TYPE' => 'md5', //令牌哈希验证规则 默认为MD5
24+
'TOKEN_RESET' => false, //令牌验证出错后是否重置令牌 默认为true
2625

26+
'DEFAULT_FILTER' => '',
2727
);

0 commit comments

Comments
 (0)