public function check($bid) { $bid = Bids::findOrFail(Input::get("bid")); $offset = Input::get("offset"); if ($offset < 0) { $now = \Carbon\Carbon::now()->subHours($offset); } else { $now = \Carbon\Carbon::now()->addHours($offset); } if (strtotime($bid->expiration) - strtotime($now) < 0) { //bid is expired if ($bid->amount < $bid->reservedPrice) { //void since bidding price is less then reserved price $bid->delete(); return "Bidding price less then reserved price"; } else { //proceed and Charge //since we get information about expiration from client we have to check it on the server as well //check wether winning user has its card working if ($bid->customerId) { \Stripe\Stripe::setApiKey("sk_test_Z98H9hmuZWjFWfbkPFvrJMgk"); \Stripe\Charge::create(array("amount" => $bid->priceToCents(), "currency" => "usd", "customer" => $bid->customerId)); \Log::info('Charged: ' . $bid->amount); } $bid->complete = 1; $bid->save(); $bid->delete(); } } else { //someone is messing with javascript return "error"; } return "Bidding is valid"; }
public function index(Request $request) { $c = $request->cookie('kvowner'); if ($c) { $tmp = explode(':', $c); if (count($tmp) != 3) { return redirect('/')->withCookie(\Cookie::forget('kvowner')); } $ls = intval($tmp[0]); $space = floatval($tmp[1]); $file_id = intval($tmp[2]); $apartment = \App\Apartment::where('ls', $ls)->where('space', $space)->first(); if (!$apartment) { \Log::info('1'); return redirect('/')->withCookie(\Cookie::forget('kvowner')); } \Log::info('2'); $file = \App\MeterFile::where('active', 1)->first(); if (!$file) { \Log::info('3'); return redirect('/')->withCookie(\Cookie::forget('kvowner')); } else { \Log::info('4'); if ($file->id != $file_id) { \Log::info('5'); return redirect('/')->withCookie(\Cookie::forget('kvowner')); } } return view('main', ['saved' => true, 'apartment' => $apartment]); } $streets = \App\Street::orderBy('name')->orderBy('prefix')->get(); return view('main', ['saved' => false, 'streets' => $streets]); }
public function update(Request $request, $id) { $arrear = Arrear::findOrFail($id); // money, confirm $arrear->update($request->all()); $payment = $arrear->payment; switch ($request->confirm) { case 1: $message = $arrear->user->name . ' 對款項進行調整'; $userId = $payment->user_id; break; case 2: $message = $payment->user->name . ' 對款項進行調整'; $userId = $arrear->user_id; break; case 3: $message = $arrear->user->name . ' 已確認您提出的款項'; $userId = $payment->user_id; break; default: break; } \Log::info($request->confirm); \Log::info($payment->user_id); event(new ApnsEvent($userId, $payment->id, $message)); $this->checkCompleted($payment); return $payment; }
public function store(Request $request) { \Log::info($request->input('author')); $comment = new Comment(); $comment->content = $request->input('content'); $comment->author = $request->input('author'); $comment->save(); return $comment->toArray(); }
public function postQuickUpdate() { $inputs = Input::all(); $widget = Widget::find($inputs['pk']); $widget->{$inputs}['name'] = $inputs['value']; Log::info("widgets save" . $widget->id . " " . $widget->name); $widget->save(); return "test"; }
/** * Application deploy. * * @param Request $request * @return \Illuminate\Http\JsonResponse */ public function deploy(Request $request) { list($algo, $hash) = explode('=', $request->header('X-Hub-Signature'), 2); if (!hash_equals($hash, hash_hmac($algo, $request->getContent(), config('services.github-webhook.secret')))) { \Log::notice('Github Webhook', ['auth' => 'failed', 'ip' => $request->ip()]); } else { \Log::info('Github Webhook', ['auth' => 'success', 'ip' => $request->ip()]); \Artisan::queue('deploy'); } return response()->json('', 200); }
/** * Display a list of all of the user's task. * * @param Request $request * @return Response */ public function index(Request $request) { \Log::info('.......shoud not be here.......in task controller index method.............'); // $tasks = DB::select('SELECT * FROM tasks where user_id = 6;'); // \Log::info($tasks); // return view ('tasks.index',['tasks' => $tasks]); // return view('tasks.index', [ // 'tasks' => $this->tasks->forUser($request->user()), // ]); return redirect('/user/userhomepage'); }
/** * Store a newly created resource in storage. * * @param Requests\VoteRequest|Request $request * @param $id * @return Response */ public function store(Requests\VoteRequest $request) { // AJAX JSON RESPONSE $response = array('status' => 'success', 'msg' => 'Article has been posted. Redirecting now.'); if (Auth::check()) { \Log::info(Auth::user()); Auth::user()->votes()->create($request->all()); } else { return \Response::json('Nope'); } return \Response::json($response); }
public function import() { DB::beginTransaction(); \Log::info('import()'); foreach (Publicacao::all() as $publicacao) { // $publicacao = $this->createContent(Publicacao::where('publicacaoId', 2679)->first()); // dd($publicacao); $this->createContent($publicacao); } DB::commit(); return 'SUCESSO!'; }
public function deleteComment($id, $token) { $comment = Comment::find($id); if (!$comment) { return CommentHelpers::formatData(array(), false, sprintf('Comment %d not found', $id), 400); } if (trim(urldecode($token)) == trim($comment->getAttribute('token'))) { $comment->delete(); \Log::info(sprintf('Deleted comment #%d', $id)); return CommentHelpers::formatData(array(), true, sprintf('Comment %d was deleted', $id)); } \Log::error(sprintf('Unauthorized request to delete comment #%d', $id)); return CommentHelpers::formatData(array(), false, null, 403); }
public function updateRandom() { $data = Redis::smembers('latest_group'); $strData = implode(", ", $data); \Log::info("Current set from Redis: {$strData}"); $response = new StreamedResponse(function () use($strData) { $x = mt_rand(1, 100); echo "data: {$strData}\n\n"; ob_flush(); flush(); sleep(2); }); $response->headers->set('Content-Type', 'text/event-stream'); return $response; }
/** * 打印原生态sql * @access protected * @param boolean $needLog 是否要记录日志 * @return array */ protected function printRawSql($needLog = false) { $queries = \DB::getQueryLog(); $formattedQueries = []; foreach ($queries as $query) { $prep = $query['query']; foreach ($query['bindings'] as $binding) { $prep = preg_replace("#\\?#", $binding, $prep, 1); } $formattedQueries[] = $prep; } if ($needLog) { \Log::info($formattedQueries); } return $formattedQueries; }
public function notificar(Request $request) { $mensagem = $request->input('mensagem'); $titulo = $request->input('titulo'); if (is_string($mensagem) && is_string($titulo)) { $gcm = \App::make('App\\GcmModel'); $res = $gcm->all(); $ids = []; foreach ($res as $key) { $ids[] = $key->registration_id; } $result = json_encode((new \App\Gcm())->enviar($ids, $titulo, $mensagem)); dd($result); \Log::info($result); } return redirect()->back(); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { if (!is_array($request->all())) { return ['error' => 'request must be an array']; } $rules = ['name' => 'required', 'email' => 'required|email', 'password' => 'required']; try { $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return ['created' => false, 'errors' => $validator->errors()->all()]; } User::create($request->all()); return ['created' => true]; } catch (Exception $e) { \Log::info('Error creating user: '******'created' => false], 500); } }
public static function grids($batters, $page) { if ($page == 'team') { $idColumns = [(new FieldConfig())->setName('nameLast')->setLabel('Last')]; } switch ($page) { case "team": \Log::info('page'); // $gridColumns = $idColumns; // $narrowGridColumns = $idColumns; break; } $narrowCfg = (new GridConfig())->setDataProvider(new EloquentDataProvider($batters))->setColumns($idColumns)->setPageSize(500); $narrowGrid = new Grid($narrowCfg); $gridCfg = (new GridConfig())->setDataProvider(new EloquentDataProvider($batters))->setColumns($idColumns)->setPageSize(500); $grid = new Grid($gridCfg); return array('narrowGrid' => $narrowGrid, 'grid' => $grid); }
public function deleteGroup(Request $request) { $data = $request->all(); DB::beginTransaction(); try { //\DB::enableQueryLog (); FoVar::whereIn('FORMULA_ID', function ($query) use($data) { $query->select('ID')->from('FORMULA')->where(['GROUP_ID' => $data['id']]); })->delete(); //\Log::info ( \DB::getQueryLog () ); Formula::where(['ID' => $data['id']])->delete(); FoGroup::where(['ID' => $data['id']])->delete(); $fo_group = $this->getFoGroup(); } catch (\Exception $e) { \Log::info($e->getMessage()); DB::rollback(); } DB::commit(); return response()->json($fo_group); }
public function postWebhook(Request $request) { $secret = 'caca'; $headers = getallheaders(); $hubSignature = $headers['X-Hub-Signature']; // Split signature into algorithm and hash list($algo, $hash) = explode('=', $hubSignature, 2); // Get payload $payload = file_get_contents('php://input'); // Calculate hash based on payload and the secret $payloadHash = hash_hmac($algo, $payload, $secret); // Check if hashes are equivalent if ($hash !== $payloadHash) { // Kill the script or do something else here. die('Bad secret'); } \Log::info('hash: ' . $hash); $all = $request->all(); $keys = array_keys($all); $basePath = base_path(); $command = 'git -C ' . $basePath . ' pull origin master'; \Log::info("======"); /* $commands = array( 'echo $PWD', 'whoami', $cmx . ' pull origin master', $cmx . ' status', $cmx . ' submodule sync', $cmx . ' submodule update', $cmx . ' submodule status', );*/ /* foreach ($keys as $key) { \Log::info($key . ': '. $all[$key]); } */ $output = shell_exec($command); \Log::info($output); return 'correcto'; }
/** * Create a new task. * * @param Request $request * @return Response */ public function store(Request $request) { // Debugbar::info("alamin is storing task"); // Debugbar::addMessage('Another message', 'mylabel'); \Log::info('**********...in task controller store method : trying to insert info to tasks.'); /* $this->validate($request, [ 'name' => 'required|max:255', ]); $request->user()->tasks()->create([ 'name' => $request->name, ]); */ // $a = new Todo(); // $a->insertToTask($request->name); Todo::insertToTask($request->name); // DB::insert('insert into tasks (user_id, name, created_at, updated_at) '. // 'values (?, ? , ?, ?)', [6, $request->name,'now()', 'now()']); // DB::INSERT INTO `tasks` (`user_id`, `name`, `created_at`, `updated_at`) VALUES ('6', 'php4', now(), now()); return redirect('/tasks'); }
public function index(Request $request) { $jsonObject = json_decode(json_encode($request->all())); \Log::info(json_encode($jsonObject)); $jsonObject = json_decode($jsonObject->jsonObject_, true); if ($jsonObject['method'] == 'save-user') { $gcm = \App::make('App\\GcmModel'); $gcm->registration_id = $jsonObject['user']['registrationId']; try { $result = $gcm->save(); $id = (string) $gcm->id; dd((new \App\Gcm())->enviar([$gcm->registration_id], 'Bem-vindo', 'Seja bem vindo ao appFatec !')); } catch (\Exception $e) { $result = false; $id = (string) ''; } \Log::info(json_encode($result)); return response()->json(['id' => $id, 'result' => "{'id':{$id}, 'registrationId': {$gcm->registration_id}}"]); } return response()->json(false); }
public function generateTestAndKey() { // if($missing = $this->getMissingParams(['title', 'copyright'])) { // return response()->json(['error' => 'Missing params', 'missing' => $missing], 422); // } $uniqId = uniqid(); // putenv("LANG='en_US.UTF-8'"); // putenv("LC_ALL='en_US.UTF-8'"); $shell = new Exec(); $cmd = new CommandBuilder(env('RUDI_PATH', './rudi/rudi')); $cmd->addArgument('output', './' . $uniqId); if (Input::has('title')) { $cmd->addArgument('title', Input::get('title')); } if (Input::has('copyright')) { $cmd->addArgument('copyright', Input::get('copyright')); } foreach ($this->nameToArgument as $name => $arg) { if (Input::has($name)) { if (Input::has($name . "-count")) { $cmd->addArgument($arg, Input::get($name . "-count")); } else { $cmd->addArgument($arg); } } } \Log::info($cmd); $shell->run($cmd); if ($shell->getReturnValue() !== 0) { return response()->json($shell->getOutput(), 500); } $output = ''; $testString = 'lilypond ' . $uniqId . '.ly ' . $uniqId . '.pdf'; $keyString = 'lilypond ' . $uniqId . '-key.ly ' . $uniqId . '-key.pdf'; exec($testString, $output); exec($keyString, $output); unlink($uniqId . '.ly'); unlink($uniqId . '-key.ly'); return ['id' => $uniqId]; }
/** * Removes a meal * @param int $id the id of the meal to remove * @return Redirect */ public function verwijder($id) { // Find the meal $meal = Meal::find($id); if (!$meal) { \App::abort(404, "Maaltijd niet gevonden"); } // Store the name of the meal for usage in the flash message $date = (string) $meal; // Send an e-mail to the registrations for confirmation \App\Http\Helpers\Mailer::mealIsDestroyedEmail($meal); // Remove all guests foreach ($meal->registrations()->get() as $registration) { if ($registration->email !== null) { $registration->delete(); } } // Remove the meal $meal->delete(); // Update user Flash::set(Flash::SUCCESS, "Maaltijd op {$date} verwijderd. Alle aanmeldingen zijn gemaild met een bevestiging."); \Log::info("Maaltijd verwijderd: {$date}"); return \Redirect::to('/administratie'); }
/** * @return check for IP */ public function check_ip() { $tc = (new ScraperController())->torNew(); $ip = \Request::ip(); $condition = array("open", "blocked"); $key = array_rand($condition, 1); $status = $condition[$key]; \Log::info($ip . ":" . $status); if ($status == 'blocked') { \Log::info("Gaining new tor identity"); if (isset($tc->connected)) { $tc->quit(); } check_ip(); } else { return $ip; } }
public function runWorkFlow(Request $request) { $data = $request->all(); TmWorkflow::where(['ID' => $data['ID']])->update(['ISRUN' => 'yes']); \DB::enableQueryLog(); $tmWorkflowTask = TmWorkflowTask::where(['WF_ID' => $data['ID'], 'ISBEGIN' => 1])->first(); \Log::info(\DB::getQueryLog()); if (count($tmWorkflowTask) > 0) { TmWorkflowTask::where(['WF_ID' => $data['ID']])->where('ID', '<>', $tmWorkflowTask['id'])->update(['ISRUN' => 0]); $objRun = new WorkflowProcessController(null, $tmWorkflowTask); $objRun->runTask(null, $tmWorkflowTask); /* $job = (new runAllocation(null, $tmWorkflowTask)); $this->dispatch($job); */ } $result = $this->getTmWorkflow(); return response()->json(['result' => $result]); }
public function postNewAddress() { \Log::info(json_encode(["tag" => "NEW_ADDRESS", "user_id" => Auth::user()->user_id, "address" => Request::input("address")])); $addressInput = Request::all()['address']; $validator = Validator::make($addressInput, ['first_name' => ['required'], 'last_name' => ['required'], 'street' => ['required'], 'city' => ['required'], 'state' => ['required'], 'zip' => ['required', 'required'], 'country_code' => ['required'], 'phone' => ['required']]); $addressInput['user_id'] = Auth::user()->user_id; if ($validator->fails()) { return error_popup("Address is not complete."); } $address = Store\Address::create($addressInput); $address->user()->associate(Auth::user()); $address->save(); $order = $this->userCart(); $order->address()->associate($address); $order->save(); return js_view("layout.ujs-reload"); }
/** * @return \Illuminate\Http\RedirectResponse */ public function cancelAccount() { if ($reason = trim(Input::get('reason'))) { $email = Auth::user()->email; $name = Auth::user()->getDisplayName(); $data = ['text' => $reason]; $subject = 'Invoice Ninja - Canceled Account'; $this->userMailer->sendTo(CONTACT_EMAIL, $email, $name, $subject, 'contact', $data); } $user = Auth::user(); $account = Auth::user()->account; \Log::info("Canceled Account: {$account->name} - {$user->email}"); Document::scope()->each(function ($item, $key) { $item->delete(); }); $this->accountRepo->unlinkAccount($account); if ($account->company->accounts->count() == 1) { $account->company->forceDelete(); } else { $account->forceDelete(); } Auth::logout(); Session::flush(); return Redirect::to('/')->with('clearGuestKey', true); }
public function cancelAccount() { if ($reason = trim(Input::get('reason'))) { $email = Auth::user()->email; $name = Auth::user()->getDisplayName(); $data = ['text' => $reason]; $this->userMailer->sendTo(CONTACT_EMAIL, $email, $name, 'Invoice Ninja Feedback [Canceled Account]', 'contact', $data); } $user = Auth::user(); $account = Auth::user()->account; \Log::info("Canceled Account: {$account->name} - {$user->email}"); $this->accountRepo->unlinkAccount($account); $account->forceDelete(); Auth::logout(); Session::flush(); return Redirect::to('/')->with('clearGuestKey', true); }
public function postLabel($id, Request $req) { $userid = $this->auth->user()->id; $this->auth->user()->points += 10; // TODO: decide the point $this->auth->user()->save(); $label = $req->get('label'); $itemId = $req->get('item'); $batchId = $req->get('batch'); \Log::info($label . " " . $itemId . " " . $batchId); // $batchId = $this->auth->user()->batch_id; $batch = \App\Batch::find($batchId); $batch->remain_count--; $batch->save(); $user_item = new \App\ItemUserRelation(); $user_item->fill(['batch_id' => $batchId, 'item_id' => $itemId, 'user_id' => $userid]); $user_item->label = $label == 'True'; $user_item->save(); return redirect('/tag/' . $id); }
public function userData($request) { $ecosponsor = $request->cookie('ecosponsor'); $data['ecosponsor'] = $ecosponsor; \Log::info("ecosponsor = {$ecosponsor}"); $data['user_name'] = $request->session()->get('user_name'); $data['username'] = $request->session()->get('username'); $username = $request->session()->get('user_name'); $roles = $request->session()->get('userRoles'); \Log::info("username = {$username}"); $data['user_id'] = $request->session()->get('user_id'); $user = Users::find($data['user_id']); if ($user) { $referralLink = "http://eco-nomix.org/referred/{$user->id}"; } else { $referralLink = "Not Logged in"; } $data['referral_link'] = $referralLink; $data['errors'] = []; $data['userRoles'] = $roles; $data['economix_url'] = 'test'; $data['homePage'] = 'homePage'; $data['title'] = 'Admin'; $data['description'] = 'Admin'; return $data; }
/** * 接收开放平台授权事件. * * @param Request $request */ public function verify(Request $request) { $options = ['debug' => true, 'app_id' => env('COMPONENT_APPID'), 'secret' => env('COMPONENT_APPSECRET'), 'token' => env('COMPONENT_TOKEN'), 'aes_key' => env('COMPONENT_AES_KEY'), 'log' => ['level' => \Monolog\Logger::DEBUG, 'file' => storage_path('logs/easywechat.log')], 'oauth' => ['scopes' => ['snsapi_userinfo'], 'callback' => '/examples/oauth_callback.php']]; $easywechat = new Application($options); $content = strval($request->getContent(false)); $decryptedData = $easywechat->encryptor->decryptMsg($request->get('msg_signature'), $request->get('nonce'), $request->get('timestamp'), $content); \Log::info($decryptedData); // verity_ticket 存入缓存 Cache::forever('component_verify_ticket', $decryptedData['ComponentVerifyTicket']); echo 'success'; }
public function getTest() { $ip = \Request::ip(); \Log::info($ip); echo "<h2>Hello</h2>"; }