' . $toggScript . $imgScript . ''); $html = '
'; $done = array(); $html .= self::var_dump_plain($var, intval($expandLevel), 0, $done); $html .= ''; if (self::$hasArray) { $html = $jsCode . $html; } if (! $return) { echo $html; } return $html; } /** * Display a variable's contents using nice HTML formatting (Without * the
tag) and will properly display the values of variables * like booleans and resources. Supports collapsable arrays and objects * as well. * * @param mixed $var The variable to dump * @return string */ public static function var_dump_plain($var, $expLevel, $depth = 0, $done = array()) { $html = ''; if ($expLevel > 0) { $expLevel--; $setImg = 0; $setStyle = 'display:inline;'; } elseif ($expLevel == 0) { $setImg = 1; $setStyle='display:none;'; } elseif ($expLevel < 0) { $setImg = 0; $setStyle = 'display:inline;'; } if (is_bool($var)) { $html .= 'bool(' . (($var) ? 'true' : 'false') . ')'; } elseif (is_int($var)) { $html .= 'int(' . $var . ')'; } elseif (is_float($var)) { $html .= 'float(' . $var . ')'; } elseif (is_string($var)) { $html .= 'string(' . strlen($var) . ') "' . self::htmlentities($var) . '"'; } elseif (is_null($var)) { $html .= 'NULL'; } elseif (is_resource($var)) { $html .= 'resource("' . get_resource_type($var) . '") "' . $var . '"'; } elseif (is_array($var)) { // Check for recursion if ($depth > 0) { foreach ($done as $prev) { if ($prev === $var) { $html .= 'array(' . count($var) . ') *RECURSION DETECTED*'; return $html; } } // Keep track of variables we have already processed to detect recursion $done[] = &$var; } self::$hasArray = true; $uuid = 'include-php-' . uniqid() . mt_rand(1, 1000000); $html .= (!empty($var) ? '' : '') . 'array(' . count($var) . ')'; if (! empty($var)) { $html .= '
[
'; $indent = 4; $longest_key = 0; foreach ($var as $key => $value) { if (is_string($key)) { $longest_key = max($longest_key, strlen($key) + 2); } else { $longest_key = max($longest_key, strlen($key)); } } foreach ($var as $key => $value) { if (is_numeric($key)) { $html .= str_repeat(' ', $indent) . str_pad($key, $longest_key, ' '); } else { $html .= str_repeat(' ', $indent) . str_pad('"' . self::htmlentities($key) . '"', $longest_key, ' '); } $html .= ' => '; $value = explode('
', self::var_dump_plain($value, $expLevel, $depth + 1, $done)); foreach ($value as $line => $val) { if ($line != 0) { $value[$line] = str_repeat(' ', $indent * 2) . $val; } } $html .= implode('
', $value) . '
'; } $html .= ']'; } } elseif (is_object($var)) { // Check for recursion foreach ($done as $prev) { if ($prev === $var) { $html .= 'object(' . get_class($var) . ') *RECURSION DETECTED*'; return $html; } } // Keep track of variables we have already processed to detect recursion $done[] = &$var; self::$hasArray=true; $uuid = 'include-php-' . uniqid() . mt_rand(1, 1000000); $html .= 'object(' . get_class($var) . ')
[
'; $varArray = (array) $var; $indent = 4; $longest_key = 0; foreach ($varArray as $key => $value) { if (substr($key, 0, 2) == "\0*") { unset($varArray[$key]); $key = 'protected:' . substr($key, 2); $varArray[$key] = $value; } elseif (substr($key, 0, 1) == "\0") { unset($varArray[$key]); $key = 'private:' . substr($key, 1, strpos(substr($key, 1), "\0")) . ':' . substr($key, strpos(substr($key, 1), "\0") + 1); $varArray[$key] = $value; } if (is_string($key)) { $longest_key = max($longest_key, strlen($key) + 2); } else { $longest_key = max($longest_key, strlen($key)); } } foreach ($varArray as $key => $value) { if (is_numeric($key)) { $html .= str_repeat(' ', $indent) . str_pad($key, $longest_key, ' '); } else { $html .= str_repeat(' ', $indent) . str_pad('"' . self::htmlentities($key) . '"', $longest_key, ' '); } $html .= ' => '; $value = explode('
', self::var_dump_plain($value, $expLevel, $depth + 1, $done)); foreach ($value as $line => $val) { if ($line != 0) { $value[$line] = str_repeat(' ', $indent * 2) . $val; } } $html .= implode('
', $value) . '
'; } $html .= ']'; } return $html; } /** * Convert entities, while preserving already-encoded entities. * * @param string $string The text to be converted * @return string */ public static function htmlentities($string, $preserve_encoded_entities = false) { if ($preserve_encoded_entities) { // @codeCoverageIgnoreStart if (defined('HHVM_VERSION')) { $translation_table = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES); } else { $translation_table = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES, self::mbInternalEncoding()); } // @codeCoverageIgnoreEnd $translation_table[chr(38)] = '&'; return preg_replace('/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/', '&', strtr($string, $translation_table)); } return htmlentities($string, ENT_QUOTES, self::mbInternalEncoding()); } /** * Wrapper to prevent errors if the user doesn't have the mbstring * extension installed. * * @param string $encoding * @return string */ protected static function mbInternalEncoding($encoding = null) { if (function_exists('mb_internal_encoding')) { return $encoding ? mb_internal_encoding($encoding) : mb_internal_encoding(); } // @codeCoverageIgnoreStart return 'UTF-8'; // @codeCoverageIgnoreEnd } } class dd { public static function run(...$arg){ array_map(function($x) { Debug::var_dump($x); }, $arg); die; } public static function table() { $args = func_get_args(); $value = $args[0]; if($args[0] === true){ $value = $args[1]; } if(is_array($value)){ echo "
"; echo $tr; echo " | "; $colp[] = $tr; } echo "|
"; if(is_array($val[$q])){ $y[] = true; $y[] = $val[$q]; call_user_func_array('dd', $y); }else{ echo $val[$q]; } echo " | "; } echo "|
"; echo $key; echo " | "; echo ""; echo $v; echo " | "; echo "
"; var_dump($value); echo ""; } } } class files { public static function exist(...$arg) { if(isset($arg[0])) { if(file_exists($arg[0])) { return true; }else{ return false; } } } public static function slug(...$arg){ if(isset($arg[0])){ $name = $arg[0]; $name = str_replace('"','',$name); $name = str_replace("'",'',$name); $name = str_replace(" ",'-',$name); $name = str_replace("@",'',$name); $name = str_replace(",",'',$name); $name = str_replace(".",'',$name); $name = str_replace("/",'',$name); $name = str_replace("|",'',$name); $name = str_replace("\\",'',$name); $name = str_replace("=",'',$name); $name = str_replace("+",'',$name); $name = str_replace("(",'',$name); $name = str_replace(")",'',$name); $name = str_replace("[",'',$name); $name = str_replace("]",'',$name); $name = str_replace(";",'',$name); $name = str_replace(":",'',$name); $name = str_replace("`",'',$name); $name = str_replace("#",'',$name); $name = str_replace("\$",'',$name); $name = str_replace("%",'',$name); $name = str_replace("^",'',$name); $name = str_replace("&",'',$name); $name = str_replace("?",'',$name); $name = str_replace("~",'',$name); return strtolower($name); } } public static function remove(...$arg){ if(isset($arg[0])){ if(file_exists($arg[0]) && $arg[0] != '' && $arg != '/' && $arg != 'web' && $arg != 'views' && $arg != 'vendor' && $arg != 'module' ){ unlink($arg[0]); } } } public static function write(...$arg) { if(isset($arg[0]) && isset($arg[1])) { $myfile = fopen($arg[0], "w") or die("Unable to open file!"); $txt = $arg[1]; fwrite($myfile, $txt); fclose($myfile); } } public static function read(...$arg) { $path = $arg[0]; if(!file_exists($path)){ return null; } $myfile = fopen($path, "r") or die("Unable to open file!"); $er = fread($myfile,filesize($path)); fclose($myfile); return $er; } } class Webs{ public static function map($path = ''){ $scan = scandir($path); $newArr = array_filter($scan,function($v){ if($v != "." && $v != ".."){ return $v; } }); $newArr = array_map(function($r) use ($path) { return $path.$r; }, $newArr); return $newArr; } } $env = explode("\n", files::read(SETUP_PATH.'.envvds')); class Tanggal{ private $dates = NULL; private $jarak = NULL; public function __construct(...$arg){ if(isset($arg[0])){ $textdate = new Text($arg[0]); $textdate = $textdate->replace('/','-')->get(); $this->dates = strtotime($textdate); }else{ $this->dates = strtotime(date('Y-m-d H-i-d')); } } public function format(...$arg){ if(isset($arg[0])){ return date($arg[0], $this->dates); } } public function id(){ return date('d-m-Y', $this->dates); } public function selisih(...$arg){ if(isset($arg[0])){ $pembanding = strtotime($arg[0]); $jarak = $pembanding - $this->dates; $jarak = $jarak / 60/ 60 / 24; // hari $this->jarak = $jarak; }else{ $pembanding = strtotime(date('Y-m-d h:i:s')); $jarak = $pembanding - $this->dates; $jarak = $jarak / 60/ 60 / 24; // hari $this->jarak = $jarak; } return $this; } public function banyakHari(){ if($this->jarak != NULL){ return $this->jarak; }else{ return 0; } } public function banyakBulan(){ if($this->jarak != NULL){ return round($this->jarak / 30); }else{ return 0; } } public function banyakTahun(){ if($this->jarak != NULL){ return round($this->jarak / 30 / 12); }else{ return 0; } } } class Text{ private $string; public function __construct(...$arg){ if(isset($arg[0])){ $this->string = $arg[0]; } return $this; } public function replace(...$arg){ if(isset($arg[0]) && isset($arg[1])){ $arg[] = $this->string; $this->string = str_replace(...$arg); } return $this; } public function slug(){ $name = $this->string; $name = str_replace('"','',$name); $name = str_replace("'",'',$name); $name = str_replace(" ",'-',$name); $name = str_replace("@",'',$name); $name = str_replace(",",'',$name); $name = str_replace(".",'',$name); $name = str_replace("/",'',$name); $name = str_replace("|",'',$name); $name = str_replace("\\",'',$name); $name = str_replace("=",'',$name); $name = str_replace("+",'',$name); $name = str_replace("(",'',$name); $name = str_replace(")",'',$name); $name = str_replace("[",'',$name); $name = str_replace("]",'',$name); $name = str_replace(";",'',$name); $name = str_replace(":",'',$name); $name = str_replace("`",'',$name); $name = str_replace("#",'',$name); $name = str_replace("\$",'',$name); $name = str_replace("%",'',$name); $name = str_replace("^",'',$name); $name = str_replace("&",'',$name); $name = str_replace("?",'',$name); $name = str_replace("~",'',$name); $this->string = $name; } public function get(){ return $this->string; } } foreach($env as $name => $val ){ if(strpos($val, "=") !== false){ $v = explode("=",$val); $val = new Text($v[1]); $val = $val ->replace("\n","") ->replace("\r","") ->replace("{APP}",APP) ->replace("{ROOT}",ROOT) ->get(); define(str_replace("\n","",$v[0]), $val); } }; if(strpos(URL,"/public") != ''){ // echo PATH.explode("/public",URL)[1]; // die(); echo ""; // die(); } class Link{ public static function redirect(...$arg){ if(isset($arg[0])){ $url = PATH.$arg[0]; echo ""; die(); } } } class Session{ public static function put($name = "", $data_arr = []) { $_SESSION[$name.SESSION] = $data_arr; } public static function delete($name = '') { unset($_SESSION[$name.SESSION]); } public static function get($name = "", $defaultnull = "") { if(isset($_SESSION[$name.SESSION])){ if ($_SESSION[$name.SESSION] != "") { return $_SESSION[$name.SESSION]; }else{ return $defaultnull; } }else{ if ($defaultnull != "") { return $defaultnull; }else{ return ""; } } } } // cek htaccess if(files::exist('.htaccess') === false) { files::write(); } class load{ public function __construct(...$arg){ foreach ($arg as $argument){ include_once SETUP_PATH.$argument.'.php'; } } } class Route { private static $route = []; private static $middleware = []; private static $use = []; private static $activeadd = NULL; private static $datamidleware = []; // midleware setup public function middleware(...$arg){ if(isset($arg[0])){ if(is_callable($arg[0])){ if(!isset(self::$middleware[self::$activeadd])){ self::$middleware[self::$activeadd] = []; } self::$middleware[self::$activeadd][] = $arg[0]; }else{ if(!isset(self::$middleware[self::$activeadd])){ self::$middleware[self::$activeadd] = []; } self::$middleware[self::$activeadd][] = $arg[0]; } } return $this; } public function addMidleware(...$arg){ if(isset($arg[0]) && isset($arg[1])){ self::$datamidleware[$arg[0]] = $arg[1]; } } public function cors($option = null){ if($option === "all"){ header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: GET, POST'); } return $this; } public function use(...$arg){ if(isset($arg[0])){ if(is_string($arg[0])){ if(!isset(self::$use[self::$activeadd])){ self::$use[self::$activeadd] = []; } self::$use[self::$activeadd][] = $arg[0]; } } return $this; } public static function session(...$arg){ if(isset($arg[0]) && $arg[0] == true){ defined('SESSION') or die(); if(files::exist(SETUP_PATH.'session53539'.SESSION) === false){ mkdir(SETUP_PATH.'session53539'.SESSION); } $filesession = SETUP_PATH.'session53539'.SESSION; if(session_status() === ''){ ini_set('session.save_path',realpath(dirname($_SERVER['DOCUMENT_ROOT']) . '/'.$filesession)); ini_set('session.gc_probability', 1); } session_start(); } } // add new route public static function add(...$argv){ $newRoute = []; if(isset($argv[0])){ if(substr( $argv[0], 0,1) != '/'){ $newRoute["url"] = PATH."/".$argv[0]; }else{ $newRoute["url"] = PATH.$argv[0]; } self::$activeadd = $newRoute['url']; $pathofroute = []; $pathofparams = []; $newRoute['totpath'] = 0; $newRoute['action-type'] = NULL; $newRoute['action'] = NULL; foreach(explode("/",$newRoute['url']) as $key => $pathRoute){ if(strpos($pathRoute, "{") !== false && strpos($pathRoute, "}") !== false){ $pathofparamsnew = []; $pathofparamsnew['position'] = $key; $pathofparamsnew['nameparams'] = $pathRoute; $pathofparams[] = $pathofparamsnew; $pathofroute[] = $pathRoute; $newRoute['totpath'] +=1; }else{ $newRoute['totpath'] +=1; $pathofroute[] = $pathRoute; } } $newRoute['routepath'] = $pathofroute; $newRoute['params'] = $pathofparams; // cek seccond parameters if(isset($argv[1])){ $action = $argv[1]; if( is_callable($action) ){ $newRoute['action-type'] = 'function'; $newRoute['action'] = $argv[1]; }else{ if(strpos($argv[1],'@') !== false){ $newRoute['action-type'] = 'controller'; $newRoute['action'] = $argv[1]; } } } } self::$route[] = $newRoute; return (new self); } // validation route after call private static function validating(...$argv){ if(isset($argv[0])){ $parameterone = $argv[0]; $routeactive = self::$route[$parameterone]; if($routeactive['action-type'] != NULL){ if($routeactive['action-type'] == 'function'){ $pathurl = explode('/',URL); $params = []; foreach($routeactive['params'] as $getpar){ $params[] = $pathurl[$getpar['position']]; } $params = (array) $params; error_reporting(0); if(isset(self::$use[$routeactive['url']])){ foreach(self::$use[$routeactive['url']] as $usecall){ include_once SETUP_PATH.$usecall; } } error_reporting(-1); if(isset(self::$middleware[$routeactive['url']])){ foreach(self::$middleware[$routeactive['url']] as $midlecall){ if(is_callable($midlecall)){ $midlecall(); }else{ self::$datamidleware[$midlecall](); } } } $routeactive['action'](...$params); die(); }else{ $pathurl = explode('/',URL); $params = []; foreach($routeactive['params'] as $getpar){ $params[] = $pathurl[$getpar['position']]; } $params = (array) $params; error_reporting(1); if(isset(self::$use[$routeactive['url']])){ foreach(self::$use[$routeactive['url']] as $usecall){ include_once SETUP_PATH.$usecall; } } $path = explode("@",$routeactive['action']); $pathDir = SETUP_PATH.$path[0]; if(file_exists($pathDir.'.php')){ error_reporting(-1); include_once $pathDir.'.php'; if(isset(self::$middleware[$routeactive['url']])){ foreach(self::$middleware[$routeactive['url']] as $midlecall){ if(is_callable($midlecall)){ $midlecall(); }else{ self::$datamidleware[$midlecall](); } } } $pat = explode('/',$path[0]); $pcount = count($pat) - 1; $nameclass = ucfirst($pat[$pcount]); $namefunc = $path[1]; $ripText = " ".$nameclass."::".$namefunc."(...\$params); "; eval($ripText); }else{ $route = self::$route; foreach($route as $y => $founderror){ if($founderror['url'] == '/404'){ (new self)->validating($y); die(); } } echo "/404