|
|
|
|
@ -21,11 +21,18 @@ class xReflector {
|
|
|
|
|
private $CallingHomeCountry = null;
|
|
|
|
|
private $CallingHomeComment = null;
|
|
|
|
|
private $CallingHomeOverrideIP = null;
|
|
|
|
|
private $Transferinterlink = null;
|
|
|
|
|
private $Interlinkfile = null;
|
|
|
|
|
public $Interlinks = null;
|
|
|
|
|
private $InterlinkXML = null;
|
|
|
|
|
private $ReflectorXML = null;
|
|
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
|
$this->Nodes = array();
|
|
|
|
|
$this->Stations = array();
|
|
|
|
|
$this->Peers = array();
|
|
|
|
|
$this->Interlinks = array();
|
|
|
|
|
$this->Transferinterlink = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function LoadXML() {
|
|
|
|
|
@ -305,22 +312,132 @@ class xReflector {
|
|
|
|
|
return $out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function SetCallingHome($Active, $DashboardURL, $Hash, $ServerURL, $Country, $Comment, $OverrideIP) {
|
|
|
|
|
$this->CallingHomeActive = ($Active === true);
|
|
|
|
|
public function SetCallingHome($CallingHomeVariables, $Hash) {
|
|
|
|
|
|
|
|
|
|
if (!isset($CallingHomeVariables['Active'])) { $CallingHomeVariables['Active'] = false; }
|
|
|
|
|
if (!isset($CallingHomeVariables['MyDashBoardURL'])) { $CallingHomeVariables['MyDashBoardURL'] = ''; }
|
|
|
|
|
if (!isset($CallingHomeVariables['ServerURL'])) { $CallingHomeVariables['ServerURL'] = ''; }
|
|
|
|
|
if (!isset($CallingHomeVariables['Country'])) { $CallingHomeVariables['Country'] = ''; }
|
|
|
|
|
if (!isset($CallingHomeVariables['Comment'])) { $CallingHomeVariables['Comment'] = ''; }
|
|
|
|
|
if (!isset($CallingHomeVariables['OverrideIPAddress'])) { $CallingHomeVariables['OverrideIPAddress'] = false; }
|
|
|
|
|
if (!isset($CallingHomeVariables['InterlinkFile'])) { $CallingHomeVariables['InterlinkFile'] = ''; }
|
|
|
|
|
|
|
|
|
|
if (!file_exists($CallingHomeVariables['InterlinkFile'])) {
|
|
|
|
|
$this->Interlinkfile = '';
|
|
|
|
|
$this->Transferinterlink = false;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$this->Transferinterlink = true;
|
|
|
|
|
$this->Interlinkfile = $CallingHomeVariables['InterlinkFile'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->CallingHomeActive = ($CallingHomeVariables['Active'] === true);
|
|
|
|
|
$this->CallingHomeHash = $Hash;
|
|
|
|
|
$this->CallingHomeDashboardURL = $DashboardURL;
|
|
|
|
|
$this->CallingHomeServerURL = $ServerURL;
|
|
|
|
|
$this->CallingHomeCountry = $Country;
|
|
|
|
|
$this->CallingHomeComment = $Comment;
|
|
|
|
|
$this->CallingHomeOverrideIP = $OverrideIP;
|
|
|
|
|
$this->CallingHomeDashboardURL = $CallingHomeVariables['MyDashBoardURL'];
|
|
|
|
|
$this->CallingHomeServerURL = $CallingHomeVariables['ServerURL'];
|
|
|
|
|
$this->CallingHomeCountry = $CallingHomeVariables['Country'];
|
|
|
|
|
$this->CallingHomeComment = $CallingHomeVariables['Comment'];
|
|
|
|
|
$this->CallingHomeOverrideIP = $CallingHomeVariables['OverrideIPAddress'];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function PushCallingHome() {
|
|
|
|
|
$CallingHome = @fopen($this->CallingHomeServerURL."?ReflectorName=".$this->ReflectorName."&ReflectorUptime=".$this->ServiceUptime."&ReflectorHash=".$this->CallingHomeHash."&DashboardURL=".$this->CallingHomeDashboardURL."&Country=".urlencode($this->CallingHomeCountry)."&Comment=".urlencode($this->CallingHomeComment)."&OverrideIP=".$this->CallingHomeOverrideIP, "r");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//debug($this->CallingHomeServerURL."?ReflectorName=".$this->ReflectorName."&ReflectorUptime=".$this->ServiceUptime."&ReflectorHash=".$this->CallingHomeHash."&DashboardURL=".$this->CallingHomeDashboardURL."&Country=".urlencode($this->CallingHomeCountry)."&Comment=".urlencode($this->CallingHomeComment));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function ReadInterlinkFile() {
|
|
|
|
|
if (file_exists($this->Interlinkfile) && (is_readable($this->Interlinkfile))) {
|
|
|
|
|
$this->Interlinks = array();
|
|
|
|
|
$this->InterlinkXML = "";
|
|
|
|
|
$Interlinkfilecontent = file($this->Interlinkfile);
|
|
|
|
|
for ($i=0;$i<count($Interlinkfilecontent);$i++) {
|
|
|
|
|
if (substr($Interlinkfilecontent[$i], 0, 1) != '#') {
|
|
|
|
|
$Interlink = explode(" ", $Interlinkfilecontent[$i]);
|
|
|
|
|
$this->Interlinks[] = new Interlink();
|
|
|
|
|
if (isset($Interlink[0])) { $this->Interlinks[count($this->Interlinks)-1]->SetName(trim($Interlink[0])); }
|
|
|
|
|
if (isset($Interlink[1])) { $this->Interlinks[count($this->Interlinks)-1]->SetAddress(trim($Interlink[1])); }
|
|
|
|
|
if (isset($Interlink[2])) {
|
|
|
|
|
$Modules = str_split(trim($Interlink[2]), 1);
|
|
|
|
|
for ($j=0;$j<count($Modules);$j++) {
|
|
|
|
|
$this->Interlinks[count($this->Interlinks)-1]->AddModule($Modules[$j]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function PrepareInterlinkXML() {
|
|
|
|
|
$xml = '
|
|
|
|
|
<interlinks>';
|
|
|
|
|
for ($i=0;$i<count($this->Interlinks);$i++) {
|
|
|
|
|
$xml .= '
|
|
|
|
|
<interlink>
|
|
|
|
|
<name>'.$this->Interlinks[$i]->GetName().'</name>
|
|
|
|
|
<address>'.$this->Interlinks[$i]->GetAddress().'</address>
|
|
|
|
|
<modules>'.$this->Interlinks[$i]->GetModules().'</modules>
|
|
|
|
|
</interlink>';
|
|
|
|
|
}
|
|
|
|
|
$xml .= '
|
|
|
|
|
</interlinks>';
|
|
|
|
|
$this->InterlinkXML = $xml;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function PrepareReflectorXML() {
|
|
|
|
|
$this->ReflectorXML = '
|
|
|
|
|
<reflector>
|
|
|
|
|
<name>'.$this->ReflectorName.'</name>
|
|
|
|
|
<uptime>'.$this->ServiceUptime.'</uptime>
|
|
|
|
|
<hash>'.$this->CallingHomeHash.'</hash>
|
|
|
|
|
<url>'.$this->CallingHomeDashboardURL.'</url>
|
|
|
|
|
<country>'.$this->CallingHomeCountry.'</country>
|
|
|
|
|
<comment>'.$this->CallingHomeComment.'</comment>
|
|
|
|
|
<ip>'.$this->CallingHomeOverrideIP.'</ip>
|
|
|
|
|
</reflector>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function CallHome() {
|
|
|
|
|
$xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
|
|
|
<query>CallingHome</query>'.$this->ReflectorXML.$this->InterlinkXML;
|
|
|
|
|
$p = @stream_context_create(array('http' => array('header' => "Content-type: application/x-www-form-urlencoded\r\n",
|
|
|
|
|
'method' => 'POST',
|
|
|
|
|
'content' => http_build_query(array('xml' => $xml)) )));
|
|
|
|
|
$result = @file_get_contents($this->CallingHomeServerURL, false, $p);
|
|
|
|
|
if ($result === false) {
|
|
|
|
|
die("CONNECTION FAILED!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function InterlinkCount() {
|
|
|
|
|
return count($this->Interlinks);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function GetInterlink($Index) {
|
|
|
|
|
if (isset($this->Interlinks[$Index])) return $this->Interlinks[$Index];
|
|
|
|
|
return array();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function IsInterlinked($Reflectorname) {
|
|
|
|
|
$i = -1;
|
|
|
|
|
$f = false;
|
|
|
|
|
while (!$f && $i<$this->InterlinkCount()) {
|
|
|
|
|
$i++;
|
|
|
|
|
if (isset($this->Interlinks[$i])) {
|
|
|
|
|
if ($this->Interlinks[$i]->GetName() == $Reflectorname) {
|
|
|
|
|
$f = true;
|
|
|
|
|
return $i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|