Skip to content

Commit

Permalink
Update and get server info (const)
Browse files Browse the repository at this point in the history
  • Loading branch information
badcast committed Nov 17, 2023
1 parent 7ed9ed3 commit 182eaae
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 11 deletions.
27 changes: 27 additions & 0 deletions server-php/api/const.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

require_once __DIR__ . '/../server_config.php';
require_once __DIR__ . '/sender.php';

if ($_SERVER["REQUEST_METHOD"] != "GET") {
send_auth_fail(STATUS_INVALID_AUTH_METHOD);
exit;
}

$server_config = new stdClass();
$server_config->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);
12 changes: 7 additions & 5 deletions server-php/api/user_delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
?>
?>
26 changes: 25 additions & 1 deletion server-php/messagedb.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion webclient/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<body>
<div id="_wforms">
<div class="form_sigin">
<p>Добро пожалаловать на сервер Драконего чая!</p>
<p>Добро пожаловать на сервер Драконего чая!</p>
<input id="inputSignin" type="text" placeholder="User ID" value=""/>
<button style="left: 0;" onclick="document.getElementById('inputSignin').value=''">x</button>
<p></p>
Expand Down
2 changes: 1 addition & 1 deletion webclient/styles/form.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
bottom: 0;
right: 0;
text-align: center;
}
}
2 changes: 1 addition & 1 deletion webclient/tea_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function tea_str_error(errcode) {
return "";
}

var net_stats =
var net_stats =
{
requestVerified: 0,
requestError: 0,
Expand Down
4 changes: 2 additions & 2 deletions webclient/tea_ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 182eaae

Please sign in to comment.