/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $timestamp = $request->input('timestamp'); $key = $request->input('key'); if (!Api::checkKey($timestamp, $key)) { return response('Unauthorized.', 401); } return $next($request); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $input = $request->all(); $api = Api::find($id); $api->name = $input['name']; $api->raml = $input['raml']; $api->save(); return redirect('/'); }
public function linkAccountGet() { #finishes authentication with access code and user id list($accessToken, $userId) = $this->getWebAuth()->finish($_GET); #generates a client object which we can grab information with by calling getAccountInfo() $client = new dbx\Client($accessToken, "PHP"); $accountInfo = $client->getAccountInfo(); #input access information to mysql table. $table = Api::updateOrCreate(['user_id' => Auth::id(), 'service' => 1, 'service_email' => $accountInfo['email'], 'service_id' => $userId], ['service_accessToken' => $accessToken]); $table->save(); $updatetable = new apiController(); $updatetable->updateAccounts(); return redirect('/'); }
public function linkAccountGet() { $client = $this->authInfo['client']; $service = $this->authInfo['service']; $client->authenticate($_GET['code']); $token = $client->getAccessToken(); $refresh = $client->getRefreshToken(); $permissionId = $service->about->get()->getUser()->getpermissionId(); $email = $service->about->get()->getUser()->getemailAddress(); $table = Api::updateOrCreate(['user_id' => Auth::id(), 'service' => 2, 'service_email' => $email, 'service_id' => $permissionId], ['service_accessToken' => $token]); $table->save(); $updatetable = new apiController(); $updatetable->updateAccounts(); return redirect('/'); }
function comment() { \Swoole::$php->session->start(); if (!$_SESSION['isLogin']) { return 'nologin'; } $uid = $_SESSION['user_id']; $post['aid'] = (int) $_POST['aid']; $post['app'] = $_POST['app']; $post['content'] = $_POST['content']; $post['uid'] = $uid; $post['uname'] = $_SESSION['user']['nickname']; if ($post['app'] === 'mblog') { $m = createModel('MicroBlog'); $entity = $m->get($post['aid']); $entity->reply_count++; $entity->save(); if ($entity->uid != $uid) { App\Api::sendmail($entity->uid, $uid, "【系统】{$post['uname']}评论了你的微博", $post['content']); } } elseif ($post['app'] === 'blog') { $m = createModel('UserLogs'); $entity = $m->get($post['aid']); $entity->reply_count++; $entity->save(); if ($entity->uid != $uid) { App\Api::sendmail($entity->uid, $uid, "【系统】{$post['uname']}评论了你的日志.({$entity['title']})", $post['content']); } } createModel('UserComment')->put($post); $return = array('id' => $_SESSION['user']['id'], 'addtime' => Swoole\Tool::howLongAgo(date('Y-m-d H:i:s')), 'nickname' => $_SESSION['user']['nickname']); if (empty($_SESSION['user']['avatar'])) { $return['avatar'] = Swoole::$php->config['user']['default_avatar']; } else { $return['avatar'] = $_SESSION['user']['avatar']; } return $return; }
/** * Run the database seeds. * * @return void */ public function run() { \App\Api::create(['version' => '1.0', 'name' => 'Verification API', 'api_name' => 'verification', 'navigation_icon' => 'fa-calendar-check-o']); }
<?php use App\Api; $segment = Request::segment(1); $second = Request::segment(2); $apis = Api::all(); ?> <nav class="navbar-default navbar-static-side" role="navigation"> <div class="sidebar-collapse"> <ul class="nav metismenu" id="side-menu"> <li class="nav-header"> <div class="dropdown profile-element"> <span> <img alt="image" class="img-circle" src="{{ asset('img/default_profile_48.jpg') }}"/> </span> <a data-toggle="dropdown" class="dropdown-toggle" href=""> <span class="clear"> <span class="block m-t-xs"> <strong class="font-bold">{{ Auth::user()->fullName() }}</strong> </span> <span class="text-muted text-xs block"> {{ Auth::user()->getRoleName() }}</span> </span> </a> </div> <div class="logo-element"> IN+ </div> </li> {{-- dashboard --}} @if($segment == 'dashboard') <li class="active"> @else <li>
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $api = Api::latest()->get(); return view('welcome', compact("api")); }
function reply() { $this->session->start(); if (!$_SESSION['isLogin']) { return Swoole\JS::echojs("if(confirm('您还没有登录,是否调整到登录页面(请首先复制您的回答内容)?')) window.parent.location.href='/page/login/?'"); } if (!empty($_POST['reply'])) { $answer['content'] = $_POST['reply']; $answer['uid'] = $this->swoole->user->getUid(); $user = createModel('UserInfo')->get($answer['uid']); $answer['aid'] = (int) $_POST['aid']; $ask = createModel('AskSubject')->get($answer['aid']); //答案数量加1 $ask->qcount += 1; //如果是未答状态,则设置为已答 if ($ask->mstatus == 0) { $ask->mstatus = 1; } $ask->save(); //为用户增加积分,回答即加5分 $user->gold += 5; $user->save(); App\Api::sendmail($ask['uid'], $answer['uid'], "【系统】" . $user['nickname'] . "回答了你的提问.({$ask['title']})", $answer['content']); createModel('AskReply')->put($answer); return Swoole\JS::alert('发布成功') . Swoole\JS::echojs('window.parent.location.href = window.parent.location.href;'); } }
public function setApi($name) { $this->name = $name; $this->api = Api::where('api_name', $name)->first(); }