/** * {@inheritDoc} * * @param Capture $request */ public function execute($request) { /** @var $request Capture */ RequestNotSupportedException::assertSupports($this, $request); $model = ArrayObject::ensureArrayObject($request->getModel()); $this->gateway->execute($httpRequest = new GetHttpRequest()); $response = ArrayObject::ensureArrayObject($httpRequest->request); if (isset($httpRequest->query['cancelled'])) { $newResponse['CANCELLED'] = true; $model->replace($newResponse); return; } if ($response['txn_id'] != null) { $response->validateNotEmpty(['payment_status', 'business', 'invoice', 'txn_id', 'mc_gross']); $this->gateway->execute(new Sync($response)); $model->replace($response); } else { if ($model['cancel_return']) { $cancelUri = HttpUri::createFromString($model['cancel_return']); $modifier = new MergeQuery('cancelled=1'); $cancelUri = $modifier($cancelUri); $model['cancel_return'] = (string) $cancelUri; } $this->gateway->execute(new CreateButtonPayment($model)); } }
/** * @Route("/session/origins", name="oidc_get_origins") * @Method({"GET"}) * @Template */ public function getOriginsAction(Request $request) { $client = $this->getClient($request->get('client_id')); $uris = array(); $uris[] = $client->getSiteUrl(); $uris[] = $client->getTermsOfUseUrl(); $uris[] = $client->getLandingPageUrl(); if ($client->getMetadata()) { $meta = $client->getMetadata(); $uris[] = $meta->getClientUri(); $uris[] = $meta->getInitiateLoginUri(); $uris[] = $meta->getPolicyUri(); $uris[] = $meta->getSectorIdentifierUri(); $uris[] = $meta->getTosUri(); $uris = array_merge($uris, $meta->getRedirectUris(), $meta->getRequestUris()); } $result = array_unique(array_map(function ($value) { if ($value === null) { return; } $uri = HttpUri::createFromString($value)->withFragment('')->withPath('')->withQuery('')->withUserInfo(''); return $uri->__toString(); }, array_filter($uris))); return new JsonResponse(array_values($result)); }
public function create(string $uri, array $query) { $query = Query::createFromPairs($query); $uri = Http::createFromString($uri); $modifier = new MergeQuery($query->__toString()); return (string) $modifier->__invoke($uri); }
/** * {@inheritDoc} */ public function createToken($gatewayName, $model, $targetPath, array $targetParameters = [], $afterPath = null, array $afterParameters = []) { /** @var TokenInterface $token */ $token = $this->tokenStorage->create(); $token->setHash($token->getHash() ?: Random::generateToken()); $targetParameters = array_replace(['payum_token' => $token->getHash()], $targetParameters); $token->setGatewayName($gatewayName); if ($model instanceof IdentityInterface) { $token->setDetails($model); } elseif (null !== $model) { $token->setDetails($this->storageRegistry->getStorage($model)->identify($model)); } if (0 === strpos($targetPath, 'http')) { $targetUri = HttpUri::createFromString($targetPath); $targetUri = $this->addQueryToUri($targetUri, $targetParameters); $token->setTargetUrl((string) $targetUri); } else { $token->setTargetUrl($this->generateUrl($targetPath, $targetParameters)); } if ($afterPath && 0 === strpos($afterPath, 'http')) { $afterUri = HttpUri::createFromString($afterPath); $afterUri = $this->addQueryToUri($afterUri, $afterParameters); $token->setAfterUrl((string) $afterUri); } elseif ($afterPath) { $token->setAfterUrl($this->generateUrl($afterPath, $afterParameters)); } $this->tokenStorage->update($token); return $token; }
public function testDateSetter() { $url = new LinkedEntity(); $url->id = 2; $url->link = Uri\Schemes\Http::createFromString("http://github.com/kayladnls?q=is%3Aopen+is%3Apr+author%3Akayladnls"); $this->em->persist($url); $this->em->flush(); }
public function getAuthenticatedRequest($method, $url, $token, array $options = []) { $baseUri = HttpUri::createFromString($this->urlApiDomain); $relativeUri = HttpUri::createFromString($url); $modifier = new Resolve($baseUri); $newUri = $modifier->__invoke($relativeUri); return parent::getAuthenticatedRequest($method, $newUri, $token, $options); }
/** * Format an URL to be fully-qualified * * @param string $value * @return string **/ public function format($value) { if (!$this->validate($value)) { throw new \InvalidArgumentException("`{$value}` is not a valid HTTP URI"); } $url = Http::createFromString($value); if ($url->getScheme() == '') { $url = $url->withScheme('http'); } return (string) $url; }
public function fetch($url) { $url = Http::createFromString($url); if (!$this->parser instanceof ParserInterface) { throw new \Exception('Must be a Parse Interface object.'); } if ($this->parser->checkUrl($url)) { $document = $this->getUrl($url); return $document; } }
/** * {@inheritDoc} */ public function execute($request) { /** @var $request Capture */ RequestNotSupportedException::assertSupports($this, $request); $details = ArrayObject::ensureArrayObject($request->getModel()); $details->validateNotEmpty('PAYMENTREQUEST_0_PAYMENTACTION'); $details->defaults(array('AUTHORIZE_TOKEN_USERACTION' => Api::USERACTION_COMMIT)); $this->gateway->execute($httpRequest = new GetHttpRequest()); if (isset($httpRequest->query['cancelled'])) { $details['CANCELLED'] = true; return; } if (false == $details['TOKEN']) { if (false == $details['RETURNURL'] && $request->getToken()) { $details['RETURNURL'] = $request->getToken()->getTargetUrl(); } if (false == $details['CANCELURL'] && $request->getToken()) { $details['CANCELURL'] = $request->getToken()->getTargetUrl(); } if (empty($details['PAYMENTREQUEST_0_NOTIFYURL']) && $request->getToken() && $this->tokenFactory) { $notifyToken = $this->tokenFactory->createNotifyToken($request->getToken()->getGatewayName(), $request->getToken()->getDetails()); $details['PAYMENTREQUEST_0_NOTIFYURL'] = $notifyToken->getTargetUrl(); } if ($details['CANCELURL']) { $cancelUri = HttpUri::createFromString($details['CANCELURL']); $modifier = new MergeQuery('cancelled=1'); $cancelUri = $modifier($cancelUri); $details['CANCELURL'] = (string) $cancelUri; } $this->gateway->execute(new SetExpressCheckout($details)); if ($details['L_ERRORCODE0']) { return; } } $this->gateway->execute(new Sync($details)); if ($details['PAYERID'] && Api::CHECKOUTSTATUS_PAYMENT_ACTION_NOT_INITIATED == $details['CHECKOUTSTATUS'] && $details['PAYMENTREQUEST_0_AMT'] > 0) { if (Api::USERACTION_COMMIT !== $details['AUTHORIZE_TOKEN_USERACTION']) { $confirmOrder = new ConfirmOrder($request->getFirstModel()); $confirmOrder->setModel($request->getModel()); $this->gateway->execute($confirmOrder); } $this->gateway->execute(new DoExpressCheckoutPayment($details)); } if (false == $details['PAYERID']) { $this->gateway->execute(new AuthorizeToken($details)); } $this->gateway->execute(new Sync($details)); }
protected function applyFormatParameterToUrls(array $data) { return array_map(function ($value) { if (is_array($value)) { return $this->applyFormatParameterToUrls($value); } $pattern = sprintf('/%s.+/', preg_quote(url(config('transfugio.rootURL')), '/')); $format = config('transfugio.http.format'); if (is_string($value) && preg_match($pattern, $value) && $format !== 'json_accept') { $url = Http::createFromString($value); //Url::createFromUrl($value); $modifiedQuery = new Query($url->getQuery()); $modifiedQuery = $modifiedQuery->merge("format={$format}"); $value = strval($url->withQuery($modifiedQuery->__toString())); } return $value; }, $data); }
/** * @param string $method * @param string $url * @param array $params * * @throws SocketException */ private function fire($method, $url, $params) { try { $url = HttpUri::createFromString($url); } catch (RuntimeException $e) { throw new InvalidUrlException($e->getMessage(), $url); } $scheme = $url->getScheme() === 'https' ? 'ssl://' : ''; $host = $scheme . $url->getHost(); $port = $url->getPort() ?: $this->getDefaultPort($url->getScheme()); $request = $this->getRequest($method, $url, $params); $socket = @fsockopen($host, $port, $errno, $errstr, $this->connectionTimeout); if (!$socket) { throw new SocketException($errstr, $errno); } fwrite($socket, $request); fclose($socket); }
/** * {@inheritDoc} * * @param Capture $request */ public function execute($request) { RequestNotSupportedException::assertSupports($this, $request); $this->gateway->execute($httpRequest = new GetHttpRequest()); //we are back from be2bill site so we have to just update model. if (empty($httpRequest->query['EXTRADATA'])) { throw new HttpResponse('The capture is invalid. Code Be2Bell1', 400); } $extraDataJson = $httpRequest->query['EXTRADATA']; if (false == ($extraData = json_decode($extraDataJson, true))) { throw new HttpResponse('The capture is invalid. Code Be2Bell2', 400); } if (empty($extraData['capture_token'])) { throw new HttpResponse('The capture is invalid. Code Be2Bell3', 400); } $this->gateway->execute($getToken = new GetToken($extraData['capture_token'])); $uri = HttpUri::createFromString($getToken->getToken()->getTargetUrl()); $uri = $uri->withQuery((string) Query::createFromArray($httpRequest->query)); throw new HttpRedirect((string) $uri); }
public function validate($value, Constraint $constraint) { if (!$value instanceof ClientMetadata) { $this->context->buildViolation('Invalid class')->addViolation(); return; } $redirectUris = $this->parseUris($value->getRedirectUris()); if ($value->getSectorIdentifierUri() !== null) { $sectorIdentifier = HttpUri::createFromString(); } else { $sectorIdentifier = null; } $hosts = array(); foreach ($redirectUris as $uri) { @($hosts[$uri->getHost()] += 1); } if (!$sectorIdentifier instanceof HttpUri && count($hosts) > 1) { $message = 'sector_identifier_uri is required when multiple hosts are used in redirect_uris. (#rfc.section.8.1)'; $this->context->buildViolation($message)->atPath('sector_identifier_uri')->setParameter('value', $message)->addViolation(); } }
/** * Sanitizes URLS by removing things and adding other things. * @param [type] $url The URL to sanitize. * @return [type] The sanitized URL. */ function sanitizeURL($url) { $rulesetMinus = array('imdb.com' => ['ref_', 'pf_rd_m', 'pf_rd_s', 'pf_rd_p', 'pf_rd_r', 'pf_rd_t', 'pf_rd_i'], 'amazon.com' => ['ref_', 'pf_rd_m', 'pf_rd_s', 'pf_rd_p', 'pf_rd_r', 'pf_rd_t', 'pf_rd_i', 'qid', 'psc', 'keywords', 'sr', 'ref', 'refRID', 'btkr', 'ie', 'camp', 'creative', 'creativeASIN', 'linkCode', 'tag', 'linkID', 'redirect'], 'amazon.co.uk' => ['ref_', 'pf_rd_m', 'pf_rd_s', 'pf_rd_p', 'pf_rd_r', 'pf_rd_t', 'pf_rd_i', 'qid', 'psc', 'keywords', 'sr', 'ref', 'refRID', 'btkr', 'ie', 'camp', 'creative', 'creativeASIN', 'linkCode', 'tag', 'linkID', 'redirect']); $rulesetPlus = array('amazon.com' => ['tag=csicon-20'], 'amazon.co.uk' => ['tag=csicon-21']); $uri = HttpUri::createFromString($url); $domain = $uri->host->getRegisterableDomain(); if (array_key_exists($domain, $rulesetMinus)) { $uri = HttpUri::createFromString($url); $modifier = new removeQueryKeys($rulesetMinus[$domain]); $url = $modifier->__invoke($uri); } if (array_key_exists($domain, $rulesetPlus)) { foreach ($rulesetPlus[$domain] as $key) { $uri = HttpUri::createFromString($url); $modifier = new MergeQuery(strval($key)); $url = $modifier->__invoke($uri); } } return $url; }
/** * The noscheme modifier function * @param string $string URL to parse * @return string URL without scheme */ function Smarty_Modifier_noscheme($string) { $uri = HttpUri::createFromString($string); return (string) $uri->withScheme(''); }
public function getSectorIdentifier() { $siUri = $this->getSectorIdentifierUri(); if ($siUri) { $uri = $siUri; } else { $uris = $this->getRedirectUris(); $uri = reset($uris); } return HttpUri::createFromString($uri)->getHost(); }
public function createUriObject($url = '') { return Http::createFromString($url); }
/** * @return Http */ public function url() : Http { return Http::createFromString(route('offers.view', [$this->id, $this->slug()])); }
/** * {@inheritdoc} */ public function convertToPHPValue($value, AbstractPlatform $platform) { return Uri\Schemes\Http::createFromString($value); }
/** * @param $url * @param $params * @return string */ protected function buildUrl($url, $params) { return HttpUri::createFromString($url)->withQuery(http_build_query($params))->__toString(); }
$_GET['url'] = substr($_GET['url'], 2); } else { $_GET['url'] = substr($_GET['url'], 1); } } elseif (substr($_GET['url'], 0, 25) == 'www.mallublog.vt.vc/goto/') { header('X-Notice: Known redirect host, autofix'); //trigger_error('URL redirects, autofix. URL: '.$_GET['url'],E_USER_NOTICE); $_GET['url'] = substr($_GET['url'], 25); } try { if (substr($_GET['url'], 0, 4) == 'ssl:') { $_GET['url'] = substr($_GET['url'], 4); $uri = HttpUri::createFromString('https://' . $_GET['url']); } else { if (!substr($_GET['url'], 0, 5) == 'http:' && !substr($_GET['url'], 0, 6) == 'https:') { $uri = HttpUri::createFromString('http://' . $_GET['url']); } else { throw new RuntimeException('Invalid URL'); } } } catch (RuntimeException $e) { header('HTTP/1.0 404 Not Found'); header('Content-type: text/plain'); echo 'Error 404: Server could not parse the ?url= that you were looking for, because it isn\'t a valid url.'; trigger_error('URL failed, unable to parse. URL: ' . $_GET['url'], E_USER_WARNING); die; } // Create an image manager instance with favored driver (gd by default) $imageManager = new Intervention\Image\ImageManager(['driver' => 'imagick']); // Create an PHP HTTP client $client = new AndriesLouw\imagesweserv\Client(tempnam('/dev/shm', 'imo_'), ['user_agent' => 'Mozilla/5.0 (compatible; ImageFetcher/6.0; +http://images.weserv.nl/)', 'connect_timeout' => 5, 'timeout' => 10, 'max_image_size' => 0, 'max_redirects' => 10, 'allowed_mime_types' => []]);
/** * @throws \RuntimeException * * @return Http */ public function url() : Http { return Http::createFromString(route('category.view', [$this->publicId(), $this->slug()])); }
/** * @param $url * @param array $params * @return string * @throws \RuntimeException * @throws \InvalidArgumentException * @throws InvalidConfigException */ public function signUrl($url, array $params = []) { $uri = Http::createFromString($url); $paramsQuery = Query::createFromArray($params); $path = $uri->getPath(); $query = $uri->query->merge($paramsQuery); $signature = $this->getHttpSignature()->generateSignature($path, $query->toArray()); $query = $query->merge(Query::createFromArray(['s' => $signature])); $uri = $uri->withQuery((string) $query); return (string) $uri; }
/** * @param StorageInterface $tokenStorage * @param StorageRegistryInterface $storageRegistry * @param string $baseUrl */ public function __construct(StorageInterface $tokenStorage, StorageRegistryInterface $storageRegistry, $baseUrl = null) { parent::__construct($tokenStorage, $storageRegistry); $this->baseUrl = $baseUrl ? HttpUri::createFromString($baseUrl) : HttpUri::createFromServer($_SERVER); }
private function getHost($uri) { return HttpUri::createFromString($uri)->getHost(); }
public function callAction(Element $element) { $url = Uri::createFromString($element->getAttribute('href')); $action = new Action($this, $url, $element); $params = explode(':', urldecode($url->getFragment())); array_shift($params); // slice away the needle $actionName = array_shift($params); $action->setParameters($params); $actions = $this->getLinkActions(); if (array_key_exists($actionName, $actions)) { $config = $actions[$actionName]; if (is_string($config)) { $config = ['call' => $config]; } $action->setConfig($config); $action->call(); } }