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,67 @@
<?php namespace ZN\Security;
/**
* 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\Security;
class CrossSiteRequestForgery
{
/**
* Cross Site Request Forgery
*
* @param string $uri = NULL
* @param string $type = 'post'
*
* @return void
*/
public static function token(?string $uri = NULL, string $type = 'post')
{
Security::CSRFToken($uri, $type);
}
/**
* Get
*
* @param string $uri = NULL
*
* @return void
*/
public static function get(?string $uri = NULL)
{
self::token($uri, 'get');
}
/**
* Get string token
*
* @param string $name = 'token'
*
* @return string
*/
public static function key(string $name = 'token')
{
Security::createCSRFTokenKey($name);
return Security::getCSRFTokenKey($name);
}
/**
* Valid token
*
* @param string $name = 'token'
* @param string $type = 'post'
*
* @return bool
*/
public static function validToken(string $name = 'token', string $type = 'post') : bool
{
return Security::validCSRFToken($name, $type);
}
}
@@ -0,0 +1,53 @@
<?php namespace ZN\Security;
/**
* 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 CrossSiteScripting
{
/**
* Script Bad Chars
*
* @var array
*/
protected static $scriptBadChars =
[
'document\.cookie' => 'document&#46;cookie',
'document\.write' => 'document&#46;write',
'\.parentNode' => '&#46;parentNode',
'\.innerHTML' => '&#46;innerHTML',
'\-moz\-binding' => '&#150;moz&#150;binding',
'<' => '&#60;',
'>' => '&#62;',
];
/**
* Encode Cross Site Scripting
*
* @param string $string
*
* @return string
*/
public static function encode(string $string) : string
{
$secBadChars = self::$scriptBadChars;
if( ! empty($secBadChars) )
{
foreach( $secBadChars as $badChar => $changeChar )
{
$badChar = trim($badChar, '/');
$string = preg_replace('/'.$badChar.'/xi', $changeChar, $string);
}
}
return $string;
}
}
+442
View File
@@ -0,0 +1,442 @@
<?php namespace ZN\Security;
/**
* 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 ForeignChar
{
/**
* Encode Foreign Char
*
* @param string $str
*
* @return string
*/
public static function encode(string $str) : string
{
$chars = self::$numericalCodes;
return str_replace(array_keys($chars), array_values($chars), $str);
}
/**
* Decode Foreign Char
*
* @param string $str
*
* @return string
*/
public static function decode(string $str) : string
{
$chars = self::$numericalCodes;
return str_replace(array_values($chars), array_keys($chars), $str);
}
/**
* Numerical Codes
*
* @var array
*/
public static $numericalCodes =
[
'À' => '&#192;',
'Ā' => '&#256;',
'ā' => '&#257;',
'Ă' => '&#258;',
'ă' => '&#259;',
'à' => '&#224;',
'Á' => '&#193;',
'á' => '&#225;',
'Â' => '&#194;',
'Ą' => '&#260;',
'ą' => '&#261;',
'â' => '&#226;',
'Ã' => '&#195;',
'ã' => '&#227;',
'Ä' => '&#196;',
'ä' => '&#228;',
'Å' => '&#197;',
'å' => '&#229;',
'Ǎ' => '&#461;',
'ǎ' => '&#462;',
'Ǻ' => '&#506;',
'ǻ' => '&#507;',
'Ǽ' => '&#508;',
'ǽ' => '&#509;',
'Ȁ' => '&#512;',
'ȁ' => '&#513;',
'Ȃ' => '&#514;',
'ȃ' => '&#515;',
'Ȧ' => '&#550;',
'ȧ' => '&#551;',
'Ǟ' => '&#478;',
'ǟ' => '&#479;',
'Ǡ' => '&#480;',
'ǡ' => '&#481;',
'Ǣ' => '&#482;',
'ǣ' => '&#483;',
'Ⱥ' => '&#570;',
'ß' => '&#223;',
'ƀ' => '&#384;',
'Ɓ' => '&#385;',
'Ƃ' => '&#386;',
'ƃ' => '&#387;',
'Ƅ' => '&#388;',
'ƅ' => '&#389;',
'Ƀ' => '&#579;',
'Ç' => '&#199;',
'ç' => '&#231;',
'Ć' => '&#262;',
'ć' => '&#263;',
'Ĉ' => '&#264;',
'ĉ' => '&#265;',
'Ċ' => '&#266;',
'ċ' => '&#267;',
'Č' => '&#268;',
'č' => '&#269;',
'Ɔ' => '&#390;',
'Ƈ' => '&#391;',
'ƈ' => '&#392;',
'Ȼ' => '&#571;',
'ȼ' => '&#572;',
'Ð' => '&#208;',
'ð' => '&#240;',
'Ď' => '&#270;',
'ď' => '&#271;',
'Đ' => '&#272;',
'đ' => '&#273;',
'Ɖ' => '&#393;',
'Ɗ' => '&#394;',
'Ƌ' => '&#395;',
'ƌ' => '&#396;',
'ƍ' => '&#397;',
'ȡ' => '&#545;',
'ȸ' => '&#568;',
'È' => '&#200;',
'è' => '&#232;',
'É' => '&#201;',
'é' => '&#233;',
'Ê' => '&#202;',
'ê' => '&#234;',
'Ë' => '&#203;',
'ë' => '&#235;',
'Ē' => '&#274;',
'ē' => '&#275;',
'Ĕ' => '&#276;',
'ĕ' => '&#277;',
'Ė' => '&#278;',
'ė' => '&#279;',
'Ę' => '&#280;',
'ę' => '&#281;',
'Ě' => '&#282;',
'ě' => '&#283;',
'Ǝ' => '&#398;',
'Ə' => '&#399;',
'Ɛ' => '&#400;',
'ǝ' => '&#477;',
'Ȅ' => '&#516;',
'ȅ' => '&#517;',
'Ȇ' => '&#518;',
'ȇ' => '&#519;',
'Ȩ' => '&#552;',
'ȩ' => '&#553;',
'Ɇ' => '&#582;',
'ɇ' => '&#583;',
'Ƒ' => '&#401;',
'ƒ' => '&#402;',
'Ĝ' => '&#284;',
'ĝ' => '&#285;',
'Ğ' => '&#286;',
'ğ' => '&#287;',
'Ġ' => '&#288;',
'ġ' => '&#289;',
'Ģ' => '&#290;',
'ģ' => '&#291;',
'Ɠ' => '&#403;',
'Ǥ' => '&#484;',
'ǥ' => '&#485;',
'Ǧ' => '&#486;',
'ǧ' => '&#487;',
'Ǵ' => '&#500;',
'ǵ' => '&#501;',
'Ĥ' => '&#292;',
'ĥ' => '&#293;',
'Ħ' => '&#294;',
'ħ' => '&#295;',
'Ɣ' => '&#404;',
'ƕ' => '&#405;',
'Ƕ' => '&#502;',
'Ȟ' => '&#542;',
'ȟ' => '&#543;',
'Ì' => '&#204;',
'ì' => '&#236;',
'Í' => '&#205;',
'í' => '&#237;',
'Î' => '&#206;',
'î' => '&#238;',
'Ï' => '&#207;',
'ï' => '&#239;',
'Ĩ' => '&#296;',
'ĩ' => '&#297;',
'Ī' => '&#298;',
'ī' => '&#299;',
'Ĭ' => '&#300;',
'ĭ' => '&#301;',
'Į' => '&#302;',
'į' => '&#303;',
'İ' => '&#304;',
'ı' => '&#305;',
'Ɩ' => '&#406;',
'Ɨ' => '&#407;',
'Ǐ' => '&#463;',
'ǐ' => '&#464;',
'Ȉ' => '&#520;',
'ȉ' => '&#521;',
'Ȋ' => '&#522;',
'ȋ' => '&#523;',
'IJ' => '&#306;',
'ij' => '&#307;',
'Ĵ' => '&#308;',
'ĵ' => '&#309;',
'ǰ' => '&#496;',
'Ɉ' => '&#584;',
'ɉ' => '&#585;',
'Ķ' => '&#310;',
'ķ' => '&#311;',
'ĸ' => '&#312;',
'Ƙ' => '&#408;',
'ƙ' => '&#409;',
'Ǩ' => '&#488;',
'ǩ' => '&#489;',
'ƚ' => '&#410;',
'ƛ' => '&#411;',
'Ɯ' => '&#412;',
'Ĺ' => '&#313;',
'ĺ' => '&#314;',
'Ļ' => '&#315;',
'ļ' => '&#316;',
'Ľ' => '&#317;',
'ľ' => '&#318;',
'Ŀ' => '&#319;',
'ŀ' => '&#320;',
'Ł' => '&#321;',
'ł' => '&#322;',
'ȴ' => '&#564;',
'Ƚ' => '&#573;',
'Ñ' => '&#209;',
'ñ' => '&#241;',
'Ń' => '&#323;',
'ń' => '&#324;',
'Ņ' => '&#325;',
'ņ' => '&#326;',
'Ň' => '&#327;',
'ň' => '&#328;',
'ʼn' => '&#329;',
'Ŋ' => '&#330;',
'ŋ' => '&#331;',
'Ɲ' => '&#413;',
'ƞ' => '&#414;',
'Ǹ' => '&#504;',
'ǹ' => '&#505;',
'Ƞ' => '&#544;',
'ȵ' => '&#565;',
'Ò' => '&#210;',
'ò' => '&#242;',
'Ó' => '&#211;',
'ó' => '&#243;',
'Ô' => '&#212;',
'ô' => '&#244;',
'Õ' => '&#213;',
'õ' => '&#245;',
'Ö' => '&#214;',
'ö' => '&#246;',
'Ō' => '&#332;',
'ō' => '&#333;',
'Ŏ' => '&#334;',
'ŏ' => '&#335;',
'Ő' => '&#336;',
'ő' => '&#337;',
'Ɵ' => '&#415;',
'Ơ' => '&#416;',
'ơ' => '&#417;',
'Ǒ' => '&#465;',
'ǒ' => '&#466;',
'Ȍ' => '&#524;',
'ȍ' => '&#525;',
'Ȏ' => '&#526;',
'ȏ' => '&#527;',
'Ȣ' => '&#546;',
'ȣ' => '&#547;',
'Ȫ' => '&#554;',
'ȫ' => '&#555;',
'Ȭ' => '&#556;',
'ȭ' => '&#557;',
'Ȯ' => '&#558;',
'ȯ' => '&#559;',
'Ȱ' => '&#560;',
'ȱ' => '&#561;',
'Þ' => '&#222;',
'þ' => '&#254;',
'Ƣ' => '&#418;',
'ƣ' => '&#419;',
'Ƥ' => '&#420;',
'ƥ' => '&#421;',
'Ǫ' => '&#490;',
'ǫ' => '&#491;',
'Ǭ' => '&#492;',
'ǭ' => '&#493;',
'ȹ' => '&#569;',
'Ɋ' => '&#586;',
'ɋ' => '&#587;',
'Œ' => '&#338;',
'œ' => '&#339;',
'Æ' => '&#198;',
'æ' => '&#230;',
'Ŕ' => '&#340;',
'ŕ' => '&#341;',
'Ŗ' => '&#342;',
'ŗ' => '&#343;',
'Ř' => '&#344;',
'ř' => '&#345;',
'Ʀ' => '&#422;',
'Ȑ' => '&#528;',
'ȑ' => '&#529;',
'Ȓ' => '&#530;',
'ȓ' => '&#531;',
'Ɍ' => '&#588;',
'ɍ' => '&#589;',
'Ś' => '&#346;',
'ś' => '&#347;',
'Ŝ' => '&#348;',
'ŝ' => '&#349;',
'Ş' => '&#350;',
'ş' => '&#351;',
'Š' => '&#352;',
'š' => '&#353;',
'Ƨ' => '&#423;',
'ƨ' => '&#424;',
'Ș' => '&#536;',
'ș' => '&#537;',
'ȿ' => '&#575;',
'Ʃ' => '&#425;',
'ƪ' => '&#426;',
'Ţ' => '&#354;',
'ţ' => '&#355;',
'Ť' => '&#356;',
'ť' => '&#357;',
'Ŧ' => '&#358;',
'ŧ' => '&#359;',
'ƫ' => '&#427;',
'Ƭ' => '&#428;',
'ƭ' => '&#429;',
'Ʈ' => '&#430;',
'Ț' => '&#538;',
'ț' => '&#539;',
'ȶ' => '&#566;',
'Ⱦ' => '&#574;',
'Ù' => '&#217;',
'ù' => '&#249;',
'Ú' => '&#218;',
'ú' => '&#250;',
'Û' => '&#219;',
'û' => '&#251;',
'Ü' => '&#220;',
'ü' => '&#252;',
'Ũ' => '&#360;',
'ũ' => '&#361;',
'Ū' => '&#362;',
'ū' => '&#363;',
'Ŭ' => '&#364;',
'ŭ' => '&#365;',
'Ů' => '&#366;',
'ů' => '&#367;',
'Ű' => '&#368;',
'ű' => '&#369;',
'Ų' => '&#370;',
'ų' => '&#371;',
'Ư' => '&#431;',
'ư' => '&#432;',
'Ʊ' => '&#433;',
'Ʋ' => '&#434;',
'Ǔ' => '&#467;',
'ǔ' => '&#468;',
'Ǖ' => '&#469;',
'ǖ' => '&#470;',
'Ǘ' => '&#471;',
'ǘ' => '&#472;',
'Ǚ' => '&#473;',
'ǚ' => '&#474;',
'Ǜ' => '&#475;',
'ǜ' => '&#476;',
'Ȕ' => '&#532;',
'ȕ' => '&#533;',
'Ȗ' => '&#534;',
'ȗ' => '&#535;',
'Ʉ' => '&#580;',
'Ʌ' => '&#581;',
'Ŵ' => '&#372;',
'ŵ' => '&#373;',
'Ý' => '&#221;',
'ý' => '&#253;',
'ÿ' => '&#255;',
'Ŷ' => '&#374;',
'ŷ' => '&#375;',
'Ÿ' => '&#376;',
'Ƴ' => '&#435;',
'ƴ' => '&#436;',
'Ȳ' => '&#562;',
'ȳ' => '&#563;',
'Ɏ' => '&#590;',
'ɏ' => '&#591;',
'Ź' => '&#377;',
'ź' => '&#378;',
'Ż' => '&#379;',
'ż' => '&#380;',
'Ž' => '&#381;',
'ž' => '&#382;',
'ſ' => '&#383;',
'Ƶ' => '&#437;',
'ƶ' => '&#438;',
'Ȥ' => '&#548;',
'ȥ' => '&#549;',
'ɀ' => '&#576;',
];
}
+47
View File
@@ -0,0 +1,47 @@
<?php namespace ZN\Security;
/**
* 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\Controller\Factory;
class Guard extends Factory
{
const factory =
[
'methods' =>
[
'timeonstay' => 'TimeOnStay::create',
'validtimeonstay' => 'TimeOnStay::valid',
'ncencode' => 'NastyCode::encode',
'injectionencode' => 'Injection::encode',
'injectiondecode' => 'Injection::decode',
'nailencode' => 'Injection::nailEncode',
'naildecode' => 'Injection::nailDecode',
'escapestringencode' => 'Injection::escapeStringEncode',
'escapestringdecode' => 'Injection::escapeStringDecode',
'xssencode' => 'CrossSiteScripting::encode',
'csrftoken' => 'CrossSiteRequestForgery::token',
'csrfpost' => 'CrossSiteRequestForgery::token',
'csrfget' => 'CrossSiteRequestForgery::get',
'csrftokenkey' => 'CrossSiteRequestForgery::key',
'validcsrftokenkey' => 'CrossSiteRequestForgery::validToken',
'htmlencode' => 'Html::encode',
'htmldecode' => 'Html::decode',
'htmltagclean' => 'Html::tagClean',
'phptagencode' => 'PHP::encode',
'phptagdecode' => 'PHP::decode',
'phptagclean' => 'PHP::tagClean',
'scripttagencode' => 'Script::encode',
'scripttagdecode' => 'Script::decode',
'foreigncharencode' => 'ForeignChar::encode',
'foreignchardecode' => 'ForeignChar::decode'
]
];
}
+55
View File
@@ -0,0 +1,55 @@
<?php namespace ZN\Security;
/**
* 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 Html
{
/**
* Encode HTML
*
* @param string $string
* @param string $type = 'quotes'
* @param string $encoding = 'utf-8'
*
* @return string
*/
public static function encode(string $string, string $type = 'quotes', string $encoding = 'utf-8') : string
{
return str_replace('&amp;', '&', htmlspecialchars(trim($string), Helper::toConstant($type, 'ENT_'), $encoding, false));
}
/**
* Decode HTML
*
* @param string $string
* @param string $type = 'quotes'
*
* @return string
*/
public static function decode(string $string, string $type = 'quotes') : string
{
return htmlspecialchars_decode(trim($string), Helper::toConstant($type, 'ENT_'));
}
/**
* Clean HTML Tag
*
* @param string $string
* @param mixed $allowable = ''
*
* @return string
*/
public static function tagClean(string $string, $allowable = '') : string
{
return strip_tags(self::decode($string), $allowable);
}
}
+111
View File
@@ -0,0 +1,111 @@
<?php namespace ZN\Security;
/**
* 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 Injection
{
/**
* Nail Chars
*
* @var array
*/
protected static $nailChars =
[
"'" => "&#39;",
'"' => "&#34;"
];
/**
* Encode Injection Chars
*
* @param string $string
*
* @return string
*/
public static function encode(string $string) : string
{
$secBadChars = Properties::$injectionBadChars;
if( ! empty($secBadChars) )
{
foreach( $secBadChars as $badChar => $changeChar )
{
$badChar = trim($badChar, '/');
$string = preg_replace('/'.$badChar.'/xi', $changeChar, $string);
}
}
return addslashes(trim($string));
}
/**
* Decode Injection Chars
*
* @param string $string
*
* @return string
*/
public static function decode(string $string) : string
{
return stripslashes(trim($string));
}
/**
* Encode Nail Chars
*
* @param string $string
*
* @return string
*/
public static function nailEncode(string $str) : string
{
$str = str_replace(array_keys(self::$nailChars), array_values(self::$nailChars), $str);
return $str;
}
/**
* Decode Nail Chars
*
* @param string $string
*
* @return string
*/
public static function nailDecode(string $str) : string
{
$str = str_replace(array_values(self::$nailChars), array_keys(self::$nailChars), $str);
return $str;
}
/**
* Encode Escape String
*
* @param string $string
*
* @return string
*/
public static function escapeStringEncode(string $data) : string
{
return addslashes($data);
}
/**
* Decode Escape String
*
* @param string $string
*
* @return string
*/
public static function escapeStringDecode(string $data) : string
{
return stripslashes($data);
}
}
+64
View File
@@ -0,0 +1,64 @@
<?php namespace ZN\Security;
/**
* 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\Singleton;
class NastyCode
{
/**
* Encode Nasty Code
*
* @param string $string
* @param mixed $badWords = NULL
* @param mixed $changeChar = '[badchars]'
*
* @return string
*/
public static function encode(string $string, $badWords = NULL, $changeChar = '[badchars]') : string
{
if( empty($badWords) )
{
$secnc = Properties::$ncEncode;
$badWords = $secnc['badChars'];
$changeChar = $secnc['changeBadChars'];
}
$regex = Singleton::class('ZN\Regex');
if( ! is_array($badWords) )
{
return $string = $regex->replace($badWords, $changeChar, $string, 'xi');
}
$ch = '';
$i = 0;
foreach( $badWords as $value )
{
if( ! is_array($changeChar) )
{
$ch = $changeChar;
}
else
{
if( isset($changeChar[$i]) )
{
$ch = $changeChar[$i];
$i++;
}
}
$string = $regex->replace($value, $ch, $string, 'xi');
}
return $string;
}
}
+60
View File
@@ -0,0 +1,60 @@
<?php namespace ZN\Security;
/**
* 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 PHP
{
/**
* PHP Tag Chars
*
* @var array
*/
protected static $phpTagChars =
[
'<?' => '&#60;&#63;',
'?>' => '&#63;&#62;'
];
/**
* Encode PHP Tag
*
* @param string $str
*
* @return string
*/
public static function encode(string $str) : string
{
return str_replace(array_keys(self::$phpTagChars), array_values(self::$phpTagChars), $str);
}
/**
* Decode PHP Tag
*
* @param string $str
*
* @return string
*/
public static function decode(string $str) : string
{
return str_replace(array_values(self::$phpTagChars), array_keys(self::$phpTagChars), $str);
}
/**
* Clean PHP Tag
*
* @param string $str
*
* @return string
*/
public static function tagClean(string $str) : string
{
return str_ireplace(['<?php', '<?', '?>'], '', $str);
}
}
+43
View File
@@ -0,0 +1,43 @@
<?php namespace ZN\Security;
/**
* 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 Properties
{
/**
* Encode Nasty Chars
*
* @var array
*/
public static $ncEncode =
[
'badChars' => # string or array
[
'<!--',
'-->',
'<?',
'?>',
'<',
'>'
],
'changeBadChars' => '[badchars]' # string veya array
];
/**
* Indection Bad Chars
*
* @var array
*/
public static $injectionBadChars =
[
'or.+\=' => '',
];
}
+69
View File
@@ -0,0 +1,69 @@
<?php namespace ZN\Security;
/**
* 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 Script
{
/**
* Script Tag Chars
*
* @var array
*/
protected static $scriptTagChars =
[
'/\<script(.*?)\>/i' => '&#60;script$1&#62;',
'/\<\/script\>/i' => '&#60;/script&#62;'
];
/**
* Script Tag Chars Decode
*
* @var array
*/
protected static $scriptTagCharsDecode =
[
'/\&\#60\;script(.*?)\&\#62\;/i' => '<script$1>',
'/\&\#60\;\/script\&\#62\;/i' => '</script>'
];
/**
* Encode Script Tags
*
* @param string $str
*
* @return string
*/
public static function encode(string $str) : string
{
return preg_replace
(
array_keys(self::$scriptTagChars),
array_values(self::$scriptTagChars),
$str
);
}
/**
* Decode Script Tags
*
* @param string $str
*
* @return string
*/
public static function decode(string $str) : string
{
return preg_replace
(
array_keys(self::$scriptTagCharsDecode),
array_values(self::$scriptTagCharsDecode),
$str
);
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php namespace ZN\Security;
/**
* 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\Serialization;
#[\AllowDynamicProperties]
class Secure
{
use Serialization;
const serialization =
[
'class' => 'Guard',
'start' => 'data',
'end' => 'get'
];
}
+48
View File
@@ -0,0 +1,48 @@
<?php namespace ZN\Security;
/**
* 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 TimeOnStay
{
/**
* Create time to stay on the page
*
* @param string $name = 'timeOnStay'
*/
public static function create(string $name = 'timeOnStay')
{
$_SESSION[$name] = time();
}
/**
* Valid time to stay on the page
*
* @param int $time = 5
* @param string $name = 'timeOnStay'
*
* @return bool
*/
public static function valid(int $time = 5, string $name = 'timeOnStay') : bool
{
if( empty($_SESSION[$name]) )
{
return false;
}
$pagetime = time() - $_SESSION[$name];
if( $pagetime >= $time )
{
return true;
}
return false;
}
}