addMidleware('post', function(){ new load('web/post'); Post::cek(); }); $route->addMidleware('cekloginadmin', function(){ new load('module/array'); new load('web/post'); Post::userLogin(); if(Session::get('login') == ''){ Session::put('message', 'silahkan login terlebih dahulu!'); Link::redirect('/'); } }); $route->session(true); $route->add(404, function(){ new load('vendor/autoload', 'web/post'); Post::err(); }); // login $route->add('/test', function(){ echo "
";

})
->use('vendor/autoload.php')
->use('module/db.php')
->use('module/perusahaan.php');

$route->add('/admin',  function(){
    
    header("Location: /admin/dashboard");

})
->use('vendor/autoload.php')
->use('module/db.php')
->use('module/perusahaan.php');

// login
$route->add('/',  function(){
    ini_set('display_errors', 1);
    View::render('landing.home');
})
->use('vendor/autoload.php')
->use('module/db.php')
->use('module/perusahaan.php');

$route->add('/tes/c',  function(){
    Cookie::setCookie('tc', [
        "success" => true
    ], time() +(3600*8) );
    echo json_encode([
        "success" => true
    ]);
})
->use('vendor/autoload.php')
->use('module/db.php')
->use('module/perusahaan.php');

$route->add('/tes/g',  function(){
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);

    $tc = Cookie::getCookie('tc');
    if($tc){
        var_dump($tc);
    }else{
        var_dump("nun");
    }
})
->use('vendor/autoload.php')
->use('module/db.php')
->use('module/perusahaan.php');

// login
$route->add('/api/update/bb',  function(){
    new load('web/updatebb/bb');
})
->use('vendor/autoload.php')
->use('module/db.php')
->use('module/perusahaan.php');

// login
$route->add('/api/update/bb/cek',  function(){
    new load('web/updatebb/cek');
})
->use('vendor/autoload.php')
->use('module/db.php')
->use('module/perusahaan.php');
// login
$route->add('/api/update/master',  function(){
    $tahun = date('Y');
    $bulan = date('m');
    DB::query("call group_call($tahun,$bulan)");
    echo json_encode([
        "success" => true,
        "message" => "berhasil update"
    ]);
})
->use('vendor/autoload.php')
->use('module/db.php')
->use('module/perusahaan.php');

$route->add('admin/fm',  function(){
    new load('module/fm');
})
->use('vendor/autoload.php')
->use('module/db.php')
->use('module/perusahaan.php')
->middleware('cekloginadmin');

$route->add('/module/app',  function(){
    ini_set('display_errors', 1);
    View::render('landing.module',[
        "kode" => ""
    ]);
})
->use('vendor/autoload.php')
->use('module/db.php')
->use('module/perusahaan.php');

$route->add('/module/app/{kode}',  function($kode){
    ini_set('display_errors', 1);
    View::render('landing.module',[
        "kode" => $kode
    ]);
})
->use('vendor/autoload.php')
->use('module/db.php')
->use('module/perusahaan.php');



$route->add('/demo-print',  function(){
    View::render('landing.demo');
})
->use('vendor/autoload.php')
->use('module/db.php')
->use('module/perusahaan.php');

$route->add('/demo-request',  function(){
    View::render('landing.request');
})
->use('vendor/autoload.php')
->use('module/db.php')
->use('module/perusahaan.php');

$route->add('/cert-print',  function(){
    ini_set('display_startup_errors', 1);
    echo Files::read(SETUP_PATH.'certificate/override.crt');
})
->use('vendor/autoload.php')
->use('module/db.php')
->use('module/perusahaan.php');

