DirectAdmin\LetsEncrypt\Lib\Config::config PHP Méthode

config() public méthode

Set or receive config variable
public config ( string | null $key = null, string | null $value = null ) : string | null
$key string | null Key of entry
$value string | null
Résultat string | null
    public function config($key = null, $value = null)
    {
        if (!$this->initialized) {
            $this->initialize();
        }
        if ($value == null) {
            return $key == null ? $this->config : $this->config[$key];
        } else {
            $this->config[$key] = $value;
            $this->save();
        }
    }

Usage Example

Exemple #1
0
use DirectAdmin\LetsEncrypt\Lib\Logger;
define('CRON', true);
require_once dirname(__DIR__) . '/includes/bootstrap.php';
$log = new Logger();
$config = new Config();
$usersPath = '/usr/local/directadmin/data/users/';
// Get all users
$users = scandir($usersPath);
// Loop through all users
foreach ($users as $user) {
    // Check if it's not some junk thingy
    if (in_array($user, ['.', '..']) || empty($user)) {
        continue;
    }
    // Create account object
    $account = new Account($user, null, $config->config('server'));
    // Is there a config file present?
    if (!$account->existsInStorage('config.json')) {
        $log->log('Skipped user ' . $account->getUsername());
        continue;
    }
    $log->log('Processing user ' . $account->getUsername());
    if (!$account->loadKeys()) {
        $log->log('No keys present at user ' . $account->getUsername());
        continue;
    }
    $account->setEmail($account->config('email'));
    // Get all domains of the user
    $domains = file_get_contents($usersPath . DIRECTORY_SEPARATOR . $account->getUsername() . DIRECTORY_SEPARATOR . 'domains.list');
    // Loop through all domains of the user
    foreach (explode("\n", $domains) as $domain) {
All Usage Examples Of DirectAdmin\LetsEncrypt\Lib\Config::config