phpldapadmin/htdocs/cmd.php

80 lines
2.6 KiB
PHP
Raw Normal View History

2009-06-30 10:46:00 +00:00
<?php
/**
* Main command page for phpLDAPadmin
* All pages are rendered through this script.
*
2009-06-30 10:46:41 +00:00
* @package phpLDAPadmin
* @subpackage Page
*/
/**
2009-06-30 10:46:00 +00:00
*/
require_once './common.php';
2009-09-06 14:13:58 +00:00
$www = array();
2009-06-30 11:46:44 +00:00
$www['cmd'] = get_request('cmd','REQUEST');
$www['meth'] = get_request('meth','REQUEST');
2009-06-30 10:46:00 +00:00
ob_start();
2009-06-30 11:46:44 +00:00
switch ($www['cmd']) {
default:
2009-06-30 11:46:44 +00:00
if (defined('HOOKSDIR') && file_exists(HOOKSDIR.$www['cmd'].'.php'))
$app['script_cmd'] = HOOKSDIR.$www['cmd'].'.php';
2009-06-30 11:46:44 +00:00
elseif (defined('HTDOCDIR') && file_exists(HTDOCDIR.$www['cmd'].'.php'))
$app['script_cmd'] = HTDOCDIR.$www['cmd'].'.php';
2009-06-30 11:46:44 +00:00
2009-06-30 11:50:46 +00:00
elseif (file_exists('welcome.php'))
$app['script_cmd'] = 'welcome.php';
else
$app['script_cmd'] = null;
2009-06-30 10:46:00 +00:00
}
2009-06-30 11:46:44 +00:00
if (DEBUG_ENABLED)
2009-08-19 03:39:37 +00:00
debug_log('Ready to render page for command [%s,%s].',128,0,__FILE__,__LINE__,__METHOD__,$www['cmd'],$app['script_cmd']);
2009-06-30 10:46:00 +00:00
2009-06-30 11:46:44 +00:00
# Create page.
# Set the index so that we render the right server tree.
$www['page'] = new page($app['server']->getIndex());
# See if we can render the command
if (trim($www['cmd'])) {
# If this is a READ-WRITE operation, the LDAP server must not be in READ-ONLY mode.
if ($app['server']->isReadOnly() && ! in_array(get_request('cmd','REQUEST'),$app['readwrite_cmds']))
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php');
2009-06-30 10:46:00 +00:00
# If this command has been disabled by the config.
if (! $_SESSION[APPCONFIG]->isCommandAvailable('script',$www['cmd'])) {
system_message(array('title'=>_('Command disabled by the server configuration'),
2010-03-14 12:48:40 +00:00
_('Error'),'body'=>sprintf('%s: <b>%s</b>.',_('The command could not be run'),htmlspecialchars($www['cmd'])),'type'=>'error'),'index.php');
$app['script_cmd'] = null;
}
}
if ($app['script_cmd'])
include $app['script_cmd'];
# Refresh a frame - this is so that one frame can trigger another frame to be refreshed.
if (isAjaxEnabled() && get_request('refresh','REQUEST') && get_request('refresh','REQUEST') != get_request('frame','REQUEST')) {
2009-08-22 11:30:50 +00:00
echo '<script type="text/javascript" language="javascript">';
2010-02-24 15:03:10 +00:00
printf("ajDISPLAY('%s','cmd=refresh&server_id=%s&noheader=%s','%s');",
2009-08-22 11:30:50 +00:00
get_request('refresh','REQUEST'),$app['server']->getIndex(),get_request('noheader','REQUEST',false,0),_('Auto refresh'));
echo '</script>';
}
2009-06-30 10:46:00 +00:00
2009-06-30 11:46:44 +00:00
# Capture the output and put into the body of the page.
$www['body'] = new block();
$www['body']->SetBody(ob_get_contents());
$www['page']->block_add('body',$www['body']);
ob_end_clean();
2009-06-30 10:46:00 +00:00
if ($www['meth'] == 'ajax')
$www['page']->show(get_request('frame','REQUEST',false,'BODY'),true,get_request('raw','REQUEST',false,false));
2009-06-30 10:46:00 +00:00
else
2009-06-30 11:46:44 +00:00
$www['page']->display();
2009-06-30 10:46:00 +00:00
?>