RELEASE 1.1.0.6

This commit is contained in:
Deon George
2009-06-30 21:52:55 +10:00
parent d5f4f91f1b
commit 647f86562f
118 changed files with 32686 additions and 19807 deletions

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/AJAXTree.php,v 1.2 2007/12/15 07:50:31 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/AJAXTree.php,v 1.2.2.2 2008/12/12 06:46:15 wurley Exp $
/**
* @package phpLDAPadmin
@@ -101,7 +101,7 @@ class AJAXTree extends PLMTree {
}
echo '<a href="'.$edit_href.'" onclick="return displayMainPage(\''.$edit_href_params.'\');" title="'.$dn.'" >';
echo '<img align="top" border="0" class="imgs" id="jt'.$node_id.'folder" src="images/'.$entry->getIcon($ldapserver).'" alt="->" />';
printf('<img align="top" border="0" class="imgs" id="jt%sfolder" src="%s/%s" alt="->" />',$node_id,IMGDIR,$entry->getIcon($ldapserver));
echo '</a>';
echo '&nbsp;';
echo '<a href="'.$edit_href.'" onclick="return displayMainPage(\''.$edit_href_params.'\');" title="'.$dn.'" class="phplm">';
@@ -131,6 +131,10 @@ class AJAXTree extends PLMTree {
$first_child = $this->get_plm_before_first_child($parent_entry,$code);
$last_child = $this->get_plm_after_last_child($parent_entry,$code);
# If compression is on, we need to compress this output - but only if called by draw_tree_node
if (function_exists('isCompress') && isCompress() && get_request('cmd','REQUEST') == 'draw_tree_node')
ob_start();
echo $first_child;
for ($i=0; $i<count($children); $i++) {
@@ -141,6 +145,12 @@ class AJAXTree extends PLMTree {
}
echo $last_child;
# If compression is on, we need to compress this output
if (function_exists('isCompress') && isCompress() && get_request('cmd','REQUEST') == 'draw_tree_node') {
$output = ob_get_clean();
echo gzencode($output);
}
}
/**
@@ -272,7 +282,7 @@ class AJAXTree extends PLMTree {
}
//folderLayer.src = \'js/phplayersmenu/menuimages/tree_folder_open.png\';
//folderLayer.src = \'js/phplayersmenu/menuimages/tree_folder_closed.png\';
nodeLayer.src = \'images/ajax-spinner.gif\';
nodeLayer.src = \''.IMGDIR.'ajax-spinner.gif\';
// perform action
if (action == 2) {
@@ -310,7 +320,7 @@ class AJAXTree extends PLMTree {
}
function displayMainPage(urlParameters) {
var mainPageDiv = getMainPageDiv();
if (mainPageDiv) includeHTML(mainPageDiv, \'<img src="images/ajax-progress.gif"><br><small>'._('Retrieving DN').'...<\/small>\');
if (mainPageDiv) includeHTML(mainPageDiv, \'<img src="'.IMGDIR.'ajax-progress.gif"><br><small>'._('Retrieving DN').'...<\/small>\');
makeGETRequest(\'cmd.php\', urlParameters+\'&meth=get_body\', \'alertMainPage\', \'cancelMainPage\');
return false;
}
@@ -337,7 +347,7 @@ class AJAXTree extends PLMTree {
$output .= $this->get_indentation($level);
$output .= '<img align="top" border="0" class="imgs" src="js/phplayersmenu/menuimages/tree_split.png" alt="--" />';
$output .= '<a href="'.htmlspecialchars($href).'" title="'.$entry->getDn().'">';
$output .= '<img align="top" border="0" class="imgs" src="images/star.png" alt="->" />';
$output .= sprintf('<img align="top" border="0" class="imgs" src="%s/star.png" alt="->" />',IMGDIR);
$output .= '</a>';
$output .= '&nbsp;';
$output .= '<a href="'.htmlspecialchars($href).'" title="'._('Create new entry here').'" class="phplm">';
@@ -361,7 +371,7 @@ class AJAXTree extends PLMTree {
$output .= $this->get_indentation($level);
$output .= '<img align="top" border="0" class="imgs" src="js/phplayersmenu/menuimages/tree_corner.png" alt="--" />';
$output .= '<a href="'.htmlspecialchars($href).'" title="'.$entry->getDn().'">';
$output .= '<img align="top" border="0" class="imgs" src="images/star.png" alt="->" />';
$output .= sprintf('<img align="top" border="0" class="imgs" src="%s/star.png" alt="->" />',IMGDIR);
$output .= '</a>';
$output .= '&nbsp;';
$output .= '<a href="'.htmlspecialchars($href).'" title="'._('Create new entry here').'" class="phplm">';

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/Attribute.php,v 1.2.2.2 2007/12/26 09:26:32 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/Attribute.php,v 1.2.2.3 2008/11/28 23:26:51 wurley Exp $
/**
* @package phpLDAPadmin
@@ -253,10 +253,7 @@ class Attribute {
public function isRdn() {
if ($this->entry) {
//$rdn = get_rdn($this->entry->getDn());
//$attr = $this->name;
//return preg_match("/^${attr}=/", $rdn);
return ($this->name == $this->entry->getRdnAttributeName());
return (preg_grep('/'.$this->name.'/',$this->entry->getRdnAttributeName()));
} else {
return false;
}

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/DefaultCreatingEntry.php,v 1.2.2.2 2007/12/29 08:24:10 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/DefaultCreatingEntry.php,v 1.2.2.3 2008/11/29 01:35:47 wurley Exp $
/**
* @package phpLDAPadmin
@@ -145,8 +145,8 @@ class DefaultCreatingEntry extends Entry {
public function getRdnAttributeName() {
$attr = $this->getRdnAttribute();
if ($attr) return $attr->getName();
else return '';
if ($attr) return array($attr->getName());
else return array('');
}
public function getRdnAttribute() {

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/DefaultEditingEntry.php,v 1.2.2.2 2007/12/29 08:25:24 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/DefaultEditingEntry.php,v 1.2.2.3 2008/03/01 02:13:03 wurley Exp $
/**
* @package phpLDAPadmin
@@ -32,10 +32,20 @@ class DefaultEditingEntry extends Entry {
if (!$int_attrs_vals) $int_attrs_vals = array();
elseif (!is_array($int_attrs_vals)) $int_attrs_vals = array($int_attrs_vals);
$custom_int_attrs_vals = $ldapserver->getCustomDNSysAttrs($this->getDn());
if (! $custom_int_attrs_vals) $attrs_vals = array();
elseif (! is_array($custom_int_attrs_vals)) $custom_int_attrs_vals = array($custom_int_attrs_vals);
$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);
$custom_attrs_vals = $ldapserver->getCustomDNAttrs($this->getDn(),false,$_SESSION[APPCONFIG]->GetValue('deref','view'));
if (! $custom_attrs_vals) $attrs_vals = array();
elseif (! is_array($custom_attrs_vals)) $custom_attrs_vals = array($custom_attrs_vals);
$int_attrs_vals = array_merge($int_attrs_vals,$custom_int_attrs_vals);
$attrs_vals = array_merge($attrs_vals,$custom_attrs_vals);
$attrs_vals = array_merge($attrs_vals, $int_attrs_vals);
uksort($attrs_vals,'sortAttrs'); # Sort these entries

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/Entry.php,v 1.2.2.3 2008/01/27 07:23:43 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/Entry.php,v 1.2.2.4 2008/11/28 23:26:51 wurley Exp $
/**
* @package phpLDAPadmin
@@ -58,10 +58,17 @@ abstract class Entry {
}
public function getRdnAttributeName() {
$attr = '';
$attr = array();
if ($this->dn) {
$i = strpos($this->dn, '=');
if ($i !== false) $attr = substr($this->dn, 0, $i);
$i = strpos($this->dn, ',');
if ($i !== false) {
$attrs = split('\+',substr($this->dn, 0, $i));
foreach ($attrs as $id => $attr) {
list ($name,$value) = split('=',$attr);
$attrs[$id] = $name;
}
$attr = array_unique($attrs);
}
}
return $attr;
}

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/EntryReader.php,v 1.2.2.3 2008/01/27 14:09:14 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/EntryReader.php,v 1.2.2.5 2008/12/12 12:20:22 wurley Exp $
define('ENTRY_READER_CREATION_CONTEXT', '1');
define('ENTRY_READER_EDITING_CONTEXT', '2');
@@ -113,7 +113,11 @@ class EntryReader extends Visitor {
// @todo editing objectclasses
if (($this->context == ENTRY_READER_CREATION_CONTEXT) && ($name == 'objectClass')) return;
$old_vals = $this->get('OldValues', $attribute);
if ($this->context == ENTRY_READER_EDITING_CONTEXT)
$old_vals = $this->get('OldValues', $attribute);
else
$old_vals = array();
$new_vals = $this->get('NewValues', $attribute);
if (isset($_POST['old_values'][$name])) {
@@ -205,7 +209,7 @@ class EntryReader extends Visitor {
}
if (is_null($val)) {
pla_error(sprintf(_('Your template is missing variable (%s)'), $request));
error(sprintf(_('Your template is missing variable (%s)'),$request),'error','index.php');
}
return $val;
@@ -255,7 +259,7 @@ class EntryReader extends Visitor {
if (function_exists($matches[1])) {
$val = call_user_func($matches[1], $matches[2], $attribute, $i, $val);
} else {
pla_error(sprintf(_('Your template has an unknown post function (%s).'), $matches[1]));
error(sprintf(_('Your template has an unknown post function (%s).'),$matches[1]),'error','index.php');
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/EntryWriter2.php,v 1.2.2.3 2008/01/27 06:48:59 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/EntryWriter2.php,v 1.2.2.4 2008/11/29 11:33:53 wurley Exp $
/**
* @package phpLDAPadmin
@@ -246,9 +246,9 @@ class EntryWriter2 extends EntryWriter1 {
}
protected function drawAttributeMenu($attribute) {
if ($attribute->getHint() /*&& $_SESSION[APPCONFIG]->GetValue('appearance', 'show_hints')*/) {
echo '<img src="images/light.png" alt="Hint" /> <span class="hint">'.$attribute->getHint().'</span>';
}
if ($attribute->getHint())
printf('<img src="%s/light.png" alt="Hint" /> <span class="hint">%s</span>',IMGDIR,$attribute->getHint());
parent::drawAttributeMenu($attribute);
}

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/HTMLTree.php,v 1.2.2.6 2008/01/27 10:17:28 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/HTMLTree.php,v 1.2.2.10 2008/12/13 02:13:13 wurley Exp $
/**
* @package phpLDAPadmin
@@ -43,8 +43,8 @@ class HTMLTree extends Tree {
printf('<tr><td class="blank" colspan="%s">&nbsp;</td></tr>',$this->getDepth()+3);
printf('<tr><td>&nbsp;</td><td><div style="overflow: auto; %s%s"><table class="tree" border=0>',
$_SESSION['plaConfig']->GetValue('appearance','tree_width') ? sprintf('width: %spx; ',$_SESSION['plaConfig']->GetValue('appearance','tree_width')) : '',
$_SESSION['plaConfig']->GetValue('appearance','tree_height') ? sprintf('height: %spx; ',$_SESSION['plaConfig']->GetValue('appearance','tree_height')) : '');
$_SESSION[APPCONFIG]->GetValue('appearance','tree_width') ? sprintf('width: %spx; ',$_SESSION[APPCONFIG]->GetValue('appearance','tree_width')) : '',
$_SESSION[APPCONFIG]->GetValue('appearance','tree_height') ? sprintf('height: %spx; ',$_SESSION[APPCONFIG]->GetValue('appearance','tree_height')) : '');
foreach ($ldapserver->getBaseDN() as $base_dn) {
# Did we get a base_dn for this server somehow?
@@ -55,7 +55,7 @@ class HTMLTree extends Tree {
if (! $ldapserver->dnExists($base_dn)) {
$javascript_id++;
printf('<tr><td class="spacer"></td><td class="spacer"></td><td><img src="images/unknown.png" /></td><td colspan="%s">%s</td></tr>',$this->getDepth()+3-3,pretty_print_dn($base_dn));
printf('<tr><td class="spacer"></td><td class="spacer"></td><td><img src="%s/unknown.png" /></td><td colspan="%s">%s</td></tr>',IMGDIR,$this->getDepth()+3-3,pretty_print_dn($base_dn));
/* Move this form and add it to the end of the html - otherwise the javascript
* doesnt work when isMassDeleteEnabled returning true.
@@ -103,9 +103,10 @@ class HTMLTree extends Tree {
}
} else { // end if $ldapserver->haveAuthInfo()
/* We don't have enough information to login to this server
* Draw the "login..." link
*/
$this->draw_login_link();
* Draw the "login..." link */
if ($ldapserver->auth_type != 'http')
$this->draw_login_link();
}
$this->draw_mass_deletion_submit_button();
@@ -153,14 +154,14 @@ class HTMLTree extends Tree {
$ldapserver = $this->getLdapServer();
echo '<tr class="server">';
printf('<td class="icon"><img src="images/server.png" alt="%s" /></td>',_('Server'));
printf('<td class="icon"><img src="%s/server.png" alt="%s" /></td>',IMGDIR,_('Server'));
printf('<td class="name" colspan="%s">',$this->getDepth()+3-1);
printf('%s',htmlspecialchars($ldapserver->name));
if ($ldapserver->haveAuthInfo() && $ldapserver->auth_type != 'config') {
if ($ldapserver->haveAuthInfo() && ! in_array($ldapserver->auth_type,array('config','http'))) {
$m = sprintf(_('Inactivity will log you off at %s'),
strftime('%H:%M',time() + ($ldapserver->session_timeout*60)));
printf(' <img width=14 height=14 src="images/timeout.png" title="%s" alt="%s"/>',$m,$m);
printf(' <img width=14 height=14 src="%s/timeout.png" title="%s" alt="%s"/>',IMGDIR,$m,$m);
}
echo '</td></tr>';
}
@@ -209,7 +210,7 @@ class HTMLTree extends Tree {
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();
if (! in_array($ldapserver->auth_type,array('config','http'))) return $this->get_logout_menu_item();
else return '';
default :
return false;
@@ -220,56 +221,56 @@ class HTMLTree extends Tree {
$ldapserver = $this->getLdapServer();
$href = sprintf('cmd.php?cmd=schema&server_id=%s',$ldapserver->server_id);
return sprintf('<a title="%s %s" href="%s"><img src="%s" alt="%s" /><br />%s</a>',
_('View schema for'),$ldapserver->name,htmlspecialchars($href),'images/schema.png',_('schema'),_('schema'));
return sprintf('<a title="%s %s" href="%s"><img src="%s/%s" alt="%s" /><br />%s</a>',
_('View schema for'),$ldapserver->name,htmlspecialchars($href),IMGDIR,'schema.png',_('schema'),_('schema'));
}
protected function get_search_menu_item() {
$ldapserver = $this->getLdapServer();
$href = sprintf('cmd.php?cmd=search&server_id=%s&form=undefined',$ldapserver->server_id);
return sprintf('<a title="%s %s" href="%s"><img src="%s" alt="%s" /><br />%s</a>',
_('search'),$ldapserver->name,htmlspecialchars($href),'images/search.png',_('search'),_('search'));
return sprintf('<a title="%s %s" href="%s"><img src="%s/%s" alt="%s" /><br />%s</a>',
_('search'),$ldapserver->name,htmlspecialchars($href),IMGDIR,'search.png',_('search'),_('search'));
}
protected function get_refresh_menu_item() {
$ldapserver = $this->getLdapServer();
$href = sprintf('cmd.php?cmd=refresh&server_id=%s',$ldapserver->server_id);
return sprintf('<a title="%s %s" href="%s"><img src="%s" alt="%s" /><br />%s</a>',
_('Refresh all expanded containers for'),$ldapserver->name,htmlspecialchars($href),'images/refresh-big.png',_('refresh'),_('refresh'));
return sprintf('<a title="%s %s" href="%s"><img src="%s/%s" alt="%s" /><br />%s</a>',
_('Refresh all expanded containers for'),$ldapserver->name,htmlspecialchars($href),IMGDIR,'refresh-big.png',_('refresh'),_('refresh'));
}
protected function get_info_menu_item() {
$ldapserver = $this->getLdapServer();
$href = sprintf('cmd.php?cmd=server_info&server_id=%s',$ldapserver->server_id);
return sprintf('<a title="%s" href="%s"><img src="%s" alt="%s" /><br />%s</a>',
_('View server-supplied information'),htmlspecialchars($href),'images/info.png',_('info'),_('info'));
return sprintf('<a title="%s" href="%s"><img src="%s/%s" alt="%s" /><br />%s</a>',
_('View server-supplied information'),htmlspecialchars($href),IMGDIR,'info.png',_('info'),_('info'));
}
protected function get_import_menu_item() {
$ldapserver = $this->getLdapServer();
$href = sprintf('cmd.php?cmd=ldif_import_form&server_id=%s',$ldapserver->server_id);
return sprintf('<a title="%s" href="%s"><img src="%s" alt="%s" /><br />%s</a>',
_('Import entries from an LDIF file'),htmlspecialchars($href),'images/import.png',_('import'),_('import'));
return sprintf('<a title="%s" href="%s"><img src="%s/%s" alt="%s" /><br />%s</a>',
_('Import entries from an LDIF file'),htmlspecialchars($href),IMGDIR,'import.png',_('import'),_('import'));
}
protected function get_export_menu_item() {
$ldapserver = $this->getLdapServer();
$href = sprintf('cmd.php?cmd=export_form&server_id=%s',$ldapserver->server_id);
return sprintf('<a title="%s" href="%s"><img src="%s" alt="%s" /><br />%s</a>',
_('Export entries'),htmlspecialchars($href),'images/export.png',_('export'),_('export'));
return sprintf('<a title="%s" href="%s"><img src="%s/%s" alt="%s" /><br />%s</a>',
_('Export entries'),htmlspecialchars($href),IMGDIR,'export.png',_('export'),_('export'));
}
protected function get_logout_menu_item() {
$ldapserver = $this->getLdapServer();
$href = sprintf('cmd.php?cmd=logout&server_id=%s',$ldapserver->server_id);
return sprintf('<a title="%s" href="%s"><img src="%s" alt="%s" /><br />%s</a>',
_('Logout of this server'),htmlspecialchars($href),'images/logout.png',_('logout'),_('logout'));
return sprintf('<a title="%s" href="%s"><img src="%s/%s" alt="%s" /><br />%s</a>',
_('Logout of this server'),htmlspecialchars($href),IMGDIR,'logout.png',_('logout'),_('logout'));
}
protected function draw_logged_in_dn() {
@@ -338,7 +339,7 @@ class HTMLTree extends Tree {
$href['expand'] = sprintf('cmd.php?cmd=expand&server_id=%s&amp;dn=%s',$ldapserver->server_id,$encoded_dn);
$href['collapse'] = sprintf('cmd.php?cmd=collapse&server_id=%s&amp;dn=%s',$ldapserver->server_id,$encoded_dn);
$href['edit'] = sprintf('cmd.php?cmd=template_engine&server_id=%s&amp;dn=%s',$ldapserver->server_id,$encoded_dn);
$img_src = sprintf('images/%s',$dnEntry->getIcon($ldapserver));
$img_src = sprintf('%s/%s',IMGDIR,$dnEntry->getIcon($ldapserver));
$rdn = get_rdn($dn);
echo '<tr class="option">';
@@ -362,15 +363,15 @@ class HTMLTree extends Tree {
# Is this node expanded? (deciding whether to draw "+" or "-")
if ($dnEntry->isOpened()) {
if (!$child_count && !$ldapserver->isShowCreateEnabled()) {
echo '<td class="expander"><img src="images/minus.png" alt="-" /></td>';
printf('<td class="expander"><img src="%s/minus.png" alt="-" /></td>',IMGDIR);
} else {
printf('<td class="expander"><a href="%s"><img src="images/minus.png" alt="-" /></a></td>',$href['collapse']);
printf('<td class="expander"><a href="%s"><img src="%s/minus.png" alt="-" /></a></td>',$href['collapse'],IMGDIR);
}
} else {
if (($child_count !== false) && (!$child_count) && (!$ldapserver->isShowCreateEnabled())) {
echo '<td class="expander"><img src="images/minus.png" alt="-" /></td>';
printf('<td class="expander"><img src="%s/minus.png" alt="-" /></td>',IMGDIR);
} else {
printf('<td class="expander"><a href="%s"><img src="images/plus.png" alt="+" /></a></td>',$href['expand']);
printf('<td class="expander"><a href="%s"><img src="%s/plus.png" alt="+" /></a></td>',$href['expand'],IMGDIR);
}
}
$colspan--;
@@ -458,7 +459,7 @@ class HTMLTree extends Tree {
echo '<td class="spacer"></td>';
echo '<td class="spacer"></td>';
printf('<td class="icon"><a href="%s"><img src="images/star.png" alt="%s" /></a></td>',$href,_('new'));
printf('<td class="icon"><a href="%s"><img src="%s/star.png" alt="%s" /></a></td>',$href,IMGDIR,_('new'));
printf('<td class="link" colspan="%s"><a href="%s" title="%s %s">%s</a></td>',
$this->getDepth()+3-$level-1-3,$href,_('Create a new entry in'),$rdn,_('Create new entry here'));
echo '</tr>';
@@ -473,7 +474,7 @@ class HTMLTree extends Tree {
sprintf('cmd.php?cmd=%s&server_id=%s',get_custom_file($ldapserver->server_id,'login_form',''),$ldapserver->server_id));
echo '<tr class="option"><td class="spacer"></td>';
printf('<td class="icon"><a href="%s"><img src="images/uid.png" alt="%s" /></a></td>',$href,_('login'));
printf('<td class="icon"><a href="%s"><img src="%s/uid.png" alt="%s" /></a></td>',$href,IMGDIR,_('login'));
printf('<td class="logged_in" colspan="%s"><a href="%s">%s</a></td>',$this->getDepth()+3-2,$href,_('Login').'...');
echo '</tr>';
@@ -489,7 +490,7 @@ class HTMLTree extends Tree {
protected function draw_logout_link() {
$ldapserver = $this->getLdapServer();
if ($ldapserver->auth_type != 'config') {
if (! in_array($ldapserver->auth_type,array('config','http'))) {
printf('<tr><td class="spacer"></td><td colspan="%s"><small><a href="cmd.php?cmd=%s&server_id=%s">%s</a></small></td></tr>',
$this->getDepth()+3-1,get_custom_file($ldapserver->server_id,'logout',''),$ldapserver->server_id,_('logout'));
}

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/PLMTree.php,v 1.2 2007/12/15 07:50:32 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/PLMTree.php,v 1.2.2.1 2008/11/29 11:33:53 wurley Exp $
require HTDOCDIR.JSDIR.'phplayersmenu/lib/PHPLIB.php';
require HTDOCDIR.JSDIR.'phplayersmenu/lib/layersmenu-common.inc.php';
@@ -41,8 +41,8 @@ class PLMTree extends HTMLTree {
if (! isset($tm)) {
$tm = new TreeMenu();
$tm->setDirroot(JSDIR.'phplayersmenu/');
$tm->setIcondir(HTDOCDIR.'/images/');
$tm->setIconwww('images/');
$tm->setIcondir(IMGDIR);
$tm->setIconwww(IMGDIR);
$tm->setImgwww(JSDIR.'phplayersmenu/menuimages/');
}

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/TemplateCreatingEntry.php,v 1.3.2.1 2007/12/26 09:26:33 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/TemplateCreatingEntry.php,v 1.3.2.2 2008/11/28 12:50:20 wurley Exp $
/**
* @package phpLDAPadmin
@@ -66,7 +66,10 @@ class TemplateCreatingEntry extends DefaultCreatingEntry {
}
public function hasDefaultTemplate() {
return $this->default_template;
if ($_SESSION[APPCONFIG]->GetValue('appearance','disable_default_template'))
return false;
else
return $this->default_template;
}
public function getAttributes() {

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/TemplateEditingEntry.php,v 1.3.2.2 2007/12/29 08:24:11 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/TemplateEditingEntry.php,v 1.3.2.4 2008/11/28 12:50:20 wurley Exp $
/**
* @package phpLDAPadmin
@@ -19,7 +19,7 @@ class TemplateEditingEntry extends DefaultEditingEntry {
parent::__construct($dn);
$this->templates = array();
$this->valid = false;
$this->default_template = false;
$this->default_template = true;
$this->selected_template = '';
}
@@ -81,7 +81,10 @@ class TemplateEditingEntry extends DefaultEditingEntry {
}
public function hasDefaultTemplate() {
return $this->default_template;
if ($_SESSION[APPCONFIG]->GetValue('appearance','disable_default_template'))
return false;
else
return $this->default_template;
}
public function getAttributes() {
@@ -105,12 +108,22 @@ class TemplateEditingEntry extends DefaultEditingEntry {
$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);
elseif (! is_array($int_attrs_vals)) $int_attrs_vals = array($int_attrs_vals);
$custom_int_attrs_vals = $ldapserver->getCustomDNSysAttrs($this->getDn());
if (! $custom_int_attrs_vals) $attrs_vals = array();
elseif (! is_array($custom_int_attrs_vals)) $custom_int_attrs_vals = array($custom_int_attrs_vals);
$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);
$custom_attrs_vals = $ldapserver->getCustomDNAttrs($this->getDn(),false,$_SESSION[APPCONFIG]->GetValue('deref','view'));
if (! $custom_attrs_vals) $attrs_vals = array();
elseif (! is_array($custom_attrs_vals)) $custom_attrs_vals = array($custom_attrs_vals);
$int_attrs_vals = array_merge($int_attrs_vals,$custom_int_attrs_vals);
$attrs_vals = array_merge($attrs_vals,$custom_attrs_vals);
$attrs_vals = array_merge($attrs_vals,$int_attrs_vals);
$selected_tmpl = isset($this->templates[$this->selected_template])

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/blowfish.php,v 1.4 2007/12/15 07:50:32 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/blowfish.php,v 1.4.2.1 2008/12/12 12:20:22 wurley Exp $
/**
* The Cipher_blowfish:: class implements the Cipher interface enryption data
@@ -13,7 +13,7 @@
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Mike Cochrane <mike@graftonhall.co.nz>
* @version $Revision: 1.4 $
* @version $Revision: 1.4.2.1 $
* @since Horde 2.2
* @package horde.cipher
*/
@@ -440,9 +440,9 @@ class Horde_Cipher_blowfish {
$unpack = unpack('N*', $block);
if (! is_array($unpack))
pla_error(
error(
sprintf('BLOWFISH: decryptBock()<br>We expected unpack to produce an array, but instead it produced [%s]. This function was entered with (%s,%s). If you think that this is a bug, then please tell the PLA developers how you got here. You are using PLA [%s,%s]',
serialize($unpack),rawurlencode($block),$key,pla_version(),phpversion()));
serialize($unpack),rawurlencode($block),$key,pla_version(),phpversion()),'error','index.php');
list($L, $R) = array_values($unpack);

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/common.php,v 1.80.2.9 2008/01/30 11:14:02 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/common.php,v 1.80.2.17 2008/12/13 08:57:09 wurley Exp $
/**
* Contains code to be executed at the top of each application page.
@@ -26,7 +26,9 @@ if (! defined('APPCONFIG'))
*/
$app['direct_scripts'] = array('cmd.php','index.php',
'view_jpeg_photo.php','entry_chooser.php',
'password_checker.php','download_binary_attr.php');
'password_checker.php','download_binary_attr.php',
'unserialize.php'
);
foreach ($app['direct_scripts'] as $script) {
$scriptOK = false;
@@ -132,20 +134,31 @@ error_reporting(E_ALL);
# Start our session.
pla_session_start();
# Initialise the hooks
require_once LIBDIR.'hooks.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');
header(sprintf('Location: index.php?URI=%s',base64_encode($_SERVER['QUERY_STRING'])));
die();
} else {
# SF Bug #1903987
if (! method_exists($_SESSION[APPCONFIG],'CheckCustom'))
error('Unknown situation, $_SESSION[APPCONFIG] exists, but method CheckCustom() does not','error',null,true,true);
# Check our custom variables.
# @todo: Change this so that we dont process a cached session.
$_SESSION[APPCONFIG]->CheckCustom();
}
# Check for safe mode.
if (ini_get('safe_mode') && ! get_request('cmd','GET'))
system_message(array(
'title'=>_('PHP Safe Mode'),
'body'=>_('You have PHP Safe Mode enabled. PLA may work unexpectedly in Safe Mode.'),
'type'=>'info'));
# Set our timezone, if it is specified in config.php
if ($_SESSION[APPCONFIG]->GetValue('appearance','timezone'))
date_default_timezone_set($_SESSION[APPCONFIG]->GetValue('appearance','timezone'));
@@ -163,11 +176,11 @@ if (DEBUG_ENABLED)
# Set our PHP timelimit.
if ($_SESSION[APPCONFIG]->GetValue('session','timelimit'))
set_time_limit($_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[APPCONFIG]->GetValue('session','timelimit'))
set_time_limit($_SESSION[APPCONFIG]->GetValue('session','timelimit') * 5);
@set_time_limit($_SESSION[APPCONFIG]->GetValue('session','timelimit') * 5);
/**
* Language configuration. Auto or specified?
@@ -204,7 +217,7 @@ if ($language == 'auto') {
(file_exists($language_dir) && is_readable($language_dir))) {
# Set language
putenv('LANG='.$HTTP_LANG); # e.g. LANG=de_DE
@putenv('LANG='.$HTTP_LANG); # e.g. LANG=de_DE
$HTTP_LANG .= '.UTF-8';
setlocale(LC_ALL,$HTTP_LANG); # set LC_ALL to de_DE
bindtextdomain('messages',LANGDIR);
@@ -225,7 +238,7 @@ if ($language == 'auto') {
$language = 'en_GB';
# Set language
putenv('LANG='.$language); # e.g. LANG=de_DE
@putenv('LANG='.$language); # e.g. LANG=de_DE
$language .= '.UTF-8';
setlocale(LC_ALL,$language); # set LC_ALL to de_DE
bindtextdomain('messages',LANGDIR);
@@ -261,16 +274,23 @@ if (isset($_REQUEST['server_id'])) {
* 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 ($ldapserver->haveAuthInfo() && isset($ldapserver->auth_type) && ! in_array($ldapserver->auth_type,array('config','http'))) {
/**
* 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('<script type="text/javascript" language="javascript">location.href=\'%s\'</script>',
htmlspecialchars($app['url_timeout']));
# If $session_timeout not defined, use ( session_cache_expire() - 1 )
$session_timeout = $ldapserver->session_timeout ? $ldapserver->session_timeout : session_cache_expire()-1;
system_message(array(
'title'=>_('Session Timed Out'),
'body'=>sprintf('%s %s %s',
_('Your Session timed out after'),$session_timeout,
_('min. of inactivity. You have been automatically logged out.')),
'type'=>'info'),'index.php');
die();
}
}

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/config_default.php,v 1.27.2.7 2008/01/30 11:16:02 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/config_default.php,v 1.27.2.9 2008/12/12 12:20:22 wurley Exp $
/**
* Configuration processing and defaults.
@@ -84,6 +84,10 @@ class Config {
'desc'=>'Array of attributes that should show a the time when showing the jscalendar',
'default'=>array(''));
$this->default->appearance['disable_default_template'] = array(
'desc'=>'Disabled the Default Template',
'default'=>false);
$this->default->appearance['hide_debug_info'] = array(
'desc'=>'Hide the features that may provide sensitive debugging information to the browser',
'default'=>true);
@@ -508,10 +512,10 @@ class Config {
if (! isset($config[$key]))
error(sprintf('A call was made in [%s] to GetValue requesting [%s] that isnt predefined.',
basename($_SERVER['PHP_SELF']),$key),'error',true);
basename($_SERVER['PHP_SELF']),$key),'error',null,true);
if (! isset($config[$key][$index]))
error(sprintf('Requesting an index [%s] in key [%s] that isnt predefined.',$index,$key),'error',true);
error(sprintf('Requesting an index [%s] in key [%s] that isnt predefined.',$index,$key),'error',null,true);
return isset($config[$key][$index]['value']) ? $config[$key][$index]['value'] : $config[$key][$index]['default'];
}
@@ -526,23 +530,23 @@ class Config {
if (isset($this->default->$masterkey)) {
if (! is_array($masterdetails))
error(sprintf('Error in configuration file, [%s] should be an ARRAY.',$masterdetails),'error',true);
error(sprintf('Error in configuration file, [%s] should be an ARRAY.',$masterdetails),'error',null,true);
foreach ($masterdetails as $key => $value) {
# Test that the key is correct.
if (! in_array($key,array_keys($this->default->$masterkey)))
error(sprintf('Error in configuration file, [%s] has not been defined as a configurable variable.',$key),'error',true);
error(sprintf('Error in configuration file, [%s] has not been defined as a configurable variable.',$key),'error',null,true);
# Test if its should be an array or not.
if (is_array($this->default->{$masterkey}[$key]['default']) && ! is_array($value))
error(sprintf('Error in configuration file, %s[\'%s\'] SHOULD be an array of values.',$masterkey,$key),'error',true);
error(sprintf('Error in configuration file, %s[\'%s\'] SHOULD be an array of values.',$masterkey,$key),'error',null,true);
if (! is_array($this->default->{$masterkey}[$key]['default']) && is_array($value))
error(sprintf('Error in configuration file, %s[\'%s\'] should NOT be an array of values.',$masterkey,$key),'error',true);
error(sprintf('Error in configuration file, %s[\'%s\'] should NOT be an array of values.',$masterkey,$key),'error',null,true);
}
} else {
error(sprintf('Error in configuration file, [%s] has not been defined as a MASTER configurable variable.',$masterkey),'error',true);
error(sprintf('Error in configuration file, [%s] has not been defined as a MASTER configurable variable.',$masterkey),'error',null,true);
}
}
}

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/emuhash_functions.php,v 1.6.10.1 2007/12/21 12:11:55 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/emuhash_functions.php,v 1.6.10.2 2008/12/12 12:20:23 wurley Exp $
/*******************************************************************************
* emuhash - partly emulates the php mhash functions
@@ -64,7 +64,7 @@ if( ! function_exists( 'mhash' ) && ! function_exists( 'mhash_keygen_s2k' ) ) {
$pwhandle = fopen( $tmpfile, "w" );
if( ! $pwhandle )
pla_error( "Unable to create a temporary file '$tmpfile' to create hashed password" );
error(sprintf('Unable to create a temporary file %s to create hashed password',$tmpfile) ,'error','index.php');
fwrite( $pwhandle, $password_clear );
fclose( $pwhandle );

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/export_functions.php,v 1.36.2.1 2007/12/26 09:26:33 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/export_functions.php,v 1.36.2.2 2008/12/12 12:20:23 wurley Exp $
/**
* Fuctions and classes for exporting ldap entries to others formats
@@ -249,8 +249,10 @@ class PlaLdapExporter extends PlaAbstractExporter {
# if no result, there is a something wrong
if (! $this->results && $this->ldap_info->ldapserver->errno())
pla_error(_('Encountered an error while performing search.'),$this->ldap_info->ldapserver->error(),
$this->ldap_info->ldapserver->errno());
system_message(array(
'title'=>_('Encountered an error while performing search.'),
'body'=>ldap_error_msg($this->ldap_info->ldapserver->error(),$this->ldap_info->ldapserver->errno()),
'type'=>'error'));
usort($this->results,'pla_compare_dns');
$this->num_entries = count($this->results);

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/functions.php,v 1.303.2.26 2008/01/30 11:17:00 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/functions.php,v 1.303.2.41 2008/12/12 12:52:26 wurley Exp $
/**
* A collection of common generic functions used throughout the application.
@@ -37,8 +37,6 @@ $app['function_files'] = array(
LIBDIR.'template_functions.php',
# Functions for hashing passwords with OpenSSL binary (only if mhash not present)
LIBDIR.'emuhash_functions.php',
# Functions for running various hooks
LIBDIR.'hooks.php',
# Functions for creating Samba passwords
LIBDIR.'createlm.php',
# Functions for timeout and automatic logout feature
@@ -66,6 +64,15 @@ function __autoload($className) {
'type'=>'error'));
}
/**
* If gettext is not installed, we will emulate it here.
*/
if (! function_exists('_')) {
function _($msg) {
return $msg;
}
}
/**
* Generic Utility Functions
*/
@@ -151,7 +158,7 @@ function pla_error_handler($errno,$errstr,$file,$lineno) {
}
# If this is a more serious error, call the error call.
error(sprintf('%s: %s',$errtype,$errstr),'error',true,true);
error(sprintf('%s: %s',$errtype,$errstr),'error',null,true,true);
}
/**
@@ -161,6 +168,11 @@ function pla_error_handler($errno,$errstr,$file,$lineno) {
* @return string The current version as read from the VERSION file.
*/
function pla_version() {
static $return = null;
if ($return)
return $return;
$version_file = realpath(LIBDIR.'../VERSION');
if (! file_exists($version_file))
$return = 'UNKNOWN';
@@ -229,27 +241,6 @@ function check_config($config_file) {
REQUIRED_PHP_VERSION,phpversion()),
'type'=>'error'));
# 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.<br /><br />Please install LDAP support before using phpLDAPadmin.<br /><small>(Dont forget to restart your web server afterwards)</small>',
'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.<br /><br />Please install XML support before using phpLDAPadmin.<br /><small>(Dont forget to restart your web server afterwards)</small>',
'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'=>_('PHP session configuration incorrect'),
'body'=>sprintf('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 "%s" is un-writable by the web server.',session_save_path()),
'type'=>'error'));
$config = new Config;
ob_start();
@@ -353,19 +344,19 @@ function check_config($config_file) {
*/
function cmd_control_pane() {
return array(
'home'=>array('link'=>sprintf('<a href="cmd.php?cmd=welcome" title="%s"><img src="images/home-big.png" alt="%s" /><br />%s</a>',_('Home'),_('Home'),_('Home'))),
'purge'=>array('link'=>sprintf('<a href="cmd.php?cmd=purge_cache" title="%s"><img src="images/trash-big.png" alt="%s" /><br />%s</a>',
_('Purge caches'),_('Purge all cached data in phpLDAPadmin, including server schemas.'),_('Purge caches'))),
'external_links:feature'=>array('link'=>sprintf('<a href="%s" target="new" title="%s"><img src="images/request-feature.png" alt="%s" /><br />%s</a>',
get_href('add_rfe'),_('Request feature'),_('light'),_('Request feature'))),
'external_links:bug'=>array('link'=>sprintf('<a href="%s" target="new" title="%s"><img src="images/bug-big.png" alt="%s" /><br />%s</a>',
get_href('add_bug'),_('Report a bug'),_('bug'),_('Report a bug'))),
'external_links:donation'=>array('link'=>sprintf('<a href="%s" target="new" title="%s"><img src="images/smile-big.png" alt="%s" /><br />%s</a>',
get_href('donate'),_('Donate'),_('Donate'),_('Donate'))),
'appearance:hide_debug_info'=>array('link'=>sprintf('<a href="cmd.php?cmd=show_cache" title="%s"><img src="images/debug-cache.png" alt="%s" /><br />%s</a>',
_('Show Cache'),_('Show Cache'),_('Show Cache'))),
'external_links:help'=>array('link'=>sprintf('<a href="%s" target="new" title="%s"><img src="images/help-big.png" alt="%s" /><br />%s</a>',
get_href('documentation'),_('Help'),_('Help'),_('Help')))
'home'=>array('link'=>sprintf('<a href="cmd.php?cmd=welcome" title="%s"><img src="%s/home-big.png" alt="%s" /><br />%s</a>',_('Home'),IMGDIR,_('Home'),_('Home'))),
'purge'=>array('link'=>sprintf('<a href="cmd.php?cmd=purge_cache" title="%s"><img src="%s/trash-big.png" alt="%s" /><br />%s</a>',
_('Purge caches'),IMGDIR,_('Purge all cached data in phpLDAPadmin, including server schemas.'),_('Purge caches'))),
'external_links:feature'=>array('link'=>sprintf('<a href="%s" target="new" title="%s"><img src="%s/request-feature.png" alt="%s" /><br />%s</a>',
get_href('add_rfe'),_('Request feature'),IMGDIR,_('light'),_('Request feature'))),
'external_links:bug'=>array('link'=>sprintf('<a href="%s" target="new" title="%s"><img src="%s/bug-big.png" alt="%s" /><br />%s</a>',
get_href('add_bug'),_('Report a bug'),IMGDIR,_('bug'),_('Report a bug'))),
'external_links:donation'=>array('link'=>sprintf('<a href="%s" target="new" title="%s"><img src="%s/smile-big.png" alt="%s" /><br />%s</a>',
get_href('donate'),_('Donate'),IMGDIR,_('Donate'),_('Donate'))),
'appearance:hide_debug_info'=>array('link'=>sprintf('<a href="cmd.php?cmd=show_cache" title="%s"><img src="%s/debug-cache.png" alt="%s" /><br />%s</a>',
_('Show Cache'),IMGDIR,_('Show Cache'),_('Show Cache'))),
'external_links:help'=>array('link'=>sprintf('<a href="%s" target="new" title="%s"><img src="%s/help-big.png" alt="%s" /><br />%s</a>',
get_href('documentation'),_('Help'),IMGDIR,_('Help'),_('Help')))
);
}
@@ -389,6 +380,14 @@ function debug_dump($variable,$die=false,$onlydebugaddr=false) {
die();
}
/**
* This function generates a backtrace
* @param boolean Whether to stop execution or not.
*/
function debug_dump_backtrace($msg='Calling BackTrace',$die=false) {
error($msg,'note',null,$die,true);
}
/**
* Debug Logging to Syslog
*
@@ -498,7 +497,7 @@ function debug_log($msg,$level=0) {
/**
* Display an error message in the system message panel of the page.
*/
function error($msg,$type='note',$fatal=false,$backtrace=false) {
function error($msg,$type='note',$redirect=null,$fatal=false,$backtrace=false) {
global $www;
global $counter;
@@ -510,7 +509,10 @@ function error($msg,$type='note',$fatal=false,$backtrace=false) {
if (! isset($www['page']))
$www['page'] = new page();
$www['page']->setsysmsg(array('title'=>_('Error'),'body'=>$msg,'type'=>$type));
if ($fatal)
$www['page']->setsysmsg(array('title'=>_('Error'),'body'=>$msg,'type'=>$type));
else
system_message(array('title'=>_('Error'),'body'=>$msg,'type'=>$type),$redirect);
# Spin loop detection
if ($counter++ > 20) {
@@ -525,24 +527,33 @@ function error($msg,$type='note',$fatal=false,$backtrace=false) {
$body = '<table class="result_table">';
$body .= "\n";
foreach (debug_backtrace() as $error => $line) {
$body .= sprintf('<tr class="hightlight"><td colspan="2"><b><small>%s</small></b></td><td>%s (%s)</td></tr>',
_('File'),isset($line['file']) ? $line['file'] : '',isset($line['line']) ? $line['line'] : '');
foreach (debug_backtrace() as $error => $line) {
$_SESSION['backtrace'][$error]['file'] = $line['file'];
$_SESSION['backtrace'][$error]['line'] = $line['line'];
$body .= sprintf('<tr class="hightlight"><td colspan="2"><b><small>%s</small></b></td><td>%s (%s)</td></tr>',
_('File'),isset($line['file']) ? $line['file'] : $last['file'],isset($line['line']) ? $line['line'] : '');
$_SESSION['backtrace'][$error]['function'] = $line['function'];
$body .= sprintf('<tr><td>&nbsp;</td><td><b><small>%s</small></b></td><td><small>%s',
_('Function'),$line['function']);
if (isset($line['args']))
if (isset($line['args'])) {
$display = strlen(serialize($line['args'])) < 50 ? serialize($line['args']) : substr(serialize($line['args']),0,50).'...<TRUNCATED>';
$_SESSION['backtrace'][$error]['args'] = $line['args'];
if (file_exists(LIBDIR.'../tools/unserialize.php'))
$body .= sprintf('&nbsp;(<a href="%s?var=%s">%s</a>)',
'/tools/unserialize.php',
htmlspecialchars(serialize($line['args'])),
htmlspecialchars(serialize($line['args'])));
$body .= sprintf('&nbsp;(<a href="%s?index=%s" target="backtrace">%s</a>)',
'../tools/unserialize.php',$error,htmlspecialchars($display));
else
$body .= sprintf('&nbsp;(%s)',htmlspecialchars(serialize($line['args'])));
$body .= sprintf('&nbsp;(%s)',htmlspecialchars($display));
}
$body .= '</small></td></tr>';
$body .= "\n";
if ($line['file'])
$last['file'] = $line['file'];
}
$body .= '</table>';
$body .= "\n";
$backtraceblock->SetBody($body);
@@ -609,7 +620,16 @@ function system_message($msg,$redirect=null) {
$_SESSION['sysmsg'][] = $msg;
if (get_request('redirect','GET'))
debug_dump_backtrace('Redirect Loop Detected',true);
if ($redirect) {
if (preg_match('/\?/',$redirect))
$redirect .= '&';
else
$redirect .= '?';
$redirect .= 'redirect=true';
header("Location: $redirect");
die();
}
@@ -1149,17 +1169,17 @@ function get_next_number(&$ldapserver,$startbase='',$type='uid',$increment=false
$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
error(sprintf(_('You specified the "auto_uid_number_mechanism" as "search" in your
configuration for server <b>%s</b>, but you did not specify the
"auto_uid_number_search_base". Please specify it before proceeding.'),$ldapserver->name));
"auto_uid_number_search_base". Please specify it before proceeding.'),$ldapserver->name),'error','index.php');
} else {
$base_dn = $startbase;
}
if (! $ldapserver->dnExists($base_dn))
pla_error(sprintf(_('Your phpLDAPadmin configuration specifies an invalid auto_uid_search_base for server %s'),
$ldapserver->name));
error(sprintf(_('Your phpLDAPadmin configuration specifies an invalid auto_uid_search_base for server %s'),
$ldapserver->name),'error','index.php');
$filter = '(|(uidNumber=*)(gidNumber=*))';
$results = array();
@@ -1170,12 +1190,13 @@ function get_next_number(&$ldapserver,$startbase='',$type='uid',$increment=false
$_SESSION[APPCONFIG]->ldapservers->GetValue($ldapserver->server_id,'auto_number','pass'));
if (! $con)
pla_error(sprintf(_('Unable to bind to <b>%s</b> with your with auto_uid credentials. Please check your configuration file.'),$ldapserver->name));
error(sprintf(_('Unable to bind to <b>%s</b> with your with auto_uid credentials. Please check your configuration file.'),$ldapserver->name),
'error','index.php');
$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.');
error(_('Untrapped error.'),'error','index.php');
foreach ($search as $dn => $attrs) {
$attrs = array_change_key_case($attrs);
@@ -1198,7 +1219,7 @@ function get_next_number(&$ldapserver,$startbase='',$type='uid',$increment=false
}
break;
default :
pla_error(sprintf('Unknown type [%s] in search',$type));
error(sprintf('Unknown type [%s] in search',$type),'error','index.php');
}
}
@@ -1234,13 +1255,15 @@ function get_next_number(&$ldapserver,$startbase='',$type='uid',$increment=false
$_SESSION[APPCONFIG]->ldapservers->GetValue($ldapserver->server_id,'auto_number','pass'));
if (! $con)
pla_error(sprintf(_('Unable to bind to <b>%s</b> with your with auto_uid credentials. Please check your configuration file.'),$ldapserver->name));
error(sprintf(_('Unable to bind to <b>%s</b> with your with auto_uid credentials. Please check your configuration file.'),$ldapserver->name),
'error','index.php');
# assume that uidpool dn is set in config file if no filter given
if (empty($filter))
if (empty($filter)) {
$uidpool_dn = $_SESSION[APPCONFIG]->ldapservers->GetValue($ldapserver->server_id,'auto_number','uidpool_dn');
$filter = '(objectclass=*)';
else {
} else {
$filter = str_replace(array('&amp;',':::'),array('&',','),$filter);
$dns = $ldapserver->search($con,$startbase,$filter,array('dn'),'sub');
@@ -1249,10 +1272,10 @@ function get_next_number(&$ldapserver,$startbase='',$type='uid',$increment=false
break;
case '0':
pla_error(_('Uidpool dn not found, please change filter parameter'));
error(_('Uidpool dn not found, please change filter parameter'),'error','index.php');
default:
pla_error(_('There is more than one dn for uidpool,please change filter parameter'));
error(_('There is more than one dn for uidpool,please change filter parameter'),'error','index.php');
}
list ($key,$attrs) = each($dns);
@@ -1260,31 +1283,38 @@ function get_next_number(&$ldapserver,$startbase='',$type='uid',$increment=false
$uidpool_dn = $attrs['dn'];
}
if (empty($uidpool_dn))
pla_error(_('uidpool_dn not found. Please check filter (arg 3) or set up uidpool_dn in config file'));
# Check that the UIDPOOL DN exists.
if (empty($uidpool_dn) || (! $ldapserver->dnExists($uidpool_dn)))
error(_('uidpool_dn not found. Please check filter (arg 3) or set up uidpool_dn in config file'),'error','index.php');
$attrs = array($type);
$key = strtolower($type);
$realkey = $type;
switch ($type) {
case 'uid' : $attr = 'uidnumber';
break;
case 'gid' : $attr = 'gidnumber';
break;
default :
error(_('Unknown uidpool type.'),'error','index.php');
}
$number = $ldapserver->search($con,$uidpool_dn,$filter,$attrs,'base');
list($rkey,$number) = each($number);
$number = array_change_key_case($number);
$number = $number[$key];
$number = $ldapserver->search($con,$uidpool_dn,$filter,array($attr),'base');
$numbers = array_change_key_case($number[$uidpool_dn]);
if (isset($increment) && ($increment == 'true')) {
$updatedattr = array ($key => $number + 1);
if (! isset($numbers[$attr]))
error(_('A query on the uidpool_dn did return a valid uidNumber.'),'error','index.php');
else
if ($increment) {
$updatedattr = array($attr => $numbers[$attr] + 1);
$ldapserver->modify($uidpool_dn,$updatedattr);
}
return $number;
return $numbers[$attr];
break;
# No other cases allowed. The user has an error in the configuration
default :
pla_error( sprintf( _('You specified an invalid value for auto_uid_number_mechanism ("%s")
in your configration. Only "uidpool" and "search" are valid.
Please correct this problem.') , $mechanism) );
error(sprintf(_('You specified an invalid value for auto_uid_number_mechanism ("%s") in your configration. Only "uidpool" and "search" are valid.
Please correct this problem.'),$mechanism),'error','index.php');
}
}
@@ -1380,7 +1410,7 @@ function get_icon( $ldapserver, $dn ) {
$cval = explode( '=', $tmp[0], 2 );
$cval = isset( $cval[1] ) ? $cval[1] : false;
if( $cval && false === strpos( $cval, ".." ) &&
file_exists( realpath( sprintf("./images/countries/%s.png",strtolower($cval)) ) ) )
file_exists(realpath(sprintf('%s/countries/%s.png',IMGDIR,strtolower($cval)))))
return sprintf("countries/%s.png",strtolower($cval));
@@ -1732,56 +1762,28 @@ function support_oid_to_text($oid_id) {
}
/**
* Prints an HTML-formatted error string. If you specify the optional
* parameters $ldap_err_msg and $ldap_err_no, this function will
* lookup the error number and display a verbose message in addition
* to the message you pass it.
*
* @param string $msg The error message to display.
* @param string $ldap_err_msg (optional) The error message supplied by the LDAP server
* @param string $ldap_err_no (optional) The hexadecimal error number string supplied by the LDAP server
* @param bool $fatal (optional) If true, phpLDAPadmin will terminate execution with the PHP die() function.
*
* @see die
* @see ldap_errno
* @see pla_verbose_error
* Print an LDAP error message
*/
function pla_error($msg,$ldap_err_msg=null,$ldap_err_no=-1,$fatal=true) {
if (defined('DEBUG_ENABLED') && (DEBUG_ENABLED))
debug_log('Entered with (%s,%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__,
$msg,$ldap_err_msg,$ldap_err_no,$fatal);
function ldap_error_msg($msg,$errnum) {
$body = '<table border=0>';
$title = '';
$errnum = ('0x'.str_pad(dechex($errnum),2,0,STR_PAD_LEFT));
$verbose_error = pla_verbose_error($errnum);
if (function_exists('syslog_err'))
syslog_err($msg);
$body .= sprintf('<tr><td><b>%s</b>:</td><td>%s</td></tr>',_('LDAP said'),htmlspecialchars($msg));
if ($ldap_err_msg)
$title = sprintf('<b>%s</b>: %s',_('LDAP said'),htmlspecialchars($ldap_err_msg));
if ($ldap_err_no != -1) {
$body = '<table>';
$ldap_err_no = ('0x'.str_pad(dechex($ldap_err_no),2,0,STR_PAD_LEFT));
$verbose_error = pla_verbose_error($ldap_err_no);
if ($verbose_error) {
$body .= sprintf('<tr><td colspan="2"><b>%s</b>: %s (%s)</td></tr>',_('Error number'),$ldap_err_no,$verbose_error['title']);
$body .= sprintf('<tr><td colspan="2"><b>%s</b>: %s</td></tr>',_('Description'),$verbose_error['desc']);
} else {
$body .= sprintf('<tr><td colspan="2"><b>%s</b>: %s</td></tr>',_('Error number'),$ldap_err_no);
$body .= sprintf('<tr><td colspan="2"><b>%s</b>: (%s)</td></tr>',_('Description'),_('no description available'));
}
$body .= '</table>';
if (function_exists('syslog_err'))
syslog_err(sprintf('%s %s',_('Error number'),$ldap_err_no));
if ($verbose_error) {
$body .= sprintf('<tr><td><b>%s</b>:</td><td>%s (%s)</td></tr>',_('Error number'),$errnum,$verbose_error['title']);
$body .= sprintf('<tr><td><b>%s</b>:</td><td>%s</td></tr>',_('Description'),$verbose_error['desc']);
} else {
$body = $msg;
$body .= sprintf('<tr><td><b>%s</b>:</td><td>%s</td></tr>',_('Error number'),$errnum);
$body .= sprintf('<tr><td><b>%s</b>:</td><td>(%s)</td></tr>',_('Description'),_('no description available'));
}
system_message(array('title'=>$title ? $title : 'Error','body'=>$body,'type'=>'error'),$fatal ? 'index.php' : null);
$body .= '</table>';
return $body;
}
/**
@@ -1832,7 +1834,7 @@ function draw_jpeg_photos($ldapserver,$dn,$attr_name='jpegPhoto',$draw_delete_bu
$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') );
error(_('Please set $jpeg_temp_dir to a writable directory in the phpLDAPadmin config.php'),'error','index.php');
if (! is_array($jpeg_data[$attr_name]))
$jpeg_data[$attr_name] = array($jpeg_data[$attr_name]);
@@ -1841,7 +1843,8 @@ function draw_jpeg_photos($ldapserver,$dn,$attr_name='jpegPhoto',$draw_delete_bu
$jpeg_filename = tempnam($jpeg_temp_dir.'/','pla');
$outjpeg = @fopen($jpeg_filename,'wb');
if (! $outjpeg)
pla_error(sprintf(_('Could not write to the $jpeg_temp_dir directory %s. Please verify that your web server can write files there.'),$jpeg_temp_dir));
error(sprintf(_('Could not write to the $jpeg_temp_dir directory %s. Please verify that your web server can write files there.'),$jpeg_temp_dir),
'error','index.php');
fwrite($outjpeg,$jpeg);
fclose ($outjpeg);
@@ -1902,7 +1905,7 @@ function draw_jpeg_photos($ldapserver,$dn,$attr_name='jpegPhoto',$draw_delete_bu
}
closedir($handle);
} else {
pla_error(sprintf('failed to open dir %s : permission denied', $jpeg_temp_dir), null, -1, false, false);
error(sprintf('failed to open dir %s : permission denied',$jpeg_temp_dir),'error');
}
}
@@ -1932,21 +1935,21 @@ function password_hash( $password_clear, $enc_type ) {
case 'ext_des':
// extended des crypt. see OpenBSD crypt man page.
if ( ! defined( 'CRYPT_EXT_DES' ) || CRYPT_EXT_DES == 0 )
pla_error( _('Your system crypt library does not support extended DES encryption.') );
error(_('Your system crypt library does not support extended DES encryption.'),'error','index.php');
$new_value = '{CRYPT}' . crypt( $password_clear, '_' . random_salt(8) );
break;
case 'md5crypt':
if( ! defined( 'CRYPT_MD5' ) || CRYPT_MD5 == 0 )
pla_error( _('Your system crypt library does not support md5crypt encryption.') );
error(_('Your system crypt library does not support md5crypt encryption.'),'error','index.php');
$new_value = '{CRYPT}' . crypt( $password_clear , '$1$' . random_salt(9) );
break;
case 'blowfish':
if( ! defined( 'CRYPT_BLOWFISH' ) || CRYPT_BLOWFISH == 0 )
pla_error( _('Your system crypt library does not support blowfish encryption.') );
error(_('Your system crypt library does not support blowfish encryption.'),'error','index.php');
// hardcoded to second blowfish version and set number of rounds
$new_value = '{CRYPT}' . crypt( $password_clear , '$2a$12$' . random_salt(13) );
@@ -1965,7 +1968,7 @@ function password_hash( $password_clear, $enc_type ) {
$new_value = '{SHA}' . base64_encode( mhash( MHASH_SHA1, $password_clear) );
} else {
pla_error( _('Your PHP install does not have the mhash() function. Cannot do SHA hashes.') );
error(_('Your PHP install does not have the mhash() function. Cannot do SHA hashes.'),'error','index.php');
}
break;
@@ -1976,7 +1979,7 @@ function password_hash( $password_clear, $enc_type ) {
$new_value = "{SSHA}".base64_encode( mhash( MHASH_SHA1, $password_clear.$salt ).$salt );
} else {
pla_error( _('Your PHP install does not have the mhash() function. Cannot do SHA hashes.') );
error(_('Your PHP install does not have the mhash() function. Cannot do SHA hashes.'),'error','index.php');
}
break;
@@ -1987,7 +1990,7 @@ function password_hash( $password_clear, $enc_type ) {
$new_value = "{SMD5}".base64_encode( mhash( MHASH_MD5, $password_clear.$salt ).$salt );
} else {
pla_error( _('Your PHP install does not have the mhash() function. Cannot do SHA hashes.') );
error(_('Your PHP install does not have the mhash() function. Cannot do SHA hashes.'),'error','index.php');
}
break;
@@ -2026,7 +2029,8 @@ function password_check( $cryptedpassword, $plainpassword ) {
// check php mhash support before using it
if( function_exists( 'mhash' ) ) {
$hash = base64_decode($cryptedpassword);
$salt = substr($hash, -4);
# OpenLDAP uses a 4 byte salt, SunDS uses an 8 byte salt - both from char 20.
$salt = substr($hash,20);
$new_hash = base64_encode( mhash( MHASH_SHA1, $plainpassword.$salt).$salt );
if( strcmp( $cryptedpassword, $new_hash ) == 0 )
@@ -2035,7 +2039,7 @@ function password_check( $cryptedpassword, $plainpassword ) {
return false;
} else {
pla_error( _('Your PHP install does not have the mhash() function. Cannot do SHA hashes.') );
error(_('Your PHP install does not have the mhash() function. Cannot do SHA hashes.'),'error','index.php');
}
break;
@@ -2053,7 +2057,7 @@ function password_check( $cryptedpassword, $plainpassword ) {
return false;
} else {
pla_error( _('Your PHP install does not have the mhash() function. Cannot do SHA hashes.') );
error(_('Your PHP install does not have the mhash() function. Cannot do SHA hashes.'),'error','index.php');
}
break;
@@ -2080,7 +2084,7 @@ function password_check( $cryptedpassword, $plainpassword ) {
// make sure that web server supports blowfish crypt
if( ! defined( 'CRYPT_BLOWFISH' ) || CRYPT_BLOWFISH == 0 )
pla_error( _('Your system crypt library does not support blowfish encryption.') );
error(_('Your system crypt library does not support blowfish encryption.'),'error','index.php');
list(,$version,$rounds,$salt_hash) = explode('$',$cryptedpassword);
@@ -2095,7 +2099,7 @@ function password_check( $cryptedpassword, $plainpassword ) {
// make sure that web server supports md5 crypt
if( ! defined( 'CRYPT_MD5' ) || CRYPT_MD5 == 0 )
pla_error( _('Your system crypt library does not support md5crypt encryption.') );
error(_('Your system crypt library does not support md5crypt encryption.'),'error','index.php');
list(,$type,$salt,$hash) = explode('$',$cryptedpassword);
@@ -2110,7 +2114,7 @@ function password_check( $cryptedpassword, $plainpassword ) {
// make sure that web server supports ext_des
if ( ! defined( 'CRYPT_EXT_DES' ) || CRYPT_EXT_DES == 0 )
pla_error( _('Your system crypt library does not support extended DES encryption.') );
error(_('Your system crypt library does not support extended DES encryption.'),'error','index.php');
if( crypt($plainpassword, $cryptedpassword ) == $cryptedpassword )
return true;
@@ -2218,7 +2222,7 @@ function draw_chooser_link( $form_element, $include_choose_text=true, $rdn="none
$title = _('Click to popup a dialog to select an entry (DN) graphically');
printf('<a href="%s" title="%s"><img class="chooser" src="images/find.png" alt="Find" /></a>',$href,$title);
printf('<a href="%s" title="%s"><img class="chooser" src="%s/find.png" alt="Find" /></a>',$href,$title,IMGDIR);
if ($include_choose_text)
printf('<span class="x-small"><a href="%s" title="%s">%s</a></span>',$href,$title,_('browse'));
}
@@ -2330,7 +2334,7 @@ function dn_unescape($dn) {
*/
function get_href($type,$extra_info='') {
$sf = 'https://sourceforge.net';
$pla = 'http://phpldapadmin.wiki.sourceforge.net';
$pla = 'http://phpldapadmin.sourceforge.net';
$group_id = '61828';
$bug_atid = '498546';
$rfe_atid = '498549';
@@ -2921,13 +2925,13 @@ function server_info_list($visible=false) {
return $server_info_list;
}
function enc_type_select_list($enc_type,$id,$attribute,$i) {
function enc_type_select_list($enc_type,$id,$attributename,$i) {
if (DEBUG_ENABLED)
debug_log('Entered with (%s,%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__,$enc_type,$id,$attribute,$i);
debug_log('Entered with (%s,%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__,$enc_type,$id,$attributename,$i);
$html = sprintf('<select id="%s_%s_%s" name="%s[%s][%s]">',
$id, htmlspecialchars($attribute->getName()), $i,
$id, htmlspecialchars($attribute->getName()), $i);
$id,htmlspecialchars($attributename),$i,
$id,htmlspecialchars($attributename),$i);
$html .= '<option>clear</option>';
foreach (array('crypt','ext_des','md5crypt','blowfish','md5','smd5','sha','ssha') as $option)
@@ -3201,7 +3205,7 @@ function draw_date_selector_link( $attr ) {
$href = "javascript:dateSelector('$attr');";
$title = _('Click to popup a dialog to select a date graphically');
printf('<a href="%s" title="%s"><img class="chooser" src="images/calendar.png" id="f_trigger_%s" style="cursor: pointer;" alt="Calendar" /></a>',$href,$title,$attr);
printf('<a href="%s" title="%s"><img class="chooser" src="%s/calendar.png" id="f_trigger_%s" style="cursor: pointer;" alt="Calendar" /></a>',$href,$title,IMGDIR,$attr);
}
/**
@@ -3223,4 +3227,13 @@ function random_junk() {
function htmlid($sid,$dn) {
return sprintf('SID%s:%s',$sid,preg_replace('/[\ =,]/','_',$dn));
}
/**
* Is compression enabled for output
*/
function isCompress() {
return (isset($_SESSION[APPCONFIG]) && $_SESSION[APPCONFIG]->GetValue('appearance','compress')
&& ! ini_get('zlib.output_compression')
&& eregi('gzip',$_SERVER['HTTP_ACCEPT_ENCODING']));
}
?>

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/hooks.php,v 1.10.2.1 2007/12/26 09:26:33 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/hooks.php,v 1.10.2.3 2008/11/28 04:44:54 wurley Exp $
/**
* Functions related to hooks management.
@@ -52,7 +52,6 @@ function sort_array_by_priority($a,$b) {
function run_hook($hook_name,$args) {
$hooks = isset($_SESSION[APPCONFIG]) ? $_SESSION[APPCONFIG]->hooks : array();
$debug = 0;
syslog_debug("Running hook $hook_name.");
if (! array_key_exists($hook_name,$hooks)) {
@@ -109,17 +108,17 @@ function run_hook($hook_name,$args) {
* called upon failure.
*/
function add_hook($hook_name,$priority,$hook_function,$rollback_function) {
global $config;
if (! array_key_exists($hook_name,$config->hooks)) {
$config->hooks[$hook_name] = array();
}
if (! array_key_exists($hook_name,$_SESSION[APPCONFIG]->hooks))
$_SESSION[APPCONFIG]->hooks[$hook_name] = array();
remove_hook($hook_name,-1,$hook_function,'');
array_push($config->hooks[$hook_name],array('priority' => $priority,'hook_function' => $hook_function,'rollback_function' => $rollback_function));
array_push($_SESSION[APPCONFIG]->hooks[$hook_name],array(
'priority' => $priority,
'hook_function' => $hook_function,
'rollback_function' => $rollback_function));
uasort($config->hooks[$hook_name],"sort_array_by_priority");
uasort($_SESSION[APPCONFIG]->hooks[$hook_name],'sort_array_by_priority');
}
/**
@@ -138,17 +137,15 @@ function add_hook($hook_name,$priority,$hook_function,$rollback_function) {
* as a rollback will be removed.
*/
function remove_hook($hook_name,$priority,$hook_function,$rollback_function) {
global $config;
if (array_key_exists($hook_name,$_SESSION[APPCONFIG]->hooks)) {
reset($_SESSION[APPCONFIG]->hooks[$hook_name]);
if (array_key_exists($hook_name,$config->hooks)) {
reset($config->hooks[$hook_name]);
while (list($key,$hook) = each($config->hooks[$hook_name])) {
while (list($key,$hook) = each($_SESSION[APPCONFIG]->hooks[$hook_name])) {
if (($priority >= 0 && $priority == $hook['priority']) ||
($hook_function && $hook_function == $hook['hook_function']) ||
($rollback_function && $rollback_function == $hook['rollback_function'])) {
unset($config->hooks[$hook_name][$key]);
unset($_SESSION[APPCONFIG]->hooks[$hook_name][$key]);
}
}
}
@@ -160,22 +157,18 @@ function remove_hook($hook_name,$priority,$hook_function,$rollback_function) {
* @param hook_name Name of hook to clear.
*/
function clear_hooks($hook_name) {
global $config;
if (!isset($config) && isset($_SESSION[APPCONFIG]))
$config = $_SESSION[APPCONFIG];
if (array_key_exists($hook_name,$config->hooks))
unset($config->hooks[$hook_name]);
if (array_key_exists($hook_name,$_SESSION[APPCONFIG]->hooks))
unset($_SESSION[APPCONFIG]->hooks[$hook_name]);
}
# Evaluating user-made hooks
if (is_dir(HOOKSDIR.'functions')) {
$dir = dir(HOOKSDIR.'functions');
while (false !== ($entry = $dir->read())) {
$filename = sprintf('%s/%s/%s',HOOKSDIR,'functions',$entry);
while (false !== ($hookfile = $dir->read())) {
$filename = sprintf('%s/%s/%s',HOOKSDIR,'functions',$hookfile);
if (is_file($filename) and eregi('php[0-9]?$',$entry))
if (is_file($filename) and eregi('php[0-9]?$',$hookfile))
require_once "$filename";
}

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/page.php,v 1.3.2.14 2008/01/27 11:57:39 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/page.php,v 1.3.2.16 2008/12/12 09:20:06 wurley Exp $
/**
* Page Rendering Functions
@@ -28,7 +28,7 @@ class page {
# Default Values for configurable items.
$this->_default['stylecss'] = CSSDIR.'style.css';
$this->_default['logo'] = IMGDIR.'logo_small.jpg';
$this->_default['logo'] = IMGDIR.'logo-small.png';
$this->_default['sysmsg']['error'] = IMGDIR.'warning.png';
$this->_default['sysmsg']['warn'] = IMGDIR.'notice.png';
$this->_default['sysmsg']['info'] = IMGDIR.'light-big.png';
@@ -45,11 +45,7 @@ class page {
}
header('Content-type: text/html; charset="UTF-8"');
if (isset($_SESSION[APPCONFIG])
&& $_SESSION[APPCONFIG]->GetValue('appearance','compress')
&& eregi('gzip',$_SERVER['HTTP_ACCEPT_ENCODING'])
&& ! ini_get('zlib.output_compression')) {
if (isCompress()) {
header('Content-Encoding: gzip');
if (DEBUG_ENABLED)
@@ -304,11 +300,7 @@ class page {
echo $object->draw('body');
}
if ($compress && ob_get_level() && isset($_SESSION[APPCONFIG])
&& $_SESSION[APPCONFIG]->GetValue('appearance','compress')
&& ! ini_get('zlib.output_compression')
&& eregi('gzip',$_SERVER['HTTP_ACCEPT_ENCODING'])) {
if ($compress && ob_get_level() && isCompress()) {
$output = ob_get_contents();
ob_end_clean();
@@ -324,7 +316,9 @@ class page {
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED)
debug_log('Entered with ()',129,__FILE__,__LINE__,__METHOD__);
printf('<tr class="foot"><td colspan=3>%s</td></tr>',pla_version());
printf('<tr class="foot"><td><small>%s</small></td><td colspan=2>%s</td></tr>',
isCompress() ? '[C]' : '&nbsp;',
pla_version());
}
public function display($filter=array()) {
@@ -384,11 +378,7 @@ class page {
echo '</html>';
# compress output
if (ob_get_level() && isset($_SESSION[APPCONFIG])
&& $_SESSION[APPCONFIG]->GetValue('appearance','compress')
&& ! ini_get('zlib.output_compression')
&& eregi('gzip',$_SERVER['HTTP_ACCEPT_ENCODING'])) {
if (ob_get_level() && isCompress()) {
$output = ob_get_contents();
ob_end_clean();

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/schema_functions.php,v 1.92 2007/12/15 07:50:32 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/schema_functions.php,v 1.92.2.1 2008/11/29 09:23:11 wurley Exp $
/**
* Classes and functions for fetching and parsing schema from an LDAP server.
@@ -61,6 +61,8 @@ class ObjectClass extends SchemaItem {
var $must_attrs;
# Arrays of attribute names that this objectClass allows, but does not require
var $may_attrs;
# Arrays of attribute names that this objectClass has been forced to MAY attrs, due to configuration
var $force_may;
# Boolean value indicating whether this objectClass is obsolete
var $is_obsolete;
# Array of objectClasses which inherit from this one (must be set at runtime explicitly by the caller)
@@ -76,6 +78,7 @@ class ObjectClass extends SchemaItem {
$this->sup_classes = array();
$this->type = $ldapserver->schema_oclass_default;
$this->must_attrs = array();
$this->force_may = array();
$this->may_attrs = array();
$this->is_obsolete = false;
$this->children_objectclasses = array();
@@ -265,11 +268,17 @@ class ObjectClass extends SchemaItem {
foreach ($attrs as $string) {
$attr = new ObjectClass_ObjectClassAttribute($string,$this->name);
array_push($this->must_attrs,$attr);
if ($ldapserver->isForceMay($attr->name)) {
array_push($this->force_may,$attr);
array_push($this->may_attrs,$attr);
} else
array_push($this->must_attrs,$attr);
}
if (DEBUG_ENABLED)
debug_log('Case MUST returned (%s)',8,__FILE__,__LINE__,__METHOD__,$this->must_attrs);
debug_log('Case MUST returned (%s) (%s)',8,__FILE__,__LINE__,__METHOD__,$this->must_attrs,$this->force_may);
break;
case 'MAY':
@@ -304,8 +313,8 @@ class ObjectClass extends SchemaItem {
$this->description = preg_replace("/\'$/",'',$this->description);
if (DEBUG_ENABLED)
debug_log('Returning () - NAME (%s), DESCRIPTION (%s), MUST (%s), MAY (%s)',9,__FILE__,__LINE__,__METHOD__,
$this->name,$this->description,$this->must_attrs,$this->may_attrs);
debug_log('Returning () - NAME (%s), DESCRIPTION (%s), MUST (%s), MAY (%s), FORCE MAY (%s)',9,__FILE__,__LINE__,__METHOD__,
$this->name,$this->description,$this->must_attrs,$this->may_attrs,$this->force_may);
}
/**
@@ -547,6 +556,17 @@ class ObjectClass extends SchemaItem {
$this->may_attrs = array_values(array_unique(array_merge($this->may_attrs,$new_may_attrs)));
}
/**
* Determine if an array is listed in the force_may attrs
*/
function isForceMay($attr) {
foreach ($this->force_may as $forcemay)
if ($forcemay->getName() == $attr)
return true;
return false;
}
}
/**
@@ -628,6 +648,8 @@ class AttributeType extends SchemaItem {
var $used_in_object_classes;
# A list of object class names that require this attribute type.
var $required_by_object_classes;
# This attribute has been forced a MAY attribute by the configuration.
var $forced_as_may;
/**
* Initialize the class' member variables
@@ -654,10 +676,11 @@ class AttributeType extends SchemaItem {
$this->type = null;
$this->used_in_object_classes = array();
$this->required_by_object_classes = array();
$this->forced_as_may = false;
}
/**
* Creates a new AttributeType objcet from a raw LDAP AttributeType string.
* Creates a new AttributeType object from a raw LDAP AttributeType string.
*/
function AttributeType($raw_ldap_attr_string) {
if (DEBUG_ENABLED)
@@ -1108,6 +1131,13 @@ class AttributeType extends SchemaItem {
function getRequiredByObjectClasses() {
return $this->required_by_object_classes;
}
/**
* This function will mark this attribute as a forced MAY attribute
*/
function setForceMay() {
$this->forced_as_may = true;
}
}
/**

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/search_results_list.php,v 1.7.2.3 2008/01/13 05:37:02 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/search_results_list.php,v 1.7.2.5 2008/11/30 13:19:49 wurley Exp $
/**
* @package phpLDAPadmin
@@ -20,7 +20,7 @@ foreach ($results as $dn => $dndetails) {
echo '<table class="result" border=0>';
echo '<tr class="list_title">';
printf('<td class="icon"><img src="images/%s" alt="icon" /></td>',get_icon($ldapserver,$dn));
printf('<td class="icon"><img src="%s/%s" alt="icon" /></td>',IMGDIR,get_icon($ldapserver,$dn));
$formatted_dn = get_rdn($dn);
if (!$_SESSION[APPCONFIG]->isCommandAvailable('schema')) {

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/search_results_table.php,v 1.9.2.3 2008/01/13 05:37:02 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/search_results_table.php,v 1.9.2.4 2008/11/29 11:33:53 wurley Exp $
/**
* Incoming variables (among others)
@@ -31,7 +31,7 @@ foreach ($results as $dn => $dndetails) {
$edit_url = sprintf('cmd.php?cmd=template_engine&amp;server_id=%s&amp;dn=%s',$ldapserver->server_id,rawurlencode($dn));
$attrs_display = array();
$attrs_display[''] = sprintf('<center><a href="%s"><img src="images/%s" alt="icon" /></a></center>',$edit_url,get_icon($ldapserver,$dn));
$attrs_display[''] = sprintf('<center><a href="%s"><img src="%s/%s" alt="icon" /></a></center>',$edit_url,IMGDIR,get_icon($ldapserver,$dn));
if ($_SESSION[APPCONFIG]->isCommandAvailable('schema')) {
$dn_display = strlen($dn) > 40

View File

@@ -1,5 +1,5 @@
<?php
/* $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/server_functions.php,v 1.51.2.7 2008/01/31 12:34:26 wurley Exp $ */
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/server_functions.php,v 1.51.2.15 2008/12/13 08:57:41 wurley Exp $
/**
* Classes and functions for LDAP server configuration and capability
@@ -77,7 +77,7 @@ class LDAPserver {
$return = false;
# For session or cookie auth_types, we check the session or cookie to see if a user has logged in.
if (in_array($this->auth_type,array('session','cookie','http'))) {
if (in_array($this->auth_type,array('session','cookie'))) {
/* we don't look at getLoggedInPass() cause it may be null for anonymous binds
* getLoggedInDN() will never return null if someone is really logged in. */
@@ -88,11 +88,30 @@ class LDAPserver {
/* whether or not the login_dn or pass is specified, we return
* true here. (if they are blank, we do an anonymous bind anyway) */
} elseif ($this->auth_type == 'http') {
# This is temp, to avoid multiple displays of this message
static $shown = false;
if (! $this->getLoggedInDN() && ! $shown) {
system_message(array(
'title'=>_('No HTTP AUTH information'),
'body'=>_('Your configuration file has authentication set to http_auth, however, there was none presented to phpLDAPadmin'),
'type'=>'error'));
$shown = true;
}
if ($this->getLoggedInDN())
$return = true;
else
$return = false;
} elseif ($this->auth_type == 'config') {
$return = true;
} else {
error(sprintf(_('Error: You have an error in your config file. The only three allowed values for auth_type in the $servers section are \'session\', \'cookie\', and \'config\'. You entered \'%s\', which is not allowed.'),htmlspecialchars($this->auth_type)),'error',true);
error(sprintf(_('Error: You have an error in your config file. The only three allowed values for auth_type in the $servers section are \'session\', \'cookie\', and \'config\'. You entered \'%s\', which is not allowed.'),htmlspecialchars($this->auth_type)),'error',null,true);
}
if (DEBUG_ENABLED)
@@ -160,6 +179,15 @@ class LDAPserver {
$this->connection[$connect_id]['login_pass'] ? md5($this->connection[$connect_id]['login_pass']) : '');
}
} elseif ($this->auth_type == 'http') {
if (! $dn && ! $pass)
$connect_id = 'anonymous';
else {
$this->connection[$connect_id]['login_dn'] = $dn;
$this->connection[$connect_id]['login_pass'] = $pass;
}
} else {
if (DEBUG_ENABLED)
debug_log('This IS some other login',80,__FILE__,__LINE__,__METHOD__);
@@ -262,7 +290,7 @@ class LDAPserver {
# Try to fire up TLS is specified in the config
if ($this->isTLSEnabled()) {
function_exists('ldap_start_tls') or error(_('Your PHP install does not support TLS.'),'error');
@ldap_start_tls($resource) or error(_('Could not start TLS. Please check your LDAP server configuration.'),'error',true);
@ldap_start_tls($resource) or error(_('Could not start TLS. Please check your LDAP server configuration.'),'error',null,true);
}
$bind_result = false;
@@ -309,9 +337,9 @@ class LDAPserver {
# invalid regex?
if (is_null($authz_id)) {
pla_error(sprintf(_('It seems that sasl_authz_id_regex "%s"." contains invalid PCRE regular expression.'),
$this->connection[$connect_id]['sasl_authz_id_regex']).
((isset($php_errormsg)) ? ' Error message: '.$php_errormsg : ''));
error(sprintf(_('It seems that sasl_authz_id_regex "%s"." contains invalid PCRE regular expression.'),
$this->connection[$connect_id]['sasl_authz_id_regex']).((isset($php_errormsg)) ? ' Error message: '.$php_errormsg : '')
,'error','index.php');
}
}
@@ -696,8 +724,8 @@ class LDAPserver {
# This error message is not localized as only developers should ever see it
if (! in_array($schema_to_fetch,$valid_schema_to_fetch))
pla_error(sprintf('Bad parameter provided to function to %s::getRawSchema(). "%s" is not valid for the schema_to_fetch parameter.',
get_class($this),htmlspecialchars($schema_to_fetch)));
error(sprintf('Bad parameter provided to function to %s::getRawSchema(). "%s" is not valid for the schema_to_fetch parameter.',
get_class($this),htmlspecialchars($schema_to_fetch)),'error','index.php');
# Try to get the schema DN from the specified entry.
$schema_dn = $this->getSchemaDN($dn);
@@ -841,7 +869,7 @@ class LDAPserver {
# We need to have objectclasses and attribues, so display an error, asking the user to get us this information.
if (in_array($schema_to_fetch,$schema_error_message_array)) {
pla_error(sprintf('Our attempts to find your SCHEMA for "%s" have FAILED.<br /><br />%s',$schema_to_fetch,$schema_error_message));
error(sprintf('Our attempts to find your SCHEMA for "%s" have FAILED.<br /><br />%s',$schema_to_fetch,$schema_error_message),'error','index.php');
} else {
$return = false;
@@ -856,8 +884,8 @@ class LDAPserver {
# Did we get something unrecognizable?
if (gettype($schema_search) != 'resource') {
if (in_array($schema_to_fetch,$schema_error_message_array)) {
pla_error(sprintf('Our attempts to find your SCHEMA for "%s" has return UNEXPECTED results.<br /><br /><small>(We expected a "resource" for $schema_search, instead, we got (%s))</small><br /><br />%s<br /><br />Dump of $schema_search:<hr /><pre><small>%s</small></pre>',
$schema_to_fetch,gettype($schema_search),$schema_error_message,serialize($schema_search)));
error(sprintf('Our attempts to find your SCHEMA for "%s" has return UNEXPECTED results.<br /><br /><small>(We expected a "resource" for $schema_search, instead, we got (%s))</small><br /><br />%s<br /><br />Dump of $schema_search:<hr /><pre><small>%s</small></pre>',
$schema_to_fetch,gettype($schema_search),$schema_error_message,serialize($schema_search)),'error','index.php');
} else {
$return = false;
@@ -879,8 +907,8 @@ class LDAPserver {
if(! isset($schema_entries[0][$schema_to_fetch])) {
if (in_array($schema_to_fetch,$schema_error_message_array)) {
pla_error(sprintf('Our attempts to find your SCHEMA for "%s" has return UNEXPECTED results.<br /><br /><small>(We expected a "%s" in the $schema array but it wasnt there.)</small><br /><br />%s<br /><br />Dump of $schema_search:<hr /><pre><small>%s</small></pre>',
$schema_to_fetch,gettype($schema_search),$schema_error_message,serialize($schema_entries)));
error(sprintf('Our attempts to find your SCHEMA for "%s" has return UNEXPECTED results.<br /><br /><small>(We expected a "%s" in the $schema array but it wasnt there.)</small><br /><br />%s<br /><br />Dump of $schema_search:<hr /><pre><small>%s</small></pre>',
$schema_to_fetch,gettype($schema_search),$schema_error_message,serialize($schema_entries)),'error','index.php');
} else {
$return = false;
@@ -1243,8 +1271,8 @@ class LDAPserver {
}
if (! isset($attrs[strtolower($sup_attr_name)])){
pla_error(sprintf('Schema error: attributeType "%s" inherits from "%s", but attributeType "%s" does not exist.',
$attr->getName(),$sup_attr_name,$sup_attr_name));
error(sprintf('Schema error: attributeType "%s" inherits from "%s", but attributeType "%s" does not exist.',
$attr->getName(),$sup_attr_name,$sup_attr_name),'error','index.php');
return;
}
@@ -1325,6 +1353,15 @@ class LDAPserver {
}
}
# Force May
foreach ($object_class->force_may as $attr_name) {
if (isset($attrs[strtolower($attr_name->name)]))
$attrs[strtolower($attr_name->name)]->setForceMay();
else {
#echo "Warning, attr not set: $attr_name<br />";
}
}
}
$return = $attrs;
@@ -1521,7 +1558,10 @@ class LDAPserver {
function rename($dn,$new_rdn,$container,$deleteoldrdn) {
$this->lastop = 'write';
if (! @ldap_rename($this->connect(true,$this->lastop,false,false),$dn,$new_rdn,$container,$deleteoldrdn)) {
pla_error(_('Could not rename the entry'),$this->error(),$this->errno(),false);
system_message(array(
'title'=>_('Could not rename the entry.'),
'body'=>ldap_error_msg($this->error(),$this->errno()),
'type'=>'error'));
} else {
# Update the tree
@@ -1778,7 +1818,7 @@ class LDAPserver {
if ($attr = ldap_first_attribute($resource,$entry_id,$attrs)) {
if (DEBUG_ENABLED)
debug_log('Processing ATTR [%s].',64,__FILE__,__LINE__,__METHOD__,$attr);
debug_log('Processing First ATTR [%s].',64,__FILE__,__LINE__,__METHOD__,$attr);
# Iterate over the attributes
while ($attr) {
@@ -1797,6 +1837,10 @@ class LDAPserver {
$return[$dn][$attr] = $values;
$attr = ldap_next_attribute($resource,$entry_id,$attrs);
if (DEBUG_ENABLED)
debug_log('Processing Next ATTR [%s].',64,__FILE__,__LINE__,__METHOD__,$attr);
} # end while attr
}
@@ -1972,7 +2016,7 @@ class LDAPserver {
break;
default:
pla_error(sprintf(_('Unknown auth_type: %s'),htmlspecialchars($this->auth_type)));
error(sprintf(_('Unknown auth_type: %s'),htmlspecialchars($this->auth_type)),'error','index.php');
break;
}
}
@@ -2044,7 +2088,7 @@ class LDAPserver {
break;
default:
pla_error(sprintf(_('Unknown auth_type: %s'),htmlspecialchars($auth_type)));
error(sprintf(_('Unknown auth_type: %s'),htmlspecialchars($auth_type)),'error','index.php');
break;
}
}
@@ -2153,7 +2197,7 @@ class LDAPserver {
# See what the server schema says about this attribute
$schema_attr = $this->getSchemaAttribute($attr_name);
if (! $schema_attr) {
if (! is_object($schema_attr)) {
/* Strangely, some attributeTypes may not show up in the server
* schema. This behavior has been observed in MS Active Directory.*/
@@ -2172,6 +2216,7 @@ class LDAPserver {
strcasecmp($attr_name,'networkaddress') == 0 ||
strcasecmp($attr_name,'objectGUID') == 0 ||
strcasecmp($attr_name,'objectSID') == 0 ||
strcasecmp($attr_name,'jpegPhoto') == 0 ||
$syntax == '1.3.6.1.4.1.1466.115.121.1.10' ||
$syntax == '1.3.6.1.4.1.1466.115.121.1.28' ||
$syntax == '1.3.6.1.4.1.1466.115.121.1.5' ||
@@ -2338,7 +2383,7 @@ class LDAPserver {
break;
default:
pla_error(sprintf(_('Unknown auth_type: %s'),htmlspecialchars($this->auth_type)));
error(sprintf(_('Unknown auth_type: %s'),htmlspecialchars($this->auth_type)),'error','index.php');
}
}
@@ -2385,11 +2430,11 @@ class LDAPserver {
break;
case 'http':
if (isset($_SERVER['PHP_AUTH_USER']))
{
if (isset($_SERVER['PHP_AUTH_USER'])) {
if ($this->isLoginAttrEnabled()) {
if ($this->isLoginStringEnabled()) {
$return = str_replace('<username>',$_SERVER['PHP_AUTH_USER'],$this->getLoginString());
} else {
if ($this->login_dn)
$this->connect(true,'user',false,true,$this->login_dn,$this->login_pass);
@@ -2406,38 +2451,40 @@ class LDAPserver {
$result = $this->search(null,$base_dn,$filter,array('dn'));
$result = array_pop($result);
$return = $result['dn'];
if ($return) break;
if ($return)
break;
}
}
} else {
$return = $_SERVER['PHP_AUTH_USER'];
}
}
else
} else
$return = false;
if ($return) {
$dn = $return;
$pass = '';
if (isset($_SERVER['PHP_AUTH_PW'])) $pass = $_SERVER['PHP_AUTH_PW'];
if (isset($_SERVER['PHP_AUTH_PW']))
$pass = $_SERVER['PHP_AUTH_PW'];
if ($this->userIsAllowedLogin($dn)) {
$ds = $this->connect(false,'user',true,true,$dn,$pass);
if (! is_resource($ds)) {
system_message(array(
'title'=>_('Authenticate to server'),
'body'=>_('Bad username or password. Please try again.'),
'type'=>'error'),
sprintf('cmd.php?cmd=login_form&server_id=%s',$this->server_id));
syslog_notice("Authentification FAILED for $dn");
}
$this->auth_type = 'config';
$this->login_dn = $dn;
$this->login_pass = $pass;
} else {
$this->auth_type = 'session';
$return = false;
}
}
@@ -2449,7 +2496,7 @@ class LDAPserver {
break;
default:
pla_error(sprintf(_('Unknown auth_type: %s'),htmlspecialchars($auth_type)));
error(sprintf(_('Unknown auth_type: %s'),htmlspecialchars($auth_type)),'error','index.php');
}
}
@@ -2509,6 +2556,108 @@ class LDAPserver {
return $return_attrs;
}
/**
* Gets the user defined operational attributes for an entry. Given a DN, this function fetches that entry's
* operational (ie, system or internal) attributes.
*
* These attributes should be treated as internal attributes.
*
* The returned associative array is of this form:
* <code>
* Array (
* [nsroleDN] => Array (
* [0] => "cn=nsManagedDisabledRole,dc=example,dc=com",
* [1] => "cn=nsDisabledRole,dc=example,dc=com",
* [2] => "cn=nsAdminRole,dc=example,dc=com"
* )
* [passwordExpirationTime]=> Array (
* [0] => "20080314183611Z"
* )
* [passwordAllowChangeTime] => Array (
* [0] => "20080116175354Z"
* )
* )
* </code>
*
* @param string $dn The DN of the entry whose interal attributes are desired.
* @param int $deref For aliases and referrals, this parameter specifies whether to
* follow references to the referenced DN or to fetch the attributes for
* the referencing DN. See http://php.net/ldap_search for the 4 valid
* options.
* @return array An associative array whose keys are attribute names and whose values
* are arrays of values for the aforementioned attribute.
*/
function getCustomDNSysAttrs($dn,$deref=LDAP_DEREF_NEVER) {
if (DEBUG_ENABLED)
debug_log('Entered with (%s,%s)',17,__FILE__,__LINE__,__METHOD__,$dn,$deref);
$attrs = $this->custom_sys_attrs;
$search = $this->search(null,$dn,'(objectClass=*)',$attrs,'base',false,$deref);
$return_attrs = array();
foreach ($search as $dn => $attrs)
foreach ($attrs as $attr => $value) {
if (is_array($value)) {
foreach ($value as $val) $return_attrs[$attr][] = $val;
} else {
$return_attrs[$attr][] = $value;
}
}
return $return_attrs;
}
/**
* Gets the user defined operational attributes for an entry. Given a DN, this function fetches that entry's
* operational (ie, system or internal) attributes.
*
* These attributes should be treated as regular attributes, not as internal attributes.
*
* The returned associative array is of this form:
* <code>
* Array (
* [nsroleDN] => Array (
* [0] => "cn=nsManagedDisabledRole,dc=example,dc=com",
* [1] => "cn=nsDisabledRole,dc=example,dc=com",
* [2] => "cn=nsAdminRole,dc=example,dc=com"
* )
* [passwordExpirationTime]=> Array (
* [0] => "20080314183611Z"
* )
* [passwordAllowChangeTime] => Array (
* [0] => "20080116175354Z"
* )
* )
* </code>
*
* @param string $dn The DN of the entry whose interal attributes are desired.
* @param int $deref For aliases and referrals, this parameter specifies whether to
* follow references to the referenced DN or to fetch the attributes for
* the referencing DN. See http://php.net/ldap_search for the 4 valid
* options.
* @return array An associative array whose keys are attribute names and whose values
* are arrays of values for the aforementioned attribute.
*/
function getCustomDNAttrs($dn,$deref=LDAP_DEREF_NEVER) {
if (DEBUG_ENABLED)
debug_log('Entered with (%s,%s)',17,__FILE__,__LINE__,__METHOD__,$dn,$deref);
$attrs = $this->custom_attrs;
$search = $this->search(null,$dn,'(objectClass=*)',$attrs,'base',false,$deref);
$return_attrs = array();
foreach ($search as $dn => $attrs)
foreach ($attrs as $attr => $value) {
if (is_array($value)) {
foreach ($value as $val) $return_attrs[$attr][] = $val;
} else {
$return_attrs[$attr][] = $value;
}
}
return $return_attrs;
}
/**
* Gets the attributes/values of an entry. Returns an associative array whose
* keys are attribute value names and whose values are arrays of values for
@@ -2733,7 +2882,8 @@ class LDAPserver {
$_SESSION[APPCONFIG]->ldapservers->GetValue($this->server_id,'unique_attrs','pass'));
if (! $con)
pla_error(sprintf(_('Unable to bind to <b>%s</b> with your with unique_attrs credentials. Please check your configuration file.'),$this->name));
error(sprintf(_('Unable to bind to <b>%s</b> with your with unique_attrs credentials. Please check your configuration file.'),$this->name),
'error','index.php');
# Build our search filter to double check each attribute.
$searchfilter = '(|';
@@ -2895,6 +3045,20 @@ class LDAPserver {
return null;
}
/**
* This function determines if the specified attribute is contained in the force_may list
* as configured in config.php.
*
* @return bool True if the specified attribute is in the $force_may list and false
* otherwise.
*/
function isForceMay($attr_name) {
if (DEBUG_ENABLED)
debug_log('Entered with (%s)',17,__FILE__,__LINE__,__METHOD__,$attr_name);
return in_array($attr_name,$this->force_may);
}
}
class LDAPservers {
@@ -3052,6 +3216,15 @@ class LDAPservers {
'desc'=>'Password for DN to use when evaluating numbers',
'default'=>null);
$this->default->auto_number['uidpool_dn'] = array(
'desc'=>'DN to use for the uidPool',
'default'=>'cn=uidPool,dc=example,dc=com');
$this->default->force_may['attrs'] = array(
'desc'=>'Attributes to force as MAY attributes, even though the schema may indicate that they are MUST attributes',
'var' => 'force_may',
'default'=>array());
$this->default->unique_attrs['dn'] = array(
'desc'=>'DN to use when evaluating uniqueness',
'default'=>null);
@@ -3098,6 +3271,16 @@ class LDAPservers {
'desc' => 'SASL properties',
'var' => 'sasl_props',
'default' => null);
$this->default->server['custom_attrs'] = array(
'desc' => 'Custom operational attributes to be treated as regular attributes',
'var' => 'custom_attrs',
'default' => array(''));
$this->default->server['custom_sys_attrs'] = array(
'desc' => 'Custom operational attributes to be treated as internal attributes',
'var' => 'custom_sys_attrs',
'default' => array(''));
}
function SetValue($server_id,$key,$index,$value) {
@@ -3106,21 +3289,21 @@ class LDAPservers {
$server_id,$key,$index,$value);
if (! isset($this->default->$key))
pla_error("ERROR: Setting a key [$key] that isnt predefined.");
error("ERROR: Setting a key [$key] that isnt predefined.",'error','index.php');
else
$default = $this->default->$key;
if (! isset($default[$index]))
pla_error("ERROR: Setting a index [$index] that isnt predefined.");
error("ERROR: Setting a index [$index] that isnt predefined.",'error','index.php');
else
$default = $default[$index];
# Test if its should be an array or not.
if (is_array($default['default']) && ! is_array($value))
pla_error("Error in configuration file, {$key}['$index'] SHOULD be an array of values.");
error("Error in configuration file, {$key}['$index'] SHOULD be an array of values.",'error','index.php');
if (! is_array($default['default']) && is_array($value))
pla_error("Error in configuration file, {$key}['$index'] should NOT be an array of values.");
error("Error in configuration file, {$key}['$index'] should NOT be an array of values.",'error','index.php');
# Some special processing.
# @todo: Add ldaps port details here.

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/session_functions.php,v 1.18.2.4 2008/01/13 06:35:51 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/session_functions.php,v 1.18.2.5 2008/12/12 12:20:23 wurley Exp $
/**
* A collection of functions to handle sessions throughout phpLDAPadmin.
@@ -117,7 +117,7 @@ function pla_session_start() {
@header('Cache-control: private'); // IE 6 Fix
if (pla_session_id_paranoid && ! pla_session_verify_id())
pla_error('Session inconsistent or session timeout');
error('Session inconsistent or session timeout','error','index.php');
# Check we have the correct version of the SESSION cache
if (isset($_SESSION['cache']) || isset($_SESSION[pla_session_id_init])) {

View File

@@ -1,5 +1,5 @@
<?php
/* $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/template_functions.php,v 1.43.2.3 2008/01/04 14:29:44 wurley Exp $ */
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/template_functions.php,v 1.43.2.8 2008/12/12 12:20:23 wurley Exp $
/**
* Classes and functions for the template engine.ation and capability
@@ -42,9 +42,10 @@ class xml2array {
$this->strXmlData = xml_parse($this->resParser,$strInputXML);
if (! $this->strXmlData)
die(sprintf('XML error: %s at line %d',
die(sprintf('XML error: %s at line %d in file %s',
xml_error_string(xml_get_error_code($this->resParser)),
xml_get_current_line_number($this->resParser)));
xml_get_current_line_number($this->resParser),
$file));
xml_parser_free($this->resParser);
@@ -113,7 +114,7 @@ class Templates {
while( ( $file = readdir( $dir ) ) !== false ) {
if (! preg_match('/.xml$/',$file)) continue;
if ($_SESSION['plaConfig']->GetValue('appearance','custom_templates_only')
if ($_SESSION[APPCONFIG]->GetValue('appearance','custom_templates_only')
&& ! preg_match('/^custom_/',$file))
continue;
@@ -141,7 +142,7 @@ class Templates {
if (! preg_match('/.xml$/',$file))
continue;
if ($_SESSION['plaConfig']->GetValue('appearance','custom_templates_only')
if ($_SESSION[APPCONFIG]->GetValue('appearance','custom_templates_only')
&& ! preg_match('/^custom_/',$file))
continue;
@@ -682,7 +683,7 @@ class Templates {
$args[0] = $_SESSION[APPCONFIG]->ldapservers->GetValue($ldapserver->server_id,'auto_number','search_base');
$container = $ldapserver->getContainerParent($container,$args[0]);
$vals = get_next_number($ldapserver,$container,$args[1],(!empty($args[2]) && ($args[2] == 'true')) ? true : false,(!empty($args[3])) ? $args[3] : false);
$vals = get_next_number($ldapserver,$container,$args[1],(!empty($args[2]) && ($args[2] == 'false')) ? false : true,(!empty($args[3])) ? $args[3] : false);
# operate calculus on next number.
if (!empty($args[4])) {
$mod = split(';',$args[4]);
@@ -981,8 +982,8 @@ class Templates {
if (isset($_POST['form'][$varname]))
$function_args[] = $_POST['form'][$varname];
else
pla_error(sprintf(_('Your template calls php.Function for a default value, however (%s) is NOT available in the POST FORM variables. The following variables are available [%s].'),$varname,
(isset($_POST['form']) ? implode('|',array_keys($_POST['form'])) : 'NONE')));
error(sprintf(_('Your template calls php.Function for a default value, however (%s) is NOT available in the POST FORM variables. The following variables are available [%s].'),$varname,
(isset($_POST['form']) ? implode('|',array_keys($_POST['form'])) : 'NONE')),'error','index.php');
} else {
$function_args[] = $arg;
}

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/timeout_functions.php,v 1.10.2.2 2008/01/27 05:11:41 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/timeout_functions.php,v 1.10.2.4 2008/12/13 08:57:09 wurley Exp $
/**
* A collection of functions used throughout phpLDAPadmin for the timeout and automatic logout feature
@@ -42,7 +42,6 @@ function unset_lastactivity($ldapserver) {
* Check if custom session timeout has been reached for server $ldapserver.
* If it has:
* - automatically log out user by calling $ldapserver->unsetLoginDN()
* - if $server_id is equal to right frame $server_id, load timeout.php page in the right frame
* - return true
*
* @param object $ldapserver The LDAPServer object of the server which the user has logged in.
@@ -69,7 +68,7 @@ function session_timed_out($ldapserver) {
if (in_array($ldapserver->auth_type,array('cookie','session'))) {
syslog_notice('Logout for '.$ldapserver->getLoggedInDN());
$ldapserver->unsetLoginDN() or pla_error(_('Could not logout.'));
$ldapserver->unsetLoginDN() or error(_('Could not logout.'),'error','index.php');
}
return true;