From 486fa279f861909621ddc1de06375b486c72077d Mon Sep 17 00:00:00 2001 From: LX3JL Date: Wed, 4 May 2016 08:33:20 +0200 Subject: [PATCH] db 2.3.1 --- dashboard/changes.txt | 7 ++ dashboard/img/flags/nie.png | Bin dashboard/index.php | 18 +++- dashboard/pgs/class.interlink.php | 48 +++++++++++ dashboard/pgs/class.reflector.php | 139 +++++++++++++++++++++++++++--- dashboard/pgs/config.inc.php | 25 +++--- dashboard/pgs/country.csv | 0 dashboard/pgs/functions.php | 2 +- 8 files changed, 211 insertions(+), 28 deletions(-) mode change 100755 => 100644 dashboard/img/flags/nie.png create mode 100644 dashboard/pgs/class.interlink.php mode change 100755 => 100644 dashboard/pgs/country.csv diff --git a/dashboard/changes.txt b/dashboard/changes.txt index b021b25..75ce59f 100644 --- a/dashboard/changes.txt +++ b/dashboard/changes.txt @@ -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 diff --git a/dashboard/img/flags/nie.png b/dashboard/img/flags/nie.png old mode 100755 new mode 100644 diff --git a/dashboard/index.php b/dashboard/index.php index d7b5405..f86cb73 100644 --- a/dashboard/index.php +++ b/dashboard/index.php @@ -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 = ""; +} + + + ?> @@ -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'].');'; } diff --git a/dashboard/pgs/class.interlink.php b/dashboard/pgs/class.interlink.php new file mode 100644 index 0000000..296c196 --- /dev/null +++ b/dashboard/pgs/class.interlink.php @@ -0,0 +1,48 @@ +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); + } + +} + + + \ No newline at end of file diff --git a/dashboard/pgs/class.reflector.php b/dashboard/pgs/class.reflector.php index d4945c8..d36f2b0 100644 --- a/dashboard/pgs/class.reflector.php +++ b/dashboard/pgs/class.reflector.php @@ -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;$iInterlinks[] = 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;$jInterlinks[count($this->Interlinks)-1]->AddModule($Modules[$j]); + } + } + } + } + return true; + } + return false; + } + public function PrepareInterlinkXML() { + $xml = ' +'; + for ($i=0;$iInterlinks);$i++) { + $xml .= ' + + '.$this->Interlinks[$i]->GetName().' +
'.$this->Interlinks[$i]->GetAddress().'
+ '.$this->Interlinks[$i]->GetModules().' +
'; + } + $xml .= ' +
'; + $this->InterlinkXML = $xml; + } + + public function PrepareReflectorXML() { + $this->ReflectorXML = ' + + '.$this->ReflectorName.' + '.$this->ServiceUptime.' + '.$this->CallingHomeHash.' + '.$this->CallingHomeDashboardURL.' + '.$this->CallingHomeCountry.' + '.$this->CallingHomeComment.' + '.$this->CallingHomeOverrideIP.' +'; + } + public function CallHome() { + $xml = ' +CallingHome'.$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; + } + } ?> diff --git a/dashboard/pgs/config.inc.php b/dashboard/pgs/config.inc.php index 6e47859..fe9fe40 100644 --- a/dashboard/pgs/config.inc.php +++ b/dashboard/pgs/config.inc.php @@ -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 ?> diff --git a/dashboard/pgs/country.csv b/dashboard/pgs/country.csv old mode 100755 new mode 100644 diff --git a/dashboard/pgs/functions.php b/dashboard/pgs/functions.php index f12eddf..353b2d3 100644 --- a/dashboard/pgs/functions.php +++ b/dashboard/pgs/functions.php @@ -60,4 +60,4 @@ function CreateCode ($laenge) { return $out; } -?> +?> \ No newline at end of file