/**
  * Overridden to allow paths be passed in and out
  * @param $url
  * @return null|string
  */
 protected static function sanitizeUrl($url)
 {
     if (strpos($url, '/') === 0) {
         return $url;
     }
     return parent::sanitizeUrl($url);
 }
 /**
  * @param $url
  * @param int $nbPages
  */
 public function __construct($url, $nbPages = 1)
 {
     if (!preg_match('/^.*leboncoin.fr/', $url)) {
         $url = preg_replace('/^[\\/]?/', $this->baseUrl, $url);
     }
     $this->url = Url::createFromUrl($url);
     $this->nbPages = $nbPages;
 }
 public function testSameValueAs()
 {
     $url1 = Url::createFromUrl('example.com');
     $url2 = UrlImmutable::createFromUrl('//example.com');
     $url3 = UrlImmutable::createFromUrl('//example.com?foo=toto+le+heros');
     $this->assertTrue($url1->sameValueAs($url2));
     $this->assertFalse($url3->sameValueAs($url2));
 }
Beispiel #4
0
 public function testCreateFromServer()
 {
     $server = array('PHP_SELF' => '', 'REQUEST_URI' => '', 'SERVER_ADDR' => '127.0.0.1', 'HTTPS' => 'on', 'SERVER_PROTOCOL' => 'HTTP', 'SERVER_PORT' => 23, 'HTTP_HOST' => 'example.com');
     $url = UrlImmutable::createFromServer($server);
     $this->assertInstanceof('\\League\\Url\\UrlImmutable', $url);
     $this->assertSame('https://example.com:23/', $url->__toString());
     $server = array('PHP_SELF' => '', 'REQUEST_URI' => '', 'SERVER_ADDR' => '127.0.0.1', 'HTTPS' => 'on', 'SERVER_PROTOCOL' => 'HTTP', 'SERVER_PORT' => 23);
     $url = Url::createFromServer($server);
     $this->assertInstanceof('\\League\\Url\\Url', $url);
     $this->assertSame('https://127.0.0.1:23/', $url->__toString());
 }
Beispiel #5
0
 public function __construct()
 {
     if (self::$url === null) {
         self::$url = UrlImmutable::createFromServer($_SERVER);
     }
 }
Beispiel #6
0
 /**
  * Try to create directory.
  *
  * @param \League\Url\UrlImmutable $url
  * @return boolean
  */
 private function createDirectory($url)
 {
     $path = $url->getPath();
     $pathArray = $path->toArray();
     $this->log(\Psr\Log\LogLevel::DEBUG, "Ensure directory exists", ['url' => $url]);
     array_pop($pathArray);
     $url = $url->setPath(new \League\Url\Components\Path($pathArray));
     $result = true;
     if (!file_exists((string) $url)) {
         $this->log(\Psr\Log\LogLevel::DEBUG, "Attempt directory creation", ['path' => (string) $url]);
         $result = @mkdir((string) $url, 0777, true);
         $this->log(\Psr\Log\LogLevel::DEBUG, $result ? "Created directory" : "Failed to create directory", ['path' => (string) $url]);
     }
     return $result;
 }
Beispiel #7
0
 /**
  * Determine if the url has a forged signature.
  *
  * @param \League\Url\UrlImmutable $url
  *
  * @return bool
  */
 protected function hasValidSignature(UrlImmutable $url)
 {
     $query = $url->getQuery();
     $expiration = $query[$this->expiresParameter];
     $providedSignature = $query[$this->signatureParameter];
     $intendedUrl = $this->getIntendedUrl($url);
     $validSignature = $this->createSignature($intendedUrl, $expiration);
     return $providedSignature === $validSignature;
 }
 public function setUp()
 {
     $this->url = UrlImmutable::createFromUrl('https://*****:*****@secure.example.com:443/test/query.php?kingkong=toto#doc3');
 }