Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b7892a7f authored by Nivesh Krishna's avatar Nivesh Krishna
Browse files

only add to .map file

parent ff9484b0
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -13,8 +13,7 @@ require_once('accounts/wp_account_creator.php');

$domain = getenv("DOMAIN");
$mail_domain = getMailDomain();
$newUserListFile = getenv('NEW_USER_LIST_FILE_PATH');
$newUserMapFile = getenv('NEW_USER_LIST_MAP_PATH');
$newUserMapFile = getenv('NEW_USER_MAP_FILEPATH');

if (!isset($_POST['username']) || !isset($_POST['password']) || !isset($_POST['displayname']) || !isset($_POST['repassword'])) {
    $error_string = $strings["error_mandatory_missing"];
@@ -334,8 +333,6 @@ function has_invalid_password_characters(string $password): bool

function addUserToList(string $email)
{
    global $newUserListFile;
    global $newUserMapFile;
    file_put_contents($newUserMapFile, time() . ',' . $email.PHP_EOL , FILE_APPEND | LOCK_EX);
    file_put_contents($newUserListFile, $email.PHP_EOL , FILE_APPEND | LOCK_EX);
    file_put_contents($newUserMapFile, $email.PHP_EOL , FILE_APPEND | LOCK_EX);
}
+0 −44
Original line number Diff line number Diff line
import os
import time 

map_file = open(os.getenv('NEW_USER_LIST_MAP_PATH'), 'r')
txt_file = open(os.getenv('NEW_USER_LIST_FILE_PATH'), 'r')

txt_file_read = txt_file.readlines()
map_file_read = map_file.readlines()
map_file_write = map_file_read.copy()
txt_file_write = txt_file_read.copy()
map_file.close()
txt_file.close()


hold_time = float(os.getenv('NUMBER_OF_DAYS_TO_HOLD', 10)) * 86400 
current_time = time.time()

for user in map_file_read:
    map_user = user.strip()
    
    for entry in txt_file_read:
        if map_user not in entry:
            continue

        created, txt_user = entry.split(',')
        txt_user = txt_user.strip()
        diff = current_time - float(created)
        
        if map_user == txt_user:
            print(f'user : {txt_user} - {diff/3600} hours')
            if (diff >= hold_time):
                print(f'remove user {txt_user}')
                map_file_write.remove(user)
                txt_file_write.remove(entry)

if map_file_write != map_file_read:
    map_file = open(os.getenv('NEW_USER_LIST_MAP_PATH'), 'w')
    map_file.writelines(map_file_write)
    map_file.close()

if txt_file_write != txt_file_read:
    txt_file = open(os.getenv('NEW_USER_LIST_FILE_PATH'), 'w')
    txt_file.writelines(txt_file_write)
    txt_file.close()
 No newline at end of file