Ticket #6700: mythweb-6700-add_ip_address_to_MythBackend_class.2.patch
File mythweb-6700-add_ip_address_to_MythBackend_class.2.patch, 2.4 KB (added by , 16 years ago) |
---|
-
classes/MythBackend.php
old new 28 28 private $fp = null; 29 29 private $connected = false; 30 30 private $host = '127.0.0.1'; 31 private $port = 6543; 32 private $port_http = 6544; 31 private $ip = '127.0.0.1'; 32 private $port = null; 33 private $port_http = null; 33 34 34 static function find($host = null, $port = 6543) {35 static function find($host = null, $port = null) { 35 36 static $Backends = array(); 36 37 37 38 // Looking for the master backend? … … 49 50 return $Backend[$host][$port]; 50 51 } 51 52 52 function __construct($host, $port ) {53 function __construct($host, $port = null) { 53 54 $this->host = $host; 54 $this->port = $port; 55 $this->ip = _or(setting('BackendServerIP', $this->host), $host); 56 $this->port = _or($port, _or(setting('BackendServerPort', $this->host), 6543)); 55 57 $this->port_http = _or(setting('BackendStatusPort', $this->host), _or(setting('BackendStatusPort'), 6544)); 56 58 } 57 59 … … 62 64 private function connect() { 63 65 if ($this->connected) 64 66 return; 65 $this->fp = @fsockopen($this-> host, $this->port, $errno, $errstr, 25);67 $this->fp = @fsockopen($this->ip, $this->port, $errno, $errstr, 25); 66 68 if (!$this->fp) 67 custom_error("Unable to connect to the master backend at {$this-> host}:{$this->port}.\nIs it running?");69 custom_error("Unable to connect to the master backend at {$this->ip}:{$this->port}".(($this->host == $this->ip)?'':" (hostname: {$this->host})").".\nIs it running?"); 68 70 $this->connected = true; 69 71 socket_set_timeout($this->fp, 20); 70 72 $this->checkProtocolVersion(); … … 188 190 } 189 191 190 192 public function httpRequest($path, $args = array()) { 191 $url = "http://{$this-> host}:{$this->port_http}/Myth/{$path}?";193 $url = "http://{$this->ip}:{$this->port_http}/Myth/{$path}?"; 192 194 foreach ($args as $key => $value) 193 195 $url .= $key.'='.urlencode($value).'&'; 194 196 return @file_get_contents($url);