Example #1
0
 /**
  * Changes the group of this user
  *
  * @param $user_id
  *
  * @param $group
  */
 public function ChangeGroup($user_id, $group)
 {
     if ($this->user->Exists($user_id)) {
         $array = ['user_group' => $group];
         $this->user->database->Update($user_id, $array);
     }
 }
Example #2
0
 public function testUser()
 {
     $this->startCodeCoverage();
     $user = new User();
     $user->Id = 'non_numeric';
     if (!($user->SetPassword('blah') === false)) {
         $this->fail("User::SetPassword didn't return false for non-numeric user id");
         return 1;
     }
     if (!($user->IsAdmin() === false)) {
         $this->fail("User::IsAdmin didn't return false for non-numeric user id");
         return 1;
     }
     $user->Id = '';
     $user->Email = '';
     if (!($user->GetName() === false)) {
         $this->fail("User::GetName didn't return false when given no user id");
         return 1;
     }
     if (!($user->IsAdmin() === false)) {
         $this->fail("User::Exists didn't return false for no user id and no email");
         return 1;
     }
     $user->Email = 'simpletest@localhost';
     if ($user->Exists() === false) {
         $this->fail('User::Exists returned false even though user exists');
         return 1;
     }
     $id = $user->GetIdFromEmail('simpletest@localhost');
     if ($id === false) {
         $this->fail('User::GetIdFromEmail returned false for a valid user');
         return 1;
     }
     $user->Id = $id;
     $user->Admin = '1';
     $user->FirstName = 'administrator';
     $user->Institution = 'Kitware Inc.';
     if ($user->Exists() != true) {
         $this->fail('User::Exists failed given a valid user id');
         return 1;
     }
     $user->Password = md5('simpletest');
     // Coverage for update save
     $user->Save();
     // Coverage for SetPassword
     $user->SetPassword(md5('simpletest'));
     $this->stopCodeCoverage();
     return 0;
 }
Example #3
0
 function testUser()
 {
     $this->startCodeCoverage();
     $user = new User();
     $user->Id = "non_numeric";
     if (!($user->SetPassword("blah") === false)) {
         $this->fail("User::SetPassword didn't return false for non-numeric user id");
         return 1;
     }
     if (!($user->IsAdmin() === false)) {
         $this->fail("User::IsAdmin didn't return false for non-numeric user id");
         return 1;
     }
     $user->Id = "";
     $user->Email = "";
     if (!($user->GetName() === false)) {
         $this->fail("User::GetName didn't return false when given no user id");
         return 1;
     }
     if (!($user->IsAdmin() === false)) {
         $this->fail("User::Exists didn't return false for no user id and no email");
         return 1;
     }
     $user->Email = "simpletest@localhost";
     if ($user->Exists() === false) {
         $this->fail("User::Exists returned false even though user exists");
         return 1;
     }
     $id = $user->GetIdFromEmail("simpletest@localhost");
     if ($id === false) {
         $this->fail("User::GetIdFromEmail returned false for a valid user");
         return 1;
     }
     $user->Id = $id;
     $user->Admin = "1";
     $user->FirstName = "administrator";
     $user->Institution = "Kitware Inc.";
     if ($user->Exists() != true) {
         $this->fail("User::Exists failed given a valid user id");
         return 1;
     }
     $user->Password = md5("simpletest");
     // Coverage for update save
     $user->Save();
     // Coverage for SetPassword
     $user->SetPassword(md5("simpletest"));
     $this->stopCodeCoverage();
     return 0;
 }
