public function parse() { if (is_null($this->rawData) === true || count(explode("\n", $this->rawData)) < 3) { $whoisServer = isset($this->rir->whois_server) ? $this->rir->whois_server : 'NO WHOIS SERVER'; Log::warning("No raw whois data returned for: " . $this->input . "(" . $whoisServer . ")"); return null; } // Check if there is the unallocated words in whois returned data if (strpos($this->rawData, 'Unallocated and unassigned') !== false) { Log::warning("Unassigned/Unallocated prefix on: " . $this->input . "(" . $this->rir->whois_server . ")"); return null; } // Check if there the usual issues with the 'high volume' error if (strpos($this->rawData, 'Unable to service request due to high volume') !== false) { Log::warning("High volume whois server error on: " . $this->input . "(" . $this->rir->whois_server . ")"); return null; } $functionName = strtolower($this->rir->name) . "Execute"; try { $results = $this->{$functionName}(); } catch (\Exception $e) { Log::warning(["Something went wrong on: " . $this->input . "(" . $this->rir->whois_server . ")"], [$e->getMessage()]); return null; } return $results; }
/** * {@inheritdoc} */ public function send(Swift_Mime_Message $message, &$failedRecipients = null) { try { $to = implode(', ', array_keys((array) $message->getTo())); $cc = implode(', ', array_keys((array) $message->getCc())); $bcc = implode(', ', array_keys((array) $message->getBcc())); $replyto = ''; foreach ((array) $message->getReplyTo() as $address => $name) { $replyto = $address; break; } $mail_options = ["sender" => "admin@{$this->app->getGaeAppId()}.appspotmail.com", "to" => $to, "subject" => $message->getSubject(), "htmlBody" => $message->getBody()]; if ($cc !== '') { $mail_options['cc'] = $cc; } if ($bcc !== '') { $mail_options['bcc'] = $bcc; } if ($replyto !== '') { $mail_options['replyto'] = $replyto; } $attachments = $this->getAttachmentsArray($message); if (count($attachments) > 0) { $mail_options['attachments'] = $attachments; } $gae_message = new GAEMessage($mail_options); $gae_message->send(); } catch (InvalidArgumentException $ex) { Log::warning("Exception sending mail: " . $ex); } }
public function getUserFromCookie($cookie) { $tokenObject = new Token($cookie); // Get a payload info from the token try { $payload = JWTAuth::decode($tokenObject); } catch (TokenExpiredException $e) { $message = 'Token in cookie was expired'; throw new TokenInCookieExpiredException($message, null, $e); } // Get user by the payload info try { $user = $this->userUpdater->updateBaseInfo($payload); } catch (RepositoryException $e) { throw new AuthException($e->getMessage(), null, $e); } // Attempt to update his profile by API or just log the error try { $user = $this->userUpdater->updateAdditionalInfo($cookie, $user); } catch (UpdatingFailureException $e) { Log::warning('An additional user information was\'nt updated. ' . $e->getMessage()); } // Login Auth::login($user, true); // Return an actual user model if login passes if (Auth::check()) { return $this->userRepository->findWithRelations(Auth::id(), ['localRole']); } else { throw new AuthException('Login error. User is not authorized.'); } }
/** * Listens for and stores PayPal IPN requests. * * @throws InvalidIpnException * * @return IpnOrder */ public function getOrder() { $ipnMessage = null; $listenerBuilder = new ListenerBuilder(); if ($this->getEnvironment() == 'sandbox') { $listenerBuilder->useSandbox(); // use PayPal sandbox } $listener = $listenerBuilder->build(); $listener->onVerified(function (MessageVerifiedEvent $event) { $ipnMessage = $event->getMessage(); Log::info('IPN message verified - ' . $ipnMessage); $this->order = $this->store($ipnMessage); }); $listener->onInvalid(function (MessageInvalidEvent $event) { $report = $event->getMessage(); Log::warning('Paypal returned invalid for ' . $report); }); $listener->onVerificationFailure(function (MessageVerificationFailureEvent $event) { $error = $event->getError(); // Something bad happend when trying to communicate with PayPal! Log::error('Paypal verification error - ' . $error); }); $listener->listen(); return $this->order; }
public static function detectAllLocation() { $views = View::all(); foreach ($views as $view) { if ($view->location != "") { continue; } $ip = $view->ip; $client = new Client(['base_uri' => 'http://ip.taobao.com', 'timeout' => 5.0]); try { $response = $client->request('GET', '/service/getIpInfo.php', ['query' => "ip={$ip}"]); $body = json_decode($response->getBody()); if ($body->code == 0) { $country = $body->data->country; $area = $body->data->area; $region = $body->data->region; $city = $body->data->city; $isp = $body->data->isp; $location = "{$country}-{$area}-{$region}-{$city}-{$isp}"; } else { $location = "获取失败"; } $view->location = $location; } catch (\Exception $e) { Log::warning($e->getMessage()); } $view->save(); } }
/** * Report or log an exception. * * This is a great spot to send exceptions to Sentry, Bugsnag, etc. * * @param \Exception $e * @return void */ public function report(Exception $e) { if ($e instanceof ParserException) { Log::warning('Hiba az url betöltésekor'); return; } return parent::report($e); }
/** * Display a listing of the resource. * * @return Response */ public function index() { Log::info('infoメッセージ'); Log::debug('debugメッセージ'); Log::warning('warningメッセージ'); Log::error('errorメッセージ'); return view('welcome'); }
public function completed() { if (count($this->answered()) == count($this->answers)) { $this->completed = true; } else { Log::warning('Попытка завершить тест при не всех отвеченных вопросах'); } return $this; }
/** * Returns an empty error in case of non-existend database (i.e. when working with a newly deployed system). * * @return array|\Illuminate\Database\Eloquent\Collection|static[] */ protected function getPermission() { try { return Permission::with('roles')->get(); } catch (PDOException $e) { Log::warning('Permission table could not be found when trying to load permissions in AuthServiceProvider'); return []; } }
public function checkFail($check_id, $note = null) { try { $this->guzzle_client->get($this->consul_url . '/v1/agent/check/fail/' . urlencode($check_id), ['query' => ['note' => $note]]); return true; } catch (Exception $e) { Log::warning("failed to update check failure: " . $check_id); return false; } }
/** * @param $id * @return string */ public static function getGametype($id) { $id = intval($id); if (isset(self::$gametype_ids[$id])) { return self::$gametype_ids[$id]; } else { Log::warning('Unknown gametype id ' . $id); return 'Unknown'; } }
/** * @param $id * @return string */ public static function teamIdToString($id) { $id = intval($id); if (isset(self::$team_id_to_string[$id])) { return self::$team_id_to_string[$id]; } else { Log::warning('Team ID: ' . $id . ' is unknown.'); return 'Unknown'; } }
public function insertValue($value) { $now = Carbon::now(); try { DB::table('chart_values')->insert(['chart_id' => $this->id, 'timestamp' => $now, 'value' => $value]); } catch (Exception $error) { Log::warning($error); return false; } return true; }
/** * 写入一行数据到目标资源 * * @param $row * @return mixed */ public function write($row) { // 换行处理 $ret = []; foreach ($row as $item) { $ret[] = str_replace("\n", "\r", $item); } $ret = fputcsv($this->fd, $ret, "\t"); if (false === $ret) { Log::warning("数据行写入csv发生错误,该行数据未能成功写入:" . json_encode($ret)); } }
public function setBodyClass(Request $request) { //$inputs = serialize($request->all()); //Log::info('Ajax request fired to setToggleMenu method: '.$inputs); if ($request->has('styling')) { //Log::info('Found hidemenu with value of: '.$request->input('hidemenu')); session(['body-class' => $request->input('styling')]); //Log::info('Session value is now: '.Session::get('hidden-menu')); } else { Log::warning('setBodyClass called with no styling input'); } }
/** * Use the returned Writer-Instance to log * uses laravel Log if no channel present/configured * * @see Illuminate\Log\Writer * * @param $name string Channelname to log to * * @return Writer */ public function channel($name) { $configChannels = $this->getChannels(); if (in_array($name, $configChannels)) { //Log::debug(print_r($configChannels, true)); $monolog = new Logger($name); return new Writer($monolog, app(null)['events']); } else { Log::warning('Trying to log to unknown channel, using laravel default'); return app()->make('log'); } }
public function updateByTXOIdentifiers($txo_identifiers, $new_attributes) { if (!$txo_identifiers) { Log::warning("No TXO identifiers provided for update"); return; } $query = $this->prototype_model->newQuery(); foreach ($txo_identifiers as $txo_identifier) { list($txid, $n) = explode(':', $txo_identifier); $query->orWhere(function ($query) use($txid, $n) { $query->where('txid', $txid)->where('n', $n); }); } return $query->update($new_attributes); }
/** * Execute the console command. * * @return mixed */ public function fire() { $expiredBlacklistedTokens = $this->Blacklist->findAllExpired(); $expiredBlacklistedTokensCount = count($expiredBlacklistedTokens); if ($expiredBlacklistedTokensCount > 0) { $this->Blacklist->deleteAllExpired(); // The number of expired blacklisted tokens should now be 0 $expiredBlacklistedTokensCountCheck = count($this->Blacklist->findAllExpired()); if ($expiredBlacklistedTokensCountCheck === 0) { Log::info('Successfully deleted ' . $expiredBlacklistedTokensCount . ' expired blacklisted authentication tokens'); } else { Log::warning('Something went wrong deleting expired blacklisted authentication tokens, ' . $expiredBlacklistedTokensCount . ' should have been removed, ' . $expiredBlacklistedTokensCountCheck . ' still remain.'); } } Log::info('No blacklisted blacklisted authentication tokens needed cleaning up as none had deleted expired'); }
/** * Write the log message to the file path set * in this writer. */ public function _write($event) { if (!$this->_formatter) { $formatter = new \SS_LogErrorFileFormatter(); $this->setFormatter($formatter); } $message = $this->_formatter->format($event); switch ($event['priorityName']) { case 'ERR': Log::error($message); break; case 'WARN': Log::warning($message); break; case 'NOTICE': Log::info($message); break; } }
/** * Execute the job. * * @return void */ public function handle() { $result = $this->setCssfile(); if ($result === false) { return false; } $tmpHtmlFile = $this->setHtml(); if (empty($tmpHtmlFile)) { Log::warning('AsyncCss: No html file is loaded'); } $cssOutput = $this->getCssOutput($tmpHtmlFile); if (empty($cssOutput)) { Log::warning('AsyncCss: Css output is empty'); } else { Cache::forever($this->cacheKey, $cssOutput); CssKeys::add($this->cacheKey); } unlink($tmpHtmlFile); }
/** * Execute the job. * * @return void */ public function handle() { $user = $this->user; Log::info("Provisioning Workplace account for user " . $user->id . "."); $request = ['schemas' => ['urn:scim:schemas:core:1.0', 'urn:scim:schemas:extension:enterprise:1.0'], 'userName' => $user->email, 'name' => ['formatted' => $user->name], 'title' => 'Medlem', 'active' => true, 'emails' => [['value' => $user->email, 'type' => 'work', 'primary' => true]], 'urn:scim:schemas:extension:enterprise:1.0' => ['department' => 'Alternativet']]; $client = new Client(['base_uri' => config('services.workplace.scim_url')]); $response = $client->request('POST', 'Users', ['headers' => ['Authorization' => "Bearer " . config('services.workplace.api_token')], 'body' => json_encode($request, JSON_FORCE_OBJECT), 'exceptions' => false]); if ($response->getStatusCode() !== 201) { // It didn't work Log::warning("Workplace account provisioning failed", ['response' => $response->getBody()->getContents()]); return; } $body = json_decode($response->getBody()->getContents()); $account = new WorkplaceAccount(); $account->user()->associate($user); $account->workplace_id = $body->id; $account->active = $body->active; $account->save(); }
public static function addOutputsToChangeAddresses($sendOutPairs, $userId) { // get change addresses and cache for 12h $changeAddresses = ChangeAddress::remember(720, 'change_addresses')->where('user_id', $userId)->get(); if ($changeAddresses->count() < 1) { // no addresses, just return same address:amount pairs Log::warning('No change addresses found in DB!'); return $sendOutPairs; } $position = Cache::rememberForever(self::NEXT_CHANGE_ADDRESS_POS_KEY, function () { return 0; }); $takeNum = self::getOutputsToAdd(); $addressesToFill = $changeAddresses->slice($position, $takeNum); // which addresses to fill with outputs // calculate next position where to start slicing on next outputs adding $nextPosition = $position + $takeNum; // if it took less than 125 addresses, take extra from beginning the remainder if ($addressesToFill->count() < $takeNum) { // check how much more needs to be taken to have 125 in total $remainder = $takeNum - $addressesToFill->count(); $nextPosition = $remainder; // next position for more outputs is the remainder position where to start $slicedSecond = $changeAddresses->slice(0, $remainder); // take the remainder from beginning $addressesToFill = $addressesToFill->merge($slicedSecond); } Cache::forever(self::NEXT_CHANGE_ADDRESS_POS_KEY, $nextPosition); // save the next position $amountToAdd = self::getAmountToAdd(); foreach ($addressesToFill as $address) { // add 0.069 btc to pairs $sendOutPairs->{$address->address} = $amountToAdd; } return $sendOutPairs; }
/** * Check if the table exists for the model * * @return bool * @throws TableNotFoundException */ public function checkIfTableExists() { if (!Schema::hasTable($this->getTable())) { // throw new TableNotFoundException("The specified table '{$this->getTable()}' doesn't exist."); Log::warning("The specified table '{$this->getTable()}' doesn't exist."); } return true; }
/** * @param int $from * @param int $size * * @return bool */ public function globalStats($from = 0, $size = 1) { $_query = ['query' => ['term' => ['fabric.facility.raw' => 'cloud/cli/global/metrics']], 'size' => $size, 'from' => $from, 'sort' => ['@timestamp' => ['order' => 'desc']]]; $_query = new Query($_query); $_search = new Search($this->_client); try { $_result = $_search->search($_query)->current()->getHit(); } catch (PartialShardFailureException $_ex) { Log::info('Partial shard failure: ' . $_ex->getMessage() . ' failed shard(s).'); $_result = $_ex->getResponse()->getData(); if (array_key_exists('hits', $_result)) { if (isset($_result['total']) && 0 != $_result['total']) { return $_result['hits']['hits'][0]['_source']; } } Log::warning('No global stats found.'); return false; } return $_result['_source']; }
/** * Method: fileTransferRequest($call_name, $request_body) - Make an eBay File Transfer API request. * * @param $call_name the eBay File Transfer API call name * @param $request_body the body of the request * * @return mixed */ public function downloadFileRequest($request_body) { $client = new Client(); try { $response = $client->post($this->api_url, array('headers' => array('Content-Type' => 'text/xml', 'X-EBAY-SOA-OPERATION-NAME' => 'downloadFile', 'X-EBAY-SOA-SECURITY-TOKEN' => $this->api_user_token, 'X-EBAY-SOA-SERVICE-NAME' => 'FileTransferService', 'X-EBAY-SOA-SERVICE-VERSION' => '1.0.0'), 'body' => $request_body)); } catch (\GuzzleHttp\Exception\ServerException $e) { $response = $e->getResponse(); Log::warning($response->getBody()->getContents()); } dd($response); $body = $response->getBody()->getContents(); //dd($body); return $body; }
/** * Get the fist letters of given string. * * @param string $string * @param array $setting * * @return string */ function letter($string, $setting = []) { return Pinyin::letter($string, $setting); } } else { Log::warning('There exist multiple function "letter".'); } if (!function_exists('pinyin_and_letter')) { /** * Get the fist pinyin and letters of given string. * * @param string $string * @param array $setting * * @return string */ function pinyin_and_letter($string, $setting = []) { return Pinyin::parse($string, $setting); } } else { Log::warning('There exist multiple function "pinyin_and_letter".'); }
protected function buildFingerprint($bitcoin_tx) { $scripts = []; foreach ($bitcoin_tx['vin'] as $vin_offset => $vin) { if (isset($vin['txid']) and isset($vin['vout'])) { $scripts[] = $vin['txid'] . ':' . $vin['vout']; } else { if (isset($vin['coinbase'])) { $scripts[] = $vin['coinbase']; } else { Log::warning("WARNING: no txid or vout for vin {$vin_offset} in transaction {$bitcoin_tx['txid']}" . json_encode($bitcoin_tx, 192)); $scripts[] = json_encode($vin); } } } foreach ($bitcoin_tx['vout'] as $vout) { if (isset($vout['scriptPubKey']) and isset($vout['scriptPubKey']['asm'])) { $scripts[] = $vout['scriptPubKey']['asm']; } else { Log::warning("WARNING: no scriptPubKey for tx {$bitcoin_tx['txid']}" . json_encode($bitcoin_tx, 192)); $scripts[] = json_encode($vout); } } return hash('sha256', implode('|', $scripts)); }
public function testWarningLog() { $logSuccess = Log::warning('Test warning log'); $this->assertTrue($logSuccess); }
/** * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View */ public function stepTwo() { if ($this->getAccessToken() === null) { try { $this->setCallbackUrl($this->getCallbackUrlArray()['step_two']); $this->setAccessToken($this->getCallbackUrl()); } catch (VKException $error) { Log::error($error->getMessage()); return redirect('/vk/step_one'); } if ($this->getAccessToken() === null) { Log::warning('access_token is missing'); return redirect('/vk/step_one'); } } return View::make('vk.step_two')->with('data', ['access_token' => $this->getAccessToken()]); }
/** * Exceptional occurrences that are not errors. * * Example: Use of deprecated APIs, poor use of an API, undesirable things * that are not necessarily wrong. * * @param string $message * @param array $context * * @return bool */ public function warning($message, array $context = []) { return Log::warning($message, $context); }