Esempio n. 1
0
 public function insert_msg($info)
 {
     $field = '';
     $value = '';
     foreach ($info as $k => $v) {
         if ($v != '') {
             $field .= "{$k},";
             $value .= "'{$v}',";
         }
     }
     $field .= "created,ip";
     $value .= "'" . $_SERVER['REQUEST_TIME'] . "','" . hy_getIP() . "'";
     $sql = "INSERT INTO " . $this->table('feed') . " (" . $field . ") VALUES(" . $value . ")";
     return $res = $this->query($sql);
 }
Esempio n. 2
0
 public function submit()
 {
     $result = array('error' => 1, 'content' => '');
     $info['name'] = isset($_POST['name']) ? hy_check($_POST['name'], 'ur') : '';
     $info['email'] = isset($_POST['email']) ? hy_check($_POST['email'], 'e') : '';
     $info['phone'] = isset($_POST['phone']) ? hy_check($_POST['phone'], 'n') : '';
     $info['content'] = isset($_POST['content']) ? hy_substr($_POST['content'], '255') : '';
     $info['ip'] = hy_getIP();
     $info['created'] = $_SERVER['REQUEST_TIME'];
     if ($info['name'] == '#@_error') {
         $result['content'] = '名字格式错误';
         print_r(json_encode($result));
         exit;
     }
     if ($info['email'] == '#@_error') {
         $result['content'] = '邮件格式错误';
         print_r(json_encode($result));
         exit;
     }
     if ($info['phone'] == '#@_error') {
         $result['content'] = '电话格式错误';
         print_r(json_encode($result));
         exit;
     }
     $check = Model('forms')->check_ip(array('ip' => $info['ip'], 'table' => 'forms_log_1'));
     if (!$check) {
         $result['content'] = '你提交得太频繁了';
         print_r(json_encode($result));
         exit;
     }
     $res = Model('forms')->insert($info, 'forms_log_1');
     if ($res) {
         $result['error'] = 0;
         $result['content'] = '添加成功';
     } else {
         $result['content'] = '系统繁忙';
     }
     print_r(json_encode($result));
     exit;
 }
Esempio n. 3
0
 public function submit()
 {
     $result = array('error' => 1, 'content' => '');
     $info['name'] = isset($_POST['name']) ? hy_check($_POST['name'], 'ur') : '';
     $info['email'] = isset($_POST['email']) ? hy_check($_POST['email'], 'e') : '';
     $info['phone'] = isset($_POST['phone']) ? hy_check($_POST['phone'], 'n') : '';
     $info['content'] = isset($_POST['content']) ? hy_substr($_POST['content'], '255') : '';
     $info['ip'] = hy_getIP();
     $info['created'] = $_SERVER['REQUEST_TIME'];
     $this->assign_global();
     if ($_POST['name'] == '' || $_POST['email'] == '' || $_POST['phone'] == '' || $_POST['content'] == '') {
         $result['content'] = '请填写完整';
         print_r(json_encode($result));
         exit;
     }
     if ($info['name'] == '#@_error') {
         $result['content'] = '名字格式错误';
         print_r(json_encode($result));
         exit;
     }
     if ($info['email'] == '#@_error') {
         $result['content'] = '邮件格式错误';
         print_r(json_encode($result));
         exit;
     }
     if ($info['phone'] == '#@_error') {
         $result['content'] = '电话格式错误';
         print_r(json_encode($result));
         exit;
     }
     $check = Model('forms')->check_ip(array('ip' => $info['ip'], 'table' => 'forms_log_1'));
     if (!$check) {
         $result['content'] = '你提交得太频繁了';
         print_r(json_encode($result));
         exit;
     }
     $res = Model('forms')->insert($info, 'forms_log_1');
     $mail = new PHPMailer();
     $mail->IsSMTP();
     // Set mailer to use SMTP
     $mail->Host = C('smtp');
     // Specify main and backup server
     $mail->SMTPAuth = true;
     // Enable SMTP authentication
     $mail->Username = C('smtp_username');
     // SMTP username
     $mail->Password = C('smtp_password');
     // SMTP password
     $mail->From = C('smtp_email');
     //$mail->FromName = 'Vancca';
     $mail->AddAddress('*****@*****.**', 'Josh Adams');
     // Add a recipient
     $mail->WordWrap = 50;
     // Set word wrap to 50 characters
     $mail->Subject = '留言';
     $mail->Body = '<p>名称:' . $info['name'] . '</p><p>邮箱:' . $info['email'] . '</p><p>电话:' . $info['phone'] . '</p><p>留言:' . $info['content'] . '</p>';
     $mail->AltBody = '<p>名称:' . $info['name'] . '</p><p>邮箱:' . $info['email'] . '</p><p>电话:' . $info['phone'] . '</p><p>留言:' . $info['content'] . '</p>';
     $mail->Send();
     if ($res) {
         $result['error'] = 0;
         $result['content'] = '添加成功';
     } else {
         $result['content'] = '系统繁忙';
     }
     print_r(json_encode($result));
     exit;
 }
Esempio n. 4
0
 /**
  * 登录操作
  */
 public function act_login()
 {
     $username = isset($_POST['username']) ? hy_check($_POST['username'], 'un', 15) : '';
     $password = isset($_POST['password']) ? hy_check($_POST['password'], '', 20) : '';
     $captcha = isset($_POST['captcha']) ? $_POST['captcha'] : '';
     $check_vali = $this->validator($captcha);
     if (!$check_vali || $captcha == '') {
         $this->showMsg('验证码错误', 'index.php?g=admin&m=index&a=login');
     }
     if ($username == '#@_error' || $password == '#@_error') {
         Error::log('[后台登录错误]' . $_POST['username'] . '--' . hy_getIP(), ADMIN_LOG);
         $this->showMsg(Lang('账号或者密码错误'), '/qq_admin.php');
     }
     if (Model('index')->check_user($username, $password)) {
         header("Location:index.php?g=admin&m=index&a=index");
     } else {
         Error::log('[后台登录错误]' . $_POST['username'] . '--' . hy_getIP(), ADMIN_LOG);
         $this->showMsg(Lang('账号或者密码错误'), 'index.php?g=admin&m=index&a=login');
     }
 }