切换导航条
此项目
正在载入...
登录
何书鹏
/
recruit
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
差异文件
浏览文件
作者
gaoyi
8 years ago
提交者
Karson
8 years ago
提交
937ebe6dcabd1509e0fdc5d194fb7755216c722d
2 个父辈
35fbc622
ffd780cf
Merge pull request !11 from gaoyi/master
显示空白字符变更
内嵌
并排对比
正在显示
8 个修改的文件
包含
130 行增加
和
5 行删除
application/admin/command/Install/fastadmin.sql
application/admin/controller/general/Config.php
application/common/library/Email.php
application/extra/site.php
application/index/view/layout/bootstrap.html
composer.json
public/assets/js/backend/general/config.js
public/assets/js/backend/general/configvalue.js
application/admin/command/Install/fastadmin.sql
查看文件 @
937ebe6
...
...
@@ -227,7 +227,7 @@ CREATE TABLE `fa_config` (
-- Records of `fa_config`
-- ----------------------------
BEGIN
;
INSERT
INTO
`fa_config`
VALUES
(
'1'
,
'name'
,
'basic'
,
'站点名称'
,
'请填写站点名称'
,
'string'
,
'FastAdmin'
,
''
,
'required'
,
''
),
(
'2'
,
'beian'
,
'basic'
,
'备案号'
,
'
'
,
'string'
,
''
,
''
,
''
,
''
),
(
'3'
,
'cdnurl'
,
'basic'
,
'CDN地址'
,
'如果使用CDN云储存请配置该值'
,
'string'
,
''
,
''
,
''
,
''
),
(
'4'
,
'version'
,
'basic'
,
'版本号'
,
'如果静态资源有变动请重新配置该值'
,
'string'
,
'1.0.1'
,
''
,
'required'
,
''
),
(
'5'
,
'timezone'
,
'basic'
,
'时区'
,
''
,
'string'
,
'Asia/Shanghai'
,
''
,
'required'
,
''
),
(
'6'
,
'forbiddenip'
,
'basic'
,
'禁止访问IP'
,
'一行一条记录'
,
'text'
,
''
,
''
,
''
,
''
),
(
'7'
,
'languages'
,
'basic'
,
'模块语言'
,
''
,
'array'
,
'{
\"
backend
\"
:
\"
zh-cn
\"
,
\"
frontend
\"
:
\"
zh-cn
\"
}'
,
''
,
'required'
,
''
),
(
'8'
,
'fixedpage'
,
'basic'
,
'后台默认页'
,
'请尽量输入左侧菜单栏存在的链接'
,
'string'
,
'dashboard'
,
''
,
'required'
,
''
),
(
'9'
,
'categorytype'
,
'dictionary'
,
'分类类型'
,
''
,
'array'
,
'{
\"
default
\"
:
\"
默认
\"
,
\"
page
\"
:
\"
单页
\"
,
\"
article
\"
:
\"
文章
\"
,
\"
test
\"
:
\"
测试
\"
}'
,
''
,
''
,
''
),
(
'10'
,
'configgroup'
,
'dictionary'
,
'配置分组'
,
''
,
'array'
,
'{
\"
basic
\"
:
\"
基础配置
\"
,
\"
email
\"
:
\"
邮件配置
\"
,
\"
dictionary
\"
:
\"
字典配置
\"
,
\"
user
\"
:
\"
会员配置
\"
,
\"
example
\"
:
\"
示例分组
\"
}'
,
''
,
''
,
''
);
INSERT
INTO
`fa_config`
VALUES
(
'1'
,
'name'
,
'basic'
,
'站点名称'
,
'请填写站点名称'
,
'string'
,
'FastAdmin'
,
''
,
'required'
,
''
),
(
'2'
,
'beian'
,
'basic'
,
'备案号'
,
'
粤ICP备15054802号-4'
,
'string'
,
''
,
''
,
''
,
''
),
(
'3'
,
'cdnurl'
,
'basic'
,
'CDN地址'
,
'如果使用CDN云储存请配置该值'
,
'string'
,
''
,
''
,
''
,
''
),
(
'4'
,
'version'
,
'basic'
,
'版本号'
,
'如果静态资源有变动请重新配置该值'
,
'string'
,
'1.0.1'
,
''
,
'required'
,
''
),
(
'5'
,
'timezone'
,
'basic'
,
'时区'
,
''
,
'string'
,
'Asia/Shanghai'
,
''
,
'required'
,
''
),
(
'6'
,
'forbiddenip'
,
'basic'
,
'禁止访问IP'
,
'一行一条记录'
,
'text'
,
''
,
''
,
''
,
''
),
(
'7'
,
'languages'
,
'basic'
,
'模块语言'
,
''
,
'array'
,
'{
\"
backend
\"
:
\"
zh-cn
\"
,
\"
frontend
\"
:
\"
zh-cn
\"
}'
,
''
,
'required'
,
''
),
(
'8'
,
'fixedpage'
,
'basic'
,
'后台默认页'
,
'请尽量输入左侧菜单栏存在的链接'
,
'string'
,
'dashboard'
,
''
,
'required'
,
''
),
(
'9'
,
'categorytype'
,
'dictionary'
,
'分类类型'
,
''
,
'array'
,
'{
\"
default
\"
:
\"
默认
\"
,
\"
page
\"
:
\"
单页
\"
,
\"
article
\"
:
\"
文章
\"
,
\"
test
\"
:
\"
测试
\"
}'
,
''
,
''
,
''
),
(
'10'
,
'configgroup'
,
'dictionary'
,
'配置分组'
,
''
,
'array'
,
'{
\"
basic
\"
:
\"
基础配置
\"
,
\"
email
\"
:
\"
邮件配置
\"
,
\"
dictionary
\"
:
\"
字典配置
\"
,
\"
user
\"
:
\"
会员配置
\"
,
\"
example
\"
:
\"
示例分组
\"
}'
,
''
,
''
,
''
),(
'11'
,
'mail_type'
,
'email'
,
'邮件发送方式'
,
'选择邮件发送方式'
,
'select'
,
'1'
,
'[
\"
请选择
\"
,
\"
SMTP
\"
,
\"
mail()函数
\"
]'
,
''
,
''
),(
'12'
,
'mail_smtp_host'
,
'email'
,
'SMTP[服务器]'
,
'错误的配置发送邮件会导致服务器超时'
,
'string'
,
'smtp.qq.com'
,
''
,
''
,
''
),(
'13'
,
'mail_smtp_port'
,
'email'
,
'SMTP[端口]'
,
'(不加密默认25,SSL默认465,TLS默认587)'
,
'string'
,
'465'
,
''
,
''
,
''
),(
'14'
,
'mail_smtp_user'
,
'email'
,
'SMTP[用户名]'
,
'(填写完整用户名)'
,
'string'
,
'10000'
,
''
,
''
,
''
),(
'15'
,
'mail_smtp_pass'
,
'email'
,
'SMTP[密码]'
,
'(填写您的密码)'
,
'string'
,
'password'
,
''
,
''
,
''
),(
'16'
,
'mail_verify_type'
,
'email'
,
'SMTP验证方式'
,
'(SMTP验证方式[推荐SSL])'
,
'select'
,
'2'
,
'[
\"
无
\"
,
\"
TLS
\"
,
\"
SSL
\"
]'
,
''
,
''
),(
'17'
,
'mail_from'
,
'email'
,
'发件人邮箱'
,
''
,
'string'
,
'10000@qq.com'
,
''
,
''
,
''
);
COMMIT
;
-- ----------------------------
...
...
application/admin/controller/general/Config.php
查看文件 @
937ebe6
...
...
@@ -2,6 +2,8 @@
namespace
app\admin\controller\general
;
use
think\Config
as
tpConfig
;
use
app\common\library\Email
;
use
app\common\controller\Backend
;
/**
...
...
@@ -233,4 +235,20 @@ class Config extends Backend
}
}
public
function
emailtest
()
{
$content
=
'<table style="width: 99.8%; "><tbody><tr><td id="QQMAILSTATIONERY" style="background:url(https://rescdn.qqmail.com/zh_CN/htmledition/images/xinzhi/bg/a_07.jpg) repeat-x #e4ebf5; min-height:550px; padding: 100px 55px 200px;">这是一封测试邮件,用于测试邮件配置是否正常!</td></tr></tbody></table>'
;
$site
=
tpConfig
::
get
(
"site"
);
$email
=
new
Email
;
$mailArr
=
Array
();
$mailArr
[
'mTo'
]
=
$site
[
'mail_from'
];
//收件人
$mailArr
[
'subject'
]
=
'这是一封测试邮件'
;
//邮件主题
$mailArr
[
'content'
]
=
$content
;
//邮件内容(html)
$mailArr
[
'fromNic'
]
=
'Fastadmin系统邮件'
;
//发件人昵称[可省略]
$mailArr
[
'toNic'
]
=
'亲爱的用户'
;
//收件人昵称[可省略]貌似无效
$data
=
$email
->
sendMail
(
$mailArr
[
'mTo'
],
$mailArr
[
'subject'
],
$mailArr
[
'content'
],
$mailArr
[
'fromNic'
],
$mailArr
[
'toNic'
]);
return
json
([
'data'
=>
$data
,
'code'
=>
200
,
'message'
=>
'操作完成'
]);
}
}
...
...
application/common/library/Email.php
0 → 100644
查看文件 @
937ebe6
<?php
namespace
app\common\library
;
use
think\Config
;
class
Email
{
/**
* 发送邮件
* @param string $mTo 收件人
* @param string $subject 邮件主题
* @param string $content 邮件内容(html)
* @param string $fromNic 发件人昵称
* @param string $toNic 收件人昵称
*/
public
function
sendMail
(
$mTo
=
''
,
$subject
=
''
,
$content
=
''
,
$fromNic
=
''
,
$toNic
=
''
)
{
$site
=
Config
::
get
(
"site"
);
$re
=
Vendor
(
'phpmailer.phpmailer.PHPMailerAutoload'
);
$mail
=
new
\PHPMailer
();
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail
->
isSMTP
();
//smtp需要鉴权 这个必须是true
$mail
->
Host
=
$site
[
'mail_smtp_host'
];
//SMTP服务器地址
$mail
->
SMTPAuth
=
true
;
// Enable SMTP authentication
$mail
->
Username
=
$site
[
'mail_smtp_user'
];
// SMTP 用戶名
$mail
->
Password
=
$site
[
'mail_smtp_pass'
];
// SMTP 密碼
switch
(
$site
[
'mail_verify_type'
])
// Enable TLS encryption, `ssl` also accepted
{
case
1
:
$mail
->
SMTPSecure
=
'tls'
;
break
;
case
2
:
$mail
->
SMTPSecure
=
'ssl'
;
break
;
default
:
$mail
->
SMTPSecure
=
''
;
}
$mail
->
Port
=
$site
[
'mail_smtp_port'
];
// 设置ssl连接smtp服务器的远程服务器端口号
$mail
->
setFrom
(
$site
[
'mail_from'
],
$fromNic
);
// [发件人],[昵称(可选)]
$mail
->
addAddress
(
$mTo
,
$toNic
);
// [收件人],[昵称(可选)]
//$mail->addReplyTo('xxxxxx@qq.com', 'Information'); // 回复地址(可选)
//$mail->addCC('xxxxxx@qq.com'); //好像是密送
//$mail->addBCC('xxxxxx@qq.com'); //好像是密送B
// $mail->addAttachment('/var/tmp/file.tar.gz'); // 添加附件
// $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // 附件名选项
$mail
->
isHTML
(
true
);
//邮件正文是否为html编码
$mail
->
Subject
=
$subject
;
//添加邮件主题
$mail
->
Body
=
$content
;
//邮件正文
//$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';//附加信息,可以省略
switch
(
$site
[
'mail_type'
])
{
case
1
:
if
(
!
$mail
->
send
())
{
//这里如果提交错误的smpt配置PHPmailer会卡住暂时不清楚为什么
$sendResult
[
'text'
]
=
$mail
->
ErrorInfo
;
$sendResult
[
'data'
]
=
false
;
return
$sendResult
;
}
else
{
$sendResult
[
'text'
]
=
'smtp发送成功'
;
$sendResult
[
'data'
]
=
true
;
return
$sendResult
;
}
break
;
case
2
://
使用
mail
方法发送邮件
$headers
=
'MIME-Version: 1.0'
.
"
\r\n
"
;
$headers
.=
'Content-type: text/html; charset=iso-8859-1'
.
"
\r\n
"
;
$headers
.=
'To: '
.
$toNic
.
' <'
.
$mTo
.
'>'
.
"
\r\n
"
;
//收件人
$headers
.=
'From: '
.
$fromNic
.
' <'
.
$site
[
'mail_from'
]
.
'>'
.
"
\r\n
"
;
//发件人
$sendResult
[
'data'
]
=
mail
(
$mTo
,
$subject
,
$content
,
$headers
);
if
(
$sendResult
[
'data'
])
{
$sendResult
[
'text'
]
=
'mail函数发送成功'
;
}
else
{
$sendResult
[
'text'
]
=
'mail函数发送失败'
;
}
return
$sendResult
;
break
;
default
:
$sendResult
[
'data'
]
=
false
;
$sendResult
[
'text'
]
=
'已关闭邮件发送'
;
return
$sendResult
;
}
}
}
...
...
application/extra/site.php
查看文件 @
937ebe6
...
...
@@ -2,7 +2,7 @@
return
array
(
'name'
=>
'FastAdmin'
,
'beian'
=>
''
,
'beian'
=>
'
粤ICP备15054802号-4
'
,
'cdnurl'
=>
''
,
'version'
=>
'1.0.1'
,
'timezone'
=>
'Asia/Shanghai'
,
...
...
@@ -28,4 +28,11 @@ return array (
'user'
=>
'会员配置'
,
'example'
=>
'示例分组'
,
),
'mail_type'
=>
'1'
,
'mail_smtp_host'
=>
'smtp.qq.com'
,
'mail_smtp_port'
=>
'465'
,
'mail_smtp_user'
=>
'10000'
,
'mail_smtp_pass'
=>
'password'
,
'mail_verify_type'
=>
'2'
,
'mail_from'
=>
'10000@qq.com'
,
);
\ No newline at end of file
...
...
application/index/view/layout/bootstrap.html
查看文件 @
937ebe6
...
...
@@ -94,7 +94,7 @@
<div
class=
"pull-left"
>
<p>
<span
class=
"text-muted"
><a
href=
"http://www.miitbeian.gov.cn/"
target=
"_blank"
>
粤ICP备15054802号-4
</a></span>
<span
class=
"text-muted"
><a
href=
"http://www.miitbeian.gov.cn/"
target=
"_blank"
>
{$site.beian}
</a></span>
</p>
<span
class=
"small"
></span>
<p>
...
...
composer.json
查看文件 @
937ebe6
...
...
@@ -20,7 +20,8 @@
"overtrue/wechat"
:
"~3.1"
,
"endroid/qrcode"
:
"^1.9"
,
"topthink/think-captcha"
:
"^1.0"
,
"mtdowling/cron-expression"
:
"^1.2"
"mtdowling/cron-expression"
:
"^1.2"
,
"phpmailer/phpmailer"
:
"^5.2"
},
"config"
:
{
"preferred-install"
:
"dist"
...
...
public/assets/js/backend/general/config.js
查看文件 @
937ebe6
...
...
@@ -76,6 +76,19 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
$
(
document
).
on
(
"change"
,
"form#add-form select[name='row[type]']"
,
function
(
e
)
{
$
(
"#add-content-container"
).
toggleClass
(
"hide"
,
[
'select'
,
'selects'
,
'checkbox'
,
'radio'
].
indexOf
(
$
(
this
).
val
())
>
-
1
?
false
:
true
);
});
//添加向发件人发送测试邮件按钮和方法
testMail
=
'<a class="btn btn-info testmail">向发件人发送测试邮件</a>'
$
(
'input[name="row[mail_from]"]'
).
parent
().
next
().
append
(
testMail
);
$
(
document
).
on
(
"click"
,
".testmail"
,
function
(){
$
.
get
(
"/admin/general.config/emailtest"
,
function
(
result
){
if
(
result
.
data
.
data
)
{
Toastr
.
success
(
result
.
data
.
text
)
}
else
{
Toastr
.
warning
(
result
.
data
.
text
)
}
});
})
},
add
:
function
()
{
Controller
.
api
.
bindevent
();
...
...
public/assets/js/backend/general/configvalue.js
查看文件 @
937ebe6
...
...
@@ -35,7 +35,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
// 为表格绑定事件
Table
.
api
.
bindevent
(
table
);
// 清
楚
缓存
// 清
除
缓存
$
(
document
).
on
(
"click"
,
".btn-clear-cache"
,
function
(
e
)
{
Backend
.
api
.
layer
.
confirm
(
__
(
"Are you sure you want to clear cache?"
),
function
()
{
Backend
.
api
.
ajax
({
...
...
请
注册
或
登录
后发表评论