Improve locating file descriptors and smbclient/net commands

This commit is contained in:
Robin Appelman 2015-12-31 20:38:39 +01:00
commit b865f430d6
5 changed files with 100 additions and 18 deletions

View file

@ -19,16 +19,31 @@ class TimeZoneProvider {
private $timeZone;
/**
* @param string $host
* @var System
*/
function __construct($host) {
private $system;
/**
* @param string $host
* @param System $system
*/
function __construct($host, System $system) {
$this->host = $host;
$this->system = $system;
}
public function get() {
if (!$this->timeZone) {
$command = 'net time zone -S ' . escapeshellarg($this->host);
$this->timeZone = exec($command);
$net = $this->system->getNetPath();
if ($net) {
$command = sprintf('%s time zone -S %s',
$net,
escapeshellarg($this->host)
);
$this->timeZone = exec($command);
} else { // fallback to server timezone
$this->timeZone = date_default_timezone_get();
}
}
return $this->timeZone;
}