diff --git a/system/autoload/Hookers.php b/system/autoload/Hookers.php new file mode 100644 index 0000000..f15d0a9 --- /dev/null +++ b/system/autoload/Hookers.php @@ -0,0 +1,57 @@ + $name, + "admin" => $admin, + "position" => $position, + "icon" => $icon, + "function" => $function, + "label" => $label, + "color" => $color, + "auth" => $auth + ]; +} + +$hook_registered = array(); + +function register_hook($action, $function){ + global $hook_registered; + $hook_registered[] = [ + 'action' => $action, + 'function' => $function + ]; +} + +function run_hook($action){ + global $hook_registered; + foreach($hook_registered as $hook){ + if($hook['action'] == $action){ + if(function_exists($hook['function'])){ + call_user_func($hook['function']); + } + } + } +} diff --git a/system/autoload/Http.php b/system/autoload/Http.php new file mode 100644 index 0000000..7728075 --- /dev/null +++ b/system/autoload/Http.php @@ -0,0 +1,117 @@ +0){ + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + } + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + if (!empty($http_proxy)) { + curl_setopt($ch, CURLOPT_PROXY, $http_proxy); + if (!empty($http_proxyauth)) { + curl_setopt($ch, CURLOPT_PROXYUSERPWD, $http_proxyauth); + } + } + $server_output = curl_exec($ch); + if (curl_errno($ch)) { + $error_msg = curl_error($ch); + } + curl_close($ch); + if($admin && $error_msg){ + r2(U . 'dashboard', 'd', $error_msg); + } + return ($server_output) ? $server_output : $error_msg; + } + + public static function postJsonData($url, $array_post, $headers = [], $basic = null) + { + global $http_proxy, $http_proxyauth, $admin; + $headers[] = 'Content-Type: application/json'; + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15); + curl_setopt($ch, CURLOPT_TIMEOUT, 15); + curl_setopt($ch, CURLOPT_VERBOSE, false); + curl_setopt($ch, CURLINFO_HEADER_OUT, false); + if (!empty($http_proxy)) { + curl_setopt($ch, CURLOPT_PROXY, $http_proxy); + if (!empty($http_proxyauth)) { + curl_setopt($ch, CURLOPT_PROXYUSERPWD, $http_proxyauth); + } + } + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($array_post)); + if(is_array($headers) && count($headers)>0){ + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + } + if (!empty($basic)) { + curl_setopt($ch, CURLOPT_USERPWD, $basic); + } + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $server_output = curl_exec($ch); + if (curl_errno($ch)) { + $error_msg = curl_error($ch); + } + curl_close($ch); + if($admin && $error_msg){ + r2(U . 'dashboard', 'd', $error_msg); + } + return ($server_output) ? $server_output : $error_msg; + } + + + public static function postData($url, $array_post, $headers = [], $basic = null) + { + global $http_proxy, $http_proxyauth, $admin; + $headers[] = 'Content-Type: application/x-www-form-urlencoded'; + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15); + curl_setopt($ch, CURLOPT_TIMEOUT, 15); + curl_setopt($ch, CURLOPT_VERBOSE, false); + curl_setopt($ch, CURLINFO_HEADER_OUT, false); + if (!empty($http_proxy)) { + curl_setopt($ch, CURLOPT_PROXY, $http_proxy); + if (!empty($http_proxyauth)) { + curl_setopt($ch, CURLOPT_PROXYUSERPWD, $http_proxyauth); + } + } + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array_post)); + if(is_array($headers) && count($headers)>0){ + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + } + if (!empty($basic)) { + curl_setopt($ch, CURLOPT_USERPWD, $basic); + } + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $server_output = curl_exec($ch); + if (curl_errno($ch)) { + $error_msg = curl_error($ch); + } + curl_close($ch); + if($admin && $error_msg){ + r2(U . 'dashboard', 'd', $error_msg); + } + return ($server_output) ? $server_output : $error_msg; + } +} diff --git a/system/autoload/Lang.php b/system/autoload/Lang.php new file mode 100644 index 0000000..d5569ab --- /dev/null +++ b/system/autoload/Lang.php @@ -0,0 +1,248 @@ +diff($ago); + + $diff->w = floor($diff->d / 7); + $diff->d -= $diff->w * 7; + + $string = array( + 'y' => Lang::T('year'), + 'm' => Lang::T('month'), + 'w' => Lang::T('week'), + 'd' => Lang::T('day'), + 'h' => Lang::T('hour'), + 'i' => Lang::T('minute'), + 's' => Lang::T('second'), + ); + foreach ($string as $k => &$v) { + if ($diff->$k) { + $v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 's' : ''); + } else { + unset($string[$k]); + } + } + + if (!$full) + $string = array_slice($string, 0, 1); + return $string ? implode(', ', $string) .' '. Lang::T('ago') : Lang::T('just now'); + } + + public static function nl2br($text) + { + return nl2br($text); + } + + public static function arrayCount($arr) + { + if (is_array($arr)) { + return count($arr); + } else if (is_object($arr)) { + return count($arr); + } else { + return 0; + } + } + + public static function getNotifText($key) + { + global $_notifmsg, $_notifmsg_default; + if (isset($_notifmsg[$key])) { + return $_notifmsg[$key]; + } else { + return $_notifmsg_default[$key]; + } + } + + public static function ucWords($text) + { + return ucwords(str_replace('_', ' ', $text)); + } + + public static function randomUpLowCase($text) + { + $jml = strlen($text); + $result = ''; + for ($i = 0; $i < $jml; $i++) { + if (rand(0, 99) % 2) { + $result .= strtolower(substr($text, $i, 1)); + } else { + $result .= substr($text, $i, 1); + } + } + return $result; + } + + /** + * $pad_type + * 0 Left + * 1 right + * 2 center + * */ + public static function pad($text, $pad_string = ' ', $pad_type = 0) + { + global $config; + $cols = 37; + if ($config['printer_cols']) { + $cols = $config['printer_cols']; + } + $text = trim($text); + $texts = explode("\n", $text); + if (count($texts) > 1) { + $text = ''; + foreach ($texts as $t) { + $text .= self::pad(trim($t), $pad_string, $pad_type) . "\n"; + } + return $text; + } else { + return str_pad(trim($text), $cols, $pad_string, $pad_type); + } + } + + public static function pads($textLeft, $textRight, $pad_string = ' ') + { + global $config; + $cols = 37; + if ($config['printer_cols']) { + $cols = $config['printer_cols']; + } + return $textLeft . str_pad($textRight, $cols - strlen($textLeft), $pad_string, 0); + } + + public static function translate($txt, $to = 'id') + { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, "https://translate.google.com/m?hl=en&sl=en&tl=$to&ie=UTF-8&prev=_m&q=" . urlencode($txt)); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone; CPU OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/28.1 Mobile/15E148 Safari/605.1.15"); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); + curl_setopt($ch, CURLOPT_TIMEOUT, 5); + curl_setopt($ch, CURLOPT_HEADER, 0); + $hasil = curl_exec($ch); + curl_close($ch); + $temp = explode('
Directory access is forbidden.
+ + \ No newline at end of file