mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-13 07:18:39 +00:00
Handle open todos
This commit is contained in:
parent
7db81b9bdd
commit
3aa3c6b0dd
|
|
@ -126,8 +126,7 @@ class FileCache extends ConnectionAbstract
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: allow $key to contain / as char and create subdirectory if necessary. This is important for cleaner caching.
|
$path = Directory::sanitize($key, self::SANITIZE);
|
||||||
$path = File::sanitize($key, self::SANITIZE);
|
|
||||||
|
|
||||||
File::put($this->con . '/' . trim($path, '/') . '.cache', $this->build($value, $expire));
|
File::put($this->con . '/' . trim($path, '/') . '.cache', $this->build($value, $expire));
|
||||||
}
|
}
|
||||||
|
|
@ -242,10 +241,10 @@ class FileCache extends ConnectionAbstract
|
||||||
*/
|
*/
|
||||||
private function getExpire(string $raw) : int
|
private function getExpire(string $raw) : int
|
||||||
{
|
{
|
||||||
$expireStart = strpos($raw, self::DELIM);
|
$expireStart = \strpos($raw, self::DELIM);
|
||||||
$expireEnd = strpos($raw, self::DELIM, $expireStart + 1);
|
$expireEnd = \strpos($raw, self::DELIM, $expireStart + 1);
|
||||||
|
|
||||||
return (int) substr($raw, $expireStart + 1, $expireEnd - ($expireStart + 1));
|
return (int) \substr($raw, $expireStart + 1, $expireEnd - ($expireStart + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -273,9 +272,9 @@ class FileCache extends ConnectionAbstract
|
||||||
$raw = File::get($path);
|
$raw = File::get($path);
|
||||||
$type = (int) $raw[0];
|
$type = (int) $raw[0];
|
||||||
|
|
||||||
$expireStart = strpos($raw, self::DELIM);
|
$expireStart = \strpos($raw, self::DELIM);
|
||||||
$expireEnd = strpos($raw, self::DELIM, $expireStart + 1);
|
$expireEnd = \strpos($raw, self::DELIM, $expireStart + 1);
|
||||||
$cacheExpire = substr($raw, $expireStart + 1, $expireEnd - ($expireStart + 1));
|
$cacheExpire = \substr($raw, $expireStart + 1, $expireEnd - ($expireStart + 1));
|
||||||
|
|
||||||
if ($cacheExpire >= 0 && $created + $cacheExpire < $now) {
|
if ($cacheExpire >= 0 && $created + $cacheExpire < $now) {
|
||||||
$this->delete($key);
|
$this->delete($key);
|
||||||
|
|
@ -303,16 +302,16 @@ class FileCache extends ConnectionAbstract
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case CacheValueType::_INT:
|
case CacheValueType::_INT:
|
||||||
$value = (int) substr($raw, $expireEnd + 1);
|
$value = (int) \substr($raw, $expireEnd + 1);
|
||||||
break;
|
break;
|
||||||
case CacheValueType::_FLOAT:
|
case CacheValueType::_FLOAT:
|
||||||
$value = (float) substr($raw, $expireEnd + 1);
|
$value = (float) \substr($raw, $expireEnd + 1);
|
||||||
break;
|
break;
|
||||||
case CacheValueType::_BOOL:
|
case CacheValueType::_BOOL:
|
||||||
$value = (bool) substr($raw, $expireEnd + 1);
|
$value = (bool) \substr($raw, $expireEnd + 1);
|
||||||
break;
|
break;
|
||||||
case CacheValueType::_STRING:
|
case CacheValueType::_STRING:
|
||||||
$value = substr($raw, $expireEnd + 1);
|
$value = \substr($raw, $expireEnd + 1);
|
||||||
break;
|
break;
|
||||||
case CacheValueType::_ARRAY:
|
case CacheValueType::_ARRAY:
|
||||||
$value = \json_decode(substr($raw, $expireEnd + 1));
|
$value = \json_decode(substr($raw, $expireEnd + 1));
|
||||||
|
|
@ -322,9 +321,9 @@ class FileCache extends ConnectionAbstract
|
||||||
break;
|
break;
|
||||||
case CacheValueType::_SERIALIZABLE:
|
case CacheValueType::_SERIALIZABLE:
|
||||||
case CacheValueType::_JSONSERIALIZABLE:
|
case CacheValueType::_JSONSERIALIZABLE:
|
||||||
$namespaceStart = strpos($raw, self::DELIM, $expireEnd);
|
$namespaceStart = \strpos($raw, self::DELIM, $expireEnd);
|
||||||
$namespaceEnd = strpos($raw, self::DELIM, $namespaceStart + 1);
|
$namespaceEnd = \strpos($raw, self::DELIM, $namespaceStart + 1);
|
||||||
$namespace = substr($raw, $namespaceStart, $namespaceEnd);
|
$namespace = \substr($raw, $namespaceStart, $namespaceEnd);
|
||||||
|
|
||||||
$value = $namespace::unserialize(substr($raw, $namespaceEnd + 1));
|
$value = $namespace::unserialize(substr($raw, $namespaceEnd + 1));
|
||||||
break;
|
break;
|
||||||
|
|
@ -351,12 +350,12 @@ class FileCache extends ConnectionAbstract
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($expire >= 0) {
|
if ($expire >= 0) {
|
||||||
$created = Directory::created(File::sanitize($key, self::SANITIZE))->getTimestamp();
|
$created = Directory::created(Directory::sanitize($key, self::SANITIZE))->getTimestamp();
|
||||||
$now = time();
|
$now = \time();
|
||||||
$raw = \file_get_contents($path);
|
$raw = \file_get_contents($path);
|
||||||
$expireStart = strpos($raw, self::DELIM);
|
$expireStart = \strpos($raw, self::DELIM);
|
||||||
$expireEnd = strpos($raw, self::DELIM, $expireStart + 1);
|
$expireEnd = \strpos($raw, self::DELIM, $expireStart + 1);
|
||||||
$cacheExpire = substr($raw, $expireStart + 1, $expireEnd - ($expireStart + 1));
|
$cacheExpire = \substr($raw, $expireStart + 1, $expireEnd - ($expireStart + 1));
|
||||||
|
|
||||||
if ($cacheExpire >= 0 && $created + $cacheExpire > $now) {
|
if ($cacheExpire >= 0 && $created + $cacheExpire > $now) {
|
||||||
File::delete($path);
|
File::delete($path);
|
||||||
|
|
@ -425,7 +424,7 @@ class FileCache extends ConnectionAbstract
|
||||||
*/
|
*/
|
||||||
private function getPath($key) : string
|
private function getPath($key) : string
|
||||||
{
|
{
|
||||||
$path = File::sanitize($key, self::SANITIZE);
|
$path = Directory::sanitize($key, self::SANITIZE);
|
||||||
return $this->con . '/' . trim($path, '/') . '.cache';
|
return $this->con . '/' . trim($path, '/') . '.cache';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,6 @@ abstract class ConnectionAbstract implements ConnectionInterface
|
||||||
*
|
*
|
||||||
* The database prefix name for unique table names
|
* The database prefix name for unique table names
|
||||||
*
|
*
|
||||||
* @todo: make private? could add huge overhead since function call required
|
|
||||||
*
|
|
||||||
* @var string
|
* @var string
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
@ -94,6 +92,25 @@ abstract class ConnectionAbstract implements ConnectionInterface
|
||||||
*/
|
*/
|
||||||
protected $schemaGrammar = null;
|
protected $schemaGrammar = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set values
|
||||||
|
*
|
||||||
|
* @param string $name Variable name
|
||||||
|
* @param string $value Variable value
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function __set($name, $value) : void
|
||||||
|
{
|
||||||
|
if (!empty($this->$name)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->$name = $value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,6 @@ final class Functions
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* todo: move to utils?! implement sqrt for array as well... could be usefull for others (e.g. matrix)
|
|
||||||
*/
|
*/
|
||||||
public static function powerFloat(array $values, float $exp = 2.0) : array
|
public static function powerFloat(array $values, float $exp = 2.0) : array
|
||||||
{
|
{
|
||||||
|
|
@ -268,7 +267,6 @@ final class Functions
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* todo: move to utils?! implement sqrt for array as well... could be usefull for others (e.g. matrix)
|
|
||||||
*/
|
*/
|
||||||
public static function powerInt(array $values, int $exp = 2) : array
|
public static function powerInt(array $values, int $exp = 2) : array
|
||||||
{
|
{
|
||||||
|
|
@ -281,6 +279,26 @@ final class Functions
|
||||||
return $squared;
|
return $squared;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sqrt all values in array.
|
||||||
|
*
|
||||||
|
* @param array $values Values to sqrt
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public static function sqrt(array $values) : array
|
||||||
|
{
|
||||||
|
$squared = [];
|
||||||
|
|
||||||
|
foreach ($values as $value) {
|
||||||
|
$squared[] = sqrt($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $squared;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the relative position on a circular construct.
|
* Gets the relative position on a circular construct.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,6 @@ namespace phpOMS\Math\Geometry\ConvexHull;
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*
|
|
||||||
* @todo : implement vertice class or use vertice class used by graphs? May be usefull in order to give vertices IDs!
|
|
||||||
*/
|
*/
|
||||||
final class MonotoneChain
|
final class MonotoneChain
|
||||||
{
|
{
|
||||||
|
|
@ -40,7 +38,7 @@ final class MonotoneChain
|
||||||
/**
|
/**
|
||||||
* Create convex hull
|
* Create convex hull
|
||||||
*
|
*
|
||||||
* @param array<string, int|float> $points Points (Point Cloud)
|
* @param array<int, array<string, int|float>> $points Points (Point Cloud)
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -102,16 +102,23 @@ final class Polygon implements D2ShapeInterface
|
||||||
$countIntersect = 0;
|
$countIntersect = 0;
|
||||||
$polygonCount = count($polygon);
|
$polygonCount = count($polygon);
|
||||||
|
|
||||||
// todo: return based on highest possibility not by first match
|
|
||||||
for ($i = 1; $i < $polygonCount; ++$i) {
|
for ($i = 1; $i < $polygonCount; ++$i) {
|
||||||
$vertex1 = $polygon[$i - 1];
|
$vertex1 = $polygon[$i - 1];
|
||||||
$vertex2 = $polygon[$i];
|
$vertex2 = $polygon[$i];
|
||||||
|
|
||||||
if (abs($vertex1['y'] - $vertex2['y']) < self::EPSILON && abs($vertex1['y'] - $point['y']) < self::EPSILON && $point['x'] > min($vertex1['x'], $vertex2['x']) && $point['x'] < max($vertex1['x'], $vertex2['x'])) {
|
if (abs($vertex1['y'] - $vertex2['y']) < self::EPSILON
|
||||||
|
&& abs($vertex1['y'] - $point['y']) < self::EPSILON
|
||||||
|
&& $point['x'] > min($vertex1['x'], $vertex2['x'])
|
||||||
|
&& $point['x'] < max($vertex1['x'], $vertex2['x'])
|
||||||
|
) {
|
||||||
return 0; // boundary
|
return 0; // boundary
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($point['y'] > min($vertex1['y'], $vertex2['y']) && $point['y'] <= max($vertex1['y'], $vertex2['y']) && $point['x'] <= max($vertex1['x'], $vertex2['x']) && abs($vertex1['y'] - $vertex2['y']) >= self::EPSILON) {
|
if ($point['y'] > min($vertex1['y'], $vertex2['y'])
|
||||||
|
&& $point['y'] <= max($vertex1['y'], $vertex2['y'])
|
||||||
|
&& $point['x'] <= max($vertex1['x'], $vertex2['x'])
|
||||||
|
&& abs($vertex1['y'] - $vertex2['y']) >= self::EPSILON
|
||||||
|
) {
|
||||||
$xinters = ($point['y'] - $vertex1['y']) * ($vertex2['x'] - $vertex1['x']) / ($vertex2['y'] - $vertex1['y']) + $vertex1['x'];
|
$xinters = ($point['y'] - $vertex1['y']) * ($vertex2['x'] - $vertex1['x']) / ($vertex2['y'] - $vertex1['y']) + $vertex1['x'];
|
||||||
|
|
||||||
if (abs($xinters - $point['x']) < self::EPSILON) {
|
if (abs($xinters - $point['x']) < self::EPSILON) {
|
||||||
|
|
|
||||||
|
|
@ -672,19 +672,6 @@ class Matrix implements \ArrayAccess, \Iterator
|
||||||
return $sign;
|
return $sign;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Lower triangulize matrix.
|
|
||||||
*
|
|
||||||
* @return Matrix
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
public function lowerTriangular() : Matrix
|
|
||||||
{
|
|
||||||
// todo: implement
|
|
||||||
return new Matrix($this->m, $this->n);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inverse matrix.
|
* Inverse matrix.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -67,8 +67,6 @@ final class Request extends RequestAbstract
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @todo: maybe change to normal path string e.g. /some/path/here instead of hash! Remember to adjust navigation elements
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function createRequestHashs(int $start = 0) : void
|
public function createRequestHashs(int $start = 0) : void
|
||||||
|
|
|
||||||
|
|
@ -58,8 +58,6 @@ final class Header extends HeaderAbstract
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* @todo Allow to extend header key with additional values.
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function set(string $key, string $header, bool $overwrite = false) : bool
|
public function set(string $key, string $header, bool $overwrite = false) : bool
|
||||||
|
|
|
||||||
|
|
@ -183,9 +183,9 @@ final class Request extends RequestAbstract
|
||||||
*/
|
*/
|
||||||
private function setupUriBuilder() : void
|
private function setupUriBuilder() : void
|
||||||
{
|
{
|
||||||
|
UriFactory::clean('?');
|
||||||
UriFactory::setQuery('/lang', $this->header->getL11n()->getLanguage());
|
UriFactory::setQuery('/lang', $this->header->getL11n()->getLanguage());
|
||||||
|
|
||||||
// todo: flush previous
|
|
||||||
foreach ($this->data as $key => $value) {
|
foreach ($this->data as $key => $value) {
|
||||||
UriFactory::setQuery('?' . $key, $value);
|
UriFactory::setQuery('?' . $key, $value);
|
||||||
}
|
}
|
||||||
|
|
@ -221,8 +221,6 @@ final class Request extends RequestAbstract
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @todo: maybe change to normal path string e.g. /some/path/here instead of hash! Remember to adjust navigation elements
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function createRequestHashs(int $start = 0) : void
|
public function createRequestHashs(int $start = 0) : void
|
||||||
|
|
@ -249,7 +247,6 @@ final class Request extends RequestAbstract
|
||||||
*/
|
*/
|
||||||
public function isMobile() : bool
|
public function isMobile() : bool
|
||||||
{
|
{
|
||||||
// TODO: maybe replace this with smart media queries... checked gets handled in reverse!!!
|
|
||||||
$useragent = $_SERVER['HTTP_USER_AGENT'] ?? '';
|
$useragent = $_SERVER['HTTP_USER_AGENT'] ?? '';
|
||||||
|
|
||||||
if (\preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i', $useragent) || \preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i', $useragent)) {
|
if (\preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i', $useragent) || \preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i', $useragent)) {
|
||||||
|
|
|
||||||
|
|
@ -396,14 +396,7 @@ final class ModuleManager
|
||||||
$this->activateModule($info);
|
$this->activateModule($info);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (PathException $e) {
|
|
||||||
// todo: handle module doesn't exist or files are missing
|
|
||||||
//echo $e->getMessage();
|
|
||||||
|
|
||||||
return false;
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
//echo $e->getMessage();
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -151,8 +151,7 @@ class SmartDateTime extends \DateTime
|
||||||
*/
|
*/
|
||||||
public function getDaysOfMonth() : int
|
public function getDaysOfMonth() : int
|
||||||
{
|
{
|
||||||
// todo: maybe ->format('t') is better
|
return (int) $this->format('t');
|
||||||
return cal_days_in_month(CAL_GREGORIAN, (int) $this->format('m'), (int) $this->format('Y'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -181,12 +181,13 @@ interface ContainerInterface
|
||||||
*
|
*
|
||||||
* @param string $path Path of the resource
|
* @param string $path Path of the resource
|
||||||
* @param string $replace Replace invalid chars with
|
* @param string $replace Replace invalid chars with
|
||||||
|
* @param string $invalid Invalid chars to sanitize
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function sanitize(string $path, string $replace = '') : string;
|
public static function sanitize(string $path, string $replace = '', string $invalid = '/[^\w\s\d\.\-_~,;\/\[\]\(\]]/') : string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get amount of sub-resources.
|
* Get amount of sub-resources.
|
||||||
|
|
|
||||||
|
|
@ -165,9 +165,9 @@ class Directory extends FileAbstract implements DirectoryInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public static function sanitize(string $path, string $replace = '') : string
|
public static function sanitize(string $path, string $replace = '', string $invalid = '/[^\w\s\d\.\-_~,;\/\[\]\(\]]/') : string
|
||||||
{
|
{
|
||||||
return DirectoryLocal::sanitize($path, $replace);
|
return DirectoryLocal::sanitize($path, $replace, $invalid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -187,9 +187,9 @@ class File extends FileAbstract implements FileInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public static function sanitize(string $path, string $replace = '') : string
|
public static function sanitize(string $path, string $replace = '', string $invalid = '/[^\w\s\d\.\-_~,;\/\[\]\(\]]/') : string
|
||||||
{
|
{
|
||||||
return LocalFile::sanitize($path, $replace);
|
return LocalFile::sanitize($path, $replace, $invalid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -370,9 +370,9 @@ final class Directory extends FileAbstract implements DirectoryInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public static function sanitize(string $path, string $replace = '') : string
|
public static function sanitize(string $path, string $replace = '', string $invalid = '/[^\w\s\d\.\-_~,;:\[\]\(\]\/]/') : string
|
||||||
{
|
{
|
||||||
return \preg_replace('[^\w\s\d\.\-_~,;:\[\]\(\]\/]', $replace, $path);
|
return \preg_replace($invalid, $replace, $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -152,9 +152,9 @@ final class File extends FileAbstract implements FileInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public static function sanitize(string $path, string $replace = '') : string
|
public static function sanitize(string $path, string $replace = '', string $invalid = '/[^\w\s\d\.\-_~,;\/\[\]\(\]]/') : string
|
||||||
{
|
{
|
||||||
return \preg_replace('/[^\w\s\d\.\-_~,;\/\[\]\(\]]/', $replace, $path);
|
return \preg_replace($invalid, $replace, $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,28 @@ final class UriFactory
|
||||||
return self::$uri[$key] ?? null;
|
return self::$uri[$key] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleanup
|
||||||
|
*
|
||||||
|
* @param string $identifier Identifier for cleaning up (e.g. * = everything, / = only path, ? = only query parameters, # only fragment etc.)
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public static function clean(string $identifier = '?') : void
|
||||||
|
{
|
||||||
|
if ($identifier === '*') {
|
||||||
|
self::$uri = [];
|
||||||
|
} else {
|
||||||
|
foreach (self::$uri as $key => $value) {
|
||||||
|
if (\stripos($key, $identifier) === 0) {
|
||||||
|
unset(self::$uri[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set global query replacements.
|
* Set global query replacements.
|
||||||
*
|
*
|
||||||
|
|
@ -81,20 +103,6 @@ final class UriFactory
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear all uri components
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
public static function clearAll() : bool
|
|
||||||
{
|
|
||||||
self::$uri = [];
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup uri builder based on current request
|
* Setup uri builder based on current request
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -376,8 +376,6 @@ class Repository
|
||||||
throw new PathException($source);
|
throw new PathException($source);
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: is valid git repository?
|
|
||||||
|
|
||||||
return implode("\n", $this->run('clone --local ' . $source . ' ' . $this->path));
|
return implode("\n", $this->run('clone --local ' . $source . ' ' . $this->path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -392,8 +390,6 @@ class Repository
|
||||||
*/
|
*/
|
||||||
public function cloneRemote(string $source) : string
|
public function cloneRemote(string $source) : string
|
||||||
{
|
{
|
||||||
// todo: is valid remote git repository?
|
|
||||||
|
|
||||||
return implode("\n", $this->run('clone ' . $source . ' ' . $this->path));
|
return implode("\n", $this->run('clone ' . $source . ' ' . $this->path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ class UriFactoryTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertNull(UriFactory::getQuery('Valid'));
|
self::assertNull(UriFactory::getQuery('Valid'));
|
||||||
self::assertEquals('query4', UriFactory::getQuery('/valid2'));
|
self::assertEquals('query4', UriFactory::getQuery('/valid2'));
|
||||||
|
|
||||||
self::assertTrue(UriFactory::clearAll());
|
self::assertTrue(UriFactory::clean('*'));
|
||||||
self::assertNull(UriFactory::getQuery('/valid2'));
|
self::assertNull(UriFactory::getQuery('/valid2'));
|
||||||
|
|
||||||
self::assertTrue(UriFactory::setQuery('/abc', 'query1'));
|
self::assertTrue(UriFactory::setQuery('/abc', 'query1'));
|
||||||
|
|
@ -59,6 +59,9 @@ class UriFactoryTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertNull(UriFactory::getQuery('/valid2'));
|
self::assertNull(UriFactory::getQuery('/valid2'));
|
||||||
self::assertNull(UriFactory::getQuery('/valid3'));
|
self::assertNull(UriFactory::getQuery('/valid3'));
|
||||||
self::assertEquals('query1', UriFactory::getQuery('/abc'));
|
self::assertEquals('query1', UriFactory::getQuery('/abc'));
|
||||||
|
|
||||||
|
self::assertTrue(UriFactory::clean('/'));
|
||||||
|
self::assertNull(UriFactory::getQuery('/abc'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBuilder()
|
public function testBuilder()
|
||||||
|
|
|
||||||
|
|
@ -114,10 +114,6 @@ class ViewTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
$view->setTemplate('/phpOMS/tests/Views/testTemplate');
|
$view->setTemplate('/phpOMS/tests/Views/testTemplate');
|
||||||
self::assertEquals('<strong>Test</strong>', $view->render());
|
self::assertEquals('<strong>Test</strong>', $view->render());
|
||||||
|
|
||||||
// todo: why is this failing?
|
|
||||||
//$view->setTemplate('phpOMS/tests/Views/testArray');
|
|
||||||
//self::assertEquals([1, 2, 3], $view->render());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user