1
0
mirror of https://github.com/ShaYmez/xlxd.git synced 2024-12-23 01:55:49 -05:00
This commit is contained in:
LX3JL 2016-05-04 08:33:20 +02:00
parent 0a17cceb45
commit 486fa279f8
8 changed files with 211 additions and 28 deletions

View File

@ -1,3 +1,10 @@
xlx db v2.3.1
- "config.inc.php" $CallingHome['InterlinkFile'] added
- "index.php" added support for interlink visualization
- "class.reflector.php" callingHome redisigned for interlink visualization
- "class.interlink.php" interlink visualization
xlx db v2.2.3
- "config.inc.php" $CallingHome['HashFile'] and $CallingHome['OverrideIPAddress'] added

0
dashboard/img/flags/nie.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -8,7 +8,7 @@ if (!class_exists('Node')) require_once("./pgs/class.node.php");
if (!class_exists('xReflector')) require_once("./pgs/class.reflector.php");
if (!class_exists('Station')) require_once("./pgs/class.station.php");
if (!class_exists('Peer')) require_once("./pgs/class.peer.php");
if (!class_exists('Interlink')) require_once("./pgs/class.interlink.php");
$Reflector = new xReflector();
$Reflector->SetFlagFile("./pgs/country.csv");
@ -48,11 +48,21 @@ if ($CallingHome['Active']) {
$CallHomeNow = true;
}
}
if ($CallHomeNow || isset($_GET['callhome'])) {
$Reflector->SetCallingHome($CallingHome['Active'], $CallingHome['MyDashBoardURL'], $Hash, $CallingHome['ServerURL'], $CallingHome['Country'], $CallingHome['Comment'], $CallingHome['OverrideIPAddress']);
$Reflector->PushCallingHome();
$Reflector->SetCallingHome($CallingHome, $Hash);
$Reflector->ReadInterlinkFile();
$Reflector->PrepareInterlinkXML();
$Reflector->PrepareReflectorXML();
$Reflector->CallHome();
}
}
else {
$Hash = "";
}
?><!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
@ -82,7 +92,7 @@ if ($CallingHome['Active']) {
echo '";
}';
if (!isset($_GET['show']) || (($_GET['show'] != 'liveircddb') && ($_GET['show'] != 'reflectors'))) {
if (!isset($_GET['show']) || (($_GET['show'] != 'liveircddb') && ($_GET['show'] != 'reflectors') && ($_GET['show'] != 'interlinks'))) {
echo '
setTimeout(ReloadPage, '.$PageOptions['PageRefreshDelay'].');';
}

View File

@ -0,0 +1,48 @@
<?php
class Interlink {
private $ReflectorName;
private $ReflectorAddress;
private $Modules;
public function __construct() {
$this->ReflectorName = null;
$this->ReflectorAddress = null;
$this->Modules = null;
}
public function SetName($RefName) { $this->ReflectorName = trim($RefName); }
public function SetAddress($RefAdd) { $this->ReflectorAddress = trim($RefAdd); }
public function GetName() { return $this->ReflectorName; }
public function GetAddress() { return $this->ReflectorAddress; }
public function GetModules() { return $this->Modules; }
public function AddModule($Module) {
$Module = trim($Module);
if (strlen($Module) != 1) return false;
if (strpos($this->Modules, $Module) === false) {
$this->Modules .= $Module;
}
return true;
}
public function RemoveModule($Module) {
$Module = trim($Module);
if (strlen($Module) != 1) return false;
if (strpos($this->Modules, $Module) !== false) {
$this->Modules = substr($this->Modules, 0, strpos($this->Modules, $Module)-1).substr($this->Modules, strpos($this->Modules, $Module)+1, strlen($this->Modules));
}
return true;
}
public function HasModuleEnabled($Module) {
if (strlen($Module) != 1) return false;
return (strpos($this->Modules, $Module) !== false);
}
}

View File

@ -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->Nodes = array();
$this->Stations = array();
$this->Peers = array();
$this->Interlinks = array();
$this->Transferinterlink = false;
}
public function LoadXML() {
@ -114,7 +121,7 @@ class xReflector {
}
return false;
}
public function LoadFlags() {
if ($this->Flagfile != null) {
$this->Flagarray = array();
@ -305,23 +312,133 @@ 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;
}
}
?>

View File

@ -14,9 +14,9 @@ $Service = array();
$CallingHome = array();
$PageOptions = array();
$PageOptions['ContactEmail'] = 'dvc@rlx.lu'; // Support E-Mail address
$PageOptions['ContactEmail'] = 'your_email'; // Support E-Mail address
$PageOptions['DashboardVersion'] = '2.2.3'; // Dashboard Version
$PageOptions['DashboardVersion'] = '2.3.1'; // Dashboard Version
$PageOptions['PageRefreshActive'] = true; // Activate automatic refresh
$PageOptions['PageRefreshDelay'] = '10000'; // Page refresh time in miliseconds
@ -24,8 +24,8 @@ $PageOptions['PageRefreshDelay'] = '10000'; // Page
$PageOptions['RepeatersPage'] = array();
$PageOptions['RepeatersPage']['LimitTo'] = 99; // Number of Repeaters to show
$PageOptions['RepeatersPage']['IPModus'] = 'ShowLast2ByteOfIP'; // See possible options above
$PageOptions['RepeatersPage']['MasqueradeCharacter'] = '*'; // Character used for masquerade
$PageOptions['RepeatersPage']['IPModus'] = 'ShowFullIP'; // See possible options above
$PageOptions['RepeatersPage']['MasqueradeCharacter'] = '*'; // Character used for masquerade
$PageOptions['PeerPage'] = array();
@ -52,13 +52,14 @@ $PageOptions['MetaRobots'] = 'index,follow';
$Service['PIDFile'] = '/var/log/xlxd.pid';
$Service['XMLFile'] = '/var/log/xlxd.xml';
$CallingHome['Active'] = false; // xlx phone home, true or false
$CallingHome['MyDashBoardURL'] = 'http://your_dashboard'; // dashboard url
$CallingHome['ServerURL'] = 'http://xlxapi.rlx.lu/api.php'; // database server, do not change !!!!
$CallingHome['PushDelay'] = 600; // push delay in seconds
$CallingHome['Country'] = "your_country"; // Country
$CallingHome['Comment'] = "your_comment"; // Comment. Max 100 character
$CallingHome['HashFile'] = "/tmp/callinghome.php"; // Make sure the apache user has read and write permissions in this folder.
$CallingHome['OverrideIPAddress'] = ""; // Leave blank for autodetection.
$CallingHome['Active'] = false; // xlx phone home, true or false
$CallingHome['MyDashBoardURL'] = 'http://your_dashboard'; // dashboard url
$CallingHome['ServerURL'] = 'http://xlxapi.rlx.lu/api.php'; // database server, do not change !!!!
$CallingHome['PushDelay'] = 600; // push delay in seconds
$CallingHome['Country'] = "your_country"; // Country
$CallingHome['Comment'] = "your_comment"; // Comment. Max 100 character
$CallingHome['HashFile'] = "/tmp/callinghome.php"; // Make sure the apache user has read and write permissions in this folder.
$CallingHome['OverrideIPAddress'] = ""; // Insert your IP address here. Leave blank for autodetection. No need to enter a fake address.
$CallingHome['InterlinkFile'] = "/xlxd/xlxd.interlink"; // Path to interlink file
?>

0
dashboard/pgs/country.csv Executable file → Normal file
View File

View File

@ -60,4 +60,4 @@ function CreateCode ($laenge) {
return $out;
}
?>
?>