Location: PHPKode > projects > PHPMyServer > server/includes/classes.php4.php
<?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
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// 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 - XML Server 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
//http://www.phpmyserver.com
//http://www.kingofdos.com
//http://www.kingofdos.com

$class_version = '02f1051414bda3eb39439ce2c998abca'; //NEVER CHANGE THIS VALUE!!!!!!

class pmsModule {
	var $modules;
	var $Version;

	//-------------------------------------------
	//---- MODULES ------------------------------
	//-------------------------------------------
	
	//AAN GetInstalledModules een version check koppelen, dat scheelt weer extra werk later
	function GetInstalledModules() {
		//Returnes the modules in the /modules directory as an array
		
		//If the array already contains modules, don't read it again, > less serverload / parsetime
		if (is_array($this->modules) AND array_count_values($this->modules>=1)) {
			return $this->modules;
		}
		
		//else, open the dir "modules", and read all directorynames. then save it to $this->modules
		elseif (chdir('modules') AND $object_tree = opendir('.')) { //change dir, and open it
			$installed_modules = array(); //create array
			while(($object_name=readdir($object_tree)) !== false) { //start while, read the dir object by object
				if (is_dir($object_name) AND $object_name!='.' AND $object_name!='..') {//if the object is an dir, and not . or ..
					$installed_modules[] = $object_name; //add it to the object array
				}
			}
			
			if (array_count_values($installed_modules)>=1) { //if there are some objects found
				$this->modules = $installed_modules; //save it to $this->modules
				return $installed_modules; //return $installed_modules
			} else
				return false;
		}
		
		//else, something went wront, return FALSE
		else
			return false;
		
	}

	function LoadModule($module_name) {
		//Loads an module and saves the values to $this->modules (each module as an new array within $this->modules).
	}
	
	function SetVersion($version) {
		if (!isset($this->Version))
			$this->Version = $version;
	}

	//-------------------------------------------
	//---- XML GENERATOR ------------------------
	//-------------------------------------------
	function GenerateXML ($data_array) {
		if (isset($this->Version))
			$version = $this->Version;
		else
			$version = 'ERROR';
		
		if ($osvertmp = $this->func->osiswindows()) {
			if ($osvertmp==true)
				$osver = "true";
			else
				$osver = "false";
		} else
			$osver = "false";
		//Generates the XML content from $this->modules
		$ret = "<?xml version=\"1.0\" encoding=\"ISO-8859-15\"?>\r\n"
		."<phpmyserver>\r\n"
		."  <server>\r\n"
		."    <version>". $version ."</version>\r\n"
		."    <osiswindows>". $osver ."</osiswindows>\r\n"
		."  </server>\r\n"
		."  <modules>\r\n";

		foreach ($data_array as $this_name => $this_data) {
			//Opens module
			$ret .= "    <".$this_name.">\r\n";
			
			//--------- START INFO
			$ret .= "      <info>\r\n";
			//module data returnen
			foreach($this_data['information'] as $this_data_key => $this_data_val) {
				$ret .= "        <".$this_data_key.">".$this_data_val."</".$this_data_key.">\r\n";
			}
			$ret .= "      </info>\r\n";
			//--------- END INFO

			//--------- START DATA
			$ret .= "      <data>\r\n";
			//module data returnen
			foreach($this_data['return_data'] as $this_data_key => $this_data_val) {
				if (is_array($this_data_val)) {
					//if (isset($this_data_val['pms_id']))
					//	$this_attrib = ' pms_id="'.$this_data_val['pms_id'].'"';
					//else
					//	$this_attrib = '';
					
					//$ret .= "        <spec_".$this_data_key.$this_attrib.">\r\n";
					//foreach($this_data_val as $this_data_sub_key => $this_data_sub_val) {
					//	$ret .= "          <".$this_data_sub_key.">".$this_data_sub_val."</".$this_data_sub_key.">\r\n";
					//}
					//$ret .= "        </spec_".$this_data_key.">\r\n";
					
					//foreach($this_data_val as $this_data_sub_key => $this_data_sub_val) {
					for ($i = 0; $i<=count($this_data_val)-1; $i++) {
						if (isset($this_data_val[$i]['pms_id']))
							$ret .= "        <".$this_data_key." index=\"".$this_data_val[$i]['pms_id']."\">\r\n";
						else
							$ret .= "        <".$this_data_key.">\r\n";
						
						if (isset($this_data_val) AND isset($this_data_val[$i]) AND is_array($this_data_val[$i])) {
							foreach($this_data_val[$i] as $this_data_sub_key => $this_data_sub_val) {
								if ($this_data_sub_key!='pms_id')
									$ret .= "          <".$this_data_sub_key.">".$this_data_sub_val."</".$this_data_sub_key.">\r\n";
							}
						}
						$ret .= "        </".$this_data_key.">\r\n";
					}

				
				} else
					$ret .= "        <".$this_data_key.">".$this_data_val."</".$this_data_key.">\r\n";
			}
			$ret .= "      </data>\r\n";
			//--------- END DATA

			//Closes module
			$ret .= "    </".$this_name.">\r\n";
		}

		$ret .= "  </modules>\r\n"
		."</phpmyserver>\r\n";

		return $ret;

	}

	//-------------------------------------------
	//---- CONSTRUCTOR --------------------------
	//-------------------------------------------
	function pmsModule() {
		//Here the class starts

		//Load the function file
		if (function_exists('pmsFuncStatic'))
			$this->func=& pmsFuncStatic();
		else
			die('Please goto <a href="http://www.phpmyserver.com">PHPMyServer.com</a> and download PHPMyServer again, this is an incompatible version!');
	}
}



//Constructor thing
//$this->valuename=& nameStatic();

function &pmsModuleStatic() {
	static $pmsModule_instance;
	
    if(!isset($pmsModule_instance)){
        $pmsModule_instance=new pmsModule();
    }
    return($pmsModule_instance); 
}


?>
Return current item: PHPMyServer