new pisilinux web sites

This commit is contained in:
Erkan IŞIK
2026-07-01 16:44:17 +03:00
commit b58488b586
21740 changed files with 2066209 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
<?php namespace ZN\Helpers;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Helpers\Exception\LogicException;
class Cleaner
{
/**
* Clean Data
*
* @param mixed $searchData
* @param mixed $cleanWord
*
* @return mixed
*/
public static function data($searchData, $cleanWord)
{
if( length($cleanWord) > length($searchData) )
{
throw new LogicException('[Cleaner::data()] -> 3.($cleanWord) parameter not be longer than 2.($searchData) parameter!');
}
if( ! is_array($searchData) )
{
$result = str_replace($cleanWord ?? '', '', $searchData ?? '');
}
else
{
if( ! is_array($cleanWord) )
{
$cleanWordArray[] = $cleanWord;
}
else
{
$cleanWordArray = $cleanWord;
}
$result = array_diff($searchData, $cleanWordArray);
}
return $result;
}
}
+489
View File
@@ -0,0 +1,489 @@
<?php namespace ZN\Helpers;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Base;
use ZN\Helper;
use ZN\Config;
use ZN\Datatype;
use ZN\Singleton;
use ZN\Filesystem;
use ZN\DataTypes\Objects;
use ZN\Helpers\Exception\LogicException;
use ZN\Helpers\Exception\InvalidArgumentException;
class Converter
{
/**
* Keeps Accent Chars
*
* @var array
*/
public static $accentChars =
[
'ä|æ|ǽ' => 'ae',
'œ' => 'oe',
'Ä' => 'Ae',
'À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ|Α|Ά|Ả|Ạ|Ầ|Ẫ|Ẩ|Ậ|Ằ|Ắ|Ẵ|Ẳ|Ặ|А' => 'A',
'à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª|α|ά|ả|ạ|ầ|ấ|ẫ|ẩ|ậ|ằ|ắ|ẵ|ẳ|ặ|а' => 'a',
'Б' => 'B',
'б' => 'b',
'Ç|Ć|Ĉ|Ċ|Č' => 'C',
'ç|ć|ĉ|ċ|č' => 'c',
'Д' => 'D',
'д' => 'd',
'Ð|Ď|Đ|Δ' => 'Dj',
'ð|ď|đ|δ' => 'dj',
'È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě|Ε|Έ|Ẽ|Ẻ|Ẹ|Ề|Ế|Ễ|Ể|Ệ|Е|Э' => 'E',
'è|é|ê|ë|ē|ĕ|ė|ę|ě|έ|ε|ẽ|ẻ|ẹ|ề|ế|ễ|ể|ệ|е|э' => 'e',
'Ф' => 'F',
'ф' => 'f',
'Ĝ|Ğ|Ġ|Ģ|Γ|Г|Ґ' => 'G',
'ĝ|ğ|ġ|ģ|γ|г|ґ' => 'g',
'Ĥ|Ħ' => 'H',
'ĥ|ħ' => 'h',
'Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ|Η|Ή|Ί|Ι|Ϊ|Ỉ|Ị|И|Ы' => 'I',
'ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı|η|ή|ί|ι|ϊ|ỉ|ị|и|ы|ї' => 'i',
'Ĵ' => 'J',
'ĵ' => 'j',
'Ķ|Κ|К' => 'K',
'ķ|κ|к' => 'k',
'Ĺ|Ļ|Ľ|Ŀ|Ł|Λ|Л' => 'L',
'ĺ|ļ|ľ|ŀ|ł|λ|л' => 'l',
'М' => 'M',
'м' => 'm',
'Ñ|Ń|Ņ|Ň|Ν|Н' => 'N',
'ñ|ń|ņ|ň|ʼn|ν|н' => 'n',
'Ö|Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ|Ο|Ό|Ω|Ώ|Ỏ|Ọ|Ồ|Ố|Ỗ|Ổ|Ộ|Ờ|Ớ|Ỡ|Ở|Ợ|О' => 'O',
'ö|ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º|ο|ό|ω|ώ|ỏ|ọ|ồ|ố|ỗ|ổ|ộ|ờ|ớ|ỡ|ở|ợ|о' => 'o',
'П' => 'P',
'п' => 'p',
'Ŕ|Ŗ|Ř|Ρ|Р' => 'R',
'ŕ|ŗ|ř|ρ|р' => 'r',
'Ś|Ŝ|Ş|Ș|Š|Σ|С' => 'S',
'ś|ŝ|ş|ș|š|ſ|σ|ς|с' => 's',
'Ț|Ţ|Ť|Ŧ|τ|Т' => 'T',
'ț|ţ|ť|ŧ|т' => 't',
'Ü|Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ|Ũ|Ủ|Ụ|Ừ|Ứ|Ữ|Ử|Ự|У' => 'U',
'ü|ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ|υ|ύ|ϋ|ủ|ụ|ừ|ứ|ữ|ử|ự|у' => 'u',
'Ý|Ÿ|Ŷ|Υ|Ύ|Ϋ|Ỳ|Ỹ|Ỷ|Ỵ|Й' => 'Y',
'ý|ÿ|ŷ|ỳ|ỹ|ỷ|ỵ|й' => 'y',
'В' => 'V',
'в' => 'v',
'Ŵ' => 'W',
'ŵ' => 'w',
'Ź|Ż|Ž|Ζ|З' => 'Z',
'ź|ż|ž|ζ|з' => 'z',
'Æ|Ǽ' => 'AE',
'ß' => 'ss',
'IJ' => 'IJ',
'ij' => 'ij',
'Œ' => 'OE',
'ƒ' => 'f',
'ξ' => 'ks',
'π' => 'p',
'β' => 'v',
'μ' => 'm',
'ψ' => 'ps',
'Ё' => 'Yo',
'ё' => 'yo',
'Є' => 'Ye',
'є' => 'ye',
'Ї' => 'Yi',
'Ж' => 'Zh',
'ж' => 'zh',
'Х' => 'Kh',
'х' => 'kh',
'Ц' => 'Ts',
'ц' => 'ts',
'Ч' => 'Ch',
'ч' => 'ch',
'Ш' => 'Sh',
'ш' => 'sh',
'Щ' => 'Shch',
'щ' => 'shch',
'Ъ|ъ|Ь|ь' => '',
'Ю' => 'Yu',
'ю' => 'yu',
'Я' => 'Ya',
'я' => 'ya'
];
/**
* Convert string to bytes.
*
* @param string $data
*
* @return float
*/
public static function toBytes(string $data) : Float
{
$number = substr($data, 0, -2);
switch( strtoupper(substr($data, -2)) )
{
case 'KB': return $number * 1024;
case 'MB': return $number * pow(1024, 2);
case 'GB': return $number * pow(1024, 3);
case 'TB': return $number * pow(1024, 4);
case 'PB': return $number * pow(1024, 5);
default : return $data;
}
}
/**
* Calculate byte
*
* @param float $bytes
* @param int $precision = 1
* @param bool $unit = true
* @param string $fix = ''
*
* @return string
*/
public static function byte(Float $bytes, int $precision = 1, bool $unit = true, string $fix = '') : string
{
$byte = 1024;
$kb = 1024 * $byte;
$mb = 1024 * $kb;
$gb = 1024 * $mb;
$tb = 1024 * $gb;
$pb = 1024 * $tb;
$eb = 1024 * $pb;
if( $bytes <= $byte && $bytes > -1 )
{
$un = 'B';
$return = $bytes;
}
elseif( $bytes <= $kb && $bytes > $byte )
{
$un = 'KB';
$return = round(($bytes / $byte),$precision);
}
elseif( $bytes <= $mb && $bytes > $kb )
{
$un = 'MB';
$return = round(($bytes / $kb),$precision);
}
elseif( $bytes <= $gb && $bytes > $mb )
{
$un = 'GB';
$return = round(($bytes / $mb),$precision);
}
elseif( $bytes <= $tb && $bytes > $gb )
{
$un = 'TB';
$return = round(($bytes / $gb),$precision);
}
elseif( $bytes <= $pb && $bytes > $tb )
{
$un = 'PB';
$return = round(($bytes / $tb),$precision);
}
elseif( $bytes <= $eb && $bytes > $pb )
{
$un = 'EB';
$return = round(($bytes / $pb),$precision);
}
else
{
$un = 'B';
$return = str_replace(",", ".", number_format($bytes));
}
return $return . ( ! empty($unit) ? $fix . $un : NULL );
}
/**
* Convert Money
*
* @param float $money = 0
* @param string $type = NULL
* @param bool $float = true
*
* @return string
*/
public static function money(Float $money = 0, ?string $type = NULL, bool $float = true) : string
{
$moneyFormat = number_format($money, 2, ',', '.');
if( $float === false )
{
$moneyFormat = explode(',', $moneyFormat)[0];
}
# 5.3.9[added]
if( ($type[0] ?? NULL) === '!' )
{
$left = ltrim($type, '!') . ' ';
$right = '';
}
else
{
$right = ' ' . $type;
$left = '';
}
$moneyFormat = trim($left . $moneyFormat . $right);
return $moneyFormat;
}
/**
* Money to Number
*
* @param string|int
*
* @return float
*/
public static function moneyToNumber($money) : Float
{
return str_replace('.', '', Datatype::divide($money, ','));
}
/**
* Convert time
*
* @param int $count
* @param string $type = 'second'
* @param string $output = 'day'
*
* @return float
*/
public static function time(int $count, string $type = 'second', string $output = 'day') : Float
{
switch( Base::removeSuffix($output, 's') )
{
case 'second': $out = 1; break;
case 'minute': $out = 60; break;
case 'hour' : $out = 60 * 60; break;
case 'day' : $out = 60 * 60 * 24; break;
case 'week' : $out = 60 * 60 * 24 * 7; break;
case 'month' : $out = 60 * 60 * 24 * 30; break;
case 'year' : $out = 60 * 60 * 24 * 30 * 12; break;
}
switch( Base::removeSuffix($type, 's') )
{
case 'second': $time = $count; break;
case 'minute': $time = 60 * $count; break;
case 'hour' : $time = 60 * 60 * $count; break;
case 'day' : $time = 60 * 60 * 24 * $count; break;
case 'week' : $time = 60 * 60 * 24 * 7 * $count; break;
case 'month' : $time = 60 * 60 * 24 * 30 * $count; break;
case 'year' : $time = 60 * 60 * 24 * 30 * 12 * $count; break;
}
return $time / $out;
}
/**
* Convert word
*
* @param string $string
* @param mixed $badWords = NULL
* @param mixed $changeChar = '[badwords]'
*
* @return string
*/
public static function word(string $string, $badWords = NULL, $changeChar = '[badwords]') : string
{
return str_ireplace($badWords ?? '', $changeChar, $string);
}
/**
* Creates anchor
*
* @param string $data
* @param string $type = 'short'
* @param array $attributes = NULL
*
* @return string
*/
public static function anchor(string $data, string $type = 'short', ?array $attributes = NULL) : string
{
return preg_replace
(
'/(^|\s|>)(((https?|ftp)\:\/\/)(\w+\.)*(\w+)\.[^<>\s]+)/xi',
'$1<a href="$2"'.Singleton::class('ZN\Hypertext\Html')->attributes((array) $attributes).'>'.( $type === 'short' ? '$6' : '$2').'</a>',
$data
);
}
/**
* Convert high lightin
*
* @param string $str
* @param array $settings
*
* @return string
*/
public static function highLight(string $str, array $settings = []) : string
{
return Helper::highLight($str, $settings);
}
/**
* Convert char
*
* @param string $string
* @param string $type - options[char|dec|hex|html]
* @param string $changeType - options[char|dec|hex|html]
*
* @return string
*/
public static function char(string $string, string $type = 'char', string $changeType = 'html') : string
{
$options = ['char', 'html', 'hex', 'dec'];
if( ! in_array($type, $options) || ! in_array($changeType, $options) )
{
throw new InvalidArgumentException('[Converter::char()] -> Available Options: [char], [html], [hex], [dec] For 2.($type) & 3.($changeType)!');
}
if( $type === $changeType )
{
throw new LogicException('[Converter::char()] -> 2.($type) & 3.($changeType) parameters [can not be equal]!');
}
$string = self::accent($string);
for( $i = 32; $i <= 255; $i++ )
{
$hexRemaining = ( $i % 16 );
$hexRemaining = str_replace( [10, 11, 12, 13, 14, 15], ['A', 'B', 'C', 'D', 'E', 'F'], $hexRemaining );
$hex = ( floor( $i / 16) ) . $hexRemaining;
if( chr($i) !== ' ' )
{
$chars['char'][] = chr($i);
$chars['dec'][] = $i." ";
$chars['hex'][] = $hex." ";
$chars['html'][] = "&#{$i};";
}
}
return trim(str_replace( $chars[strtolower($type)], $chars[strtolower($changeType)], $string ));
}
/**
* Converter Accent Char
*
* [fixed]5.7.6
*
* @param string $str
*
* @return string
*/
public static function accent(string $str) : string
{
$accent = array_merge(Config::get('Expressions', 'accentChars') ?: [], self::$accentChars);
$accent = Datatype::multikey($accent);
return str_replace(array_keys($accent), array_values($accent), $str);
}
/**
* Convert URL word
*
* @param string $str
*
* @return string
*/
public static function urlWord(string $str) : string
{
return self::slug($str);
}
/**
* Convert slug
*
* @param string $str
* @param string $protectExtension = false
*
* @return string
*/
public static function slug(string $str, bool $protectExtension = false) : string
{
if( $protectExtension === true )
{
$ext = Filesystem::getExtension($str, true);
$str = Filesystem::removeExtension($str);
}
$str = self::accent(trim($str));
$str = preg_replace('/\&\#*\w+\;/', '' , $str);
$str = preg_replace("/\W/" , '-', $str);
$str = preg_replace("/\_/" , '-', $str);
$str = preg_replace('/\-+/' , '-', $str);
return mb_convert_case(trim($str, '-'), MB_CASE_LOWER) . ($ext ?? NULL);
}
/**
* Convert charset
*
* @param string $str
* @param string $fromCharset
* @param string $toCharset = 'utf-8'
*
* @return string
*/
public static function charset(string $str, string $fromCharset, string $toCharset = 'utf-8') : string
{
return mb_convert_encoding($str, $fromCharset, $toCharset);
}
/**
* Convert to string
*
* @param mixed $var
*
* @return string
*/
public static function toString($var) : string
{
if( is_array($var) || is_object($var) )
{
return implode(' ', (array) $var);
}
return (string) $var;
}
/**
* Convert to object recursive
*
* @param array $var
*
* @return object
*/
public static function toObjectRecursive(array $var)
{
return new Objects($var);
}
/**
* Convert to constant
*
* @param string $var
* @param string $prefix = NULL
* @param string $suffix = NULL
*/
public static function toConstant(string $var, ?string $prefix = NULL, ?string $suffix = NULL)
{
return Helper::toConstant($var, $prefix, $suffix);
}
}
+128
View File
@@ -0,0 +1,128 @@
<?php namespace ZN\Helpers;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use stdClass;
use ZN\Classes;
use ZN\DataTypes\Arrays;
class Debugger
{
/**
* Keeps Debug Data
*
* @var array
*/
protected $debug;
/**
* Magic Constructor
*/
public function __construct()
{
$debug = debug_backtrace();
$this->debug = Arrays\RemoveElement::first($debug, 3);
}
/**
* Current Debug Data
*
* @return object
*/
public function current() : stdClass
{
return $this->layerInfo($this->debug, 0, 1);
}
/**
* Parent Debug Data
*
* @param int $index = 1
*
* @return object
*/
public function parent(int $index = 1) : stdClass
{
return $this->layerInfo($this->debug, $index, $index + 1);
}
/**
* Output Debug
*
* @param mixed $type = 'array' - options[array|string|int value]
*
* @return mixed
*/
public function output($type = 'array')
{
$debug = Arrays\RemoveElement::first($this->debug, 2);
$debug = array_merge([(array) $this->current()], $debug);
if( is_numeric($type) )
{
return (object) ( $debug[$type] ?? $this->defaultVariables() );
}
else if( $type === 'array' )
{
return $debug;
}
else
{
return $this->defaultVariables();
}
}
/**
* Protected Layer
*/
protected function layerInfo($debug, $layer1 = 0, $layer2 = 1)
{
$file = $debug[$layer1]['file'] ?? NULL;
$line = $debug[$layer1]['line'] ?? NULL;
$function = $debug[$layer2]['function'] ?? NULL;
$class = $debug[$layer2]['class'] ?? NULL;
$args = $debug[$layer2]['args'] ?? NULL;
$type = $debug[$layer1]['type'] ?? NULL;
$type = str_replace('->', '::', $type ?? '');
$classSuffix = $type.$function.'()';
$method = $class.$classSuffix;
$internalMethod = Classes::onlyName((string) $class).$classSuffix;
return (object)
[
'file' => $file,
'line' => $line,
'args' => $args,
'function' => $function,
'class' => $class,
'type' => $type,
'method' => $method,
'internalMethod' => $internalMethod
];
}
/**
* Protected Default
*/
protected function defaultVariables()
{
return (object)
[
'file' => NULL,
'line' => NULL,
'function' => NULL,
'class' => NULL,
'type' => NULL,
'method' => NULL,
'internalMethod' => NULL
];
}
}
@@ -0,0 +1,17 @@
<?php namespace ZN\Helpers\Exception;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Ability\Exclusion;
class InvalidArgumentException extends \InvalidArgumentException
{
use Exclusion;
}
@@ -0,0 +1,17 @@
<?php namespace ZN\Helpers\Exception;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Ability\Exclusion;
class LogicException extends \LogicException
{
use Exclusion;
}
+22
View File
@@ -0,0 +1,22 @@
<?php namespace ZN\Helpers;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Ability\Fabrication;
class Iterate
{
use Fabrication;
const fabrication =
[
'suffix' => 'Iterator'
];
}
+79
View File
@@ -0,0 +1,79 @@
<?php namespace ZN\Helpers;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
class Limiter
{
/**
* Limit word
*
* @param string $str
* @param int $limit = 100
* @param string $endChar = '...'
* @param bool $stripTags = true
* @param string $encoding = 'utf-8'
*
* @return string
*/
public static function word(string $str, int $limit = 100, string $endChar = '...', bool $stripTags = true, string $encoding = "utf-8") : string
{
$str = trim($str);
if( $stripTags === true )
{
$str = strip_tags($str);
}
$str = str_replace(["\n","\r","&nbsp;"], " ", $str);
preg_match('/^\s*+(?:\S++\s*+){1,'.(int) $limit.'}/', $str, $matches);
$match = $matches[0] ?? '';
if( mb_strlen($str, $encoding) === mb_strlen($match, $encoding) )
{
$endChar = '';
}
return rtrim($match) . $endChar;
}
/**
* Limit char
*
* @param string $str
* @param int $limit = 500
* @param string $endChar = '...'
* @param bool $stripTags = true
* @param string $encoding = 'utf-8'
*
* @return string
*/
public static function char(string $str, int $limit = 500, string $endChar = '...', bool $stripTags = false, string $encoding = "utf-8") : string
{
$str = trim($str);
if( $stripTags === true )
{
$str = strip_tags($str);
}
$str = preg_replace("/\s+/", ' ', str_replace(["\r\n", "\r", "\n", "&nbsp;"], ' ', $str));
if( mb_strlen($str, $encoding) <= $limit )
{
return $str;
}
else
{
return mb_substr($str, 0, $limit, $encoding).$endChar;
}
}
}
+134
View File
@@ -0,0 +1,134 @@
<?php namespace ZN\Helpers;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Helper;
class Logger implements LoggerInterface
{
/**
* Notice log
*
* @param string $message
* @param string $time
*
* @return bool
*/
public static function notice(string $message, ?string $time = NULL)
{
return self::report(__FUNCTION__, $message, NULL, $time);
}
/**
* Emergency log
*
* @param string $message
* @param string $time
*
* @return bool
*/
public static function emergency(string $message, ?string $time = NULL)
{
return self::report(__FUNCTION__, $message, NULL, $time);
}
/**
* Alert log
*
* @param string $message
* @param string $time
*
* @return bool
*/
public static function alert(string $message, ?string $time = NULL)
{
return self::report(__FUNCTION__, $message, NULL, $time);
}
/**
* Error log
*
* @param string $message
* @param string $time
*
* @return bool
*/
public static function error(string $message, ?string $time = NULL)
{
return self::report(__FUNCTION__, $message, NULL, $time);
}
/**
* Warning log
*
* @param string $message
* @param string $time
*
* @return bool
*/
public static function warning(string $message, ?string $time = NULL)
{
return self::report(__FUNCTION__, $message, NULL, $time);
}
/**
* Critical log
*
* @param string $message
* @param string $time
*
* @return bool
*/
public static function critical(string $message, ?string $time = NULL)
{
return self::report(__FUNCTION__, $message, NULL, $time);
}
/**
* Info log
*
* @param string $message
* @param string $time
*
* @return bool
*/
public static function info(string $message, ?string $time = NULL)
{
return self::report(__FUNCTION__, $message, NULL, $time);
}
/**
* Debug log
*
* @param string $message
* @param string $time
*
* @return bool
*/
public static function debug(string $message, ?string $time = NULL)
{
return self::report(__FUNCTION__, $message, NULL, $time);
}
/**
* Report log
*
* @param string $subject
* @param string $message
* @param string $destination
* @param string $time
*
* @return bool
*/
public static function report(string $subject, string $message, ?string $destination = NULL, ?string $time = NULL) : bool
{
return Helper::report($subject, $message, $destination, $time);
}
}
@@ -0,0 +1,105 @@
<?php namespace ZN\Helpers;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
interface LoggerInterface
{
/**
* Notice log
*
* @param string $message
* @param string $time
*
* @return bool
*/
public static function notice(string $message, ?string $time = NULL);
/**
* Emergency log
*
* @param string $message
* @param string $time
*
* @return bool
*/
public static function emergency(string $message, ?string $time = NULL);
/**
* Alert log
*
* @param string $message
* @param string $time
*
* @return bool
*/
public static function alert(string $message, ?string $time = NULL);
/**
* Error log
*
* @param string $message
* @param string $time
*
* @return bool
*/
public static function error(string $message, ?string $time = NULL);
/**
* Warning log
*
* @param string $message
* @param string $time
*
* @return bool
*/
public static function warning(string $message, ?string $time = NULL);
/**
* Critical log
*
* @param string $message
* @param string $time
*
* @return bool
*/
public static function critical(string $message, ?string $time = NULL);
/**
* Info log
*
* @param string $message
* @param string $time
*
* @return bool
*/
public static function info(string $message, ?string $time = NULL);
/**
* Debug log
*
* @param string $message
* @param string $time
*
* @return bool
*/
public static function debug(string $message, ?string $time = NULL);
/**
* Report log
*
* @param string $subject
* @param string $message
* @param string $destination
* @param string $time
*
* @return bool
*/
public static function report(string $subject, string $message, ?string $destination = NULL, ?string $time = NULL) : bool;
}
+602
View File
@@ -0,0 +1,602 @@
<?php namespace ZN\Helpers;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Base;
use ZN\Config;
class Mime
{
/**
* Magic Call
*
* @param string $method
* @param array $parameters
*
* @return array|string|bool|false
*/
public function __call($method, $parameters)
{
if( strpos($method, 'is') === 0 )
{
$type = Base::removePrefix($method, 'is');
return (bool) stristr($this->type(...$parameters), $type);
}
return $this->mimeTypes[$method] ?? false;
}
/**
* Magic Constructor
*/
public function __construct()
{
$this->mimeTypes = array_merge(Config::get('Expressions', 'mimeTypes') ?: [], $this->mimeTypes);
}
/**
* Mime Content Type
*
* @param string $file
* @param mixed $element = NULL
*
* @return string|false
*/
public static function type(string $file, $element = NULL)
{
if( ! is_file($file) )
{
return false;
}
$return = mime_content_type($file);
if( $element === NULL )
{
return $return;
}
return explode('/', $return)[$element] ?? false;
}
/**
* Keeps Standart Mime Types
*
* @var array
*/
public $mimeTypes =
[
# A
'aac' => 'audio/x-acc',
'ac3' => 'audio/ac3',
'ai' =>
[
'application/pdf',
'application/postscript'
],
'aifc' => 'audio/x-aiff',
'aif' =>
[
'audio/x-aiff',
'audio/aiff'
],
'aiff' =>
[
'audio/x-aiff',
'audio/aiff'
],
'au' => 'audio/x-au',
'avi' =>
[
'video/x-msvideo',
'video/msvideo',
'video/avi',
'application/x-troff-msvideo'
],
# A
# B
'bin' =>
[
'application/macbinary',
'application/mac-binary',
'application/octet-stream',
'application/x-binary',
'application/x-macbinary'
],
'bmp' =>
[
'image/bmp',
'image/x-bmp',
'image/x-bitmap',
'image/x-xbitmap',
'image/x-win-bitmap',
'image/x-windows-bmp',
'image/ms-bmp',
'image/x-ms-bmp',
'application/bmp',
'application/x-bmp',
'application/x-win-bitmap'
],
# B
# C
'cdr' =>
[
'application/cdr',
'application/coreldraw',
'application/x-cdr',
'application/x-coreldraw',
'image/cdr',
'image/x-cdr',
'zz-application/zz-winassoc-cdr'
],
'cer' =>
[
'application/pkix-cert',
'application/x-x509-ca-cert'
],
'class' => 'application/octet-stream',
'cpt' => 'application/mac-compactpro',
'crl' =>
[
'application/pkix-crl',
'application/pkcs-crl'
],
'crt' =>
[
'application/x-x509-ca-cert',
'application/x-x509-user-cert',
'application/pkix-cert'
],
'csr' => 'application/octet-stream',
'css' =>
[
'text/css',
'text/plain'
],
'csv' =>
[
'text/x-comma-separated-values',
'text/comma-separated-values',
'application/octet-stream',
'application/vnd.ms-excel',
'application/x-csv',
'text/x-csv',
'text/csv',
'application/csv',
'application/excel',
'application/vnd.msexcel',
'text/plain'
],
# C
# D
'dcr' => 'application/x-director',
'der' => 'application/x-x509-ca-cert',
'dir' => 'application/x-director',
'dll' => 'application/octet-stream',
'dms' => 'application/octet-stream',
'doc' =>
[
'application/msword',
'application/vnd.ms-office'
],
'docx' =>
[
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/zip',
'application/msword',
'application/x-zip'
],
'dot' =>
[
'application/msword',
'application/vnd.ms-office'
],
'dotx' =>
[
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/zip',
'application/msword'
],
'dvi' => 'application/x-dvi',
'dxr' => 'application/x-director',
# D
# E
'eml' => 'message/rfc822',
'eps' => 'application/postscript',
'exe' =>
[
'application/octet-stream',
'application/x-msdownload'
],
# E
# F
'flac' => 'audio/x-flac',
'f4v' => 'video/mp4',
# F
# G
'gif' => 'image/gif',
'gpg' => 'application/gpg-keys',
'gtar' => 'application/x-gtar',
'gz' => 'application/x-gzip',
'gzip' => 'application/x-gzip',
# G
# H
'hqx' =>
[
'application/mac-binhex40',
'application/mac-binhex',
'application/x-binhex40',
'application/x-mac-binhex40'
],
'htm' =>
[
'text/html',
'text/plain'
],
'html' =>
[
'text/html',
'text/plain'
],
# H
# I
'ical' => 'text/calendar',
'ico' => 'image/x-icon',
'ics' => 'text/calendar',
# I
# J
'jar' =>
[
'application/java-archive',
'application/x-java-application',
'application/x-jar',
'application/x-compressed'
],
'jpe' =>
[
'image/jpeg',
'image/pjpeg'
],
'jpeg' =>
[
'image/jpeg',
'image/pjpeg'
],
'jpg' =>
[
'image/jpeg',
'image/pjpeg'
],
'webp' =>
[
'image/webp'
],
'js' =>
[
'application/x-javascript',
'text/plain'
],
'json' =>
[
'application/json',
'text/json'
],
# J
# L
'lha' => 'application/octet-stream',
'log' =>
[
'text/plain',
'text/x-log'
],
'lzh' => 'application/octet-stream',
# L
# K
'kdb' => 'application/octet-stream',
'kml' =>
[
'application/vnd.google-earth.kml+xml',
'application/xml',
'text/xml'
],
'kmz' =>
[
'application/vnd.google-earth.kmz',
'application/zip',
'application/x-zip'
],
# K
# M
'mid' => 'audio/midi',
'midi' => 'audio/midi',
'mif' => 'application/vnd.mif',
'mov' => 'video/quicktime',
'movie' => 'video/x-sgi-movie',
'mpe' => 'video/mpeg',
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'mpga' => 'audio/mpeg',
'mp2' => 'audio/mpeg',
'mp3' =>
[
'audio/mpeg',
'audio/mpg',
'audio/mpeg3',
'audio/mp3'
],
'mp4' => 'video/mp4',
'm3u' => 'text/plain',
'm4a' => 'audio/x-m4a',
'm4u' => 'application/vnd.mpegurl',
# M
# O
'oda' => 'application/oda',
'ogg' => 'audio/ogg',
# O
# P
'pdf' =>
[
'application/pdf',
'application/force-download',
'application/x-download',
'binary/octet-stream'
],
'pem' =>
[
'application/x-x509-user-cert',
'application/x-pem-file',
'application/octet-stream'
],
'pgp' => 'application/pgp',
'php' =>
[
'application/x-httpd-php',
'application/php',
'application/x-php',
'text/php', 'text/x-php',
'application/x-httpd-php-source'
],
'phps' => 'application/x-httpd-php-source',
'php3' => 'application/x-httpd-php',
'php4' => 'application/x-httpd-php',
'phtml' => 'application/x-httpd-php',
'png' =>
[
'image/png',
'image/x-png'
],
'ppt' =>
[
'application/powerpoint',
'application/vnd.ms-powerpoint',
'application/vnd.ms-office',
'application/msword'
],
'pptx' =>
[
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/x-zip',
'application/zip'
],
'ps' => 'application/postscript',
'psd' =>
[
'application/x-photoshop',
'image/vnd.adobe.photoshop'
],
'p10' =>
[
'application/x-pkcs10',
'application/pkcs10'
],
'p12' => 'application/x-pkcs12',
'p7a' => 'application/x-pkcs7-signature',
'p7c' =>
[
'application/pkcs7-mime',
'application/x-pkcs7-mime'
],
'p7m' =>
[
'application/pkcs7-mime',
'application/x-pkcs7-mime'
],
'p7r' => 'application/x-pkcs7-certreqresp',
'p7s' => 'application/pkcs7-signature',
# P
# Q
'qt' => 'video/quicktime',
# Q
# R
'ra' => 'audio/x-realaudio',
'ram' => 'audio/x-pn-realaudio',
'rar' =>
[
'application/x-rar',
'application/rar',
'application/x-rar-compressed'
],
'rm' => 'audio/x-pn-realaudio',
'rpm' => 'audio/x-pn-realaudio-plugin',
'rsa' => 'application/x-pkcs7',
'rtf' => 'text/rtf',
'rtx' => 'text/richtext',
'rv' => 'video/vnd.rn-realvideo',
# R
# S
'sea' => 'application/octet-stream',
'shtml' =>
[
'text/html',
'text/plain'
],
'sit' => 'application/x-stuffit',
'smi' => 'application/smil',
'smil' => 'application/smil',
'so' => 'application/octet-stream',
'srt' =>
[
'text/srt',
'text/plain'
],
'sst' => 'application/octet-stream',
'svg' =>
[
'image/svg+xml',
'application/xml',
'text/xml'
],
'swf' => 'application/x-shockwave-flash',
# S
# T
'tar' => 'application/x-tar',
'text' => 'text/plain',
'tgz' =>
[
'application/x-tar',
'application/x-gzip-compressed'
],
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'txt' => 'text/plain',
# T
# V
'vcf' => 'text/x-vcard',
'vlc' => 'application/videolan',
'vtt' =>
[
'text/vtt',
'text/plain'
],
# V
# W
'wav' =>
[
'audio/x-wav',
'audio/wave',
'audio/wav'
],
'wbxml' => 'application/wbxml',
'webm' => 'video/webm',
'wma' =>
[
'audio/x-ms-wma',
'video/x-ms-asf'
],
'wmlc' => 'application/wmlc',
'wmv' =>
[
'video/x-ms-wmv',
'video/x-ms-asf'
],
'word' =>
[
'application/msword',
'application/octet-stream'
],
# W
# X
'xht' => 'application/xhtml+xml',
'xhtml' => 'application/xhtml+xml',
'xl' => 'application/excel',
'xls' =>
[
'application/vnd.ms-excel',
'application/msexcel',
'application/x-msexcel',
'application/x-ms-excel',
'application/x-excel',
'application/x-dos_ms_excel',
'application/xls',
'application/x-xls',
'application/excel',
'application/download',
'application/vnd.ms-office',
'application/msword'
],
'xlsx' =>
[
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/zip',
'application/vnd.ms-excel',
'application/msword',
'application/x-zip'
],
'xml' =>
[
'application/xml',
'text/xml',
'text/plain'
],
'xsl' =>
[
'application/xml',
'text/xsl',
'text/xml'
],
'xspf' => 'application/xspf+xml',
# X
# Z
'z' => 'application/x-compress',
'zip' =>
[
'application/x-zip',
'application/zip',
'application/x-zip-compressed',
'application/s-compressed',
'multipart/x-zip'
],
'zsh' => 'text/x-scriptzsh',
# Z
# 3
'3gp' =>
[
'video/3gp',
'video/3gpp'
],
'3g2' => 'video/3gpp2',
# 3
# 7
'7zip' =>
[
'application/x-compressed',
'application/x-zip-compressed',
'application/zip',
'multipart/x-zip'
]
# 7
];
}
+126
View File
@@ -0,0 +1,126 @@
<?php namespace ZN\Helpers;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use stdClass;
use ZN\Base;
use ZN\Classes;
use ZN\Protection\Json;
class Reflect
{
/**
* Keeps Reflection Classes
*
* @var array
*/
protected $classes =
[
'class',
'extension',
'function',
'method',
'object',
'parameter',
'property'
];
/**
* Magic Call
*
* @param string $method
* @param array $parameters
*
* @return mixed
*/
public function __call($method, $parameters)
{
$lower = strtolower($method);
if( in_array($lower, $this->classes) )
{
return $this->call($parameters, $method);
}
return $this->call($parameters)->$method(); // @codeCoverageIgnore
}
/**
* Annotation
*
* @param string $class
* @param string $function = NULL
*
* @return object
*/
public function annotation(string $class, ?string $function = NULL) : stdClass
{
if( strstr($class, '::') )
{
$method = explode('::', $class);
$class = $method[0];
$function = $method[1];
}
if( $function[0] === '$' )
{
$class = $this->property($class, ltrim($function, '$'));
}
else
{
if( $function === NULL )
{
$class = $this->class($class);
}
else
{
$class = $this->method($class, $function);
}
}
preg_match_all('/@(\w+.*?)\s+(.*?)\s+\*/s', $class->getDocComment() ?? '', $match);
$keys = $match[1] ?? [];
$values = $match[2] ?? [];
$values = array_map(function($data)
{
if( Json::check($data) )
{
return Json::decodeObject($data);
}
elseif( $data[0] === ':' )
{
return eval('?><?php return ' . ltrim(Base::suffix($data, ';'), ':'));
}
return $data;
}, $values);
return (object) array_combine($keys, $values);
}
/**
* Protected Call
*/
protected function call($parameters, $type = NULL)
{
$class = 'Reflection' . $type;
if( $type === 'class' )
{
$parameters[0] = Classes::class($parameters[0]);
}
return (new $class(...$parameters));
}
}
+90
View File
@@ -0,0 +1,90 @@
<?php namespace ZN\Helpers;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Helpers\Exception\LogicException;
class Rounder
{
/**
* Average
*
* @param float $number
* @param int $count = 0
*
* @return float
*/
public static function average(Float $number, int $count = 0) : Float
{
return round($number, $count);
}
/**
* Down
*
* @param float $number
* @param int $count = 0
*
* @return float
*/
public static function down(Float $number, int $count = 0) : Float
{
if( $count === 0 )
{
return floor($number);
}
$numbers = explode(".", $number);
$edit = 0;
if( ! empty($numbers[1]) )
{
$edit = substr($numbers[1], 0, $count);
return (float) $numbers[0].".".$edit;
}
else
{
throw new LogicException('[Rounder::down()] -> Decimal values can not be specified for the integer! Check 2.($count) parameter!');
}
}
/**
* Up
*
* @param float $number
* @param int $count = 0
*
* @return float
*/
public static function up(Float $number, int $count = 0) : Float
{
if( $count === 0 )
{
return ceil($number);
}
$numbers = explode(".", $number);
$edit = 0;
if( ! empty($numbers[1]) )
{
$edit = substr($numbers[1], 0, $count);
return (float) $numbers[0].".".($edit + 1);
}
else
{
throw new LogicException('[Rounder::up()] -> Decimal values can not be specified for the integer! Check 2.($count) parameter!');
}
}
}
+46
View File
@@ -0,0 +1,46 @@
<?php namespace ZN\Helpers;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
class Searcher
{
/**
* Search Data
*
* @param mixed $searchData
* @param mixed $searchWord
* @param string $output = 'boolean' - options[string|position|boolean]
*/
public static function data($searchData, $searchWord, string $output = 'boolean')
{
if( ! is_array($searchData) )
{
switch( $output )
{
case 'string' : return strstr($searchData, $searchWord);
case 'position': return strpos($searchData, $searchWord);
case 'boolean' : return strpos($searchData, $searchWord) > -1 ? true : false;
default : return false;
}
}
else
{
$result = array_search($searchWord, $searchData);
switch( $output )
{
case 'string' : return $result ? $searchWord : false;
case 'position': return $result ?: -1;
case 'boolean' : return (bool) $result;
default : return false;
}
}
}
}
+97
View File
@@ -0,0 +1,97 @@
<?php namespace ZN\Helpers;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Config;
class Symbol
{
/**
* Magic Call
*
* @param string $method
* @param array $parameters
*
* @return string|false
*/
public function __call($method, $parameters)
{
return $this->symbols[$method] ?? false;
}
/**
* Magic Constructor
*/
public function __construct()
{
$this->symbols = array_merge(Config::get('Expressions', 'symbols'), $this->symbols);
}
/**
* Keeps Symbols
*
* @var array
*/
public $symbols =
[
'copyright' => '&copy;', //©
'register' => '&#174;', //®
'euro' => '&#8364;', //€
'dolar' => '$', //$
'usd' => '$', //$
'rightDoubleArrow' => '&#187;', //»
'leftDoubleArrow' => '&#171;', //«
'invertQuestion' => '&#191;', //¿
'tradeMark' => '&#8482;', //™
'turkishLira' => '&#x20BA;', //t
'cent' => '&#162;', //¢
'yen' => '&#165;', //¥
'pound' => '&#163;', //£
'currency' => '&#164;', //¤
'division' => '&#247;', //÷
'minus' => '&#177;', //±
'micro' => '&#181;', //µ
'degree' => '&#176;', //°
'section' => '&#167;', //§
'bigSlash' => '&#216;', //Ø
'smallSlash' => '&#248;', //ø
'permil' => '&permil;', //‰
'tilde' => '&#126;', //~
'spade' => '&spades;', //♠
'club' => '&clubs;', //♣
'heart' => '&hearts;', //♥
'diam' => '&diams;', //♦
'at' => '&#64;', //@
'function' => '&fnof;', //ƒ
'product' => '&prod;', //∏
'equivalent ' => '&equiv;', //≡
'partial' => '&part;', //∂
'integral' => '&int;', //∫
'infinity' => '&infin;', //∞
'squareRoot' => '&radic;', //√
'approximately' => '&asymp;', //≈
'notEquals' => '&ne;', //≠
'triangle' => '&there4;', //∴
'greaterEquals' => '&ge;', //≥
'lessEquals' => '&le;', //≤
'paragraph' => '&para;', //¶
'bigDote' => '&bull;', //•
'midDote' => '&middot;', //·
'dagger' => '&dagger;', //†
'doubleDagger' => '&Dagger;', //‡
'diamond' => '&loz;', //◊
'upArrow' => '&uarr;', //↑
'downArrow' => '&darr;', //↓
'leftArrow' => '&larr;', //←
'rightArrow' => '&rarr;', //→
'doubleHeadedArrow' => '&harr;', //↔
'notSymbol' => '&not;' //¬
];
}