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) {