<?php
$query = "SELECT `value` FROM `setting` WHERE `name` = 'Domain Passwords are Encrypted'";
$result = mysql_query($query) or die("ERROR in query: $query");
list($encrypted) = mysql_fetch_row($result);

if($encrypted == 1){

    /*
     * ------------------------------------------------
     * REENCRYPTION OF DOMAIN PASSWORDS TO AVOID ISSUES
     * ------------------------------------------------
     */
    require_once 'encrypted/Clientexec.php';
    
    $query3 = "SELECT `id`, `password` FROM `domains`";
    $result3 = mysql_query($query3) or die("ERROR in query: $query3");
    while (list($id, $password) = mysql_fetch_row($result3)) {
        $decryptedPassword = NE_Lib::decryptData($password, Clientexec::getDomainPwdEncryptionKey());
        $encryptedPassword = $this->encryptData($decryptedPassword);

        $update2 = "UPDATE `domains` SET `password` = '".mysql_real_escape_string($encryptedPassword)."' WHERE `id` = $id";
        mysql_query($update2) or die("ERROR in query: $update2");
    }
    
}
?>