Merge branch 'ent-12864-actualizar-libreria-halfpastfouram-de-php' into 'develop'

Ent 12864 Actualizar librería halfpastfouram de PHP

See merge request artica/pandorafms!6932
This commit is contained in:
Rafael Ameijeiras 2024-02-15 08:27:44 +00:00
commit f28808f246
15 changed files with 330 additions and 11 deletions

View File

@ -172,12 +172,12 @@ function process_user_login_local($login, $pass, $api=false, $passAlreadyEncrypt
$credentials_check = $pass === $row['password'];
} else {
// Perform password check whether it is MD5-hashed (old hashing) or Bcrypt-hashed.
if (strlen($row['password']) === 32) {
if (strlen(($row['password'] ?? '')) === 32) {
// MD5.
$credentials_check = $row !== false && $row['password'] !== md5('') && $row['password'] == md5($pass);
} else {
// Bcrypt.
$credentials_check = password_verify($pass, $row['password']);
$credentials_check = password_verify($pass, ($row['password'] ?? ''));
}
}

View File

@ -2,7 +2,7 @@
namespace Artica\PHPChartJS;
use Halfpastfour\Collection\CollectionInterface;
use Artica\PHPChartJS\Collection\CollectionInterface;
/**
* Interface ChartInterface

View File

@ -0,0 +1,123 @@
<?php
namespace Artica\PHPChartJS\Collection;
use Artica\PHPChartJS\Collection\Collection;
/**
* Class ArrayAccess
* @package Artica\PHPChartJS\Collection\Collection
*/
class ArrayAccess extends Collection implements ArrayAccessInterface
{
/**
* Check if the given offset exists in the set of data.
*
* @param mixed $offset The offset to check.
*
* @return bool
*/
public function offsetExists( $offset )
{
// Can not retrieve a key based on a value other than a string, integer or boolean
if( !is_string( $offset ) && !is_int( $offset ) && !is_bool( $offset ) ) {
return false;
}
return array_key_exists( $offset, $this->data );
}
/**
* Get a value from the given offset.
*
* @param mixed $offset The offset to get the value from.
*
* @return mixed
*/
public function offsetGet( $offset )
{
if( $this->offsetExists( $offset ) ) {
return $this->data[ $offset ];
}
return null;
}
/**
* Set a value at the given offset.
*
* @param mixed $offset The offset to set the value at.
* @param mixed $value The value to set.
*
* @return $this
*/
public function offsetSet( $offset, $value )
{
$this->data[ $offset ] = $value;
return $this;
}
/**
* Unset a value at the given offset. Does nothing if the offset is not found.
*
* @param mixed $offset The offset to unset the value from.
*
* @return $this
*/
public function offsetUnset( $offset )
{
if( $this->offsetExists( $offset ) ) {
unset( $this->data[ $offset ] );
}
return $this;
}
/**
* Provide a callback to use for sorting the data.
*
* @param \Closure $callback The callback to be used.
*
* @return $this
*/
public function usort( \Closure $callback )
{
usort( $this->data, $callback );
reset( $this->data );
return $this;
}
/**
* Sort the data by key.
*
* @param int $sortFlags Optional flags to provide to ksort.
*
* @return $this
*/
public function ksort( $sortFlags = null )
{
ksort( $this->data, $sortFlags );
return $this;
}
/**
* Count the rows of data the collection contains.
*
* @return int
*/
public function count()
{
return count( $this->data );
}
/**
* @return ArrayIterator
*/
public function getIterator()
{
return new ArrayIterator( $this );
}
}

View File

@ -0,0 +1,42 @@
<?php
namespace Artica\PHPChartJS\Collection;
/**
* Interface ArrayAccessInterface
* @package Artica\PHPChartJS\Collection\Collection
*/
interface ArrayAccessInterface
{
/**
* Should set the data for the collection and return the previous set of data.
*
* @param array $data
*
* @return array
*/
public function exchangeArray( array $data );
/**
* Should perform the php function usort on the dataset.
*
* @param \Closure $callback
*
* @return $this
*/
public function usort( \Closure $callback );
/**
* Should perform the php function ksort on the dataset.
*
* @return $this
*/
public function ksort();
/**
* Count the rows of data the collection contains.
*
* @return int
*/
public function count();
}

View File

@ -0,0 +1,17 @@
<?php
namespace Artica\PHPChartJS\Collection;
/**
* Interface ArraySerializableInterface
* @package Artica\PHPChartJS\Collection
*/
interface ArraySerializableInterface
{
/**
* Should return an array containing all values.
*
* @return array
*/
public function getArrayCopy();
}

View File

@ -0,0 +1,114 @@
<?php
namespace Artica\PHPChartJS\Collection;
/**
* Class Collection
* @package Artica\PHPChartJS\Collection
*/
abstract class Collection implements CollectionInterface, ArraySerializableInterface
{
/**
* The internal set of data.
*
* @var array
*/
protected $data = [];
/**
* Collection constructor.
*
* @param array|null $data
*/
public function __construct( array $data = null )
{
if( !is_null( $data ) ) {
$this->data = $data;
}
}
/**
* Add a value to the beginning of the set of data. This will change existing keys.
*
* @param mixed $value The value to prepend.
*
* @return $this
*/
public function prepend( $value )
{
array_unshift( $this->data, $value );
return $this;
}
/**
* Add a value to the end of the set of data.
*
* @param mixed $value The value to append.
*
* @return $this
*/
public function append( $value )
{
array_push( $this->data, $value );
return $this;
}
/**
* Shift an element off of the left of the collection.
*
* @return mixed
*/
public function trimLeft()
{
return array_shift( $this->data );
}
/**
* Pop an element off of the right of the collection.
*
* @return mixed
*/
public function trimRight()
{
return array_pop( $this->data );
}
/**
* Should return an array containing all values.
*
* @return array
*/
public function getArrayCopy()
{
return $this->data;
}
/**
* Should set the data for the collection and return the previous set of data.
*
* @param array $data
*
* @return array
*/
public function exchangeArray( array $data )
{
// Gather return data
$returnArray = $this->getArrayCopy();
// Set the new data
$this->data = $data;
return $returnArray;
}
/**
* Get (and create if not exists) an iterator.
*
* @return \ArrayIterator
*/
public function getIterator()
{
return new \ArrayIterator( $this->data );
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace Artica\PHPChartJS\Collection;
/**
* Interface CollectionInterface
*/
interface CollectionInterface
{
/**
* @param mixed $value
*
* @return $this
*/
public function append( $value );
/**
* @param mixed $value
*
* @return $this
*/
public function prepend( $value );
}

View File

@ -2,7 +2,7 @@
namespace Artica\PHPChartJS\Collection;
use Halfpastfour\Collection\Collection\ArrayAccess;
use Artica\PHPChartJS\Collection\ArrayAccess;
use Artica\PHPChartJS\Delegate;
use JsonSerializable as JsonSerializableInterface;

View File

@ -2,7 +2,7 @@
namespace Artica\PHPChartJS;
use Halfpastfour\Collection\Collection\ArrayAccess;
use Artica\PHPChartJS\Collection\ArrayAccess;
use JsonSerializable;
/**

View File

@ -2,7 +2,7 @@
namespace Artica\PHPChartJS;
use Halfpastfour\Collection\Collection\ArrayAccess;
use Artica\PHPChartJS\Collection\ArrayAccess;
use JsonSerializable;
/**

View File

@ -2,7 +2,7 @@
namespace Artica\PHPChartJS\Options\Scales;
use Halfpastfour\Collection\Collection\ArrayAccess;
use Artica\PHPChartJS\Collection\ArrayAccess;
use Artica\PHPChartJS\ArraySerializableInterface;
use JsonSerializable;

View File

@ -2,7 +2,7 @@
namespace Artica\PHPChartJS\Options\Scales;
use Halfpastfour\Collection\Collection\ArrayAccess;
use Artica\PHPChartJS\Collection\ArrayAccess;
use Artica\PHPChartJS\ArraySerializableInterface;
use JsonSerializable;

View File

@ -2,7 +2,7 @@
namespace Artica\PHPChartJS\Options\Scales;
use Halfpastfour\Collection\Collection\ArrayAccess;
use Artica\PHPChartJS\Collection\ArrayAccess;
use Artica\PHPChartJS\ArraySerializableInterface;
use JsonSerializable;

View File

@ -2,7 +2,7 @@
namespace Artica\PHPChartJS;
use Halfpastfour\Collection\Collection\ArrayAccess;
use Artica\PHPChartJS\Collection\ArrayAccess;
use JsonSerializable;
/**

View File

@ -2,7 +2,7 @@
namespace Test;
use Halfpastfour\Collection\Collection\ArrayAccess;
use Artica\PHPChartJS\Collection\ArrayAccess;
use Artica\PHPChartJS\ArraySerializableInterface;
use Artica\PHPChartJS\Chart\Bar;
use Artica\PHPChartJS\ChartInterface;