Version 4.7.13

This commit is contained in:
Neo committed 2025-12-19 16:14:56 -08:00
1 parent fd22d99e69
commit 7124a02564
954 files changed
+29277 -59308

No files matched your search

+75 -1
View File
@@ -160,6 +160,10 @@ class _Curl
public function __destruct()
{
curl_close( $this->curl );
if( static::$_multiHandle instanceof \CurlMultiHandle )
{
curl_multi_close( static::$_multiHandle );
}
}
/**
@@ -378,6 +382,7 @@ class _Curl
/**
* Execute the request
*
* @todo Remove if multi handle works out long term.
* @return \IPS\Http\Response
* @throws \IPS\Http\Request\CurlException
*/
@@ -407,6 +412,75 @@ class _Curl
/* Return it */
return new \IPS\Http\Response( $output );
}
/**
* @breif Store the cURL Multi Handle
*/
protected static $_multiHandle;
/**
* Execute the request via cURL Multi - We use this to cache and share connections between requests
*
* @return \IPS\Http\Response
* @throws \IPS\Http\Request\CurlException
*/
protected function _executeMh(): \IPS\Http\Response
{
/* Init multi handle if needed */
if( empty( static::$_multiHandle ) )
{
static::$_multiHandle = curl_multi_init();
}
/* Store handle for this request */
curl_multi_add_handle( static::$_multiHandle, $this->curl );
/* Execute request and wait for response */
$active = NULL;
do
{
$ret = curl_multi_exec( static::$_multiHandle, $active );
}
while( $ret == CURLM_CALL_MULTI_PERFORM );
while( $active && $ret == CURLM_OK )
{
if( curl_multi_select( static::$_multiHandle ) != -1 )
{
do
{
$mrc = curl_multi_exec( static::$_multiHandle, $active );
}
while( $mrc == CURLM_CALL_MULTI_PERFORM );
}
}
$output = curl_multi_getcontent( $this->curl );
/* Remove handles we no longer need */
curl_multi_remove_handle( static::$_multiHandle, $this->curl );
/* Log - but because the output can be large, only do this if we explicitly have debug logging enabled */
if ( \defined('\IPS\DEBUG_LOG') and \IPS\DEBUG_LOG )
{
\IPS\Log::debug( "\n\n------------------------------------\ncURL REQUEST: {$this->url}\n------------------------------------\n\n" . implode( "\n", $this->headersForLog ) . "\n\n" . var_export( $this->dataForLog, TRUE ) . "\n\n------------------------------------\nRESPONSE\n------------------------------------\n\n" . $output, 'request' );
}
/* Errors? */
if ( $output === FALSE )
{
throw new CurlException( $this->url . "\n" . curl_error( $this->curl ), curl_errno( $this->curl ) );
}
/* If this is FTP we need to fudge the headers a little */
if( isset( $this->url->data['scheme'] ) and $this->url->data['scheme'] == 'ftp' )
{
$output = "HTTP/1.1 200 OK\nFTP: True\r\n\r\n" . $output;
}
/* Return it */
return new \IPS\Http\Response( $output );
}
/**
* Execute the request and follow redirects id necessary
@@ -419,7 +493,7 @@ class _Curl
protected function _executeAndFollowRedirects( $method, $params=NULL )
{
/* Execute */
$response = $this->_execute();
$response = $this->_executeMh();
/* Either return it or follow it */
if ( $this->followRedirects and \in_array( $response->httpResponseCode, array( 301, 302, 303, 307, 308 ) ) )
+1 -1
View File
@@ -638,7 +638,7 @@ class _Url
*/
public function __toString()
{
return (string) $this->url;
return (string) $this->url;
}
/* !Encoding and Decoding */
+1 -18
View File
@@ -91,26 +91,9 @@ class _Useragent
*/
public function parseUserAgent()
{
/* Is it ours? */
if ( preg_match( '/^InvisionCommunityApp\/(\d+\.\d+\.\d+) \((.+?)\) (.+?) \((.+?)\)$/', $this->useragent, $matches ) ) // Matches: 1 = App version, 2 = App name (differentiates multicommunity vs white-label) 3 = "Android" or "iOS/X.Y.Z" 4 = Semi-human-friendly name (e.g. "iPhone11,6" is iPhone XS Max)
{
if ( $matches[3] === 'Android' )
{
$this->platform = $matches[4];
}
else
{
$this->platform = preg_replace( '/^(.+?)\d+,\d+$/', '$1', $matches[4] );
}
$this->browser = 'InvisionCommunityApp';
$this->browserVersion = $matches[1];
return;
}
/* Set basic data */
require_once( \IPS\ROOT_PATH . '/system/3rd_party/PhpUserAgent/UserAgentParser.php' );
$data = parse_user_agent( $this->useragent );
$data = \donatj\UserAgent\parse_user_agent( $this->useragent );
$this->platform = $data['platform'];
$this->browser = $data['browser'];
$this->browserVersion = $data['version'];