Initial import

This commit is contained in:
sas.fajri
2026-05-25 20:01:37 +07:00
commit 710d7c1b97
10371 changed files with 2381698 additions and 0 deletions

View File

@@ -0,0 +1,97 @@
<?php
/*
### Auth API
- Functions
- login x
- logout
template function {
$this->sys_debug();
try {
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
*/
class Auth extends MY_Controller {
var $db_onedev;
public function index()
{
echo "AUTH API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
}
function isLogin() {
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
} else {
$prm = $this->sys_input;
$data = array(
"user" => $this->sys_user
);
$this->sys_ok($data);
}
}
function login() {
$prm = $this->sys_input;
try {
//existing password enc
$sm_password = md5($this->one_salt . $prm["password"] .
$this->one_salt);
$query = $this->db_onedev->query("select M_UserID, M_UserUsername,
M_UserGroupDashboard
from m_user
join m_usergroup on m_userm_usergroupid = m_usergroupid
where M_UserUsername=? and M_UserPassword=?
and M_UserIsActive = 'Y'
",array($prm["username"], $sm_password));
echo $query;
if (!$query) {
$message = $this->db_onedev->error();
$this->sys_error($message);
exit;
}
$rows = $query->result_array();
if (count($rows) > 0 ) {
$user = $rows[0];
$user['M_UserGroupDashboard'] = "https://{$_SERVER['SERVER_NAME']}/{$user['M_UserGroupDashboard']}";
$token = JWT::encode($user,$this->SECRET_KEY);
$data = array(
"user" => $user,
"token" => $token
);
$query = $this->db_onedev->query("update m_user SET M_UserIsLoggedIn = 'Y', M_UserLastAccess = now() WHERE M_UserID = ?
",array($user['M_UserID']));
if (!$query) {
$message = $this->db_onedev->error();
$this->sys_error($message);
exit;
}
$this->sys_ok($data);
exit;
}
$this->sys_error_db("Invalid UserName / Password");
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function logout() {
$this->sys_error("ok");
}
}
?>