Location: PHPKode > projects > PHPMyServer > lite/index.php4.php
// PHPMyServer - A PHP System Information Script - Old project name was PHPMyStats
// http://www.phpmyserver.com/
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
// $Id: index.php/index.php4.php/index.php5.php/etc ,v 2.6 13-08-2005 16:30 precision Exp $
// Date in $Id is as DD-MM-YY

//PHPMyServer - Lite Client v2.6
//Build version:
//  split version at the DOT, before the DOT is the CORE version, AFTER the DOT is de RELEASE
//Every new release will get an higher number, so when i released version 2 of the script for the 126523st time, its version v2.126523

//Copyright 2004-2005 by KingOfDos Intra/Extra/Internet WebServices

$index_version = '1d4f67f89ab9ba08b8da8b6e583467ab'; //NEVER CHANGE THIS VALUE!!!!!!  

//Including some files
include 'config.php';
include 'includes/functions.php4.php';
include 'includes/class.template.php4.php';
include 'includes/class.parselayout.php4.php';
include 'includes/class.ipcalc.php4.php';

//If debug modus
$debugable = true;
$errorArray = array();

if (isset($_GET) AND isset($_GET['debug']) AND $debugable==true)

if ($debug==true)

//XML Parser class has also a link to the template engine
$xml_parser = new ParseXMLtoLayout(); //XML parser loader

//IP Check
if (isset($_SERVER['REMOTE_ADDR']) AND match_secure_ipv4($_SERVER['REMOTE_ADDR'])) {
	if (eregi('/',$access_from) AND strlen($access_from)<=40 AND $access_from_arr = explode('/',$access_from) AND count($access_from_arr)==2 AND
			match_secure_ipv4($access_from_arr[0]) AND match_secure_ipv4($access_from_arr[1])
	) {
		$ipcalc = new IPCalc();
		if ($ipcalc->isIPInSubnet($_SERVER['REMOTE_ADDR']))
			$access_me = true;
			$access_me = false;
	} elseif (eregi(',',$access_from) AND $access_from_arr = explode(',',$access_from)) {
		foreach($access_from_arr as $access_this_key => $access_this_val) {
			if (match_secure_ipv4($access_this_val) AND $access_this_val==$_SERVER['REMOTE_ADDR']) {
	} elseif (match_secure_ipv4($access_from) AND $access_from==$_SERVER['REMOTE_ADDR'])
	elseif ($access_from=='ALL')
	elseif ($access_from=='LOCALHOST' AND $_SERVER['REMOTE_ADDR']=='')
//IP (not) allowed
if (!$access_me) {
	if (match_secure_ipv4($_SERVER['REMOTE_ADDR']))
		error_log($pms_errorlog_default.'PMS::NO_IP_ACCESS['.$_SERVER['REMOTE_ADDR'].']',0); // Log to Webserver LOG
		error_log($pms_errorlog_default.'PMS::NO_IP_ACCESS[INSECURE_IP]',0); //Log to Webserver LOG

//Get the XML File from the server (when possable)
if ($ret_data = http_get($pms_xmlserver_url)) {
	if ($xmlreadeddata = myxmltoarray($ret_data)) {
		if ($xml_parser->SetData($xmlreadeddata)){
			if ($xmlserver_modules = $xml_parser->GetLoadedModules())
				$passtrue = true;
				$errorArray[] = 'Can\'t find / read the loaded module list from [ '.$pms_xmlserver_url.' ]';
		} else
			$errorArray[] = 'SetData faild with data from [ '.$pms_xmlserver_url.' ] (make sure that you have an ENDING slash when you open an directory, or use the FULL path!)';
	} else
		$errorArray[] = 'Can\'t parse XML into an array from [ '.$pms_xmlserver_url.' ]'."\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n".$ret_data."\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n";
} else
	$errorArray[] = 'Error in HTTP_GET [ '.$pms_xmlserver_url.' ]';
	//'Can\'t find / parse XML Server data at URL[ '.$pms_xmlserver_url.' ]'
//Read the XML file
//if ($ret_data = http_get($pms_xmlserver_url) AND $xml_parser->SetData(myxmltoarray($ret_data)) AND $xmlserver_modules = $xml_parser->GetLoadedModules()) {
if ($passtrue==true) {
	$xml_parser->tplClass->useif('content','pms_data',true); //Parse IF [pms_data]
	//Foreach #1 (modules)
	//Loop al modules that are loaded (by name)
	foreach($xmlserver_modules as $module_id => $module_name) { //Loop all modules to show/hide the IF's
		$xml_parser->ModuleLoaded($module_name); //When module is loaded, show him, otherwise -> remove him from the templatefile
		$module_data = $xml_parser->GetPathData('MODULES::'.$module_name); //Get the module_data (of the current module)
		$module_repl_arr = array();  //This is the ARRAY that contains all changes for every FOREACH. It will be used JUST before FOREACH #1 will restart.

		//--Foreach #2 (data in module)(split INFO and DATA)
		foreach($module_data as $this_module_key => $this_module_val) { //$module_data contains ALL information (PHPMyServer\Modules\$modulename\INFO and PHPMyServer\Modules\$modulename\DATA), this is an loop that will loop all that data.
			if (strtolower($this_module_key)=='info' AND gettype($this_module_val)=='array' AND count($this_module_val)>=1) { //The INFO section of the CURRENT module (see $module_name)
				//Replacing the INFO of the CURRENT module here
				//The $this_module_val contains some value's, with this foreach loop all of them and add it to the replace array.
				foreach($this_module_val as $this_module_info_key => $this_module_info_val)
					$module_repl_arr[$module_name.'::INFO::'.strtoupper($this_module_info_key)] = $this_module_info_val;

			} elseif (strtolower($this_module_key)=='data' AND gettype($this_module_val)=='array' AND count($this_module_val)>=1) { //The DATA section of the CURRENT module (see $module_name)
				//Replacing the DATA of the CURRENT module here

				//This will replace all the values, this is the main DATA foreach
				//--Foreach #3 STARTS HERE

				foreach($this_module_val as $this_module_data_key => $this_module_data_val) {
					//If it's an MULTI array, souch as HardDisk, HardWare, and more modules. That are using LOOPS
					//if ($module_name=='HARDDISK' and is_array($this_module_data_val) AND !isset($this_module_data_val['__multi']))
					//	print_r($this_module_data_val);
					//IN DEZE IFF ZIT DE FOUT!!! HIERDOOR KRIJG JE "Array to string conversion" op regel 185 van template.php4.php
					//Hij denkt dat de HDD geen ARRAY is (hij mist de __multi), terwijl dat wel zo zou moeten zijn!!
					if (is_array($this_module_data_val) AND isset($this_module_data_val['__multi']) AND $this_module_data_val['__multi']==1) {
						//echo 'is_array 72 = true<br>';
						$i=0;//The number for the device, or whatever it is. In the replacement's system of an MULTI array i want an ID. The ID is used as folowing: MODULENAME::DATA::MULTIARRAYNAME::ID::VALUE. Example: HARDWARE::DATA::DEVICE::0::TYPE. It's the ZERO (0) bevore the TYPE and after the DEVICE.
						$loop = 'MOD_'.strtoupper($module_name).'_'.$this_module_data_key; //Loop name
						//Get the loop of this MULTI array
						$xml_parser->tplClass->getloop('content',$loop); //Get the loop. Example: {LOOP=MOD_HARDWARE_DEVICE} blaat {/LOOP=MOD_HARDWARE_DEVICE}
						//Start loop
						foreach($this_module_data_val as $this_subdata_loop_key => $this_subdata_loop_val) { //Loop DATA in MULTI array
							if (is_array($this_subdata_loop_val)) {//The __multi value may not be replaced, so check if it's him or not. //cutted  AND $this_subdata_loop_key!='__multi'     zorgde er voor dat hij het eerste object in een multi array niet liet zien.
								$module_loop_replace = array();
								foreach($this_subdata_loop_val as $this_multi_arr_key => $this_multi_arr_val) { //This is the LOOP inside the MULTI data, all values replace here!
									$module_loop_replace[$this_multi_arr_key] = $this_multi_arr_val;

								if(is_array($module_loop_replace)) $xml_parser->tplClass->Replaceloop($loop,$module_loop_replace); //Replaces all the things for this loop
						//End loop
						$xml_parser->tplClass->ReturnLoop('content',$loop); //Return the LOOP to the CONTENT template
					elseif(is_array($this_module_data_val)) {
						$loop = 'MOD_'.strtoupper($module_name).'_'.$this_module_data_key; //Loop name
						$module_loop_replace = array();
						//Get the loop of this MULTI array
						$xml_parser->tplClass->getloop('content',$loop); //Get the loop. Example: {LOOP=MOD_HARDWARE_DEVICE} blaat {/LOOP=MOD_HARDWARE_DEVICE}
						//Start loop
						foreach($this_module_data_val as $this_subdata_loop_key => $this_subdata_loop_val) { //Loop DATA in MULTI array
							if ($this_subdata_loop_key!='__multi') {//The __multi value may not be replaced, so check if it's him or not.
								$module_loop_replace[$this_subdata_loop_key] = $this_subdata_loop_val;
						if(is_array($module_loop_replace)) $xml_parser->tplClass->Replaceloop($loop,$module_loop_replace); //Replaces all the things for this loop
						//End loop
						$xml_parser->tplClass->ReturnLoop('content',$loop); //Return the LOOP to the CONTENT template
					//When it's an NORMAL module, like Generic_Information and Network
					else {
						$module_repl_arr[$module_name.'::DATA::'.strtoupper($this_module_data_key)] = $this_module_data_val;
				//--Foreach #3 ENDS HERE
			} else
				error_log($pms_errorlog_default.'Foreach #2 - Illegal KEY from FOREACH',0); //Write ERROR to the ERROR.LOG (Apache), what IIS and other webservers will do, i don't know! Please let me know if you find out!
		//--Foreach #2 ENDS HERE
		$xml_parser->tplClass->Replace('content',$module_repl_arr); //Replace the just generated value's
		unset($module_repl_arr); //Remove the array, for re-use
	///--------------- Main replace for the entire template
	//Client IP / etc.
	$module_repl_arr = array();
	if (isset($_SERVER) AND $_SERVER['REMOTE_ADDR'] AND preg_match("/\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]\.\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]\.\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]\.\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]/x",$_SERVER["REMOTE_ADDR"]) AND $tmp_host = gethostbyaddr($_SERVER["REMOTE_ADDR"]))
		$module_repl_arr['NETWORK::DATA::THIS_CLIENT_NAMEBYIP'] = $tmp_host;
		$module_repl_arr['NETWORK::DATA::THIS_CLIENT_NAMEBYIP'] = 'Unknown';
	//nslookup server_name
	if (isset($_SERVER) AND $_SERVER['REMOTE_ADDR'] AND preg_match("/\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]\.\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]\.\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]\.\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]/x",$_SERVER["REMOTE_ADDR"]))
		$module_repl_arr['NETWORK::DATA::THIS_CLIENT_IP'] = $_SERVER['REMOTE_ADDR'];
		$module_repl_arr['NETWORK::DATA::THIS_CLIENT_IP'] = 'Unknown';
		$module_repl_arr['NETWORK::DATA::THIS_CLIENT_CONNECTION_PORT'] = 'Unknown';
		$module_repl_arr['NETWORK::DATA::THIS_CLIENT_CONNECTION_PROTOCOL'] = 'Unknown';
	$module_repl_arr['PMS::SERVER::VERSION'] = $xml_parser->GetPathData('SERVER::VERSION');
	$module_repl_arr['PMS::CLIENT::VERSION'] = $index_version;
	$module_repl_arr['PMS::SERVER::OSISWINDOWS'] = $xml_parser->GetPathData('SERVER::OSISWINDOWS');
	//--End Main replace --------------
	//----- Little Update System
	$update_md5_arr = array($index_version);//Create an array, including this client version MD5 hash
	if ($server_ver_md5 = $xml_parser->GetPathData('SERVER::VERSION')) //Read the version of PHPMyServer - XML Server
		$update_md5_arr[] = $server_ver_md5;
	if ($pms_update_auto==true) //When AUTO update is enabled.
		if ($update_data = PMSUpdateExec($pms_update_url,$update_md5_arr)){//Check for updates at the folowing url.
			if(gettype($update_data)=='string') {
				$errorArray[] = $update_data;
			} else {
				foreach($update_data as $this_update_val) {
		} else
	//--------End update System

	//Printing generated template
} else {
	//when you can't open the XML Server that the user requested
	//echo 'XML Server / File not found, please check the URL';exit;
		'NETWORK::DATA::XML_SERVER_IP'		=>	'?.?.?.?',
	//$errorArray[] = 'Can\'t find / parse XML Server data at URL[ '.$pms_xmlserver_url.' ]';

	//-----------Start Error System
	if (is_array($errorArray) AND count($errorArray)>=1) {
		foreach($errorArray as $this_error) {
	} else
	//--------------End Error System
echo $xml_parser->tplClass->qprint('content'); //Print the data.
Return current item: PHPMyServer