|
- #include "./modules/http.mod.hsp"
- #include "./modules/setting.mod.hsp"
-
-
- #ifndef __USER__
- #define __USER__
-
- #module \
- User
-
- #define CREATE_URL (CONFIG_SERVER_URL + "/create_user.php")
- #define AUTH_URL (CONFIG_SERVER_URL + "/auth_user.php")
-
- #deffunc local \
- Create \
- str p_name
- Fetch@Http CREATE_URL + "?name=" + p_name
-
- If status@Http = STATUS_SUCCESS@Http {
- Split data@Http, ",", create_data
-
- id = Int (create_data.0)
- pass = create_data.1
- inheritanceCode = create_data.2
- }
- Else {
- id = 0
- pass = ""
- inheritanceCode = ""
- }
-
- Save@Setting
-
- Return
-
- #deffunc local \
- Auth \
- int p_id,\
- local l_data
- Load@Setting
-
- If id <= 0 {
- Return
- }
-
- Fetch@Http AUTH_URL + "?id=" + id + "&pass=" + pass
-
- If status@Http = STATUS_SUCCESS@Http {
- Split data@Http, ",", l_data
-
- If Int (l_data.0) = 0 {
- id = 0
-
- Return
- }
-
- name = l_data.1
- }
- Else {
- id = 0
- }
-
- Return
-
- #global
-
- #endif ; not __USER__
|