mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-04 01:34:07 +02:00
more configurability for library users
- Make TimeZoneProvider and System overridable - Add system for passing additional options - make timeout configurable
This commit is contained in:
parent
2f3ff44f4c
commit
2f261f868d
20 changed files with 303 additions and 107 deletions
|
|
@ -7,44 +7,41 @@
|
|||
|
||||
namespace Icewind\SMB;
|
||||
|
||||
class TimeZoneProvider {
|
||||
class TimeZoneProvider implements ITimeZoneProvider {
|
||||
/**
|
||||
* @var string
|
||||
* @var string[]
|
||||
*/
|
||||
private $host;
|
||||
private $timeZones = [];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $timeZone;
|
||||
|
||||
/**
|
||||
* @var System
|
||||
* @var ISystem
|
||||
*/
|
||||
private $system;
|
||||
|
||||
/**
|
||||
* @param string $host
|
||||
* @param System $system
|
||||
* @param ISystem $system
|
||||
*/
|
||||
public function __construct($host, System $system) {
|
||||
$this->host = $host;
|
||||
public function __construct(ISystem $system) {
|
||||
$this->system = $system;
|
||||
}
|
||||
|
||||
public function get() {
|
||||
if (!$this->timeZone) {
|
||||
public function get($host) {
|
||||
if (!isset($this->timeZones[$host])) {
|
||||
$net = $this->system->getNetPath();
|
||||
if ($net) {
|
||||
if ($net && $host) {
|
||||
$command = sprintf('%s time zone -S %s',
|
||||
$net,
|
||||
escapeshellarg($this->host)
|
||||
escapeshellarg($host)
|
||||
);
|
||||
$this->timeZone = exec($command);
|
||||
$timeZone = exec($command);
|
||||
if (!$timeZone) {
|
||||
$timeZone = date_default_timezone_get();
|
||||
}
|
||||
$this->timeZones[$host] = $timeZone;
|
||||
} else { // fallback to server timezone
|
||||
$this->timeZone = date_default_timezone_get();
|
||||
$this->timeZones[$host] = date_default_timezone_get();
|
||||
}
|
||||
}
|
||||
return $this->timeZone;
|
||||
return $this->timeZones[$host];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue