' . $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 ""; if(isset($value[0])){ if(count($value) > 0){ $obj = array_keys((array) $value[0]); $colp = []; echo ""; foreach($obj as $key => $tr){ echo ""; $colp[] = $tr; } echo ""; foreach($value as $val){ $val = (array) $val; echo ""; foreach($colp as $q){ echo ""; } echo ""; } } }else{ foreach($value as $key => $v){ echo ""; echo ""; echo ""; echo ""; } } // echo "
"; echo $tr; echo "
"; if(is_array($val[$q])){ $y[] = true; $y[] = $val[$q]; call_user_func_array('dd', $y); }else{ echo $val[$q]; } echo "
"; echo $key; echo ""; echo $v; echo "
"; if ($args[0] !== true) { die(); } }else{ 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.'.envsetup')); 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
page not found"; } } } } } // starting route public static function call(){ $route = self::$route; // cari data yang sesuai dengan URL // cek url; foreach($route as $key => $routedata){ if($routedata['url'] == URL){ (new self)->validating($key); die(); } } $pathurl = explode('/',URL); $countpathurl = count($pathurl); // cek url base on count path of url and filter it $pathofroot = array_filter($route, function(...$arg) use ($countpathurl, $pathurl) { if($arg[0]['totpath'] == $countpathurl){ return $arg; } }, ARRAY_FILTER_USE_BOTH ); $capable = array_map(function(...$arg) use($pathurl){ $data = $arg[0]; $data['compability'] = 0; foreach($data['routepath'] as $kk => $root){ if($pathurl[$kk] == $root){ $data['compability'] += 1; } } return $data['compability']; }, $pathofroot); $rr = [-1,-2]; foreach($capable as $n){ $rr[] = $n; } $capable = max(...$rr); $get = array_map(function(...$arg) use($pathurl){ $data = $arg[0]; $data['compability'] = 0; foreach($data['routepath'] as $kk => $root){ if($pathurl[$kk] == $root){ $data['compability'] += 1; } } return $data; }, $pathofroot); $getdata = array_map(function(...$arg){ return $arg[0]; },array_filter($get, function(...$arg) use ($capable) { if($arg[0]['compability'] == $capable && $capable > 1){ return $arg[0]; } })); function serachParamTrueOrFalse(...$arg){ function isparams(...$ssa){ $res = false; foreach($ssa[1] as $s){ if($s['position'] == $ssa[0]){ $res = true; } } return $res; } $result = true; foreach($arg[2] as $key => $prm){ if(isparams($key, $arg[1]) != true){ if($arg[0][$key] != $prm){ $result = false; }; } } return $result; } if(count($getdata) > 0){ foreach($getdata as $key => $calldata){ $url = $calldata['url']; if(serachParamTrueOrFalse($calldata['routepath'], $calldata["params"], $pathurl) == true){ foreach($route as $numroute => $routes){ if($routes['url'] == $url){ (new self)->validating($numroute); die(); } } }else{ foreach($route as $y => $founderror){ if($founderror['url'] == PATH . '/404'){ (new self)->validating($y); die(); } } echo "/404
page not found"; }; die(); }; }else{ foreach($route as $y => $founderror){ if($founderror['url'] == PATH . '/404'){ (new self)->validating($y); die(); } } echo "/404
page not found"; } } } // cek web folder if(files::exist(SETUP_PATH.'web') === false){ mkdir(SETUP_PATH.'web'); if(files::exist(SETUP_PATH.'web/route.php') === false){ files::write(SETUP_PATH.'web/route.php', "call();"); include_once SETUP_PATH.'web/route.php'; } }else{ include_once SETUP_PATH.'web/route.php'; }