| 1 |
<?php /* $Id$ */ |
|---|
| 2 |
//Copyright (C) 2004 Coalescent Systems Inc. (info@coalescentsystems.ca) |
|---|
| 3 |
// |
|---|
| 4 |
//This program is free software; you can redistribute it and/or |
|---|
| 5 |
//modify it under the terms of the GNU General Public License |
|---|
| 6 |
//as published by the Free Software Foundation; either version 2 |
|---|
| 7 |
//of the License, or (at your option) any later version. |
|---|
| 8 |
// |
|---|
| 9 |
//This program is distributed in the hope that it will be useful, |
|---|
| 10 |
//but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 |
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 |
//GNU General Public License for more details. |
|---|
| 13 |
|
|---|
| 14 |
$type = isset($_REQUEST['type'])?$_REQUEST['type']:'setup'; |
|---|
| 15 |
$display = isset($_REQUEST['display'])?$_REQUEST['display']:''; |
|---|
| 16 |
$extdisplay = isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:null; |
|---|
| 17 |
$skip = isset($_REQUEST['skip'])?$_REQUEST['skip']:0; |
|---|
| 18 |
$action = isset($_REQUEST['action'])?$_REQUEST['action']:null; |
|---|
| 19 |
$quietmode = isset($_REQUEST['quietmode'])?$_REQUEST['quietmode']:''; |
|---|
| 20 |
|
|---|
| 21 |
// determine module type to show, default to 'setup' |
|---|
| 22 |
$type_names = array( |
|---|
| 23 |
'tool'=>'Tools', |
|---|
| 24 |
'setup'=>'Setup', |
|---|
| 25 |
'cdrcost'=>'Call Cost', |
|---|
| 26 |
); |
|---|
| 27 |
|
|---|
| 28 |
include('header.php'); |
|---|
| 29 |
|
|---|
| 30 |
// get all enabled modules |
|---|
| 31 |
// active_modules array used below and in drawselects function and genConf function |
|---|
| 32 |
$active_modules = module_getinfo(false, MODULE_STATUS_ENABLED); |
|---|
| 33 |
|
|---|
| 34 |
// initialize menu with module admin |
|---|
| 35 |
$fpbx_menu = array( |
|---|
| 36 |
'modules' => array('type'=>'tool', 'category' => 'System Administration', 'name' => 'Module Admin', 'sort' => 0) |
|---|
| 37 |
); |
|---|
| 38 |
|
|---|
| 39 |
// include any module global functions |
|---|
| 40 |
// add module sections to $fpbx_menu |
|---|
| 41 |
$types = array(); |
|---|
| 42 |
if(is_array($active_modules)){ |
|---|
| 43 |
foreach($active_modules as $key => $module) { |
|---|
| 44 |
//include module functions |
|---|
| 45 |
if (is_file("modules/{$key}/functions.inc.php")) { |
|---|
| 46 |
require_once("modules/{$key}/functions.inc.php"); |
|---|
| 47 |
} |
|---|
| 48 |
//create an array of module sections to display |
|---|
| 49 |
// only of the type we are displaying though |
|---|
| 50 |
|
|---|
| 51 |
// stored as [items][$type][$category][$name] = $displayvalue |
|---|
| 52 |
if (isset($module['items']) && is_array($module['items'])) { |
|---|
| 53 |
// loop through the types |
|---|
| 54 |
foreach($module['items'] as $itemKey => $item) { |
|---|
| 55 |
if (!in_array($item['type'], $types)) { |
|---|
| 56 |
$types[] = $item['type']; |
|---|
| 57 |
} |
|---|
| 58 |
// item is an assoc array, with at least array(name=>, category=>, type=>) |
|---|
| 59 |
$fpbx_menu[$itemKey] = $item; |
|---|
| 60 |
} |
|---|
| 61 |
} |
|---|
| 62 |
} |
|---|
| 63 |
} |
|---|
| 64 |
sort($types); |
|---|
| 65 |
|
|---|
| 66 |
// new gui hooks |
|---|
| 67 |
if(is_array($active_modules)){ |
|---|
| 68 |
foreach($active_modules as $key => $module) { |
|---|
| 69 |
if (isset($module['items']) && is_array($module['items'])) { |
|---|
| 70 |
foreach($module['items'] as $itemKey => $itemName) { |
|---|
| 71 |
//list of potential _configpageinit functions |
|---|
| 72 |
$initfuncname = $key . '_' . $itemKey . '_configpageinit'; |
|---|
| 73 |
if ( function_exists($initfuncname) ) { |
|---|
| 74 |
$configpageinits[] = $initfuncname; |
|---|
| 75 |
} |
|---|
| 76 |
} |
|---|
| 77 |
} |
|---|
| 78 |
//check for module level (rather than item as above) _configpageinit function |
|---|
| 79 |
$initfuncname = $key . '_configpageinit'; |
|---|
| 80 |
if ( function_exists($initfuncname) ) { |
|---|
| 81 |
$configpageinits[] = $initfuncname; |
|---|
| 82 |
} |
|---|
| 83 |
} |
|---|
| 84 |
} |
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
// extensions vs device/users ... this is a bad design, but hey, it works |
|---|
| 88 |
if (isset($amp_conf["AMPEXTENSIONS"]) && ($amp_conf["AMPEXTENSIONS"] == "deviceanduser")) { |
|---|
| 89 |
unset($fpbx_menu["extensions"]); |
|---|
| 90 |
} else { |
|---|
| 91 |
unset($fpbx_menu["devices"]); |
|---|
| 92 |
unset($fpbx_menu["users"]); |
|---|
| 93 |
} |
|---|
| 94 |
|
|---|
| 95 |
if (is_array($fpbx_menu)) { |
|---|
| 96 |
foreach ($fpbx_menu as $key => $value) { |
|---|
| 97 |
// check access |
|---|
| 98 |
if ($_SESSION["AMP_user"]->checkSection($key)) { |
|---|
| 99 |
// if the module has it's own translations, use them for displaying menu item |
|---|
| 100 |
if (extension_loaded('gettext')) { |
|---|
| 101 |
if (is_dir("modules/{$key}/i18n")) { |
|---|
| 102 |
bindtextdomain($key,"modules/{$key}/i18n"); |
|---|
| 103 |
bind_textdomain_codeset($key, 'utf8'); |
|---|
| 104 |
textdomain($key); |
|---|
| 105 |
} else { |
|---|
| 106 |
bindtextdomain('amp','./i18n'); |
|---|
| 107 |
textdomain('amp'); |
|---|
| 108 |
} |
|---|
| 109 |
} |
|---|
| 110 |
} else { |
|---|
| 111 |
// they don't have access to this, remove it completely |
|---|
| 112 |
unset($fpbx_menu[$key]); |
|---|
| 113 |
} |
|---|
| 114 |
} |
|---|
| 115 |
} |
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
// check access |
|---|
| 120 |
if ( ($display != '') && !isset($fpbx_menu[$display]) ) { |
|---|
| 121 |
showview("noaccess"); |
|---|
| 122 |
exit; |
|---|
| 123 |
} |
|---|
| 124 |
|
|---|
| 125 |
// load the component from the loaded modules |
|---|
| 126 |
if ( $display != '' && isset($configpageinits) && is_array($configpageinits) ) { |
|---|
| 127 |
|
|---|
| 128 |
$currentcomponent = new component($display,$type); |
|---|
| 129 |
|
|---|
| 130 |
// call every modules _configpageinit function which should just |
|---|
| 131 |
// register the gui and process functions for each module, if relevent |
|---|
| 132 |
// for this $display |
|---|
| 133 |
foreach ($configpageinits as $func) { |
|---|
| 134 |
$func($display); |
|---|
| 135 |
} |
|---|
| 136 |
|
|---|
| 137 |
// now run each 'process' function and 'gui' function |
|---|
| 138 |
$currentcomponent->processconfigpage(); |
|---|
| 139 |
$currentcomponent->buildconfigpage(); |
|---|
| 140 |
} |
|---|
| 141 |
|
|---|
| 142 |
// note: we buffer all the output from the 'page' being loaded.. |
|---|
| 143 |
// This may change in the future, with proper returns, but for now, it's a simple |
|---|
| 144 |
// way to support the old page.item.php include module format. |
|---|
| 145 |
ob_start(); |
|---|
| 146 |
|
|---|
| 147 |
// show the appropriate page |
|---|
| 148 |
switch($display) { |
|---|
| 149 |
default: |
|---|
| 150 |
//display the appropriate module page |
|---|
| 151 |
if (!isset($active_modules) || (isset($active_modules) && !is_array($active_modules))) { |
|---|
| 152 |
break; |
|---|
| 153 |
} |
|---|
| 154 |
|
|---|
| 155 |
foreach ($active_modules as $modkey => $module) { |
|---|
| 156 |
if (!isset($module['items']) || (isset($module['items']) && !is_array($module['items']))){ |
|---|
| 157 |
continue; |
|---|
| 158 |
} |
|---|
| 159 |
|
|---|
| 160 |
foreach (array_keys($module['items']) as $item){ |
|---|
| 161 |
if ($display != $item) { |
|---|
| 162 |
continue; |
|---|
| 163 |
} |
|---|
| 164 |
|
|---|
| 165 |
// modules can use their own translation files |
|---|
| 166 |
if (extension_loaded('gettext')) { |
|---|
| 167 |
if(is_dir("./modules/{$modkey}/i18n")) { |
|---|
| 168 |
bindtextdomain($modkey,"./modules/{$modkey}/i18n"); |
|---|
| 169 |
bind_textdomain_codeset($modkey, 'utf8'); |
|---|
| 170 |
textdomain($modkey); |
|---|
| 171 |
} |
|---|
| 172 |
} |
|---|
| 173 |
|
|---|
| 174 |
//TODO Determine which item is this module displaying. Currently this is over the place, we should standarize on a "itemid" request var for now, we'll just cover all possibilities :-( |
|---|
| 175 |
$possibilites = array( |
|---|
| 176 |
'userdisplay', |
|---|
| 177 |
'extdisplay', |
|---|
| 178 |
'id', |
|---|
| 179 |
'itemid', |
|---|
| 180 |
'category', |
|---|
| 181 |
'selection' |
|---|
| 182 |
); |
|---|
| 183 |
$itemid = ''; |
|---|
| 184 |
foreach($possibilites as $possibility) { |
|---|
| 185 |
if ( isset($_REQUEST[$possibility]) && $_REQUEST[$possibility] != '' ) |
|---|
| 186 |
$itemid = $_REQUEST[$possibility]; |
|---|
| 187 |
} |
|---|
| 188 |
|
|---|
| 189 |
// create a module_hook object for this module's page |
|---|
| 190 |
$module_hook = new moduleHook; |
|---|
| 191 |
|
|---|
| 192 |
// populate object variables |
|---|
| 193 |
$module_hook->install_hooks($itemid,$modkey,$item); |
|---|
| 194 |
|
|---|
| 195 |
// let hooking modules process the $_REQUEST |
|---|
| 196 |
$module_hook->process_hooks($itemid,$modkey,$item,$_REQUEST); |
|---|
| 197 |
|
|---|
| 198 |
// include the module page |
|---|
| 199 |
include "modules/{$modkey}/page.{$item}.php"; |
|---|
| 200 |
|
|---|
| 201 |
// global component |
|---|
| 202 |
if ( isset($currentcomponent) ) { |
|---|
| 203 |
echo $currentcomponent->generateconfigpage(); |
|---|
| 204 |
} |
|---|
| 205 |
|
|---|
| 206 |
} |
|---|
| 207 |
} |
|---|
| 208 |
break; |
|---|
| 209 |
case 'modules': |
|---|
| 210 |
include 'page.modules.php'; |
|---|
| 211 |
break; |
|---|
| 212 |
case '': |
|---|
| 213 |
if ($astman) { |
|---|
| 214 |
/* |
|---|
| 215 |
printf( "<h2>%s</h2>", dgettext("welcome page", "Welcome to FreePBX.") ); |
|---|
| 216 |
|
|---|
| 217 |
$modules_needup = module_getinfo(false, MODULE_STATUS_NEEDUPGRADE); |
|---|
| 218 |
$modules_broken = module_getinfo(false, MODULE_STATUS_BROKEN); |
|---|
| 219 |
if (count($modules_needup) || count($modules_broken)) { |
|---|
| 220 |
echo "<div class=\"warning\">"; |
|---|
| 221 |
if (count($modules_needup)) { |
|---|
| 222 |
echo "<p>"._("Warning: The following modules are disabled because they need upgrading: "); |
|---|
| 223 |
echo implode(", ",array_keys($modules_needup)); |
|---|
| 224 |
echo "</p>"; |
|---|
| 225 |
} |
|---|
| 226 |
if (count($modules_broken)) { |
|---|
| 227 |
echo "<p>"._("Warning: The following modules are disabled because they are broken: "); |
|---|
| 228 |
echo implode(", ",array_keys($modules_broken)); |
|---|
| 229 |
echo "</p>"; |
|---|
| 230 |
} |
|---|
| 231 |
echo "<p>", sprintf(dgettext("welcome page","You should go to the <a href='%s'>Module Admin</a> page to fix these.</p>"), "config.php?display=modules&type=tool"); |
|---|
| 232 |
echo "</div>"; |
|---|
| 233 |
} |
|---|
| 234 |
|
|---|
| 235 |
// BETA code - remove later. |
|---|
| 236 |
echo "<div class=\"warning\">"; |
|---|
| 237 |
printf( "<p>%s</p>", dgettext("welcome page", "You are FreePBX 2.3 Beta 1. This release is the first release in prepartation for FreePBX Version 2.3.0.") ); |
|---|
| 238 |
|
|---|
| 239 |
printf( "<p>%s</p>" , dgettext("welcome page", "Currently known bugs are maintained on <a href='http://www.freepbx.org/trac/wiki/2.3Beta'>this TRAC page</a>. If you find a bug, please <a href='http://www.freepbx.org/trac/newticket'>create a bug report</a> (you need to create an account - this is to avoid spammers) and the bug report will immediately appear on the <a href='http://www.freepbx.org/trac/wiki/2.3Beta'>TRAC page</a> so that it can be easily tracked by other users.") ); |
|---|
| 240 |
echo "</div>"; |
|---|
| 241 |
|
|---|
| 242 |
printf( "<!--[if IE]><p>%s</p><![endif]-->" , dgettext("welcome page", "Note, presently, Microsoft's Internet Explorer is <b>not</b> a supported web browser, and you must use a standards compliant browser, such as Firefox.") ); |
|---|
| 243 |
|
|---|
| 244 |
if ($amp_conf['AMPMGRPASS'] == 'amp111') { |
|---|
| 245 |
printf( "<div class=\"warning\"><p>%s</p></div>", dgettext("welcome text", "Warning: You are running FreePBX and ").$amp_conf['AMPENGINE'].dgettext("welcome page", " with the default manager pass. You should consider changing this to something else.")." ".sprintf('(<a href="http://aussievoip.com/wiki/index.php?page=FreePBX-ManagerPass" target="_new">%s</a>)', _("Help")) ); |
|---|
| 246 |
} |
|---|
| 247 |
|
|---|
| 248 |
if ( ($amp_conf["AMPDBENGINE"] == "mysql") || ($amp_conf["AMPDBENGINE"] == "pgsql")) { |
|---|
| 249 |
if ($amp_conf['AMPDBPASS'] == 'amp109') { |
|---|
| 250 |
printf( "<div class=\"warning\"><p>%s</p></div>", dgettext("welcome text", "Warning: You are running FreePBX and ").$amp_conf['AMPDBENGINE'].dgettext("welcome page", " with the default password ")." ".sprintf('(<a href="http://aussievoip.com/wiki/index.php?page=FreePBX-MysqlPass" target="_new">%s</a>)', _("Help")) ); |
|---|
| 251 |
} |
|---|
| 252 |
} |
|---|
| 253 |
|
|---|
| 254 |
|
|---|
| 255 |
|
|---|
| 256 |
printf( "<p>%s</p>" , dgettext("welcome page", "If you're new to FreePBX, Welcome. Here are some quick instructions to get you started") ); |
|---|
| 257 |
|
|---|
| 258 |
echo "<p>"; |
|---|
| 259 |
printf( dgettext("welcome page", |
|---|
| 260 |
"There are a large number of Plug-in modules available from the Online Repository. This is |
|---|
| 261 |
available by clicking on the <a href='%s'>Tools menu</a> up the top, then |
|---|
| 262 |
<a href='%s'>Module Admin</a>, then |
|---|
| 263 |
<a href='%s'>Check for updates online</a>. |
|---|
| 264 |
Modules are updated and patched often, so if you are having a problem, it's worth checking there to see if there's |
|---|
| 265 |
a new version of the module available."), |
|---|
| 266 |
"config.php?type=tool", |
|---|
| 267 |
"config.php?display=modules&type=tool", |
|---|
| 268 |
"config.php?display=modules&type=tool&extdisplay=online" |
|---|
| 269 |
); |
|---|
| 270 |
echo "</p>\n"; |
|---|
| 271 |
|
|---|
| 272 |
echo "<p>"; |
|---|
| 273 |
printf( dgettext( "welcome page", |
|---|
| 274 |
"If you're having any problems, you can also use the <a href='%s'>Online Support</a> |
|---|
| 275 |
module (<b>you need to install this through the <a href='%s'>Module Repository</a> first</b>) |
|---|
| 276 |
to talk to other users and the devlopers in real time. Click on <a href='%s'>Start IRC</a>, |
|---|
| 277 |
when the module is installed, to start a Java IRC client." ), |
|---|
| 278 |
"config.php?type=tool&display=irc", |
|---|
| 279 |
"config.php?display=modules&type=tool&extdisplay=online", |
|---|
| 280 |
"config.php?type=tool&display=irc&action=start" |
|---|
| 281 |
); |
|---|
| 282 |
echo "</p>\n"; |
|---|
| 283 |
|
|---|
| 284 |
echo "<p>"; |
|---|
| 285 |
printf( dgettext( "welcome page", |
|---|
| 286 |
"There is also a community based <a href='%s' target='_new'>FreePBX Web Forum</a> where you can post |
|---|
| 287 |
questions and search for answers for any problems you may be having."), |
|---|
| 288 |
"http://forums.freepbx.org" ); |
|---|
| 289 |
echo "</p>\n"; |
|---|
| 290 |
|
|---|
| 291 |
print( "<p>" . _("We hope you enjoy using FreePBX!") . "</p>\n" ); |
|---|
| 292 |
} // no manager, no connection to asterisk |
|---|
| 293 |
else { |
|---|
| 294 |
echo "<p><div class='clsError'>\n"; |
|---|
| 295 |
echo "<b>" . _("Warning:") . "</b>\n"; |
|---|
| 296 |
echo "<br>"; |
|---|
| 297 |
echo "<br>\n"; |
|---|
| 298 |
echo _("Cannot connect to Asterisk Manager with "). "<i>" .$amp_conf["AMPMGRUSER"] . "</i>"; |
|---|
| 299 |
echo "<br>"; |
|---|
| 300 |
echo _("Asterisk may not be running."); |
|---|
| 301 |
echo "</div></p>\n"; |
|---|
| 302 |
*/ |
|---|
| 303 |
showview('welcome', array('AMP_CONF' => &$amp_conf)); |
|---|
| 304 |
} else { |
|---|
| 305 |
// no manager, no connection to asterisk |
|---|
| 306 |
showview('welcome_nomanager', array('mgruser' => $amp_conf["AMPMGRUSER"])); |
|---|
| 307 |
} |
|---|
| 308 |
break; |
|---|
| 309 |
} |
|---|
| 310 |
|
|---|
| 311 |
if ($quietmode) { |
|---|
| 312 |
// send the output buffer |
|---|
| 313 |
ob_end_flush(); |
|---|
| 314 |
} else { |
|---|
| 315 |
$admin_template = $template = array(); |
|---|
| 316 |
|
|---|
| 317 |
|
|---|
| 318 |
$admin_template['content'] = ob_get_contents(); |
|---|
| 319 |
ob_end_clean(); |
|---|
| 320 |
|
|---|
| 321 |
// build the admin interface (with menu) |
|---|
| 322 |
$admin_template['fpbx_types'] = $types; |
|---|
| 323 |
$admin_template['fpbx_type_names'] = $type_names; |
|---|
| 324 |
$admin_template['fpbx_menu'] = $fpbx_menu; |
|---|
| 325 |
$admin_template['fpbx_usecategories'] = $amp_conf['USECATEGORIES']; |
|---|
| 326 |
$admin_template['fpbx_type'] = $type; |
|---|
| 327 |
$admin_template['display'] = $display; |
|---|
| 328 |
|
|---|
| 329 |
// then load it and put it into the main freepbx interface |
|---|
| 330 |
$template['content'] = loadview('freepbx_admin', $admin_template); |
|---|
| 331 |
|
|---|
| 332 |
// setup main template |
|---|
| 333 |
$template['display'] = $display; |
|---|
| 334 |
$template['title'] = "FreePBX administration"; |
|---|
| 335 |
$template['amp_conf'] = &$amp_conf; |
|---|
| 336 |
|
|---|
| 337 |
|
|---|
| 338 |
showview('freepbx', $template); |
|---|
| 339 |
} |
|---|
| 340 |
|
|---|
| 341 |
?> |
|---|