function logout_all() { $log = new Log(); $id = $_SESSION['user_login_id']; $sql = "UPDATE `user_login` SET `user_logout_time` = SYSDATE() , `user_login_status` = '0' WHERE `id` = '{$id}' "; DB::update(DB::raw($sql)); $log->add_log(" ", " ", "User Logout"); // add a log }
public function nuevaReceta(Receta $receta) { $result = $this->serviceReceta->nuevaReceta($receta); if ($result) { $log = new Log(); $log->setIdAnimal($receta->getIdAnimal()); $log->setTipoLog('Receta'); $log->setDescripcion(' Receta creada con exito'); $this->serviceLog->nuevoLog($log); return 'Atencion creada con exito'; } else { return 'Error al crear atencion, intentelo nuevamente'; } }
public function nuevoApunte(Apunte $apunte) { $result = $this->serviceApunte->nuevoApunte($apunte); if ($result) { $log = new Log(); $log->setIdAnimal($apunte->getIdAnimal()); $log->setTipoLog('Apunte'); $log->setDescripcion('Apunte creado con exito'); $this->serviceLog->nuevoLog($log); return 'Apunte creada con exito'; } else { return 'Error al crear apunte, intentelo nuevamente'; } }
public function edit(Request $request) { if (!\Session::get('user')->can('硬件管理')) { abort(401); } $hardware = Hardware::find($request->input('id')); $old_attributes = $hardware->attributesToArray(); $hardware->name = $request->input('name'); $hardware->description = $request->input('description'); $hardware->model = $request->input('model'); $hardware->self_produce = (bool) ($request->input('self_produce') == 'on'); $new_attributes = $hardware->attributesToArray(); $user = \Session::get('user'); foreach (array_diff_assoc($old_attributes, $new_attributes) as $key => $value) { $old = $old_attributes[$key]; $new = $new_attributes[$key]; if ($key == 'self_produce') { $old = $old == 'true' ? '自产' : '外采'; $new = $new == 'true' ? '自产' : '外采'; } \Log::notice(strtr('硬件修改: 用户(%name[%id]) 修改了硬件 (%hardware[%hardware_id]) 的基本信息: [%key] %old --> %new', ['%name' => $user->name, '%id' => $user->id, '%hardware' => $hardware->name, '%hardware_id' => $hardware->id, '%key' => $key, '%old' => $old, '%new' => $new])); } $hardware->save(); return redirect()->back()->with('message_content', '修改成功!')->with('message_type', 'info'); }
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; }
private function execute($message, $tg) { try { if (!array_key_exists('text', $message)) { app()->abort(200, 'Missing command'); } if (starts_with($message['text'], '/start')) { $this->start($message, $tg); } else { if (starts_with($message['text'], '/cancel')) { $this->cancel($message, $tg); } else { if (starts_with($message['text'], '/list')) { $this->listApps($message, $tg); } else { if (starts_with($message['text'], '/revoke')) { $this->revoke($message, $tg); } else { if (starts_with($message['text'], '/help')) { $this->help($message, $tg); } else { $this->commandReply($message, $tg); } } } } } return response()->json('', 200); } catch (\Exception $e) { \Log::error($e); app()->abort(200); } }
public function LihatLog() { // return Log::getMonolog(); Log::listen(function ($level, $message, $context) { return " {$level} || {$message} || {$context} "; }); }
/** * Stores new upload * */ public function store() { $file = Input::file('file'); $upload = new Upload(); try { $upload->process($file); } catch (Exception $exception) { // Something went wrong. Log it. Log::error($exception); $error = array('name' => $file->getClientOriginalName(), 'size' => $file->getSize(), 'error' => $exception->getMessage()); // Return error return Response::json($error, 400); } // If it now has an id, it should have been successful. if ($upload->id) { $newurl = URL::asset($upload->publicpath() . $upload->filename); // this creates the response structure for jquery file upload $success = new stdClass(); $success->name = $upload->filename; $success->size = $upload->size; $success->url = $newurl; $success->thumbnailUrl = $newurl; $success->deleteUrl = action('UploadController@delete', $upload->id); $success->deleteType = 'DELETE'; $success->fileID = $upload->id; return Response::json(array('files' => array($success)), 200); } else { return Response::json('Error', 400); } }
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 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"; }
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(); }
private function notifyHost($client, $reservation) { $host = $reservation->property->user; $twilioNumber = config('services.twilio')['number']; try { $client->account->messages->sendMessage($twilioNumber, $host->fullNumber(), $reservation->message); } catch (Exception $e) { Log::error($e->getMessage()); } }
public function update(Request $request) { $query = DB::table('Company')->where('companyId', $request->input('companyId'))->update(array('companyName' => $request->input('companyName'), 'generalAttributes' => $request->input('generalAttributes'), 'purposeAndTopic' => $request->input('purposeAndTopic'), 'companyCenterAndDepartment' => $request->input('companyCenterAndDepartment'), 'jobDescription' => $request->input('jobDescription'), 'companyAdress' => $request->input('companyAdress'), 'employeeCount' => $request->input('employeeCount'), 'companyMail' => $request->input('companyMail'), 'employeeId' => \Session::get('employeeId'))); \Log::error($query); if ($query) { $result = array("result" => "success"); } else { $result = array("result" => "failed"); } return \View::make('ajaxResult', $result); }
/** * 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'); }
private function notifyHost($client, $reservation) { $host = $reservation->property->user; $twilioNumber = config('services.twilio')['number']; $messageBody = $reservation->message . ' - Reply \'yes\' or \'accept\' to confirm the reservation, or anything else to reject it.'; try { $client->messages->create($host->fullNumber(), ['from' => $twilioNumber, 'body' => $messageBody]); } catch (Exception $e) { Log::error($e->getMessage()); } }
/** * 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!'; }
/** * Store a newly created resource in storage. * * @return Response */ public function store(MicroCritical $request) { //store $microcritical = new MicroCritical(); $microcritical->description = $request->description; try { $microcritical->save(); $url = session('SOURCE_URL'); return redirect()->to($url)->with('message', trans('messages.record-successfully-saved'))->with('activemicrocritical', $microcritical->id); } catch (QueryException $e) { Log::error($e); } }
/** * Store a newly created resource in storage. * * @return Response */ public function store($measures) { // dd($measures); $measureIds = array(); foreach ($measures as $data) { $measure = new Measure(); $measure->name = trim($data['name']); $measure->measure_type_id = $data['measure_type_id']; $measure->unit = $data['unit']; $measure->description = $data['description']; try { $measure->save(); $measureIds[] = $measure->id; } catch (QueryException $e) { Log::error($e); } if ($measure->isNumeric()) { $val['agemin'] = $data['agemin']; $val['agemax'] = $data['agemax']; $val['gender'] = $data['gender']; $val['rangemin'] = $data['rangemin']; $val['rangemax'] = $data['rangemax']; $val['interpretation'] = $data['interpretation']; // Add ranges for this measure for ($i = 0; $i < count($val['agemin']); $i++) { $measurerange = new MeasureRange(); $measurerange->measure_id = $measure->id; $measurerange->age_min = $val['agemin'][$i]; $measurerange->age_max = $val['agemax'][$i]; $measurerange->gender = $val['gender'][$i]; $measurerange->range_lower = $val['rangemin'][$i]; $measurerange->range_upper = $val['rangemax'][$i]; $measurerange->interpretation = $val['interpretation'][$i]; $measurerange->save(); } } else { if ($measure->isAlphanumeric() || $measure->isAutocomplete()) { $val['val'] = $data['val']; $val['interpretation'] = $data['interpretation']; for ($i = 0; $i < count($val['val']); $i++) { $measurerange = new MeasureRange(); $measurerange->measure_id = $measure->id; $measurerange->alphanumeric = $val['val'][$i]; $measurerange->interpretation = $val['interpretation'][$i]; $measurerange->save(); } } } } return $measureIds; }
public function store(Request $request) { $this->validate($request, ['name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|confirmed|min:6', 'rol' => 'required|in:1,2', 'image' => 'required|mimes:jpeg,png,bmp']); if (!$request->file('image')->isValid()) { Log::error('Invalid image file for user ' . Carbon::now()); App::abort(500); } $image_name = $request->input('email') . Carbon::now()->timestamp . "_" . $request->file('image')->getClientOriginalName(); $request->file('image')->move(public_path() . '/images/users/', $image_name); $data = $request->all(); $data['image'] = $image_name; User::create($data); return redirect(action('UserController@index')); }
public function delete($id) { if (!\Session::get('user')->can('产品信息管理')) { abort(401); } $product = Product::find($id); $product_name = $product->name; $product_id = $product->id; if ($product->delete()) { $user = \Session::get('user'); \Log::notice(strtr('产品删除: 用户(%name[%id]) 删除产品 (%product[%product_id])', ['%name' => $user->name, '%id' => $user->id, '%product' => $product_name, '%product_id' => $product_id])); return redirect()->route('products')->with('message_content', '删除成功!')->with('message_type', 'info'); } }
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); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { session_start(); $data = $request->all(); $count = App\User::where('user_name', $data['user_name'])->count(); if ($count != 0) { return 0; } else { $data['user_owner'] = $_SESSION['user_id']; $data['user_password'] = md5($data['user_password']); $userid = App\User::create($data)->id; $log = new Log(); $log->add_log("users", $userid, "insert"); // add a log foreach ($_SESSION['groups'] as $group_name) { $group_d = App\group::where('group_name', $group_name)->first(); $group_pri = App\privilege::where('group_id', $group_d->group_id)->first(); $data_pri = ['user_id' => $userid, 'group_id' => $group_d->group_id, 'call_log' => $group_pri->call_log, 'contact' => $group_pri->contact, 'account' => $group_pri->account, 'user' => $group_pri->user, 'group' => $group_pri->group, 'sales' => $group_pri->sales, 'ticket' => $group_pri->ticket]; App\user_group::create($data_pri); } return redirect('user'); } }
/** * */ public function within(Request $request) { $start = microtime(true); if (str_contains($request->path(), 'mongo')) { $collection = $this->model->within($request->json('geometry.coordinates')); $elapsed = microtime(true) - $start; } else { $geometry = \geoPHP::load($request->input('geometry'), 'wkt'); $collection = $this->model->within($geometry->asText('wkt')); $elapsed = microtime(true) - $start; } $logMessage = 'ms to get %s data: %f in %s'; \Log::debug(sprintf($logMessage, str_contains($request->path(), 'mongo') ? 'Mongo' : 'PostGIS', $elapsed, 'within()')); return Response::json(['points' => $collection, 'area' => 0]); }
/** * Handle incomming hooks. * * @param Request $request Incomming request object * @param string $appName Name of the application the hook came from * * @return Response */ public function recieve(Request $request, $appName) { /** @var \App\Hooks\ServiceRouter $serviceRouter */ $serviceRouter = app('ServiceRouter'); $result = $serviceRouter->route($request, $appName); if ($result === false) { \Log::error('Unable to handle request ' . $request->getUri()); \Log::error(json_encode($request->all(), JSON_PRETTY_PRINT)); return ['status' => 'Failure', 'message' => 'Unable to handle this type of request']; } if (isset($result['project']) && $result['project'] instanceof Project) { $this->processProject($result); } return ['status' => 'Success']; }
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 edit(Request $request) { $user = \Session::get('user'); if (!$user->can('产品模块管理')) { abort(401); } $module = Module::find($request->input('module_id')); $old_attributes = $module->attributesToArray(); $module->name = $request->input('name'); $module->description = $request->input('description'); $module->save(); $new_attributes = $module->attributesToArray(); $product = $module->product; foreach (array_diff_assoc($old_attributes, $new_attributes) as $key => $value) { \Log::notice(strtr('产品模块修改: 用户(%name[%id]) 修改了产品 (%product[%product_id]) 的模块 (%module[%module_id])基本信息: [%key] %old --> %new', ['%name' => $user->name, '%id' => $user->id, '%product' => $product->name, '%product_id' => $product->id, '%key' => $key, '%old' => $old_attributes[$key], '%new' => $new_attributes[$key]])); } $old_deped_modules = $module->dep_modules->lists('id')->all(); if (count($old_deped_modules)) { $module->dep_modules()->detach($old_deped_modules); } $new_deped_modules = $request->input('modules', []); $d1 = array_diff($new_deped_modules, $old_deped_modules); $d2 = array_diff($old_deped_modules, $new_deped_modules); if (count($d1)) { $dep_modules = []; foreach ($d1 as $id) { $m = Module::find($id); $dep_modules[] = strtr('(%name[%id])', ['%name' => $m->name, '%id' => $m->id]); } //新加的模块 \Log::notice(strtr('产品模块修改: 用户(%name[%id]) 增加了产品 (%product[%product_id]) 的模块 (%module[%module_id]) 的依赖模块 %dep_modules', ['%name' => $user->name, '%id' => $user->id, '%product' => $product->name, '%product_id' => $product->id, '%module' => $module->name, '%module_id' => $module->id, '%dep_modules' => implode(',', $dep_modules)])); } if (count($d2)) { $dep_modules = []; foreach ($d2 as $id) { $m = Module::find($id); $dep_modules[] = strtr('(%name[%id])', ['%name' => $m->name, '%id' => $m->id]); } //删除的模块 \Log::notice(strtr('产品模块修改: 用户(%name[%id]) 删除了产品 (%product[%product_id]) 的模块 (%module[%module_id]) 的依赖模块 %dep_modules', ['%name' => $user->name, '%id' => $user->id, '%product' => $product->name, '%product_id' => $product->id, '%module' => $module->name, '%module_id' => $module->id, '%dep_modules' => implode(',', $dep_modules)])); } foreach ($new_deped_modules as $module_id) { $dep_module = Module::find($module_id); $module->dep_modules()->save($dep_module); } return redirect()->back()->with('message_content', '修改成功!')->with('message_type', 'info'); }