diff --git a/VERSION b/VERSION index 96cc9d6..bbd32d5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -$Name: RELEASE-1_1_0_1 $ +$Name: RELEASE-1_1_0_2 $ diff --git a/config/config.php.example b/config/config.php.example index 79cbde4..4c380ae 100644 --- a/config/config.php.example +++ b/config/config.php.example @@ -111,8 +111,8 @@ $config->custom->commands['all'] = array( /* If you want to choose the appearance of the tree, specify a class name which inherits from the Tree class. */ -// $config->custom->appearance['tree'] = "HTMLTree"; -# $config->custom->appearance['tree'] = "PLMTree"; +// $config->custom->appearance['tree'] = "AJAXTree"; +# $config->custom->appearance['tree'] = "HTMLTree"; /* If you want to customise the entry view/edition, specify your factory name which inherits from the EntryFactory class. @@ -404,6 +404,7 @@ $friendly_attrs = array(); $friendly_attrs['facsimileTelephoneNumber'] = 'Fax'; $friendly_attrs['telephoneNumber'] = 'Phone'; +$friendly_attrs['uid'] = 'User Name'; /*********************************************/ /* Support for attrs display order */ diff --git a/htdocs/add_attr.php b/htdocs/add_attr.php index 7443ccc..6bb205f 100644 --- a/htdocs/add_attr.php +++ b/htdocs/add_attr.php @@ -1,5 +1,5 @@ isReadOnly()) pla_error(_('You cannot perform updates while server is in read-only mode')); -if (! $_SESSION['plaConfig']->isCommandAvailable('attribute_add')) +if (! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_add')) pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('add attribute'))); $entry['val'] = get_request('val','POST'); diff --git a/htdocs/add_attr_form.php b/htdocs/add_attr_form.php index 1ba7710..76feae6 100644 --- a/htdocs/add_attr_form.php +++ b/htdocs/add_attr_form.php @@ -1,5 +1,5 @@ 0) { foreach ($ldap['attrs']['avail'] as $a) { # is there a user-friendly translation available for this attribute? - if (isset($_SESSION['plaConfig']->friendly_attrs[strtolower($a)])) { + if ($_SESSION[APPCONFIG]->haveFriendlyName($a)) { $attr_display = sprintf('%s (%s)', - htmlspecialchars($_SESSION['plaConfig']->friendly_attrs[strtolower($a)]), + htmlspecialchars($_SESSION[APPCONFIG]->getFriendlyName($a)), htmlspecialchars($a)); } else { @@ -129,9 +129,9 @@ if (count($ldap['binattrs']['avail']) > 0) { foreach ($ldap['binattrs']['avail'] as $a) { # is there a user-friendly translation available for this attribute? - if (isset($_SESSION['plaConfig']->friendly_attrs[strtolower($a)])) { + if ($_SESSION[APPCONFIG]->haveFriendlyName($a)) { $attr_display = sprintf('%s (%s)', - htmlspecialchars($_SESSION['plaConfig']->friendly_attrs[strtolower($a)]), + htmlspecialchars($_SESSION[APPCONFIG]->getFriendlyName($a)), htmlspecialchars($a)); } else { diff --git a/htdocs/add_value.php b/htdocs/add_value.php index a98e12a..de1fa4b 100644 --- a/htdocs/add_value.php +++ b/htdocs/add_value.php @@ -1,5 +1,5 @@ isReadOnly()) pla_error(_('You cannot perform updates while server is in read-only mode')); -if (! $_SESSION['plaConfig']->isCommandAvailable('attribute_add_value')) +if (! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_add_value')) pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('add attribute value'))); # The DN and ATTR we are working with. diff --git a/htdocs/add_value_form.php b/htdocs/add_value_form.php index f6baee2..682127e 100644 --- a/htdocs/add_value_form.php +++ b/htdocs/add_value_form.php @@ -1,5 +1,5 @@ GetValue('appearance','entry_reader').'($ldapserver);'); +eval('$reader = new '.$_SESSION[APPCONFIG]->GetValue('appearance','entry_reader').'($ldapserver);'); $reader->visit('Start', $entry['ldap']); if (! $entry['ldap'] || $entry['ldap']->isReadOnly()) @@ -58,12 +58,12 @@ if (! $entry['ldap'] || $entry['ldap']->isReadOnly()) /* attribute values */ /*********************/ -eval('$writer = new '.$_SESSION['plaConfig']->GetValue('appearance','entry_writer').'($ldapserver);'); +eval('$writer = new '.$_SESSION[APPCONFIG]->GetValue('appearance','entry_writer').'($ldapserver);'); $ldap['attr'] = $entry['ldap']->getAttribute($entry['attr']['string']); if (!$ldap['attr']) { // define a new attribute for the entry - $attributefactoryclass = $_SESSION['plaConfig']->GetValue('appearance','attribute_factory'); + $attributefactoryclass = $_SESSION[APPCONFIG]->GetValue('appearance','attribute_factory'); eval('$attribute_factory = new '.$attributefactoryclass.'();'); $ldap['attr'] = $attribute_factory->newAttribute($entry['attr']['string'], array()); $ldap['attr']->setEntry($entry['ldap']); @@ -72,9 +72,9 @@ $ldap['count'] = $ldap['attr']->getValueCount(); if ($ldap['attr']->isReadOnly()) pla_error(sprintf(_('The attribute (%s) is in readonly mode.'),$entry['attr']['html']),null,-1,true); -if (! $_SESSION['plaConfig']->isCommandAvailable('attribute_add_value')) +if (! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_add_value')) pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('add attribute value'))); -if (($ldap['attr']->getValueCount() == 0) && ! $_SESSION['plaConfig']->isCommandAvailable('attribute_add')) +if (($ldap['attr']->getValueCount() == 0) && ! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_add')) pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('add attribute'))); /* @@ -197,7 +197,7 @@ if ($entry['attr']['oclass']) { echo ''; echo '
'; - if ($_SESSION['plaConfig']->GetValue('appearance','show_hints')) + if ($_SESSION[APPCONFIG]->GetValue('appearance','show_hints')) printf('
Hint%s
', _('Note: You may be required to enter new attributes that these objectClass(es) require')); echo ''; diff --git a/htdocs/cmd.php b/htdocs/cmd.php index 920aa5f..fce9f57 100644 --- a/htdocs/cmd.php +++ b/htdocs/cmd.php @@ -1,5 +1,5 @@ SetBody(ob_get_contents()); +# Create page. +$www['page'] = new page($ldapserver->server_id); + +if ($file) + include $file; + +# 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(); -if (DEBUG_ENABLED) - debug_log('Ready to render page for command [%s,%s].',128,__FILE__,__LINE__,__METHOD__,$cmd,$file); - -$www = new page($ldapserver->server_id); -$www->block_add('body',$body); - -if ($meth == 'get_body') - $www->body(true); +if ($www['meth'] == 'get_body') + $www['page']->body(true); else - $www->display(); + $www['page']->display(); ?> diff --git a/htdocs/common.php b/htdocs/common.php index 13b2037..40a2d0f 100644 --- a/htdocs/common.php +++ b/htdocs/common.php @@ -1,10 +1,12 @@ diff --git a/htdocs/compare.php b/htdocs/compare.php index c05a049..38847b3 100644 --- a/htdocs/compare.php +++ b/htdocs/compare.php @@ -1,5 +1,5 @@ ldapservers->Instance($server_id_src); +$ldapserver_src = $_SESSION[APPCONFIG]->ldapservers->Instance($server_id_src); if (! $ldapserver_src->haveAuthInfo()) pla_error(_('Not enough information to login to server. Please check your configuration.')); -$ldapserver_dst = $_SESSION['plaConfig']->ldapservers->Instance($server_id_dst); +$ldapserver_dst = $_SESSION[APPCONFIG]->ldapservers->Instance($server_id_dst); if (! $ldapserver_src->haveAuthInfo()) pla_error(_('Not enough information to login to server. Please check your configuration.')); @@ -33,10 +33,8 @@ if (! $ldapserver_src->dnExists($dn_src)) if (! $ldapserver_dst->dnExists($dn_dst)) pla_error(sprintf(_('No such entry: %s'),pretty_print_dn($dn_dst))); -$_SESSION['plaConfig']->friendly_attrs = process_friendly_attr_table(); - -$attrs_src = $ldapserver_src->getDNAttrs($dn_src,false,$_SESSION['plaConfig']->GetValue('deref','view')); -$attrs_dst = $ldapserver_dst->getDNAttrs($dn_dst,false,$_SESSION['plaConfig']->GetValue('deref','view')); +$attrs_src = $ldapserver_src->getDNAttrs($dn_src,false,$_SESSION[APPCONFIG]->GetValue('deref','view')); +$attrs_dst = $ldapserver_dst->getDNAttrs($dn_dst,false,$_SESSION[APPCONFIG]->GetValue('deref','view')); # Get a list of all attributes. $attrs_all = array_keys($attrs_src); @@ -118,13 +116,13 @@ foreach ($attrs_all as $attr) { $required_note = ''; # is there a user-friendly translation available for this attribute? - if (isset($_SESSION['plaConfig']->friendly_attrs[strtolower($attr)])) { - $attr_display = $_SESSION['plaConfig']->friendly_attrs[strtolower($attr)]; - $attr_note = sprintf('alias',sprintf(_('Note: \'%s\' is an alias for \'%s\''),$attr_display,$attr)); + if ($_SESSION[APPCONFIG]->haveFriendlyName($attr)) { + $attr_display = $_SESSION[APPCONFIG]->getFriendlyName($attr); + $attr_note = sprintf('%s',_('Note'),$attr_display,_('is an alias for'),$attr,_('alias')); } else { - $attr_note = ''; $attr_display = $attr; + $attr_note = ''; } # is this attribute required by an objectClass? @@ -311,7 +309,7 @@ foreach ($attrs_all as $attr) { if (trim($val) == "") echo "[" . _('empty') . "]
\n"; - elseif (0 == strcasecmp($attr,'userPassword') && $_SESSION['plaConfig']->GetValue('appearance','obfuscate_password_display')) + elseif (0 == strcasecmp($attr,'userPassword') && $_SESSION[APPCONFIG]->GetValue('appearance','obfuscate_password_display')) echo preg_replace('/./','*',$val) . "
"; else @@ -320,7 +318,7 @@ foreach ($attrs_all as $attr) { // @todo: redundant - $vals is always an array. } else { - if (0 == strcasecmp($attr,'userPassword') && $_SESSION['plaConfig']->GetValue('appearance','obfuscate_password_display')) + if (0 == strcasecmp($attr,'userPassword') && $_SESSION[APPCONFIG]->GetValue('appearance','obfuscate_password_display')) echo preg_replace('/./','*',$vals) . "
"; else echo $vals . "
"; diff --git a/htdocs/copy.php b/htdocs/copy.php index f69b6fa..c9d6333 100644 --- a/htdocs/copy.php +++ b/htdocs/copy.php @@ -1,5 +1,5 @@ isCommandAvailable('entry_move')) +if (! $_SESSION[APPCONFIG]->isCommandAvailable('entry_move')) pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('copy entry'))); $entry['src']['id'] = get_request('server_id'); $entry['dst']['id'] = get_request('dest_server_id'); -$entry['src']['ldapserver'] = $_SESSION['plaConfig']->ldapservers->Instance($entry['src']['id']); -$entry['dst']['ldapserver'] = $_SESSION['plaConfig']->ldapservers->Instance($entry['dst']['id']); +$entry['src']['ldapserver'] = $_SESSION[APPCONFIG]->ldapservers->Instance($entry['src']['id']); +$entry['dst']['ldapserver'] = $_SESSION[APPCONFIG]->ldapservers->Instance($entry['dst']['id']); if ($entry['dst']['ldapserver']->isReadOnly()) pla_error(_('Destination server is currently READ-ONLY.')); diff --git a/htdocs/copy_form.php b/htdocs/copy_form.php index 27569d3..1c09fb1 100644 --- a/htdocs/copy_form.php +++ b/htdocs/copy_form.php @@ -1,5 +1,5 @@ '; echo "\n"; -if ($_SESSION['plaConfig']->GetValue('appearance','show_hints')) +if ($_SESSION[APPCONFIG]->GetValue('appearance','show_hints')) printf('Light%s',_('Hint: Copying between different servers only works if there are no schema violations')); echo ''; diff --git a/htdocs/create.php b/htdocs/create.php index 070b2ac..15f0698 100644 --- a/htdocs/create.php +++ b/htdocs/create.php @@ -1,5 +1,5 @@ isReadOnly()) pla_error(_('You cannot perform updates while server is in read-only mode'), null, -1, true); -if (! $_SESSION['plaConfig']->isCommandAvailable('entry_create')) +if (! $_SESSION[APPCONFIG]->isCommandAvailable('entry_create')) pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('create entry'))); $rdn_attr = isset($_POST['rdn_attribute']) ? $_POST['rdn_attribute'] : null; -$entryfactoryclass = $_SESSION['plaConfig']->GetValue('appearance','entry_factory'); +$entryfactoryclass = $_SESSION[APPCONFIG]->GetValue('appearance','entry_factory'); eval('$entry_factory = new '.$entryfactoryclass.'();'); $entry = $entry_factory->newCreatingEntry(''); -eval('$reader = new '.$_SESSION['plaConfig']->GetValue('appearance', 'entry_reader').'($ldapserver);'); +eval('$reader = new '.$_SESSION[APPCONFIG]->GetValue('appearance', 'entry_reader').'($ldapserver);'); $entry->accept($reader); $container = $entry->getContainer(); @@ -94,7 +94,7 @@ if (run_hook('pre_entry_create',array('server_id'=>$ldapserver->server_id,'dn'=> if ($add_result) { run_hook('post_entry_create',array('server_id'=>$ldapserver->server_id,'dn'=>$new_dn,'attrs'=>$new_entry)); - $action_number = $_SESSION['plaConfig']->GetValue('appearance', 'action_after_creation'); + $action_number = $_SESSION[APPCONFIG]->GetValue('appearance', 'action_after_creation'); $container = get_container($new_dn,false); //$container_container = get_container($container); diff --git a/htdocs/css/style.css b/htdocs/css/style.css index 1ccfdf1..c3a531a 100644 --- a/htdocs/css/style.css +++ b/htdocs/css/style.css @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/css/style.css,v 1.48 2007/12/15 07:50:30 wurley Exp $ */ +/* $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/css/style.css,v 1.48.2.1 2007/12/24 06:41:51 wurley Exp $ */ /* Global Page */ table.page { @@ -82,9 +82,13 @@ table.page table.control a:hover { text-decoration: none; } +table.page table.control tr td.spacer { + width: 20%; +} + table.page table.control tr td.logo { text-align: right; - width: 20%; + width: 10%; } table.control td.logo img.logo { @@ -706,6 +710,19 @@ table.login { background-color: #ddddff; } +#generic { + background-color: #fafaff; + padding-left: 17px; +} +#generic:focus { + background-color: #ffffba; +} + +#generic:disabled { + background-color: #ddddff; +} + + /* Search Box */ table.search { background-color: #eeeeff; diff --git a/htdocs/delete.php b/htdocs/delete.php index bc9562c..37017ff 100644 --- a/htdocs/delete.php +++ b/htdocs/delete.php @@ -1,5 +1,5 @@ isReadOnly()) pla_error(_('You cannot perform updates while server is in read-only mode')); -if (! $_SESSION['plaConfig']->isCommandAvailable('entry_delete', 'simple_delete')) +if (! $_SESSION[APPCONFIG]->isCommandAvailable('entry_delete', 'simple_delete')) pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('delete entry'))); $entry['dn'] = get_request('dn'); @@ -43,7 +43,7 @@ if ($result) { 'title'=>_('Delete DN'), 'body'=>_('Successfully deleted DN ').sprintf('%s',$entry['dn']), 'type'=>'info'), - 'index.php'); + sprintf('index.php?server_id=%s',$ldapserver->server_id)); } else { pla_error(sprintf(_('Could not delete the entry: %s'),''.pretty_print_dn($entry['dn']).''), diff --git a/htdocs/delete_attr.php b/htdocs/delete_attr.php index 346ca6f..cbce0d2 100644 --- a/htdocs/delete_attr.php +++ b/htdocs/delete_attr.php @@ -1,5 +1,5 @@ isReadOnly()) pla_error(_('You cannot perform updates while server is in read-only mode')); -if (! $_SESSION['plaConfig']->isCommandAvailable('attribute_delete')) +if (! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_delete')) pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('delete attribute'))); $entry['dn']['string'] = get_request('dn'); diff --git a/htdocs/download_binary_attr.php b/htdocs/download_binary_attr.php index eb58903..2acd2f3 100644 --- a/htdocs/download_binary_attr.php +++ b/htdocs/download_binary_attr.php @@ -1,5 +1,5 @@ dnExists($dn)) pla_error(sprintf(_('No such entry: %s'),pretty_print_dn($dn))); -$search = $ldapserver->search(null,$dn,'(objectClass=*)',array($attr),'base',false,$_SESSION['plaConfig']->GetValue('deref','view')); +$search = $ldapserver->search(null,$dn,'(objectClass=*)',array($attr),'base',false,$_SESSION[APPCONFIG]->GetValue('deref','view')); # Dump the binary data to the browser if (ob_get_level()) ob_end_clean(); diff --git a/htdocs/entry_chooser.php b/htdocs/entry_chooser.php index 9b0bea7..640f45d 100644 --- a/htdocs/entry_chooser.php +++ b/htdocs/entry_chooser.php @@ -1,5 +1,5 @@ haveAuthInfo()) pla_error(_('Not enough information to login to server. Please check your configuration.')); - $entry['children'] = $ldapserver->getContainerContents($entry['container'],0,'(objectClass=*)',$_SESSION['plaConfig']->GetValue('deref','tree')); + $entry['children'] = $ldapserver->getContainerContents($entry['container'],0,'(objectClass=*)',$_SESSION[APPCONFIG]->GetValue('deref','tree')); sort($entry['children']); foreach ($ldapserver->getBaseDN() as $base_dn) { if (DEBUG_ENABLED) - debug_log('entry_chooser.php: Comparing BaseDN [%s] with container [%s]',64,$base_dn,$entry['container']); + debug_log('Comparing BaseDN [%s] with container [%s]',64,__FILE__,__LINE__,__METHOD__,$base_dn,$entry['container']); if (! pla_compare_dns($entry['container'],$base_dn)) { $parent_container = false; @@ -85,9 +85,9 @@ if (isset($ldapserver) && ! is_null($entry['container'])) { /* draw the root of the selection tree (ie, list all the servers) */ } else { - foreach ($_SESSION['plaConfig']->ldapservers->GetServerList() as $id) { + foreach ($_SESSION[APPCONFIG]->ldapservers->GetServerList() as $id) { - $ldapserver = $_SESSION['plaConfig']->ldapservers->Instance($id); + $ldapserver = $_SESSION[APPCONFIG]->ldapservers->Instance($id); if ($ldapserver->isVisible()) { diff --git a/htdocs/export.php b/htdocs/export.php index fbbbe95..6ecb620 100755 --- a/htdocs/export.php +++ b/htdocs/export.php @@ -1,5 +1,5 @@ isCommandAvailable('export')) +if (! $_SESSION[APPCONFIG]->isCommandAvailable('export')) pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('export'))); $entry['base_dn'] = get_request('dn'); diff --git a/htdocs/header.php b/htdocs/header.php index c23efcf..72e40f9 100644 --- a/htdocs/header.php +++ b/htdocs/header.php @@ -1,5 +1,5 @@ GetValue('appearance','language') : 'auto'; +$language = isset($_SESSION[APPCONFIG]) ? $language = $_SESSION[APPCONFIG]->GetValue('appearance','language') : 'auto'; # text/xml won't work with MSIE, but is very useful for debugging xhtml code. # header('Content-type: text/xml; charset="UTF-8"'); @@ -26,13 +26,13 @@ echo "\n\n"; echo ''; -if (isset($_SESSION['plaConfig']) && $pagetitle = $_SESSION['plaConfig']->GetValue('appearance','page_title')) +if (isset($_SESSION[APPCONFIG]) && $pagetitle = $_SESSION[APPCONFIG]->GetValue('appearance','page_title')) printf('phpLDAPadmin - %s',$pagetitle); else echo 'phpLDAPadmin'; -if (isset($_SESSION['plaConfig'])) - $css = $_SESSION['plaConfig']->GetValue('appearance','stylesheet'); +if (isset($_SESSION[APPCONFIG])) + $css = $_SESSION[APPCONFIG]->GetValue('appearance','stylesheet'); else $css = 'style.css'; printf('','../htdocs/'.CSSDIR,$css); diff --git a/htdocs/index.php b/htdocs/index.php index b9f25cf..372a8de 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -1,5 +1,5 @@ *******************************************/ -/* +/** * We will perform some sanity checking here, since this file is normally loaded first when users - * first setup PLA. + * first access the application. */ define('LIBDIR',sprintf('%s/',realpath('../lib/'))); ini_set('display_errors',1); @@ -33,64 +33,72 @@ if (! is_readable(LIBDIR.'functions.php')) { if (ob_get_level()) ob_end_clean(); die(sprintf("Cannot read the file '%sfunctions.php' its permissions may be too strict.",LIBDIR)); } -if (ob_get_level()) ob_end_clean(); + +if (ob_get_level()) + ob_end_clean(); require LIBDIR.'functions.php'; -$config_file = CONFDIR.'config.php'; + +# Define the path to our configuration file. +if (defined('CONFDIR')) + $app['config_file'] = CONFDIR.'config.php'; +else + $app['config_file'] = 'config.php'; # Make sure this PHP install has gettext, we use it for language translation if (! extension_loaded('gettext')) pla_error('

