2015-09-17 03:16:07 +08:00
|
|
|
<?php
|
|
|
|
require_once( 'database.php' );
|
|
|
|
class Server {
|
2015-09-18 03:34:26 +08:00
|
|
|
public function __construct( $id ) {
|
|
|
|
if ( $id ) {
|
2015-10-15 21:28:35 +08:00
|
|
|
$s = dbFetchOne( 'SELECT * FROM Servers WHERE Id=?', NULL, array( $id ) );
|
|
|
|
if ( $s ) {
|
|
|
|
foreach ($s as $k => $v) {
|
|
|
|
$this->{$k} = $v;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Error("Unable to load Server record for Id=" . $id );
|
2015-09-17 03:16:07 +08:00
|
|
|
}
|
2015-09-18 03:34:26 +08:00
|
|
|
} else {
|
|
|
|
$this->{'Name'} = '';
|
|
|
|
$this->{'Hostname'} = '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-02 04:16:07 +08:00
|
|
|
public function Url() {
|
|
|
|
return ZM_BASE_PROTOCOL . '://'. $this->Hostname();
|
2015-09-18 03:34:26 +08:00
|
|
|
}
|
|
|
|
public function Hostname() {
|
2015-10-03 02:22:19 +08:00
|
|
|
if ( isset( $this->{'Hostname'} ) and ( $this->{'Hostname'} != '' ) ) {
|
|
|
|
return $this->{'Hostname'};
|
2015-09-18 04:06:47 +08:00
|
|
|
}
|
2015-10-03 02:22:19 +08:00
|
|
|
return $this->{'Name'};
|
2015-09-17 03:16:07 +08:00
|
|
|
}
|
2015-12-02 04:16:07 +08:00
|
|
|
public function __call( $fn, array $args= NULL){
|
|
|
|
if(isset($this->{$fn})){
|
|
|
|
return $this->{$fn};
|
|
|
|
#array_unshift($args, $this);
|
|
|
|
#call_user_func_array( $this->{$fn}, $args);
|
|
|
|
}
|
|
|
|
}
|
2015-09-17 03:16:07 +08:00
|
|
|
}
|
|
|
|
?>
|