index.php
3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
/**
* [WeEngine System] Copyright (c) 20180428183619 WE7.CC
* WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
*/
define('IN_MOBILE', true);
require '../framework/bootstrap.inc.php';
load()->app('common');
load()->app('template');
require IA_ROOT . '/app/common/bootstrap.app.inc.php';
$acl = array(
'home' => array(
'default' => 'home',
),
'mc' => array(
'default' => 'home'
)
);
if ($_W['setting']['copyright']['status'] == 1) {
$_W['siteclose'] = true;
message('抱歉,站点已关闭,关闭原因:' . $_W['setting']['copyright']['reason']);
}
$multiid = intval($_GPC['t']);
if(empty($multiid)) {
$multiid = intval($unisetting['default_site']);
unset($setting);
}
$multi = pdo_fetch("SELECT * FROM ".tablename('site_multi')." WHERE id=:id AND uniacid=:uniacid", array(':id' => $multiid, ':uniacid' => $_W['uniacid']));
$multi['site_info'] = @iunserializer($multi['site_info']);
$styleid = !empty($_GPC['s']) ? intval($_GPC['s']) : intval($multi['styleid']);
$style = pdo_fetch("SELECT * FROM ".tablename('site_styles')." WHERE id = :id", array(':id' => $styleid));
$templates = uni_templates();
$templateid = intval($style['templateid']);
$template = $templates[$templateid];
$_W['template'] = !empty($template) ? $template['name'] : 'default';
$_W['styles'] = array();
if(!empty($template) && !empty($style)) {
$sql = "SELECT `variable`, `content` FROM " . tablename('site_styles_vars') . " WHERE `uniacid`=:uniacid AND `styleid`=:styleid";
$params = array();
$params[':uniacid'] = $_W['uniacid'];
$params[':styleid'] = $styleid;
$stylevars = pdo_fetchall($sql, $params);
if(!empty($stylevars)) {
foreach($stylevars as $row) {
if (strexists($row['variable'], 'img')) {
$row['content'] = tomedia($row['content']);
}
$_W['styles'][$row['variable']] = $row['content'];
}
}
unset($stylevars, $row, $sql, $params);
}
$_W['page'] = array();
$_W['page']['title'] = $multi['title'];
if(is_array($multi['site_info'])) {
$_W['page'] = array_merge($_W['page'], $multi['site_info']);
}
unset($multi, $styleid, $style, $templateid, $template, $templates);
if ($controller == 'wechat' && $action == 'card' && $do == 'use') {
header("location: index.php?i={$_W['uniacid']}&c=entry&m=paycenter&do=consume&encrypt_code={$_GPC['encrypt_code']}&card_id={$_GPC['card_id']}&openid={$_GPC['openid']}&source={$_GPC['source']}");
exit;
}
$controllers = array();
$handle = opendir(IA_ROOT . '/app/source/');
if(!empty($handle)) {
while($dir = readdir($handle)) {
if($dir != '.' && $dir != '..') {
$controllers[] = $dir;
}
}
}
if(!in_array($controller, $controllers)) {
$controller = 'home';
}
$init = IA_ROOT . "/app/source/{$controller}/__init.php";
if(is_file($init)) {
require $init;
}
$actions = array();
$handle = opendir(IA_ROOT . '/app/source/' . $controller);
if(!empty($handle)) {
while($dir = readdir($handle)) {
if($dir != '.' && $dir != '..' && strexists($dir, '.ctrl.php')) {
$dir = str_replace('.ctrl.php', '', $dir);
$actions[] = $dir;
}
}
}
if(empty($actions)) {
$str = '';
if(uni_is_multi_acid()) {
$str = "&j={$_W['acid']}";
}
header("location: index.php?i={$_W['uniacid']}{$str}&c=home?refresh");
}
if(!in_array($action, $actions)) {
$action = $acl[$controller]['default'];
}
if(!in_array($action, $actions)) {
$action = $actions[0];
}
require _forward($controller, $action);
function _forward($c, $a) {
$file = IA_ROOT . '/app/source/' . $c . '/' . $a . '.ctrl.php';
return $file;
}