Your install of PHP appears to be missing GETTEXT support.

GETTEXT is used for language translation.

Please install GETTEXT support before using phpLDAPadmin.
(Dont forget to restart your web server afterwards)

'); -/* +/** * Helper functions. * Our required helper functions are defined in functions.php */ -foreach ($pla_function_files as $file_name ) { - if (! file_exists($file_name)) - pla_error(sprintf('Fatal error: Required file "%s" does not exist.',$file_name)); +if (isset($app['function_files']) && is_array($app['function_files'])) + foreach ($app['function_files'] as $file_name ) { + if (! file_exists($file_name)) + pla_error(sprintf('Fatal error: Required file "%s" does not exist.',$file_name)); - if (! is_readable($file_name)) - pla_error(sprintf('Fatal error: Cannot read the file "%s", its permissions may be too strict.',$file_name)); + if (! is_readable($file_name)) + pla_error(sprintf('Fatal error: Cannot read the file "%s", its permissions may be too strict.',$file_name)); - ob_start(); - require $file_name; - if (ob_get_level()) ob_end_clean(); -} + ob_start(); + require $file_name; + if (ob_get_level()) ob_end_clean(); + } # Configuration File check -if (! file_exists($config_file)) { +if (! file_exists($app['config_file'])) { echo ''; echo ''; echo ''; - printf('phpLDAPadmin - %s',pla_version()); + printf('%s - %s','phpLDAPadmin',pla_version()); echo ''; echo ''; echo ''; - echo '

Configure phpLDAPadmin

'; + printf('

Configure %s

','phpLDAPadmin'); echo '

