Update Helper & Sample .env

This commit is contained in:
Daeng Deni Mardaeni 2023-05-25 17:38:40 +07:00
parent 4d2959b538
commit 05b26a4b95
2 changed files with 460 additions and 335 deletions

View File

@ -4,6 +4,11 @@ APP_KEY=
APP_DEBUG=true APP_DEBUG=true
APP_URL=http://localhost:8000 APP_URL=http://localhost:8000
METHOD_AUTH=usermanager
IP_USER_MANAGER=10.0.20.68
PORT_USER_MANAGER=82
APP_ID=WOF
LOG_CHANNEL=stack LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug LOG_LEVEL=debug

View File

@ -423,3 +423,123 @@ if (!function_exists('getIcon')) {
return theme()->getIcon($name, $class, $type); return theme()->getIcon($name, $class, $type);
} }
} }
function verify_user($id, $passwd, $SERVER_ADDR, $IPUserManager, $portUserManager, $appId)
{
$USERMANPROG = "user_verification.php";
$sock = fsockopen("tcp://" . $IPUserManager, $portUserManager, $errno, $errstr, 30);
if (!$sock) die("$errstr ($errno)\n");
$data = "appsid=" . urlencode($appId) . "&loginid=" . urlencode($id) . "&passwd=" . urlencode($passwd) . "&addr=" . $SERVER_ADDR . "&version=2";
//echo "data: $data <BR>";
fwrite($sock, "POST /user_verification_dev.php HTTP/1.0\r\n");
fwrite($sock, "Host: $IPUserManager\r\n");
fwrite($sock, "Content-type: application/x-www-form-urlencoded\r\n");
fwrite($sock, "Content-length: " . strlen($data) . "\r\n");
fwrite($sock, "Accept: */*\r\n");
fwrite($sock, "\r\n");
fwrite($sock, "$data\r\n");
fwrite($sock, "\r\n");
$headers = "";
while ($str = trim(fgets($sock, 4096))) $headers .= "$str\n";
$body = "";
while (!feof($sock)) $body .= fgets($sock, 4096);
fclose($sock);
return decompress($body);
}
function getAllowableScript($sessionMenu)
{
//$sessionMenu = $_SESSION['MENU'];
if (!empty($sessionMenu)) {
$tempMenuArrayLine = explode('-', $sessionMenu);
//print_r($tempMenuArrayLine);
if (count($tempMenuArrayLine) > 0) {
foreach ($tempMenuArrayLine as $tkey => $tval) {
$tempMenuArray = explode('|', $tval);
if (count($tempMenuArray) > 0) {
foreach ($tempMenuArray as $mkey => $mval) {
[$menukey, $menuval] = explode('>', $mval);
if ($menukey === 'LINK') {
$SCRIPT_ALLOW[$menuval] = 1;
}
//$menu[$menuCounter][$menukey] = $menuval;
}
//$menuCounter++;
}
}
}
}
return $SCRIPT_ALLOW;
}
function decompress($data)
{
$text = '';
$total = strlen($data);
for ($j = 0; $j < $total; $j = $j + 2) {
$text .= chr(hexdec(substr($data, $j, 2)));
}
return $text;
}
function compress($data)
{
$text = '';
$total = strlen($data);
for ($i = 0; $i < $total; $i++) {
$temp = dechex(ord(substr($data, $i, 1)));
if (strlen($temp) < 2) {
$temp = '0' . $temp;
}
$text .= $temp;
}
return $text;
}
function jsonToView($jsonText = '')
{
$arr = json_decode($jsonText, true);
$html = "";
if ($arr && is_array($arr)) {
$html .= _arrayToHtmlTableRecursive($arr);
}
return $html;
}
function _arrayToHtmlTableRecursive($arr)
{
$str = "<table><tbody>";
foreach ($arr as $key => $val) {
$str .= "<tr>";
$str .= "<td>$key</td>";
$str .= "<td>";
if (is_array($val)) {
if (!empty($val)) {
$str .= _arrayToHtmlTableRecursive($val);
}
} else {
$str .= "<strong>$val</strong>";
}
$str .= "</td></tr>";
}
$str .= "</tbody></table>";
return $str;
}