Example #1
0
 /**
  * 发送邮件
  *
  * @param string $to
  * @param string $to_name
  * @param string $subject
  * @param string $body
  * @param string $mailtype
  * @return boolean
  */
 public static function send($to, $to_name, $subject, $body, $chaosong = array(), $mailtype = 'txt')
 {
     self::init();
     $send_type = mod_config::get_one_config('fl_sendemailtype') == '1' ? 'smtp' : 'mail';
     $mail = new PHPMailer();
     $mail->SMTPDebug = false;
     // 发送方式
     if ($send_type == 'smtp') {
         self::smtp_init();
         $mail->IsSMTP();
         $mail->Host = self::$smtp_server;
         $mail->Port = self::$smtp_port;
         $mail->SmtpSsl = self::$smtp_ssl;
         // SSL 连接
         if (self::$smtp_auth) {
             $mail->SMTPAuth = true;
             $mail->Username = self::$smtp_user;
             $mail->Password = self::$smtp_pwd;
         } else {
             $mail->SMTPAuth = false;
         }
     } elseif ($send_type == 'mail') {
         $mail->IsMail();
     }
     // 发件人邮箱
     $mail->From = self::$from_email;
     // 发件人名称
     if (self::$from_name != '') {
         $mail->FromName = self::$from_name;
     }
     // 收件人邮箱和姓名
     $mail->AddAddress($to, $to_name);
     if ($chaosong) {
         foreach ($chaosong as $v) {
             $mail->AddCC($v['to'], $v['name']);
         }
     }
     // 邮件编码
     $mail->CharSet = self::$charset;
     // 邮件编码方式
     $mail->Encoding = "base64";
     // 邮件格式类型
     if ($mailtype == 'txt') {
         $mail->IsHTML(false);
     } elseif ($mailtype == 'html') {
         $mail->IsHTML(true);
         $mail->AltBody = "text/html";
     }
     $mail->Subject = $subject;
     // 邮件主题
     $mail->Body = $body;
     // 邮件内容D
     return !$mail->Send() ? false : true;
 }
 public function mail()
 {
     $post = $_POST;
     if ($post['submit']) {
         unset($post['submit']);
         mod_config::set_configs($post);
         mod_login::message('更新邮箱发送配置成功');
     } else {
         $configs = mod_config::get_configs(array('fl_sendemail', 'fl_sendemailtype', 'fl_fromemail', 'fl_smtpserver', 'fl_smtpport', 'fl_smtpssl', 'fl_smtpauth', 'fl_smtpid', 'fl_smtppass'));
         $action_link = array('href' => '?c=config&a=index', 'text' => '返回系统配置');
         pm_tpl::assign('action_link', $action_link);
         pm_tpl::assign('ur_here', '配置SMTP发送');
         pm_tpl::assign('config', $configs);
         pm_tpl::display('config_mail');
     }
 }
Example #3
0
}
//加载常量定义库
require_once PATH_ADMIN . '/config/cfg_constants.php';
// 加载函数库
require_once PATH_APPLICATION . '/pm_core_functions.php';
// 自动转义
if (@function_exists(auto_addslashes)) {
    auto_addslashes($_POST);
    auto_addslashes($_GET);
    auto_addslashes($_COOKIE);
    auto_addslashes($_REQUEST);
}
//加载相关文件
require_once PATH_CONFIG . '/cfg_database.php';
require_once PATH_APPLICATION . '/pm_router.php';
require_once includesqlfile();
//加载数据库文件
require_once PATH_MODULE . '/smarty/Smarty.class.php';
require_once PATH_APPLICATION . '/pm_tpl.php';
defined('DEBUG_LEVEL') || define('DEBUG_LEVEL', TRUE);
defined('HOST') || define('HOST', 'http://' . $_SERVER['HTTP_HOST']);
$path_info = pathinfo($_SERVER['PHP_SELF']);
$path_x = rtrim(strtr($path_info['dirname'], array('\\' => '/')), '/');
//URL定义
defined('URL') || define('URL', 'http://' . $_SERVER['HTTP_HOST'] . $path_x);
defined('VERIFY_CODE') || define('VERIFY_CODE', mod_config::get_one_config('fl_verify_code'));
// 分页
defined('PAGE_ROWS') || define('PAGE_ROWS', 20);
defined('PATH_COOKIE') || define('PATH_COOKIE', '/');
$global_config = mod_config::get_configs(array('fl_timedf', 'fl_sysname', 'fl_sysurl'));
pm_tpl::assign('cp_home', $global_config['fl_sysname']);
 /**
  * IP 验证
  */
 public static function ip_verify()
 {
     $ipban = mod_config::get_one_config('yl_ipban');
     if (empty($ipban)) {
         return true;
     }
     $ip = split(',', $ipban);
     if (empty($ip)) {
         return true;
     }
     $current_ip = self::get_ip();
     foreach ($ip as $row) {
         $row = trim($row);
         if (count(split('.', $row)) == 3 && $current_ip == $row) {
             exit('<h1>Forbidden</h1>');
         } elseif (implode('.', array_slice(explode('.', $current_ip), 0, 3)) == implode('.', array_slice(explode('.', $row), 0, 3))) {
             exit('<h1>Forbidden</h1>');
         }
     }
     return true;
 }