-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.function.php
More file actions
51 lines (51 loc) · 1.69 KB
/
Copy pathbase.function.php
File metadata and controls
51 lines (51 loc) · 1.69 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
<?php
function __autoload($classname)
{
$filename = "service/" . $classname . ".class.php";
include_once($filename);
}
function error($errno = 0, $errmsg = "success")
{
return json_encode(array('errno'=>$errno, 'errmsg'=>$errmsg));
}
function pub_data(){
$f = new SaeFetchurl();
return $f->fetch( $GLOBALS['public_image_file'] );
}
/**
* 外部邮件发送
*
*
*/
function common_mail($mail_subject, $mail_body, $mail_type = "HTML")
{
include_once('service/mail.class.php');
$mail_from_info = $GLOBALS['config']['common_mail'];
$smtp_server = $mail_from_info['server'];
$smtp_server_port = $mail_from_info['port'];
$smtp_user = $mail_from_info['user'];
$smtp_pass = $mail_from_info['pass'];
$smtp_mail_from = $mail_from_info['mail'];
$smtp_mail_to = $GLOBALS['config']['mailto'];
$mail_subject = mb_convert_encoding( $mail_subject, 'gbk', 'utf-8');
$mail_body = mb_convert_encoding( $mail_body, 'gbk', 'utf-8');
$mail_type = empty($mail_type) ? "HTML" : $mail_type;
$smtp = new SMTP($smtp_server, $smtp_server_port, true, $smtp_user, $smtp_pass);
$smtp->debug = true;
return @$smtp->sendmail($smtp_mail_to, $smtp_mail_from, $mail_subject, $mail_body, $mail_type);
}
/**
* 格式化输入异常服务信息
* @param $service string 服务名 见config.php
* @param $method string 服务对应的方法名 见config.php
* @param $error array 包括errno、errmsg
* @return string
*
*/
function format_output($service, $method, $error)
{
$info = "[" . date("Y-m-d H:i:s") . "]";
$info .= " 服务:" . $service . " 方法:" . $method . " 操作失败.errno:" . $error['errno'] . " errmsg:" . $error['errmsg'];
return $info;
}
?>