コード例 #1
0
ファイル: DBAgent.php プロジェクト: Jaggle/JetPHP
 /**
  * 添加
  */
 public function insert()
 {
     $data = jet_Post('data');
     dump($data, 1);
     echo jet_JSON(array('status' => true));
     die;
 }
コード例 #2
0
ファイル: AjaxController.php プロジェクト: Jaggle/JetPHP
 public function mail()
 {
     if (jet_Post('action') == 'do_mailer') {
         error_reporting(0);
         $mail = new \PHPMailer();
         apply_config($mail, 'smtp');
         $mail->isSMTP();
         // Set mailer to use SMTP
         $mail->addAddress(jet_Post('to'), 'HELLO');
         // Add a recipient
         $mail->isHTML(true);
         // Set email format to HTML
         $mail->Subject = '这是一架邮件轰炸机!';
         $content = jet_Post('content');
         if (!$content) {
             $content = '这是一架邮件轰炸机!';
         }
         $mail->Body = $content;
         $mail->AltBody = strip_tags($content);
         if (!$mail->send()) {
             echo jet_JSON(array('message' => '错误: ' . $mail->ErrorInfo, 'has' => false));
         } else {
             echo jet_JSON(array('message' => "你的邮件已经发送给" . jet_Post('to') . ",内容是{$content}" . $mail->Username, 'has' => true));
         }
     } else {
         $this->render();
     }
 }
コード例 #3
0
ファイル: Notification.class.php プロジェクト: Jaggle/JetPHP
 /**
  * 通过id设置消息为已读
  * 这个方法用于ajax请求
  */
 public function setread()
 {
     $id = jet_Post('id');
     if (!empty($id)) {
         $flag = $this->model('notification')->where($id)->setField('is_read', 1);
         if ($flag) {
             echo jet_JSON(array('message' => '设置已读成功!', 'has' => 1));
             return;
         } else {
             echo jet_JSON(array('message' => '设置已读失败!', 'has' => 0));
             return;
         }
     }
 }
コード例 #4
0
ファイル: PostController.php プロジェクト: Jaggle/JetPHP
 /**
  * 实现ajax添加评论的功能,本方法只用于ajax请求
  *
  */
 public function addComment()
 {
     $_SERVER['REQUEST_METHOD'] === 'POST' or die('welcome to jet');
     $data = jet_Post('data');
     $data['status'] = 'pending';
     $data['type'] = 'post';
     //评论对应的类型,post为文章
     $data['author'] = $this->current_user();
     $data['content'] = strip_tags($data['content']);
     $in_id = $this->model('comment')->insert($data);
     //insert操作
     $data['publish_time'] = $this->model('comment')->where($in_id)->field('publish_time');
     $data['status'] = true;
     if ($in_id) {
         foreach ($data as $key => $value) {
             $data[$key] = urlencode($value);
         }
         $data = json_encode($data);
         echo urldecode($data);
     } else {
         echo "server:failed";
     }
     exit;
 }
コード例 #5
0
ファイル: AccountController.php プロジェクト: Jaggle/JetPHP
 /**
  * 注册功能
  */
 public function register()
 {
     if (jet_Post('action') === 'do_register') {
         $mail = jet_Post('mail');
         $user = jet_Post('user');
         $pswd = jet_Post('pswd');
         $p_mail = '/^[\\w]+(\\.[\\w+])*@[\\w-]+(\\.[\\w-]+)+$/i';
         $p_user = "******";
         $p_pswd = "#^[A-Za-z0-9\\-_]{3,20}#";
         if (!preg_match($p_mail, $mail)) {
             echo jet_JSON(array('msg' => '请输入正确的邮箱格式', 'has' => false));
             return;
         } elseif (!preg_match($p_pswd, $pswd)) {
             echo jet_JSON(array('msg' => '请输入正确的密码,长度在3-20之间', 'has' => false));
             return;
         } elseif (preg_match($p_user, $user)) {
             //判断是否有相同账号
             if ($this->model('user')->where("user = '******'")->num()) {
                 echo jet_JSON(array('msg' => '已经存在相同用户,请修改您的名字', 'has' => false));
                 return;
             } else {
             }
             //everything is ok
         } else {
             echo jet_JSON(array('msg' => '用户名格式不正确,请不要输入字符,长度在3-20之间', 'has' => false));
             return;
         }
         $salt = jet_Config('jet_identity');
         $reg['identity'] = md5($salt . $user);
         //识别码加密
         $reg['pswd'] = md5($pswd);
         //密码MD5加密
         $reg['user'] = $user;
         $reg['mail'] = $mail;
         $reg['fans'] = jet_Config('register_fans');
         $reg['type'] = jet_Config('register_type');
         $reg['register_time'] = date('Y-m-d h:i:s', time());
         $reg['status'] = jet_Config('register_status');
         //向数据库插入数据
         $flag = $this->model('user')->insert($reg);
         if ($flag) {
             $flag = $this->sendVerifyMail($reg);
             if ($flag) {
                 echo jet_JSON(array('msg' => '注册成功!', 'has' => true));
             } else {
                 echo jet_JSON(array('msg' => '程序出现错误,希望你能将这个错误反馈给我们!错误代码:ERROR_REG_01', 'has' => false));
             }
         } else {
             echo jet_JSON(array('msg' => '程序出现错误,希望你能将这个错误反馈给我们!错误代码:ERROR_REG_02', 'has' => false));
         }
     } else {
         echo jet_JSON(array('msg' => '程序出现错误,希望你能将这个错误反馈给我们!错误代码:ERROR_REG_03', 'has' => false));
     }
 }
コード例 #6
0
ファイル: AdminController.php プロジェクト: Jaggle/JetPHP
 /**
  * 评论管理
  */
 public function comment()
 {
     //评论列表
     if ($this->a == '' or $this->a == 'index' or $this->a == 'list') {
         $list = $this->model('comment')->select();
         foreach ($list as $key => $value) {
             foreach ($value as $k => $v) {
                 $attach = $list[$key]['attach'];
                 $list[$key]['attach_title'] = $this->model('post')->where($attach)->field('title');
                 if ($k == 'content') {
                     $list[$key]['content'] = strip_tags($v);
                     //去掉html标签v
                 }
             }
         }
         $this->assign('list', $list);
         $this->render('admin/comment/index');
     }
     //删除操作
     if ($this->a == 'd' or $this->a == 'delete') {
         $id = jet_Post('id');
         if (strpos($id, ',')) {
             $flag = $this->model('comment')->delete(trim($id, ','));
             //移除前后的字符,
         } else {
             $flag = $this->model('comment')->where($id)->delete();
         }
         if ($flag) {
             echo jet_JSON(array('msg' => true));
         } else {
             echo jet_JSON(array('msg' => false));
         }
     }
 }
コード例 #7
0
ファイル: IndexController.php プロジェクト: Jaggle/JetPHP
 /**
  * 长轮询测试
  */
 public function polling()
 {
     if (jet_Post('id')) {
         $id = jet_Post('id');
         $list = $this->model('post')->where("id > {$id}")->get();
         if ($list) {
             //$list = array_slice($list,0,2);
             $list['has'] = true;
             foreach ($list as $key => $value) {
                 $list[$key] = str_replace('"', '\'', $value);
                 //替换双引号
                 $list[$key] = str_replace(':', '|=|', $list[$key]);
                 //替换冒号
             }
             echo jet_JSON($list);
             return;
         } else {
             $list['has'] = false;
             echo jet_JSON($list);
             return;
         }
     } else {
         $this->render();
     }
 }