Version 4.1.2
This commit is contained in:
1 parent
3ba79295ee
commit
28bd025b35
1131 files changed
+63658
-20579
No files matched your search
+58
-18
@@ -247,7 +247,10 @@ class _Url
|
||||
{
|
||||
/* Always lowercase */
|
||||
$value = mb_strtolower( $value );
|
||||
|
||||
|
||||
/* Get rid of newlines/carriage returns as they're not cool in friendly URL titles */
|
||||
$value = str_replace( array( "\r\n", "\r", "\n" ), ' ', $value );
|
||||
|
||||
/* Just for readability */
|
||||
$value = str_replace( ' ', '-', $value );
|
||||
|
||||
@@ -358,7 +361,7 @@ class _Url
|
||||
$keys = array( $keys => $keys );
|
||||
}
|
||||
|
||||
$queryString = array_diff_key( $this->queryString, $keys );
|
||||
$queryString = array_diff_key( $this->queryString, array_combine( array_values( $keys ), array_values( $keys ) ) );
|
||||
}
|
||||
|
||||
return $this->reconstruct( $this->data, $queryString );
|
||||
@@ -494,7 +497,7 @@ class _Url
|
||||
/* Is it internal? We have to ignore protocol because areas like force login over https and secure checkout in Nexus will use https urls for an otherwise http site and we end up with infinite redirects */
|
||||
if ( $internal === NULL )
|
||||
{
|
||||
$this->isInternal = ( mb_substr( str_replace( 'https://', 'http://', $this->url ), 0, mb_strlen( str_replace( 'https://', 'http://', \IPS\Settings::i()->base_url ) ) ) === str_replace( 'https://', 'http://', \IPS\Settings::i()->base_url ) );
|
||||
$this->isInternal = ( mb_substr( str_replace( array( 'https://', 'http://' ), '//', $this->url ), 0, mb_strlen( str_replace( array( 'https://', 'http://' ), '//', \IPS\Settings::i()->base_url ) ) ) === str_replace( array( 'https://', 'http://' ), '//', \IPS\Settings::i()->base_url ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -642,17 +645,16 @@ class _Url
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the query/path
|
||||
* Get FURL query
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function queryPath()
|
||||
public function getFurlQuery()
|
||||
{
|
||||
/* Determine our gateway */
|
||||
$gatewayFile = explode( '/', str_replace( '\\', '/', $_SERVER['SCRIPT_FILENAME'] ) );
|
||||
$gatewayFile = array_pop( $gatewayFile );
|
||||
|
||||
/* Work out what the FURL "query" is */
|
||||
|
||||
$baseUrl = $this->utf8ParseUrl( \IPS\Settings::i()->base_url );
|
||||
|
||||
if ( \IPS\Settings::i()->htaccess_mod_rewrite )
|
||||
@@ -681,9 +683,7 @@ class _Url
|
||||
}
|
||||
}
|
||||
|
||||
$query = preg_replace( '#^(' . preg_quote( rtrim( $baseUrl['path'], '/' ), '#' ) . ')/(' . $gatewayFile . ')?(?:(?:\?/|\?))?(.+?)?$#', '$3', $query );
|
||||
|
||||
return $query;
|
||||
return preg_replace( '#^(' . preg_quote( rtrim( $baseUrl['path'], '/' ), '#' ) . ')/(' . $gatewayFile . ')?(?:(?:\?/|\?))?(.+?)?$#', '$3', $query );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -704,8 +704,8 @@ class _Url
|
||||
/* Get furl definition */
|
||||
$furlDefinition = static::furlDefinition();
|
||||
|
||||
/* What is the query */
|
||||
$query = $this->queryPath();
|
||||
/* Work out what the FURL "query" is */
|
||||
$query = $this->getFurlQuery();
|
||||
|
||||
/* Examine our URLs */
|
||||
$this->examineFurl( $furlDefinition, $query, $set, $usedTemplate );
|
||||
@@ -777,7 +777,23 @@ class _Url
|
||||
{
|
||||
try
|
||||
{
|
||||
$correctUrl = $usedTemplate['verify']::loadFromUrl( \IPS\Http\Url::internal( $usedTemplate['_rebuiltUrl'], 'front' ) )->url();
|
||||
$contentObject = $usedTemplate['verify']::loadFromUrl( \IPS\Http\Url::internal( $usedTemplate['_rebuiltUrl'], 'front' ) );
|
||||
|
||||
if( method_exists( $contentObject, 'canView' ) )
|
||||
{
|
||||
if( $contentObject->canView() )
|
||||
{
|
||||
$correctUrl = $contentObject->url();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$correctUrl = $contentObject->url();
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
@@ -848,8 +864,24 @@ class _Url
|
||||
{
|
||||
parse_str( $data['real'], $paramsInCorrectUrl );
|
||||
$paramsInCorrectUrl = array_merge( array_keys( $paramsInCorrectUrl ), $params );
|
||||
|
||||
$correctUrl = $data['verify']::loadFromUrl( \IPS\Http\Url::internal( $requestedUrl->data['query'], 'front' ) )->url();
|
||||
|
||||
$contentObject = $data['verify']::loadFromUrl( \IPS\Http\Url::internal( $requestedUrl->data['query'], 'front' ) );
|
||||
|
||||
if( method_exists( $contentObject, 'canView' ) )
|
||||
{
|
||||
if( $contentObject->canView() )
|
||||
{
|
||||
$correctUrl = $contentObject->url();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$correctUrl = $contentObject->url();
|
||||
}
|
||||
|
||||
$paramsToSet = array();
|
||||
foreach ( $requestedUrl->queryString as $k => $v )
|
||||
@@ -942,7 +974,7 @@ class _Url
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function examineFurl( &$furlDefinition, &$query, &$set, &$usedTemplate, $checkAlias=FALSE, $checkWithoutTopLevel=FALSE )
|
||||
public function examineFurl( &$furlDefinition, &$query, &$set, &$usedTemplate, $checkAlias=FALSE, $checkWithoutTopLevel=FALSE )
|
||||
{
|
||||
foreach ( $furlDefinition as $_key => $data )
|
||||
{
|
||||
@@ -1110,7 +1142,7 @@ class _Url
|
||||
}
|
||||
|
||||
/* Set a default user-agent since many services block requests without one, i.e. spotify */
|
||||
$requestObj->setHeaders( array( 'User-Agent' => 'IPS Community Suite 4.0' ) );
|
||||
$requestObj->setHeaders( array( 'User-Agent' => 'IPS Community Suite 4.1' ) );
|
||||
|
||||
return $requestObj;
|
||||
}
|
||||
@@ -1125,7 +1157,15 @@ class _Url
|
||||
public function import( $storageExtension )
|
||||
{
|
||||
$parts = $this->utf8ParseUrl( $this->url );
|
||||
return \IPS\File::create( $storageExtension, basename( $parts['path'] ), $this->request()->get() );
|
||||
$response = $this->request()->get();
|
||||
|
||||
/* We should not attempt to "import" 404, 403, 500, etc. responses */
|
||||
if( (int) $response->httpResponseCode !== 200 )
|
||||
{
|
||||
throw new \RuntimeException( "COULD_NOT_IMPORT" );
|
||||
}
|
||||
|
||||
return \IPS\File::create( $storageExtension, basename( $parts['path'] ), $response );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user