Пример #1
0
 /**
  * @preserveGlobalState disabled
  * @runInSeparateProcess
  */
 public function test_delete()
 {
     $auth = new Hm_Auth_DB($this->config);
     $this->assertTrue($auth->delete('unittestuser'));
     $this->assertFalse($auth->delete('nobody'));
     $config = new Hm_Mock_Config();
     $auth = new Hm_Auth_DB($config);
     $this->assertFalse($auth->delete('unittestuser'));
     $auth = new Hm_Auth_DB($this->config);
     $this->assertTrue($auth->create('unittestuser', 'unittestpass'));
 }
Пример #2
0
/**
 * CLI script to delete a user account from the local DB
 */
if (strtolower(php_sapi_name()) !== 'cli') {
    die("Must be run from the command line\n");
}
if (is_array($argv) && count($argv) == 2) {
    $user = $argv[1];
} else {
    die("Incorrect usage\n\nphp ./scripts/delete_account.php <username>\n\n");
}
/* debug mode has to be set to something or include files will die() */
define('DEBUG_MODE', false);
/* determine current absolute path used for require statements */
define('APP_PATH', dirname(dirname(__FILE__)) . '/');
/* get the framework */
require APP_PATH . 'lib/framework.php';
/* get config object */
$config = new Hm_Site_Config_File(APP_PATH . 'hm3.rc');
/* check config for db auth */
if ($config->get('auth_type') != 'DB') {
    die("Incorrect usage\n\nThis script only works if DB auth is enabled in your site configuration\n\n");
}
$auth = new Hm_Auth_DB($config);
if ($user) {
    if ($auth->delete($user)) {
        die("User deleted\n\n");
    } else {
        die("An error occured\n\n");
    }
}
Пример #3
0
 * CLI script to add a user account to the local DB
 */
if (strtolower(php_sapi_name()) !== 'cli') {
    die("Must be run from the command line\n");
}
if (is_array($argv) && count($argv) == 3) {
    $user = $argv[1];
    $pass = $argv[2];
} else {
    die("Incorrect usage\n\nphp ./scripts/create_account.php <username> <password>\n\n");
}
/* debug mode has to be set to something or include files will die() */
define('DEBUG_MODE', false);
/* determine current absolute path used for require statements */
define('APP_PATH', dirname(dirname(__FILE__)) . '/');
/* get the framework */
require APP_PATH . 'lib/framework.php';
/* get config object */
$config = new Hm_Site_Config_File(APP_PATH . 'hm3.rc');
/* check config for db auth */
if ($config->get('auth_type') != 'DB') {
    die("Incorrect usage\n\nThis script only works if DB auth is enabled in your site configuration\n\n");
}
$auth = new Hm_Auth_DB($config);
if ($user && $pass) {
    if ($auth->create($user, $pass)) {
        die("User created\n\n");
    } else {
        die("An error occured\n\n");
    }
}
Пример #4
0
<?php

// this file is included in module.php in the folder above...
global $User, $SqlDatabase, $args, $Logger;
// STEP 1: check that we have valid settings for pat app
$ps = getPatSettings();
/* CYPHT stuff..... */
define('APP_PATH', $ps->fileroot . (substr($ps->fileroot, -1) == '/' ? '' : '/'));
require APP_PATH . 'lib/framework.php';
$config = new Hm_Site_Config_File(APP_PATH . 'hm3.rc');
/* check config for db auth */
if ($config->get('auth_type') != 'DB') {
    die('fail<--separate-->Mail framework need to be set up with DB configuration for this to work. Please review your cypth installation.');
}
$auth = new Hm_Auth_DB($config);
$validuser = false;
//now check if we have a user, if not try to create or update password to match users.
if ($auth->check_credentials($User->Name, $User->Password)) {
    $validuser = true;
    $Logger->log('Pat user is valid');
} else {
    if ($auth->create($User->Name, $User->Password)) {
        $validuser = true;
        $Logger->log('Pat user created');
    } else {
        if ($auth->change_pass($User->Name, $User->Password)) {
            $validuser = true;
            $Logger->log('Pat user pass updated');
        } else {
            die('fail<!--separate-->Could not create/update Friend user at Pat end.');
        }
Пример #5
0
 * CLI script to update a user password
 */
if (strtolower(php_sapi_name()) !== 'cli') {
    die("Must be run from the command line\n");
}
if (is_array($argv) && count($argv) == 3) {
    $user = $argv[1];
    $pass = $argv[2];
} else {
    die("Incorrect usage\n\nphp ./scripts/update_password.php <username> <password>\n\n");
}
/* debug mode has to be set to something or include files will die() */
define('DEBUG_MODE', false);
/* determine current absolute path used for require statements */
define('APP_PATH', dirname(dirname(__FILE__)) . '/');
/* get the framework */
require APP_PATH . 'lib/framework.php';
/* get config object */
$config = new Hm_Site_Config_File(APP_PATH . 'hm3.rc');
/* check config for db auth */
if ($config->get('auth_type') != 'DB') {
    die("Incorrect usage\n\nThis script only works if DB auth is enabled in your site configuration\n\n");
}
$auth = new Hm_Auth_DB($config);
if ($user && $pass) {
    if ($auth->change_pass($user, $pass)) {
        die("Password Updated\n\n");
    } else {
        die("An error occured\n\n");
    }
}