public function addMailOne() { //先判断这个session时间是否存在 if (session("addMailOneTime")) { //如果时间已经存在,则查看系统现在的时间和session时间相差是否超过3小时 } //设置一个session时间 session("addMailOneTime", time()); // $userID = I('userID'); //发信人id $userID = session("userID"); //发信人id $toUserID = I('toUserID'); //获取浏览器传过来的收信人id //获取公开信id,如果用户从公开信页面写的私人信件,就在数据库里增加这个id,以确定用户首次写信时从什么地方 $openMailID = Verif::canshu(I('openMailID'), 'openMailID', false, 'int'); $mailNeirong = Verif::canshu(I('mailNeirong'), 'mailNeirong', true, 'mailNeirong'); //邮件内容 //检测是否给自己写信 .如果发信人id 和收信人id一样的话,返回错误 Verif::ziji($userID, $toUserID); //获取key .这个要放在最后执行 $mailKey = Qita::getUserListKey($userID, $toUserID); if ($openMailID) { //检测用户是否已经给这封公开信写过信 $openMailjiance = Db::dbfindOne('UserMailList', ['faxin_user_id' => $userID, 'open_mail_id' => $openMailID]); if ($openMailjiance) { exit(json_encode(['zhuangtai' => 0, 'tishi' => '你已经给这封公开信回过信了'])); } } //将信件写入数据库 Db::dbSave("UserMailList", ['mail_key' => $mailKey, 'faxin_user_id' => $userID, 'shouxin_user_id' => $toUserID, 'mail_neirong' => stripslashes(htmlspecialchars_decode($mailNeirong)), 'open_mail_id' => $openMailID, 'faxin_time_int' => time()]); //增加 user_list 的new_mail_count数 Count::newMailCountAdd(['user_id' => $toUserID, 'mail_key' => $mailKey]); $this->ajaxReturn(['zhuangtai' => 1, 'tishi' => '发信成功']); }
public static function userImg() { $upload = new \Think\Upload(); // 实例化上传类 $upload->maxSize = 3145728; // 设置附件上传大小 $upload->exts = array('jpg', 'gif', 'png', 'jpeg'); // 设置附件上传类型 $upload->rootPath = './Public/'; //设置上传主目录 $upload->savePath = './userImg/'; // 设置附件上传目录 $upload->autoSub = false; // 上传文件 $info = $upload->upload(); if (!$info) { // 上传错误提示错误信息 //dump($upload->getError()); exit(json_encode(["zhuangtai" => 0, "tishi" => "上传错误", 'data' => $upload])); } else { // 上传成功 // dump($info); $userImg = $info['file']['savename']; // echo $userImg; //写入用户头像数据库 Db::dbSave("UserImg", ['user_id' => session('userID'), 'img_name' => $userImg, 'time_int' => time()]); //dump($userImg); echo json_encode(["zhuangtai" => 1, "tishi" => "修改成功", 'data' => $userImg]); // return ["zhuangtai" => 1, "tishi" => "修改成功", 'data' => $userImg]; } }