$route->add('/sign-print',  function(){
    $KEY = SETUP_PATH.'certificate/key.pem';
    $req = $_POST['request'];
    $privateKey = openssl_get_privatekey(file_get_contents($KEY) /*, $PASS */);
    $signature = null;
    openssl_sign($req, $signature, $privateKey, "sha512"); // Use "sha1" for QZ Tray 2.0 and older
    if ($signature) {
        header("Content-type: text/plain");
        echo base64_encode($signature);
        exit(0);
    }
    echo '

Error signing message

'; http_response_code(500); exit(1); }) ->use('vendor/autoload.php') ->use('module/db.php') ->use('module/perusahaan.php'); $route->add('/admin/laporan/kartukekayaan/{faktur}', 'module/http/api@kartukekayaan') ->use('vendor/autoload.php') ->use('module/db.php') ->use('module/dd.php') ->use('module/perusahaan.php') //->middleware('cekloginadmin') ; // login access $route->add('loginrequest', function(){ new load('web/loginadmin'); AdminVerify::cek(1); }) ->use('module/db.php') ->middleware('post'); $route->add('loginrequestadmin', function(){ new load('web/loginadmin'); AdminVerify::cek(3); }) ->use('module/db.php') ->middleware('post'); $route->add('loginrequestacc', function(){ new load('web/loginadmin'); AdminVerify::cek(2); }) ->use('module/db.php') ->middleware('post'); $route->add('/script/{file}', function($file){ header('Pragma: public'); header('Cache-Control: max-age=86400, public'); header('Expires: '. gmdate('D, d M Y H:i:s \G\M\T', time() + (86400 * 360) )); header('Content-Type: application/javascript'); $x = base64_decode( explode("||",$file)[0] ); $x = Files::read(SETUP_PATH."script/".$x); $x = str_replace("{time}", View::time() , $x); $x = str_replace("{js}", PATH."/assets-js/", $x); $x = str_replace("{{PATH}}",PATH, $x); $x = str_replace("{{APPNAME}}",APPNAME, $x); $x = str_replace("{{ APPNAME }}",APPNAME, $x); $x = str_replace("{{ PATH }}",PATH, $x); echo $x; }); $route->add('assets-js/{name}', function($name){ $file = SETUP_PATH . "script/". join("/", explode("-", explode("?", $name )[0] ) ) ; ob_start(); header('Pragma: public'); header('Cache-Control: max-age=86400, public'); header('Expires: '. gmdate('D, d M Y H:i:s \G\M\T', time() + (86400 * 360) )); header('Content-Type: application/javascript'); if(file_exists($file)){ $x = Files::read($file); $x = str_replace("{time}", View::filetimes(), $x); $x = str_replace("{js}", PATH."/assets-js/", $x); $x = str_replace("{{PATH}}", PATH, $x); $x = str_replace("{{ PATH }}", PATH, $x); $x = str_replace("{{APPNAME}}",APPNAME, $x); $x = str_replace("{{ APPNAME }}",APPNAME, $x); $x = str_replace("{{ SETUP_PATH }}", SETUP_PATH, $x); $x = str_replace("{{ ASSET }}", ASSET, $x); echo $x; } echo " "; }); $route->add('assets-jsm/{name}', function($name){ ob_start(); header('Pragma: public'); header('Cache-Control: max-age=86400, public'); header('Expires: '. gmdate('D, d M Y H:i:s \G\M\T', time() + (86400 * 360) )); header('Content-Type: application/javascript'); View::multijs($name); }); $route->add('assets-jsx/{main}', function($ax){ ob_start(); header('Pragma: public'); header('Cache-Control: max-age=86400, public'); header('Expires: '. gmdate('D, d M Y H:i:s \G\M\T', time() + (86400 * 360) )); header('Content-Type: application/javascript'); View::multijsx(); }); // login out $route->add('/admin/logout', function(){ Session::delete('login'); Link::redirect('/'); }); $route->add('/alive', function(){ header('Content-Type: application/javascript'); echo "window.statusUserActive = 1;"; }); $route->add('/lv', function(){ echo View::sc('file.js'); }); $route->add('admin', function(){ echo ""; }); $route->add('/db/api', 'module/http/app@api') ->use('vendor/autoload.php') ->use('module/db.php') ->use('module/help.php') ->use('module/perusahaan.php') ->middleware('cekloginadmin') ->middleware('post') ; $route->add('/jurubayar/api', 'module/http/jurubayar@api') ->use('vendor/autoload.php') ->use('module/db.php') ->use('module/help.php') ->use('module/perusahaan.php') // ->middleware('cekloginadmin') // ->middleware('post') ; $route->add('/db/api/multiple', 'module/http/app@multiple') ->use('vendor/autoload.php') ->use('module/db.php') ->use('module/help.php') ->use('module/perusahaan.php') ->middleware('cekloginadmin') ->middleware('post'); $route->add('/admin/api/connection', 'module/http/api@connection') ->use('vendor/autoload.php') ->use('module/db.php') ->use('module/dd.php') ->use('module/perusahaan.php') ->middleware('cekloginadmin'); $route->add('/admin/master/api/data', 'module/http/api@master') ->use('vendor/autoload.php') ->use('module/db.php') ->use('module/dd.php') ->use('module/perusahaan.php') ->middleware('cekloginadmin'); $route->add('/admin/laporan/kartupiutang/{faktur}', 'module/http/api@kartupiutang') ->use('vendor/autoload.php') ->use('module/db.php') ->use('module/dd.php') ->use('module/perusahaan.php') ->middleware('cekloginadmin'); $route->add('/admin/laporan/tagihan/{faktur}', 'module/http/api@tagihan') ->use('vendor/autoload.php') ->use('module/db.php') ->use('module/dd.php') ->use('module/perusahaan.php') ->middleware('cekloginadmin'); $route->add('/upload/data/anggota', function(){ ini_set('display_errors', 1); $ok = $_POST['ok']; $start = $_POST['start']; $end = $_POST['end']; $tipe = $_POST['tipe']; $enm = $_POST['enm']; $ft = $enm.$tipe; $s = []; if($start != $end){ if(!file_exists($ft)){ $s[] = $ok; Files::write($ft, json_encode($s, true)); }else{ $s = json_decode(Files::read($ft),true); $s[] = $ok; Files::write($ft, json_encode($s, true)); } }else{ $s = json_decode(Files::read($ft),true); $s[] = $ok; unlink($ft); $sx = ""; foreach ($s as $key => $t) { $sx .= $t; } $sx = json_decode(base64_decode($sx),true); foreach ($sx as $key => $rt) { $e = (object) $rt; DB::query("truncate $e->table"); DB::query($e->data); } echo json_encode([ "status" => "success" ]); } }) ->use('vendor/autoload.php') ->use('module/db.php') ->use('module/help.php') ->use('module/perusahaan.php') ->use('module/datatable.php') ->middleware('cekloginadmin') ->middleware('post'); $route->add('/upload/data/excel/api', function(){ ini_set('display_errors', 0); $ok = $_POST['ok']; $start = $_POST['start']; $end = $_POST['end']; $tipe = $_POST['tipe']; $enm = $_POST['enm']; $ft = $enm.$tipe; $s = []; if($start != $end){ if(!file_exists($ft)){ $s[] = $ok; Files::write($ft, json_encode($s, true)); }else{ $s = json_decode(Files::read($ft),true); $s[] = $ok; Files::write($ft, json_encode($s, true)); } }else{ $s = json_decode(Files::read($ft),true); $s[] = $ok; unlink($ft); $sx = ""; foreach ($s as $key => $t) { $sx .= $t; } $sx = json_decode(base64_decode($sx),true); foreach ($sx as $key => $rt) { $e = (object) $rt; DB::query($e->table); DB::query($e->data); } echo json_encode([ "status" => "success" ]); } }) ->use('vendor/autoload.php') ->use('module/db.php') ->use('module/help.php') ->use('module/perusahaan.php') ->use('module/datatable.php') ->middleware('cekloginadmin') ->middleware('post'); foreach(Webs::map(SETUP_PATH.'web/api/') as $pathLoad){ try{ include_once $pathLoad; }catch(Exception $e){ // throw error } }; foreach(Webs::map(SETUP_PATH.'web/laporan/') as $pathLoad){ try{ include_once $pathLoad; }catch(Exception $e){ // throw error } }; foreach(Webs::map(SETUP_PATH.'web/moduleTest/') as $pathLoad){ try{ include_once $pathLoad; }catch(Exception $e){ // throw error } }; $route->add('/push/acc', function(){ Bug::show(); $path = "../../acc"; $path2 = "../../acc/public"; $file = "../../acc/.htaccess"; $file2 = "../../acc/index.php"; $htaccess = Files::read(".htaccess"); $index = Files::read("../txt.txt"); if(!file_exists($path)){ mkdir($path); } if(!file_exists($path2)){ mkdir($path2); } Files::write($file2, $index); }); $route->add('/push/administrator', function(){ Bug::show(); $path = "../../administrator"; $path2 = "../../administrator/public"; $file = "../../administrator/.htaccess"; $file2 = "../../administrator/index.php"; $htaccess = Files::read(".htaccess"); $index = Files::read("../txt2.txt"); if(!file_exists($path)){ mkdir($path); } if(!file_exists($path2)){ mkdir($path2); } Files::write($file2, $index); Files::write($file, $htaccess); var_dump(Files::read($file)); }); $route->add('/push/vds', function(){ Bug::show(); $path = "../../vdsadmin"; $path2 = "../../vdsadmin/public"; $file = "../../vdsadmin/.htaccess"; $file2 = "../../vdsadmin/index.php"; $htaccess = Files::read(".htaccess"); $index = Files::read("../txt3.txt"); if(!file_exists($path)){ mkdir($path); } if(!file_exists($path2)){ mkdir($path2); } Files::write($file2, $index); Files::write($file, $htaccess); var_dump(Files::read($file)); }); if(APPNAME == 'usp' || APPNAME == 'acc'){ foreach(Webs::map(SETUP_PATH.'web/admin/') as $pathLoad){ include_once $pathLoad; }; } if(APPNAME == 'vds'){ foreach(Webs::map(SETUP_PATH.'web/vds/') as $pathLoad){ include_once $pathLoad; }; } if(APPNAME == 'setup'){ foreach(Webs::map(SETUP_PATH.'web/setup/') as $pathLoad){ include_once $pathLoad; }; } $route->add('/newid', function(){ echo id::new(); }); $route->add('/cron', function(){ var_dump(ROOT.'/usp/'); $cron = new NN\Module\crontab(); var_dump($cron); }) ->use('module/cron.php') ; $route->add('/testing-script', 'module/http/test@index') ->use('vendor/autoload.php') ->use('module/db.php') ->use('module/dd.php') ->use('module/perusahaan.php'); $route->call();