📄 page.modules.php
字号:
<?php /* $Id: page.modules.php 2436 2006-09-15 03:14:06Z qldrob $ */$extdisplay = isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:'';$installed = find_allmodules();function pageReload(){return ""; //return "<script language=\"Javascript\">document.location='".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']."&foo=".rand()."'</script>";}if (isset($_POST['submit']) && is_array($_POST['modules'])) { // if form has been submitted foreach ($_POST['modules'] as $module) { switch ($_POST['modaction']) { case "install": if (runModuleSQL($module,'install')) installModule($module,$_POST[$module.'_version']); else echo "<div class=\"error\">"._("Module install script failed to run")."</div>"; break; case "uninstall": if (runModuleSQL($module,'uninstall')) uninstallModule($module); else echo "<div class=\"error\">"._("Module uninstall script failed to run")."</div>"; break; case "enable": enableModule($module); echo pageReload(); break; case "disable": disableModule($module); echo pageReload(); break; case "delete": deleteModule($module); rmModule($module); break; case "download": fetchModule($module); break; case "upgrade": upgradeModule($module); break; case "installenable": // install and enable a module $boolInstall = true; // only run install if it's not installed if ($installed[$module]['status'] == 0) { // set to false on failed install $boolInstall = runModuleSQL($module,'install'); if ($boolInstall) { installModule($module,$_POST[$module.'_version']); enableModule($module); echo pageReload(); } else { echo "<div class=\"error\">{$module}: "._("Module install script failed to run")."</div>"; } } else { // it's already installed, so just enable it enableModule($module); echo pageReload(); } break; case "downloadinstall": // download, install and enable fetchModule($module); if (runModuleSQL($module,'install')) installModule($module,$_POST[$module.'_version']); else echo "<div class=\"error\">"._("Module install script failed to run")."</div>"; enableModule($module); break; case "downloadupdate": //download and update fetchModule($module); upgradeModule($module); break; case "uninstalldelete": //uninstall and delete if (runModuleSQL($module,'uninstall')) uninstallModule($module); else echo "<div class=\"error\">"._("Module uninstall script failed to run")."</div>"; deleteModule($module); rmModule($module); break; } }}?></div><!-- <div class="rnav"> <li><a id="<?php echo ($extdisplay=='' ? 'current':'') ?>" href="config.php?display=modules&type=tool&extdisplay="><?php echo _("Local Modules") ?></a></li> <li><a id="<?php echo ($extdisplay=='online' ? 'current':'') ?>" href="config.php?display=modules&type=tool&extdisplay=online"><?php echo _("Online Modules") ?></a></li></div>--><div class="content"><?phpswitch($extdisplay) { case "online": echo "<h2>"; echo _("Module Administration (online)"); echo "</h2>"; echo "<a href='config.php?display=modules&type=tool&extdisplay=local'>"._("Terminate Connection to Online Module Repository")."</a>\n"; // determine which modules we have installed already $installed = find_allmodules(); // determine what modules are available $online = getModuleXml(); $dispMods = new displayModules($installed,$online); echo $dispMods->drawModules(); break; default: echo "<h2>"; echo _("Module Administration"); echo "</h2>"; echo "<a href='config.php?display=modules&type=tool&extdisplay=online'>"._("Connect to Online Module Repository")."</a>\n"; $installed = find_allmodules(); $dispMods = new displayModules($installed); echo $dispMods->drawModules(); break;}?><?php/* BEGIN FUNCTIONS *//* displays table of modules provided in the passed array * If displaying online modules, pass that array as the second arg */class displayModules { var $html; //constructor function displayModules($installed,$online=false) { // So, we have an array with several: /* [phpinfo] => Array ( [displayName] => PHP Info [version] => 1.0 [type] => tool [category] => Basic [info] => http://www.freepbx.org/wikiPage [items] => Array ( [PHPINFO] => PHP Info [PHPINFO2] => PHP Info2 ) [requirements] => Array ( [FILE] => /usr/sbin/asterisk [MODULE] => core ) ) */ // if we are displaying online modules, determine which are installed if($online) { $online = $this->sortModules($online); foreach(array_keys($online) as $arrkey) { if (!is_array($installed)) { continue; } // Determine if module is already local if(array_key_exists($arrkey,$installed)) { //check if online version is newer $newversion = $online[$arrkey]['version']; $oldversion = $installed[$arrkey]['version']; // version_compare returns 1 if new > old if (version_compare($newversion,$oldversion) == 1) { $modsOnlineUpdate[] = $online[$arrkey]; } else { // we are not displaying this array .. it's just here for kicks $modsOnlineInstalled[] = $online[$arrkey]; } } else { $modsOnlineOnly[] = $online[$arrkey]; } //$this->html .= $this->tableHtml($online[$arrkey],$status,$action); } /* * Available Module Updates */ if(is_array($modsOnlineUpdate)) { $rows = ""; foreach($modsOnlineUpdate as $mod) { $color = "orange"; $rows .= $this->tableHtml($mod,$color); } $this->options = " <select name=\"modaction\"> <option value=\"downloadupdate\">"._("Download and Update selected")." <option value=\"download\">"._("Download selected")." </select> <input type=\"submit\" name=\"submit\" value=\""._("Submit")."\"> "; // build the table $this->html .= $this->formStart(_("Available Module Updates (online)")); $this->html .= $rows; $this->html .= $this->formEnd($mod['status']); } /* * Online Modules */ if(is_array($modsOnlineOnly)) { $rows = ""; foreach($modsOnlineOnly as $mod) { $color = "white"; $rows .= $this->tableHtml($mod,$color); } $this->options = " <select name=\"modaction\"> <option value=\"downloadinstall\">"._("Download and Install selected")." <option value=\"download\">"._("Download selected")." </select> <input type=\"submit\" name=\"submit\" value=\""._("Submit")."\"> "; // build the table $this->html .= $this->formStart(_("Modules Available (online)")); $this->html .= $rows; $this->html .= $this->formEnd($mod['status']); } } $installed = $this->sortModules($installed); if (isset($installed) && is_array($installed)) { foreach($installed as $mod) { //create seperate arrays based on module status if ($mod['status'] == 0) { $modsNotinstalled[] = $mod; } else if($mod['status'] == 1){ $modsDisabled[] = $mod; } else if($mod['status'] == 2){ $modsEnabled[] = $mod; } else if($mod['status'] == 3){ $modsUpdate[] = $mod; } else if($mod['status'] == -1){ $modsBroken[] = $mod; } //$this->html .= $this->tableHtml($mod,$status,$color); } // draw a form and list for each module status /* * Modules Needing Update */ if(is_array($modsUpdate)) { $rows = ""; foreach($modsUpdate as $mod) { $color = "#CCFF00"; $rows .= $this->tableHtml($mod,$color); } $this->options = " <select name=\"modaction\"> <option value=\"upgrade\">"._("Upgrade Selected")." </select> <input type=\"submit\" name=\"submit\" value=\""._("Submit")."\"> "; // build the table $this->html .= $this->formStart(_("Enabled Modules Requiring Upgrade")); $this->html .= $rows; $this->html .= $this->formEnd($mod['status']); } /* * Enabled Modules */ if(is_array($modsEnabled)) { $rows = ""; foreach($modsEnabled as $mod) { $color = "white"; $rows .= $this->tableHtml($mod,$color); } $this->options = " <select name=\"modaction\"> <option value=\"disable\">"._("Disable Selected")." <option value=\"uninstall\">"._("Uninstall Selected")." <option value=\"uninstalldelete\">"._("Uninstall and Delete Selected")." </select> <input type=\"submit\" name=\"submit\" value=\""._("Submit")."\"> "; // build the table $this->html .= $this->formStart(_("Enabled Modules")); $this->html .= $rows; $this->html .= $this->formEnd($mod['status']); } /* * Disabled Modules */ if(is_array($modsDisabled)) { $rows = ""; foreach($modsDisabled as $mod) { $color = "white"; $rows .= $this->tableHtml($mod,$color); } $this->options = " <select name=\"modaction\"> <option value=\"enable\">"._("Enable Selected")." <option value=\"uninstall\">"._("Uninstall Selected")." <option value=\"uninstalldelete\">"._("Uninstall and Delete Selected")." </select> <input type=\"submit\" name=\"submit\" value=\""._("Submit")."\"> "; // build the table $this->html .= $this->formStart(_("Disabled Modules"));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -