Beispiel #1
0
 public function webwxsendmsg($ToUserName, $info)
 {
     $user = Login::where('wxuin', $this->wxuin)->where('status', 1)->first();
     if (!$user) {
         $this->death();
     }
     $cookies = json_decode($user->cookies);
     dd($user);
     $ClientMsgId = time();
     $LocalID = $ClientMsgId;
     $url = "https://webpush.weixin.qq.com/cgi-bin/mmwebwx-bin/webwxsendmsg?sid=" . urlencode($cookies->wxsid) . "&skey=" . urlencode($cookies->skey) . "&r=" . t() . "&pass_ticket=" . urlencode($user->pass_ticket);
     $post['BaseRequest']['DeviceID'] = $user->deviceid;
     $post['BaseRequest']['Sid'] = $cookies->wxsid;
     $post['BaseRequest']['Skey'] = $user->skey;
     $post['BaseRequest']['Uin'] = (int) $cookies->wxuin;
     $post['Msg']['FromUserName'] = $user->UserName;
     $post['Msg']['ToUserName'] = $ToUserName;
     $post['Msg']['Type'] = 1;
     $post['Msg']['Content'] = $info;
     $post['Msg']['ClientMsgId'] = $ClientMsgId;
     $post['Msg']['LocalID'] = $LocalID;
     dd($post);
     $html = CURL::send($url, ['Cookie' => urldecode(http_build_query($cookies, '', '; '))], [], ['ret' => 'body', 'post' => json_encode($post)]);
     dd($html);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $user = Login::where('remember_token', '=', $request->header('token'))->where('login_from', '=', $request->ip())->join('members', 'members.id', '=', 'logins.member_id')->where('logins.status', '=', '1')->first();
     if (!($user->mtype == 3 || $user->mtype == 1)) {
         $returnData = array('status' => 'fail', 'mesage' => 'insufficient permision', 'code' => 403);
         return $returnData;
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $login = Login::where('remember_token', '=', $request->header('token'))->where('status', '=', '1')->where('login_from', '=', $request->ip())->count();
     if ($login == 1) {
         return $next($request);
     } else {
         $returnData = array('status' => 'fail', 'message' => 'invalid token', 'code' => 403);
         return Response::json($returnData, 200);
     }
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $login = Login::where('remember_token', '=', $request->header('token'))->where('login_from', '=', $request->ip())->join('members', 'members.id', '=', 'logins.member_id')->where('logins.status', '=', '1')->first();
     if ($login->mtype < 3) {
         return $next($request);
     } else {
         $returnData = array('status' => 'fail', 'message' => 'invalid request', 'code' => 403);
         return Response::json($returnData, 200);
     }
 }
Beispiel #5
0
 public function stop(Request $request)
 {
     $user = Auth::user();
     $login = Login::where('user_id', $user->id)->where('login_time', '>=', Carbon::today('Europe/Budapest'))->orderBy('id', 'desc')->first();
     if ($login && $login->logout_time == null) {
         $login->update(['logout_time' => Carbon::parse($request->custom_logout)]);
         return redirect()->back();
     } else {
         return redirect()->back()->withErrors('Volt stop');
     }
 }
Beispiel #6
0
 public function authenticateLogin(Request $request)
 {
     $loginUsername = $request->input('username');
     $loginPassword = $request->input('password');
     $Login = Login::where('loginUsername', $loginUsername)->first();
     if ($Login != null and $loginPassword == $Login->loginPassword) {
         $content = $Login->id;
         return response($content);
     }
     $content = "NOTFOUND";
     return response($content);
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create(Request $request)
 {
     $login = Login::where('remember_token', '=', $request->header('token'))->where('login_from', '=', $request->ip())->join('members', 'members.id', '=', 'logins.member_id')->where('logins.status', '=', '1')->first();
     $notice = new Notice();
     $notice->for = $request['for'];
     $notice->subject = $request['subject'];
     $notice->body = $request['body'];
     $notice->sendBy = $login->member_id;
     if ($notice->save()) {
         $returnData = array('status' => 'ok', 'notice' => $notice, 'code' => 200);
     } else {
         $returnData = array('code' => 500, 'status' => 'fail', 'message' => 'notice could not created');
     }
     return $returnData;
 }
Beispiel #8
0
 function death($msg = "")
 {
     echo "wxuin:{$this->wxuin} is death";
     if ($msg) {
         \Log::info($msg);
     }
     Login::where('wxuin', $this->wxuin)->update(['status' => 0]);
     abort(500);
 }
 public function getFriends($wxuin)
 {
     //循环执行心跳
     $user = Login::where('wxuin', $wxuin)->where('status', 1)->first();
     if (!$user) {
         \Log::info("wxuin:{$wxuin} 冻结状态,结束此次循环");
         return;
     }
     $cookies = json_decode($user->cookies);
     $url = "https://webpush.weixin.qq.com/cgi-bin/mmwebwx-bin/webwxgetcontact?r=" . t();
     $ret = CURL::send($url, ['Cookie' => urldecode(http_build_query($cookies, '', '; '))], ['follow_redirects' => false], ['ret' => 'all']);
     $html = $ret->body;
     $html = iconv('UTF-8', 'UTF-8//IGNORE', $html);
     $cookies2 = toCookies($ret->cookies);
     $cookies = (object) ((array) $cookies2 + (array) $cookies);
     //更新Cookie
     Login::where('wxuin', $wxuin)->update(['cookies' => json_encode($cookies)]);
     $data_arr = json_decode($html, true);
     foreach ($data_arr['MemberList'] as $k => $v) {
         //获取好友信息
         $data = array('my_uin' => $wxuin, 'Uin' => $v['Uin'], 'Alias' => $v['Alias'], 'UserName' => $v['UserName'], 'NickName' => $v['NickName'], 'RemarkName' => $v['RemarkName'], 'HeadImgUrl' => $v['HeadImgUrl'], 'Sex' => $v['Sex'], 'Signature' => $v['Signature'], 'Province' => $v['Province'], 'City' => $v['City']);
         $ff = Friends::where('UserName', $v['UserName'])->first();
         //如果存在了就更新
         if ($ff) {
             Friends::where('UserName', $v['UserName'])->update($data);
         } else {
             $data_batch[] = $data;
         }
     }
     if (isset($data_batch)) {
         Friends::insert($data_batch);
     }
     return $data_arr;
 }
 public function changePassword(Request $request)
 {
     $user = Login::where('remember_token', '=', $request->header('token'))->where('login_from', '=', $request->ip())->join('members', 'members.id', '=', 'logins.member_id')->where('logins.status', '=', '1')->first();
     if (Auth::attempt(['username' => $user->username, 'password' => $request['old']])) {
         $member = Member::find($user->member_id);
         $member->password = Hash::make($request['new']);
         //return $member->password;
         $member->save();
         $returnData = array('status' => 'ok', 'code' => 200);
         return Response::json($returnData, 200);
     } else {
         $returnData = array('status' => 'fail');
         return Response::json($returnData, 401);
     }
 }
 public function transferToDelivery(Request $request)
 {
     $metaData = MetaData::where('meta_key', 'server_status')->first();
     if ($metaData['meta_value'] == 0) {
         $errorData = array('status' => 'fail', 'message' => 'Sorry! Server is closed. Please try later.', 'code' => '422');
         return Response::json($errorData, 422);
     }
     $login = Login::where('remember_token', '=', $request->header('token'))->where('login_from', '=', $request->ip())->join('members', 'members.id', '=', 'logins.member_id')->where('logins.status', '=', '1')->first();
     $clientStock = ClientStock::find($request['clientStockId']);
     $account = new Account();
     if ($account->getAccount($login->member_id) < $clientStock->remaining_cost + $clientStock->delivery_charge) {
         $errorData = array('status' => 'fail', 'message' => 'Insufficient Balance!', 'code' => '422');
         return Response::json($errorData, 422);
     }
     if ($clientStock->memberId != $login->member_id) {
         $errorData = array('status' => 'fail', 'message' => 'Invalid Request!', 'code' => '422');
         return Response::json($errorData, 422);
     } else {
         $clientStock->status = 4;
         $clientStock->save();
         $account = new Account();
         $account->ticket = $clientStock->ticket;
         $account->amount = $clientStock->remaining_cost + $clientStock->delivery_charge;
         $account->type = 0;
         $account->addedBy = $login->member_id;
         $account->memberId = $clientStock->memberId;
         $account->save();
         $returnData = array('status' => 'ok', 'code' => '200', 'clientStock' => $clientStock, 'account' => $account);
         return Response::json($returnData, 200);
     }
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create(Request $request)
 {
     $login = Login::where('remember_token', '=', $request->header('token'))->where('status', '=', '1')->where('login_from', '=', $request->ip())->count();
     //$login = "******";
     return $login;
 }