-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetconfig.php
More file actions
221 lines (212 loc) · 4.7 KB
/
getconfig.php
File metadata and controls
221 lines (212 loc) · 4.7 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<?php
namespace ScpoPHP\Config {
/**基本配置 */
class Base
{
public static Self $now;
public function __construct(
/**默认字符编码 */
public $charset = 'UTF-8',
) {
Self::$now = $this;
}
}
new Base();
/**便捷错误处理 */
class Errpage
{
public static Self $now;
public function __construct(
/**默认错误显示页面 */
public $callback_page = '/errpage.html?',
/**默认回调参数键值 */
public $query_key = 'info',
/**默认数据序列化器 */
public $encoder = 'json_encode',
) {
Self::$now = $this;
}
}
new Errpage();
/**数据库操作配置 */
class Db
{
public static Self $now;
public function __construct(
/**连接参数 */
public $params = [
'hostname' => 'localhost',
'username' => 'root',
'password' => '123456',
'database' => 'mysql',
'port' => 3306,
'socket' => null
],
) {
Self::$now = $this;
}
}
new Db();
/**cookie简便函数相关 */
class Cookie
{
public static Self $now;
public function __construct(
/**setcookie默认参数 */
public $params = [
'value' => '',
'expires_or_options' => 0,
'path' => '',
'domain' => '',
'secure' => false,
'httponly' => false
],
) {
Self::$now = $this;
}
}
new Cookie();
}
// captcha.php
namespace ScpoPHP\Config {
/**验证码配置 */
class Captcha
{
/**图片宽 */
static public $width = 150;
/**图片高 */
static public $height = 45;
}
}
// user.php
namespace ScpoPHP\Config {
/**用户系统配置 */
class User {}
}
namespace ScpoPHP\Config\User {
/**账号数据表相关 */
class Acct {}
}
namespace ScpoPHP\Config\User\Acct {
/**账号数据表配置 */
class Table
{
/**账号数据表名称 */
static public $table = 'scpous_account';
/**主键字段名称 */
static public $identity = 'id';
/**密码字段名称 */
static public $password = 'password';
/**盐字段名称 */
static public $salt = 'salt';
/**其他字段 */
static public $addiinfo = array(
'username'
);
}
}
namespace ScpoPHP\Config\User\Acct\Table {
/**唯一索引复用相关配置
* @link http://scpo-php.seventop.top/user/acct/recov/ */
class Recov
{
/**是否启用复用 */
static public $enable = true;
/**复用字段 */
static public $column = array(
'id'
);
/**复用表后缀 则复用表名称为"${table_name}${suffix}${column_name}" */
static public $suffix = '_recov_';
}
}
namespace ScpoPHP\Config\User {
/**账号验证相关 */
class Auth
{
/**账号验证的方法
* @link http://scpo-php.seventop.top/user/method/ */
static public $method = 102;
}
}
namespace ScpoPHP\Config\User\Auth {
/**账号验证cookie相关 */
class Cookie
{
/**存储密码的字段名 */
static public $password = 'scpous-password';
/**存储主键的字段名 */
static public $identity = 'scpous-identity';
/**存储验证哈希的字段名 */
static public $authhash = 'scpous-authhash';
/**其他信息的字段名 */
static public $addiinfo = array(
'username' => 'scpous-username'
);
/**默认参数 */
static public $params = array(
'expires_or_options' => 3600 * 24 * 15,
'path' => '/',
'domain' => '',
'secure' => false,
'httponly' => false
);
/**
* 102号方法的哈希函数
*
* 默认函数仅为示例,
* 为了安全性请您重写此函数或者修改闭包函数`ScpoPHP\Config\User\Auth\Cookie::$my_hash102f`
* @param array $orig 应有一个参数接受要加密的信息的数组
* @return string 应返回哈希后得到的字符串
*/
static public function hash102f($orig)
{
if (($myf = self::$my_hash102f) !== false) return $myf($orig);
// 加盐
$str = hex2bin('C843906F02510E8C87ED9667F0525D689F1CF74F9A1594A5');
// 哈希
foreach ($orig as $val) $str .= $val;
return md5($str);
}
/**用户自定义102号方法哈希函数 */
static public $my_hash102f = false;
}
/**账号验证session相关 */
class Session
{
/**存储id的字段名 */
static public $identity = 'scpous-identity';
}
}
// email.php
namespace ScpoPHP\Config {
/**邮件发送SMTP服务器配置 */
class Smtp
{
public function __construct(
/**SMTP服务器地址 */
public $host = 'SMTP.163.com',
/**SMTP服务器端口 */
public $port = 25,
/**SMTP账号的名称 */
public $name = 'user',
/**SMTP账号的密码 */
public $pwd = 'PASSWORD',
) {}
}
/**邮件发送配置 */
class Email
{
public static Self $now;
public function __construct(
public $smtp = new Smtp(),
/**作为发送人显示的地址 */
public $addr = 'someone@163.com',
/**作为发送人使用的名称 */
public $name = 'someone',
) {
Self::$now = $this;
}
}
new Email();
}