Commit eb8f01cb authored by Sigrid Suski's avatar Sigrid Suski

(!) Updated User agent for Crawler to a newer version

    (!) CURL error message if Crawler does not work at all
   	(!) Includes Sobi Framework 1.0.12
parent 78159949
......@@ -15,6 +15,9 @@
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* @created Thu, Dec 1, 2016 11:53:09 by Radek Suski
* @modified 30 April 2020 by Sigrid Suski
*/
namespace Sobi;
......@@ -22,9 +25,8 @@ namespace Sobi;
defined( 'SOBI' ) || exit( 'Restricted access' );
/**
* @author Radek Suski
* @created Thu, Dec 1, 2016 11:53:09
* @modified 21 January 2020 by Sigrid Suski
* Class C
* @package Sobi
*/
abstract class C
{
......@@ -42,5 +44,5 @@ abstract class C
const NO = 0;
const ROOT = JPATH_ROOT;
const DS = DIRECTORY_SEPARATOR;
const VERSION = '1.0.11';
const VERSION = '1.0.12';
}
<?php
/**
* @package: Sobi Framework
*
* @author
* Name: Sigrid Suski & Radek Suski, Sigsiu.NET GmbH
* Email: sobi[at]sigsiu.net
* Url: https://www.Sigsiu.NET
* @copyright Copyright (C) 2006 - 2016 Sigsiu.NET GmbH (https://www.sigsiu.net). All rights reserved.
*
* @copyright Copyright (C) 2006 - 2020 Sigsiu.NET GmbH (https://www.sigsiu.net). All rights reserved.
* @license GNU/LGPL Version 3
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3
* as published by the Free Software Foundation, and under the additional terms according section 7 of GPL v3.
* See http://www.gnu.org/licenses/lgpl.html and https://www.sigsiu.net/licenses.
* See https://www.gnu.org/licenses/lgpl.html and https://www.sigsiu.net/licenses.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* @created Sat, Dec 3, 2016 15:22:50
*
* @created Sat, Dec 3, 2016 15:22:50 by Radek Suski
* @modified 30 April 2020 by Sigrid Suski
*/
namespace Sobi\Communication;
......@@ -23,9 +27,23 @@ defined( 'SOBI' ) || exit( 'Restricted access' );
use Sobi\Error\Exception;
use Sobi\Framework;
/**
* Class CURL
* @package Sobi\Communication
*/
class CURL
{
/**
* @var false|resource|null
*/
private $resource = null;
/**
* @var array
*/
private $curlStatus = 0;
/**
* @var array
*/
static $infoCodes = [
'effective_url' => CURLINFO_EFFECTIVE_URL,
'http_code' => CURLINFO_HTTP_CODE,
......@@ -47,8 +65,11 @@ class CURL
'ssl_verifyresult' => CURLINFO_SSL_VERIFYRESULT,
'content_length_download' => CURLINFO_CONTENT_LENGTH_DOWNLOAD,
'content_length_upload' => CURLINFO_CONTENT_LENGTH_UPLOAD,
'content_type' => CURLINFO_CONTENT_TYPE
'content_type' => CURLINFO_CONTENT_TYPE,
];
/**
* @var array
*/
static $optionsCodes = [
'autoreferer' => CURLOPT_AUTOREFERER,
'binarytransfer' => CURLOPT_BINARYTRANSFER,
......@@ -68,7 +89,7 @@ class CURL
'header' => CURLOPT_HEADER,
'httpget' => CURLOPT_HTTPGET,
'httpproxytunnel' => CURLOPT_HTTPPROXYTUNNEL,
// 'mute' => CURLOPT_MUTE,
// 'mute' => CURLOPT_MUTE,
'netrc' => CURLOPT_NETRC,
'nobody' => CURLOPT_NOBODY,
'noprogress' => CURLOPT_NOPROGRESS,
......@@ -82,7 +103,7 @@ class CURL
'upload' => CURLOPT_UPLOAD,
'verbose' => CURLOPT_VERBOSE,
'buffersize' => CURLOPT_BUFFERSIZE,
// 'closepolicy' => CURLOPT_CLOSEPOLICY,
// 'closepolicy' => CURLOPT_CLOSEPOLICY,
'connecttimeout' => CURLOPT_CONNECTTIMEOUT,
'dns_cache_timeout' => CURLOPT_DNS_CACHE_TIMEOUT,
'ftpsslauth' => CURLOPT_FTPSSLAUTH,
......@@ -150,16 +171,16 @@ class CURL
/**
* Initialize a cURL session
*
* @param null $url
* @throws Exception
*
* @return CURL
* @throws Exception
*/
public function __construct( $url = null )
{
if ( function_exists( 'curl_init' ) ) {
/*
* For some reason on certain PHP/CURL version it causes error if the $url is null
*/
/* For some reason on certain PHP/CURL version it causes error if the $url is null */
if ( $url ) {
$this->resource = curl_init( $url );
}
......@@ -168,14 +189,16 @@ class CURL
}
}
else {
throw new Exception( Framework::Txt( 'CURL_NOT_INSTALLED' ) );
$this->curlStatus = 999;
}
}
/**
* Sets an option on the given cURL session handle.
*
* @param string $option - The CURLOPT_XXX option to set.
* @param mixed $value - The value to be set on option
*
* @return bool
*/
public function setOption( $option, $value )
......@@ -183,12 +206,15 @@ class CURL
if ( is_string( $option ) && isset( self::$optionsCodes[ $option ] ) ) {
$option = self::$optionsCodes[ $option ];
}
return curl_setopt( $this->resource, $option, $value );
}
/**
* Sets multiple options for a cURL session
*
* @param array $options - An array specifying which options to set and their values. The keys should be valid curl_setopt() constants or their integer equivalents.
*
* @return bool
*/
public function setOptions( $options )
......@@ -201,12 +227,23 @@ class CURL
}
}
}
return curl_setopt_array( $this->resource, $options );
}
/**
* set an URL
* @return array
*/
public function status()
{
return $this->curlStatus;
}
/**
* Sets an URL.
*
* @param string $url
*
* @return bool
*/
public function setUrl( $url )
......@@ -216,9 +253,11 @@ class CURL
/**
* TRUE to include the header in the output.
*
* @param $timeOut
* @internal param bool $header
*
* @return bool
* @internal param bool $header
*/
public function setTimeOut( $timeOut )
{
......@@ -227,7 +266,9 @@ class CURL
/**
* TRUE to include the header in the output.
*
* @param bool $header
*
* @return bool
*/
public function setHeader( $header )
......@@ -244,7 +285,8 @@ class CURL
}
/**
* Closes a cURL session and frees all resources
* Closes a cURL session and frees all resources.
*
* @return mixed
*/
public function close()
......@@ -265,6 +307,7 @@ class CURL
*/
public function exec()
{
$this->error[ 'active' ] = false;
$r = curl_exec( $this->resource );
$inf = $this->info();
if ( $inf[ 'http_code' ] == 301 || $inf[ 'http_code' ] == 302 ) {
......@@ -273,20 +316,25 @@ class CURL
preg_match( '/Location: (http.*)/', $r, $newUrl );
$this->setOption( 'header', false );
$this->setOption( 'url', $newUrl[ 1 ] );
return $this->exec();
}
return $r;
}
/**
* Gets information about the last transfer
* Gets information about the last transfer.
*
* @param string $opt - correspond option
*
* @return bool
*/
public function info( $opt = null )
{
if ( $opt && is_string( $opt ) && isset( self::$infoCodes[ $opt ] ) ) {
$opt = self::$infoCodes[ $opt ];
return curl_getinfo( $this->resource, $opt );
}
else {
......@@ -294,6 +342,12 @@ class CURL
}
}
/**
* @param $url
*
* @return array|false
* @throws Exception
*/
public function certificate( $url )
{
$errno = null;
......@@ -321,6 +375,7 @@ class CURL
);
if ( !( $this->validCode( $this->exec() ) ) ) {
$err = $this->info();
return [ 'err' => $err[ 'http_code' ], 'msg' => Framework::Txt( 'NO_CONNECT', 'https://' . $url ) ];
}
$res = stream_context_create( [ 'ssl' => [ 'capture_peer_cert' => true ] ] );
......@@ -334,42 +389,65 @@ class CURL
}
}
/**
* @param $url
*
* @return false|int
*/
private function validateHttp( $url )
{
return preg_match( '|http[s]?:\/\/[a-z0-9\.\-\_]{3,}\.[a-z]{2,5}.*|i', $url );
}
/**
* @param $response
*
* @return bool|int
*/
public function getCode( $response )
{
$matches = [];
if ( preg_match( '/HTTP\/1\.\d+\s+(\d+)/', $response, $matches ) ) {
return ( int )$matches[ 1 ];
return ( int ) $matches[ 1 ];
}
else {
return false;
}
}
/**
* @param $response
*
* @return bool
*/
public function validCode( $response )
{
return ( ( $this->getCode( $response ) >= 200 ) && ( $this->getCode( $response ) < 400 ) );
}
/**
* Return the last error number and/or a string containing the last error for the current session
* Returns the last error number and/or a string containing the last error for the current session.
*
* @param bool $message - return string containing the last error
* @param bool $number - return error number
*
* @return string
*/
public function error( $message = true, $number = true )
{
$err = [];
$errno = curl_errno( $this->resource );
if ( $number ) {
$err[] = curl_errno( $this->resource );
$err[] = $errno;
}
if ( $message ) {
$err[] = curl_error( $this->resource );
}
return implode( ', ', $err );
if ( $errno ) {
return implode( ': ', $err );
}
else {
return null;
}
}
}
<?php
/**
* @package: Sobi Framework
*
* @author
* Name: Sigrid Suski & Radek Suski, Sigsiu.NET GmbH
* Email: sobi[at]sigsiu.net
* Url: https://www.Sigsiu.NET
* @copyright Copyright (C) 2006 - 2016 Sigsiu.NET GmbH (https://www.sigsiu.net). All rights reserved.
*
* @copyright Copyright (C) 2006 - 2020 Sigsiu.NET GmbH (https://www.sigsiu.net). All rights reserved.
* @license GNU/LGPL Version 3
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3
* as published by the Free Software Foundation, and under the additional terms according section 7 of GPL v3.
* See http://www.gnu.org/licenses/lgpl.html and https://www.sigsiu.net/licenses.
* See https://www.gnu.org/licenses/lgpl.html and https://www.sigsiu.net/licenses.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* @created Thu, Dec 1, 2016 12:04:19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* @created Thu, Dec 1, 2016 12:04:19 by Radek Suski
* @modified 30 April 2020 by Sigrid Suski
*/
namespace Sobi;
......@@ -23,6 +27,10 @@ defined( '_JEXEC' ) || exit( 'Restricted access' );
use Sobi\Autoloader\Autoloader;
use Sobi\Error\Exception;
/**
* Class Framework
* @package Sobi
*/
abstract class Framework
{
/** @var array */
......@@ -57,6 +65,7 @@ abstract class Framework
{
if ( is_array( self::$translator ) && count( self::$translator ) == 2 ) {
$args = func_get_args();
return call_user_func_array( self::$translator, $args );
}
else {
......@@ -72,6 +81,7 @@ abstract class Framework
{
if ( is_array( self::$config ) && count( self::$config ) == 2 ) {
$args = func_get_args();
return call_user_func_array( self::$config, $args );
}
else {
......
# Changelog for Sobi Framework
Changelog for Sobi Framework
===================================================
@package: Sobi Framework
#### @package
@author
Name: Sigrid Suski & Radek Suski, Sigsiu.NET GmbH
Sobi Framework
#### @author
Name: Sigrid Suski and Radek Suski, Sigsiu.NET GmbH
Email: sobi[at]sigsiu.net
Url: https://www.Sigsiu.NET
@copyright Copyright (C) 2006 - 2020 Sigsiu.NET GmbH (https://www.sigsiu.net). All rights reserved.
@license GNU/GPL Version 3
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3
#### @copyright
Copyright (C) 2006 - 2020 Sigsiu.NET GmbH (https://www.sigsiu.net). All rights reserved.
@license GNU/LGPL Version 3
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3
as published by the Free Software Foundation, and under the additional terms according section 7 of GPL v3.
See https://www.gnu.org/licenses/gpl.html and https://www.sigsiu.net/licenses.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
#### Legend:
(*) Security Fix
(#) Bug Fix
(+) Addition
(-) Removed
(!) Change
Legend:
- (*) - Security Fix
- (#) - Bug Fix
- (+) - Addition
- (-) - Removed
- (!) - Change
### 1.0.12 (30 May 2020)
1.0.11 (21 January 2020)
------------------
(!) CURL error messages improved and initialisation status added
### 1.0.11 (21 January 2020)
(#) double usage of variable $e
1.0.10 (26 November 2019)
------------------
### 1.0.10 (26 November 2019)
(+) Workaround for Joomla returnig wrongfully an integer when array with the same name is set
1.0.9 (13 February 2019)
------------------
### 1.0.9 (13 February 2019)
(+) Implementation of FileSystem::FixUrl and failsafe for FileSystem::FixPath
......@@ -48,15 +54,13 @@ Legend:
(#) Original file should not be deleted after resampling
1.0.8 (10 January 2019)
------------------
### 1.0.8 (10 January 2019)
(#) Image rotation not called
(#) Input::Search breaks after first result
1.0.7 (6 September 2018)
------------------
### 1.0.7 (6 September 2018)
(+) Simple OpenSSL encryption added
(+) Option to replace characters with null in StringUtils::Nid
......@@ -68,21 +72,18 @@ Legend:
(#) Count on non-arrays in PHP 7.2.x (Issue #103)
1.0.6 (4 May 2018)
-------------------
### 1.0.6 (4 May 2018)
(#) HTML filter, reverting html entities (Issue #8)
1.0.5 (3 May 2018)
-------------------
### 1.0.5 (3 May 2018)
(#) Closing for empty tags changed to short closing and leads to problems (Issue #7)
(#) Each save doubles the number of line-breaks in textareas (Issue #6)
1.0.4 (25 April 2018)
-------------------
### 1.0.4 (25 April 2018)
(+) Implemented AthosHun\HTMLFilter
(+) Implemented Grafika
......@@ -92,8 +93,7 @@ Legend:
(#) Missing slash in RegEx (Issue #3)
1.0.3 (28 December 2017)
-------------------
### 1.0.3 (28 December 2017)
(+) Input::Search implemented
......@@ -104,22 +104,18 @@ Legend:
(#) Or-operation of where conditions with time as parameter failed
1.0.2 (4 March 2017)
-------------------
### 1.0.2 (4 March 2017)
(#) Wrong regex for Input::Cmd
1.0.1 (1 March 2017)
-------------------
### 1.0.1 (1 March 2017)
(!) Array syntax changed
(#) SPC used in Framework; junk left after moving functionality to the Framework (Issue #1766)
1.0.0 (21 January 2017)
-------------------
### 1.0.0 (21 January 2017)
(+) Initial release
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment