From 182eaaed636f5c27866f467f9aa73f495eef6b78 Mon Sep 17 00:00:00 2001 From: badcast Date: Fri, 17 Nov 2023 15:29:20 +0600 Subject: [PATCH] Update and get server info (const) --- server-php/api/const.php | 27 +++++++++++++++++++++++++++ server-php/api/user_delete.php | 12 +++++++----- server-php/messagedb.php | 26 +++++++++++++++++++++++++- webclient/index.html | 2 +- webclient/styles/form.css | 2 +- webclient/tea_api.js | 2 +- webclient/tea_ui.js | 4 ++-- 7 files changed, 64 insertions(+), 11 deletions(-) create mode 100644 server-php/api/const.php diff --git a/server-php/api/const.php b/server-php/api/const.php new file mode 100644 index 0000000..ec7843f --- /dev/null +++ b/server-php/api/const.php @@ -0,0 +1,27 @@ +waitoutLock = WAITOUT_LOCK_MICROS; +$server_config->waitoutTimeChances = WAITOUT_TIME_CHANCES; +$server_config->strMaxNickname = STR_MAX_NICKNAME; +$server_config->strMaxMessage = STR_MAX_TEXT; +$server_config->msgMaxCount = MESSAGE_MAX_COUNT; +$server_config->msgIndexerSupported = true; +$server_config->msgIndexerEnable = MESSAGE_INDEXER_ENABLE; +$server_config->sysOS = PHP_OS; +$server_config->sysInfo = php_uname(); +$server_config->serverVer = file_get_contents("TEA_SERVER_VERSION"); +$server_config->diskTotalSpace = disk_total_space(__DIR__); +$server_config->diskFreeSpace = disk_free_space(__DIR__); +$server_config->welcome = file_get_contents("WELCOME.txt"); + +//user found, and send information +send(STATUS_OK, $server_config); diff --git a/server-php/api/user_delete.php b/server-php/api/user_delete.php index eaeb430..361753d 100644 --- a/server-php/api/user_delete.php +++ b/server-php/api/user_delete.php @@ -32,16 +32,18 @@ //User ID $user_del_status = pop_user($data->user_id); - if ($user_del_status === null) { - send(STATUS_ADMIN_ACCOUNT_REACHABLE, false); - exit; - } if ($user_del_status === false) { send(STATUS_ID_NO_EXIST, false); exit; } + else + if ($user_del_status === null) { + send(STATUS_ADMIN_ACCOUNT_REACHABLE, false); + exit; + } + //user found, and send information send(STATUS_OK, true); } -?> \ No newline at end of file +?> diff --git a/server-php/messagedb.php b/server-php/messagedb.php index a087c59..517f4f2 100644 --- a/server-php/messagedb.php +++ b/server-php/messagedb.php @@ -12,12 +12,36 @@ function message_first_id($uid_reader, $uid_target) { - //TODO: Get First Message ID + //TODO: Get First Message ID } function message_last_id($uid_reader, $uid_target) { //TODO: Get Last Message ID + $msg_file = MESSAGE_DIRS . "/" . $uid_target->user_id . MESSAGE_FILE_EXT; + $msg_id = -1; + + for(;;){ + if(MESSAGE_INDEXER_ENABLE) + { + $msg_cache_file = $msg_file . MESSAGE_FILE_CACHE_EXT; + + if(!file_exists($msg_cache_file) || !($fd = fopen($msg_cache_file, "rb"))) + { + break; + } + + // read from cached + fseek($fd, PHP_INT_SIZE, SEEK_END); + $flen = ftell($fd); + + + break; + } + break; + } + + return $msg_id; } function message_read($uid_reader, $uid_target, $msg_id_start, $max_messages = -1) diff --git a/webclient/index.html b/webclient/index.html index e93b501..415721f 100644 --- a/webclient/index.html +++ b/webclient/index.html @@ -12,7 +12,7 @@
-

Добро пожалаловать на сервер Драконего чая!

+

Добро пожаловать на сервер Драконего чая!

diff --git a/webclient/styles/form.css b/webclient/styles/form.css index 25d51dd..440813e 100644 --- a/webclient/styles/form.css +++ b/webclient/styles/form.css @@ -11,4 +11,4 @@ bottom: 0; right: 0; text-align: center; -} +} \ No newline at end of file diff --git a/webclient/tea_api.js b/webclient/tea_api.js index b8797c3..50f9bc7 100644 --- a/webclient/tea_api.js +++ b/webclient/tea_api.js @@ -34,7 +34,7 @@ function tea_str_error(errcode) { return ""; } -var net_stats = +var net_stats = { requestVerified: 0, requestError: 0, diff --git a/webclient/tea_ui.js b/webclient/tea_ui.js index 2a20b21..7f8399a 100644 --- a/webclient/tea_ui.js +++ b/webclient/tea_ui.js @@ -18,11 +18,11 @@ async function tea_ui_signin() { await tea_request(req); } -function tea_ui_start(){ +function tea_ui_start() { alert("asdsadasd"); } -document.body.onload = function ( env ) { tea_ui_start(); }; +document.body.onload = function (env) { tea_ui_start(); }; void tea_ui_show(formId) {