/** * Decypts the RCON Password * @return string */ public function getPassword() { if (empty($this->rcon_password)) { throw new RconException(500, 'RCON Password Not Set'); } return Crypt::decrypt($this->rcon_password); }
public function extractKeyAndUser(Request $request) { $apiKey = $request->header('Authorization'); if (!$apiKey) { throw new InvalidAuthException('No Authorization header provided.'); } if (strpos($apiKey, 'Basic ') === 0) { $apiKey = substr($apiKey, 5, strlen($apiKey)); } $parts = explode(':', $apiKey); if (sizeof($parts) != 2) { throw new InvalidAuthException('Invalid Authorization header provided. It has to be user:code'); } $user = User::where('email', trim($parts[0]))->first(); if ($user) { try { $key = new PrivateKey($user->rsaKey->private); $pass = Crypt::decrypt(trim($parts[1])); $key->unlock($pass); return ['user' => $user, 'key' => $key]; } catch (\Exception $e) { throw new InvalidAuthException($e->getMessage()); } } return null; }
public function getConfirmEmail($token) { try { $email = Crypt::decrypt($token); $userQuery = DB::table('users')->where('email', $email); $user = $userQuery->first(); if (isset($user)) { switch (\Config::get('app.registerMode')) { case 'auto': $userQuery->update(['active' => 1]); Util::flash(trans('auth.confirmed'), '', Util::ALERT_SUCCESS); // Foi enviado um email. return view('auth/login'); break; case 'confirm': $userQuery->update(['pending' => 1]); return view('info', ['title' => trans('auth.pending-approval_confirmation'), 'text' => trans('auth.pending-approval')]); break; } } else { Util::flash(trans('auth.user'), '', Util::ALERT_ERROR); } // Não existe o email. } catch (Exception $e) { Util::flash(trans('auth.token'), '', Util::ALERT_ERROR); // Token inválido. } return Redirect::action(self::HOME_ACTION); }
/** * Execute the console command. * * @return mixed */ public function fire() { // Get the Name and Value of the environment variable. $name = $this->argument('name'); $value = $this->argument('value'); // If the name of the environment variable has not been included, ask the user for it. if (empty($name)) { $name = $this->ask('What is the name of the environment variable?'); } // If the value of the environment variable has not been included, ask the user for it. if (empty($value)) { $value = $this->ask('What is the value of the environment variable?'); } // Append the new environment variable to the file. try { \File::get('.env'); // Encrypt the value. $encrypted_value = Crypt::encrypt($value); // Append the value to the .env file. \File::append('.env', "\n{$name} = {$encrypted_value} "); // Display success message using the decrypted value of the encrypted value. $this->info('The environment variable named ' . $name . ' has been added with the value of ' . Crypt::decrypt($encrypted_value) . '. Please check that the value displayed is the supplied value.'); } catch (\Illuminate\Contracts\Filesystem\FileNotFoundException $e) { $this->error('Unable to load the .env file.'); } }
public function match($store) { $cookie = Cookie::get('store'); if ($cookie && ($store_id = Crypt::decrypt($cookie))) { return $store->find($store_id); } return false; }
/** * Get refresh token from session and decrypt it. * * @return mixed */ public function getRefreshToken() { if ($this->has('refresh_token')) { $token = $this->get('refresh_token'); return Crypt::decrypt($token); } throw new MissingRefreshTokenException(sprintf('No refresh token stored in current session. Verify you have added refresh_token to your scope items on your connected app settings in Salesforce.')); }
function decrypt($value) { try { return Crypt::decrypt($value); } catch (DecryptException $e) { // } }
/** * @param Request $request * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View */ public function showAction(Request $request) { $configuration = $this->repository->findFirst(); if (!$configuration) { $data = ['send_email_process' => '1']; $data['url_form'] = Configuration::URL_FORM; $configuration = Configuration::firstOrCreate($data); } return view('configuration.form', ['configuration' => $configuration, 'password' => strlen($configuration->password) ? Crypt::decrypt($configuration->password) : $configuration->password, 'choices' => Configuration::$selectChoices]); }
public function downloadAReportTask(Request $request) { // get parameters from url route $parameters = $request->route()->parameters(); $reportTask = ReportTask::builder()->find(Crypt::decrypt($parameters['token'])); $filename = Crypt::decrypt($parameters['filename']); if ($reportTask === null) { abort(404); } return response()->download(storage_path('exports') . '/' . $filename . '.' . $reportTask->extension_file_023); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (Auth::guest()) { Auth::onceUsingId(Crypt::decrypt(request()->input('_user'))); } if (Auth::user()) { return $next($request); } else { Response::make('No Autorizado', 401); } }
private function replaceData($data) { $data['ip'] = getIp(); $data['ratingspage_id'] = $data['id']; $data['ratingspage_type'] = str_replace("\\", "_", Crypt::decrypt($data['model'])); $data['rating'] = $data['value']; if (Sentry::check()) { $data['user_id'] = Sentry::getUser()->id; } return $data; }
public function modelDecrypterCallback($array) { $new_array = []; foreach ($array as $key => $value) { if (in_array($key, $this->encryptable_array)) { $new_array[$key] = Crypt::decrypt($value); } else { $new_array[$key] = $value; } } return $new_array; }
/** * if a user is deactivated by admin * can not access any route that is under auth middleware * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (Cookie::get('blocked') && Cookie::get('blocked') === Crypt::decrypt(Cookie::get('blocked'))) { return redirect('home')->with(['error' => 'messages.error.not_active']); } $user = Auth::user(); if ($user->active === '1') { return $next($request); } Auth::logout(); return redirect('home')->with(['error' => 'messages.error.not_active'])->withCookie(Cookie::make('blocked', Crypt::encrypt('blocked'), '12000')); }
/** * Extending Laravel Validator (http://laravel.com/docs/validation#custom-validation-rules) */ public function validate($attribute, $value, $parameters, $validator) { // Laravel will throw an uncaught exception if the value is empty // We will try and catch it to make it easier on users. try { $value = Crypt::decrypt($value); } catch (\Illuminate\Encryption\DecryptException $exception) { return false; } // The current time should be greater than the time the form was built + the speed option return is_numeric($value) && time() > $value + $parameters[0]; }
public function doAddComment() { parse_str(Input::get('data'), $data); if (isset($data['id_page'])) { $data['commentpage_type'] = Crypt::decrypt($data['commentable']); $data['commentpage_id'] = $data['id_page']; if (Sentry::check()) { $data['user_id'] = Sentry::getUser()->id; $data['name'] = Sentry::getUser()->getFullName(); } Comment::create($data); return $this->listCommetns($data['commentpage_type'], $data['id_page']); } }
/** * @return \Illuminate\Http\RedirectResponse */ public function getActivate() { try { $token = Input::get('token'); $email = Input::get('email'); $id = Crypt::decrypt($token); $user = User::where(['id' => $id, 'email' => $email])->firstOrFail(); $user->active = true; $user->save(); Auth::loginUsingId($user->id); return Redirect::route('home'); } catch (\Exception $e) { return Redirect::route('login'); } }
public function getFind($id) { $data = $this->find($id); if ($data != null) { $data->package_id = Crypt::decrypt($data->package_id); $data->source = Crypt::decrypt($data->source); $data->destination = Crypt::decrypt($data->destination); $data->port = Crypt::decrypt($data->port); $data->protocol = Crypt::decrypt($data->protocol); $data->data = Crypt::decrypt($data->data); } else { $data = new Package(); } return $data; }
public function onOpen(ConnectionInterface $conn) { // Store the new connection to send messages to later $this->clients->attach($conn); $session = (new SessionManager(App::getInstance()))->driver(); $cookies = $conn->WebSocket->request->getCookies(); $laravelCookie = urldecode($cookies[Config::get('session.cookie')]); $idSession = Crypt::decrypt($laravelCookie); $session->setId($idSession); $session->start(); $userId = $session->get(Auth::getName()); $user = User::find($userId); $conn->userId = $userId; $conn->isAdmin = $user->is_admin === true; echo "New connection! ({$conn->resourceId}), {$userId}\n"; }
/** * Bootstrap any application services. * * @return void */ public function boot() { $this->app->singleton(\Google_Client::class, function ($app) { $client = new \Google_Client(); $client->setApplicationName('GDrive Comments'); $client->setClientId(config('services.google.client_id')); $client->setClientSecret(config('services.google.client_secret')); $client->setAccessToken(Crypt::decrypt($app['auth']->user()->token)); return $client; }); $this->app->singleton(\Google_Service_Drive::class, function ($app) { if ($app->environment() === 'testing') { return new MockedGoogleServiceDrive(); } $drive = new \Google_Service_Drive($app[\Google_Client::class]); return $drive; }); }
public function login(Request $req) { session_start(); $contrasena = ""; $usuario = Usuario::where('usuario', $req->username)->first(); $_SESSION['nombres'] = $usuario->nombres; if (isset($usuario)) { $contrasena = Crypt::decrypt($usuario->password); if ($contrasena != $req->passwordLog) { $usuario = null; } } if (isset($usuario)) { $_SESSION['key'] = $usuario->id; return view('principal', ['user' => $usuario->nombres]); } return view('welcome'); }
/** * 验证token,返回当前用户的id * @param $token */ public static function validateToken($token) { try { $decrypted = Crypt::decrypt($token); } catch (DecryptException $e) { return false; } $str = base64_decode($decrypted); $login_info = explode("&&", $str); //检查时间 $last_time = $login_info[0]; $login_time = microtime(true); $remind = $login_time - $last_time; if ($remind > 36000) { return false; } return $login_info[1]; }
public function createCustomRecord($parameters) { $parameters['companies'] = Company::all(); $parameters['families'] = Family::all(); $parameters['brands'] = Brand::all(); $parameters['products'] = Product::builder()->where('active_072', true)->get(); // decrypt id $parameters['id'] = Crypt::decrypt($parameters['id']); $order = Order::builder()->find($parameters['id']); if ($order == null) { return redirect()->route($this->resource == 'octopus-stock' ? 'octopusStock' : 'octopusLaboratoryOrder')->with(['msg' => 2, 'txtMsg' => trans('octopus::pulsar.order_does_not_exist', ['id' => $parameters['id']])]); } if ($order->stock_id_079 != null) { return redirect()->route($this->resource == 'octopus-stock' ? 'octopusStock' : 'octopusLaboratoryOrder')->with(['msg' => 2, 'txtMsg' => trans('octopus::pulsar.stock_already_created', ['id' => $order->id_079])]); } $object = ['name_076' => $order->name_076, 'address_076' => $order->address_076, 'cp_076' => $order->cp_076, 'locality_076' => $order->locality_076, 'alias_077' => $order->alias_077, 'request_id_080' => $order->request_id_079, 'order_id_080' => $order->id_079, 'supervisor_id_080' => $order->supervisor_id_079, 'customer_id_080' => isset($order->customer_id_079) ? $order->customer_id_079 : null, 'shop_id_080' => $order->shop_id_079, 'company_id_080' => $order->company_id_079, 'family_id_080' => $order->family_id_079, 'brand_id_080' => $order->brand_id_079, 'product_id_080' => $order->product_id_079, 'laboratory_id_080' => $order->laboratory_id_079, 'address_id_080' => isset($order->address_id_079) ? $order->address_id_079 : null, 'company_name_080' => isset($order->company_name_079) ? $order->company_name_079 : null, 'name_080' => isset($order->name_079) ? $order->name_079 : null, 'surname_080' => isset($order->surname_079) ? $order->surname_079 : null, 'country_id_080' => $order->country_id_079, 'territorial_area_1_id_080' => isset($order->territorial_area_1_id_079) ? $order->territorial_area_1_id_079 : null, 'territorial_area_2_id_080' => isset($order->territorial_area_2_id_079) ? $order->territorial_area_2_id_079 : null, 'territorial_area_3_id_080' => isset($order->territorial_area_3_id_079) ? $order->territorial_area_3_id_079 : null, 'cp_080' => isset($order->cp_079) ? $order->cp_079 : null, 'locality_080' => isset($order->locality_079) ? $order->locality_079 : null, 'address_080' => isset($order->address_079) ? $order->address_079 : null, 'phone_080' => isset($order->phone_079) ? $order->phone_079 : null, 'email_080' => isset($order->email_079) ? $order->email_079 : null, 'observations_080' => isset($order->observations_079) ? $order->observations_079 : null, 'view_height_080' => $order->view_width_079, 'view_width_080' => $order->view_height_079, 'total_height_080' => isset($order->total_width_079) ? $order->total_width_079 : null, 'total_width_080' => isset($order->total_height_079) ? $order->total_height_079 : null, 'units_080' => $order->units_079, 'expiration_080' => isset($order->expiration_079) ? $order->expiration_079 : null, 'expiration_text_080' => isset($order->expiration_text_079) ? $order->expiration_text_079 : null, 'attachment_080' => isset($order->attachment_079) ? $order->attachment_079 : null, 'comments_080' => isset($order->comments_079) ? $order->comments_079 : null]; $parameters['object'] = (object) $object; return $parameters; }
/** * Execute the job. * * @return void */ public function handle(StoredValue $sv) { $card_num = $this->card_number; $pin = Crypt::decrypt($this->pin); $checkBalanceResponse = $sv->checkBalance($card_num, $pin); if ($checkBalanceResponse->getErrorCode() != 0) { //fail the job. } if ($checkBalanceResponse->getAmount() != $this->card->balance) { //fail the job } $resetResponse = $sv->changePin($card_num); if ($resetResponse->getErrorCode() != 0) { //retry? } $pin = $resetResponse->getCardPin(); Log::info('new pin ' . $pin); $this->card->encyrpted_pin = Crypt::encrypt($pin); $this->card->status = 'available'; $this->card->save(); $this->delete(); }
/** * Function that checks the output of a server mail account * * @access public * @param array $account * @return boolean || string */ public static function testEmailAccount($account) { $data['name'] = $account['name_013']; $data['email'] = $account['email_013']; $data['subject'] = "Send test - Envío de pruebas"; $data['text'] = "\n\nCongratulations,\nthis is a test email, if you are receiving this email, your account has been configured correctly.\n\nEnhorabuena,\neste es un envío de pruebas, si está recibiendo este correo, su cuenta se ha configurado correctamente."; //set outgoingserver config(['mail.host' => $account['outgoing_server_013']]); config(['mail.port' => $account['outgoing_port_013']]); config(['mail.from' => ['address' => $account['email_013'], 'name' => $account['name_013']]]); config(['mail.encryption' => $account['outgoing_secure_013'] == '' ? null : $account['outgoing_secure_013']]); config(['mail.username' => $account['outgoing_user_013']]); config(['mail.password' => Crypt::decrypt($account['outgoing_pass_013'])]); try { self::sendEmail($data); } catch (\Swift_TransportException $swiftTransportException) { $messageBag = new MessageBag(); $messageBag->add('error', $swiftTransportException->getMessage()); return $messageBag; } return true; }
public static function checkMessageToSend() { $notificationsAccount = Preference::getValue('formsNotificationsAccount', 4); $emailAccount = EmailAccount::find($notificationsAccount->value_018); if ($emailAccount == null) { return null; } $messages = Message::where('dispatched_405', false)->get(); config(['mail.host' => $emailAccount->outgoing_server_013]); config(['mail.port' => $emailAccount->outgoing_port_013]); config(['mail.from' => ['address' => $emailAccount->email_013, 'name' => $emailAccount->name_013]]); config(['mail.encryption' => $emailAccount->outgoing_secure_013 == 'null' ? null : $emailAccount->outgoing_secure_013]); config(['mail.username' => $emailAccount->outgoing_user_013]); config(['mail.password' => Crypt::decrypt($emailAccount->outgoing_pass_013)]); foreach ($messages as $message) { Mail::send(['html' => $message->template_405, 'text' => $message->text_template_405], ['dataMessage' => $message, 'dataTextMessage' => json_decode($message->data_message_405), 'data' => json_decode($message->data_405)], function ($m) use($emailAccount, $message) { $m->to($message->email_405, $message->name_405)->subject(trans($message->subject_405) . ' ' . json_decode($message->data_message_405)->name_form_405 . ' ( ID. ' . json_decode($message->data_405)->id_403 . (isset(json_decode($message->data_405)->email_403) && isset(json_decode($message->data_405)->email_403) != '' ? ' - ' . json_decode($message->data_405)->email_403 : null) . ' )'); if ($emailAccount->reply_to_013 != null) { $m->replyTo($emailAccount->reply_to_013); } }); Message::where('id_405', $message->id_405)->update(['dispatched_405' => true, 'send_date_405' => date('U')]); } }
/** * @param $password * * @return string */ public function getPasswordAttribute($password) { return Crypt::decrypt($password); }
public function getAccessTokenAttribute($value) { return json_decode(Crypt::decrypt($value), true); }
/** * getConnections() function fetches all connections from * connection and table specified. Then returns a path * to a configuration file which gets imported and * deleted. * * @param $connection * @param $table * @return null|string */ public static function getConnections($connection, $table) { $connections = DB::connection($connection)->table($table)->get(); if (!empty($connections)) { /** * Create an empty array which will get populated with the data from * $connections in the correct format within the foreach statement * below file generation. */ $config = array(); /** * Generate a random string for the filename as it is temporary * and more secure. */ $random_string = ConnectionLoader::random_string(35); /** * Append the .php extension to the file name and store here * storage_path/app/$tempFile with some starting content. */ $tempFileName = $random_string . '.php'; $tempFile = Storage::disk('local')->put($tempFileName, '<?php return '); if ($tempFile === true) { /** * Loops through the connections checking the driver and pushes * correctly formatted array into the $config array. */ foreach ($connections as $connection) { $name = $connection->name; $driver = $connection->driver; if ($driver == 'sqlite') { $connection_config = array('driver' => $driver, 'database' => database_path($connection->database), 'prefix' => $connection->prefix); $config[$name] = $connection_config; } elseif ($driver == 'mysql') { $strict = $connection->strict; if ($strict == 1) { $strict = true; } else { $strict = false; } $password = $connection->password; if (empty($password)) { $connection_config = array('driver' => $driver, 'host' => $connection->host, 'database' => $connection->database, 'username' => $connection->username, 'password' => $password, 'charset' => $connection->charset, 'collation' => $connection->collation, 'prefix' => $connection->prefix, 'strict' => $strict); } else { $connection_config = array('driver' => $driver, 'host' => $connection->host, 'database' => $connection->database, 'username' => $connection->username, 'password' => Crypt::decrypt($password), 'charset' => $connection->charset, 'collation' => $connection->collation, 'prefix' => $connection->prefix, 'strict' => $strict); } $config[$name] = $connection_config; } elseif ($driver == 'pgsql') { $password = $connection->password; if (empty($password)) { $connection_config = array('driver' => $driver, 'host' => $connection->host, 'port' => $connection->port, 'database' => $connection->database, 'username' => $connection->username, 'password' => $password, 'charset' => $connection->charset, 'prefix' => $connection->prefix, 'schema' => $connection->schema); } else { $connection_config = array('driver' => $driver, 'host' => $connection->host, 'port' => $connection->port, 'database' => $connection->database, 'username' => $connection->username, 'password' => Crypt::decrypt($password), 'charset' => $connection->charset, 'prefix' => $connection->prefix, 'schema' => $connection->schema); } $config[$name] = $connection_config; } } /** * Append a var_export of $config to the temporary file and * append the semicolon. * * Returns the temporary filename. */ $endFile = ';'; Storage::append($tempFileName, var_export($config, true)); Storage::append($tempFileName, $endFile); return $tempFileName; } else { \error_log('Unable to create temporary file'); } } else { \error_log('Configuration File Connection Invalid.'); return null; } }
/** * @param $secret * @return mixed */ public function getSecretAttribute($secret) { return Crypt::decrypt($secret); }
/** * @return mixed **/ public function grid() { $EncryptedSearch = Request::get('search', ""); if ("" == $EncryptedSearch) { return Response::json(['error' => true, 'description' => 'No search'], 412); } // try { $search = Crypt::decrypt($EncryptedSearch); } catch (\Exception $e) { return Response::json(['error' => true, 'description' => 'Search decode'], 412); } // $response = Gulliver::getInsuranceAvailability(['origin' => mb_convert_case($search['origin'], MB_CASE_UPPER), 'destination' => mb_convert_case($search['destination'], MB_CASE_TITLE), 'dateFrom' => $search['dateFrom'], 'dateTo' => $search['dateTo'], 'passengers' => true == is_array($search['passengers']) ? implode(',', $search['passengers']) : $search['passengers'], 'currency' => 'ARS']); if (false == $response) { return Response::json(['error' => true, 'description' => Gulliver::$error], 412); } // $sessionId = $response['sessionId']; $response = $response['availablePlans']; // foreach ($response as $key => $item) { $response[$key]['insuranceTotalPrices']['requestedSellingPrice']['taxes'] = $item['insuranceTotalPrices']['requestedSellingPrice']['afterTax'] - $item['insuranceTotalPrices']['requestedSellingPrice']['beforeTax']; // $row = InsuranceModel::store(['session' => $sessionId, 'plan_number' => $key, 'item' => json_encode($response[$key]), 'search' => json_encode($search)]); // http://viajes-laravel.dev/compra/seguros/?GID=71ff1103-d3c6-4e12-92b1-0caccc864d2a&BID=1 $response[$key]['booking'] = url() . '/compra/seguros?' . http_build_query(['GID' => $sessionId, 'BID' => $row->id]); } // Cookie::queue(self::$config['cookieName'], $search, self::$config['cookieTtl']); // return Response::json(['error' => false, 'description' => 'Ok', 'total' => sizeof($response), 'grid' => view('Insurance/grid')->with(['destination' => mb_convert_case($search['destination'], MB_CASE_LOWER), 'response' => $response])->render()], 200); }