⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 page.modules.php

📁 最近在做软交换时研究的一个软交换的东东
💻 PHP
📖 第 1 页 / 共 2 页
字号:
				$this->html .= $rows;				$this->html .= $this->formEnd($mod['status']);			}			/* 			 *  Local Modules Not Installed			 */						if(is_array($modsNotinstalled)) {				$rows = "";				foreach($modsNotinstalled as $mod) {					$color = "white";					$rows .= $this->tableHtml($mod,$color);				}				$this->options = "					<select name=\"modaction\">						<option value=\"installenable\">"._("Enable Selected")."						<option value=\"delete\">"._("Delete Selected")."					</select>					<input type=\"submit\" name=\"submit\" value=\""._("Submit")."\">					";				// build the table				$this->html .= $this->formStart(_("Not Installed Local Modules"));				$this->html .= $rows;				$this->html .= $this->formEnd($mod['status']);			}						if(is_array($modsBroken)) {				$rows = "";				foreach($modsBroken as $mod) {					$color = "#FFFFFF";					$rows .= $this->tableHtml($mod,$color);				}				$this->options = "					<select name=\"modac						<option value=\"delete\">"._("Delete Selected")."					</select>					<input type=\"submit\" name=\"submit\" value=\""._("Submit")."\">					";				// build the table				$this->html .= $this->formStart(_('Broken'));				$this->html .= $rows;				$this->html .= $this->formEnd($mod['status']);			}					}			}		//sorts the modules by category	function sortModules($array) {		if (isset($array) && is_array($array)) {			foreach($array as $key => $mod) {				// sort the list in category / displayName order				// this is the only way i know how to do this...surely there is another way?								// fields for sort				$displayName = isset($mod['displayName']) ? $mod['displayName'] : 'unknown';				$category = isset($mod['category']) ? $mod['category'] : 'unknown';					// we want to sort on this so make it first in the new array				$newallmods[$key]['asort'] = $category.$displayName;							// copy the rest of the array				$newallmods[$key]['displayName'] = $displayName;				$newallmods[$key]['category'] = $category;				$newallmods[$key]['rawname'] = $mod['rawname'];				$newallmods[$key]['info'] = $mod['info'];				$newallmods[$key]['location'] = $mod['location'];				$newallmods[$key]['version'] = isset($mod['version']) ? $mod['version'] : 'unknown';				$newallmods[$key]['type'] = isset($mod['type']) ? $mod['type'] : 'unknown';				$newallmods[$key]['status'] = isset($mod['status']) ? $mod['status'] : 0;								asort($newallmods);				}			return $newallmods;		}	}		function tableHtml($arrRow,$color) {		return <<< End_of_Html						<tr bgcolor={$color}>				<td>					<input type="checkbox" name="modules[]" value="{$arrRow['rawname']}">					<input type="hidden" name="{$arrRow['rawname']}_version" value="{$arrRow['version']}">				</td>				<td><a target=_BLANK href={$arrRow['info']}>{$arrRow['displayName']} ({$arrRow['rawname']})</a></td>				<td>{$arrRow['version']}</td>				<td>{$arrRow['type']}</td>				<td>{$arrRow['category']}</td>			</tr>			End_of_Html;	}		function formStart($title = "") {		return "			<h4>{$title}</h4>			<form method=\"POST\" action=\"{$_SERVER['REQUEST_URI']}\">			<table border=1><tr><th>&nbsp;</th><th>". _("Module")."</th><th>". _("Version")."</th><th>". _("Type") ."</th><th>". _("Category") ."</th></tr>				";	}	function formEnd() {		return "</table>{$this->options}</form><hr>";	}			function drawModules() {		return $this->html;	}}function getModuleXml() {	global $amp_conf;	//this should be in an upgrade file ... putting here for now.	sql('CREATE TABLE IF NOT EXISTS module_xml (time INT NOT NULL , data BLOB NOT NULL) TYPE = MYISAM ;');		$result = sql('SELECT * FROM module_xml','getRow',DB_FETCHMODE_ASSOC);	// if the epoch in the db is more than 2 hours old, or the xml is less than 100 bytes, then regrab xml	// Changed to 5 minutes while not in release. Change back for released version.	//	// used for debug, time set to 0 to always fall through	// if((time() - $result['time']) > 0 || strlen($result['data']) < 100 ) {	if((time() - $result['time']) > 300 || strlen($result['data']) < 100 ) {		$version = getversion();		$version = $version[0][0];		// we need to know the freepbx major version we have running (ie: 2.1.2 is 2.1)		preg_match('/(\d+\.\d+)/',$version,$matches);		//echo "the result is ".$matches[1];		if (isset($amp_conf["AMPMODULEXML"])) {			$fn = $amp_conf["AMPMODULEXML"]."modules-".$matches[1].".xml";			// echo "(From amportal.conf)"; //debug		} else {		$fn = "http://mirror.freepbx.org/modules-".$matches[1].".xml";			// echo "(From default)"; //debug		}		//$fn = "/usr/src/freepbx-modules/modules.xml";		$data = file_get_contents($fn);		// remove the old xml		sql('DELETE FROM module_xml');		// update the db with the new xml		$data4sql = (get_magic_quotes_gpc() ? $data : addslashes($data));		sql('INSERT INTO module_xml (time,data) VALUES ('.time().',"'.$data4sql.'")');	} else {//		echo "using cache";		$data = $result['data'];	}	//echo time() - $result['time'];	$parser = new xml2ModuleArray($data);	$xmlarray = $parser->parseModulesXML($data);	//$modules = $xmlarray['XML']['MODULE'];		//echo "<hr>Raw XML Data<pre>"; print_r(htmlentities($data)); echo "</pre>";	//echo "<hr>XML2ARRAY<pre>"; print_r($xmlarray); echo "</pre>";		return $xmlarray;}// runModuleSQL moved to functions.inc.phpfunction installModule($modname,$modversion) {	global $db;	global $amp_conf;		switch ($amp_conf["AMPDBENGINE"])	{		case "sqlite":			// to support sqlite2, we are not using autoincrement. we need to find the 			// max ID available, and then insert it			$sql = "SELECT max(id) FROM modules;";			$results = $db->getRow($sql);			$new_id = $results[0];			$new_id ++;			$sql = "INSERT INTO modules (id,modulename, version,enabled) values ('{$new_id}','{$modname}','{$modversion}','0' );";			break;				default:			$sql = "INSERT INTO modules (modulename, version) values ('{$modname}','{$modversion}');";		break;	}	$results = $db->query($sql);	if(DB::IsError($results)) {		die($results->getMessage());	}}function uninstallModule($modname) {	global $db;	$sql = "DELETE FROM modules WHERE modulename = '{$modname}'";	$results = $db->query($sql);	if(DB::IsError($results)) {		die($results->getMessage());	}}function enableModule($modname) {	global $db;	$sql = "UPDATE modules SET enabled = 1 WHERE modulename = '{$modname}'";	$results = $db->query($sql);	if(DB::IsError($results)) {		die($results->getMessage());	}}function disableModule($modname) {	global $db;	$sql = "UPDATE modules SET enabled = 0 WHERE modulename = '{$modname}'";	$results = $db->query($sql);	if(DB::IsError($results)) {		die($results->getMessage());	}}function deleteModule($modname) {	global $db;	$sql = "DELETE FROM modules WHERE modulename = '{$modname}' LIMIT 1";	$results = $db->query($sql);	if(DB::IsError($results)) {		die($results->getMessage());	}}//downloads a module, and extracts it into the module dirfunction fetchModule($name) {	global $amp_conf;	$res = getThisModule($name);	if (!isset($res)) {		echo "<div class=\"error\">"._("Unaware of module")." {$name}</div>";		return false;	}	$file = basename($res['location']);	$filename = $amp_conf['AMPWEBROOT']."/admin/modules/_cache/".$file;	if(file_exists($filename)) {		// We might already have it! Let's check the MD5.		$filedata = "";		$fh = @fopen($filename, "r");		while (!feof($fh)) {			$filedata .= fread($fh, 8192);		}		if (isset($res['md5sum']) && $res['md5sum'] == md5 ($filedata)) {			// Note, if there's no MD5 information, it will redownload			// every time. Otherwise theres no way to avoid a corrupt			// download			return verifyAndInstall($filename);		} else {			unlink($filename);		}	}	if (isset($amp_conf['AMPMODULESVN'])) {		$url = $amp_conf['AMPMODULESVN'].$res['location'];		// echo "(From amportal.conf)"; // debug	} else {	$url = "http://mirror.freepbx.org/modules/".$res['location'];		// echo "(From default)"; // debug	}	$fp = @fopen($filename,"w");	$filedata = file_get_contents($url);	fwrite($fp,$filedata);	fclose($fp);	if (is_readable($filename) !== TRUE ) {		echo "<div class=\"error\">"._("Unable to save")." {$filename} - Check file/directory permissions</div>";		return false;	}	// Check the MD5 info against what's in the module's XML	if (!isset($res['md5sum']) || empty($res['md5sum'])) {		echo "<div class=\"error\">"._("Unable to Locate Integrity information for")." {$filename} - "._("Continuing Anyway")."</div>";	} elseif ($res['md5sum'] != md5 ($filedata)) {		echo "<div class=\"error\">"._("File Integrity FAILED for")." {$filename} - "._("Aborting")."</div>";		unlink($filename);		return false;	}	// verifyAndInstall does the untar, and will do the signed-package check.	return verifyAndInstall($filename);}function upgradeModule($module, $allmods = NULL) {	if($allmods === NULL)		$allmods = find_allmodules();	// the install.php can set this to false if the upgrade fails.	$success = true;	if(is_file("modules/$module/install.php"))		include "modules/$module/install.php";	if ($success) {		sql('UPDATE modules SET version = "'.$allmods[$module]['version'].'" WHERE modulename = "'.$module.'"');		needreload();	}}function rmModule($module) {	global $amp_conf;	if($module != 'core') {		if (is_dir($amp_conf['AMPWEBROOT'].'/admin/modules/'.$module) && strstr($module, '.') === FALSE ) {			exec('/bin/rm -rf '.$amp_conf['AMPWEBROOT'].'/admin/modules/'.$module);		}	} else {		echo "<script language=\"Javascript\">alert('"._("You cannot delete the Core module")."');</script>";	}}function getThisModule($modname) {	$xmlinfo = getModuleXml();	foreach($xmlinfo as $key => $mod) {		if (isset($mod['rawname']) && $mod['rawname'] == $modname) 			return $mod;	}}function verifyAndInstall($filename) {	global $amp_conf;	system("tar zxf {$filename} --directory={$amp_conf['AMPWEBROOT']}/admin/modules/");	return true;}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -