Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 /**
  * {@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);
     }
 }
Ejemplo n.º 3
0
 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.');
     }
 }
Ejemplo n.º 4
0
 /**
  * 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;
 }
Ejemplo n.º 5
0
 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();
     }
 }
Ejemplo n.º 6
0
 /**
  * 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);
 }
Ejemplo n.º 7
0
 /**
  * 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');
 }
Ejemplo n.º 8
0
Archivo: Test.php Proyecto: DJZT/tezter
 public function completed()
 {
     if (count($this->answered()) == count($this->answers)) {
         $this->completed = true;
     } else {
         Log::warning('Попытка завершить тест при не всех отвеченных вопросах');
     }
     return $this;
 }
Ejemplo n.º 9
0
 /**
  * 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 [];
     }
 }
Ejemplo n.º 10
0
 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;
     }
 }
Ejemplo n.º 11
0
 /**
  * @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';
     }
 }
Ejemplo n.º 12
0
 /**
  * @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';
     }
 }
Ejemplo n.º 13
0
 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;
 }
Ejemplo n.º 14
0
 /**
  * 写入一行数据到目标资源
  *
  * @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));
     }
 }
Ejemplo n.º 15
0
 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');
     }
 }
Ejemplo n.º 16
0
 /**
  * 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');
     }
 }
Ejemplo n.º 17
0
 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;
     }
 }
Ejemplo n.º 20
0
 /**
  * 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);
 }
Ejemplo n.º 21
0
 /**
  * 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;
 }
Ejemplo n.º 23
0
 /**
  * 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;
 }
Ejemplo n.º 24
0
 /**
  * @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'];
 }
Ejemplo n.º 25
0
 /**
  * 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;
 }
Ejemplo n.º 26
0
    /**
     * 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));
 }
Ejemplo n.º 28
0
 public function testWarningLog()
 {
     $logSuccess = Log::warning('Test warning log');
     $this->assertTrue($logSuccess);
 }
Ejemplo n.º 29
0
 /**
  * @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()]);
 }
Ejemplo n.º 30
0
 /**
  * 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);
 }