1 | <?php |
||
18 | class Server extends AbstractServer { |
||
19 | /** |
||
20 | * Check if the smbclient php extension is available |
||
21 | * |
||
22 | * @param System $system |
||
23 | * @return bool |
||
24 | */ |
||
25 | public static function available(System $system) { |
||
28 | |||
29 | 10 | private function getAuthFileArgument() { |
|
36 | |||
37 | /** |
||
38 | * @return IShare[] |
||
39 | * |
||
40 | * @throws AuthenticationException |
||
41 | * @throws InvalidHostException |
||
42 | * @throws ConnectException |
||
43 | */ |
||
44 | 10 | public function listShares() { |
|
45 | 10 | $command = sprintf('%s %s %s -L %s', |
|
46 | 10 | $this->system->getSmbclientPath(), |
|
47 | 10 | $this->getAuthFileArgument(), |
|
48 | 10 | $this->getAuth()->getExtraCommandLineArguments(), |
|
49 | 10 | escapeshellarg('//' . $this->getHost()) |
|
50 | ); |
||
51 | 10 | $connection = new RawConnection($command); |
|
52 | 10 | $connection->writeAuthentication($this->getAuth()->getUsername(), $this->getAuth()->getPassword()); |
|
53 | 10 | $connection->connect(); |
|
54 | 10 | if (!$connection->isValid()) { |
|
55 | throw new ConnectionException($connection->readLine()); |
||
56 | } |
||
57 | 10 | $output = $connection->readAll(); |
|
58 | // sometimes we get an empty line first |
||
59 | 10 | if (count($output) < 2) { |
|
60 | 10 | $output = $connection->readAll(); |
|
61 | } |
||
62 | 10 | $parser = new Parser($this->timezoneProvider); |
|
63 | |||
64 | 10 | if (isset($output[0])) { |
|
65 | 4 | $parser->checkConnectionError($output[0]); |
|
66 | } |
||
67 | |||
68 | 10 | $shareNames = $parser->parseListShares($output); |
|
69 | |||
70 | 10 | $shares = array(); |
|
71 | 10 | foreach ($shareNames as $name => $description) { |
|
72 | 4 | $shares[] = $this->getShare($name); |
|
73 | } |
||
74 | 10 | return $shares; |
|
75 | } |
||
76 | |||
77 | /** |
||
78 | * @param string $name |
||
79 | * @return IShare |
||
80 | */ |
||
81 | 512 | public function getShare($name) { |
|
84 | } |
||
85 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: