Exemple #1
0
/**
 * 模型id.php 内容模型或表单模型回调处理函数(需要一定的开发基础)
 *
 * 这是一个示例文件
 *
 * 函数格式:function callback_模型表名称($data) {}
 * $data 就是表单的提交内容了
 */
function callback_demo($data)
{
    // 由开发者二次开发
    // 用于发送邮件
    mail::set(App::$config);
    mail::sendmail('收件人地址', '发信标题', '发信内容');
}
 /**
  * 验证Email
  */
 public function ajaxmailAction()
 {
     if ($this->get('submit')) {
         $toemail = $this->get('mail_to');
         if (empty($toemail)) {
             exit(lang('a-ind-33'));
         }
         $config = array('SITE_MAIL_TYPE' => (int) $this->post('mail_type'), 'SITE_MAIL_SERVER' => $this->post('mail_server'), 'SITE_MAIL_PORT' => (int) $this->post('mail_port'), 'SITE_MAIL_FROM' => $this->post('mail_from'), 'SITE_MAIL_AUTH' => $this->post('mail_auth'), 'SITE_MAIL_USER' => $this->post('mail_user'), 'SITE_MAIL_PASSWORD' => $this->post('mail_password'));
         mail::set($config);
         if (mail::sendmail($toemail, lang('a-ind-34'), lang('a-ind-35'))) {
             echo lang('a-ind-36');
         } else {
             echo lang('a-ind-37');
         }
     } else {
         exit(lang('a-ind-38'));
     }
 }
Exemple #3
0
 /**
  * 保存非法字符攻击日志
  */
 private static function save_attack_log($type, $val)
 {
     $cfg = App::get_config();
     if ($cfg['SYS_ATTACK_LOG']) {
         if (SYS_DOMAIN) {
             $_SERVER['REQUEST_URI'] = str_replace('/' . SYS_DOMAIN, '', $_SERVER['REQUEST_URI']);
         }
         $data = array('url' => isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] ? $_SERVER['QUERY_STRING'] : $_SERVER['REQUEST_URI'], 'ip' => client::get_user_ip(), 'uid' => get_cookie('member_id'), 'time' => time(), 'type' => $type, 'val' => $val, 'user' => $_SERVER['HTTP_USER_AGENT']);
         $dir = APP_ROOT . 'cache' . DIRECTORY_SEPARATOR . 'attack' . DIRECTORY_SEPARATOR;
         $file = $dir . date('Ymd') . '.log';
         if (!is_dir($dir)) {
             mkdir($dir, 0777);
         }
         $body = file_exists($file) ? file_get_contents($file) : null;
         if ($body) {
             $fdata = explode(PHP_EOL, $body);
             $idata = 0;
             foreach ($fdata as $v) {
                 if (empty($v)) {
                     continue;
                 }
                 $t = unserialize($v);
                 if ($data['ip'] == $t['ip']) {
                     $idata++;
                 }
                 //若Ip出现10次以上,直接禁止不再保存提醒
                 //相同地址在20秒内都含有非法字符,直接禁止不再保存提醒
                 if ($idata >= 10 || $data['time'] - $t['time'] < 20 && $data['user'] == $t['user'] && $data['ip'] == $t['ip'] && $data['url'] == $t['url']) {
                     if ($cfg['SYS_ILLEGAL_CHAR']) {
                         App::display_error(lang('app-10') . '<pre>' . htmlspecialchars(self::strip_slashes($val)) . '</pre>', 1);
                     }
                     unset($cfg);
                     return false;
                 }
             }
             unset($fadta);
         }
         $body = serialize($data) . PHP_EOL . $body;
         file_put_contents($file, $body, LOCK_EX);
         if ($data['ip'] && $cfg['SYS_ATTACK_MAIL'] && check::is_email($cfg['SITE_SYSMAIL'])) {
             //发送邮件至管理员
             mail::set($cfg);
             $body = '------------------------------------------------------------------------------------------<br>' . 'SITE: ' . SITE_URL . '<br>URL: ' . $data['url'] . '<br>TYPE: ' . $data['type'] . '<br>VALUE: ' . $data['val'] . '<br>IP: ' . $data['ip'] . '<br>TIME: ' . date(TIME_FORMAT, $data['time']) . '<br>USER: '******'user'] . '<br>------------------------------------------------------------------------------------------<br>' . lang('a-cfg-6') . '<br>';
             mail::sendmail($cfg['SITE_SYSMAIL'], lang('a-cfg-5') . '-' . $cfg['SITE_NAME'], $body);
         }
     }
     if ($cfg['SYS_ILLEGAL_CHAR']) {
         App::display_error(lang('app-10') . '<pre>' . htmlspecialchars(self::strip_slashes($val)) . '</pre>', 1);
     }
     unset($cfg);
 }
Exemple #4
0
 /**
  * 密码找回邮件通知
  */
 protected function passEmail($username, $email)
 {
     if (empty($username) || empty($email)) {
         return false;
     }
     $rand = md5(rand(0, 9999) . microtime());
     $link = $this->get_server_name() . url('member/repass/find', array('id' => base64_encode(time() . '|' . $rand . '|' . md5($username))), 1);
     $this->member->update(array('randcode' => $rand), "username='******'");
     mail::set($this->site);
     $content = $this->memberconfig['pass_tpl'] ? $this->memberconfig['pass_tpl'] : lang('m-com-6', array('1' => $username, '2' => $link));
     $content = str_replace(array('{username}', '{link}'), array($username, $link), $content);
     return mail::sendmail($email, lang('m-com-7', array('1' => $this->site['SITE_NAME'])), htmlspecialchars_decode($content));
 }