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
@@ -0,0 +1,21 @@
<?php namespace ZN\Protection\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\Exception;
class ScalarDataException extends Exception
{
const lang =
[
'tr' => '[%] bilgisi array veya object türü olmalıdır!',
'en' => '[%] information must be array or object type!'
];
}
+108
View File
@@ -0,0 +1,108 @@
<?php namespace ZN\Protection;
/**
* 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 Json extends StoreAbstract implements StoreInterface
{
use StoreTrait;
/**
* Encode
*
* @param mixed $data
* @param string $type = 'unescapedUnicode'
*
* @return string
*/
public static function encode($data, string $type = 'unescapedUnicode') : string
{
return json_encode($data, Helper::toConstant($type, 'JSON_'));
}
/**
* Decode
*
* @param string $data
* @param bool $array = false
* @param int $length = 512
*
* @return mixed
*/
public static function decode(string $data, bool $array = false, int $length = 512)
{
$return = json_decode($data, $array, $length);
return $return;
}
/**
* Decode Object
*
* @param string $data
* @param int $length = 512
*
* @return object
*/
public static function decodeObject(string $data, int $length = 512)
{
return json_decode($data, false, $length);
}
/**
* Decode Array
*
* @param string $data
* @param int $length = 512
*
* @return array
*/
public static function decodeArray(string $data, int $length = 512) : array
{
return (array) json_decode($data, true, $length);
}
/**
* Error
*
* @param void
*
* @return string
*/
public static function error() : string
{
return json_last_error_msg();
}
/**
* Error No
*
* @param void
*
* @return int
*/
public static function errno() : int
{
return json_last_error();
}
/**
* Check
*
* @param string $data
*
* @return bool
*/
public static function check(string $data) : bool
{
return ( is_array(json_decode($data, true)) && json_last_error() === 0 );
}
}
+127
View File
@@ -0,0 +1,127 @@
<?php namespace ZN\Protection;
/**
* 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;
class Separator extends StoreAbstract implements StoreInterface
{
use StoreTrait;
/**
* Keeps key
*
* @var string
*/
protected static $key = "+-?||?-+" ;
/**
* Keeps separator
*
* @var string
*/
protected static $separator = "|?-++-?|";
/**
* Encode
*
* @param array $data
* @param string $type = 'unescapedUnicode'
*
* @return string
*/
public static function encode($data, ?string $key = NULL, ?string $separator = NULL) : string
{
if( ! is_scalar($data) )
{
$data = (array) $data;
}
$word = '';
$key = $key ?: self::$key;
$separator = $separator ?: self::$separator;
foreach( $data as $k => $v )
{
$word .= self::_security($k).$key.self::_security($v).$separator;
}
return mb_substr($word, 0, -(mb_strlen($separator)));
}
/**
* Decode
*
* @param string $data
* @param string $key = NULL
* @param string $separator = NULL
*
* @return object
*/
public static function decode(string $data, ?string $key = NULL, ?string $separator = NULL) : stdClass
{
$key = $key ?: self::$key;
$separator = $separator ?: self::$separator;
$keyval = explode($separator, $data);
$splits = [];
$object = [];
if( is_array($keyval) ) foreach( $keyval as $v )
{
$splits = explode($key, $v);
if( isset($splits[1]) )
{
$object[$splits[0]] = $splits[1];
}
}
return (object) $object;
}
/**
* Decode Object
*
* @param string $data
* @param string $key = NULL
* @param string $separator = NULL
*
* @return object
*/
public static function decodeObject(string $data, ?string $key = NULL, ?string $separator = NULL) : stdClass
{
return self::decode($data, $key, $separator);
}
/**
* Decode Array
*
* @param string $data
* @param string $key = NULL
* @param string $separator = NULL
*
* @return array
*/
public static function decodeArray(string $data, ?string $key = NULL, ?string $separator = NULL) : array
{
return (array) self::decode($data, $key, $separator);
}
/**
* Protected Security
*
* @param string $data
*/
protected static function _security($data)
{
return str_replace([self::$key, self::$separator], '', $data ?? '');
}
}
+75
View File
@@ -0,0 +1,75 @@
<?php namespace ZN\Protection;
/**
* 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;
class Serial extends StoreAbstract implements StoreInterface
{
use StoreTrait;
/**
* Encode
*
* @param mixed $data
*
* @return string
*/
public static function encode($data) : string
{
return serialize($data);
}
/**
* Decode
*
* @param string $data
* @param bool $array = false
*
* @return object
*/
public static function decode(string $data, bool $array = false)
{
if( $array === false )
{
return (object) unserialize($data);
}
else
{
return (array) unserialize($data);
}
}
/**
* Decode
*
* @param string $data
* @param bool $array = false
*
* @return object
*/
public static function decodeObject(string $data) : stdClass
{
return self::decode($data, false);
}
/**
* Decode Array
*
* @param string $data
* @param bool $array = false
*
* @return array
*/
public static function decodeArray(string $data) : array
{
return self::decode($data, true);
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php namespace ZN\Protection;
/**
* 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\Container;
class Store
{
use Container;
/**
* Magic Constructor
*
* @param StoreInterface $store
*/
public function __construct(StoreInterface $store = NULL)
{
self::$container = $store;
}
}
@@ -0,0 +1,93 @@
<?php namespace ZN\Protection;
/**
* 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\Protection\Exception\ScalarDataException;
abstract class StoreAbstract
{
/**
* Encode
*
* @param mixed $data
* @param string $type = 'unescapedUnicode'
*
* @return string
*/
abstract public static function encode($data) : string;
/**
* Decode
*
* @param string $data
* @param bool $array = false
* @param int $length = 512
*
* @return mixed
*/
abstract public static function decode(string $data);
/**
* Decode Object
*
* @param string $data
* @param int $length = 512
*
* @return object
*/
abstract public static function decodeObject(string $data);
/**
* Decode Array
*
* @param string $data
* @param int $length = 512
*
* @return array
*/
abstract public static function decodeArray(string $data) : array;
/**
* Error
*
* @param void
*
* @return string
*/
public static function error() : string
{
return false;
}
/**
* Error No
*
* @param void
*
* @return int
*/
public static function errno() : int
{
return 0;
}
/**
* Check
*
* @param string $data
*
* @return bool
*/
public static function check(string $data) : bool
{
return true;
}
}
@@ -0,0 +1,117 @@
<?php namespace ZN\Protection;
/**
* 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 StoreInterface
{
/**
* Write
*
* @param string $file
* @param mixed $data
*
* @return string
*/
public static function write(string $file, $data) : bool;
/**
* Read
*
* @param string $file
* @param bool $array = false
*
* @return mixed
*/
public static function read(string $file, bool $array = false);
/**
* Read object
*
* @param string $file
*
* @return object
*/
public static function readObject(string $file);
/**
* Read array
*
* @param string $file
*
* @return array
*/
public static function readArray(string $file) : array;
/**
* Encode
*
* @param mixed $data
* @param string $type = 'unescapedUnicode'
*
* @return string
*/
public static function encode($data) : string;
/**
* Decode
*
* @param string $data
* @param bool $array = false
* @param int $length = 512
*
* @return mixed
*/
public static function decode(string $data);
/**
* Decode Object
*
* @param string $data
*
* @return object
*/
public static function decodeObject(string $data);
/**
* Decode Array
*
* @param string $data
*
* @return array
*/
public static function decodeArray(string $data) : array;
/**
* Error
*
* @param void
*
* @return string
*/
public static function error() : string;
/**
* Error No
*
* @param void
*
* @return int
*/
public static function errno() : int;
/**
* Check
*
* @param string $data
*
* @return bool
*/
public static function check(string $data) : bool;
}
@@ -0,0 +1,97 @@
<?php namespace ZN\Protection;
/**
* 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\Protection\Exception\ScalarDataException;
trait StoreTrait
{
protected static function addExtension($file)
{
if( strstr(get_called_class(), 'Json') )
{
return Base::suffix($file, '.json');
}
return $file;
}
/**
* Write
*
* @param string $file
* @param mixed $data
*
* @return string
*/
public static function write(string $file, $data) : bool
{
if( is_scalar($data) )
{
throw new ScalarDataException(NULL, 'data');
}
$json = self::encode($data);
return file_put_contents(self::addExtension($file), $json);
}
/**
* Read
*
* @param string $file
* @param bool $array = false
*
* @return mixed
*/
public static function read(string $file, bool $array = false)
{
$file = self::addExtension($file);
if( ! is_file($file) )
{
return false;
}
$json = file_get_contents($file);
return self::decode($json, $array);
}
/**
* Read object
*
* @param string $file
*
* @return mixed
*/
public static function readObject(string $file)
{
return self::read($file, false);
}
/**
* Read array
*
* @param string $file
*
* @return mixed
*/
public static function readArray(string $file) : array
{
if( is_file($file) && strstr(get_called_class(), 'Separator') )
{
return (array) self::decode(file_get_contents($file));
}
return self::read($file, true);
}
}