function resetPasswordDB($email, &$strNewPassword, &$strResponseMessage, &$strResponseData)
{
    assert(isset($email));
    $strResponseMessage = "Unsuccessful";
    $strResult = "Reset password unsuccessful";
    $dbConnection = getDBConnection($strResponseMessage);
    if (!$dbConnection->connect_errno) {
        $strNewPassword = generateTemporaryPassword();
        $sha256Password = hash('sha256', $strNewPassword);
        $stmtQuery = "UPDATE icaict515a_employees SET password='******' WHERE email=?";
        if ($stmt = $dbConnection->prepare($stmtQuery)) {
            $email = scrubInput($email, $dbConnection);
            $stmt->bind_param('s', $email);
            $bSuccess = $stmt->execute();
            if ($bSuccess && $stmt->affected_rows > 0) {
                $strResponseMessage = "Success";
                $strResult = "Password has been reset to a temporary password.";
            }
            $stmt->close();
        }
        $dbConnection->close();
    }
    $strResponseData = $strResult;
    return $strResponseMessage == "Success";
}
 function resetPasswordDB($email, &$strResponseStatus, &$strResponseMessage)
 {
     assert(isset($email));
     assert(isset($this->dbConnection));
     $strResponseStatus = "Unsuccessful";
     $strResponseMessage = "Reset password unsuccessful";
     if (!$dbConnection->connect_errno) {
         $this->strNewPassword = generateTemporaryPassword();
         $sha256Password = hash('sha256', $this->strNewPassword);
         $stmtQuery = "UPDATE icaweb516a_users SET password='******' WHERE email=?";
         if ($stmt = $dbConnection->prepare($stmtQuery)) {
             $email = $this->scrubInput($email);
             $stmt->bind_param('s', $email);
             $bSuccess = $stmt->execute();
             if ($bSuccess && $stmt->affected_rows > 0) {
                 $strResponseStatus = "Success";
                 $strResponseMessage = "Password has been reset to a temporary password.";
             }
             $stmt->close();
         }
     }
     return $strResponseStatus == "Success";
 }
 * file that was distributed with this source code.
 */
/**
 * @author Niels Keurentjes <*****@*****.**>>
 */
define('PASSWORD_LENGTH', 16);
function generateTemporaryPassword()
{
    static $base = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
    $result = '';
    for ($i = 0; $i < PASSWORD_LENGTH; ++$i) {
        $result .= $base[mt_rand(0, strlen($base) - 1)];
    }
    for ($i = 0; $i < 100; ++$i) {
        $result = str_shuffle($result);
    }
    return $result;
}
$parameters = ['DIRECTADMIN_URL' => null, 'MASTER_ADMIN_USERNAME' => null, 'MASTER_ADMIN_PASSWORD' => null, 'ADMIN_USERNAME' => 'testadmin', 'ADMIN_PASSWORD' => generateTemporaryPassword(), 'RESELLER_USERNAME' => 'testresell', 'RESELLER_PASSWORD' => generateTemporaryPassword(), 'USER_USERNAME' => 'testuser', 'USER_PASSWORD' => generateTemporaryPassword(), 'TEST_EMAIL' => 'example@127.0.0.1', 'TEST_RESELLER_DOMAIN' => 'reseller.test.org', 'TEST_USER_DOMAIN' => 'user.test.org'];
foreach ($parameters as $parameter => &$value) {
    // Constants override environment
    if (defined($parameter)) {
        continue;
    }
    if (!isset($value) && empty($value = getenv($parameter))) {
        throw new RuntimeException("Required setting {$parameter} was neither set as a constant or an environment variable");
    }
    define($parameter, $value);
}
// Include composer autoload
require __DIR__ . str_replace('/', DIRECTORY_SEPARATOR, '/../vendor/autoload.php');
Beispiel #4
0
 /**
  * @depends testDefaultDomain
  */
 public function testMailboxes(Domain $domain)
 {
     // Create 2 forwarders after asserting they are the first
     $this->assertEmpty($domain->getMailboxes());
     $mail1 = $domain->createMailbox('mail1', generateTemporaryPassword());
     $mail2 = $domain->createMailbox('mail2', generateTemporaryPassword(), 500, 500);
     $this->assertCount(2, $boxes = $domain->getMailboxes());
     // Check mailbox statistics
     $this->assertEquals('mail1@' . TEST_USER_DOMAIN, $boxes['mail1']->getEmailAddress());
     $this->assertNull($mail1->getDiskLimit());
     $this->assertEquals(500, $mail2->getDiskLimit());
     $this->assertEquals(0, $mail1->getDiskUsage(), 'Disk usage should be near empty', 0.1);
     $this->assertEquals(0, $mail2->getMailsSent());
     // Changing password should not throw any errors
     $mail1->setPassword(generateTemporaryPassword());
     // Delete the mailbox and ensure domain stats are updated
     $boxes['mail2']->delete();
     $this->assertCount(1, $domain->getMailboxes());
     $mail1->delete();
     $this->assertEmpty($domain->getMailboxes());
 }