phpuri 추가. root, shredIcon, gameIage 경로 계산 코드를 추가

This commit is contained in:
2018-04-08 18:38:01 +09:00
parent 9108ce3f19
commit f060716a3c
17 changed files with 438 additions and 42 deletions
+1
View File
@@ -9,5 +9,6 @@ return array(
'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
'5b154887902198b16314243c6e0e3e19' => $vendorDir . '/pguardiario/phpuri/phpuri.php',
'870dc64919afa8b0f700701bb2c6a783' => $baseDir . '/f_config/config.php',
);
+1
View File
@@ -10,6 +10,7 @@ class ComposerStaticInit67b09c83b85c3bc0027caefe5bba171a
'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
'5b154887902198b16314243c6e0e3e19' => __DIR__ . '/..' . '/pguardiario/phpuri/phpuri.php',
'870dc64919afa8b0f700701bb2c6a783' => __DIR__ . '/../..' . '/f_config/config.php',
);
+26
View File
@@ -463,6 +463,32 @@
"psr-3"
]
},
{
"name": "pguardiario/phpuri",
"version": "1.0",
"version_normalized": "1.0.0.0",
"source": {
"type": "git",
"url": "https://github.com/monkeysuffrage/phpuri.git",
"reference": "ad0a5ec033fe616cfef55578b9c7f2458be8fbfc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/monkeysuffrage/phpuri/zipball/ad0a5ec033fe616cfef55578b9c7f2458be8fbfc",
"reference": "ad0a5ec033fe616cfef55578b9c7f2458be8fbfc",
"shasum": ""
},
"time": "2015-05-24T09:13:17+00:00",
"type": "project",
"installation-source": "dist",
"autoload": {
"files": [
"phpuri.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"description": "A php library for converting relative urls to absolute."
},
{
"name": "php-extended/php-system",
"version": "1.3.0",
+18
View File
@@ -0,0 +1,18 @@
Phpuri
=========
A php library for converting relative urls to absolute.
```php
require 'phpuri.php';
echo phpUri::parse('https://www.google.com/')->join('foo');
//==> https://www.google.com/foo
```
### Benchmark
<pre>
php test.php
rel2abs: successes -> 26, failures => 9, elapsed time: 0.001301
url_to_absolute: successes -> 32, failures => 3, elapsed time: 0.0029089999999999
phpuri: successes -> 35, failures => 0, elapsed time: 0.002402
</pre>
+11
View File
@@ -0,0 +1,11 @@
{
"name": "pguardiario/phpuri",
"type": "project",
"version": "1.0",
"description": "A php library for converting relative urls to absolute.",
"autoload" : {
"files": [
"phpuri.php"
]
}
}
+197
View File
@@ -0,0 +1,197 @@
<?php
/**
* A php library for converting relative urls to absolute.
* Website: https://github.com/monkeysuffrage/phpuri
*
* <pre>
* echo phpUri::parse('https://www.google.com/')->join('foo');
* //==> https://www.google.com/foo
* </pre>
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @author P Guardiario <pguardiario@gmail.com>
* @version 1.0
*/
/**
* phpUri
*/
class phpUri
{
/**
* http(s)://
* @var string
*/
public $scheme;
/**
* www.example.com
* @var string
*/
public $authority;
/**
* /search
* @var string
*/
public $path;
/**
* ?q=foo
* @var string
*/
public $query;
/**
* #bar
* @var string
*/
public $fragment;
private function __construct( $string )
{
preg_match_all( '/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/', $string, $m );
$this->scheme = $m[ 2 ][ 0 ];
$this->authority = $m[ 4 ][ 0 ];
/**
* CHANGE:
* @author Dominik Habichtsberg <Dominik.Habichtsberg@Hbg-IT.de>
* @since 24 Mai 2015 10:02 Uhr
*
* Former code: $this->path = ( empty( $m[ 5 ][ 0 ] ) ) ? '/' : $m[ 5 ][ 0 ];
* No tests failed, when the path is empty.
* With the former code, the relative urls //g and #s failed
*/
$this->path = $m[ 5 ][ 0 ];
$this->query = $m[ 7 ][ 0 ];
$this->fragment = $m[ 9 ][ 0 ];
}
private function to_str()
{
$ret = '';
if ( !empty( $this->scheme ) )
{
$ret .= "{$this->scheme}:";
}
if ( !empty( $this->authority ) )
{
$ret .= "//{$this->authority}";
}
$ret .= $this->normalize_path( $this->path );
if ( !empty( $this->query ) )
{
$ret .= "?{$this->query}";
}
if ( !empty( $this->fragment ) )
{
$ret .= "#{$this->fragment}";
}
return $ret;
}
private function normalize_path( $path )
{
if ( empty( $path ) )
{
return '';
}
$normalized_path = $path;
$normalized_path = preg_replace( '`//+`', '/', $normalized_path, -1, $c0 );
$normalized_path = preg_replace( '`^/\\.\\.?/`', '/', $normalized_path, -1, $c1 );
$normalized_path = preg_replace( '`/\\.(/|$)`', '/', $normalized_path, -1, $c2 );
/**
* CHANGE:
* @author Dominik Habichtsberg <Dominik.Habichtsberg@Hbg-IT.de>
* @since 24 Mai 2015 10:05 Uhr
* changed limit form -1 to 1, because climbing up the directory-tree failed
*/
$normalized_path = preg_replace( '`/[^/]*?/\\.\\.(/|$)`', '/', $normalized_path, 1, $c3 );
$num_matches = $c0 + $c1 + $c2 + $c3;
return ( $num_matches > 0 ) ? $this->normalize_path( $normalized_path ) : $normalized_path;
}
/**
* Parse an url string
*
* @param string $url the url to parse
*
* @return phpUri
*/
public static function parse( $url )
{
$uri = new phpUri( $url );
return $uri;
}
/**
* Join with a relative url
*
* @param string $relative the relative url to join
*
* @return string
*/
public function join( $relative )
{
$uri = new phpUri( $relative );
switch ( TRUE )
{
case !empty( $uri->scheme ):
break;
case !empty( $uri->authority ):
break;
case empty( $uri->path ):
$uri->path = $this->path;
if ( empty( $uri->query ) )
{
$uri->query = $this->query;
}
break;
case strpos( $uri->path, '/' ) === 0:
break;
default:
$base_path = $this->path;
if ( strpos( $base_path, '/' ) === FALSE )
{
$base_path = '';
}
else
{
$base_path = preg_replace( '/\/[^\/]+$/', '/', $base_path );
}
if ( empty( $base_path ) && empty( $this->authority ) )
{
$base_path = '/';
}
$uri->path = $base_path . $uri->path;
}
if ( empty( $uri->scheme ) )
{
$uri->scheme = $this->scheme;
if ( empty( $uri->authority ) )
{
$uri->authority = $this->authority;
}
}
return $uri->to_str();
}
}