Commit 2935818e authored by Radek Suski's avatar Radek Suski

Merge branch 'master' of https://code.sigsiu.net/Sigsiu.NET/Sobi-Framework

# Conflicts:
#	changelog.md
parents 47690ee1 19f25461
......@@ -44,5 +44,5 @@ abstract class C
const NO = 0;
const ROOT = JPATH_ROOT;
const DS = DIRECTORY_SEPARATOR;
const VERSION = '1.0.12';
const VERSION = '1.0.13';
}
......@@ -17,7 +17,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* @created Sat, Dec 3, 2016 15:22:50 by Radek Suski
* @modified 01 May 2020 by Sigrid Suski
* @modified 01 June 2020 by Sigrid Suski
*/
namespace Sobi\Communication;
......@@ -352,7 +352,7 @@ class CURL
$url = $url[ 0 ];
}
if ( !( $this->validateHttp( 'https://' . $url ) ) ) {
return [ 'err' => 500, 'msg' => Framework::Txt( 'INVALID_URL', 'https://' . $url ) ];
return [ 'err' => 500, 'msg' => Framework::Error( 'INVALID_URL', 'https://' . $url ) ];
}
$this->setOptions(
[
......@@ -368,12 +368,20 @@ class CURL
if ( !( $this->validCode( $this->exec() ) ) ) {
$err = $this->info();
return [ 'err' => $err[ 'http_code' ], 'msg' => Framework::Txt( 'NO_CONNECT', 'https://' . $url ) ];
return [ 'err' => $err[ 'http_code' ], 'msg' => Framework::Error( 'NO_CONNECT', 'https://' . $url ) ];
}
$res = stream_context_create( [ 'ssl' => [ 'capture_peer_cert' => true ] ] );
// @todo we can try to catch and if validation fails do it w/o but give the user a warning
// $res = stream_context_create( [ 'ssl' => [ 'capture_peer_cert' => true, 'verify_peer' => false, 'verify_peer_name' => false ] ] );
$client = stream_socket_client( "ssl://{$url}:443", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $res );
if ( !$client ) {
if ( $errno == 0 ) {
return [ 'err' => 998, 'msg' => Framework::Error( 'CURL_INITIALISATION_ERROR', 'https://' . $url ) ];
}
else {
return [ 'err' => $errno, 'msg' => $errstr ];
}
}
$cont = stream_context_get_options( $client );
if ( !$errno ) {
return openssl_x509_parse( $cont[ 'ssl' ][ 'peer_certificate' ] );
......@@ -464,7 +472,7 @@ class CURL
$err[] = $errno;
}
if ( $message ) {
$err[] = Framework::Txt( 'CURL_NOT_INSTALLED' );
$err[] = Framework::Error( 'CURL_NOT_INSTALLED' );
}
if ( $errno ) {
return implode( ': ', $err );
......
......@@ -145,7 +145,7 @@ class File
return $this->_filename;
}
else {
throw new Exception( Framework::Txt( 'CANNOT_UPLOAD_FILE_TO', str_replace( C::ROOT, null, $destination ) ) );
throw new Exception( Framework::Error( 'CANNOT_UPLOAD_FILE_TO', str_replace( C::ROOT, null, $destination ) ) );
}
}
}
......
<?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.
*
* 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:02:59
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* @created Thu, Dec 1, 2016 by Radek Suski
* @modified 02 June 2020 by Sigrid Suski
*/
namespace Sobi\FileSystem;
......@@ -24,10 +28,13 @@ use Sobi\C;
use Sobi\Framework;
use Sobi\Error\Exception;
/**
* Class FileSystem
* @package Sobi\FileSystem
*/
abstract class FileSystem
{
/**
**
* @param string $file
*
* @return bool
......@@ -38,11 +45,10 @@ abstract class FileSystem
}
/**
* *
* @param string $file
* @param bool $safe
*
* @return bool
* @return string|string[]
*/
public static function Clean( $file, $safe = false )
{
......@@ -63,10 +69,9 @@ abstract class FileSystem
}
/**
* *
* @param string $file
*
* @return bool
* @return mixed|string
*/
public static function GetExt( $file )
{
......@@ -76,10 +81,9 @@ abstract class FileSystem
}
/**
* *
* @param string $file
*
* @return bool
* @return mixed|string
*/
public static function GetFileName( $file )
{
......@@ -89,11 +93,11 @@ abstract class FileSystem
}
/**
* *
* @param string $source
* @param string $destination
*
* @return bool
* @return mixed
* @throws Exception
*/
public static function Copy( $source, $destination )
{
......@@ -126,11 +130,10 @@ abstract class FileSystem
}
/**
* *
* @param string $file
*
* @return bool|void
* @throws Exception
* @return bool
*/
public static function Delete( $file )
{
......@@ -140,7 +143,7 @@ abstract class FileSystem
throw new Exception( Framework::Txt( 'Fatal error. Trying to delete not allowed path "%s"', $file ) );
}
return \Jfolder::delete( $file );
\Jfolder::delete( $file );
}
else {
return \Jfile::delete( $file );
......@@ -170,6 +173,11 @@ abstract class FileSystem
return file_get_contents( $file );
}
/**
* @param $path
*
* @return string|string[]
*/
public static function FixPath( $path )
{
$sep = explode( '://', $path );
......@@ -181,6 +189,11 @@ abstract class FileSystem
return str_replace( C::DS . C::DS, C::DS, str_replace( C::DS . C::DS, C::DS, str_replace( '\\', '/', $path ) ) );
}
/**
* @param $url
*
* @return string|string[]
*/
public static function FixUrl( $url )
{
$sep = explode( '://', $url );
......@@ -197,8 +210,8 @@ abstract class FileSystem
* @param string $buffer
* @param bool $append
*
* @throws Exception
* @return bool
* @throws Exception
*/
public static function Write( $file, &$buffer, $append = false )
{
......@@ -220,6 +233,7 @@ abstract class FileSystem
* @param string $destination
*
* @return bool
* @throws Exception
*/
public static function Upload( $name, $destination )
{
......@@ -266,19 +280,15 @@ abstract class FileSystem
}
/**
* *
* @param string $path
*
* @return bool
* @param $path
*/
public static function Rmdir( $path )
{
return \JFolder::delete( $path );
\JFolder::delete( $path );
}
/**
* *
* @param string $path
* @param $path
*
* @return bool
*/
......@@ -288,8 +298,7 @@ abstract class FileSystem
}
/**
* *
* @param string $path
* @param $path
*
* @return bool
*/
......@@ -299,10 +308,9 @@ abstract class FileSystem
}
/**
* *
* @param string $path
* @param $path
*
* @return bool
* @return false|int
*/
public static function Owner( $path )
{
......@@ -310,9 +318,8 @@ abstract class FileSystem
}
/**
* *
* @param string $source
* @param string $destination
* @param $source
* @param $destination
*
* @return bool
*/
......
......@@ -17,7 +17,7 @@
* 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
* @modified 01 June 2020 by Sigrid Suski
*/
namespace Sobi;
......@@ -35,6 +35,10 @@ abstract class Framework
{
/** @var array */
protected static $translator = [];
/**
* @var array
*/
protected static $errortranslator = [];
/** @var array */
protected static $config;
......@@ -47,6 +51,14 @@ abstract class Framework
self::$translator = $callback;
}
/**
* @param array $callback
*/
public static function SetErrorTranslator( array $callback )
{
self::$errortranslator = $callback;
}
/**
*
*/
......@@ -73,6 +85,22 @@ abstract class Framework
}
}
/**
* @return mixed
* @throws Exception
*/
public static function Error()
{
if ( is_array( self::$errortranslator ) && count( self::$errortranslator ) == 2 ) {
$args = func_get_args();
return call_user_func_array( self::$errortranslator, $args );
}
else {
throw new Exception( 'Error Translator has not been set' );
}
}
/**
* @return string | array
* @throws Exception
......
......@@ -234,7 +234,12 @@ abstract class Input
{
$value = Request::Instance()->{$request}->getString( $name, $default );
return filter_var( $value, FILTER_SANITIZE_ADD_SLASHES );
if ( version_compare( PHP_VERSION, '7.4.0' ) >= 0 ) {
return filter_var( $value, FILTER_SANITIZE_ADD_SLASHES );
}
else {
return filter_var( $value, FILTER_SANITIZE_MAGIC_QUOTES );
}
}
/**
......
......@@ -31,8 +31,13 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
(!) Change
### 1.0.13 (31 Juli 2020)
(+) Added support for WEBP images into Grafika
### 1.0.13 (05 June 2020)
(+) Output of error messages added
(+) CURL initialisation error added
(#) FILTER_SANITIZE_ADD_SLASHES does not work for PHP versions below 7.4
### 1.0.12 (30 May 2020)
......
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