Example #4
0
 public function testRegisterUser()
 {
     // Enable password rotation.
     $this->addLineToConfig($this->RotationConfig);
     // Create a new user for this test.
     $url = $this->url . '/register.php';
     $content = $this->connect($url);
     if ($content == false) {
         return;
     }
     $this->setField('fname', 'Jane');
     $this->setField('lname', 'Smith');
     $this->setField('email', 'jane@smith');
     $this->setField('passwd', '12345');
     $this->setField('passwd2', '12345');
     $this->setField('institution', 'me');
     $this->clickSubmitByName('sent', array('url' => 'catchbot'));
     $this->assertText('Registration Complete. Please login with your email and password.');
     // Get the id for this user.
     $user = new User();
     $user->Email = 'jane@smith';
     if (!$user->Exists()) {
         $this->fail("User does not exist after registration");
         return false;
     }
     $this->UserId = $user->Id;
     // Make sure the password was recorded for rotation.
     $row = pdo_single_row_query("SELECT * FROM password WHERE userid={$this->UserId}");
     if (!$row || !array_key_exists('password', $row)) {
         $this->fail("No entry in password table after rotation");
     }
 }
Example #5
0
 public function testAccountLockout()
 {
     // Enable our config settings.
     $this->addLineToConfig($this->AttemptsConfig);
     $this->addLineToConfig($this->LengthConfig);
     // Get the id for the simpletest user.
     $user = new User();
     $user->Email = 'simpletest@localhost';
     if (!$user->Exists()) {
         $this->fail("simpletest user does not exist");
         return false;
     }
     $userid = $user->Id;
     // Lock the account out by specifying the wrong password multiple times.
     $this->login('simpletest@localhost', 'asdf');
     $this->login('simpletest@localhost', 'asdf');
     // Make sure we get the same error message when we attempt to login
     // whether or not we use the correct password.
     $this->login('simpletest@localhost', 'asdf');
     $this->assertText('Your account is locked');
     $this->login('simpletest@localhost', 'simpletest');
     $this->assertText('Your account is locked');
     // Manually set the lock to expire.
     pdo_query("UPDATE lockout SET unlocktime = '1980-01-01 00:00:00'\n            WHERE userid={$userid}");
     // Make sure we can successfully log in now.
     $this->login('simpletest@localhost', 'simpletest');
     $this->assertText('Log Out');
     $this->removeLineFromConfig($this->AttemptsConfig);
     $this->removeLineFromConfig($this->LengthConfig);
     $this->pass('Test passed');
 }
<?php

require dirname(__FILE__) . '/../fx.php';
while (@ob_end_clean()) {
}
$skipping = true;
$page = 1;
while ($page !== false) {
    $followers = Twitter::GetFollowers('ta_follows', $page);
    foreach ($followers as $f) {
        $exists = User::Exists($f['screen_name']);
        if ($exists or $skipping) {
            continue;
        }
        $skipping = false;
        $user = Twitter::Follow($headers['x-twittersenderscreenname']);
        if (User::Create($f)) {
            echo $f['screen_name'] . " created\n";
            Twitter::Tweet('d ' . $f['screen_name'] . ' Welcome to Follows from TwitApps. Send your email address by direct message to @ta_follows to activate this service.');
        } else {
            echo 'Failed to create user for ' . $f['screen_name'] . ': ' . mysql_error() . "\n";
        }
    }
    if (count($followers) == 100) {
        $page++;
    } else {
        $page = false;
    }
}
Example #7
0
                 if (!checkName($loginnew)) {
                     $localerror = 1;
                     $content .= sprintf($html->string_error, $l['str_bad_login_name']) . '<br>';
                 }
                 if ($passwordnew != $confirmpasswordnew) {
                     $localerror = 1;
                     $content .= sprintf($html->string_error, $l['str_passwords_dont_match']) . '<br>';
                 }
             }
             // end no error after empty checks
             if (!$localerror) {
                 // ****************************************
                 // *            Create new user           *
                 // ****************************************
                 $newuser = new User('', '', '');
                 if ($newuser->Exists($loginnew)) {
                     $content .= sprintf($html->string_error, $l['str_login_already_exists']);
                 } else {
                     $group->GroupUserCreate($newuser, $loginnew, $passwordnew, '', $user->userid, $grouprightsnew);
                     if ($group->error) {
                         $content .= sprintf($html->string_error, $group->error);
                     } else {
                         // user successfully created
                         $content .= $l['str_new_user_has_been_successfully_created'];
                     }
                     // zone created successfully
                 }
             } else {
                 // error, print form again
                 $content .= '
 <form action="' . $_SERVER["PHP_SELF"] . '" method="post">