'; echo '
'; - printf(_('You need to configure phpLDAPadmin. Edit the file "%s" to do so. An example config file is provided in "%s.example".'),$config_file,$config_file); + printf(_('You need to configure %s. Edit the file "%s" to do so. An example config file is provided in "%s.example".'),'phpLDAPadmin',$app['config_file'],$app['config_file']); echo '
'; echo ''; echo ''; die(); -} elseif (! is_readable($config_file)) { - pla_error(sprintf('Fatal error: Cannot read your configuration file "%s", its permissions may be too strict.',$config_file)); +} elseif (! is_readable($app['config_file'])) { + pla_error(sprintf('Fatal error: Cannot read your configuration file "%s", its permissions may be too strict.',$app['config_file'])); } # If our config file fails the sanity check, then stop now. -if (! check_config($config_file)) { - $www = new page(); - $body = new block(); - $www->block_add('body',$body); - $www->display(); +if (! check_config($app['config_file'])) { + $www['page'] = new page(); + $www['body'] = new block(); + $www['page']->block_add('body',$www['body']); + $www['page']->display(); exit; } diff --git a/htdocs/ldif_import.php b/htdocs/ldif_import.php index b13c3da..570158c 100644 --- a/htdocs/ldif_import.php +++ b/htdocs/ldif_import.php @@ -1,5 +1,5 @@ isCommandAvailable('import')) +if (! $_SESSION[APPCONFIG]->isCommandAvailable('import')) pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('import'))); $entry['continuous_mode'] = get_request('continuous_mode') ? true : false; diff --git a/htdocs/login.php b/htdocs/login.php index 6a9367f..a5717ab 100644 --- a/htdocs/login.php +++ b/htdocs/login.php @@ -1,5 +1,5 @@ getLoginAttr()); +$login['pass'] = get_request('login_pass'); if ($ldapserver->isAnonBindAllowed()) $anon_bind = get_request('anonymous_bind') == 'on' ? true : false; else $anon_bind = false; -if (! $anon_bind && ! strlen($pass)) +if (! $anon_bind && ! strlen($login['pass'])) system_message(array( 'title'=>_('Authenticate to server'), 'body'=>_('You left the password blank.'), 'type'=>'warn'), - 'cmd.php?cmd=login_form'); + sprintf('cmd.php?cmd=login_form&server_id=%s',$ldapserver->server_id)); $save_auth_type = $ldapserver->auth_type; if ($anon_bind) { if (DEBUG_ENABLED) - debug_log('Anonymous Login was posted [%s].',64,$anon_bind); + debug_log('Anonymous Login was posted [%s].',64,__FILE__,__LINE__,__METHOD__,$anon_bind); - $dn = null; - $pass = null; + $login['dn'] = null; + $login['pass'] = null; /* Checks if the login_attr option is enabled for this host, which allows users to login with a simple username like 'jdoe' rather @@ -45,10 +44,10 @@ if ($anon_bind) { # Is this a login string (printf-style) if ($ldapserver->isLoginStringEnabled()) { - $dn = str_replace('',$uid,$ldapserver->getLoginString()); + $login['dn'] = str_replace('',$ldapserver->getLoginAttr(),$ldapserver->getLoginString()); if (DEBUG_ENABLED) - debug_log('LoginStringDN: [%s]',64,$dn); + debug_log('LoginStringDN: [%s]',64,__FILE__,__LINE__,__METHOD__,$login['dn']); } else { # This is a standard login_attr @@ -63,36 +62,36 @@ if ($anon_bind) { $ldapserver->connect(true,'anonymous'); if (! empty($ldapserver->login_class)) - $filter = sprintf('(&(objectClass=%s)(%s=%s))',$ldapserver->login_class,$ldapserver->login_attr,$uid); + $filter = sprintf('(&(objectClass=%s)(%s=%s))',$ldapserver->login_class,$ldapserver->getLoginAttr(),$login['val']); else - $filter = sprintf('%s=%s',$ldapserver->login_attr,$uid); + $filter = sprintf('%s=%s',$ldapserver->getLoginAttr(),$login['val']); # Got through each of the BASE DNs and test the login. foreach ($ldapserver->getBaseDN() as $base_dn) { if (DEBUG_ENABLED) - debug_log('Searching LDAP with base [%s]',64,$base_dn); + debug_log('Searching LDAP with base [%s]',64,__FILE__,__LINE__,__METHOD__,$base_dn); $result = $ldapserver->search(null,$base_dn,$filter,array('dn')); $result = array_pop($result); - $dn = $result['dn']; + $login['dn'] = $result['dn']; - if ($dn) { + if ($login['dn']) { if (DEBUG_ENABLED) - debug_log('Got DN [%s] for user ID [%s]',64,$dn,$uid); + debug_log('Got DN [%s] for user ID [%s]',64,__FILE__,__LINE__,__METHOD__,$login['dn'],$login['val']); break; } } # If we got here then we werent able to find a DN for the login filter. - if (! $dn) + if (! $login['dn']) if ($ldapserver->login_fallback_dn) - $dn = $uid; + $login['dn'] = $login['val']; else system_message(array( 'title'=>_('Authenticate to server'), 'body'=>_('Bad username or password. Please try again.'), 'type'=>'error'), - 'cmd.php?cmd=login_form'); + sprintf('cmd.php?cmd=login_form&server_id=%s',$ldapserver->server_id)); # Restore the original auth_type $ldapserver->auth_type = $save_auth_type; @@ -101,32 +100,32 @@ if ($anon_bind) { # We fake a 'config' server auth_type to omit duplicated code if (DEBUG_ENABLED) - debug_log('Setting login type to CONFIG with DN [%s]',64,$dn); + debug_log('Setting login type to CONFIG with DN [%s]',64,__FILE__,__LINE__,__METHOD__,$login['dn']); $save_auth_type = $ldapserver->auth_type; $ldapserver->auth_type = 'config'; -$ldapserver->login_dn = $dn; -$ldapserver->login_pass = $pass; +$ldapserver->login_dn = $login['dn']; +$ldapserver->login_pass = $login['pass']; # Verify that dn is allowed to login -if (! $ldapserver->userIsAllowedLogin($dn)) +if (! $ldapserver->userIsAllowedLogin($login['dn'])) system_message(array( 'title'=>_('Authenticate to server'), 'body'=>_('Sorry, you are not allowed to use phpLDAPadmin with this LDAP server.'), 'type'=>'error'), - 'cmd.php?cmd=login_form'); + sprintf('cmd.php?cmd=login_form&server_id=%s',$ldapserver->server_id)); if (DEBUG_ENABLED) - debug_log('User is not prohibited from logging in - now bind with DN [%s]',64,$dn); + debug_log('User is not prohibited from logging in - now bind with DN [%s]',64,__FILE__,__LINE__,__METHOD__,$login['dn']); # Verify that the login is good -if (is_null($dn) && is_null($pass)) +if (is_null($login['dn']) && is_null($login['pass'])) $ds = $ldapserver->connect(false,'anonymous',true); else $ds = $ldapserver->connect(false,'user',true); if (DEBUG_ENABLED) - debug_log('Connection returned [%s]',64,$ds); + debug_log('Connection returned [%s]',64,__FILE__,__LINE__,__METHOD__,$ds); if (! is_resource($ds)) { if ($anon_bind) @@ -134,24 +133,24 @@ if (! is_resource($ds)) { 'title'=>_('Authenticate to server'), 'body'=>_('Could not bind anonymously to server.'), 'type'=>'error'), - 'cmd.php?cmd=login_form'); + sprintf('cmd.php?cmd=login_form&server_id=%s',$ldapserver->server_id)); else system_message(array( 'title'=>_('Authenticate to server'), 'body'=>_('Bad username or password. Please try again.'), 'type'=>'error'), - 'cmd.php?cmd=login_form'); + sprintf('cmd.php?cmd=login_form&server_id=%s',$ldapserver->server_id)); - syslog_notice("Authentification FAILED for $dn"); + syslog_notice(sprintf('Authentification FAILED for %s',$login['dn'])); } $ldapserver->auth_type = $save_auth_type; -$ldapserver->setLoginDN($dn,$pass,$anon_bind) or pla_error(_('Could not set cookie.')); +$ldapserver->setLoginDN($login['dn'],$login['pass'],$anon_bind) or pla_error(_('Could not set cookie.')); set_lastactivity($ldapserver); if (! $anon_bind) { - syslog_notice("Authentification successful for $dn"); + syslog_notice(sprintf('Authentification successful for %s',$login['dn'])); } # Since we were successful, clear the cache so that it will be refreshed with the new creditentials. @@ -161,5 +160,5 @@ system_message(array( 'title'=>_('Authenticate to server'), 'body'=>_('Successfully logged into server.').($anon_bind ? sprintf(' (%s)',_('Anonymous Bind')) : ''), 'type'=>'info'), - 'index.php'); + sprintf('index.php?server_id=%s',$ldapserver->server_id)); ?> diff --git a/htdocs/login_form.php b/htdocs/login_form.php index 5315962..f665bba 100644 --- a/htdocs/login_form.php +++ b/htdocs/login_form.php @@ -1,5 +1,5 @@ '; echo ''; -printf('',$ldapserver->isLoginAttrEnabled() ? _('Login Name') : _('Login DN')); +printf('', + $ldapserver->login_attr == 'dn' ? _('Login DN') : $_SESSION[APPCONFIG]->getFriendlyName($ldapserver->login_attr)); printf('', - $ldapserver->isLoginAttrEnabled() ? 'uid' : 'login_dn', - $ldapserver->isLoginAttrEnabled() ? '' : $ldapserver->login_dn); + $ldapserver->login_attr, + $ldapserver->login_attr == 'dn' ? $ldapserver->login_dn : ''); echo ''; printf('',_('Password')); diff --git a/htdocs/logout.php b/htdocs/logout.php index 62557ce..3bb771b 100644 --- a/htdocs/logout.php +++ b/htdocs/logout.php @@ -1,5 +1,5 @@ _('Logout'), 'body'=>('Logged out successfully from server.'), 'type'=>'info'), - 'index.php'); + sprintf('index.php?server_id=%s',$ldapserver->server_id)); ?> diff --git a/htdocs/mass_delete.php b/htdocs/mass_delete.php index f3ed25e..e75f9de 100644 --- a/htdocs/mass_delete.php +++ b/htdocs/mass_delete.php @@ -1,5 +1,5 @@ isReadOnly() ) pla_error(_('Unable to delete, server is in READY-ONLY mode.')); -if (! $_SESSION['plaConfig']->isCommandAvailable('entry_delete', 'mass_delete')) +if (! $_SESSION[APPCONFIG]->isCommandAvailable('entry_delete', 'mass_delete')) pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('delete mass entries'))); $confirmed = isset($_POST['confirmed']) ? true : false; diff --git a/htdocs/modify_member_form.php b/htdocs/modify_member_form.php index 7738a03..22dc66f 100644 --- a/htdocs/modify_member_form.php +++ b/htdocs/modify_member_form.php @@ -1,5 +1,5 @@ getBaseDN() as $base_dn) { # Get all entries that can be added to the group - if (preg_match("/^$attr$/i",$_SESSION['plaConfig']->GetValue('modify_member','posixgroupattr'))) + if (preg_match("/^$attr$/i",$_SESSION[APPCONFIG]->GetValue('modify_member','posixgroupattr'))) $possible_values = array_merge($ldapserver->search(null,$base_dn, - $_SESSION['plaConfig']->GetValue('modify_member','posixfilter'), - array($_SESSION['plaConfig']->GetValue('modify_member','posixattr')))); + $_SESSION[APPCONFIG]->GetValue('modify_member','posixfilter'), + array($_SESSION[APPCONFIG]->GetValue('modify_member','posixattr')))); else $possible_values = array_merge($ldapserver->search(null,$base_dn, - $_SESSION['plaConfig']->GetValue('modify_member','filter'), - array($_SESSION['plaConfig']->GetValue('modify_member','attr')))); + $_SESSION[APPCONFIG]->GetValue('modify_member','filter'), + array($_SESSION[APPCONFIG]->GetValue('modify_member','attr')))); } if ($possible_values) @@ -75,10 +75,10 @@ printf('%s %s %s %s:', _('There are'),$num_current_members,_('members in group'),htmlspecialchars($rdn)); for ($i=0; $iGetValue('modify_member','posixgroupattr'))) - $possible_members[$i] = $possible_values[$i][$_SESSION['plaConfig']->GetValue('modify_member','posixattr')]; + if (preg_match("/^$attr$/i",$_SESSION[APPCONFIG]->GetValue('modify_member','posixgroupattr'))) + $possible_members[$i] = $possible_values[$i][$_SESSION[APPCONFIG]->GetValue('modify_member','posixattr')]; else - $possible_members[$i] = $possible_values[$i][$_SESSION['plaConfig']->GetValue('modify_member','attr')]; + $possible_members[$i] = $possible_values[$i][$_SESSION[APPCONFIG]->GetValue('modify_member','attr')]; } sort($possible_members); diff --git a/htdocs/purge_cache.php b/htdocs/purge_cache.php index 68b866a..15de8e4 100644 --- a/htdocs/purge_cache.php +++ b/htdocs/purge_cache.php @@ -1,5 +1,5 @@ isCommandAvailable('purge')) +if (! $_SESSION[APPCONFIG]->isCommandAvailable('purge')) pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('purge'))); $purge_session_keys = array('cache'); diff --git a/htdocs/rdelete.php b/htdocs/rdelete.php index 5bc5bd0..96595eb 100644 --- a/htdocs/rdelete.php +++ b/htdocs/rdelete.php @@ -1,5 +1,5 @@ isReadOnly()) pla_error(_('You cannot perform updates while server is in read-only mode')); -if (! $_SESSION['plaConfig']->isCommandAvailable('entry_delete', 'simple_delete')) +if (! $_SESSION[APPCONFIG]->isCommandAvailable('entry_delete', 'simple_delete')) pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('delete entry'))); $entry['dn'] = $_POST['dn']; diff --git a/htdocs/refresh.php b/htdocs/refresh.php index ba4dd3a..cab3f82 100644 --- a/htdocs/refresh.php +++ b/htdocs/refresh.php @@ -1,5 +1,5 @@ isCommandAvailable('server_refresh')) +if (! $_SESSION[APPCONFIG]->isCommandAvailable('server_refresh')) pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('refresh server'))); unset($_SESSION['cache'][$ldapserver->server_id]['tree']); diff --git a/htdocs/rename.php b/htdocs/rename.php index c140438..9670fb5 100644 --- a/htdocs/rename.php +++ b/htdocs/rename.php @@ -1,5 +1,5 @@ isReadOnly()) pla_error(_('You cannot perform updates while server is in read-only mode')); -if (! $_SESSION['plaConfig']->isCommandAvailable('entry_rename')) +if (! $_SESSION[APPCONFIG]->isCommandAvailable('entry_rename')) pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('rename entry'))); $dn = ($_POST['dn']); diff --git a/htdocs/schema.php b/htdocs/schema.php index 53110dc..bfb6600 100644 --- a/htdocs/schema.php +++ b/htdocs/schema.php @@ -1,5 +1,5 @@ isCommandAvailable('schema')) +if (! $_SESSION[APPCONFIG]->isCommandAvailable('schema')) pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('view schema'))); $entry['view'] = get_request('view','GET','false','objectClasses'); diff --git a/htdocs/search.php b/htdocs/search.php index 91dd72f..fe9fa37 100644 --- a/htdocs/search.php +++ b/htdocs/search.php @@ -1,5 +1,5 @@ GetValue('search','display')); +$entry['format'] = get_request('format','GET','false',$_SESSION[APPCONFIG]->GetValue('search','display')); $entry['form'] = get_request('form','GET',false,get_request('form','SESSION')); $entry['orderby']['raw'] = get_request('orderby','GET'); @@ -81,9 +81,9 @@ if ($entry['base_dn']['string']) { printf('','../htdocs/'.JSDIR); echo '
'; -$entry['command']['as'] = $_SESSION['plaConfig']->isCommandAvailable('search','advanced_search'); -$entry['command']['ps'] = $_SESSION['plaConfig']->isCommandAvailable('search','predefined_search'); -$entry['command']['ss'] = $_SESSION['plaConfig']->isCommandAvailable('search','simple_search'); +$entry['command']['as'] = $_SESSION[APPCONFIG]->isCommandAvailable('search','advanced_search'); +$entry['command']['ps'] = $_SESSION[APPCONFIG]->isCommandAvailable('search','predefined_search'); +$entry['command']['ss'] = $_SESSION[APPCONFIG]->isCommandAvailable('search','simple_search'); if ($entry['form'] == 'advanced') { if ($entry['command']['as']) @@ -116,15 +116,15 @@ echo '
'; if ($entry['search']) { if ($entry['form'] == 'advanced') { - if (! $_SESSION['plaConfig']->isCommandAvailable('search','advanced_search')) + if (! $_SESSION[APPCONFIG]->isCommandAvailable('search','advanced_search')) pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('advanced search'))); } elseif ($entry['form'] == 'predefined') { - if (! $_SESSION['plaConfig']->isCommandAvailable('search','predefined_search')) + if (! $_SESSION[APPCONFIG]->isCommandAvailable('search','predefined_search')) pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('predefined search'))); } elseif ($entry['form'] == 'simple') { - if (! $_SESSION['plaConfig']->isCommandAvailable('search','simple_search')) + if (! $_SESSION[APPCONFIG]->isCommandAvailable('search','simple_search')) pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('simple search'))); } @@ -132,10 +132,10 @@ if ($entry['search']) { if ($entry['display']) $search_result_attributes = $entry['display']['array']; else - $search_result_attributes = $_SESSION['plaConfig']->GetValue('search','result_attributes'); + $search_result_attributes = $_SESSION[APPCONFIG]->GetValue('search','result_attributes'); } else { - $search_result_attributes = $_SESSION['plaConfig']->GetValue('search','result_attributes'); + $search_result_attributes = $_SESSION[APPCONFIG]->GetValue('search','result_attributes'); } # do we have enough authentication information for the specified server_id @@ -148,7 +148,7 @@ if ($entry['search']) { 'title'=>_('Search'), 'body'=>_('You have not logged into the selected server yet, so you cannot perform searches on it.'), 'type'=>'warn'), - 'cmd.php?cmd=login_form'); + $login_url); } if (is_numeric($entry['predefined'])) { @@ -214,14 +214,14 @@ if ($entry['search']) { 'title'=>_('Unrecognized criteria option: ').htmlspecialchars($entry['criterion']), 'body'=>_('If you want to add your own criteria to the list. Be sure to edit search.php to handle them. Quitting.'), 'type'=>'warn'), - 'cmd.php?cmd=search'); + sprintf('cmd.php?cmd=search&server_id=%s',$ldapserver->server_id)); } } # prevent script from bailing early on a long delete @set_time_limit(0); - $size_limit = $_SESSION['plaConfig']->GetValue('search','size_limit'); + $size_limit = $_SESSION[APPCONFIG]->GetValue('search','size_limit'); # Sanity check if ($size_limit < 1) @@ -233,18 +233,18 @@ if ($entry['search']) { foreach ($base_dns as $base_dn) { if (! $ldapserver->dnExists($base_dn)) { if (DEBUG_ENABLED) - debug_log('BaseDN [%s] skipped as it doesnt exist in [%s].',64, + debug_log('BaseDN [%s] skipped as it doesnt exist in [%s].',64,__FILE__,__LINE__,__METHOD__, $base_dn,$ldapserver->server_id); continue; } else { if (DEBUG_ENABLED) - debug_log('Search with base DN [%s]',64,$base_dn); + debug_log('Search with base DN [%s]',64,__FILE__,__LINE__,__METHOD__,$base_dn); } $results = $ldapserver->search(null,dn_escape($base_dn),$entry['filter']['clean'],$search_result_attributes, - $entry['scope'],$entry['orderby']['array'],$_SESSION['plaConfig']->GetValue('deref','search')); + $entry['scope'],$entry['orderby']['array'],$_SESSION[APPCONFIG]->GetValue('deref','search')); if ((! $results) && $ldapserver->errno()) pla_error(_('Encountered an error while performing search.'),$ldapserver->error(),$ldapserver->errno()); @@ -265,7 +265,7 @@ if ($entry['search']) { printf('
',_('Entries found'),_(':'), number_format($count),$time_elapsed,_('seconds')); - if ($_SESSION['plaConfig']->isCommandAvailable('export')) { + if ($_SESSION[APPCONFIG]->isCommandAvailable('export')) { $href = htmlspecialchars(sprintf('cmd.php?cmd=export_form&server_id=%s&scope=%s&dn=%s&filter=%s&attributes=%s', $ldapserver->server_id,$entry['scope'],$base_dn,rawurlencode($entry['filter']['clean']),rawurlencode(join(', ',$search_result_attributes)))); @@ -290,7 +290,7 @@ if ($entry['search']) { echo ' ]'; - if ($_SESSION['plaConfig']->isCommandAvailable('schema')) { + if ($_SESSION[APPCONFIG]->isCommandAvailable('schema')) { echo '
'; printf('%s%s %s',_('Base DN'),_(':'),htmlspecialchars($base_dn)); diff --git a/htdocs/server_info.php b/htdocs/server_info.php index ee71759..bdfc702 100644 --- a/htdocs/server_info.php +++ b/htdocs/server_info.php @@ -1,5 +1,5 @@ isCommandAvailable('server_info')) +if (! $_SESSION[APPCONFIG]->isCommandAvailable('server_info')) pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('view server informations'))); # The attributes we'll examine when searching the LDAP server's RootDSE diff --git a/htdocs/show_cache.php b/htdocs/show_cache.php index 1918890..302efa9 100644 --- a/htdocs/show_cache.php +++ b/htdocs/show_cache.php @@ -1,5 +1,5 @@ GetValue('appearance','hide_debug_info')) { +if (! $_SESSION[APPCONFIG]->GetValue('appearance','hide_debug_info')) { echo '
    '; foreach (array_keys($_SESSION) as $key) { if (($key == 'cache') && is_array($_SESSION[$key])) diff --git a/htdocs/template_engine.php b/htdocs/template_engine.php index 92e60c5..1b8fb38 100644 --- a/htdocs/template_engine.php +++ b/htdocs/template_engine.php @@ -1,5 +1,5 @@ GetValue('appearance', 'entry_reader').'($ldapserver);'); + eval('$reader = new '.$_SESSION[APPCONFIG]->GetValue('appearance', 'entry_reader').'($ldapserver);'); $entry['dn']['tree']->accept($reader); - eval('$writer = new '.$_SESSION['plaConfig']->GetValue('appearance', 'entry_writer').'($ldapserver);'); + eval('$writer = new '.$_SESSION[APPCONFIG]->GetValue('appearance', 'entry_writer').'($ldapserver);'); $entry['dn']['tree']->accept($writer); } } @@ -54,16 +54,16 @@ if ($entry['dn']['string']) { pla_error(_('You cannot perform updates while server is in read-only mode')); # Create a new empty entry - $entryfactoryclass = $_SESSION['plaConfig']->GetValue('appearance','entry_factory'); + $entryfactoryclass = $_SESSION[APPCONFIG]->GetValue('appearance','entry_factory'); eval('$entry_factory = new '.$entryfactoryclass.'();'); $entry['dn']['tree'] = $entry_factory->newCreatingEntry(''); # Init the entry with incoming data - eval('$reader = new '.$_SESSION['plaConfig']->GetValue('appearance', 'entry_reader').'($ldapserver);'); + eval('$reader = new '.$_SESSION[APPCONFIG]->GetValue('appearance', 'entry_reader').'($ldapserver);'); $entry['dn']['tree']->accept($reader); # Display the creating entry - eval('$writer = new '.$_SESSION['plaConfig']->GetValue('appearance', 'entry_writer').'($ldapserver);'); + eval('$writer = new '.$_SESSION[APPCONFIG]->GetValue('appearance', 'entry_writer').'($ldapserver);'); $entry['dn']['tree']->accept($writer); } ?> diff --git a/htdocs/update.php b/htdocs/update.php index 3c522f9..fe31f55 100644 --- a/htdocs/update.php +++ b/htdocs/update.php @@ -1,5 +1,5 @@ $val) { } elseif ($val == '') { $entry['update'][$attr] = array(); - if (! $_SESSION['plaConfig']->isCommandAvailable('attribute_delete')) + if (! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_delete')) pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('delete attribute'))); } else { # Skip change $entry['update'][$attr] = $val; - if (! $_SESSION['plaConfig']->isCommandAvailable('attribute_add_value') - && ! $_SESSION['plaConfig']->isCommandAvailable('attribute_delete_value')) + if (! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_add_value') + && ! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_delete_value')) pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('modify attribute values'))); } @@ -75,8 +75,8 @@ foreach ($entry['update'] as $attr => $val) { foreach ($val as $i => $v) $entry['update'][$attr][$i] = $v; - if (! $_SESSION['plaConfig']->isCommandAvailable('attribute_add_value') - && ! $_SESSION['plaConfig']->isCommandAvailable('attribute_delete_value')) + if (! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_add_value') + && ! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_delete_value')) pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('modify attribute values'))); } } diff --git a/htdocs/update_confirm.php b/htdocs/update_confirm.php index 891e6f0..99476aa 100644 --- a/htdocs/update_confirm.php +++ b/htdocs/update_confirm.php @@ -1,5 +1,5 @@ getAttributes() as $old_attr) { /* new values */ /***************/ -eval('$reader = new '.$_SESSION['plaConfig']->GetValue('appearance','entry_reader').'($ldapserver);'); +eval('$reader = new '.$_SESSION[APPCONFIG]->GetValue('appearance','entry_reader').'($ldapserver);'); $entry['ldap']->accept($reader); $entry['values']['new'] = array(); @@ -171,7 +171,7 @@ if (isset($entry['values']['new']['objectClass'])) { /* update array */ /****************/ -eval('$writer = new '.$_SESSION['plaConfig']->GetValue('appearance','entry_writer').'($ldapserver);'); +eval('$writer = new '.$_SESSION[APPCONFIG]->GetValue('appearance','entry_writer').'($ldapserver);'); $writer->draw('Title',$entry['ldap']); $writer->draw('Subtitle',$entry['ldap']); @@ -204,18 +204,12 @@ if (count($entry['values']['new']) > 0) { echo "\n\n"; $counter = 0; - $friendly_attrs = $_SESSION['plaConfig']->friendly_attrs; foreach ($entry['values']['new'] as $attr => $new_val) { $counter++; printf('
',$counter%2 ? 'even' : 'odd'); echo ''; echo ''; } diff --git a/htdocs/view_jpeg_photo.php b/htdocs/view_jpeg_photo.php index acdb826..ed9313d 100644 --- a/htdocs/view_jpeg_photo.php +++ b/htdocs/view_jpeg_photo.php @@ -1,5 +1,5 @@ GetValue('jpeg','tmpdir'),$file['name']); +$file['name'] = sprintf('%s/%s',$_SESSION[APPCONFIG]->GetValue('jpeg','tmpdir'),$file['name']); if (! file_exists($file['name'])) pla_error(sprintf('%s%s %s',_('No such file'),_(':'),htmlspecialchars($file['name']))); diff --git a/htdocs/welcome.php b/htdocs/welcome.php index 7282000..fb7aca2 100644 --- a/htdocs/welcome.php +++ b/htdocs/welcome.php @@ -1,38 +1,36 @@ '; echo '

'; - -printf('%s', - _('phpLDAPadmin logo'), - _('phpLDAPadmin logo')); - +printf('%s',_('phpLDAPadmin logo'),_('phpLDAPadmin logo')); echo '

'; echo _('Use the menu to the left to navigate'); echo '

'; $links = ''; -if ($_SESSION['plaConfig']->isCommandAvailable('external_links')) { - if ($_SESSION['plaConfig']->isCommandAvailable('external_links', 'credits')) { +if ($_SESSION[APPCONFIG]->isCommandAvailable('external_links')) { + if ($_SESSION[APPCONFIG]->isCommandAvailable('external_links', 'credits')) { $links .= sprintf('%s',get_href('credits'),_('Credits')); } - if ($_SESSION['plaConfig']->isCommandAvailable('external_links', 'help')) { + if ($_SESSION[APPCONFIG]->isCommandAvailable('external_links', 'help')) { if ($links) $links .= ' | '; $links .= sprintf('%s',get_href('documentation'),_('Documentation')); } - if ($_SESSION['plaConfig']->isCommandAvailable('external_links', 'donation')) { + if ($_SESSION[APPCONFIG]->isCommandAvailable('external_links', 'donation')) { if ($links) $links .= ' | '; $links .= sprintf('%s',get_href('donate'),_('Donate')); } diff --git a/lib/Attribute.php b/lib/Attribute.php index 6907e1d..016c9fd 100644 --- a/lib/Attribute.php +++ b/lib/Attribute.php @@ -1,5 +1,5 @@ friendly_attrs; - $name = real_attr_name($this->name); - - if ($this->friendly_name) { + if ($this->friendly_name) return $this->friendly_name; - } elseif (isset($friendly_attrs[$name])) { - return $friendly_attrs[$name]; - } elseif (isset($friendly_attrs[strtolower($name)])) { - return $friendly_attrs[strtolower($name)]; - } else { - return $name; - } + else + return $_SESSION[APPCONFIG]->getFriendlyName(real_attr_name($this->name)); } public function setDescription($description) { diff --git a/lib/AttributeFactory.php b/lib/AttributeFactory.php index 8498fb0..1e79ecc 100644 --- a/lib/AttributeFactory.php +++ b/lib/AttributeFactory.php @@ -1,5 +1,5 @@ newSambaPasswordAttribute($name,$values); - } elseif (in_array_ignore_case($name,array_keys($_SESSION['plaConfig']->GetValue('appearance','date_attrs')))) { + } elseif (in_array_ignore_case($name,array_keys($_SESSION[APPCONFIG]->GetValue('appearance','date_attrs')))) { return $this->newDateAttribute($name,$values); } elseif (in_array(strtolower($name),array('shadowlastchange','shadowmin', diff --git a/lib/DefaultCreatingEntry.php b/lib/DefaultCreatingEntry.php index a318a48..7ea1b7d 100644 --- a/lib/DefaultCreatingEntry.php +++ b/lib/DefaultCreatingEntry.php @@ -1,5 +1,5 @@ getDn()); + if (DEBUG_ENABLED) + debug_log('Entered with () for dn (%s)',1,__FILE__,__LINE__,__METHOD__,$this->getDn()); if (! $attrs) { $attrs = array(); - $attributefactoryclass = $_SESSION['plaConfig']->GetValue('appearance','attribute_factory'); + $attributefactoryclass = $_SESSION[APPCONFIG]->GetValue('appearance','attribute_factory'); eval('$attribute_factory = new '.$attributefactoryclass.'();'); if ($this->objectClasses) { diff --git a/lib/DefaultEditingEntry.php b/lib/DefaultEditingEntry.php index b0e8261..cfca77a 100644 --- a/lib/DefaultEditingEntry.php +++ b/lib/DefaultEditingEntry.php @@ -1,5 +1,5 @@ getDn(); - if (DEBUG_ENABLED) debug_log('%s[%s]::getAttributes()',1,get_class($this),$dn); + if (DEBUG_ENABLED) + debug_log('Entered with () for dn (%s)',1,__FILE__,__LINE__,__METHOD__,$dn); if (! isset($attrs[$dn])) { $attrs[$dn] = array(); - $attributefactoryclass = $_SESSION['plaConfig']->GetValue('appearance','attribute_factory'); + $attributefactoryclass = $_SESSION[APPCONFIG]->GetValue('appearance','attribute_factory'); eval('$attribute_factory = new '.$attributefactoryclass.'();'); $int_attrs_vals = $ldapserver->getDNSysAttrs($this->getDn()); if (!$int_attrs_vals) $int_attrs_vals = array(); elseif (!is_array($int_attrs_vals)) $int_attrs_vals = array($int_attrs_vals); - $attrs_vals = $ldapserver->getDNAttrs($this->getDn(),false,$_SESSION['plaConfig']->GetValue('deref','view')); + $attrs_vals = $ldapserver->getDNAttrs($this->getDn(),false,$_SESSION[APPCONFIG]->GetValue('deref','view')); if (! $attrs_vals) $attrs_vals = array(); elseif (! is_array($attrs_vals)) $attrs_vals = array($attrs_vals); diff --git a/lib/Entry.php b/lib/Entry.php index 892d1ce..660e210 100644 --- a/lib/Entry.php +++ b/lib/Entry.php @@ -1,5 +1,5 @@ server_id : -1); - $ldap['child_limit'] = $nolimit ? 0 : $_SESSION['plaConfig']->GetValue('search','size_limit'); - $ldap['filter'] = $_SESSION['plaConfig']->GetValue('appearance','tree_filter'); - $ldap['deref'] = $_SESSION['plaConfig']->GetValue('deref','view'); + $ldap['child_limit'] = $nolimit ? 0 : $_SESSION[APPCONFIG]->GetValue('search','size_limit'); + $ldap['filter'] = $_SESSION[APPCONFIG]->GetValue('appearance','tree_filter'); + $ldap['deref'] = $_SESSION[APPCONFIG]->GetValue('deref','view'); $ldap['children'] = $ldapserver->getContainerContents($this->getDn(),$ldap['child_limit'],$ldap['filter'],$ldap['deref']); if (DEBUG_ENABLED) diff --git a/lib/EntryReader.php b/lib/EntryReader.php index de3e649..be2f398 100644 --- a/lib/EntryReader.php +++ b/lib/EntryReader.php @@ -1,5 +1,5 @@ getDn()); + if (DEBUG_ENABLED) + debug_log('Enter with (%s) for dn (%s)',1,__FILE__,__LINE__,__METHOD__,$entry,$entry->getDn()); } public function visitEntryEnd($entry) { - if (DEBUG_ENABLED) debug_log('%s::visitEntryEnd(%s)',1,get_class($this),$entry->getDn()); + if (DEBUG_ENABLED) + debug_log('Enter with (%s) for dn (%s)',1,__FILE__,__LINE__,__METHOD__,$entry,$entry->getDn()); } /**************************/ @@ -37,14 +39,16 @@ class EntryReader extends Visitor { /**************************/ public function visitDefaultEditingEntryStart($entry) { - if (DEBUG_ENABLED) debug_log('%s::visitDefaultEditingEntryStart()',1,get_class($this)); + if (DEBUG_ENABLED) + debug_log('Enter with (%s) for dn (%s)',1,__FILE__,__LINE__,__METHOD__,$entry,$entry->getDn()); $this->context = ENTRY_READER_EDITING_CONTEXT; $this->visit('Entry::Start', $entry); } public function visitTemplateEditingEntryStart($entry) { - if (DEBUG_ENABLED) debug_log('%s::visitTemplateEditingEntryStart()',1,get_class($this)); + if (DEBUG_ENABLED) + debug_log('Enter with (%s) for dn (%s)',1,__FILE__,__LINE__,__METHOD__,$entry,$entry->getDn()); $this->visit('DefaultEditingEntry::Start', $entry); @@ -62,7 +66,8 @@ class EntryReader extends Visitor { /**************************/ public function visitDefaultCreatingEntryStart($entry) { - if (DEBUG_ENABLED) debug_log('%s::visitDefaultCreatingEntryStart()',1,get_class($this)); + if (DEBUG_ENABLED) + debug_log('Enter with (%s) for dn (%s)',1,__FILE__,__LINE__,__METHOD__,$entry,$entry->getDn()); $this->context = ENTRY_READER_CREATION_CONTEXT; $this->visit('Entry::Start', $entry); @@ -81,7 +86,8 @@ class EntryReader extends Visitor { } public function visitTemplateCreatingEntryStart($entry) { - if (DEBUG_ENABLED) debug_log('%s::visitTemplateCreatingEntryStart()',1,get_class($this)); + if (DEBUG_ENABLED) + debug_log('Enter with (%s) for dn (%s)',1,__FILE__,__LINE__,__METHOD__,$entry,$entry->getDn()); $this->visit('DefaultCreatingEntry::Start', $entry); @@ -99,7 +105,8 @@ class EntryReader extends Visitor { /**************************/ public function visitAttribute($attribute) { - if (DEBUG_ENABLED) debug_log('%s::visitAttribute(%s)',1,get_class($this),$attribute->getName()); + if (DEBUG_ENABLED) + debug_log('Enter with (%s) for attribute (%s)',1,__FILE__,__LINE__,__METHOD__,$attribute,$attribute->getName()); $name = $attribute->getName(); // @todo editing objectclasses diff --git a/lib/EntryWriter1.php b/lib/EntryWriter1.php index f02618a..813263b 100644 --- a/lib/EntryWriter1.php +++ b/lib/EntryWriter1.php @@ -1,5 +1,5 @@ '; echo 'var defaults = new Array();var default_date_format = "'; - echo $_SESSION['plaConfig']->GetValue('appearance', 'date'); + echo $_SESSION[APPCONFIG]->GetValue('appearance', 'date'); echo '";'; } @@ -352,7 +352,7 @@ class EntryWriter1 extends EntryWriter { echo ''; echo ''; - if ($_SESSION['plaConfig']->GetValue('appearance', 'show_hints')) { + if ($_SESSION[APPCONFIG]->GetValue('appearance', 'show_hints')) { echo ' Hint'; echo _('Hint: You must choose exactly one structural objectClass (shown in bold above)'); echo '
'; @@ -587,7 +587,7 @@ class EntryWriter1 extends EntryWriter { } protected function getDefaultEditingEntryMenuItem($entry, $i) { - $config = $_SESSION['plaConfig']; + $config = $_SESSION[APPCONFIG]; switch ($i) { case IdEntryRefreshMenuItem : @@ -791,7 +791,7 @@ class EntryWriter1 extends EntryWriter { } protected function getDefaultEditingEntryDeleteAttributeMessage($entry) { - if ($_SESSION['plaConfig']->isCommandAvailable('attribute_delete_value')) + if ($_SESSION[APPCONFIG]->isCommandAvailable('attribute_delete_value')) return sprintf($this->hint_layout,_('Hint: To delete an attribute, empty the text field and click save.')); else return ''; @@ -1464,7 +1464,7 @@ class EntryWriter1 extends EntryWriter { echo ''; # Setup the $attr_note, which will be displayed to the right of the attr name (if any) - if ($_SESSION['plaConfig']->GetValue('appearance', 'show_attribute_notes')) { + if ($_SESSION[APPCONFIG]->GetValue('appearance', 'show_attribute_notes')) { $this->draw('Notes', $attribute); } @@ -1547,7 +1547,7 @@ class EntryWriter1 extends EntryWriter { switch ($i) { case IdAttributeAddValueMenuItem : if ($attribute->isVisible() && !$attribute->isReadOnly() - && !$attribute->isRdn() && $_SESSION['plaConfig']->isCommandAvailable('attribute_add_value')) { + && !$attribute->isRdn() && $_SESSION[APPCONFIG]->isCommandAvailable('attribute_add_value')) { if ($attribute->getMaxValueCount() < 0 || $attribute->getValueCount() < $attribute->getMaxValueCount()) { return $this->get('AddValueMenuItem', $attribute); } @@ -1555,10 +1555,10 @@ class EntryWriter1 extends EntryWriter { return ''; case IdAttributeModifyMemberMenuItem : - if (in_array($attribute->getName(), $_SESSION['plaConfig']->GetValue('modify_member','groupattr'))) { + if (in_array($attribute->getName(), $_SESSION[APPCONFIG]->GetValue('modify_member','groupattr'))) { if ($attribute->isVisible() && !$attribute->isReadOnly() && !$attribute->isRdn() - && ($_SESSION['plaConfig']->isCommandAvailable('attribute_add_value') - || $_SESSION['plaConfig']->isCommandAvailable('attribute_delete_value'))) { + && ($_SESSION[APPCONFIG]->isCommandAvailable('attribute_add_value') + || $_SESSION[APPCONFIG]->isCommandAvailable('attribute_delete_value'))) { return $this->get('ModifyMemberMenuItem', $attribute); } } @@ -1566,7 +1566,7 @@ class EntryWriter1 extends EntryWriter { case IdAttributeRenameMenuItem : if ($attribute->isVisible() && $attribute->isRdn() && !$attribute->isReadOnly() - && $_SESSION['plaConfig']->isCommandAvailable('entry_rename')) { + && $_SESSION[APPCONFIG]->isCommandAvailable('entry_rename')) { return $this->get('RenameMenuItem', $attribute); } return ''; @@ -1742,8 +1742,8 @@ class EntryWriter1 extends EntryWriter { $opts = $arr1; $default = (count($vals) > 0 ? $vals[0] : ''); - if (!is_string($default)) $default = ''; - if (!is_null($attribute->getValue($i)) || (strlen($default) <= 0)) { + if (!is_scalar($default)) $default = ''; + if (!is_null($attribute->getValue($i)) && (strlen($default) <= 0)) { $default = $this->get('DefaultValueHelper', $attribute, $i); } @@ -1876,7 +1876,7 @@ class EntryWriter1 extends EntryWriter { } protected function drawAttributeName($attribute) { - $config = $_SESSION['plaConfig']; + $config = $_SESSION[APPCONFIG]; $attr_display = $attribute->getFriendlyName(); @@ -1896,7 +1896,7 @@ class EntryWriter1 extends EntryWriter { $friendly_name = $attribute->getFriendlyName(); if ($friendly_name != $attribute->getName()) { - return "getName()) . "\">alias"; + return sprintf('%s',_('Note'),$friendly_name,_('is an alias for'),$attribute->getName(),_('alias')); } else { return ''; } @@ -1989,12 +1989,12 @@ class EntryWriter1 extends EntryWriter { } } - if (! $attribute->isReadOnly() && $_SESSION['plaConfig']->isCommandAvailable('attribute_delete')) { + if (! $attribute->isReadOnly() && $_SESSION[APPCONFIG]->isCommandAvailable('attribute_delete')) { printf(''. 'Trash %s', $attribute->getName(), $attribute->getFriendlyName(), _('delete attribute')); } - } elseif ($attribute->isReadOnly() || ! $_SESSION['plaConfig']->isCommandAvailable('attribute_add_value')) { + } elseif ($attribute->isReadOnly() || ! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_add_value')) { printf('
', _("[no value]")); } else { @@ -2081,9 +2081,9 @@ class EntryWriter1 extends EntryWriter { protected function drawDateAttributeJavascript($attribute) { $this->draw('Attribute::Javascript', $attribute); - $entry['date'] = $_SESSION['plaConfig']->GetValue('appearance','date_attrs'); - $entry['time'] = $_SESSION['plaConfig']->GetValue('appearance','date_attrs_showtime'); - $entry['format'] = $_SESSION['plaConfig']->GetValue('appearance', 'date'); + $entry['date'] = $_SESSION[APPCONFIG]->GetValue('appearance','date_attrs'); + $entry['time'] = $_SESSION[APPCONFIG]->GetValue('appearance','date_attrs_showtime'); + $entry['format'] = $_SESSION[APPCONFIG]->GetValue('appearance', 'date'); if (isset($entry['date'][$attribute->getName()])) $entry['format'] = $entry['date'][$attribute->getName()]; @@ -2202,9 +2202,9 @@ class EntryWriter1 extends EntryWriter { if ($attribute->getEntry() && $attribute->getEntry()->getDn()) { draw_jpeg_photos($this->ldapserver, $attribute->getEntry()->getDn(), $attribute->getName(), ! $attribute->isReadOnly() - && $_SESSION['plaConfig']->isCommandAvailable('attribute_delete')); + && $_SESSION[APPCONFIG]->isCommandAvailable('attribute_delete')); } - } elseif ($attribute->isReadOnly() || ! $_SESSION['plaConfig']->isCommandAvailable('attribute_add_value')) { + } elseif ($attribute->isReadOnly() || ! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_add_value')) { printf('
',_('[no value]')); } else { $i = 0; @@ -2633,7 +2633,7 @@ class EntryWriter1 extends EntryWriter { } protected function drawShadowAttributeShadowDate($attribute, $shadow_date) { - $config = $_SESSION['plaConfig']; + $config = $_SESSION[APPCONFIG]; //$shadow_format_attrs = array_merge($shadow_before_today_attrs,$shadow_after_today_attrs); $shadow_before_today_attrs = arrayLower($attribute->shadow_before_today_attrs); diff --git a/lib/EntryWriter2.php b/lib/EntryWriter2.php index 0a39d80..0ed6e98 100644 --- a/lib/EntryWriter2.php +++ b/lib/EntryWriter2.php @@ -1,5 +1,5 @@ '; - if ($_SESSION['plaConfig']->GetValue('appearance', 'show_attribute_notes')) { + if ($_SESSION[APPCONFIG]->GetValue('appearance', 'show_attribute_notes')) { $this->draw('Notes', $attribute); } @@ -246,7 +246,7 @@ class EntryWriter2 extends EntryWriter1 { } protected function drawAttributeMenu($attribute) { - if ($attribute->getHint() /*&& $_SESSION['plaConfig']->GetValue('appearance', 'show_hints')*/) { + if ($attribute->getHint() /*&& $_SESSION[APPCONFIG]->GetValue('appearance', 'show_hints')*/) { echo 'Hint '.$attribute->getHint().''; } parent::drawAttributeMenu($attribute); diff --git a/lib/HTMLTree.php b/lib/HTMLTree.php index 2bcc34b..b565a2f 100644 --- a/lib/HTMLTree.php +++ b/lib/HTMLTree.php @@ -1,5 +1,5 @@ isCommandAvailable('schema')) return $this->get_schema_menu_item(); + if ($_SESSION[APPCONFIG]->isCommandAvailable('schema')) return $this->get_schema_menu_item(); else return ''; case 1 : - if ($_SESSION['plaConfig']->isCommandAvailable('search')) return $this->get_search_menu_item(); + if ($_SESSION[APPCONFIG]->isCommandAvailable('search')) return $this->get_search_menu_item(); else return ''; case 2 : - if ($_SESSION['plaConfig']->isCommandAvailable('server_refresh')) return $this->get_refresh_menu_item(); + if ($_SESSION[APPCONFIG]->isCommandAvailable('server_refresh')) return $this->get_refresh_menu_item(); else return ''; case 3 : - if ($_SESSION['plaConfig']->isCommandAvailable('server_info')) return $this->get_info_menu_item(); + if ($_SESSION[APPCONFIG]->isCommandAvailable('server_info')) return $this->get_info_menu_item(); else return ''; case 4 : - if (!$ldapserver->isReadOnly() && $_SESSION['plaConfig']->isCommandAvailable('import')) return $this->get_import_menu_item(); + if (!$ldapserver->isReadOnly() && $_SESSION[APPCONFIG]->isCommandAvailable('import')) return $this->get_import_menu_item(); else return ''; case 5 : - if ($_SESSION['plaConfig']->isCommandAvailable('export')) return $this->get_export_menu_item(); + if ($_SESSION[APPCONFIG]->isCommandAvailable('export')) return $this->get_export_menu_item(); else return ''; case 6 : if ($ldapserver->auth_type != 'config') return $this->get_logout_menu_item(); @@ -221,7 +221,7 @@ class HTMLTree extends Tree { protected function get_search_menu_item() { $ldapserver = $this->getLdapServer(); - $href = sprintf('cmd.php?cmd=search&server_id=%s&form=undefined"',$ldapserver->server_id); + $href = sprintf('cmd.php?cmd=search&server_id=%s&form=undefined',$ldapserver->server_id); return sprintf('%s
%s
', _('search'),$ldapserver->name,htmlspecialchars($href),'images/search.png',_('search'),_('search')); diff --git a/lib/TemplateCreatingEntry.php b/lib/TemplateCreatingEntry.php index 2ae7cbe..4d1ed75 100644 --- a/lib/TemplateCreatingEntry.php +++ b/lib/TemplateCreatingEntry.php @@ -1,5 +1,5 @@ GetValue('appearance','attribute_factory'); + $attributefactoryclass = $_SESSION[APPCONFIG]->GetValue('appearance','attribute_factory'); eval('$attribute_factory = new '.$attributefactoryclass.'();'); if ($this->objectClasses) { diff --git a/lib/TemplateEditingEntry.php b/lib/TemplateEditingEntry.php index 8a22829..da6ad0d 100644 --- a/lib/TemplateEditingEntry.php +++ b/lib/TemplateEditingEntry.php @@ -1,5 +1,5 @@ valid) { if (DEBUG_ENABLED) - debug_log('TemplateEditingEntry::readEditingTemplates() : all templates [%s] are valid',1,count($this->templates)); + debug_log('All templates [%s] are valid',1,__FILE__,__LINE__,__METHOD__,count($this->templates)); return; } @@ -46,24 +46,28 @@ class TemplateEditingEntry extends DefaultEditingEntry { foreach ($all_templates as $template_name => $template_attrs) { # don't select hidden templates if (isset($template_attrs['visible']) && (! $template_attrs['visible'])) { - if (DEBUG_ENABLED) debug_log('TemplateEditingEntry::readEditingTemplates() : the template %s is not visible',1,$template_name); + if (DEBUG_ENABLED) + debug_log('The template %s is not visible',1,__FILE__,__LINE__,__METHOD__,$template_name); continue; } # don't select invalid templates if (isset($template_attrs['invalid']) && $template_attrs['invalid']) { - if (DEBUG_ENABLED) debug_log('TemplateEditingEntry::readEditingTemplates() : the template %s is invalid [%s]',1,$template_name,isset($template_attrs['invalid_reason']) ? $template_attrs['invalid_reason'] : ''); + if (DEBUG_ENABLED) + debug_log('The template %s is invalid [%s]',1,__FILE__,__LINE__,__METHOD__,$template_name,isset($template_attrs['invalid_reason']) ? $template_attrs['invalid_reason'] : ''); $this->valid = false; continue; } # check the template filter if (isset($template_attrs['regexp'])) { if (! @preg_match('/'.$template_attrs['regexp'].'/i',$this->getDn())) { - if (DEBUG_ENABLED) debug_log('TemplateEditingEntry::readEditingTemplates() : the entry dn doesn\'t match the template %s regexp',1,$template_name); + if (DEBUG_ENABLED) + debug_log('The entry dn doesn\'t match the template %s regexp',1,__FILE__,__LINE__,__METHOD__,$template_name); continue; } } # finally add the template to the list - if (DEBUG_ENABLED) debug_log('TemplateEditingEntry::readEditingTemplates() : the template %s is available for the entry',1,$template_name); + if (DEBUG_ENABLED) + debug_log('The template %s is available for the entry',1,__FILE__,__LINE__,__METHOD__,$template_name); $this->templates[$template_name] = $template_attrs; } } @@ -87,7 +91,8 @@ class TemplateEditingEntry extends DefaultEditingEntry { static $attrs = array(); $dn = $this->getDn(); - if (DEBUG_ENABLED) debug_log('%s[%s]::getAttributes()',1,get_class($this),$dn); + if (DEBUG_ENABLED) + debug_log('Entered with () for dn [%s]',1,__FILE__,__LINE__,__METHOD__,$dn); if (!$this->selected_template) { return parent::getAttributes(); @@ -95,14 +100,14 @@ class TemplateEditingEntry extends DefaultEditingEntry { $attrs[$dn] = array(); $tmpl[$dn] = $this->selected_template; - $attributefactoryclass = $_SESSION['plaConfig']->GetValue('appearance','attribute_factory'); + $attributefactoryclass = $_SESSION[APPCONFIG]->GetValue('appearance','attribute_factory'); eval('$attribute_factory = new '.$attributefactoryclass.'();'); $int_attrs_vals = $ldapserver->getDNSysAttrs($this->getDn()); if (! $int_attrs_vals) $attrs_vals = array(); elseif (! is_array($int_attrs_vals)) $int_attrs_vals = array($attrs_vals); - $attrs_vals = $ldapserver->getDNAttrs($this->getDn(),false,$_SESSION['plaConfig']->GetValue('deref','view')); + $attrs_vals = $ldapserver->getDNAttrs($this->getDn(),false,$_SESSION[APPCONFIG]->GetValue('deref','view')); if (! $attrs_vals) $attrs_vals = array(); elseif (! is_array($attrs_vals)) $attrs_vals = array($attrs_vals); diff --git a/lib/Tree.php b/lib/Tree.php index b71bd1e..d89e607 100644 --- a/lib/Tree.php +++ b/lib/Tree.php @@ -1,5 +1,5 @@ ldapservers->Instance($server_id); + $ldapserver = $_SESSION[APPCONFIG]->ldapservers->Instance($server_id); if (!$ldapserver) return null; - $treeclass = $_SESSION['plaConfig']->GetValue('appearance','tree'); + $treeclass = $_SESSION[APPCONFIG]->GetValue('appearance','tree'); eval('$tree = new '.$treeclass.'($server_id);'); foreach ($ldapserver->getBaseDN() as $baseDn) @@ -45,7 +45,7 @@ abstract class Tree { } public function getLdapServer() { - return $_SESSION['plaConfig']->ldapservers->Instance($this->server_id); + return $_SESSION[APPCONFIG]->ldapservers->Instance($this->server_id); } /** @@ -71,7 +71,7 @@ abstract class Tree { * children array of its parent * * The added entry is created using the factory class defined - * in $_SESSION['plaConfig']->custom->appearance['entry_factory'] + * in $_SESSION[APPCONFIG]->custom->appearance['entry_factory'] * * @param $dn the dn of the entry to create */ @@ -79,7 +79,7 @@ abstract class Tree { if (DEBUG_ENABLED) debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$dn); - $ldapserver = $_SESSION['plaConfig']->ldapservers->Instance($this->server_id); + $ldapserver = $_SESSION[APPCONFIG]->ldapservers->Instance($this->server_id); # We need to convert the DN to lower case, to avoid any case problems and strip any unnessary spaces after commas. $dnlower = $this->indexDN($dn); @@ -121,7 +121,7 @@ abstract class Tree { if (isset($this->misses[$dnlower])) unset($this->misses[$dnlower]); - $entryfactoryclass = $_SESSION['plaConfig']->GetValue('appearance','entry_factory'); + $entryfactoryclass = $_SESSION[APPCONFIG]->GetValue('appearance','entry_factory'); eval('$entry_factory = new '.$entryfactoryclass.'();'); if (DEBUG_ENABLED) debug_log('New ENTRY (%s) for (%s).',64,__FILE__,__LINE__,__METHOD__,$dnlower,$dn); diff --git a/lib/common.php b/lib/common.php index 5dc98a6..6074d0e 100644 --- a/lib/common.php +++ b/lib/common.php @@ -1,23 +1,33 @@ _('Configuration cache stale.'), - 'body'=>_('Your configuration has been automatically refreshed.'), - 'type'=>'info')); - - $config_file = CONFDIR.'config.php'; - check_config($config_file); - - } else { - # Sanity check, specially when upgrading from a previous release. - foreach (array_keys($_SESSION['cache']) as $id) - if (isset($_SESSION['cache'][$id]['tree']['null']) && ! is_object($_SESSION['cache'][$id]['tree']['null'])) - unset($_SESSION['cache'][$id]); - } -} - -# If we came via index.php, then set our $config. -if (! isset($_SESSION['plaConfig']) && isset($config)) - $_SESSION['plaConfig'] = $config; - -# If we get here, and plaConfig is not set, then redirect the user to the index. -if (! isset($_SESSION['plaConfig'])) { - header('Location: index.php'); +# If we get here, and $_SESSION[APPCONFIG] is not set, then redirect the user to the index. +if (! isset($_SESSION[APPCONFIG])) { + if (isset($_REQUEST['server_id'])) + header(sprintf('Location: index.php?server_id=%s',$_REQUEST['server_id'])); + else + header('Location: index.php'); die(); } else { # Check our custom variables. # @todo: Change this so that we dont process a cached session. - $_SESSION['plaConfig']->CheckCustom(); + $_SESSION[APPCONFIG]->CheckCustom(); } # If we are here, $_SESSION is set - so enabled DEBUGing if it has been configured. -if (($_SESSION['plaConfig']->GetValue('debug','syslog') || $_SESSION['plaConfig']->GetValue('debug','file')) - && $_SESSION['plaConfig']->GetValue('debug','level')) +if (($_SESSION[APPCONFIG]->GetValue('debug','syslog') || $_SESSION[APPCONFIG]->GetValue('debug','file')) + && $_SESSION[APPCONFIG]->GetValue('debug','level')) define('DEBUG_ENABLED',1); else define('DEBUG_ENABLED',0); -# Since DEBUG_ENABLED is set later, as $config may not be set, we'll if (DEBUG_ENABLED) - debug_log('PLA (%s) initialised and starting with (%s).',1,pla_version(),$_REQUEST); + debug_log('Application (%s) initialised and starting with (%s).',1,__FILE__,__LINE__,__METHOD__, + pla_version(),$_REQUEST); # Set our PHP timelimit. -if ($_SESSION['plaConfig']->GetValue('session','timelimit')) - set_time_limit($_SESSION['plaConfig']->GetValue('session','timelimit')); +if ($_SESSION[APPCONFIG]->GetValue('session','timelimit')) + set_time_limit($_SESSION[APPCONFIG]->GetValue('session','timelimit')); # If debug mode is set, increase the time_limit, since we probably need it. -if (DEBUG_ENABLED && $_SESSION['plaConfig']->GetValue('session','timelimit')) - set_time_limit($_SESSION['plaConfig']->GetValue('session','timelimit') * 5); +if (DEBUG_ENABLED && $_SESSION[APPCONFIG]->GetValue('session','timelimit')) + set_time_limit($_SESSION[APPCONFIG]->GetValue('session','timelimit') * 5); -# @todo: Change this so that we dont process a cached session. -$_SESSION['plaConfig']->friendly_attrs = process_friendly_attr_table(); - -/* +/** * Language configuration. Auto or specified? * Shall we attempt to auto-determine the language? */ - -$language = $_SESSION['plaConfig']->GetValue('appearance','language'); +$language = $_SESSION[APPCONFIG]->GetValue('appearance','language'); if ($language == 'auto') { + # Make sure their browser correctly reports language. If not, skip this. if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { @@ -201,11 +189,10 @@ if ($language == 'auto') { $HTTP_LANGS = array_unique($HTTP_LANGS); foreach ($HTTP_LANGS as $HTTP_LANG) { - # Try to grab one after the other the language file - $language_file = LANGDIR.$HTTP_LANG; + $language_dir = LANGDIR.$HTTP_LANG; if ((substr($HTTP_LANG,0,2) == 'en') || - (file_exists($language_file) && is_readable($language_file))) { + (file_exists($language_dir) && is_readable($language_dir))) { # Set language putenv('LANG='.$HTTP_LANG); # e.g. LANG=de_DE @@ -218,16 +205,16 @@ if ($language == 'auto') { break; } } + #todo: Generate an error if language doesnt exist. } } else { # Grab the language file configured in config.php + #todo: Generate an error if language doesnt exist. if ($language != null) { if (strcmp($language,'english') == 0) $language = 'en_GB'; - $language_file = LANGDIR.$language; - # Set language putenv('LANG='.$language); # e.g. LANG=de_DE $language .= '.UTF-8'; @@ -239,7 +226,7 @@ if ($language == 'auto') { } } -/* +/** * Strip slashes from GET, POST, and COOKIE variables if this * PHP install is configured to automatically addslashes() */ @@ -251,34 +238,43 @@ if (get_magic_quotes_gpc() && (! isset($slashes_stripped) || ! $slashes_stripped $slashes_stripped = true; } -if (isset($_REQUEST['server_id'])) { - $ldapserver = $_SESSION['plaConfig']->ldapservers->Instance($_REQUEST['server_id']); -} else { - $ldapserver = $_SESSION['plaConfig']->ldapservers->Instance(null); -} - -# Test to see if we should log out the user due to the timeout. -if ($ldapserver->haveAuthInfo() && $ldapserver->auth_type != 'config') { - /* If time out value has been reached: - - log out user - - put $server_id in array of recently timed out servers */ - if (session_timed_out($ldapserver)) { - $timeout_url = 'cmd.php?cmd=timeout&server_id='.$ldapserver->server_id; - echo ''; - die(); - } -} - -/* - * Update $_SESSION['activity'] - * for timeout and automatic logout feature +/** + * Create our application repository variable. */ -if ($ldapserver->haveAuthInfo()) - set_lastactivity($ldapserver); +if (isset($_REQUEST['server_id'])) { + $ldapserver = $_SESSION[APPCONFIG]->ldapservers->Instance($_REQUEST['server_id']); +} else { + if (isset($_SESSION[APPCONFIG]->ldapservers) && is_object($_SESSION[APPCONFIG]->ldapservers)) + $ldapserver = $_SESSION[APPCONFIG]->ldapservers->Instance(null); +} + +/** + * Look/evaluate our timeout + */ +if (isset($ldapserver) && is_object($ldapserver) && method_exists($ldapserver,'haveAuthInfo')) { + if ($ldapserver->haveAuthInfo() && isset($ldapserver->auth_type) && $ldapserver->auth_type != 'config') { + /** + * If time out value has been reached: + * - log out user + * - put $server_id in array of recently timed out servers + */ + if (function_exists('session_timed_out') && session_timed_out($ldapserver)) { + $app['url_timeout'] = sprintf('cmd.php?cmd=timeout&server_id=%s',$_REQUEST['server_id']); + printf('', + htmlspecialchars($app['url_timeout'])); + die(); + } + } + + # Update $_SESSION['activity'] for timeout and automatic logout feature + if ($ldapserver->haveAuthInfo() && function_exists('set_lastactivity')) + set_lastactivity($ldapserver); +} /** * At this point we have read all our additional function PHP files and our configuration. + * If we are using hooks, run the session_init hook. */ -run_hook('post_session_init',array()); - +if (function_exists('run_hook')) + run_hook('post_session_init',array()); ?> diff --git a/lib/config_default.php b/lib/config_default.php index def3647..0dd673c 100644 --- a/lib/config_default.php +++ b/lib/config_default.php @@ -1,22 +1,35 @@ 'Date format whenever dates are shown', 'default'=>'%A %e %B %Y'); + $this->default->appearance['custom_templates_only'] = array( + 'desc'=>'Only display the custom templates.', + 'default'=>false); + $this->default->appearance['date_attrs'] = array( 'desc'=>'Array of attributes that should show a jscalendar', 'default'=>array('shadowExpire'=>'%es','shadowLastChange'=>'%es')); @@ -556,5 +573,63 @@ class Config { } return false; } + + /** + * Reads the friendly_attrs array as defined in config.php and lower-cases all + * the keys. Will return an empty array if the friendly_attrs array is not defined + * in config.php. This is simply used so we can more easily lookup user-friendly + * attributes configured by the admin. + */ + function getFriendlyAttrs($friendly_attrs) { + if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) + debug_log('Entered with ()',1,__FILE__,__LINE__,__METHOD__); + + # If friendly_attrs is not an array, then set to an empty array. + if (! is_array($friendly_attrs)) + $this->friendly_attrs = array(); + + else + foreach ($friendly_attrs as $old_name => $new_name) + $this->friendly_attrs[strtolower($old_name)] = $new_name; + } + + /** + * This function will return the friendly name of an attribute, if it exists. + * If the friendly name doesnt exist, the attribute name will be returned. + * + * @param attribute + * @return string friendly name|attribute + */ + public function getFriendlyName($attr) { + if ($this->haveFriendlyName($attr)) + return $this->friendly_attrs[strtolower($attr)]; + else + return $attr; + } + + /** + * This function will return true if a friendly name exists for an attribute. + * If the friendly name doesnt exist, it will return false. + * + * @param attribute + * @return boolean true|false + */ + public function haveFriendlyName($attr) { + return isset($this->friendly_attrs[strtolower($attr)]); + + } + + /** + * This function will return the html for a friendly name attribute. + * + * @param attribute + * @return string html for the friendly name. + */ + public function getFriendlyHTML($attr) { + if ($this->haveFriendlyName($attr)) + return sprintf('%s',_('Alias for'),$attr,htmlspecialchars($this->getFriendlyName($attr))); + else + return $attr; + } } ?> diff --git a/lib/export_functions.php b/lib/export_functions.php index b244f0e..1f13cf5 100755 --- a/lib/export_functions.php +++ b/lib/export_functions.php @@ -1,5 +1,5 @@ ldapserver = $_SESSION['plaConfig']->ldapservers->Instance($server_id); + $this->ldapserver = $_SESSION[APPCONFIG]->ldapservers->Instance($server_id); $this->ldapserver->base_dn = $base_dn; $this->ldapserver->query_filter = $query_filter; $this->ldapserver->scope = $scope; @@ -245,7 +245,7 @@ class PlaLdapExporter extends PlaAbstractExporter { # get the data to be exported $this->results = $this->ldap_info->ldapserver->search(null,$this->base_dn,$this->queryFilter,$this->attributes, - $this->scope,true,$_SESSION['plaConfig']->GetValue('deref','export')); + $this->scope,true,$_SESSION[APPCONFIG]->GetValue('deref','export')); # if no result, there is a something wrong if (! $this->results && $this->ldap_info->ldapserver->errno()) diff --git a/lib/functions.php b/lib/functions.php index 84085aa..cccea1d 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -1,8 +1,9 @@ _('Generic Error'), + 'body'=>sprintf('%s: %s [%s]', + __METHOD__,_('Called to load a class that cant be found'),$className), + 'type'=>'error')); } +/** + * Generic Utility Functions + */ + +/** + * Returns the phpLDAPadmin version currently running. The version + * is read from the file named VERSION. + * + * @return string The current version as read from the VERSION file. + */ +function pla_version() { + $version_file = realpath(LIBDIR.'../VERSION'); + if (! file_exists($version_file)) + $return = 'UNKNOWN'; + + else { + $f = fopen($version_file,'r'); + $version = trim(fread($f, filesize($version_file))); + fclose($f); + + # We use cvs_prefix, because CVS will translate this on checkout otherwise. + $cvs_prefix = '\$Name:'; + + $return = preg_replace('/^'.$cvs_prefix.' RELEASE-([0-9_]+)\s*\$$/','$1',$version); + $return = preg_replace('/_/','.',$return); + + # Check if we are a CVS copy. + if (preg_match('/^'.$cvs_prefix.'?\s*\$$/',$return)) + $return = 'CVS'; + + # Check if we are special CVS branch + elseif (preg_match('/^'.$cvs_prefix.'?\s*([a-zA-Z]+)?\s*\$$/',$return,$match)) + $return = $match[1]; + + # If return is still the same as version, then the tag is not one we expect. + elseif ($return == $version) + $return = 'UNKNOWN'; + } + + if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) + debug_log('Entered with (), Returning (%s)',1,__FILE__,__LINE__,__METHOD__,$return); + + return $return; +} + +/** + * This function will convert the browser two character language into the + * default 5 character language, where the country portion should NOT be + * assumed to be upper case characters of the first two characters. + */ +function auto_lang($lang) { + switch ($lang) { + case 'ja': return 'ja_JP'; + case 'cs': return 'cs_CZ'; + default: return sprintf('%s_%s',$lang,strtoupper($lang)); + } +} + +/** + * Makes sure that the config file is properly setup and + * that your install of PHP can handle LDAP stuff. + */ +function check_config($config_file) { + global $config,$ldapservers; + global $queries, $attrs_display_order; + global $hidden_attrs, $hidden_except_dn, $hidden_attrs_ro; + global $read_only_attrs, $read_only_except_dn, $unique_attrs; + + # Read in config_default.php + require_once LIBDIR.'config_default.php'; + + # Make sure their PHP version is current enough + if (strcmp(phpversion(),REQUIRED_PHP_VERSION) < 0) + pla_error(sprintf('phpLDAPadmin requires PHP version %s or greater.
(You are using %s)', + REQUIRED_PHP_VERSION,phpversion())); + + # Make sure this PHP install has all our required extensions + if (! extension_loaded('ldap')) + system_message(array( + 'title'=>_('Missing required extension'), + 'body'=> 'Your install of PHP appears to be missing LDAP support.

Please install LDAP support before using phpLDAPadmin.
(Dont forget to restart your web server afterwards)', + 'type'=>'error')); + + # Make sure that we have php-xml loaded. + if (! function_exists('xml_parser_create')) + system_message(array( + 'title'=>_('Missing required extension'), + 'body'=> 'Your install of PHP appears to be missing XML support.

Please install XML support before using phpLDAPadmin.
(Dont forget to restart your web server afterwards)', + 'type'=>'error')); + + # Make sure their session save path is writable, if they are using a file system session module, that is. + if ( ! strcasecmp('Files',session_module_name() && ! is_writable(realpath(session_save_path())))) + system_message(array( + 'title'=>_('Missing required extension'), + 'body'=> 'Your PHP session configuration is incorrect. Please check the value of session.save_path in your php.ini to ensure that the directory specified there exists and is writable. The current setting of "'.session_save_path().'" is un-writable by the web server.', + 'type'=>'error')); + + $config = new Config; + + /* Check for syntax errors in config.php + As of php 4.3.5, this NO longer catches fatal errors :( */ + + ob_start(); + require $config_file; + $str = ''; + if (ob_get_level()) { + $str = ob_get_contents(); + ob_end_clean(); + } + + if ($str) { + $str = strip_tags($str); + $matches = array(); + preg_match('/(.*):\s+(.*):.*\s+on line (\d+)/',$str,$matches); + + if (isset($matches[1]) && isset($matches[2]) && isset($matches[3])) { + $error_type = $matches[1]; + $error = $matches[2]; + $line_num = $matches[3]; + + $file = file($config_file); + + echo ''."\n"; + echo ''."\n"; + echo "\n"; + + echo ''; + echo ''; + echo 'phpLDAPadmin Config File Error'; + echo ''; + echo ''; + + echo ''; + echo '

Config File ERROR

'; + printf('

%s (%s) on line %s

',$error_type,$error,$line_num); + + echo '
'; + printf('Looks like your config file has an ERROR on line %s.
',$line_num); + echo 'Here is a snippet around that line
'; + echo '
'."\n"; + + echo '
'; + + for ($i = $line_num-9; $i<$line_num+5; $i++) { + if ($i+1 == $line_num) + echo '
'; + + if ($i < 0) + continue; + + printf('%s: %s
',$i+1,htmlspecialchars($file[$i])); + if ($i+1 == $line_num) + echo '
'; + } + + echo '
'; + echo '
'; + echo 'Hint: Sometimes these errors are caused by lines preceding the line reported.'; + echo '
'; + echo ''; + echo ''; + + return false; + } + } + + # Process our friendly attributes. + if (isset($friendly_attrs)) + $config->getFriendlyAttrs($friendly_attrs); + + # Check for server definitions. + if (! isset($ldapservers) || count($ldapservers->GetServerList()) == 0) + system_message(array( + 'title'=>_('Missing required configuration'), + 'body'=> 'Your config.php is missing Server Definitions. Please see the sample file config/config.php.example.', + 'type'=>'error')); + + $config->ldapservers = $ldapservers; + + if (isset($queries)) $config->queries = $queries; + if (isset($attrs_display_order)) $config->attrs_display_order = $attrs_display_order; + if (isset($hidden_attrs)) $config->hidden_attrs = $hidden_attrs; + if (isset($hidden_except_dn)) $config->hidden_except_dn = $hidden_except_dn; + if (isset($hidden_attrs_ro)) $config->hidden_attrs_ro = $hidden_attrs_ro; + if (isset($read_only_attrs)) $config->read_only_attrs = $read_only_attrs; + if (isset($read_only_except_dn)) $config->read_only_except_dn = $read_only_except_dn; + if (isset($unique_attrs)) $config->unique_attrs = $unique_attrs; + + # Check the memory limit parameter. + if (ini_get('memory_limit') < $config->GetValue('session','memorylimit')) + system_message(array( + 'title'=>_('Memory Limit low.'), + 'body'=> sprintf('Your php memory limit is low - currently %s',ini_get('memory_limit'),false), + 'type'=>'error')); + + # if $_SESSION['sysmsg'] is set, then there were problems. + if (isset($_SESSION['sysmsg'])) + return false; + + return true; +} + +/** + * Commands available in the control_panel of the page + * + * @return array + */ +function cmd_control_pane() { + return array( + 'home'=>array('link'=>sprintf('%s
%s
',_('Home'),_('Home'),_('Home'))), + 'purge'=>array('link'=>sprintf('%s
%s
', + _('Purge caches'),_('Purge all cached data in phpLDAPadmin, including server schemas.'),_('Purge caches'))), + 'external_links:feature'=>array('link'=>sprintf('%s
%s
', + get_href('add_rfe'),_('Request feature'),_('light'),_('Request feature'))), + 'external_links:bug'=>array('link'=>sprintf('%s
%s
', + get_href('add_bug'),_('Report a bug'),_('bug'),_('Report a bug'))), + 'external_links:donation'=>array('link'=>sprintf('%s
%s
', + get_href('donate'),_('Donate'),_('Donate'),_('Donate'))), + 'appearance:hide_debug_info'=>array('link'=>sprintf('%s
%s
', + _('Show Cache'),_('Show Cache'),_('Show Cache'))), + 'external_links:help'=>array('link'=>sprintf('%s
%s
', + get_href('documentation'),_('Help'),_('Help'),_('Help'))) + ); +} + +/** + * This function dumps the $variable for debugging purposes + * @param string|array Variable to dump + * @param boolean Whether to stop execution or not. + */ +function debug_dump($variable,$die=false,$onlydebugaddr=false) { + if ($onlydebugaddr && + $_SESSION[APPCONFIG]->GetValue('debug','addr') && + $_SERVER['HTTP_X_FORWARDED_FOR'] != $_SESSION[APPCONFIG]->GetValue('debug','addr') && + $_SERVER['REMOTE_ADDR'] != $_SESSION[APPCONFIG]->GetValue('debug','addr')) + return; + + print '
';
+	print_r($variable);
+	print '
'; + + if ($die) + die(); +} + +/** + * Debug Logging to Syslog + * + * The global debug level is turned on in your configuration file by setting: + * + * $config->custom->debug['level'] = 255; + * + * together with atleast one output direction (currently file and syslog are supported). + * + * $config->custom->debug['file'] = '/tmp/pla_debug.log'; + * $config->custom->debug['syslog'] = true; + * + * + * The debug level is turned into binary, then if the message levels bit is on + * the message will be sent to the debug log. (Thus setting your debug level to 255, + * all bits on, will results in all messages being printed.) + * + * The message level bits are defined here. + * 0( 1) = Entry/Return results from function calls. + * 1( 2) = Configuration Processing + * 2( 4) = Template Processing + * 3( 8) = Schema Processing + * 4( 16) = LDAP Server Communication + * 5( 32) = Tree Processing + * 7( 64) = Other non generic messages + * 8(128) = Page Processing + * @param string $msg Message to send to syslog + * @param int $level Log bit number for this message. + * @see syslog.php + */ + +function debug_log($msg,$level=0) { + global $debug_file,$timer; + + # Temporary, to catch when these are not set in the function arguments. + $file = __FILE__; + $line = __LINE__; + $method = __METHOD__; + + # In case we are called before we are fully initialised or if debugging is not set. + if (! isset($_SESSION[APPCONFIG]) || ! ($_SESSION[APPCONFIG]->GetValue('debug','file') + || $_SESSION[APPCONFIG]->GetValue('debug','syslog'))) + return false; + + $debug_level = $_SESSION[APPCONFIG]->GetValue('debug','level'); + if (! $debug_level || (! ($level & $debug_level))) + return; + + $debugaddr = false; + if ($_SESSION[APPCONFIG]->GetValue('debug','addr')) { + if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] == $_SESSION[APPCONFIG]->GetValue('debug','addr')) + $debugaddr = true; + + elseif ($_SERVER['REMOTE_ADDR'] == $_SESSION[APPCONFIG]->GetValue('debug','addr')) + $debugaddr = true; + } else $debugaddr = true; + + if (! $debugaddr) + return; + + # If we are limiting debug to a browser, then check that + $caller = basename( $_SERVER['PHP_SELF'] ); + + if (func_num_args() > 2) { + $args = func_get_args(); + array_shift($args); + array_shift($args); + + # This is temporary, until we change all the debug_log statements. + if (is_string($args[0]) && preg_match('/.php$/',$args[0])) { + $file = array_shift($args); + $line = array_shift($args); + $method = array_shift($args); + } + + $fargs = array(); + foreach ($args as $key) { + if (is_array($key) || is_object($key)) + array_push($fargs,serialize($key)); + else + array_push($fargs,$key); + } + $msg = vsprintf($msg, array_values($fargs)); + } + + if (function_exists('stopwatch')) + $timer = stopwatch(); + else + $timer = null; + + $debug_message = sprintf('[%2.3f] %3s-%s(%04s): %s: %s',$timer,$level,basename($file),$line,$method,substr($msg,0,200)); + + if ($debug_file || $_SESSION[APPCONFIG]->GetValue('debug','file')) { + if (! $debug_file) + $debug_file = fopen($_SESSION[APPCONFIG]->GetValue('debug','file'), + $_SESSION[APPCONFIG]->GetValue('debug','append') ? 'a' : 'w'); + + fwrite($debug_file,$debug_message."\n"); + } + + if ($_SESSION[APPCONFIG]->GetValue('debug','syslog')) + syslog_notice($debug_message); + + return syslog_notice( sprintf('%s(%s): %s',$caller,$level,$msg) ); +} + +/** + * Display an error message in the system message panel of the page. + */ +function error($msg,$type='note',$fatal=false,$backtrace=false) { + global $www; + global $counter; + + # if the error is fatal, we'll need to stop here. + if (! isset($www['page']) && $fatal) + $www['page'] = new page(null); + + # Just a check to see that we are called right. + if (! isset($www['page']) && ! $fatal) + die("Function error called incorrectly [$msg]"); + + $www['page']->setsysmsg(array('title'=>_('Error'),'body'=>$msg,'type'=>$type)); + + # Spin loop detection + if ($counter++ > 20) { + debug_dump("Spin loop detection."); + debug_dump(array('msg'=>$msg,'session'=>$_SESSION['sysmsg'],'www'=>$www),1); + } + + if ($fatal) + $www['page']->display(array('tree'=>false)); +} + +/** + * Return the result of a form variable, with optional default + */ +function get_request($attr,$type=null,$die=false,$default=null) { + switch($type) { + case 'GET': + $value = isset($_GET[$attr]) ? $_GET[$attr] : $default; + break; + + case 'REQUEST': + $value = isset($_REQUEST[$attr]) ? $_REQUEST[$attr] : $default; + break; + + case 'SESSION': + $value = isset($_SESSION[$attr]) ? $_SESSION[$attr] : $default; + break; + + case 'POST': + default: + $value = isset($_POST[$attr]) ? $_POST[$attr] : $default; + break; + } + + if (! is_array($value) && trim($value) == "") + $value = $default; + + if ($die && is_null($value)) + system_message(array( + 'title'=>_('Generic Error'), + 'body'=>sprintf('%s: Called "%s" without "%s" using "%s"', + basename($_SERVER['PHP_SELF']),get_request('cmd','REQUEST'),$attr,$type), + 'type'=>'error'), + sprintf('index.php?server_id=%s',$ldapserver->server_id)); + + return $value; +} + +/** + * Record a system message. + * This function can be used as an alternative to generate a system message, if page hasnt yet been defined. + */ +function system_message($msg,$redirect=null) { + if (! is_array($msg)) + return null; + + if (! isset($msg['title']) && ! isset($msg['body'])) + return null; + + $_SESSION['sysmsg'][] = $msg; + + if ($redirect) { + header("Location: $redirect"); + die(); + } +} + +/** + * Other Functions + */ + +/** + * Encryption using blowfish algorithm + * + * @param string original data + * @param string the secret + * + * @return string the encrypted result + * + * @access public + * + * @author lem9 (taken from the phpMyAdmin source) + */ +function pla_blowfish_encrypt($data,$secret=null) { + if (DEBUG_ENABLED) + debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__, + $data,$secret); + + # If our secret is null or blank, get the default. + if ($secret === null || ! trim($secret)) + $secret = $_SESSION[APPCONFIG]->GetValue('session','blowfish'); + + # If the secret isnt set, then just return the data. + if (! trim($secret)) + return $data; + + if (file_exists(LIBDIR.'blowfish.php')) + require_once LIBDIR.'blowfish.php'; + else + return $data; + + $pma_cipher = new Horde_Cipher_blowfish; + $encrypt = ''; + + for ($i=0; $iencryptBlock($block, $secret); + } + return base64_encode($encrypt); +} + +/** + * Decryption using blowfish algorithm + * + * @param string encrypted data + * @param string the secret + * + * @return string original data + * + * @access public + * + * @author lem9 (taken from the phpMyAdmin source) + */ +function pla_blowfish_decrypt($encdata,$secret=null) { + if (DEBUG_ENABLED) + debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__, + $encdata,$secret); + + # This cache gives major speed up for stupid callers :) + static $CACHE = array(); + + if (isset($CACHE[$encdata])) + return $CACHE[$encdata]; + + # If our secret is null or blank, get the default. + if ($secret === null || ! trim($secret)) + $secret = $_SESSION[APPCONFIG]->GetValue('session','blowfish'); + + # If the secret isnt set, then just return the data. + if (! trim($secret)) + return $encdata; + + if (file_exists(LIBDIR.'blowfish.php')) + require_once LIBDIR.'blowfish.php'; + else + return $data; + + $pma_cipher = new Horde_Cipher_blowfish; + $decrypt = ''; + $data = base64_decode($encdata); + + for ($i=0; $idecryptBlock(substr($data, $i, 8), $secret); + + $return = trim($decrypt); + $CACHE[$encdata] = $return; + return $return; +} + +/** + * Returns the cached array of LDAP resources. + * + * Note that internally, this function utilizes a two-layer cache, + * one in memory using a static variable for multiple calls within + * the same page load, and one in a session for multiple calls within + * the same user session (spanning multiple page loads). + * + * @return Returns the cached attributed requested, + * or null if there is nothing cached.. + */ +function get_cached_item($server_id,$item,$subitem='null') { + # Set default return + $return = null; + + # Check config to make sure session-based caching is enabled. + if ($_SESSION[APPCONFIG]->GetValue('cache',$item)) { + + global $cache; + if (isset($cache[$server_id][$item][$subitem])) { + if (DEBUG_ENABLED) + debug_log('Returning MEMORY cached [%s] (%s)',1,__FILE__,__LINE__,__METHOD__, + $item,$subitem); + + $return = $cache[$server_id][$item][$subitem]; + + } elseif (isset($_SESSION['cache'][$server_id][$item][$subitem])) { + if (DEBUG_ENABLED) + debug_log('Returning SESSION cached [%s] (%s)',1,__FILE__,__LINE__,__METHOD__, + $item,$subitem); + + $return = $_SESSION['cache'][$server_id][$item][$subitem]; + $cache[$server_id][$item][$subitem] = $return; + + } + } + + if (DEBUG_ENABLED) + debug_log('Entered with (%s,%s,%s), Returning (%s)',1,__FILE__,__LINE__,__METHOD__, + $server_id,$item,$subitem,$return); + + return $return; +} + +/** + * Caches the specified $item for the specified $server_id. + * + * Returns true on success of false on failure. + */ +function set_cached_item($server_id,$item,$subitem='null',$data) { + if (DEBUG_ENABLED) + debug_log('Entered with (%s,%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, + $server_id,$item,$subitem,$data); + + # Check config to make sure session-based caching is enabled. + if ($_SESSION[APPCONFIG]->GetValue('cache',$item)) { + global $cache; + + $cache[$server_id][$item][$subitem] = $data; + $_SESSION['cache'][$server_id][$item][$subitem] = $data; + return true; + + } else + return false; +} + +/** + * Deletes the cache for a specified $item for the specified $server_id + * + * @return: void + */ +function del_cached_item($server_id,$item,$subitem='null') { + if (DEBUG_ENABLED) + debug_log('Entered with (%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, + $server_id,$item,$subitem); + + # Check config to make sure session-based caching is enabled. + if (isset($_SESSION['cache'][$server_id][$item][$subitem])) + unset($_SESSION['cache'][$server_id][$item][$subitem]); +} + +/** + * Utility wrapper for setting cookies, which takes into consideration + * phpLDAPadmin configuration values. On success, true is returned. On + * failure, false is returned. + * + * @param string $name The name of the cookie to set. + * @param string $val The value of the cookie to set. + * @param int $expire (optional) The duration in seconds of this cookie. If unspecified, $cookie_time + * is used from config.php + * @param string $dir (optional) The directory value of this cookie (see php.net/setcookie) + * + * @see setcookie + * @return bool + */ +function pla_set_cookie($name,$val,$expire=null,$dir=null) { + # Set default return + $return = false; + + if ($expire == null) { + $cookie_time = $_SESSION[APPCONFIG]->GetValue('session','cookie_time'); + $expire = $cookie_time == 0 ? null : time() + $cookie_time; + } + + if ($dir == null) + $dir = dirname($_SERVER['PHP_SELF']); + + if (@setcookie($name,$val,$expire,$dir)) { + $_COOKIE[$name] = $val; + $return = true; + } + + if (DEBUG_ENABLED) + debug_log('Entered with (%s,%s,%s,%s), Returning (%s)',1,__FILE__,__LINE__,__METHOD__, + $name,$val,$expire,$dir,$return); + + return $return; +} + +/** + * PLA specific Functions + */ + /** * Fetches whether the user has configured phpLDAPadmin to obfuscate passwords * with "*********" when displaying them. @@ -69,10 +732,10 @@ function __autoload($className) { * @return bool */ function obfuscate_password_display($enc=null) { - if ($_SESSION['plaConfig']->GetValue('appearance','obfuscate_password_display')) + if ($_SESSION[APPCONFIG]->GetValue('appearance','obfuscate_password_display')) $return = true; - elseif (! $_SESSION['plaConfig']->GetValue('appearance','show_clear_password') && (is_null($enc) || $enc == 'clear')) + elseif (! $_SESSION[APPCONFIG]->GetValue('appearance','show_clear_password') && (is_null($enc) || $enc == 'clear')) $return = true; else @@ -99,10 +762,6 @@ function pretty_print_dn($dn) { if (DEBUG_ENABLED) debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$dn); -# @todo: Disabled, as it is affecting the special chars being displayed. -# if (! is_dn_string($dn)) -# return $dn; - $dn_save = $dn; $dn = pla_explode_dn($dn); @@ -135,7 +794,7 @@ function pretty_print_dn($dn) { */ function is_dn_string($str) { if (DEBUG_ENABLED) - debug_log('is_dn_string(): Entered with (%s)',1,$str); + debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$str); /* Try to break the string into its component parts if it can be done ie, "uid=Manager" "dc=example" and "dc=com" */ @@ -173,7 +832,7 @@ function is_dn_string($str) { */ function is_mail_string($str) { if (DEBUG_ENABLED) - debug_log('is_mail_string(): Entered with (%s)',1,$str); + debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$str); $mail_regex = "/^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*$/"; @@ -192,7 +851,7 @@ function is_mail_string($str) { */ function is_url_string($str) { if (DEBUG_ENABLED) - debug_log('is_url_string(): Entered with (%s)',1,$str); + debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$str); $url_regex = '/(ftp|https?):\/\/+[\w\.\-\/\?\=\&]*\w+/'; @@ -202,43 +861,6 @@ function is_url_string($str) { return false; } -/** - * Utility wrapper for setting cookies, which takes into consideration - * phpLDAPadmin configuration values. On success, true is returned. On - * failure, false is returned. - * - * @param string $name The name of the cookie to set. - * @param string $val The value of the cookie to set. - * @param int $expire (optional) The duration in seconds of this cookie. If unspecified, $cookie_time - * is used from config.php - * @param string $dir (optional) The directory value of this cookie (see php.net/setcookie) - * - * @see setcookie - * @return bool - */ -function pla_set_cookie( $name, $val, $expire=null, $dir=null ) { - # Set default return - $return = false; - - if ($expire == null) { - $cookie_time = $_SESSION['plaConfig']->GetValue('session','cookie_time'); - $expire = $cookie_time == 0 ? null : time() + $cookie_time; - } - - if ($dir == null) - $dir = dirname( $_SERVER['PHP_SELF'] ); - - if (@setcookie($name,$val,$expire,$dir)) { - $_COOKIE[$name] = $val; - $return = true; - } - - if (DEBUG_ENABLED) - debug_log('pla_set_cookie(): Entered with (%s,%s,%s,%s), Returning (%s)',1,$name,$val,$expire,$dir,$return); - - return $return; -} - /** * Get a customized file for a server * We don't need any caching, because it's done by PHP @@ -252,38 +874,17 @@ function get_custom_file($server_id,$filename,$path) { # Set default return $return = $path.$filename; - $custom = $_SESSION['plaConfig']->ldapservers->GetValue($server_id,'custom','pages_prefix'); + $custom = $_SESSION[APPCONFIG]->ldapservers->GetValue($server_id,'custom','pages_prefix'); if (! is_null($custom) && is_file(realpath($path.$custom.$filename))) $return = $path.$custom.$filename; if (DEBUG_ENABLED) - debug_log('get_custom_file(): Entered with (%s,%s,%s), Returning (%s)',1,$server_id,$filename,$path,$return); + debug_log('Entered with (%s,%s,%s), Returning (%s)',1,__FILE__,__LINE__,__METHOD__, + $server_id,$filename,$path,$return); return $return; } -/** - * Call a customized function - * - * @param int $server_id The ID of the server - * @param string $filename The requested function - * - * @return any The result of the called function - */ -function call_custom_function( $server_id, $function ) { - # Set default return - $return = $function; - - $custom = $_SESSION['plaConfig']->ldapservers->GetValue($server_id,'custom','pages_prefix'); - if (! is_null($custom) && function_exists($custom.$function)) - $return = $custom.$filename; - - if (DEBUG_ENABLED) - debug_log('get_custom_file(): Entered with (%s,%s), Returning (%s)',1,$server_id,$function,$return); - - return call_user_func($return ); -} - /** * Compares 2 DNs. If they are equivelant, returns 0, otherwise, * returns their sorting order (similar to strcmp()): @@ -317,7 +918,7 @@ function call_custom_function( $server_id, $function ) { */ function pla_compare_dns($dn1,$dn2) { if (DEBUG_ENABLED) - debug_log('pla_compare_dns(): Entered with (%s,%s)',1,$dn1,$dn2); + debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__,$dn1,$dn2); # If pla_compare_dns is passed via a tree, then we'll just get the DN part. if (is_array($dn1)) @@ -384,7 +985,7 @@ function pla_compare_dns($dn1,$dn2) { */ function real_attr_name($attr_name) { if (DEBUG_ENABLED) - debug_log('real_attr_name(): Entered with (%s)',1,$attr_name); + debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$attr_name); $attr_name = preg_replace('/;.*$/U','',$attr_name); return $attr_name; @@ -417,20 +1018,20 @@ function real_attr_name($attr_name) { */ function get_next_number(&$ldapserver,$startbase='',$type='uid',$increment=false,$filter=false) { if (DEBUG_ENABLED) - debug_log('get_next_number(): Entered with (%s,%s,%s,%s)',1, - $ldapserver->server_id,$startbase,$type,$filter); + debug_log('Entered with (%s,%s,%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, + $ldapserver->server_id,$startbase,$type,$increment,$filter); - if (! $_SESSION['plaConfig']->ldapservers->GetValue($ldapserver->server_id,'auto_number','enable')) + if (! $_SESSION[APPCONFIG]->ldapservers->GetValue($ldapserver->server_id,'auto_number','enable')) return false; # Based on the configured mechanism, go get the next available uidNumber! - $mechanism = $_SESSION['plaConfig']->ldapservers->GetValue($ldapserver->server_id,'auto_number','mechanism'); + $mechanism = $_SESSION[APPCONFIG]->ldapservers->GetValue($ldapserver->server_id,'auto_number','mechanism'); switch ($mechanism) { case 'search' : if (! $startbase) { - $base_dn = $_SESSION['plaConfig']->ldapservers->GetValue($ldapserver->server_id,'auto_number','search_base'); + $base_dn = $_SESSION[APPCONFIG]->ldapservers->GetValue($ldapserver->server_id,'auto_number','search_base'); if (is_null($base_dn)) pla_error(sprintf(_('You specified the "auto_uid_number_mechanism" as "search" in your @@ -450,13 +1051,13 @@ function get_next_number(&$ldapserver,$startbase='',$type='uid',$increment=false # Check see and use our alternate uid_dn and password if we have it. $con = $ldapserver->connect(false,'auto_search',false,true, - $_SESSION['plaConfig']->ldapservers->GetValue($ldapserver->server_id,'auto_number','dn'), - $_SESSION['plaConfig']->ldapservers->GetValue($ldapserver->server_id,'auto_number','pass')); + $_SESSION[APPCONFIG]->ldapservers->GetValue($ldapserver->server_id,'auto_number','dn'), + $_SESSION[APPCONFIG]->ldapservers->GetValue($ldapserver->server_id,'auto_number','pass')); if (! $con) pla_error(sprintf(_('Unable to bind to %s with your with auto_uid credentials. Please check your configuration file.'),$ldapserver->name)); - $search = $ldapserver->search($con,$base_dn,$filter,array('uidNumber','gidNumber'),'sub',false,$_SESSION['plaConfig']->GetValue('deref','search')); + $search = $ldapserver->search($con,$base_dn,$filter,array('uidNumber','gidNumber'),'sub',false,$_SESSION[APPCONFIG]->GetValue('deref','search')); if (! is_array($search)) pla_error('Untrapped error.'); @@ -499,8 +1100,8 @@ function get_next_number(&$ldapserver,$startbase='',$type='uid',$increment=false $uid_hash[$uid] = 1; # start with the least existing autoNumber and add 1 - if ($_SESSION['plaConfig']->ldapservers->GetValue($ldapserver->server_id,'auto_number','min')) - $minNumber = $_SESSION['plaConfig']->ldapservers->GetValue($ldapserver->server_id,'auto_number','min'); + if ($_SESSION[APPCONFIG]->ldapservers->GetValue($ldapserver->server_id,'auto_number','min')) + $minNumber = $_SESSION[APPCONFIG]->ldapservers->GetValue($ldapserver->server_id,'auto_number','min'); else $minNumber = intval($autonum[0]) + 1; @@ -514,15 +1115,15 @@ function get_next_number(&$ldapserver,$startbase='',$type='uid',$increment=false case 'uidpool': $con = $ldapserver->connect(false,'auto_search',false,true, - $_SESSION['plaConfig']->ldapservers->GetValue($ldapserver->server_id,'auto_number','dn'), - $_SESSION['plaConfig']->ldapservers->GetValue($ldapserver->server_id,'auto_number','pass')); + $_SESSION[APPCONFIG]->ldapservers->GetValue($ldapserver->server_id,'auto_number','dn'), + $_SESSION[APPCONFIG]->ldapservers->GetValue($ldapserver->server_id,'auto_number','pass')); if (! $con) pla_error(sprintf(_('Unable to bind to %s with your with auto_uid credentials. Please check your configuration file.'),$ldapserver->name)); # assume that uidpool dn is set in config file if no filter given if (empty($filter)) - $uidpool_dn = $_SESSION['plaConfig']->ldapservers->GetValue($ldapserver->server_id,'auto_number','uidpool_dn'); + $uidpool_dn = $_SESSION[APPCONFIG]->ldapservers->GetValue($ldapserver->server_id,'auto_number','uidpool_dn'); else { $filter = str_replace(array('&',':::'),array('&',','),$filter); @@ -595,7 +1196,8 @@ function get_next_number(&$ldapserver,$startbase='',$type='uid',$increment=false */ function get_icon( $ldapserver, $dn ) { if (DEBUG_ENABLED) - debug_log('get_icon(): Entered with (%s,%s)',1,$ldapserver->server_id,$dn); + debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__, + $ldapserver->server_id,$dn); // fetch and lowercase all the objectClasses in an array $object_classes = $ldapserver->getDNAttr($dn,'objectClass',true); @@ -778,7 +1380,8 @@ function get_icon( $ldapserver, $dn ) { */ function expand_dn_with_base( $base,$sub_dn ) { if (DEBUG_ENABLED) - debug_log('expand_dn_with_base(): Entered with (%s,%s)',1,$base,$sub_dn); + debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__, + $base,$sub_dn); $empty_str = ( is_null($sub_dn) || ( ( $len = strlen( trim( $sub_dn ) ) ) == 0 ) ); @@ -793,56 +1396,6 @@ function expand_dn_with_base( $base,$sub_dn ) { } } -/** - * Builds the initial tree that is stored in the session variable 'tree'. - * Simply returns an array with an entry for each active server in - * config.php. The structure of the returned array is simple, and looks like - * this: - * - * Array ( - * 0 => Array ( ) - * 1 => Array ( ) - * ) - * - * This function is not meant as a user callable function, but rather a convenient, - * automated method for setting up the initial structure for the tree viewer. - */ -function build_initial_tree() { - $return = array(); - - foreach ($_SESSION['plaConfig']->ldapservers->GetServerList() as $id) { - if (! trim($_SESSION['plaConfig']->ldapservers->GetValue($id,'server','host'))) - continue; - - $return[$id] = array(); - } - - if (DEBUG_ENABLED) - debug_log('build_initial_tree(): Entered with (), Returning (%s)',1,$return); - - return $return; -} - -/** - * Returns true if the passed string $temp contains all printable - * ASCII characters. Otherwise (like if it contains binary data), - * returns false. - */ -function is_printable_str($temp) { - if (DEBUG_ENABLED) - debug_log('is_printable_str(): Entered with (%s)',1,$temp); - - $len = strlen($temp); - - for ($i=0; $i<$len; $i++) { - $ascii_val = ord( substr( $temp,$i,1 ) ); - if( $ascii_val < 32 || $ascii_val > 126 ) - return false; - } - - return true; -} - /** * Reads the query, checks all values and sets defaults. * @@ -851,12 +1404,12 @@ function is_printable_str($temp) { */ function get_cleaned_up_predefined_search($query_id) { if (DEBUG_ENABLED) - debug_log('get_cleaned_up_predefined_search(): Entered with (%s)',1,$query_id); + debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$query_id); - if (! isset($_SESSION['plaConfig']->queries[$query_id])) + if (! isset($_SESSION[APPCONFIG]->queries[$query_id])) return null; - $query = $_SESSION['plaConfig']->queries[$query_id]; + $query = $_SESSION[APPCONFIG]->queries[$query_id]; $base = (isset($query['base'])) ? $query['base'] : null; @@ -890,7 +1443,7 @@ function get_cleaned_up_predefined_search($query_id) { */ function random_salt( $length ) { if (DEBUG_ENABLED) - debug_log('random_salt(): Entered with (%s)',1,$length); + debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$length); $possible = '0123456789'. 'abcdefghijklmnopqrstuvwxyz'. @@ -969,7 +1522,8 @@ function get_container($dn,$lower=true) { $container = strtolower($container); if (DEBUG_ENABLED) - debug_log('get_container(): Entered with (%s), Returning (%s)',1,$dn,$container); + debug_log('Entered with (%s,%s), Returning (%s)',1,__FILE__,__LINE__,__METHOD__, + $dn,$lower,$container); return $container; } @@ -991,7 +1545,7 @@ function get_container($dn,$lower=true) { */ function pla_verbose_error( $err_no ) { if (DEBUG_ENABLED) - debug_log('pla_verbose_error(): Entered with (%s)',1,$err_no); + debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$err_no); static $err_codes; @@ -1027,7 +1581,7 @@ function pla_verbose_error( $err_no ) { // @todo: describe this function function support_oid_to_text($oid_id) { if (DEBUG_ENABLED) - debug_log('support_oid_to_text(): Entered with (%s)',1,$oid_id); + debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$oid_id); static $oid; @@ -1062,23 +1616,6 @@ function support_oid_to_text($oid_id) { return null; } -function error($msg,$type='note',$fatal=false,$backtrace=false) { - global $www; - - # if the error is fatal, we'll need to stop here. - if (! isset($www) && $fatal) - $www = new page(null); - - # Just a check to see that we are called right. - if (! isset($www) && ! $fatal) - pla_error('Function error called incorrectly',null,-1,true,true); - - $www->setsysmsg(array('title'=>_('Error'),'body'=>$msg,'type'=>$type)); - - if ($fatal) - $www->display(array('tree'=>false)); -} - /** * Prints an HTML-formatted error string. If you specify the optional * parameters $ldap_err_msg and $ldap_err_no, this function will @@ -1096,7 +1633,8 @@ function error($msg,$type='note',$fatal=false,$backtrace=false) { */ function pla_error($msg,$ldap_err_msg=null,$ldap_err_no=-1,$fatal=true,$backtrace=null) { if (defined('DEBUG_ENABLED') && (DEBUG_ENABLED)) - debug_log('pla_error(): Entered with (%s,%s,%s,%s)',1,$msg,$ldap_err_msg,$ldap_err_no,$fatal); + debug_log('Entered with (%s,%s,%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, + $msg,$ldap_err_msg,$ldap_err_no,$fatal,$backtrace); $server = isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : 'undefined'; @@ -1206,7 +1744,8 @@ function pla_error($msg,$ldap_err_msg=null,$ldap_err_no=-1,$fatal=true,$backtrac */ function pla_error_handler($errno,$errstr,$file,$lineno) { if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) - debug_log('pla_error_handler(): Entered with (%s,%s,%s,%s)',1,$errno,$errstr,$file,$lineno); + debug_log('Entered with (%s,%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, + $errno,$errstr,$file,$lineno); /* error_reporting will be 0 if the error context occurred * within a function call with '@' preprended (ie, @ldap_bind() ); @@ -1265,26 +1804,6 @@ function pla_error_handler($errno,$errstr,$file,$lineno) { pla_error(sprintf('%s: %s',$errtype,$errstr),null,-1,true,debug_backtrace()); } -/** - * Reads the friendly_attrs array as defined in config.php and lower-cases all - * the keys. Will return an empty array if the friendly_attrs array is not defined - * in config.php. This is simply used so we can more easily lookup user-friendly - * attributes configured by the admin. - */ -function process_friendly_attr_table() { - if (DEBUG_ENABLED) - debug_log('process_friendly_attr_table(): Entered with ()',1); - - $attrs_table = array(); - if( isset( $_SESSION['plaConfig']->friendly_attrs ) && is_array( $_SESSION['plaConfig']->friendly_attrs ) ) - foreach( $_SESSION['plaConfig']->friendly_attrs as $old_name => $new_name ) - $attrs_table[ strtolower( $old_name ) ] = $new_name; - else - return array(); - - return $attrs_table; -} - /** * Draw the jpegPhoto image(s) for an entry wrapped in HTML. Many options are available to * specify how the images are to be displayed. @@ -1310,7 +1829,7 @@ function draw_jpeg_photos($ldapserver,$dn,$attr_name='jpegPhoto',$draw_delete_bu $draw_bytes_and_size=true,$table_html_attrs='align="left"',$img_html_attrs='') { if (DEBUG_ENABLED) - debug_log('draw_jpeg_photos(): Entered with (%s,%s,%s,%s,%s,%s,%s)',1, + debug_log('Entered with (%s,%s,%s,%s,%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, $ldapserver->server_id,$dn,$attr_name,$draw_delete_buttons, $draw_bytes_and_size,$table_html_attrs,$img_html_attrs); @@ -1331,7 +1850,7 @@ function draw_jpeg_photos($ldapserver,$dn,$attr_name='jpegPhoto',$draw_delete_bu return; } - $jpeg_temp_dir = realpath($_SESSION['plaConfig']->GetValue('jpeg','tmpdir').'/'); + $jpeg_temp_dir = realpath($_SESSION[APPCONFIG]->GetValue('jpeg','tmpdir').'/'); if (! is_writable($jpeg_temp_dir)) pla_error(_('Please set $jpeg_temp_dir to a writable directory in the phpLDAPadmin config.php') ); @@ -1397,7 +1916,7 @@ function draw_jpeg_photos($ldapserver,$dn,$attr_name='jpegPhoto',$draw_delete_bu while (($file = readdir($handle)) != false) { if (preg_match($jpegtmp_wildcard,$file)) { $file = "$jpeg_temp_dir/$file"; - if ((time() - filemtime($file)) > $_SESSION['plaConfig']->GetValue('jpeg','tmp_keep_time')) + if ((time() - filemtime($file)) > $_SESSION[APPCONFIG]->GetValue('jpeg','tmp_keep_time')) @unlink($file); } } @@ -1417,13 +1936,14 @@ function draw_jpeg_photos($ldapserver,$dn,$attr_name='jpegPhoto',$draw_delete_bu */ function password_hash( $password_clear, $enc_type ) { if (DEBUG_ENABLED) - debug_log('password_hash(): Entered with (%s,%s)',1,$password_clear,$enc_type); + debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__, + $password_clear,$enc_type); $enc_type = strtolower( $enc_type ); switch( $enc_type ) { case 'crypt': - if ($_SESSION['plaConfig']->GetValue('password', 'no_random_crypt_salt')) + if ($_SESSION[APPCONFIG]->GetValue('password', 'no_random_crypt_salt')) $new_value = '{CRYPT}' . crypt($password_clear,substr($password_clear,0,2)); else $new_value = '{CRYPT}' . crypt($password_clear,random_salt(2)); @@ -1509,7 +2029,8 @@ function password_hash( $password_clear, $enc_type ) { */ function password_check( $cryptedpassword, $plainpassword ) { if (DEBUG_ENABLED) - debug_log('password_check(): Entered with (%s,%s)',1,$cryptedpassword,$plainpassword); + debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__, + $cryptedpassword,$plainpassword); if( preg_match( "/{([^}]+)}(.*)/", $cryptedpassword, $cypher ) ) { $cryptedpassword = $cypher[2]; @@ -1650,7 +2171,7 @@ function password_check( $cryptedpassword, $plainpassword ) { */ function get_enc_type( $user_password ) { if (DEBUG_ENABLED) - debug_log('get_enc_type(): Entered with (%s)',1,$user_password); + debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$user_password); /* Capture the stuff in the { } to determine if this is crypt, md5, etc. */ $enc_type = null; @@ -1688,50 +2209,9 @@ function get_enc_type( $user_password ) { */ function get_default_hash($server_id) { if (DEBUG_ENABLED) - debug_log('get_default_hash(): Entered with (%s)',1,$server_id); + debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$server_id); - return $_SESSION['plaConfig']->ldapservers->GetValue($server_id,'appearance','password_hash'); -} - -/** - * Returns the phpLDAPadmin version currently running. The version - * is read from the file named VERSION. - * - * @return string The current version as read from the VERSION file. - */ -function pla_version() { - $version_file = realpath(LIBDIR.'../VERSION'); - if (! file_exists($version_file)) - $return = 'UNKNOWN'; - - else { - $f = fopen($version_file,'r'); - $version = trim(fread($f, filesize($version_file))); - fclose($f); - - # We use cvs_prefix, because CVS will translate this on checkout otherwise. - $cvs_prefix = '\$Name:'; - - $return = preg_replace('/^'.$cvs_prefix.' RELEASE-([0-9_]+)\s*\$$/','$1',$version); - $return = preg_replace('/_/','.',$return); - - # Check if we are a CVS copy. - if (preg_match('/^'.$cvs_prefix.'?\s*\$$/',$return)) - $return = 'CVS'; - - # Check if we are special CVS branch - elseif (preg_match('/^'.$cvs_prefix.'?\s*([a-zA-Z]+)?\s*\$$/',$return,$match)) - $return = $match[1]; - - # If return is still the same as version, then the tag is not one we expect. - elseif ($return == $version) - $return = 'UNKNOWN'; - } - - if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) - debug_log('pla_version(): Entered with (), Returning (%s)',1,$return); - - return $return; + return $_SESSION[APPCONFIG]->ldapservers->GetValue($server_id,'appearance','password_hash'); } /** @@ -1746,7 +2226,8 @@ function pla_version() { */ function draw_chooser_link( $form_element, $include_choose_text=true, $rdn="none" ) { if (DEBUG_ENABLED) - debug_log('draw_chooser_link(): Entered with (%s,%s,%s)',1,$form_element,$include_choose_text,$rdn); + debug_log('Entered with (%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, + $form_element,$include_choose_text,$rdn); if ($rdn == 'none') { $href = "javascript:dnChooserPopup('$form_element','');"; @@ -1839,7 +2320,7 @@ function dn_escape($dn) { $dn = preg_replace('/([^\\\\]),(\s*[^=]*\s*)([^,])$/','$1\\\\2C$2$3',$dn); if (DEBUG_ENABLED) - debug_log('dn_escape(): Entered with (%s), Returning (%s)',1,$olddn,$dn); + debug_log('Entered with (%s), Returning (%s)',1,__FILE__,__LINE__,__METHOD__,$olddn,$dn); return $dn; } @@ -1937,7 +2418,7 @@ function utime () { */ function array_to_query_string( $array, $exclude_vars=array(), $url_encode_ampersands=true ) { if (DEBUG_ENABLED) - debug_log('array_to_query_string(): Entered with (%s,%s,%s)',1, + debug_log('Entered with (%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, count($array),count($exclude_vars),$url_encode_ampersands); if (! is_array($array)) @@ -1989,7 +2470,7 @@ function array_to_query_string( $array, $exclude_vars=array(), $url_encode_amper */ function pla_reverse_dn($dn) { if (DEBUG_ENABLED) - debug_log('pla_reverse_dn(): Entered with (%s)',1,$dn); + debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$dn); return (join(',',array_reverse(pla_explode_dn($dn)))); } @@ -1999,9 +2480,9 @@ function pla_reverse_dn($dn) { */ function sortAttrs($a,$b) { if (DEBUG_ENABLED) - debug_log('sortAttrs(): Entered with (%s,%s)',1,$a,$b); + debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__,$a,$b); - $attrs_display_order = isset($_SESSION['plaConfig']->attrs_display_order) ? $_SESSION['plaConfig']->attrs_display_order : array(); + $attrs_display_order = isset($_SESSION[APPCONFIG]->attrs_display_order) ? $_SESSION[APPCONFIG]->attrs_display_order : array(); if ($a == $b) return 0; @@ -2012,8 +2493,8 @@ function sortAttrs($a,$b) { # If not, check if its friendly name is $attrs_display_order, get its key # If not, assign one greater than number of elements. if ( $a_key === false ) { - if (isset($_SESSION['plaConfig']->friendly_attrs[strtolower($a)])) { - $a_key = array_search($_SESSION['plaConfig']->friendly_attrs[strtolower($a)],$attrs_display_order); + if ($_SESSION[APPCONFIG]->haveFriendlyName($a)) { + $a_key = array_search($_SESSION[APPCONFIG]->getFriendlyName($a),$attrs_display_order); if ($a_key == '') $a_key = count($attrs_display_order)+1; @@ -2024,8 +2505,8 @@ function sortAttrs($a,$b) { $b_key = array_search($b,$attrs_display_order); if ($b_key === false) { - if (isset($_SESSION['plaConfig']->friendly_attrs[strtolower($b)])) { - $b_key = array_search($_SESSION['plaConfig']->friendly_attrs[strtolower($b)],$attrs_display_order); + if ($_SESSION[APPCONFIG]->haveFriendlyName($b)) { + $b_key = array_search($_SESSION[APPCONFIG]->getFriendlyName($b),$attrs_display_order); if ($b_key == '') $b_key = count($attrs_display_order)+1; @@ -2037,8 +2518,8 @@ function sortAttrs($a,$b) { # Case where neither $a, nor $b are in $attrs_display_order, $a_key = $b_key = one greater than num elements. # So we sort them alphabetically if ($a_key === $b_key) { - $a = strtolower((isset($_SESSION['plaConfig']->friendly_attrs[strtolower($a)]) ? $_SESSION['plaConfig']->friendly_attrs[strtolower($a)] : $a)); - $b = strtolower((isset($_SESSION['plaConfig']->friendly_attrs[strtolower($b)]) ? $_SESSION['plaConfig']->friendly_attrs[strtolower($b)] : $b)); + $a = strtolower($_SESSION[APPCONFIG]->getFriendlyName($a)); + $b = strtolower($_SESSION[APPCONFIG]->getFriendlyName($b)); return strcmp($a,$b); } @@ -2061,7 +2542,7 @@ function attrcmp($a1, $a2) { */ function arrayLower($array) { if (DEBUG_ENABLED) - debug_log('arrayLower(): Entered with (%s)',1,$array); + debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$array); if (! is_array($array)) return $array; @@ -2081,7 +2562,7 @@ function arrayLower($array) { */ function array_stripslashes(&$array) { if (DEBUG_ENABLED) - debug_log('array_stripslashes(): Entered with (%s)',1,$array); + debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$array); if (is_array($array)) while (list($key) = each($array)) @@ -2103,7 +2584,7 @@ function get_user_agent_string() { $return = false; if (DEBUG_ENABLED) - debug_log('get_user_agent_string(): Entered with (), Returning (%s)',1,$return); + debug_log('Entered with (), Returning (%s)',1,__FILE__,__LINE__,__METHOD__,$return); return $return; } @@ -2131,7 +2612,7 @@ function is_browser_os_unix() { $return = string_in_array_value(get_user_agent_string(),$agent_strs); if (DEBUG_ENABLED) - debug_log('is_browser_os_unix(): Entered with (), Returning (%s)',1,$return); + debug_log('Entered with (), Returning (%s)',1,__FILE__,__LINE__,__METHOD__,$return); return $return; } @@ -2153,7 +2634,7 @@ function is_browser_os_windows() { $return = string_in_array_value(get_user_agent_string(),$agent_strs); if (DEBUG_ENABLED) - debug_log('is_browser_os_windows(): Entered with (), Returning (%s)',1,$return); + debug_log('Entered with (), Returning (%s)',1,__FILE__,__LINE__,__METHOD__,$return); return $return; } @@ -2170,35 +2651,11 @@ function is_browser_os_mac() { $return = string_in_array_value(get_user_agent_string(),$agent_strs); if (DEBUG_ENABLED) - debug_log('is_browser_os_windows(): Entered with (), Returning (%s)',1,$return); + debug_log('Entered with (), Returning (%s)',1,__FILE__,__LINE__,__METHOD__,$return); return $return; } -/** - * Return the default format for search results. - * - * @return string The format to use. - */ -function get_default_search_display() { - if (DEBUG_ENABLED) - debug_log('get_default_search_display(): Entered with ()',1); - - global $default_search_display; - - if( ! isset( $default_search_display ) || is_null( $default_search_display ) ) - return 'list'; - - elseif( 0 == strcasecmp( $default_search_display, 'list' ) ) - return 'list'; - - elseif( 0 == strcasecmp( $default_search_display, 'table' ) ) - return 'table'; - - else - pla_error( sprintf( _('Your config.php specifies an invalid value for $default_search_display: %s. Please fix it'), htmlspecialchars( $default_search_display ) ) ); -} - /** * Checks if a string exists in an array, ignoring case. * @@ -2252,7 +2709,8 @@ function string_in_array_value( $needle, $haystack ) { } if (DEBUG_ENABLED) - debug_log('string_in_array_value(): Entered with (%s,%s), Returning (%s)',1,$needle,$haystack,$return); + debug_log('Entered with (%s,%s), Returning (%s)',1,__FILE__,__LINE__,__METHOD__, + $needle,$haystack,$return); return $return; } @@ -2269,7 +2727,8 @@ function string_in_array_value( $needle, $haystack ) { */ function full_str_pad($input, $pad_length, $pad_string = '', $pad_type = 0) { if (DEBUG_ENABLED) - debug_log('full_str_pad(): Entered with (%s,%s,%s,%s)',1,$input,$pad_length,$pad_string,$pad_type); + debug_log('Entered with (%s,%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, + $input,$pad_length,$pad_string,$pad_type); $str = ''; $length = $pad_length - strlen($input); @@ -2291,91 +2750,6 @@ function full_str_pad($input, $pad_length, $pad_string = '', $pad_type = 0) { return $str; } -/** - * Encryption using blowfish algorithm - * - * @param string original data - * @param string the secret - * - * @return string the encrypted result - * - * @access public - * - * @author lem9 (taken from the phpMyAdmin source) - */ -function pla_blowfish_encrypt( $data, $secret=null ) { - if (DEBUG_ENABLED) - debug_log('pla_blowfish_encrypt(): Entered with (%s,%s)',1,$data,$secret); - - # If our secret is null or blank, get the default. - if( $secret === null || ! trim($secret)) - $secret = $_SESSION['plaConfig']->GetValue('session','blowfish'); - - # If the secret isnt set, then just return the data. - if (! trim($secret)) - return $data; - - require_once LIBDIR.'blowfish.php'; - - $pma_cipher = new Horde_Cipher_blowfish; - $encrypt = ''; - - for ($i=0; $iencryptBlock($block, $secret); - } - return base64_encode($encrypt); -} - -/** - * Decryption using blowfish algorithm - * - * @param string encrypted data - * @param string the secret - * - * @return string original data - * - * @access public - * - * @author lem9 (taken from the phpMyAdmin source) - */ -function pla_blowfish_decrypt( $encdata, $secret=null ) { - if (DEBUG_ENABLED) - debug_log('pla_blowfish_decrypt(): Entered with (%s,%s)',1,$encdata,$secret); - - // This cache gives major speed up for stupid callers :) - static $cache = array(); - - if( isset( $cache[$encdata] ) ) - return $cache[$encdata]; - - # If our secret is null or blank, get the default. - if( $secret === null || ! trim($secret)) - $secret = $_SESSION['plaConfig']->GetValue('session','blowfish'); - - # If the secret isnt set, then just return the data. - if (! trim($secret)) - return $encdata; - - require_once LIBDIR.'blowfish.php'; - - $pma_cipher = new Horde_Cipher_blowfish; - $decrypt = ''; - $data = base64_decode($encdata); - - for ($i=0; $idecryptBlock(substr($data, $i, 8), $secret); - } - - $return = trim($decrypt); - $cache[$encdata] = $return; - return $return; -} - /** * Gets a DN string using the user-configured tree_display_format string to format it. */ @@ -2383,14 +2757,15 @@ function draw_formatted_dn($ldapserver,$entry) { $dn = $entry->getDn(); if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s)',1,$ldapserver->server_id,$dn); + debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__, + $ldapserver->server_id,$dn); - $format = $_SESSION['plaConfig']->GetValue('appearance','tree_display_format'); + $format = $_SESSION[APPCONFIG]->GetValue('appearance','tree_display_format'); preg_match_all('/%[a-zA-Z_0-9]+/',$format,$tokens); $tokens = $tokens[0]; if (DEBUG_ENABLED) - debug_log('The tokens are (%s)',1,$tokens); + debug_log('The tokens are (%s)',1,__FILE__,__LINE__,__METHOD__,$tokens); foreach ($tokens as $token) { if (strcasecmp($token,'%dn') == 0) @@ -2432,7 +2807,8 @@ function draw_formatted_dn($ldapserver,$entry) { */ function shadow_date( $attrs, $attr) { if (DEBUG_ENABLED) - debug_log('shadow_date(): Entered with (%s,%s)',1,$attrs,$attr); + debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__, + $attrs,$attr); $shadowlastchange_attribute = null; $shadowmax_attribute = null; @@ -2488,7 +2864,7 @@ function shadow_date( $attrs, $attr) { */ function clean_search_vals( $val ) { if (DEBUG_ENABLED) - debug_log('clean_search_vals(): Entered with (%s)',1,$val); + debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$val); # Remove any escaped brackets already. $val = preg_replace('/\\\\([\(\)])/','$1',$val); @@ -2506,14 +2882,15 @@ function clean_search_vals( $val ) { */ function server_select_list ($select_id=null,$only_logged_on=true,$select_name='server_id',$js_script=null) { if (DEBUG_ENABLED) - debug_log('server_select_list(): Entered with (%s,%s,%s,%s)',1,$select_id,$only_logged_on,$select_name,$js_script); + debug_log('Entered with (%s,%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, + $select_id,$only_logged_on,$select_name,$js_script); $count = 0; $server_menu_html = sprintf(''; $html .= ''; @@ -2694,7 +2959,7 @@ function enc_type_select_list($enc_type) { // Converts a little-endian hex-number to one, that 'hexdec' can convert function littleEndian($hex) { if (DEBUG_ENABLED) - debug_log('littleEndian(): Entered with (%s)',1,$hex); + debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$hex); $result = ''; @@ -2706,7 +2971,7 @@ function littleEndian($hex) { function binSIDtoText($binsid) { if (DEBUG_ENABLED) - debug_log('binSIDtoText(): Entered with (%s)',1,$binsid); + debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$binsid); $hex_sid=bin2hex($binsid); $rev = hexdec(substr($hex_sid,0,2)); // Get revision-part of SID @@ -2738,7 +3003,7 @@ function masort(&$data,$sortby,$rev=0) { # if the array to sort is null or empty if (! $data) return; - + static $sort_funcs = array(); if (empty($sort_funcs[$sortby])) { @@ -2800,8 +3065,8 @@ function masort(&$data,$sortby,$rev=0) { */ function return_ldap_hash($ldapserver,$base_dn,$filter,$key,$attrs,$sort=true) { if (DEBUG_ENABLED) - debug_log('return_ldap_hash(): Entered with (%s,%s,%s,%s,%s)',0, - $ldapserver->server_id,$base_dn,$filter,$key,count($attrs)); + debug_log('Entered with (%s,%s,%s,%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, + $ldapserver->server_id,$base_dn,$filter,$key,$attrs,$sort); $ldapquery = $ldapserver->search(null,$base_dn,$filter,$attrs,'sub',$sort,LDAP_DEREF_NEVER,0); @@ -2832,37 +3097,17 @@ function return_ldap_hash($ldapserver,$base_dn,$filter,$key,$attrs,$sort=true) { return $results; } -/** - * This function dumps the $variable for debugging purposes - * @param string|array Variable to dump - * @param boolean Whether to stop execution or not. - */ -function debug_dump($variable,$die=false,$onlydebugaddr=false) { - if ($onlydebugaddr && - $_SESSION['plaConfig']->GetValue('debug','addr') && - $_SERVER['HTTP_X_FORWARDED_FOR'] != $_SESSION['plaConfig']->GetValue('debug','addr') && - $_SERVER['REMOTE_ADDR'] != $_SESSION['plaConfig']->GetValue('debug','addr')) - return; - - print '
';
-	print_r($variable);
-	print '
'; - - if ($die) - die(); -} - /** * This function returns a string automatically generated * based on the criteria defined in the array $criteria in config.php */ function password_generate() { - $no_use_similiar = ! $_SESSION['plaConfig']->GetValue('password','use_similar'); - $lowercase = $_SESSION['plaConfig']->GetValue('password','lowercase'); - $uppercase = $_SESSION['plaConfig']->GetValue('password','uppercase'); - $digits = $_SESSION['plaConfig']->GetValue('password','numbers'); - $punctuation = $_SESSION['plaConfig']->GetValue('password','punctuation'); - $length = $_SESSION['plaConfig']->GetValue('password','length'); + $no_use_similiar = ! $_SESSION[APPCONFIG]->GetValue('password','use_similar'); + $lowercase = $_SESSION[APPCONFIG]->GetValue('password','lowercase'); + $uppercase = $_SESSION[APPCONFIG]->GetValue('password','uppercase'); + $digits = $_SESSION[APPCONFIG]->GetValue('password','numbers'); + $punctuation = $_SESSION[APPCONFIG]->GetValue('password','punctuation'); + $length = $_SESSION[APPCONFIG]->GetValue('password','length'); $outarray = array(); @@ -2922,7 +3167,7 @@ function password_generate() { $return = implode('', $outarray); if (DEBUG_ENABLED) - debug_log('password_generate(): Entered with (), Returning (%s)',1,$return); + debug_log('Entered with (), Returning (%s)',1,__FILE__,__LINE__,__METHOD__,$return); return $return; } @@ -2958,108 +3203,25 @@ function a_array_rand($input,$num_req) { } if (DEBUG_ENABLED) - debug_log('a_array_rand(): Entered with (%s,%s), Returning (%s)',1,$input,$num_req,$return); + debug_log('Entered with (%s,%s), Returning (%s)',1,__FILE__,__LINE__,__METHOD__, + $input,$num_req,$return); return $return; } -/** - * Returns the cached array of LDAP resources. - * - * Note that internally, this function utilizes a two-layer cache, - * one in memory using a static variable for multiple calls within - * the same page load, and one in a session for multiple calls within - * the same user session (spanning multiple page loads). - * - * @return Returns the cached attributed requested, - * or null if there is nothing cached.. - */ -function get_cached_item($server_id,$item,$subitem='null') { - # Set default return - $return = null; - - # Check config to make sure session-based caching is enabled. - if ($_SESSION['plaConfig']->GetValue('cache',$item)) { - - global $cache; - if (isset($cache[$server_id][$item][$subitem])) { - if (DEBUG_ENABLED) - debug_log('get_cached_item(): Returning MEMORY cached [%s] (%s)',1,$item,$subitem); - - $return = $cache[$server_id][$item][$subitem]; - - } elseif (isset($_SESSION['cache'][$server_id][$item][$subitem])) { - if (DEBUG_ENABLED) - debug_log('get_cached_item(): Returning SESSION cached [%s] (%s)',1,$item,$subitem); - - $return = $_SESSION['cache'][$server_id][$item][$subitem]; - $cache[$server_id][$item][$subitem] = $return; - - } - } - - if (DEBUG_ENABLED) - debug_log('get_cached_item(): Entered with (%s,%s,%s), Returning (%s)',1, - $server_id,$item,$subitem,count($return)); - - return $return; -} - -/** - * Caches the specified $item for the specified $server_id. - * - * Returns true on success of false on failure. - */ -function set_cached_item($server_id,$item,$subitem='null',$data) { - if (DEBUG_ENABLED) - debug_log('set_cached_item(): Entered with (%s,%s,%s,%s)',1,$server_id,$item,$subitem,$data); - - # Check config to make sure session-based caching is enabled. - if ($_SESSION['plaConfig']->GetValue('cache',$item)) { - global $cache; - - $cache[$server_id][$item][$subitem] = $data; - $_SESSION['cache'][$server_id][$item][$subitem] = $data; - return true; - - } else - return false; -} - -/** - * Deletes the cache for a specified $item for the specified $server_id - * - * @return: void - */ -function del_cached_item($server_id,$item,$subitem='null') { - if (DEBUG_ENABLED) - debug_log('del_cached_item(): Entered with (%s,%s,%s)',1,$server_id,$item,$subitem); - - # Check config to make sure session-based caching is enabled. - if (isset($_SESSION['cache'][$server_id][$item][$subitem])) - unset($_SESSION['cache'][$server_id][$item][$subitem]); -} - /** * Draws an HTML date selector button which, when clicked, pops up a date selector dialog. * @param string $attr The name of the date type attribute */ function draw_date_selector_link( $attr ) { - debug_log('draw_date_selector_link(): Entered with (%s)',1,$attr); + if (DEBUG_ENABLED) + debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$attr); $href = "javascript:dateSelector('$attr');"; $title = _('Click to popup a dialog to select a date graphically'); printf('Calendar',$href,$title,$attr); } -function no_expire_header() { - header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); - header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT'); - header('Cache-Control: no-store, no-cache, must-revalidate'); - header('Cache-Control: post-check=0, pre-check=0', false); - header('Pragma: no-cache'); -} - /** * This is for Opera. By putting "random junk" in the query string, it thinks * that it does not have a cached version of the page, and will thus @@ -3070,73 +3232,6 @@ function random_junk() { return md5(strtotime('now').$time['usec']); } -/** - * This function will convert the browser two character language into the - * default 5 character language, where the country portion should NOT be - * assumed to be upper case characters of the first two characters. - */ -function auto_lang($lang) { - switch ($lang) { - case 'ja': return 'ja_JP'; - case 'cs': return 'cs_CZ'; - default: return sprintf('%s_%s',$lang,strtoupper($lang)); - } -} - -function get_request($attr,$type='POST',$die=false,$default=null) { - switch($type) { - case 'GET': - $value = isset($_GET[$attr]) ? $_GET[$attr] : $default; - break; - - case 'REQUEST': - $value = isset($_REQUEST[$attr]) ? $_REQUEST[$attr] : $default; - break; - - case 'SESSION': - $value = isset($_SESSION[$attr]) ? $_SESSION[$attr] : $default; - break; - - case 'POST': - default: - $value = isset($_POST[$attr]) ? $_POST[$attr] : $default; - break; - } - - if (! is_array($value) && trim($value) == "") - $value = $default; - - if ($die && is_null($value)) - system_message(array( - 'title'=>_('Generic Error'), - 'body'=>sprintf('%s: Called "%s" without "%s" using "%s"',basename($_SERVER['PHP_SELF']),get_request('cmd','REQUEST'),$attr,$type), - 'type'=>'error'),'index.php'); - - return $value; -} - -function system_message($msg,$redirect=null,$noserverid=false) { - global $ldapserver; - - if (! is_array($msg)) - return null; - - $_SESSION['sysmsg'][] = $msg; - - if ($redirect) { - if ($noserverid || ! $ldapserver) { - header("Location: $redirect"); - - } else { - if (preg_match('/\?/',$redirect)) - header(sprintf('Location: %s&server_id=%s',$redirect,$ldapserver->server_id)); - else - header(sprintf('Location: %s?server_id=%s',$redirect,$ldapserver->server_id)); - } - exit; - } -} - /** * Returns a HTML id that can be used in the URL after the #. * @@ -3146,147 +3241,4 @@ function system_message($msg,$redirect=null,$noserverid=false) { function htmlid($sid,$dn) { return sprintf('SID%s:%s',$sid,preg_replace('/[\ =,]/','_',$dn)); } - -/* - * Makes sure that the config file is properly setup and - * that your install of PHP can handle LDAP stuff. - */ - -function check_config($config_file) { - global $config,$ldapservers; - global $friendly_attrs, $queries, $attrs_display_order; - global $hidden_attrs, $hidden_except_dn, $hidden_attrs_ro; - global $read_only_attrs, $read_only_except_dn, $unique_attrs; - - # Read in config_default.php - require_once LIBDIR.'config_default.php'; - - # Make sure their PHP version is current enough - if (strcmp(phpversion(),REQUIRED_PHP_VERSION) < 0) - pla_error(sprintf('phpLDAPadmin requires PHP version %s or greater.
(You are using %s)', - REQUIRED_PHP_VERSION,phpversion())); - - # Make sure this PHP install has all our required extensions - if (! extension_loaded('ldap')) - system_message(array( - 'title'=>_('Missing required extension'), - 'body'=> 'Your install of PHP appears to be missing LDAP support.

Please install LDAP support before using phpLDAPadmin.
(Dont forget to restart your web server afterwards)', - 'type'=>'error')); - - # Make sure that we have php-xml loaded. - if (! function_exists('xml_parser_create')) - system_message(array( - 'title'=>_('Missing required extension'), - 'body'=> 'Your install of PHP appears to be missing XML support.

Please install XML support before using phpLDAPadmin.
(Dont forget to restart your web server afterwards)', - 'type'=>'error')); - - # Make sure their session save path is writable, if they are using a file system session module, that is. - if ( ! strcasecmp('Files',session_module_name() && ! is_writable(realpath(session_save_path())))) - system_message(array( - 'title'=>_('Missing required extension'), - 'body'=> 'Your PHP session configuration is incorrect. Please check the value of session.save_path in your php.ini to ensure that the directory specified there exists and is writable. The current setting of "'.session_save_path().'" is un-writable by the web server.', - 'type'=>'error')); - - $config = new Config; - - /* Check for syntax errors in config.php - As of php 4.3.5, this NO longer catches fatal errors :( */ - - ob_start(); - require_once $config_file; - $str = ''; - if (ob_get_level()) { - $str = ob_get_contents(); - ob_end_clean(); - } - - if ($str) { - $str = strip_tags($str); - $matches = array(); - preg_match('/(.*):\s+(.*):.*\s+on line (\d+)/',$str,$matches); - - if (isset($matches[1]) && isset($matches[2]) && isset($matches[3])) { - $error_type = $matches[1]; - $error = $matches[2]; - $line_num = $matches[3]; - - $file = file($config_file); - - echo ''."\n"; - echo ''."\n"; - echo "\n"; - - echo ''; - echo ''; - echo 'phpLDAPadmin Config File Error'; - echo ''; - echo ''; - - echo ''; - echo '

Config File ERROR

'; - printf('

%s (%s) on line %s

',$error_type,$error,$line_num); - - echo '
'; - printf('Looks like your config file has an ERROR on line %s.
',$line_num); - echo 'Here is a snippet around that line
'; - echo '
'."\n"; - - echo '
'; - - for ($i = $line_num-9; $i<$line_num+5; $i++) { - if ($i+1 == $line_num) - echo '
'; - - if ($i < 0) - continue; - - printf('%s: %s
',$i+1,htmlspecialchars($file[$i])); - if ($i+1 == $line_num) - echo '
'; - } - - echo '
'; - echo '
'; - echo 'Hint: Sometimes these errors are caused by lines preceding the line reported.'; - echo '
'; - echo ''; - echo ''; - - return false; - } - } - - # Check for server definitions. - if (! isset($ldapservers) || count($ldapservers->GetServerList()) == 0) - system_message(array( - 'title'=>_('Missing required extension'), - 'body'=> 'Your config.php is missing Server Definitions. Please see the sample file config/config.php.example.', - 'type'=>'error')); - - $config->ldapservers = $ldapservers; - - if (isset($friendly_attrs)) $config->friendly_attrs = $friendly_attrs; - if (isset($queries)) $config->queries = $queries; - if (isset($attrs_display_order)) $config->attrs_display_order = $attrs_display_order; - if (isset($hidden_attrs)) $config->hidden_attrs = $hidden_attrs; - if (isset($hidden_except_dn)) $config->hidden_except_dn = $hidden_except_dn; - if (isset($hidden_attrs_ro)) $config->hidden_attrs_ro = $hidden_attrs_ro; - if (isset($read_only_attrs)) $config->read_only_attrs = $read_only_attrs; - if (isset($read_only_except_dn)) $config->read_only_except_dn = $read_only_except_dn; - if (isset($unique_attrs)) $config->unique_attrs = $unique_attrs; - - # Check the memory limit parameter. - if (ini_get('memory_limit') < $config->GetValue('session','memorylimit')) - system_message(array( - 'title'=>_('Memory Limit low.'), - 'body'=> sprintf('Your php memory limit is low - currently %s',ini_get('memory_limit'),false), - 'type'=>'error')); - - # if $_SESSION['sysmsg'] is set, then there were problems. - if (isset($_SESSION['sysmsg'])) - return false; - - return true; -} ?> diff --git a/lib/hooks.php b/lib/hooks.php index 6bd8e83..9224d95 100644 --- a/lib/hooks.php +++ b/lib/hooks.php @@ -1,5 +1,5 @@ hooks : array(); + $hooks = isset($_SESSION[APPCONFIG]) ? $_SESSION[APPCONFIG]->hooks : array(); $debug = 0; syslog_debug("Running hook $hook_name."); @@ -161,8 +161,8 @@ function remove_hook($hook_name,$priority,$hook_function,$rollback_function) { */ function clear_hooks($hook_name) { global $config; - if (!isset($config) && isset($_SESSION['plaConfig'])) - $config = $_SESSION['plaConfig']; + if (!isset($config) && isset($_SESSION[APPCONFIG])) + $config = $_SESSION[APPCONFIG]; if (array_key_exists($hook_name,$config->hooks)) unset($config->hooks[$hook_name]); diff --git a/lib/page.php b/lib/page.php index 5a38b6c..e173717 100644 --- a/lib/page.php +++ b/lib/page.php @@ -1,5 +1,5 @@ GetValue('appearance','compress') + if (isset($_SESSION[APPCONFIG]) + && $_SESSION[APPCONFIG]->GetValue('appearance','compress') && eregi('gzip',$_SERVER['HTTP_ACCEPT_ENCODING']) && ! ini_get('zlib.output_compression')) { @@ -56,10 +56,10 @@ class page { debug_log('Sent COMPRESSED header to browser and discarded (%s)',129,__FILE__,__LINE__,__METHOD__,$preOutput); } - if (isset($_SESSION['plaConfig']) - && $_SESSION['plaConfig']->GetValue('appearance','compress') + if (isset($_SESSION[APPCONFIG]) + && $_SESSION[APPCONFIG]->GetValue('appearance','compress') && ini_get('zlib.output_compression')) - $this->setsysmsg(array(array('title'=>_('Warning'),'body'=>_('WARNING: You cannot have PHP compression and phpLDAPadmin compression enabled at the same time. Please unset zlib.output_compression or set $config->custom->appearance[\'compress\']=false'),'type'=>'warn'))); + $this->setsysmsg(array('title'=>_('Warning'),'body'=>_('WARNING: You cannot have PHP compression and phpLDAPadmin compression enabled at the same time. Please unset zlib.output_compression or set $config->custom->appearance[\'compress\']=false'),'type'=>'warn')); # Turn back on output buffering. ob_start(); @@ -75,7 +75,7 @@ class page { $this->_app['logo'] = $this->_default['logo']; if (! is_null($server_id)) - $this->_app['urlcss'] = sprintf('%s%s',CSSDIR,$_SESSION['plaConfig']->GetValue('appearance','stylesheet')); + $this->_app['urlcss'] = sprintf('%s%s',CSSDIR,$_SESSION[APPCONFIG]->GetValue('appearance','stylesheet')); else $this->_app['urlcss'] = sprintf('%s%s',CSSDIR,'style.css'); @@ -99,24 +99,27 @@ class page { # Page Title echo ''; - if (isset($_SESSION['plaConfig'])) + if (isset($_SESSION[APPCONFIG])) printf('%s (%s) - %s', - $this->_app['title'],pla_version(),$_SESSION['plaConfig']->GetValue('appearance','page_title')); + $this->_app['title'],pla_version(),$_SESSION[APPCONFIG]->GetValue('appearance','page_title')); else printf('%s - %s',$this->_app['title'],pla_version()); # Style sheet. printf('',$this->_app['urlcss']); - printf('',JSDIR); - printf('','../htdocs/'.JSDIR); printf('','../htdocs/'); - echo "\n"; - printf('',JSDIR); - printf('',JSDIR); - printf('',JSDIR); - printf('','../htdocs/'.JSDIR); - printf('','../htdocs/'.JSDIR); - echo "\n"; + + if (defined('JSDIR')) { + printf('',JSDIR); + printf('','../htdocs/'.JSDIR); + echo "\n"; + printf('',JSDIR); + printf('',JSDIR); + printf('',JSDIR); + printf('','../htdocs/'.JSDIR); + printf('','../htdocs/'.JSDIR); + echo "\n"; + } # HTML head requirements. if (is_array($this->_head) && count ($this->_head)) @@ -131,14 +134,14 @@ class page { if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) debug_log('Entered with ()',129,__FILE__,__LINE__,__METHOD__); - if (isset($_SESSION['plaConfig'])) - $pagetitle = $_SESSION['plaConfig']->GetValue('appearance','page_title') ? ' - '.$_SESSION['plaConfig']->GetValue('appearance','page_title') : ''; + if (isset($_SESSION[APPCONFIG])) + $pagetitle = $_SESSION[APPCONFIG]->GetValue('appearance','page_title') ? ' - '.$_SESSION[APPCONFIG]->GetValue('appearance','page_title') : ''; else $pagetitle = ''; echo ''; - if (is_null($this->server_id)) + if (! isset($this->server_id) || is_null($this->server_id)) printf('%s',' '); else printf('%s %s',$this->_app['title'],$pagetitle); @@ -150,63 +153,31 @@ class page { if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) debug_log('Entered with ()',129,__FILE__,__LINE__,__METHOD__); - if (! isset($this->server_id) || is_null($this->server_id)) { - echo ' '; - return; - } - echo ''; echo ''; $empty = true; - if ($_SESSION['plaConfig']->isCommandAvailable('home')) { - printf('', - _('Home'),_('Home'),_('Home')); - $empty = false; - } + if (function_exists('cmd_control_pane')) + foreach (cmd_control_pane() as $cmd => $cmddetails) { + $cmds = preg_split('/:/',$cmd); - if ($_SESSION['plaConfig']->isCommandAvailable('purge')) { - printf('', - _('Purge caches'),_('Purge all cached data in phpLDAPadmin, including server schemas.'),_('Purge caches')); - $empty = false; - } + if ($_SESSION[APPCONFIG]->isCommandAvailable($cmds)) { + if ((isset($cmddetails['enable']) && trim($cmddetails['enable'])) || ! isset($cmddetails['enable'])) { + printf('',$cmddetails['link']); - if ($_SESSION['plaConfig']->isCommandAvailable('external_links', 'feature')) { - printf('', - get_href('add_rfe'),_('Request feature'),_('light'),_('Request feature')); - $empty = false; - } + $empty = false; + } + } + } - if ($_SESSION['plaConfig']->isCommandAvailable('external_links', 'bug')) { - printf('', - get_href('add_bug'),_('Report a bug'),_('bug'),_('Report a bug')); - $empty = false; - } - - if ($_SESSION['plaConfig']->isCommandAvailable('external_links', 'donation')) { - printf('', - get_href('donate'),_('Donate'),_('Donate'),_('Donate')); - $empty = false; - } - - if (! $_SESSION['plaConfig']->GetValue('appearance','hide_debug_info')) { - printf('', - _('Show Cache'),_('Show Cache'),_('Show Cache')); - $empty = false; - } - - if ($_SESSION['plaConfig']->isCommandAvailable('external_links', 'help')) { - printf('', - get_href('documentation'),_('Help'),_('Help'),_('Help')); - $empty = false; - } - - if ($empty) { + if ($empty) echo ''; - } - printf('',$this->_app['logo']); + if (isset($this->_app['logo'])) + printf('',$this->_app['logo']); + else + echo ''; echo ''; echo '
%s
%s
%s
%s
%s%s
%s
%s
%s
%s
%s
%s
%s
%s
%s
   
'; @@ -216,10 +187,10 @@ class page { if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) debug_log('Entered with ()',129,__FILE__,__LINE__,__METHOD__); - if (! isset($_SESSION['plaConfig'])) + if (! isset($_SESSION[APPCONFIG])) return; - $server_id = is_null($this->server_id) ? min($_SESSION['plaConfig']->ldapservers->GetServerList()) : $this->server_id; + $server_id = is_null($this->server_id) ? min($_SESSION[APPCONFIG]->ldapservers->GetServerList()) : $this->server_id; echo ''; if (count(server_info_list(true)) > 1) { @@ -232,9 +203,9 @@ class page { echo "\n\n"; } - foreach ($_SESSION['plaConfig']->ldapservers->GetServerList() as $server_id) { + foreach ($_SESSION[APPCONFIG]->ldapservers->GetServerList() as $server_id) { printf('
',$server_id,($server_id == $this->server_id) ? 'block': 'none'); - $ldapserver = $_SESSION['plaConfig']->ldapservers->Instance($server_id); + $ldapserver = $_SESSION[APPCONFIG]->ldapservers->Instance($server_id); $tree = Tree::getInstance($ldapserver->server_id); @@ -246,7 +217,7 @@ class page { public function block_add($side,$object) { if (! is_object($object)) - error('not an object'); + error(sprintf('block_add called with [%s], but it is not an object',serialize($object))); $this->_block[$side][] = $object; } @@ -312,9 +283,11 @@ class page { ob_start(); } - # System Message - if (isset($_SESSION['sysmsg']) && $_SESSION['sysmsg']) { - $this->setsysmsg($_SESSION['sysmsg']); + # Add the Session System Messages + if (isset($_SESSION['sysmsg']) && is_array($_SESSION['sysmsg'])) { + foreach ($_SESSION['sysmsg'] as $msg) + $this->setsysmsg($msg); + unset($_SESSION['sysmsg']); } @@ -330,8 +303,8 @@ class page { echo $object->draw('body'); } - if ($compress && ob_get_level() && isset($_SESSION['plaConfig']) - && $_SESSION['plaConfig']->GetValue('appearance','compress') + if ($compress && ob_get_level() && isset($_SESSION[APPCONFIG]) + && $_SESSION[APPCONFIG]->GetValue('appearance','compress') && ! ini_get('zlib.output_compression') && eregi('gzip',$_SERVER['HTTP_ACCEPT_ENCODING'])) { @@ -410,8 +383,8 @@ class page { echo ''; # compress output - if (ob_get_level() && isset($_SESSION['plaConfig']) - && $_SESSION['plaConfig']->GetValue('appearance','compress') + if (ob_get_level() && isset($_SESSION[APPCONFIG]) + && $_SESSION[APPCONFIG]->GetValue('appearance','compress') && ! ini_get('zlib.output_compression') && eregi('gzip',$_SERVER['HTTP_ACCEPT_ENCODING'])) { @@ -434,17 +407,13 @@ class page { return; if (isset($this->sysmsg)) - $nummsg = count($this->sysmsg); + $msgnum = count($this->sysmsg) + 1; else - $nummsg = 1; + $msgnum = 1; - foreach ($data as $msgno => $msgarray) { - $msgindex = $msgno + $nummsg; - - foreach (array('title','body','type') as $index) - if (isset($msgarray[$index])) - $this->sysmsg[$msgindex][$index] = $msgarray[$index]; - } + foreach (array('title','body','type') as $index) + if (isset($data[$index])) + $this->sysmsg[$msgnum][$index] = $data[$index]; } } diff --git a/lib/search_form_advanced.php b/lib/search_form_advanced.php index fd418fd..f79b34b 100644 --- a/lib/search_form_advanced.php +++ b/lib/search_form_advanced.php @@ -1,5 +1,5 @@ isCommandAvailable('search', 'simple_search'); - $ps = $_SESSION['plaConfig']->isCommandAvailable('search', 'predefined_search'); + $ss = $_SESSION[APPCONFIG]->isCommandAvailable('search', 'simple_search'); + $ps = $_SESSION[APPCONFIG]->isCommandAvailable('search', 'predefined_search'); if ($ss | $ps) { echo '('; if ($ss) { @@ -104,7 +104,7 @@ if (isset($entry['base_dn']['exist']) && $entry['base_dn']['exist']) + join(', ',$_SESSION[APPCONFIG]->GetValue('search','result_attributes')); ?>" /> diff --git a/lib/search_form_predefined.php b/lib/search_form_predefined.php index 772e921..bcbb17a 100644 --- a/lib/search_form_predefined.php +++ b/lib/search_form_predefined.php @@ -1,5 +1,5 @@ %s',_('Predefined Searches')); -$ss = $_SESSION['plaConfig']->isCommandAvailable('search', 'simple_search'); -$as = $_SESSION['plaConfig']->isCommandAvailable('search', 'advanced_search'); +$ss = $_SESSION[APPCONFIG]->isCommandAvailable('search', 'simple_search'); +$as = $_SESSION[APPCONFIG]->isCommandAvailable('search', 'advanced_search'); if ($ss | $as) { echo '('; if ($ss) { @@ -37,7 +37,7 @@ if ($ss | $as) { echo ' '; -if (! isset($_SESSION['plaConfig']->queries) || ! is_array($_SESSION['plaConfig']->queries) || count($_SESSION['plaConfig']->queries) == 0) { +if (! isset($_SESSION[APPCONFIG]->queries) || ! is_array($_SESSION[APPCONFIG]->queries) || count($_SESSION[APPCONFIG]->queries) == 0) { printf('%s',_('No queries have been defined in config.php.')); } else { @@ -47,7 +47,7 @@ if (! isset($_SESSION['plaConfig']->queries) || ! is_array($_SESSION['plaConfig' echo ''; echo ' -GetValue('search','attributes') as $id => $attribute) { ?> +GetValue('search','attributes') as $id => $attribute) { ?>