Skip to content

Instantly share code, notes, and snippets.

@adibenc
Last active October 13, 2020 08:36
Show Gist options
  • Save adibenc/44d1c9a35b51d99511a3731f93680186 to your computer and use it in GitHub Desktop.
Save adibenc/44d1c9a35b51d99511a3731f93680186 to your computer and use it in GitHub Desktop.
php native manual debugger & util
<?php
defined('DEBUG_SEPARATOR') or define('DEBUG_SEPARATOR', "debug ================================================================");
// include('../dhelp/common.php');
if (!function_exists('ds')) {
function ds($n = 72)
{
echo str_repeat("=", $n);
}
}
if (!function_exists('preout')) {
function preout($v)
{
echo "<pre>";
var_dump($v);
echo "</pre>";
}
}
if (!function_exists('preson')) {
function preson($v)
{
echo "<pre>";
echo json_encode($v,JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
echo "</pre>";
}
}
if (!function_exists('presonRet')) {
function presonRet($v)
{
return json_encode($v,JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
}
}
if (!function_exists('jsonResponse')) {
function jsonResponse($respCode,$msg,$data)
{
$r=[
'status' => $respCode ,
'message' => $msg ,
'data' => $data
];
return response()->json($r, $respCode);
}
}
if (!function_exists('toFile')) {
function toFile($content = "cnt", $file = "file")
{
$f = fopen($file, "w");
fwrite($f,$content);
fclose($f);
return true;
}
}
if (!function_exists('arrayGet')) {
function arrayGet($array, $key, $default = NULL)
{
return isset($array[$key]) ? $array[$key] : $default;
}
}
//get stisla file from
if (!function_exists('stisla')) {
function stisla($file)
{
return config('view.ui.template').$file;
}
}
// src="{{ architect('$1')}}"></script>
if (!function_exists('architect')) {
function architect($file)
{
return config('view.ui.architect.template').$file;
}
}
if (!function_exists('getSessKeyFromState')) {
// $referer = $_SERVER['HTTP_REFERER'];
// get sesskey
function getSessKeyFromState($referer)
{
preout($referer);
$kejaksaan = strpos($referer, "https://api.kejaksaan.go.id") === 0;
if(!$kejaksaan){
return false;
}
$sesskey = "-";
$parsedReferer = parse_url($referer);
parse_str($parsedReferer['query'], $queries);
parse_str($queries['state'], $queries2);
$q1sesskey = array_key_exists('sesskey', $queries2);
$q2sesskey = array_key_exists('amp;sesskey', $queries2);
if($q1sesskey){
// preout($queries2['amp;sesskey']);
$sesskey = $queries2['sesskey'];
return $sesskey;
}
if($q2sesskey){
// preout($queries2['amp;sesskey']);
$sesskey = $queries2['amp;sesskey'];
return $sesskey;
}
// preout(array_key_exists('sesskey', $queries2));
return false;
}
}
if (!function_exists('anc')) {
// clean sesskey
function anc($link)
{
?>
teruskan :
<a href="<?= $link ?>"><?= $link ?></a>
<?php
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment