Fixed time zone calculation issue
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / system / io / RemoteFile.class.php
1 <?php
2 namespace wcf\system\io;
3 use wcf\system\exception\SystemException;
4
5 /**
6 * The RemoteFile class opens a connection to a remote host as a file.
7 *
8 * @author Marcel Werk
9 * @copyright 2001-2014 WoltLab GmbH
10 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
11 * @package com.woltlab.wcf
12 * @subpackage system.io
13 * @category Community Framework
14 */
15 class RemoteFile extends File {
16 /**
17 * host address
18 * @var string
19 */
20 protected $host = '';
21
22 /**
23 * port
24 * @var integer
25 */
26 protected $port = 0;
27
28 /**
29 * error number
30 * @var integer
31 */
32 protected $errorNumber = 0;
33
34 /**
35 * error description
36 * @var string
37 */
38 protected $errorDesc = '';
39
40 /**
41 * Opens a new connection to a remote host.
42 *
43 * @param string $host
44 * @param integer $port
45 * @param integer $timeout
46 * @param array $options
47 */
48 public function __construct($host, $port, $timeout = 30) {
49 $this->host = $host;
50 $this->port = $port;
51
52 $this->resource = @fsockopen($host, $port, $this->errorNumber, $this->errorDesc, $timeout);
53 if ($this->resource === false) {
54 throw new SystemException('Can not connect to ' . $host, 0, $this->errorDesc);
55 }
56 }
57
58 /**
59 * Returns the error number of the last error.
60 *
61 * @return integer
62 */
63 public function getErrorNumber() {
64 return $this->errorNumber;
65 }
66
67 /**
68 * Returns the error description of the last error.
69 *
70 * @return string
71 */
72 public function getErrorDesc() {
73 return $this->errorDesc;
74 }
75 }