Automated code cleanup, part 2, all the missing brackets

This commit is contained in:
Timothy Warren 2019-02-12 14:57:50 -05:00
parent f8f0d175b8
commit 35a0d22953
73 changed files with 7312 additions and 2116 deletions

View File

@ -17,7 +17,9 @@ $request['dn'] = get_request('dn','GET');
# Check if the entry exists. # Check if the entry exists.
if (! $request['dn'] || ! $app['server']->dnExists($request['dn'])) if (! $request['dn'] || ! $app['server']->dnExists($request['dn']))
{
error(sprintf(_('The entry (%s) does not exist.'), $request['dn']), 'error', 'index.php'); error(sprintf(_('The entry (%s) does not exist.'), $request['dn']), 'error', 'index.php');
}
$request['page'] = new TemplateRender($app['server']->getIndex(),get_request('template','REQUEST',false,null)); $request['page'] = new TemplateRender($app['server']->getIndex(),get_request('template','REQUEST',false,null));
$request['page']->setDN($request['dn']); $request['page']->setDN($request['dn']);
@ -38,10 +40,15 @@ if (get_request('meth','REQUEST') != 'ajax') {
$attr['binary'] = array(); $attr['binary'] = array();
foreach ($request['template']->getAvailAttrs() as $attribute) foreach ($request['template']->getAvailAttrs() as $attribute)
{
if ($app['server']->isAttrBinary($attribute->getName())) if ($app['server']->isAttrBinary($attribute->getName()))
{
array_push($attr['binary'], $attribute); array_push($attr['binary'], $attribute);
else } else
{
array_push($attr['avail'], $attribute); array_push($attr['avail'], $attribute);
}
}
if (count($attr['avail']) > 0) { if (count($attr['avail']) > 0) {
echo '<br />'; echo '<br />';
@ -53,9 +60,13 @@ if (get_request('meth','REQUEST') != 'ajax') {
echo '<div>'; echo '<div>';
if ($_SESSION[APPCONFIG]->getValue('confirm','update')) if ($_SESSION[APPCONFIG]->getValue('confirm','update'))
{
echo '<input type="hidden" name="cmd" value="update_confirm" />'; echo '<input type="hidden" name="cmd" value="update_confirm" />';
}
else else
{
echo '<input type="hidden" name="cmd" value="update" />'; echo '<input type="hidden" name="cmd" value="update" />';
}
printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex()); printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($request['dn'])); printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($request['dn']));
@ -65,9 +76,13 @@ if (get_request('meth','REQUEST') != 'ajax') {
foreach ($attr['avail'] as $attribute) { foreach ($attr['avail'] as $attribute) {
# Is there a user-friendly translation available for this attribute? # Is there a user-friendly translation available for this attribute?
if ($attribute->haveFriendlyName()) if ($attribute->haveFriendlyName())
$attr_display = sprintf('%s (%s)',$attribute->getFriendlyName(),$attribute->getName(false)); {
$attr_display = sprintf('%s (%s)', $attribute->getFriendlyName(), $attribute->getName(FALSE));
}
else else
$attr_display = $attribute->getName(false); {
$attr_display = $attribute->getName(FALSE);
}
printf('<option value="%s">%s</option>',htmlspecialchars($attribute->getName()),$attr_display); printf('<option value="%s">%s</option>',htmlspecialchars($attribute->getName()),$attr_display);
} }
@ -95,9 +110,13 @@ if (get_request('meth','REQUEST') != 'ajax') {
echo '<div>'; echo '<div>';
if ($_SESSION[APPCONFIG]->getValue('confirm','update')) if ($_SESSION[APPCONFIG]->getValue('confirm','update'))
{
echo '<input type="hidden" name="cmd" value="update_confirm" />'; echo '<input type="hidden" name="cmd" value="update_confirm" />';
}
else else
{
echo '<input type="hidden" name="cmd" value="update" />'; echo '<input type="hidden" name="cmd" value="update" />';
}
printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex()); printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
printf('<input type="hidden" name="dn" value="%s" />',$request['dn']); printf('<input type="hidden" name="dn" value="%s" />',$request['dn']);
@ -108,9 +127,13 @@ if (get_request('meth','REQUEST') != 'ajax') {
foreach ($attr['binary'] as $attribute) { foreach ($attr['binary'] as $attribute) {
# Is there a user-friendly translation available for this attribute? # Is there a user-friendly translation available for this attribute?
if ($attribute->haveFriendlyName()) if ($attribute->haveFriendlyName())
$attr_display = sprintf('%s (%s)',$attribute->getFriendlyName(),$attribute->getName(false)); {
$attr_display = sprintf('%s (%s)', $attribute->getFriendlyName(), $attribute->getName(FALSE));
}
else else
$attr_display = $attribute->getName(false); {
$attr_display = $attribute->getName(FALSE);
}
printf('<option value="%s">%s</option>',htmlspecialchars($attribute->getName()),$attr_display); printf('<option value="%s">%s</option>',htmlspecialchars($attribute->getName()),$attr_display);
} }
@ -121,11 +144,15 @@ if (get_request('meth','REQUEST') != 'ajax') {
printf('<input type="submit" name="submit" value="%s" class="update_dn" />',_('Add')); printf('<input type="submit" name="submit" value="%s" class="update_dn" />',_('Add'));
if (! ini_get('file_uploads')) if (! ini_get('file_uploads'))
{
printf('<br /><small><b>%s</b></small><br />', printf('<br /><small><b>%s</b></small><br />',
_('Your PHP configuration has disabled file uploads. Please check php.ini before proceeding.')); _('Your PHP configuration has disabled file uploads. Please check php.ini before proceeding.'));
}
else else
{
printf('<br /><small><b>%s: %s</b></small><br />', _('Maximum file size'), ini_get('upload_max_filesize')); printf('<br /><small><b>%s: %s</b></small><br />', _('Maximum file size'), ini_get('upload_max_filesize'));
}
echo '</div>'; echo '</div>';
echo '</form>'; echo '</form>';
@ -145,7 +172,9 @@ if (get_request('meth','REQUEST') != 'ajax') {
echo '<table class="entry" cellspacing="0" align="center" border="0">'; echo '<table class="entry" cellspacing="0" align="center" border="0">';
foreach ($request['template']->getAvailAttrs() as $attribute) foreach ($request['template']->getAvailAttrs() as $attribute)
{
$request['page']->draw('Template', $attribute); $request['page']->draw('Template', $attribute);
}
$request['page']->drawFormSubmitButton(); $request['page']->drawFormSubmitButton();
echo '</table>'; echo '</table>';
@ -173,7 +202,9 @@ if (get_request('meth','REQUEST') != 'ajax') {
printf('<option value="%s">%s</option>','',''); printf('<option value="%s">%s</option>','','');
foreach ($request['template']->getAvailAttrs() as $attribute) foreach ($request['template']->getAvailAttrs() as $attribute)
{
printf('<option value="%s">%s</option>', htmlspecialchars($attribute->getName()), $attribute->getFriendlyName()); printf('<option value="%s">%s</option>', htmlspecialchars($attribute->getName()), $attribute->getFriendlyName());
}
echo '</select>'; echo '</select>';

View File

@ -21,7 +21,9 @@ $request['dn'] = get_request('dn','REQUEST',true);
# Check if the entry exists. # Check if the entry exists.
if (! $request['dn'] || ! $app['server']->dnExists($request['dn'])) if (! $request['dn'] || ! $app['server']->dnExists($request['dn']))
{
error(sprintf(_('The entry (%s) does not exist.'), $request['dn']), 'error', 'index.php'); error(sprintf(_('The entry (%s) does not exist.'), $request['dn']), 'error', 'index.php');
}
$request['page'] = new TemplateRender($app['server']->getIndex(),get_request('template','REQUEST',false,null)); $request['page'] = new TemplateRender($app['server']->getIndex(),get_request('template','REQUEST',false,null));
$request['page']->setDN($request['dn']); $request['page']->setDN($request['dn']);
@ -37,10 +39,14 @@ $ldap['attrs']['must'] = array();
foreach ($request['template']->getAttribute('objectclass')->getValues() as $oclass_name) { foreach ($request['template']->getAttribute('objectclass')->getValues() as $oclass_name) {
# Exclude "top" if its there. # Exclude "top" if its there.
if (! strcasecmp('top',$oclass_name)) if (! strcasecmp('top',$oclass_name))
{
continue; continue;
}
if ($soc = $app['server']->getSchemaObjectClass($oclass_name)) if ($soc = $app['server']->getSchemaObjectClass($oclass_name))
$ldap['attrs']['must'] = array_merge($ldap['attrs']['must'],$soc->getMustAttrNames(true)); {
$ldap['attrs']['must'] = array_merge($ldap['attrs']['must'], $soc->getMustAttrNames(TRUE));
}
} }
$ldap['attrs']['must'] = array_unique($ldap['attrs']['must']); $ldap['attrs']['must'] = array_unique($ldap['attrs']['must']);
@ -49,12 +55,18 @@ $ldap['attrs']['must'] = array_unique($ldap['attrs']['must']);
* but that the object does not currently contain */ * but that the object does not currently contain */
$ldap['attrs']['need'] = array(); $ldap['attrs']['need'] = array();
foreach ($ldap['attrs']['must'] as $attr) foreach ($ldap['attrs']['must'] as $attr)
{
if (is_null($request['template']->getAttribute($attr))) if (is_null($request['template']->getAttribute($attr)))
{
array_push($ldap['attrs']['need'], $attribute_factory->newAttribute($attr, array('values' => array()), $app['server']->getIndex())); array_push($ldap['attrs']['need'], $attribute_factory->newAttribute($attr, array('values' => array()), $app['server']->getIndex()));
}
}
# Mark all the need attributes as shown # Mark all the need attributes as shown
foreach ($ldap['attrs']['need'] as $index => $values) foreach ($ldap['attrs']['need'] as $index => $values)
{
$ldap['attrs']['need'][$index]->show(); $ldap['attrs']['need'][$index]->show();
}
if (count($ldap['attrs']['need']) > 0) { if (count($ldap['attrs']['need']) > 0) {
$request['page']->drawTitle(sprintf('%s <b>%s</b>',_('Add new objectClass to'),get_rdn($request['dn']))); $request['page']->drawTitle(sprintf('%s <b>%s</b>',_('Add new objectClass to'),get_rdn($request['dn'])));
@ -73,9 +85,12 @@ if (count($ldap['attrs']['need']) > 0) {
echo '<div>'; echo '<div>';
if ($_SESSION[APPCONFIG]->getValue('confirm','update')) if ($_SESSION[APPCONFIG]->getValue('confirm','update'))
echo '<input type="hidden" name="cmd" value="update_confirm" />'; {
echo '<input type='hidden' name='cmd' value='update_confirm' />'; }
else else
{
echo '<input type="hidden" name="cmd" value="update" />'; echo '<input type="hidden" name="cmd" value="update" />';
}
printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex()); printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($request['dn'])); printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($request['dn']));
@ -87,11 +102,15 @@ if (count($ldap['attrs']['need']) > 0) {
$counter = 0; $counter = 0;
echo '<tr><td colspan="2">'; echo '<tr><td colspan="2">';
foreach ($request['template']->getAttribute('objectclass')->getValues() as $value) foreach ($request['template']->getAttribute('objectclass')->getValues() as $value)
{
$request['page']->draw('HiddenValue', $request['template']->getAttribute('objectclass'), $counter++); $request['page']->draw('HiddenValue', $request['template']->getAttribute('objectclass'), $counter++);
}
echo '</td></tr>'; echo '</td></tr>';
foreach ($ldap['attrs']['need'] as $count => $attr) foreach ($ldap['attrs']['need'] as $count => $attr)
{
$request['page']->draw('Template', $attr); $request['page']->draw('Template', $attr);
}
echo '</table>'; echo '</table>';
@ -108,7 +127,9 @@ if (count($ldap['attrs']['need']) > 0) {
$app['server']->getIndex(),rawurlencode($request['dn'])); $app['server']->getIndex(),rawurlencode($request['dn']));
if (get_request('meth','REQUEST') == 'ajax') if (get_request('meth','REQUEST') == 'ajax')
{
$href .= '&meth=ajax'; $href .= '&meth=ajax';
}
header(sprintf('Location: %s',$href)); header(sprintf('Location: %s',$href));
die(); die();

View File

@ -19,7 +19,9 @@ $request['attr'] = get_request('attr','GET',true);
# Check if the entry exists. # Check if the entry exists.
if (! $request['dn'] || ! $app['server']->dnExists($request['dn'])) if (! $request['dn'] || ! $app['server']->dnExists($request['dn']))
{
error(sprintf(_('The entry (%s) does not exist.'), $request['dn']), 'error', 'index.php'); error(sprintf(_('The entry (%s) does not exist.'), $request['dn']), 'error', 'index.php');
}
$request['page'] = new TemplateRender($app['server']->getIndex(),get_request('template','REQUEST',false,null)); $request['page'] = new TemplateRender($app['server']->getIndex(),get_request('template','REQUEST',false,null));
$request['page']->setDN($request['dn']); $request['page']->setDN($request['dn']);
@ -46,10 +48,13 @@ if (! strcasecmp($request['attr'],'objectclass') || get_request('meth','REQUEST'
echo '<form action="cmd.php" method="post" class="new_value" id="entry_form" enctype="multipart/form-data" onsubmit="return submitForm(this)">'; echo '<form action="cmd.php" method="post" class="new_value" id="entry_form" enctype="multipart/form-data" onsubmit="return submitForm(this)">';
echo '<div>'; echo '<div>';
if ($_SESSION[APPCONFIG]->getValue('confirm','update')) if ($_SESSION[APPCONFIG]->getValue('confirm','update'))
echo '<input type="hidden" name="cmd" value="update_confirm" />'; {
echo '<input type='hidden' name='cmd' value='update_confirm' />'; }
else else
{
echo '<input type="hidden" name="cmd" value="update" />'; echo '<input type="hidden" name="cmd" value="update" />';
} }
}
printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex()); printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($request['dn'])); printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($request['dn']));
@ -71,7 +76,9 @@ if (! strcasecmp($request['attr'],'objectclass') || get_request('meth','REQUEST'
echo '<table border="0"><tr><td>'; echo '<table border="0"><tr><td>';
for ($i=0;$i<$request['count'];$i++) { for ($i=0;$i<$request['count'];$i++) {
if ($i > 0) if ($i > 0)
{
echo '<br/>'; echo '<br/>';
}
$request['page']->draw('CurrentValue',$request['attribute'],$i); $request['page']->draw('CurrentValue',$request['attribute'],$i);
$request['page']->draw('HiddenValue',$request['attribute'],$i); $request['page']->draw('HiddenValue',$request['attribute'],$i);
} }
@ -96,7 +103,9 @@ if (! strcasecmp($request['attr'],'objectclass') || get_request('meth','REQUEST'
$socs = $app['server']->SchemaObjectClasses(); $socs = $app['server']->SchemaObjectClasses();
foreach ($request['attribute']->getValues() as $oclass) foreach ($request['attribute']->getValues() as $oclass)
{
unset($socs[strtolower($oclass)]); unset($socs[strtolower($oclass)]);
}
# Draw objectClass selection # Draw objectClass selection
echo '<table border="0">'; echo '<table border="0">';
@ -105,7 +114,9 @@ if (! strcasecmp($request['attr'],'objectclass') || get_request('meth','REQUEST'
foreach ($socs as $name => $oclass) { foreach ($socs as $name => $oclass) {
# Exclude any structural ones, that are not in the heirachy, as they'll only generate an LDAP_OBJECT_CLASS_VIOLATION # Exclude any structural ones, that are not in the heirachy, as they'll only generate an LDAP_OBJECT_CLASS_VIOLATION
if (($oclass->getType() == 'structural') && ! $oclass->isRelated($request['attribute']->getValues())) if (($oclass->getType() == 'structural') && ! $oclass->isRelated($request['attribute']->getValues()))
{
continue; continue;
}
printf('<option value="%s">%s</option>',$oclass->getName(false),$oclass->getName(false)); printf('<option value="%s">%s</option>',$oclass->getName(false),$oclass->getName(false));
} }
@ -121,8 +132,10 @@ if (! strcasecmp($request['attr'],'objectclass') || get_request('meth','REQUEST'
echo '</tr>'; echo '</tr>';
if ($_SESSION[APPCONFIG]->getValue('appearance','show_hints')) if ($_SESSION[APPCONFIG]->getValue('appearance','show_hints'))
{
printf('<tr><td colspan="2"><small><br /><img src="%s/light.png" alt="Hint" /><span class="hint">%s</span></small></td></tr>', printf('<tr><td colspan="2"><small><br /><img src="%s/light.png" alt="Hint" /><span class="hint">%s</span></small></td></tr>',
IMGDIR, _('Note: You may be required to enter new attributes that these objectClass(es) require')); IMGDIR, _('Note: You may be required to enter new attributes that these objectClass(es) require'));
}
echo '</table>'; echo '</table>';
echo '</form>'; echo '</form>';
@ -136,14 +149,20 @@ if (! strcasecmp($request['attr'],'objectclass') || get_request('meth','REQUEST'
$sattr = $app['server']->getSchemaAttribute($request['attr']); $sattr = $app['server']->getSchemaAttribute($request['attr']);
if ($sattr->getDescription()) if ($sattr->getDescription())
{
printf('<small><b>%s:</b> %s</small><br />', _('Description'), $sattr->getDescription()); printf('<small><b>%s:</b> %s</small><br />', _('Description'), $sattr->getDescription());
}
if ($sattr->getType()) if ($sattr->getType())
{
printf('<small><b>%s:</b> %s</small><br />', _('Syntax'), $sattr->getType()); printf('<small><b>%s:</b> %s</small><br />', _('Syntax'), $sattr->getType());
}
if ($sattr->getMaxLength()) if ($sattr->getMaxLength())
{
printf('<small><b>%s:</b> %s %s</small><br />', printf('<small><b>%s:</b> %s %s</small><br />',
_('Maximum Length'), number_format($sattr->getMaxLength()), _('characters')); _('Maximum Length'), number_format($sattr->getMaxLength()), _('characters'));
}
echo '<br />'; echo '<br />';
printf('<input type="submit" id="save_button" name="submit" value="%s" />',_('Add New Value')); printf('<input type="submit" id="save_button" name="submit" value="%s" />',_('Add New Value'));

View File

@ -21,20 +21,30 @@ ob_start();
switch ($www['cmd']) { switch ($www['cmd']) {
default: default:
if (defined('HOOKSDIR') && file_exists(HOOKSDIR.$www['cmd'].'.php')) if (defined('HOOKSDIR') && file_exists(HOOKSDIR.$www['cmd'].'.php'))
{
$app['script_cmd'] = HOOKSDIR . $www['cmd'] . '.php'; $app['script_cmd'] = HOOKSDIR . $www['cmd'] . '.php';
}
elseif (defined('HTDOCDIR') && file_exists(HTDOCDIR.$www['cmd'].'.php')) elseif (defined('HTDOCDIR') && file_exists(HTDOCDIR.$www['cmd'].'.php'))
{
$app['script_cmd'] = HTDOCDIR . $www['cmd'] . '.php'; $app['script_cmd'] = HTDOCDIR . $www['cmd'] . '.php';
}
elseif (file_exists('welcome.php')) elseif (file_exists('welcome.php'))
{
$app['script_cmd'] = 'welcome.php'; $app['script_cmd'] = 'welcome.php';
}
else else
$app['script_cmd'] = null; {
$app['script_cmd'] = NULL;
}
} }
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
{
debug_log('Ready to render page for command [%s,%s].', 128, 0, __FILE__, __LINE__, __METHOD__, $www['cmd'], $app['script_cmd']); debug_log('Ready to render page for command [%s,%s].', 128, 0, __FILE__, __LINE__, __METHOD__, $www['cmd'], $app['script_cmd']);
}
# Create page. # Create page.
# Set the index so that we render the right server tree. # Set the index so that we render the right server tree.
@ -44,7 +54,9 @@ $www['page'] = new page($app['server']->getIndex());
if (trim($www['cmd'])) { if (trim($www['cmd'])) {
# If this is a READ-WRITE operation, the LDAP server must not be in READ-ONLY mode. # If this is a READ-WRITE operation, the LDAP server must not be in READ-ONLY mode.
if ($app['server']->isReadOnly() && ! in_array(get_request('cmd','REQUEST'),$app['readwrite_cmds'])) if ($app['server']->isReadOnly() && ! in_array(get_request('cmd','REQUEST'),$app['readwrite_cmds']))
{
error(_('You cannot perform updates while server is in read-only mode'), 'error', 'index.php'); error(_('You cannot perform updates while server is in read-only mode'), 'error', 'index.php');
}
# If this command has been disabled by the config. # If this command has been disabled by the config.
if (! $_SESSION[APPCONFIG]->isCommandAvailable('script',$www['cmd'])) { if (! $_SESSION[APPCONFIG]->isCommandAvailable('script',$www['cmd'])) {
@ -56,7 +68,9 @@ if (trim($www['cmd'])) {
} }
if ($app['script_cmd']) if ($app['script_cmd'])
{
include $app['script_cmd']; include $app['script_cmd'];
}
# Refresh a frame - this is so that one frame can trigger another frame to be refreshed. # Refresh a frame - this is so that one frame can trigger another frame to be refreshed.
if (isAjaxEnabled() && get_request('refresh','REQUEST') && get_request('refresh','REQUEST') != get_request('frame','REQUEST')) { if (isAjaxEnabled() && get_request('refresh','REQUEST') && get_request('refresh','REQUEST') != get_request('frame','REQUEST')) {
@ -73,7 +87,11 @@ $www['page']->block_add('body',$www['body']);
ob_end_clean(); ob_end_clean();
if ($www['meth'] == 'ajax') if ($www['meth'] == 'ajax')
$www['page']->show(get_request('frame','REQUEST',false,'BODY'),true,get_request('raw','REQUEST',false,false)); {
$www['page']->show(get_request('frame', 'REQUEST', FALSE, 'BODY'), TRUE, get_request('raw', 'REQUEST', FALSE, FALSE));
}
else else
{
$www['page']->display(); $www['page']->display();
}

View File

@ -9,6 +9,8 @@
*/ */
if (! defined('LIBDIR')) if (! defined('LIBDIR'))
{
define('LIBDIR', sprintf('%s/', realpath('../lib/'))); define('LIBDIR', sprintf('%s/', realpath('../lib/')));
}
require_once LIBDIR.'common.php'; require_once LIBDIR.'common.php';

View File

@ -21,10 +21,14 @@ $ldap['SRC'] = $_SESSION[APPCONFIG]->getServer(get_request('server_id_src'));
$ldap['DST'] = $_SESSION[APPCONFIG]->getServer(get_request('server_id_dst')); $ldap['DST'] = $_SESSION[APPCONFIG]->getServer(get_request('server_id_dst'));
if (! $ldap['SRC']->dnExists($request['dnSRC'])) if (! $ldap['SRC']->dnExists($request['dnSRC']))
{
error(sprintf('%s (%s)', _('No such entry.'), pretty_print_dn($request['dnSRC'])), 'error', 'index.php'); error(sprintf('%s (%s)', _('No such entry.'), pretty_print_dn($request['dnSRC'])), 'error', 'index.php');
}
if (! $ldap['DST']->dnExists($request['dnDST'])) if (! $ldap['DST']->dnExists($request['dnDST']))
{
error(sprintf('%s (%s)', _('No such entry.'), pretty_print_dn($request['dnDST'])), 'error', 'index.php'); error(sprintf('%s (%s)', _('No such entry.'), pretty_print_dn($request['dnDST'])), 'error', 'index.php');
}
$request['pageSRC'] = new PageRender($ldap['SRC']->getIndex(),get_request('template','REQUEST',false,'none')); $request['pageSRC'] = new PageRender($ldap['SRC']->getIndex(),get_request('template','REQUEST',false,'none'));
$request['pageSRC']->setDN($request['dnSRC']); $request['pageSRC']->setDN($request['dnSRC']);
@ -88,16 +92,22 @@ sort($attrs_all);
foreach ($attrs_all as $attr) { foreach ($attrs_all as $attr) {
# Has the config.php specified that this attribute is to be hidden or shown? # Has the config.php specified that this attribute is to be hidden or shown?
if ($ldap['SRC']->isAttrHidden($attr) || $ldap['DST']->isAttrHidden($attr)) if ($ldap['SRC']->isAttrHidden($attr) || $ldap['DST']->isAttrHidden($attr))
{
continue; continue;
}
$attributeSRC = $request['templateSRC']->getAttribute($attr); $attributeSRC = $request['templateSRC']->getAttribute($attr);
$attributeDST = $request['templateDST']->getAttribute($attr); $attributeDST = $request['templateDST']->getAttribute($attr);
# Get the values and see if they are the same. # Get the values and see if they are the same.
if ($attributeSRC && $attributeDST && ($attributeSRC->getValues() == $attributeDST->getValues())) if ($attributeSRC && $attributeDST && ($attributeSRC->getValues() == $attributeDST->getValues()))
{
echo '<tr>'; echo '<tr>';
}
else else
{
echo '<tr>'; echo '<tr>';
}
foreach (array('src','dst') as $side) { foreach (array('src','dst') as $side) {
# If we are on the source side, show the attribute name. # If we are on the source side, show the attribute name.
@ -109,7 +119,9 @@ foreach ($attrs_all as $attr) {
echo '</td>'; echo '</td>';
if ($request['pageSRC']->getServerID() == $request['pageDST']->getServerID()) if ($request['pageSRC']->getServerID() == $request['pageDST']->getServerID())
{
echo '<td class="title">&nbsp;</td>'; echo '<td class="title">&nbsp;</td>';
}
else { else {
echo '<td class="note" style="text-align: right;">'; echo '<td class="note" style="text-align: right;">';
@ -126,7 +138,9 @@ foreach ($attrs_all as $attr) {
case 'dst': case 'dst':
if ($attributeDST) { if ($attributeDST) {
if ($attributeSRC && ($request['pageSRC']->getServerID() == $request['pageDST']->getServerID())) if ($attributeSRC && ($request['pageSRC']->getServerID() == $request['pageDST']->getServerID()))
{
echo '<td class="title">&nbsp;</td>'; echo '<td class="title">&nbsp;</td>';
}
else { else {
echo '<td class="title" >'; echo '<td class="title" >';
@ -151,9 +165,13 @@ foreach ($attrs_all as $attr) {
# Get the values and see if they are the same. # Get the values and see if they are the same.
if ($attributeSRC && $attributeDST && ($attributeSRC->getValues() == $attributeDST->getValues())) if ($attributeSRC && $attributeDST && ($attributeSRC->getValues() == $attributeDST->getValues()))
{
echo '<tr style="background-color: #F0F0F0;">'; echo '<tr style="background-color: #F0F0F0;">';
}
else else
{
echo '<tr>'; echo '<tr>';
}
foreach (array('src','dst') as $side) { foreach (array('src','dst') as $side) {
echo '<td class="value" colspan="2"><table border="0">'; echo '<td class="value" colspan="2"><table border="0">';
@ -163,17 +181,25 @@ foreach ($attrs_all as $attr) {
case 'src': case 'src':
if ($attributeSRC && count($attributeSRC->getValues())) if ($attributeSRC && count($attributeSRC->getValues()))
{
$request['pageSRC']->draw('CurrentValues', $attributeSRC); $request['pageSRC']->draw('CurrentValues', $attributeSRC);
}
else else
{
echo '&nbsp;'; echo '&nbsp;';
}
break; break;
case 'dst': case 'dst':
if ($attributeDST && count($attributeDST->getValues())) if ($attributeDST && count($attributeDST->getValues()))
{
$request['pageDST']->draw('CurrentValues', $attributeDST); $request['pageDST']->draw('CurrentValues', $attributeDST);
}
else else
{
echo '&nbsp;'; echo '&nbsp;';
}
break; break;
} }

View File

@ -18,7 +18,9 @@ $request['dn'] = get_request('dn','GET');
# Check if the entry exists. # Check if the entry exists.
if (! $request['dn'] || ! $app['server']->dnExists($request['dn'])) if (! $request['dn'] || ! $app['server']->dnExists($request['dn']))
{
error(sprintf(_('The entry (%s) does not exist.'), $request['dn']), 'error', 'index.php'); error(sprintf(_('The entry (%s) does not exist.'), $request['dn']), 'error', 'index.php');
}
$request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none')); $request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
$request['page']->setDN($request['dn']); $request['page']->setDN($request['dn']);

View File

@ -22,20 +22,30 @@ $ldap['DST'] = $_SESSION[APPCONFIG]->getServer(get_request('server_id_dst'));
# Error checking # Error checking
if (! trim($request['dnDST'])) if (! trim($request['dnDST']))
{
error(_('You left the destination DN blank.'), 'error', 'index.php'); error(_('You left the destination DN blank.'), 'error', 'index.php');
}
if ($ldap['DST']->isReadOnly()) if ($ldap['DST']->isReadOnly())
{
error(_('Destination server is currently READ-ONLY.'), 'error', 'index.php'); error(_('Destination server is currently READ-ONLY.'), 'error', 'index.php');
}
if ($ldap['DST']->dnExists($request['dnDST'])) if ($ldap['DST']->dnExists($request['dnDST']))
{
error(sprintf(_('The destination entry (%s) already exists.'), pretty_print_dn($request['dnDST'])), 'error', 'index.php'); error(sprintf(_('The destination entry (%s) already exists.'), pretty_print_dn($request['dnDST'])), 'error', 'index.php');
}
if (! $ldap['DST']->dnExists($ldap['DST']->getContainer($request['dnDST']))) if (! $ldap['DST']->dnExists($ldap['DST']->getContainer($request['dnDST'])))
{
error(sprintf(_('The destination container (%s) does not exist.'), error(sprintf(_('The destination container (%s) does not exist.'),
pretty_print_dn($ldap['DST']->getContainer($request['dnDST']))), 'error', 'index.php'); pretty_print_dn($ldap['DST']->getContainer($request['dnDST']))), 'error', 'index.php');
}
if (pla_compare_dns($request['dnSRC'],$request['dnDST']) == 0 && $ldap['SRC']->getIndex() == $ldap['DST']->getIndex()) if (pla_compare_dns($request['dnSRC'],$request['dnDST']) == 0 && $ldap['SRC']->getIndex() == $ldap['DST']->getIndex())
{
error(_('The source and destination DN are the same.'), 'error', 'index.php'); error(_('The source and destination DN are the same.'), 'error', 'index.php');
}
$request['recursive'] = (get_request('recursive') == 'on') ? true : false; $request['recursive'] = (get_request('recursive') == 'on') ? true : false;
$request['remove'] = (get_request('remove') == 'yes') ? true : false; $request['remove'] = (get_request('remove') == 'yes') ? true : false;
@ -79,10 +89,13 @@ if ($request['recursive']) {
# Set all attributes with a values as shown, and remove the add value options # Set all attributes with a values as shown, and remove the add value options
foreach ($request['templateDST']->getAttributes(true) as $sattribute) foreach ($request['templateDST']->getAttributes(true) as $sattribute)
if ($sattribute->getValues() && ! $sattribute->isInternal()) { {
if ($sattribute->getValues() && ! $sattribute->isInternal())
{
$sattribute->show(); $sattribute->show();
$sattribute->setMaxValueCount(count($sattribute->getValues())); $sattribute->setMaxValueCount(count($sattribute->getValues()));
} }
}
$request['pageDST']->accept(); $request['pageDST']->accept();
@ -92,15 +105,19 @@ if ($request['recursive']) {
$copy_result = copy_dn($ldap['SRC'],$ldap['DST'],$request['dnSRC'],$request['dnDST'],$request['remove']); $copy_result = copy_dn($ldap['SRC'],$ldap['DST'],$request['dnSRC'],$request['dnDST'],$request['remove']);
if ($copy_result) if ($copy_result)
{
$copy_message = sprintf('%s %s: <b>%s</b> %s', $copy_message = sprintf('%s %s: <b>%s</b> %s',
$request['remove'] ? _('Move successful') : _('Copy successful'), $request['remove'] ? _('Move successful') : _('Copy successful'),
_('DN'), $request['dnDST'], _('has been created.')); _('DN'), $request['dnDST'], _('has been created.'));
}
else else
{
$copy_message = sprintf('%s %s: <b>%s</b> %s', $copy_message = sprintf('%s %s: <b>%s</b> %s',
$request['remove'] ? _('Move NOT successful') : _('Copy NOT successful'), $request['remove'] ? _('Move NOT successful') : _('Copy NOT successful'),
_('DN'), $request['dnDST'], _('has NOT been created.')); _('DN'), $request['dnDST'], _('has NOT been created.'));
} }
} }
}
if ($copy_result) { if ($copy_result) {
$redirect_url = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s&refresh=SID_%s_nodes&noheader=1', $redirect_url = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s&refresh=SID_%s_nodes&noheader=1',
@ -115,7 +132,9 @@ if ($copy_result) {
function r_copy_dn($serverSRC,$serverDST,$snapshottree,$dnSRC,$dnDST,$remove) { function r_copy_dn($serverSRC,$serverDST,$snapshottree,$dnSRC,$dnDST,$remove) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 1, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 1, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$copy_message = array(); $copy_message = array();
@ -127,7 +146,9 @@ function r_copy_dn($serverSRC,$serverDST,$snapshottree,$dnSRC,$dnDST,$remove) {
$copy_result = copy_dn($serverSRC,$serverDST,$dnSRC,$dnDST,false); $copy_result = copy_dn($serverSRC,$serverDST,$dnSRC,$dnDST,false);
if (! $copy_result) if (! $copy_result)
return false; {
return FALSE;
}
array_push($copy_message,sprintf('%s %s: <b>%s</b> %s',_('Copy successful'),_('DN'),$dnDST,_('has been created.'))); array_push($copy_message,sprintf('%s %s: <b>%s</b> %s',_('Copy successful'),_('DN'),$dnDST,_('has been created.')));
@ -138,35 +159,45 @@ function r_copy_dn($serverSRC,$serverDST,$snapshottree,$dnSRC,$dnDST,$remove) {
$copy_message = array_merge($copy_message,array_values($copy_result)); $copy_message = array_merge($copy_message,array_values($copy_result));
if (! $copy_result) if (! $copy_result)
$hadError = true; {
$hadError = TRUE;
}
} }
if (! $hadError && $remove) { if (! $hadError && $remove) {
$delete_result = $serverSRC->delete($dnSRC); $delete_result = $serverSRC->delete($dnSRC);
if ($delete_result) if ($delete_result)
{
array_push($copy_message, sprintf('%s %s: <b>%s</b> %s', _('Delete successful'), _('DN'), $dnDST, _('has been deleted.'))); array_push($copy_message, sprintf('%s %s: <b>%s</b> %s', _('Delete successful'), _('DN'), $dnDST, _('has been deleted.')));
} }
}
} else { } else {
$copy_result = copy_dn($serverSRC,$serverDST,$dnSRC,$dnDST,$remove); $copy_result = copy_dn($serverSRC,$serverDST,$dnSRC,$dnDST,$remove);
if ($copy_result) if ($copy_result)
{
array_push($copy_message, sprintf('%s %s: <b>%s</b> %s', array_push($copy_message, sprintf('%s %s: <b>%s</b> %s',
$remove ? _('Move successful') : _('Copy successful'), $remove ? _('Move successful') : _('Copy successful'),
_('DN'), $dnDST, _('has been created.'))); _('DN'), $dnDST, _('has been created.')));
}
else else
{
array_push($copy_message, sprintf('%s %s: <b>%s</b> %s', array_push($copy_message, sprintf('%s %s: <b>%s</b> %s',
$remove ? _('Move NOT successful') : _('Copy NOT successful'), $remove ? _('Move NOT successful') : _('Copy NOT successful'),
_('DN'), $dnDST, _('has NOT been created.'))); _('DN'), $dnDST, _('has NOT been created.')));
} }
}
return $copy_message; return $copy_message;
} }
function copy_dn($serverSRC,$serverDST,$dnSRC,$dnDST,$remove) { function copy_dn($serverSRC,$serverDST,$dnSRC,$dnDST,$remove) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 1, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 1, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$request = array(); $request = array();
$request['pageSRC'] = new PageRender($serverSRC->getIndex(),get_request('template','REQUEST',false,'none')); $request['pageSRC'] = new PageRender($serverSRC->getIndex(),get_request('template','REQUEST',false,'none'));
@ -183,14 +214,20 @@ function copy_dn($serverSRC,$serverDST,$dnSRC,$dnDST,$remove) {
# Create of move the entry # Create of move the entry
if ($remove) if ($remove)
return $serverDST->rename($request['templateSRC']->getDN(),$request['templateDST']->getRDN(),$serverDST->getContainer($dnDST),true); {
return $serverDST->rename($request['templateSRC']->getDN(), $request['templateDST']->getRDN(), $serverDST->getContainer($dnDST), TRUE);
}
else else
{
return $serverDST->add($request['templateDST']->getDN(), $request['templateDST']->getLDAPadd()); return $serverDST->add($request['templateDST']->getDN(), $request['templateDST']->getLDAPadd());
} }
}
function build_tree($server,$dn,$buildtree) { function build_tree($server,$dn,$buildtree) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 1, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 1, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
# We search all children, not only the visible children in the tree # We search all children, not only the visible children in the tree
$children = $server->getContainerContents($dn,null,0); $children = $server->getContainerContents($dn,null,0);
@ -198,11 +235,15 @@ function build_tree($server,$dn,$buildtree) {
if (count($children)) { if (count($children)) {
$buildtree[$dn] = $children; $buildtree[$dn] = $children;
foreach ($children as $child_dn) foreach ($children as $child_dn)
{
$buildtree = build_tree($server, $child_dn, $buildtree); $buildtree = build_tree($server, $child_dn, $buildtree);
} }
}
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
{
debug_log('Returning (%s)', 1, 0, __FILE__, __LINE__, __METHOD__, $buildtree); debug_log('Returning (%s)', 1, 0, __FILE__, __LINE__, __METHOD__, $buildtree);
}
return $buildtree; return $buildtree;
} }

View File

@ -17,7 +17,9 @@ $request['dn'] = get_request('dn','GET');
# Check if the entry exists. # Check if the entry exists.
if (! $request['dn'] || ! $app['server']->dnExists($request['dn'])) if (! $request['dn'] || ! $app['server']->dnExists($request['dn']))
{
error(sprintf(_('The entry (%s) does not exist.'), $request['dn']), 'error', 'index.php'); error(sprintf(_('The entry (%s) does not exist.'), $request['dn']), 'error', 'index.php');
}
$request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none')); $request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
$request['page']->setDN($request['dn']); $request['page']->setDN($request['dn']);
@ -93,11 +95,14 @@ echo '</table>';
echo '</form>'; echo '</form>';
if ($_SESSION[APPCONFIG]->getValue('appearance','show_hints')) if ($_SESSION[APPCONFIG]->getValue('appearance','show_hints'))
printf('<div style="text-align: center;"><small><img src="%s/light.png" alt="Light" /><span class="hint">%s</span></small></div>', {
IMGDIR,_('Hint: Copying between different servers only works if there are no schema violations')); printf('<div style='text - align: center;'><small><img src=' % s / light . png' alt='Light' /><span class='hint'>%s</span></small></div>',
IMGDIR,_('Hint: Copying between different servers only works if there are no schema violations')); }
# Draw the javascrpt to enable/disable the filter field if this may be a recursive copy # Draw the javascrpt to enable/disable the filter field if this may be a recursive copy
if (count($request['children']) > 0) if (count($request['children']) > 0)
{
printf('<script type="text/javascript" src="%sform_field_toggle_enable.js"></script>', JSDIR); printf('<script type="text/javascript" src="%sform_field_toggle_enable.js"></script>', JSDIR);
}

View File

@ -26,7 +26,9 @@ $request['page']->accept();
$request['template'] = $request['page']->getTemplate(); $request['template'] = $request['page']->getTemplate();
if ((! $request['template']->getContainer() || ! $app['server']->dnExists($request['template']->getContainer())) && ! get_request('create_base')) if ((! $request['template']->getContainer() || ! $app['server']->dnExists($request['template']->getContainer())) && ! get_request('create_base'))
{
error(sprintf(_('The container you specified (%s) does not exist. Please try again.'), $request['template']->getContainer()), 'error', 'index.php'); error(sprintf(_('The container you specified (%s) does not exist. Please try again.'), $request['template']->getContainer()), 'error', 'index.php');
}
# Check if the container is a leaf - we shouldnt really return a hit here, the template engine shouldnt have allowed a user to attempt to create an entry... # Check if the container is a leaf - we shouldnt really return a hit here, the template engine shouldnt have allowed a user to attempt to create an entry...
$tree = get_cached_item($app['server']->getIndex(),'tree'); $tree = get_cached_item($app['server']->getIndex(),'tree');
@ -39,17 +41,23 @@ if (! $request['container'] && ! get_request('create_base')) {
# Check our RDN # Check our RDN
if (! count($request['template']->getRDNAttrs())) if (! count($request['template']->getRDNAttrs()))
{
error(_('The were no attributes marked as an RDN attribute.'), 'error', 'index.php'); error(_('The were no attributes marked as an RDN attribute.'), 'error', 'index.php');
}
if (! $request['template']->getRDN()) if (! $request['template']->getRDN())
{
error(_('The RDN field is empty?'), 'error', 'index.php'); error(_('The RDN field is empty?'), 'error', 'index.php');
}
# Some other attribute checking... # Some other attribute checking...
foreach ($request['template']->getAttributes() as $attribute) { foreach ($request['template']->getAttributes() as $attribute) {
# Check that our Required Attributes have a value - we shouldnt really return a hit here, the template engine shouldnt have allowed this to slip through. # Check that our Required Attributes have a value - we shouldnt really return a hit here, the template engine shouldnt have allowed this to slip through.
# @todo this isIgnoredAttr() function is missing? # @todo this isIgnoredAttr() function is missing?
if ($attribute->isRequired() && ! count($attribute->getValues()) && ! $app['server']->isIgnoredAttr($attr->getName())) if ($attribute->isRequired() && ! count($attribute->getValues()) && ! $app['server']->isIgnoredAttr($attr->getName()))
{
error(sprintf(_('You left the value blank for required attribute (%s).'), error(sprintf(_('You left the value blank for required attribute (%s).'),
$attribute->getName(false)),'error','index.php'); $attribute->getName(FALSE)), 'error', 'index.php');
}
} }
# Create the entry # Create the entry
@ -60,25 +68,34 @@ if ($add_result) {
$href = sprintf('cmd=template_engine&server_id=%s',$app['server']->getIndex()); $href = sprintf('cmd=template_engine&server_id=%s',$app['server']->getIndex());
if ($request['redirect']) if ($request['redirect'])
{
$redirect_url = $request['redirect']; $redirect_url = $request['redirect'];
}
else if ($action_number == 2) else if ($action_number == 2)
{
$redirect_url = sprintf('cmd.php?%s&template=%s&container=%s', $redirect_url = sprintf('cmd.php?%s&template=%s&container=%s',
$href, 'default', $request['template']->getContainerEncode()); $href, 'default', $request['template']->getContainerEncode());
}
else else
{
$redirect_url = sprintf('cmd.php?%s&template=%s&dn=%s', $redirect_url = sprintf('cmd.php?%s&template=%s&dn=%s',
$href, 'default', $request['template']->getDNEncode()); $href, 'default', $request['template']->getDNEncode());
}
if ($action_number == 1 || $action_number == 2) if ($action_number == 1 || $action_number == 2)
printf('<meta http-equiv="refresh" content="0; url=%s" />',$redirect_url); {
printf('<meta http-equiv='refresh' content='0; url =%s' />',$redirect_url); }
if ($action_number == 1 || $action_number == 2) { if ($action_number == 1 || $action_number == 2) {
$create_message = sprintf('%s %s: <b>%s</b> %s', $create_message = sprintf('%s %s: <b>%s</b> %s',
_('Creation successful!'),_('DN'),$request['template']->getDN(),_('has been created.')); _('Creation successful!'),_('DN'),$request['template']->getDN(),_('has been created.'));
if (isAjaxEnabled()) if (isAjaxEnabled())
{
$redirect_url .= sprintf('&refresh=SID_%s_nodes&noheader=1', $app['server']->getIndex()); $redirect_url .= sprintf('&refresh=SID_%s_nodes&noheader=1', $app['server']->getIndex());
}
system_message(array( system_message(array(
'title'=>_('Create Entry'), 'title'=>_('Create Entry'),

View File

@ -20,7 +20,9 @@ $request['page']->accept();
$request['template'] = $request['page']->getTemplate(); $request['template'] = $request['page']->getTemplate();
if (! $request['template']->getContainer() || ! $app['server']->dnExists($request['template']->getContainer())) if (! $request['template']->getContainer() || ! $app['server']->dnExists($request['template']->getContainer()))
{
error(sprintf(_('The container you specified (%s) does not exist. Please try again.'), $request['template']->getContainer()), 'error', 'index.php'); error(sprintf(_('The container you specified (%s) does not exist. Please try again.'), $request['template']->getContainer()), 'error', 'index.php');
}
# Check if the container is a leaf - we shouldnt really return a hit here, the template engine shouldnt have allowed a user to attempt to create an entry... # Check if the container is a leaf - we shouldnt really return a hit here, the template engine shouldnt have allowed a user to attempt to create an entry...
$tree = get_cached_item($app['server']->getIndex(),'tree'); $tree = get_cached_item($app['server']->getIndex(),'tree');
@ -33,17 +35,23 @@ if (! $request['container']) {
# Check our RDN # Check our RDN
if (! count($request['template']->getRDNAttrs())) if (! count($request['template']->getRDNAttrs()))
{
error(_('The were no attributes marked as an RDN attribute.'), 'error', 'index.php'); error(_('The were no attributes marked as an RDN attribute.'), 'error', 'index.php');
}
if (! $request['template']->getRDN()) if (! $request['template']->getRDN())
{
error(_('The RDN field is empty?'), 'error', 'index.php'); error(_('The RDN field is empty?'), 'error', 'index.php');
}
# Some other attribute checking... # Some other attribute checking...
foreach ($request['template']->getAttributes() as $attribute) { foreach ($request['template']->getAttributes() as $attribute) {
# Check that our Required Attributes have a value - we shouldnt really return a hit here, the template engine shouldnt have allowed this to slip through. # Check that our Required Attributes have a value - we shouldnt really return a hit here, the template engine shouldnt have allowed this to slip through.
# @todo this isIgnoredAttr() function is missing? # @todo this isIgnoredAttr() function is missing?
if ($attribute->isRequired() && ! count($attribute->getValues()) && ! $app['server']->isIgnoredAttr($attr->getName())) if ($attribute->isRequired() && ! count($attribute->getValues()) && ! $app['server']->isIgnoredAttr($attr->getName()))
{
error(sprintf(_('You left the value blank for required attribute (%s).'), error(sprintf(_('You left the value blank for required attribute (%s).'),
$attribute->getName(false)),'error','index.php'); $attribute->getName(FALSE)), 'error', 'index.php');
}
} }
# Check for unique attributes # Check for unique attributes
@ -68,7 +76,8 @@ if (count($request['template']->getLDAPadd(true))) {
printf('<input type="hidden" name="container" value="%s" />',$request['template']->getContainerEncode(false)); printf('<input type="hidden" name="container" value="%s" />',$request['template']->getContainerEncode(false));
printf('<input type="hidden" name="template" value="%s" />',$request['template']->getID()); printf('<input type="hidden" name="template" value="%s" />',$request['template']->getID());
foreach ($request['template']->getRDNAttrs() as $rdn) foreach ($request['template']->getRDNAttrs() as $rdn)
printf('<input type="hidden" name="rdn_attribute[]" value="%s" />',htmlspecialchars($rdn)); {
printf('<input type='hidden' name='rdn_attribute[]' value=' % s' />',htmlspecialchars($rdn)); }
echo "\n"; echo "\n";
$request['page']->drawHiddenAttributes(); $request['page']->drawHiddenAttributes();
@ -100,7 +109,9 @@ if (count($request['template']->getLDAPadd(true))) {
$input_onclick = ''; $input_onclick = '';
if ($attribute->isRequired()) if ($attribute->isRequired())
{
$input_disabled = 'disabled="disabled"'; $input_disabled = 'disabled="disabled"';
}
printf('<td><input name="skip_array[%s]" id="skip_array_%s" type="checkbox" %s %s/></td>', printf('<td><input name="skip_array[%s]" id="skip_array_%s" type="checkbox" %s %s/></td>',
htmlspecialchars($attribute->getName()),htmlspecialchars($attribute->getName()),$input_disabled,$input_onclick); htmlspecialchars($attribute->getName()),htmlspecialchars($attribute->getName()),$input_disabled,$input_onclick);
@ -133,10 +144,14 @@ if (count($request['template']->getLDAPadd(true))) {
echo _('You made no changes'); echo _('You made no changes');
if (isAjaxEnabled()) if (isAjaxEnabled())
{
printf(' <a href="cmd.php?%s" onclick="return ajDISPLAY(\'BODY\',\'%s\',\'%s\');">%s</a>.', printf(' <a href="cmd.php?%s" onclick="return ajDISPLAY(\'BODY\',\'%s\',\'%s\');">%s</a>.',
htmlspecialchars($href), htmlspecialchars($href), _('Retrieving DN'), _('Go back')); htmlspecialchars($href), htmlspecialchars($href), _('Retrieving DN'), _('Go back'));
}
else else
{
printf(' <a href="cmd.php?%s">%s</a>.', htmlspecialchars($href), _('Go back')); printf(' <a href="cmd.php?%s">%s</a>.', htmlspecialchars($href), _('Go back'));
}
echo '</div>'; echo '</div>';
} }

View File

@ -16,7 +16,9 @@ $request = array();
$request['dn'] = get_request('dn','REQUEST',true); $request['dn'] = get_request('dn','REQUEST',true);
if (! $app['server']->dnExists($request['dn'])) if (! $app['server']->dnExists($request['dn']))
{
error(sprintf('%s (%s)', _('No such entry.'), '<b>' . pretty_print_dn($request['dn']) . '</b>'), 'error', 'index.php'); error(sprintf('%s (%s)', _('No such entry.'), '<b>' . pretty_print_dn($request['dn']) . '</b>'), 'error', 'index.php');
}
# Delete the entry. # Delete the entry.
$result = $app['server']->delete($request['dn']); $result = $app['server']->delete($request['dn']);
@ -25,7 +27,9 @@ if ($result) {
$redirect_url = ''; $redirect_url = '';
if (isAjaxEnabled()) if (isAjaxEnabled())
{
$redirect_url .= sprintf('&refresh=SID_%s_nodes&noheader=1', $app['server']->getIndex()); $redirect_url .= sprintf('&refresh=SID_%s_nodes&noheader=1', $app['server']->getIndex());
}
system_message(array( system_message(array(
'title'=>_('Delete DN'), 'title'=>_('Delete DN'),
@ -33,8 +37,10 @@ if ($result) {
'type'=>'info'), 'type'=>'info'),
sprintf('index.php?server_id=%s%s',$app['server']->getIndex(),$redirect_url)); sprintf('index.php?server_id=%s%s',$app['server']->getIndex(),$redirect_url));
} else } else
{
system_message(array( system_message(array(
'title' => _('Could not delete the entry.') . sprintf(' (%s)', pretty_print_dn($request['dn'])), 'title' => _('Could not delete the entry.') . sprintf(' (%s)', pretty_print_dn($request['dn'])),
'body'=>ldap_error_msg($app['server']->getErrorMessage(null),$app['server']->getErrorNum(null)), 'body' => ldap_error_msg($app['server']->getErrorMessage(NULL), $app['server']->getErrorNum(NULL)),
'type' => 'error')); 'type' => 'error'));
}

View File

@ -17,7 +17,9 @@ $request['attr'] = get_request('attr','REQUEST',true);
$request['index'] = get_request('index','REQUEST',true); $request['index'] = get_request('index','REQUEST',true);
if ($app['server']->isAttrReadOnly($request['attr'])) if ($app['server']->isAttrReadOnly($request['attr']))
{
error(sprintf(_('The attribute "%s" is flagged as read-only in the phpLDAPadmin configuration.'), $request['attr']), 'error', 'index.php'); error(sprintf(_('The attribute "%s" is flagged as read-only in the phpLDAPadmin configuration.'), $request['attr']), 'error', 'index.php');
}
$update_array = array(); $update_array = array();
$update_array[$request['attr']] = $app['server']->getDNAttrValue($request['dn'],$request['attr']); $update_array[$request['attr']] = $app['server']->getDNAttrValue($request['dn'],$request['attr']);
@ -26,21 +28,27 @@ $redirect_url = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s',
$app['server']->getIndex(),rawurlencode($request['dn'])); $app['server']->getIndex(),rawurlencode($request['dn']));
if (! isset($update_array[$request['attr']][$request['index']])) if (! isset($update_array[$request['attr']][$request['index']]))
{
system_message(array( system_message(array(
'title' => _('Could not delete attribute value.'), 'title' => _('Could not delete attribute value.'),
'body' => sprintf('%s. %s/%s', _('The attribute value does not exist'), $request['attr'], $request['index']), 'body' => sprintf('%s. %s/%s', _('The attribute value does not exist'), $request['attr'], $request['index']),
'type' => 'warn'), $redirect_url); 'type' => 'warn'), $redirect_url);
}
else { else {
unset($update_array[$request['attr']][$request['index']]); unset($update_array[$request['attr']][$request['index']]);
foreach ($update_array as $key => $values) foreach ($update_array as $key => $values)
{
$update_array[$key] = array_values($values); $update_array[$key] = array_values($values);
}
$result = $app['server']->modify($request['dn'],$update_array); $result = $app['server']->modify($request['dn'],$update_array);
if ($result) { if ($result) {
foreach ($update_array as $attr => $junk) foreach ($update_array as $attr => $junk)
{
$redirect_url .= sprintf('&modified_attrs[]=%s', $attr); $redirect_url .= sprintf('&modified_attrs[]=%s', $attr);
}
header("Location: $redirect_url"); header("Location: $redirect_url");
die(); die();

View File

@ -22,10 +22,12 @@ $request['template'] = $request['page']->getTemplate();
# Check if the entry exists. # Check if the entry exists.
if (! $request['dn'] || ! $app['server']->dnExists($request['dn'])) if (! $request['dn'] || ! $app['server']->dnExists($request['dn']))
{
system_message(array( system_message(array(
'title' => _('Entry does not exist'), 'title' => _('Entry does not exist'),
'body' => sprintf('%s (%s)', _('The entry does not exist'), $request['dn']), 'body' => sprintf('%s (%s)', _('The entry does not exist'), $request['dn']),
'type' => 'error'), 'index.php'); 'type' => 'error'), 'index.php');
}
# We search all children, not only the visible children in the tree # We search all children, not only the visible children in the tree
$request['children'] = $app['server']->getContainerContents($request['dn'],null,0,'(objectClass=*)',LDAP_DEREF_NEVER); $request['children'] = $app['server']->getContainerContents($request['dn'],null,0,'(objectClass=*)',LDAP_DEREF_NEVER);
@ -106,7 +108,9 @@ if (count($request['children'])) {
$i = 0; $i = 0;
printf('<select size="%s" multiple disabled style="background:white; color:black;width:500px" >',min(10,count($request['search']))); printf('<select size="%s" multiple disabled style="background:white; color:black;width:500px" >',min(10,count($request['search'])));
foreach ($request['search'] as $key => $value) foreach ($request['search'] as $key => $value)
{
printf('<option>%s. %s</option>', ++$i, dn_unescape($value['dn'])); printf('<option>%s. %s</option>', ++$i, dn_unescape($value['dn']));
}
echo '</select>'; echo '</select>';
echo "\n"; echo "\n";

View File

@ -21,14 +21,18 @@ $request['type'] = get_request('type','GET',false,'octet-stream');
$request['filename'] = get_request('filename','GET',false,sprintf('%s:%s.bin',get_rdn($request['dn'],true),$request['attr'])); $request['filename'] = get_request('filename','GET',false,sprintf('%s:%s.bin',get_rdn($request['dn'],true),$request['attr']));
if (! $app['server']->dnExists($request['dn'])) if (! $app['server']->dnExists($request['dn']))
{
error(sprintf(_('The entry (%s) does not exist.'), $request['dn']), 'error', 'index.php'); error(sprintf(_('The entry (%s) does not exist.'), $request['dn']), 'error', 'index.php');
}
$search = $app['server']->getDNAttrValues($request['dn'],null,LDAP_DEREF_NEVER,array($request['attr'])); $search = $app['server']->getDNAttrValues($request['dn'],null,LDAP_DEREF_NEVER,array($request['attr']));
# Dump the binary data to the browser # Dump the binary data to the browser
$obStatus = ob_get_status(); $obStatus = ob_get_status();
if (isset($obStatus['type']) && $obStatus['type'] && $obStatus['status']) if (isset($obStatus['type']) && $obStatus['type'] && $obStatus['status'])
{
ob_end_clean(); ob_end_clean();
}
if (! isset($search[$request['attr']][$request['index']])) { if (! isset($search[$request['attr']][$request['index']])) {
# We cant display an error, but we can set a system message, which will be display on the next page render. # We cant display an error, but we can set a system message, which will be display on the next page render.

View File

@ -18,7 +18,9 @@ $request['noheader'] = get_request('noheader','REQUEST',false,0);
$tree = Tree::getInstance($request['server_id']); $tree = Tree::getInstance($request['server_id']);
if (! $tree) if (! $tree)
{
die(); die();
}
$treesave = false; $treesave = false;
@ -50,12 +52,18 @@ if ($request['dn']) {
} }
if ($treesave) if ($treesave)
{
set_cached_item($app['server']->getIndex(), 'tree', 'null', $tree); set_cached_item($app['server']->getIndex(), 'tree', 'null', $tree);
}
if ($request['dn']) if ($request['dn'])
{
echo $tree->draw_children($dnentry, $request['code']); echo $tree->draw_children($dnentry, $request['code']);
}
else else
{
$tree->draw($request['noheader']); $tree->draw($request['noheader']);
}
die(); die();

View File

@ -46,7 +46,9 @@ if (isset($app['server']) && ! is_null($request['container'])) {
foreach ($app['server']->getBaseDN() as $base) { foreach ($app['server']->getBaseDN() as $base) {
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
{
debug_log('Comparing BaseDN [%s] with container [%s]', 64, 0, __FILE__, __LINE__, __METHOD__, $base, $request['container']); debug_log('Comparing BaseDN [%s] with container [%s]', 64, 0, __FILE__, __LINE__, __METHOD__, $base, $request['container']);
}
if (! pla_compare_dns($request['container'],$base)) { if (! pla_compare_dns($request['container'],$base)) {
$parent_container = false; $parent_container = false;
@ -67,10 +69,14 @@ if (isset($app['server']) && ! is_null($request['container'])) {
echo '</tr>'; echo '</tr>';
if (! count($request['children'])) if (! count($request['children']))
{
printf('<td class="blank" colspan="2">&nbsp;</td><td colspan="2">(%s)</td>', _('no entries')); printf('<td class="blank" colspan="2">&nbsp;</td><td colspan="2">(%s)</td>', _('no entries'));
}
else else
foreach ($request['children'] as $dn) { {
foreach ($request['children'] as $dn)
{
$href['return'] = sprintf("javascript:returnDN('%s%s')", ($request['rdn'] ? sprintf('%s,', $request['rdn']) : ''), str_replace('\\', '\\\\', $dn)); $href['return'] = sprintf("javascript:returnDN('%s%s')", ($request['rdn'] ? sprintf('%s,', $request['rdn']) : ''), str_replace('\\', '\\\\', $dn));
$href['expand'] = sprintf('entry_chooser.php?server_id=%s&form=%s&element=%s&rdn=%s&container=%s', $href['expand'] = sprintf('entry_chooser.php?server_id=%s&form=%s&element=%s&rdn=%s&container=%s',
$app['server']->getIndex(), $request['form'], $request['element'], $request['rdn'], rawurlencode($dn)); $app['server']->getIndex(), $request['form'], $request['element'], $request['rdn'], rawurlencode($dn));
@ -80,20 +86,25 @@ if (isset($app['server']) && ! is_null($request['container'])) {
printf('<td class="icon"><a href="%s"><img src="%s/plus.png" alt="Plus" /></a></td>', $href['expand'], IMGDIR); printf('<td class="icon"><a href="%s"><img src="%s/plus.png" alt="Plus" /></a></td>', $href['expand'], IMGDIR);
$entry = $tree->getEntry($dn); $entry = $tree->getEntry($dn);
if (is_null($entry)) { if (is_null($entry))
{
$tree->addEntry($dn); $tree->addEntry($dn);
$entry = $tree->getEntry($dn); $entry = $tree->getEntry($dn);
} }
if ($entry) if ($entry)
{
$item = draw_formatted_dn($app['server'], $entry); $item = draw_formatted_dn($app['server'], $entry);
else } else
{
$item = $dn; $item = $dn;
}
printf('<td colspan="2"><a href="%s">%s</a></td>', $href['return'], $item); printf('<td colspan="2"><a href="%s">%s</a></td>', $href['return'], $item);
echo '</tr>'; echo '</tr>';
echo "\n\n"; echo "\n\n";
} }
}
# Draw the root of the selection tree (ie, list all the servers) # Draw the root of the selection tree (ie, list all the servers)
} else { } else {

View File

@ -25,7 +25,9 @@ $types = $request['export']->getType();
if ($request['file']) { if ($request['file']) {
$obStatus = ob_get_status(); $obStatus = ob_get_status();
if (isset($obStatus['type']) && $obStatus['type'] && $obStatus['status']) if (isset($obStatus['type']) && $obStatus['type'] && $obStatus['status'])
{
ob_end_clean(); ob_end_clean();
}
header('Content-type: application/download'); header('Content-type: application/download');
header(sprintf('Content-Disposition: inline; filename="%s.%s"','export',$types['extension'].($request['export']->isCompressed() ? '.gz' : ''))); header(sprintf('Content-Disposition: inline; filename="%s.%s"','export',$types['extension'].($request['export']->isCompressed() ? '.gz' : '')));

View File

@ -69,9 +69,11 @@ printf('<td><span style="white-space: nowrap">%s</span></td>',_('Search Scope'))
echo '<td>'; echo '<td>';
foreach ($available_scopes as $id => $desc) foreach ($available_scopes as $id => $desc)
{
printf('<input type="radio" name="scope" value="%s" id="%s"%s /><label for="%s">%s</label><br />', printf('<input type="radio" name="scope" value="%s" id="%s"%s /><label for="%s">%s</label><br />',
htmlspecialchars($id), $id, ($id == $request['scope']) ? 'checked="checked"' : '', htmlspecialchars($id), $id, ($id == $request['scope']) ? 'checked="checked"' : '',
htmlspecialchars($id), $desc); htmlspecialchars($id), $desc);
}
echo '</td>'; echo '</td>';
@ -123,9 +125,11 @@ echo '<fieldset style="height: 100px">';
printf('<legend>%s</legend>',_('Line ends')); printf('<legend>%s</legend>',_('Line ends'));
foreach ($available_formats as $id => $desc) foreach ($available_formats as $id => $desc)
{
printf('<input type="radio" name="format" value="%s" id="%s"%s /><label for="%s">%s</label><br />', printf('<input type="radio" name="format" value="%s" id="%s"%s /><label for="%s">%s</label><br />',
htmlspecialchars($id), htmlspecialchars($id), ($request['format'] == $id) ? ' checked="checked"' : '', htmlspecialchars($id), htmlspecialchars($id), ($request['format'] == $id) ? ' checked="checked"' : '',
htmlspecialchars($id), $desc); htmlspecialchars($id), $desc);
}
echo '</fieldset>'; echo '</fieldset>';
echo '</td></tr>'; echo '</td></tr>';
@ -149,14 +153,22 @@ echo '</form>';
*/ */
function get_line_end_format() { function get_line_end_format() {
if (is_browser('win')) if (is_browser('win'))
{
return 'win'; return 'win';
}
elseif (is_browser('unix')) elseif (is_browser('unix'))
{
return 'unix'; return 'unix';
}
elseif (is_browser('mac')) elseif (is_browser('mac'))
{
return 'mac'; return 'mac';
}
else else
{
return 'unix'; return 'unix';
} }
}
/** /**
* Gets the USER_AGENT string from the $_SERVER array, all in lower case in * Gets the USER_AGENT string from the $_SERVER array, all in lower case in
@ -166,10 +178,14 @@ function get_line_end_format() {
*/ */
function get_user_agent_string() { function get_user_agent_string() {
if (isset($_SERVER['HTTP_USER_AGENT'])) if (isset($_SERVER['HTTP_USER_AGENT']))
{
return strtolower($_SERVER['HTTP_USER_AGENT']); return strtolower($_SERVER['HTTP_USER_AGENT']);
}
else else
{
return ''; return '';
} }
}
/** /**
* Determine the OS for the browser * Determine the OS for the browser
@ -208,8 +224,12 @@ function is_browser($type) {
); );
if (isset($agents[$type])) if (isset($agents[$type]))
{
return in_array(get_user_agent_string(), $agents[$type]); return in_array(get_user_agent_string(), $agents[$type]);
}
else else
return false; {
return FALSE;
}
} }

View File

@ -19,11 +19,17 @@
$dir = opendir( '.' ); $dir = opendir( '.' );
while( ( $file = readdir( $dir ) ) !== false ) { while( ( $file = readdir( $dir ) ) !== false ) {
if( $file == '.' || $file == '..' ) if( $file == '.' || $file == '..' )
{
continue; continue;
}
if( ! preg_match( '/\.png$/', $file ) ) if( ! preg_match( '/\.png$/', $file ) )
{
continue; continue;
}
if( $file == 'phpLDAPadmin_logo1.png' ) if( $file == 'phpLDAPadmin_logo1.png' )
{
continue; continue;
}
$files[ filesize( $file ) . '_' . $file ] = $file; $files[ filesize( $file ) . '_' . $file ] = $file;
} }

View File

@ -19,11 +19,17 @@
$dir = opendir( '.' ); $dir = opendir( '.' );
while( ( $file = readdir( $dir ) ) !== false ) { while( ( $file = readdir( $dir ) ) !== false ) {
if( $file == '.' || $file == '..' ) if( $file == '.' || $file == '..' )
{
continue; continue;
}
if( ! preg_match( '/\.png$/', $file ) ) if( ! preg_match( '/\.png$/', $file ) )
{
continue; continue;
}
if( $file == 'phpLDAPadmin_logo1.png' ) if( $file == 'phpLDAPadmin_logo1.png' )
{
continue; continue;
}
$files[ filesize( $file ) . '_' . $file ] = $file; $files[ filesize( $file ) . '_' . $file ] = $file;
} }

View File

@ -60,7 +60,8 @@ while (! $request['import']->eof()) {
printf('<small>%s <a href="%s">%s</a>',$actionString[$changetype],$edit_href,$request['template']->getDN()); printf('<small>%s <a href="%s">%s</a>',$actionString[$changetype],$edit_href,$request['template']->getDN());
if ($request['import']->LDAPimport()) if ($request['import']->LDAPimport())
printf(' <span style="color:green;">%s</span></small><br />',_('Success')); {
printf(' <span style='color:green;'>%s</span></small><br />',_('Success')); }
else { else {
printf(' <span style="color:red;">%s</span></small><br /><br />',_('Failed')); printf(' <span style="color:red;">%s</span></small><br /><br />',_('Failed'));
@ -84,8 +85,10 @@ while (! $request['import']->eof()) {
} }
if (! $request['continuous_mode']) if (! $request['continuous_mode'])
{
break; break;
} }
}
function display_pla_parse_error($request) { function display_pla_parse_error($request) {
$type = $request->getType(); $type = $request->getType();
@ -103,7 +106,9 @@ function display_pla_parse_error($request) {
printf('<tr><td colspan=2><b>%s</b>:</td></tr>',_('Data')); printf('<tr><td colspan=2><b>%s</b>:</td></tr>',_('Data'));
foreach ($request->error['data'] as $line) foreach ($request->error['data'] as $line)
{
printf('<tr><td>&nbsp;</td><td>%s</td></tr>', $line); printf('<tr><td>&nbsp;</td><td>%s</td></tr>', $line);
}
echo '</table>'; echo '</table>';
echo '</center>'; echo '</center>';

View File

@ -13,7 +13,9 @@
require './common.php'; require './common.php';
if (! ini_get('file_uploads')) if (! ini_get('file_uploads'))
{
error(_('Your PHP.INI does not have file_uploads = ON. Please enable file uploads in PHP.'), 'error', 'index.php'); error(_('Your PHP.INI does not have file_uploads = ON. Please enable file uploads in PHP.'), 'error', 'index.php');
}
$request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none')); $request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
$request['page']->drawTitle(sprintf('<b>%s</b>',_('Import'))); $request['page']->drawTitle(sprintf('<b>%s</b>',_('Import')));

View File

@ -33,71 +33,103 @@ error_reporting(-1);
# General functions needed to proceed. # General functions needed to proceed.
ob_start(); ob_start();
if (! file_exists(LIBDIR.'functions.php')) { if (! file_exists(LIBDIR.'functions.php')) {
if (ob_get_level()) ob_end_clean(); if (ob_get_level())
{
ob_end_clean();
}
die(sprintf("Fatal error: Required file '<b>%sfunctions.php</b>' does not exist.",LIBDIR)); die(sprintf("Fatal error: Required file '<b>%sfunctions.php</b>' does not exist.",LIBDIR));
} }
if (! is_readable(LIBDIR.'functions.php')) { if (! is_readable(LIBDIR.'functions.php')) {
if (ob_get_level()) ob_end_clean(); if (ob_get_level())
{
ob_end_clean();
}
die(sprintf("Cannot read the file '<b>%sfunctions.php</b>' its permissions may be too strict.",LIBDIR)); die(sprintf("Cannot read the file '<b>%sfunctions.php</b>' its permissions may be too strict.",LIBDIR));
} }
if (ob_get_level()) if (ob_get_level())
{
ob_end_clean(); ob_end_clean();
}
# Make sure this PHP install has pcre # Make sure this PHP install has pcre
if (! extension_loaded('pcre')) if (! extension_loaded('pcre'))
{
die('<p>Your install of PHP appears to be missing PCRE support.</p><p>Please install PCRE support before using phpLDAPadmin.<br /><small>(Dont forget to restart your web server afterwards)</small></p>'); die('<p>Your install of PHP appears to be missing PCRE support.</p><p>Please install PCRE support before using phpLDAPadmin.<br /><small>(Dont forget to restart your web server afterwards)</small></p>');
}
require LIBDIR.'functions.php'; require LIBDIR.'functions.php';
spl_autoload_register("autoload"); spl_autoload_register("autoload");
# Define the path to our configuration file. # Define the path to our configuration file.
if (defined('CONFDIR')) if (defined('CONFDIR'))
{
$app['config_file'] = CONFDIR . 'config.php'; $app['config_file'] = CONFDIR . 'config.php';
}
else else
{
$app['config_file'] = 'config.php'; $app['config_file'] = 'config.php';
}
# Make sure this PHP install has session support # Make sure this PHP install has session support
if (! extension_loaded('session')) if (! extension_loaded('session'))
error('<p>Your install of PHP appears to be missing php-session support.</p><p>Please install php-session support before using phpLDAPadmin.<br /><small>(Dont forget to restart your web server afterwards)</small></p>','error',null,true); {
error('<p>Your install of PHP appears to be missing php-session support.</p><p>Please install php-session support before using phpLDAPadmin.<br /><small>(Dont forget to restart your web server afterwards)</small></p>', 'error', NULL, TRUE);
}
# Make sure this PHP install has gettext, we use it for language translation # Make sure this PHP install has gettext, we use it for language translation
if (! extension_loaded('gettext')) if (! extension_loaded('gettext'))
{
system_message(array( system_message(array(
'title' => _('Missing required extension'), 'title' => _('Missing required extension'),
'body' => 'Your install of PHP appears to be missing GETTEXT support.</p><p>GETTEXT is used for language translation.</p><p>Please install GETTEXT support before using phpLDAPadmin.<br /><small>(Dont forget to restart your web server afterwards)</small>', 'body' => 'Your install of PHP appears to be missing GETTEXT support.</p><p>GETTEXT is used for language translation.</p><p>Please install GETTEXT support before using phpLDAPadmin.<br /><small>(Dont forget to restart your web server afterwards)</small>',
'type' => 'error')); 'type' => 'error'));
}
# Make sure this PHP install has all our required extensions # Make sure this PHP install has all our required extensions
if (! extension_loaded('ldap')) if (! extension_loaded('ldap'))
{
system_message(array( system_message(array(
'title' => _('Missing required extension'), '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>', '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')); 'type' => 'error'));
}
# Make sure that we have php-xml loaded. # Make sure that we have php-xml loaded.
if (! function_exists('xml_parser_create')) if (! function_exists('xml_parser_create'))
{
system_message(array( system_message(array(
'title' => _('Missing required extension'), '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>', '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')); 'type' => 'error'));
}
/** /**
* Helper functions. * Helper functions.
* Our required helper functions are defined in functions.php * Our required helper functions are defined in functions.php
*/ */
if (isset($app['function_files']) && is_array($app['function_files'])) if (isset($app['function_files']) && is_array($app['function_files']))
foreach ($app['function_files'] as $file_name ) { {
foreach ($app['function_files'] as $file_name)
{
if ( ! file_exists($file_name)) if ( ! file_exists($file_name))
error(sprintf('Fatal error: Required file "%s" does not exist.',$file_name),'error',null,true); {
error(sprintf('Fatal error: Required file "%s" does not exist.', $file_name), 'error', NULL, TRUE);
}
if ( ! is_readable($file_name)) if ( ! is_readable($file_name))
error(sprintf('Fatal error: Cannot read the file "%s", its permissions may be too strict.',$file_name),'error',null,true); {
error(sprintf('Fatal error: Cannot read the file "%s", its permissions may be too strict.', $file_name), 'error', NULL, TRUE);
}
ob_start(); ob_start();
require $file_name; require $file_name;
if (ob_get_level()) ob_end_clean(); if (ob_get_level())
{
ob_end_clean();
}
}
} }
# Configuration File check # Configuration File check
@ -122,7 +154,9 @@ if (! $config = check_config($app['config_file'])) {
} }
if ($uri = get_request('URI','GET')) if ($uri = get_request('URI','GET'))
{
header(sprintf('Location: cmd.php?%s', base64_decode($uri))); header(sprintf('Location: cmd.php?%s', base64_decode($uri)));
}
if (! preg_match('/^([0-9]+\.?)+/',app_version())) { if (! preg_match('/^([0-9]+\.?)+/',app_version())) {
system_message(array( system_message(array(
@ -131,17 +165,21 @@ if (! preg_match('/^([0-9]+\.?)+/',app_version())) {
'type'=>'info','special'=>true)); 'type'=>'info','special'=>true));
if (count($_SESSION[APPCONFIG]->untested())) if (count($_SESSION[APPCONFIG]->untested()))
{
system_message(array( system_message(array(
'title' => 'Untested configuration paramaters', 'title' => 'Untested configuration paramaters',
'body' => sprintf('The following parameters have not been tested. If you have configured these parameters, and they are working as expected, please let the developers know, so that they can be removed from this message.<br/><small>%s</small>', implode(', ', $_SESSION[APPCONFIG]->untested())), 'body' => sprintf('The following parameters have not been tested. If you have configured these parameters, and they are working as expected, please let the developers know, so that they can be removed from this message.<br/><small>%s</small>', implode(', ', $_SESSION[APPCONFIG]->untested())),
'type'=>'info','special'=>true)); 'type' => 'info', 'special' => TRUE));
}
$server = $_SESSION[APPCONFIG]->getServer(get_request('server_id','REQUEST')); $server = $_SESSION[APPCONFIG]->getServer(get_request('server_id','REQUEST'));
if (count($server->untested())) if (count($server->untested()))
{
system_message(array( system_message(array(
'title' => 'Untested server configuration paramaters', 'title' => 'Untested server configuration paramaters',
'body' => sprintf('The following parameters have not been tested. If you have configured these parameters, and they are working as expected, please let the developers know, so that they can be removed from this message.<br/><small>%s</small>', implode(', ', $server->untested())), 'body' => sprintf('The following parameters have not been tested. If you have configured these parameters, and they are working as expected, please let the developers know, so that they can be removed from this message.<br/><small>%s</small>', implode(', ', $server->untested())),
'type'=>'info','special'=>true)); 'type' => 'info', 'special' => TRUE));
}
} }
include './cmd.php'; include './cmd.php';

View File

@ -16,22 +16,28 @@ $user['login'] = get_request('login');
$user['password'] = get_request('login_pass'); $user['password'] = get_request('login_pass');
if ($user['login'] && ! strlen($user['password'])) if ($user['login'] && ! strlen($user['password']))
{
system_message(array( system_message(array(
'title' => _('Authenticate to server'), 'title' => _('Authenticate to server'),
'body' => _('You left the password blank.'), 'body' => _('You left the password blank.'),
'type' => 'warn'), 'type' => 'warn'),
sprintf('cmd.php?cmd=login_form&server_id=%s', get_request('server_id', 'REQUEST'))); sprintf('cmd.php?cmd=login_form&server_id=%s', get_request('server_id', 'REQUEST')));
}
if ($app['server']->login($user['login'],$user['password'],'user')) if ($app['server']->login($user['login'],$user['password'],'user'))
{
system_message(array( system_message(array(
'title' => _('Authenticate to server'), 'title' => _('Authenticate to server'),
'body' => _('Successfully logged into server.'), 'body' => _('Successfully logged into server.'),
'type' => 'info'), 'type' => 'info'),
sprintf('cmd.php?server_id=%s', get_request('server_id', 'REQUEST'))); sprintf('cmd.php?server_id=%s', get_request('server_id', 'REQUEST')));
}
else else
{
system_message(array( system_message(array(
'title' => _('Failed to Authenticate to server'), 'title' => _('Failed to Authenticate to server'),
'body' => _('Invalid Username or Password.'), 'body' => _('Invalid Username or Password.'),
'type' => 'error'), 'type' => 'error'),
sprintf('cmd.php?cmd=login_form&server_id=%s', get_request('server_id', 'REQUEST'))); sprintf('cmd.php?cmd=login_form&server_id=%s', get_request('server_id', 'REQUEST')));
}

View File

@ -44,9 +44,13 @@ if ($app['server']->getAuthType() == 'http') {
header(sprintf('WWW-Authenticate: Basic realm="%s"',$_SESSION[APPCONFIG]->getValue('session','http_realm'))); header(sprintf('WWW-Authenticate: Basic realm="%s"',$_SESSION[APPCONFIG]->getValue('session','http_realm')));
if ($_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.0') if ($_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.0')
header('HTTP/1.0 401 Unauthorized'); // http 1.0 method {
header('HTTP/1.0 401 Unauthorized');
} // http 1.0 method
else else
header('Status: 401 Unauthorized'); // http 1.1 method {
header('Status: 401 Unauthorized');
} // http 1.1 method
return; return;
@ -59,7 +63,8 @@ if ($app['server']->getAuthType() == 'http') {
echo '<input type="hidden" name="nodecode[login_pass]" value="1" />'; echo '<input type="hidden" name="nodecode[login_pass]" value="1" />';
if (get_request('redirect','GET',false,false)) if (get_request('redirect','GET',false,false))
printf('<input type="hidden" name="redirect" value="%s" />',rawurlencode(get_request('redirect','GET'))); {
printf('<input type='hidden' name='redirect' value=' % s' />',rawurlencode(get_request('redirect', 'GET'))); }
echo '</div>'; echo '</div>';
@ -79,8 +84,10 @@ if ($app['server']->getAuthType() == 'http') {
# If Anon bind allowed, then disable the form if the user choose to bind anonymously. # If Anon bind allowed, then disable the form if the user choose to bind anonymously.
if ($app['server']->isAnonBindAllowed()) if ($app['server']->isAnonBindAllowed())
{
printf('<tr><td colspan="2"><small><b>%s</b></small> <input type="checkbox" name="anonymous_bind" onclick="form_field_toggle_enable(this,[\'login\',\'password\'],\'login\')" id="anonymous_bind_checkbox" /></td></tr>', printf('<tr><td colspan="2"><small><b>%s</b></small> <input type="checkbox" name="anonymous_bind" onclick="form_field_toggle_enable(this,[\'login\',\'password\'],\'login\')" id="anonymous_bind_checkbox" /></td></tr>',
_('Anonymous')); _('Anonymous'));
}
printf('<tr><td colspan="2" style="text-align: center;"><input type="submit" name="submit" value="%s" /></td></tr>', printf('<tr><td colspan="2" style="text-align: center;"><input type="submit" name="submit" value="%s" /></td></tr>',
_('Authenticate')); _('Authenticate'));
@ -93,6 +100,8 @@ if ($app['server']->getAuthType() == 'http') {
echo '<script type="text/javascript">document.getElementById("login").focus()</script>'; echo '<script type="text/javascript">document.getElementById("login").focus()</script>';
if ($app['server']->isAnonBindAllowed()) if ($app['server']->isAnonBindAllowed())
{
printf('<script type="text/javascript" src="%sform_field_toggle_enable.js"></script>', JSDIR); printf('<script type="text/javascript" src="%sform_field_toggle_enable.js"></script>', JSDIR);
} }
}

View File

@ -21,9 +21,11 @@ if ($app['server']->logout()) {
sprintf('index.php?server_id=%s',$app['server']->getIndex())); sprintf('index.php?server_id=%s',$app['server']->getIndex()));
} else } else
{
system_message(array( system_message(array(
'title' => _('Failed to Logout of server'), 'title' => _('Failed to Logout of server'),
'body' => _('Please report this error to the admins.'), 'body' => _('Please report this error to the admins.'),
'type' => 'error'), 'type' => 'error'),
sprintf('index.php?server_id=%s', $app['server']->getIndex())); sprintf('index.php?server_id=%s', $app['server']->getIndex()));
}

View File

@ -16,23 +16,29 @@ $request = array();
$request['dn'] = get_request('dn','REQUEST'); $request['dn'] = get_request('dn','REQUEST');
if (! $request['dn']) if (! $request['dn'])
{
system_message(array( system_message(array(
'title' => _('No entry selected'), 'title' => _('No entry selected'),
'body' => _('No entry was selected to delete'), 'body' => _('No entry was selected to delete'),
'type' => 'warn'), 'index.php'); 'type' => 'warn'), 'index.php');
}
if (! is_array($request['dn'])) if (! is_array($request['dn']))
{
$request['dn'] = array($request['dn']); $request['dn'] = array($request['dn']);
}
$request['children'] = array(); $request['children'] = array();
$request['parent'] = array(); $request['parent'] = array();
foreach ($request['dn'] as $dn) { foreach ($request['dn'] as $dn) {
# Check if the entry exists. # Check if the entry exists.
if (! $dn || ! $app['server']->dnExists($dn)) if (! $dn || ! $app['server']->dnExists($dn))
{
system_message(array( system_message(array(
'title' => _('Entry does not exist'), 'title' => _('Entry does not exist'),
'body' => sprintf('%s (%s/%s)', _('The entry does not exist and will be ignored'), $dn), 'body' => sprintf('%s (%s/%s)', _('The entry does not exist and will be ignored'), $dn),
'type' => 'error')); 'type' => 'error'));
}
# We search all children, not only the visible children in the tree # We search all children, not only the visible children in the tree
if (! in_array_ignore_case($dn,$request['children'])) { if (! in_array_ignore_case($dn,$request['children'])) {
@ -49,16 +55,21 @@ echo '<center>';
echo '<table class="forminput" border="0">'; echo '<table class="forminput" border="0">';
if (count($request['parent']) == 1) if (count($request['parent']) == 1)
printf('<tr><td colspan="4"><b>%s</b></td></tr>',_('Are you sure you want to permanently delete this object?')); {
printf('<tr><td colspan='4'><b>%s</b></td></tr>',_('Are you sure you want to permanently delete this object?')); }
else else
{
printf('<tr><td colspan="4"><b>%s</b></td></tr>', _('Are you sure you want to permanently delete these objects?')); printf('<tr><td colspan="4"><b>%s</b></td></tr>', _('Are you sure you want to permanently delete these objects?'));
}
echo '<tr><td colspan="4">&nbsp;</td></tr>'; echo '<tr><td colspan="4">&nbsp;</td></tr>';
printf('<tr><td style="width: 10%%;">%s:</td><td colspan="3" style="width: 75%%;"><b>%s</b></td></tr>',_('Server'),$app['server']->getName()); printf('<tr><td style="width: 10%%;">%s:</td><td colspan="3" style="width: 75%%;"><b>%s</b></td></tr>',_('Server'),$app['server']->getName());
foreach ($request['parent'] as $dn) foreach ($request['parent'] as $dn)
{
printf('<tr><td style="width: 10%%;"><acronym title="%s">%s</acronym></td><td colspan="3" style="width: 75%%;"><b>%s</b></td></tr>', printf('<tr><td style="width: 10%%;"><acronym title="%s">%s</acronym></td><td colspan="3" style="width: 75%%;"><b>%s</b></td></tr>',
_('Distinguished Name'), _('DN'), $dn); _('Distinguished Name'), _('DN'), $dn);
}
echo '<tr><td colspan="4">&nbsp;</td></tr>'; echo '<tr><td colspan="4">&nbsp;</td></tr>';
@ -82,7 +93,9 @@ if (count($request['children'])) {
} }
foreach ($request['search'] as $value) foreach ($request['search'] as $value)
{
array_push($request['delete'], $value['dn']); array_push($request['delete'], $value['dn']);
}
echo '<tr>'; echo '<tr>';
echo '<td colspan="4">'; echo '<td colspan="4">';
@ -109,7 +122,9 @@ if (count($request['children'])) {
echo '<tr><td colspan="4"><center>'; echo '<tr><td colspan="4"><center>';
printf('<select size="%s" multiple disabled style="background:white; color:black;width:500px" >',min(10,count($request['delete']))); printf('<select size="%s" multiple disabled style="background:white; color:black;width:500px" >',min(10,count($request['delete'])));
foreach ($request['delete'] as $key => $value) foreach ($request['delete'] as $key => $value)
{
printf('<option>%s. %s</option>', ++$i, htmlspecialchars(dn_unescape($value))); printf('<option>%s. %s</option>', ++$i, htmlspecialchars(dn_unescape($value)));
}
echo '</select>'; echo '</select>';
echo '</center></td></tr>'; echo '</center></td></tr>';
echo "\n"; echo "\n";
@ -123,7 +138,9 @@ echo '<form action="cmd.php" method="post">';
echo '<input type="hidden" name="cmd" value="rdelete" />'; echo '<input type="hidden" name="cmd" value="rdelete" />';
printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex()); printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
foreach ($request['parent'] as $dn) foreach ($request['parent'] as $dn)
{
printf('<input type="hidden" name="dn[]" value="%s" />', htmlspecialchars($dn)); printf('<input type="hidden" name="dn[]" value="%s" />', htmlspecialchars($dn));
}
printf('<input type="submit" value="%s" />',sprintf(_('Delete all %s objects'),count($request['delete']))); printf('<input type="submit" value="%s" />',sprintf(_('Delete all %s objects'),count($request['delete'])));
echo '</form>'; echo '</form>';
echo '</center></td>'; echo '</center></td>';

View File

@ -40,16 +40,20 @@ foreach ($request['dn'] as $dn) {
# Mark our attributes to edit as shown. # Mark our attributes to edit as shown.
foreach ($template->getAttributes(true) as $attribute) { foreach ($template->getAttributes(true) as $attribute) {
if ($attribute->isInternal()) if ($attribute->isInternal())
{
continue; continue;
}
if (in_array_ignore_case($attribute->getName(),$request['attrs']) || in_array('*',$request['attrs'])) { if (in_array_ignore_case($attribute->getName(),$request['attrs']) || in_array('*',$request['attrs'])) {
$attribute->show(); $attribute->show();
# Get a list of our columns (we are not interested in these attribute values) # Get a list of our columns (we are not interested in these attribute values)
if (! isset($attrcols[$attribute->getName()])) if (! isset($attrcols[$attribute->getName()]))
{
$attrcols[$attribute->getName()] = $attribute; $attrcols[$attribute->getName()] = $attribute;
} }
} }
}
$counter++; $counter++;
} }
@ -57,7 +61,9 @@ foreach ($request['dn'] as $dn) {
usort($attrcols,'sortAttrs'); usort($attrcols,'sortAttrs');
if (! count($request['page'])) if (! count($request['page']))
{
header('Location: index.php'); header('Location: index.php');
}
# We'll render this forms Title with the first DN's object. # We'll render this forms Title with the first DN's object.
$request['page'][0]->drawTitle(_('Bulk edit the following DNs')); $request['page'][0]->drawTitle(_('Bulk edit the following DNs'));
@ -69,7 +75,8 @@ echo '<input type="hidden" name="cmd" value="mass_update" />';
printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex()); printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
foreach ($request['page'] as $j => $page) foreach ($request['page'] as $j => $page)
printf('<input type="hidden" name="dn[%s]" value="%s" />',$j,$page->getTemplate()->getDN()); {
printf('<input type='hidden' name='dn[%s]' value=' % s' />',$j,$page->getTemplate()->getDN()); }
echo '</div>'; echo '</div>';
@ -99,7 +106,9 @@ foreach ($request['page'] as $j => $page) {
echo '<td>'; echo '<td>';
if ($attribute) { if ($attribute) {
foreach ($attribute->getValues() as $i => $val) foreach ($attribute->getValues() as $i => $val)
{
$page->draw('MassFormReadWriteValue', $attribute, $i, $j); $page->draw('MassFormReadWriteValue', $attribute, $i, $j);
}
# The attribute doesnt exist. If it is available by the shema, we can draw an empty input box. # The attribute doesnt exist. If it is available by the shema, we can draw an empty input box.
} else { } else {
@ -115,8 +124,10 @@ foreach ($request['page'] as $j => $page) {
} }
if (! $match) if (! $match)
{
printf('<center><small>%s</small></center>', _('Attribute not available')); printf('<center><small>%s</small></center>', _('Attribute not available'));
} }
}
echo '</td>'; echo '</td>';
} }

View File

@ -32,7 +32,9 @@ foreach ($request['dn'] as $index => $dn) {
# Simulate the requirements for *Render->accept() # Simulate the requirements for *Render->accept()
if (! isset($request['mass_values'][$index])) if (! isset($request['mass_values'][$index]))
{
continue; continue;
}
$_REQUEST['new_values'] = $request['mass_values'][$index]; $_REQUEST['new_values'] = $request['mass_values'][$index];
@ -41,8 +43,10 @@ foreach ($request['dn'] as $index => $dn) {
$render->accept(true); $render->accept(true);
if ($render->getTemplate()->getLDAPmodify(false,$index)) if ($render->getTemplate()->getLDAPmodify(false,$index))
{
$request['update'][$index] = $render; $request['update'][$index] = $render;
} }
}
# We can use the $render to give us a title # We can use the $render to give us a title
$render->drawTitle(_('Bulk update the following DNs')); $render->drawTitle(_('Bulk update the following DNs'));
@ -57,10 +61,14 @@ if (count($request['update'])) {
$result = $app['server']->modify($template->getDN(),$template->getLDAPmodify(false,$index)); $result = $app['server']->modify($template->getDN(),$template->getLDAPmodify(false,$index));
if ($result) if ($result)
{
printf('%s: <b>%s</b><br>', $template->getDN(), _('Modification successful!')); printf('%s: <b>%s</b><br>', $template->getDN(), _('Modification successful!'));
}
else else
{
printf('%s: <b>%s</b><br>', $template->getDN(), _('Modification NOT successful!')); printf('%s: <b>%s</b><br>', $template->getDN(), _('Modification NOT successful!'));
} }
}
} else { } else {
echo '<form action="cmd.php" method="post">'; echo '<form action="cmd.php" method="post">';
@ -69,7 +77,9 @@ if (count($request['update'])) {
echo '<input type="hidden" name="confirm" value="1" />'; echo '<input type="hidden" name="confirm" value="1" />';
foreach ($request['update'] as $j => $page) foreach ($request['update'] as $j => $page)
{
printf('<input type="hidden" name="dn[%s]" value="%s" />', $j, $page->getTemplate()->getDN()); printf('<input type="hidden" name="dn[%s]" value="%s" />', $j, $page->getTemplate()->getDN());
}
echo '<table class="result_box" width="100%" border="1">'; echo '<table class="result_box" width="100%" border="1">';
echo '<tr><td>'; echo '<tr><td>';
@ -117,13 +127,17 @@ if (count($request['update'])) {
foreach ($attribute->getValues() as $key => $value) { foreach ($attribute->getValues() as $key => $value) {
# For multiple values, we'll highlight the changed ones # For multiple values, we'll highlight the changed ones
if ((count($attribute->getValues()) > 5) && in_array($value,$attribute->getAddedValues())) if ((count($attribute->getValues()) > 5) && in_array($value,$attribute->getAddedValues()))
{
echo '<span style="color:#004400; background:#FFFFA0">'; echo '<span style="color:#004400; background:#FFFFA0">';
}
$page->draw('CurrentValue',$attribute,$key); $page->draw('CurrentValue',$attribute,$key);
# For multiple values, close the highlighting # For multiple values, close the highlighting
if ((count($attribute->getValues()) > 5) && in_array($value,$attribute->getAddedValues())) if ((count($attribute->getValues()) > 5) && in_array($value,$attribute->getAddedValues()))
{
echo '</span>'; echo '</span>';
}
echo '<br />'; echo '<br />';
printf('<input type="hidden" name="mass_values[%s][%s][%s]" value="%s" />',$index,$attribute->getName(),$key,$value); printf('<input type="hidden" name="mass_values[%s][%s][%s]" value="%s" />',$index,$attribute->getName(),$key,$value);
@ -135,18 +149,24 @@ if (count($request['update'])) {
echo '<td><span style="white-space: nowrap;">'; echo '<td><span style="white-space: nowrap;">';
if (! $attribute->getOldValues()) if (! $attribute->getOldValues())
{
printf('<span style="color: green">[%s]</span>', _('attribute doesnt exist')); printf('<span style="color: green">[%s]</span>', _('attribute doesnt exist'));
}
foreach ($attribute->getOldValues() as $key => $value) { foreach ($attribute->getOldValues() as $key => $value) {
# For multiple values, we'll highlight the changed ones # For multiple values, we'll highlight the changed ones
if ((count($attribute->getOldValues()) > 5) && in_array($value,$attribute->getRemovedValues()) && count($attribute->getValues())) if ((count($attribute->getOldValues()) > 5) && in_array($value,$attribute->getRemovedValues()) && count($attribute->getValues()))
{
echo '<span style="color:#880000; background:#FFFFA0">'; echo '<span style="color:#880000; background:#FFFFA0">';
}
$page->draw('OldValue',$attribute,$key); $page->draw('OldValue',$attribute,$key);
# For multiple values, close the highlighting # For multiple values, close the highlighting
if ((count($attribute->getOldValues()) > 5) && in_array($value,$attribute->getRemovedValues()) && count($attribute->getValues())) if ((count($attribute->getOldValues()) > 5) && in_array($value,$attribute->getRemovedValues()) && count($attribute->getValues()))
{
echo '</span>'; echo '</span>';
}
echo '<br />'; echo '<br />';
} }

View File

@ -22,9 +22,13 @@ $request['page']->accept(true);
$request['template'] = $request['page']->getTemplate(); $request['template'] = $request['page']->getTemplate();
if (! is_null($request['dn'])) if (! is_null($request['dn']))
{
$rdn = get_rdn($request['dn']); $rdn = get_rdn($request['dn']);
}
else else
$rdn = null; {
$rdn = NULL;
}
# Get all current group members # Get all current group members
$current_members = $app['server']->getDNAttrValue($request['dn'],$request['attr']); $current_members = $app['server']->getDNAttrValue($request['dn'],$request['attr']);
@ -63,10 +67,14 @@ printf('%s <b>%s</b> %s <b>%s</b>:',
$possible_members = array(); $possible_members = array();
for ($i=0;$i<count($possible_values);$i++) { for ($i=0;$i<count($possible_values);$i++) {
if (preg_match("/^".$request['attr']."$/i",$_SESSION[APPCONFIG]->getValue('modify_member','posixgroupattr'))) if (preg_match("/^".$request['attr']."$/i",$_SESSION[APPCONFIG]->getValue('modify_member','posixgroupattr')))
{
$possible_members[$i] = $possible_values[$i][$_SESSION[APPCONFIG]->getValue('modify_member', 'posixattr')][0]; $possible_members[$i] = $possible_values[$i][$_SESSION[APPCONFIG]->getValue('modify_member', 'posixattr')][0];
}
else else
{
$possible_members[$i] = $possible_values[$i][$_SESSION[APPCONFIG]->getValue('modify_member', 'attr')]; $possible_members[$i] = $possible_values[$i][$_SESSION[APPCONFIG]->getValue('modify_member', 'attr')];
} }
}
# Show only user that are not already in group. # Show only user that are not already in group.
$possible_members = array_diff($possible_members,$current_members); $possible_members = array_diff($possible_members,$current_members);
@ -82,9 +90,12 @@ echo '<br />';
echo '<form action="cmd.php" method="post" class="add_value" id="member">'; echo '<form action="cmd.php" method="post" class="add_value" id="member">';
echo '<div>'; echo '<div>';
if ($_SESSION[APPCONFIG]->getValue('confirm','update')) if ($_SESSION[APPCONFIG]->getValue('confirm','update'))
echo '<input type="hidden" name="cmd" value="update_confirm" />'; {
echo '<input type='hidden' name='cmd' value='update_confirm' />'; }
else else
{
echo '<input type="hidden" name="cmd" value="update" />'; echo '<input type="hidden" name="cmd" value="update" />';
}
echo '</div>'; echo '</div>';
echo '<table class="modify_members">'; echo '<table class="modify_members">';
@ -107,16 +118,20 @@ switch ($request['attr']) {
$possible = sprintf('(,%s,)',$matches[1]); $possible = sprintf('(,%s,)',$matches[1]);
if (! in_array($possible,$current_members)) if (! in_array($possible,$current_members))
{
printf('<option>%s</option>', $possible); printf('<option>%s</option>', $possible);
} }
}
break; break;
case ('memberuid' || 'member' || 'uniquemember'): case ('memberuid' || 'member' || 'uniquemember'):
foreach ($possible_members as $possible) { foreach ($possible_members as $possible) {
if (! in_array($possible,$current_members)) if (! in_array($possible,$current_members))
{
printf('<option>%s</option>', $possible); printf('<option>%s</option>', $possible);
} }
}
break; break;
} }
@ -129,7 +144,9 @@ echo '<td>';
echo '<select name="members" size="10" multiple="multiple">'; echo '<select name="members" size="10" multiple="multiple">';
foreach ($current_members as $current) foreach ($current_members as $current)
{
printf('<option>%s</option>', htmlspecialchars($current)); printf('<option>%s</option>', htmlspecialchars($current));
}
echo '</select>'; echo '</select>';
echo '</td>'; echo '</td>';
@ -158,8 +175,10 @@ printf('<input type="hidden" name="attr" value="%s" />',$request['attr']);
/* Generate array of input text boxes from current members. /* Generate array of input text boxes from current members.
* update_confirm.php will see this as old_values[member-attribute][item] */ * update_confirm.php will see this as old_values[member-attribute][item] */
for ($i=0; $i<count($current_members); $i++) for ($i=0; $i<count($current_members); $i++)
{
printf('<input type="hidden" name="old_values[%s][%s]" value="%s" />', printf('<input type="hidden" name="old_values[%s][%s]" value="%s" />',
htmlspecialchars($request['attr']), $i, htmlspecialchars($current_members[$i])); htmlspecialchars($request['attr']), $i, htmlspecialchars($current_members[$i]));
}
/* Javascript generates array of input text boxes from new members. /* Javascript generates array of input text boxes from new members.
* update_confirm.php will see this as new_values[member-attribute][item] * update_confirm.php will see this as new_values[member-attribute][item]

View File

@ -20,10 +20,12 @@ $query['attrs'] = array('+','*');
$results = $app['server']->query($query,null); $results = $app['server']->query($query,null);
if (! isset($attrs['monitorcontext']) || ! count($results)) if (! isset($attrs['monitorcontext']) || ! count($results))
{
system_message(array( system_message(array(
'title' => _('Monitoring context does not exist'), 'title' => _('Monitoring context does not exist'),
'body' => sprintf('%s: <b>%s</b>', _('Could not obtain the monitor context for this server'), $app['server']->getName()), 'body' => sprintf('%s: <b>%s</b>', _('Could not obtain the monitor context for this server'), $app['server']->getName()),
'type' => 'warn'), 'index.php'); 'type' => 'warn'), 'index.php');
}
printf('<h3 class="title">%s%s</h3>',_('Monitor info for: '),$app['server']->getName()); printf('<h3 class="title">%s%s</h3>',_('Monitor info for: '),$app['server']->getName());
printf('<h3 class="subtitle">%s</h3>',_('Server reports the following information about itself')); printf('<h3 class="subtitle">%s</h3>',_('Server reports the following information about itself'));
@ -67,7 +69,9 @@ foreach (array(
printf('<td style="width: 10%%;">%s</td><td style="width: 20%%;">%s</td>',_('Type'),'namingContext'); printf('<td style="width: 10%%;">%s</td><td style="width: 20%%;">%s</td>',_('Type'),'namingContext');
foreach ($attrs as $attr) foreach ($attrs as $attr)
{
printf('<td style="width: 20%%;">%s</td>', $attr); printf('<td style="width: 20%%;">%s</td>', $attr);
}
echo '</tr>'; echo '</tr>';
@ -83,12 +87,17 @@ foreach (array(
$seealso = is_array($results[$key]['seealso']) ? $results[$key]['seealso'] : array($results[$key]['seealso']); $seealso = is_array($results[$key]['seealso']) ? $results[$key]['seealso'] : array($results[$key]['seealso']);
foreach ($seealso as $db) foreach ($seealso as $db)
{
if (isset($results[$db]['namingcontexts'])) if (isset($results[$db]['namingcontexts']))
{
printf('<acronym title="%s">%s</acronym><br/>', printf('<acronym title="%s">%s</acronym><br/>',
isset($results[$db]['labeleduri']) ? implode(' ', $results[$db]['labeleduri']) : _('Internal'), isset($results[$db]['labeleduri']) ? implode(' ', $results[$db]['labeleduri']) : _('Internal'),
implode(' ', $results[$db]['namingcontexts'])); implode(' ', $results[$db]['namingcontexts']));
else } else
{
printf('%s ', implode(' ', $results[$db]['monitoredinfo'])); printf('%s ', implode(' ', $results[$db]['monitoredinfo']));
}
}
} else { } else {
echo '&nbsp;'; echo '&nbsp;';
@ -99,20 +108,29 @@ foreach (array(
echo '<td>'; echo '<td>';
if (isset($results[$key][$attr])) { if (isset($results[$key][$attr])) {
if (! is_array($results[$key][$attr])) if (! is_array($results[$key][$attr]))
{
$sc = array($results[$key][$attr]); $sc = array($results[$key][$attr]);
}
else else
{
$sc = $results[$key][$attr]; $sc = $results[$key][$attr];
}
if (strcasecmp('supportedcontrol',$attr) == 0) if (strcasecmp('supportedcontrol',$attr) == 0)
foreach ($sc as $control) { {
foreach ($sc as $control)
{
$oidtotext = support_oid_to_text($control); $oidtotext = support_oid_to_text($control);
printf('<acronym title="%s">%s</acronym><br/>', printf('<acronym title="%s">%s</acronym><br/>',
$control, $oidtotext['title']); $control, $oidtotext['title']);
} }
}
else else
{
printf('%s ', implode('<br/>', $sc)); printf('%s ', implode('<br/>', $sc));
}
} else { } else {
echo '&nbsp;'; echo '&nbsp;';
@ -207,14 +225,20 @@ foreach (array(
echo '<table class="result_table" border="0" width="100%">'; echo '<table class="result_table" border="0" width="100%">';
if (isset($results[$dn]['monitoropinitiated'])) if (isset($results[$dn]['monitoropinitiated']))
{
printf('<tr class="highlight"><td style="width: 20%%;">%s</td><td class="value" style="width: 80%%;">%s</td></tr>', printf('<tr class="highlight"><td style="width: 20%%;">%s</td><td class="value" style="width: 80%%;">%s</td></tr>',
'monitorOpInitiated', $results[$dn]['monitoropinitiated'][0]); 'monitorOpInitiated', $results[$dn]['monitoropinitiated'][0]);
}
if (isset($results[$dn]['monitoropcompleted'])) if (isset($results[$dn]['monitoropcompleted']))
{
printf('<tr class="highlight"><td style="width: 20%%;">%s</td><td class="value" style="width: 80%%;">%s</td></tr>', printf('<tr class="highlight"><td style="width: 20%%;">%s</td><td class="value" style="width: 80%%;">%s</td></tr>',
'monitorOpCompleted', $results[$dn]['monitoropcompleted'][0]); 'monitorOpCompleted', $results[$dn]['monitoropcompleted'][0]);
}
if (isset($results[$dn]['monitoredinfo'])) if (isset($results[$dn]['monitoredinfo']))
{
printf('<tr class="highlight"><td style="width: 20%%;">%s</td><td class="value" style="width: 80%%;">%s</td></tr>', printf('<tr class="highlight"><td style="width: 20%%;">%s</td><td class="value" style="width: 80%%;">%s</td></tr>',
'monitoredInfo', $results[$dn]['monitoredinfo'][0]); 'monitoredInfo', $results[$dn]['monitoredinfo'][0]);
}
# Look for some connecitons # Look for some connecitons
foreach ($results as $key => $value) { foreach ($results as $key => $value) {

View File

@ -56,9 +56,13 @@ if ($request['action'] == 'compare') {
echo '&nbsp;&nbsp;&nbsp;&nbsp;<b>'; echo '&nbsp;&nbsp;&nbsp;&nbsp;<b>';
if (password_check($request['hash'],$request['password'],$request['attribute'])) if (password_check($request['hash'],$request['password'],$request['attribute']))
{
printf('<span class="good">%s</span>', _('Passwords match!')); printf('<span class="good">%s</span>', _('Passwords match!'));
}
else else
{
printf('<span class="bad">%s</span>', _('Passwords do not match!')); printf('<span class="bad">%s</span>', _('Passwords do not match!'));
}
echo '</b>'; echo '</b>';
} }

View File

@ -15,15 +15,22 @@ $purge_session_keys = array('app_initialized','backtrace','cache',APPCONFIG);
$size = 0; $size = 0;
foreach ($purge_session_keys as $key) foreach ($purge_session_keys as $key)
if (isset($_SESSION[$key])) { {
if (isset($_SESSION[$key]))
{
$size += strlen(serialize($_SESSION[$key])); $size += strlen(serialize($_SESSION[$key]));
unset($_SESSION[$key]); unset($_SESSION[$key]);
} }
}
if (! $size) if (! $size)
{
$body = _('No cache to purge.'); $body = _('No cache to purge.');
}
else else
{
$body = sprintf(_('Purged %s bytes of cache.'), number_format($size)); $body = sprintf(_('Purged %s bytes of cache.'), number_format($size));
}
system_message(array( system_message(array(
'title'=>_('Purge cache'), 'title'=>_('Purge cache'),

View File

@ -15,17 +15,24 @@ $request = array();
$request['dn'] = get_request('dn','REQUEST',true); $request['dn'] = get_request('dn','REQUEST',true);
if (! is_array($request['dn'])) if (! is_array($request['dn']))
{
$request['dn'] = array($request['dn']); $request['dn'] = array($request['dn']);
}
$request['parent'] = array(); $request['parent'] = array();
foreach ($request['dn'] as $dn) foreach ($request['dn'] as $dn)
{
if ( ! $app['server']->dnExists($dn)) if ( ! $app['server']->dnExists($dn))
{
system_message(array( system_message(array(
'title' => _('Entry does not exist'), 'title' => _('Entry does not exist'),
'body' => sprintf('%s (%s)', _('Unable to delete entry, it does not exist'), $dn), 'body' => sprintf('%s (%s)', _('Unable to delete entry, it does not exist'), $dn),
'type' => 'error')); 'type' => 'error'));
else } else
{
array_push($request['parent'], $dn); array_push($request['parent'], $dn);
}
}
printf('<h3 class="title">%s</h3>',_('Delete LDAP entries')); printf('<h3 class="title">%s</h3>',_('Delete LDAP entries'));
printf('<h3 class="subtitle">%s</h3>',_('Recursive delete progress')); printf('<h3 class="subtitle">%s</h3>',_('Recursive delete progress'));
@ -70,7 +77,9 @@ function pla_rdelete($server,$dn) {
} else { } else {
foreach ($children as $child_dn) foreach ($children as $child_dn)
{
pla_rdelete($server, $child_dn); pla_rdelete($server, $child_dn);
}
printf('<span style="white-space: nowrap;">%s %s...',_('Deleting'),$dn); printf('<span style="white-space: nowrap;">%s %s...',_('Deleting'),$dn);

View File

@ -17,9 +17,13 @@ if (get_request('purge','REQUEST')) {
del_cached_item($app['server']->getIndex(),'tree'); del_cached_item($app['server']->getIndex(),'tree');
if ($tree) if ($tree)
{
$openDNs = $tree->listOpenItems(); $openDNs = $tree->listOpenItems();
}
else else
{
$openDNs = array(); $openDNs = array();
}
$tree = Tree::getInstance($app['server']->getIndex()); $tree = Tree::getInstance($app['server']->getIndex());
@ -38,9 +42,13 @@ if (get_request('purge','REQUEST')) {
} }
if (get_request('meth','REQUEST') == 'ajax') if (get_request('meth','REQUEST') == 'ajax')
header(sprintf('Location: cmd.php?cmd=draw_tree_node&noheader=%s&server_id=%s&meth=ajax&frame=TREE',get_request('noheader','REQUEST',false,0),$app['server']->getIndex())); {
header(sprintf('Location: cmd.php?cmd=draw_tree_node&noheader=%s&server_id=%s&meth=ajax&frame=TREE', get_request('noheader', 'REQUEST', FALSE, 0), $app['server']->getIndex()));
}
else else
{
header(sprintf('Location: cmd.php?server_id=%s', $app['server']->getIndex())); header(sprintf('Location: cmd.php?server_id=%s', $app['server']->getIndex()));
}
die(); die();

View File

@ -23,13 +23,17 @@ if (! $app['server']->isBranchRenameEnabled()) {
$children = $app['server']->getContainerContents($request['dnSRC'],null,0,'(objectClass=*)',LDAP_DEREF_NEVER); $children = $app['server']->getContainerContents($request['dnSRC'],null,0,'(objectClass=*)',LDAP_DEREF_NEVER);
if (count($children) > 0) if (count($children) > 0)
{
error(_('You cannot rename an entry which has children entries (eg, the rename operation is not allowed on non-leaf entries)'), 'error', 'index.php'); error(_('You cannot rename an entry which has children entries (eg, the rename operation is not allowed on non-leaf entries)'), 'error', 'index.php');
} }
}
$request['dnDST'] = sprintf('%s,%s',$request['rdnDST'],$request['container']); $request['dnDST'] = sprintf('%s,%s',$request['rdnDST'],$request['container']);
if ($request['dnDST'] == $request['dnSRC']) if ($request['dnDST'] == $request['dnSRC'])
{
error(_('You did not change the RDN'), 'error', 'index.php'); error(_('You did not change the RDN'), 'error', 'index.php');
}
$rdnattr = array(); $rdnattr = array();
$rdnattr['SRC'] = explode('=',$request['dnSRC']); $rdnattr['SRC'] = explode('=',$request['dnSRC']);
@ -39,7 +43,9 @@ $new_dn_value = explode('=',$request['rdnDST'],2);
$rdnattr['DST'] = $new_dn_value[0]; $rdnattr['DST'] = $new_dn_value[0];
if (count($new_dn_value) != 2 || ! isset($new_dn_value[1])) if (count($new_dn_value) != 2 || ! isset($new_dn_value[1]))
{
error(_('Invalid RDN value'), 'error', 'index.php'); error(_('Invalid RDN value'), 'error', 'index.php');
}
$deleteoldrdn = $rdnattr['SRC'] == $rdnattr['DST']; $deleteoldrdn = $rdnattr['SRC'] == $rdnattr['DST'];
$success = $app['server']->rename($request['dnSRC'],$request['rdnDST'],$request['container'],$deleteoldrdn); $success = $app['server']->rename($request['dnSRC'],$request['rdnDST'],$request['container'],$deleteoldrdn);

View File

@ -48,7 +48,9 @@ echo '<div style="text-align: center;">';
$counter = 0; $counter = 0;
foreach ($entry['schema_types'] as $item => $value) { foreach ($entry['schema_types'] as $item => $value) {
if ($counter++) if ($counter++)
{
echo ' | '; echo ' | ';
}
$entry['href'][$item] = sprintf('cmd=schema&server_id=%s&view=%s',$app['server']->getIndex(),$item); $entry['href'][$item] = sprintf('cmd=schema&server_id=%s&view=%s',$app['server']->getIndex(),$item);
@ -57,12 +59,15 @@ foreach ($entry['schema_types'] as $item => $value) {
} else { } else {
if (isAjaxEnabled()) if (isAjaxEnabled())
printf('<a href="cmd.php?%s" onclick="return ajDISPLAY(\'BODY\',\'%s\',\'Loading %s\');" title="Loading %s">%s</a>', {
htmlspecialchars($entry['href'][$item]),htmlspecialchars($entry['href'][$item]),$value,$value,$value); printf('<a href='cmd . php ?%s' onclick="return ajDISPLAY(\'BODY\',\'%s\',\'Loading %s\');" title='Loading % s'>%s</a>',
htmlspecialchars($entry['href'][$item]),htmlspecialchars($entry['href'][$item]),$value,$value,$value); }
else else
{
printf('<a href="cmd.php?%s">%s</a>', htmlspecialchars($entry['href'][$item]), _($value)); printf('<a href="cmd.php?%s">%s</a>', htmlspecialchars($entry['href'][$item]), _($value));
} }
} }
}
echo '</div>'; echo '</div>';
echo '<br />'; echo '<br />';
@ -78,7 +83,9 @@ switch($entry['view']) {
$schema_syntaxes = $app['server']->SchemaSyntaxes(); $schema_syntaxes = $app['server']->SchemaSyntaxes();
if (! $schema_syntaxes) if (! $schema_syntaxes)
{
error($schema_error_str, 'error', 'index.php'); error($schema_error_str, 'error', 'index.php');
}
foreach ($schema_syntaxes as $syntax) { foreach ($schema_syntaxes as $syntax) {
$counter++; $counter++;
@ -86,10 +93,14 @@ switch($entry['view']) {
$desc = $syntax->getDescription(); $desc = $syntax->getDescription();
if ($highlight_oid && $highlight_oid == $oid) if ($highlight_oid && $highlight_oid == $oid)
{
echo '<tr class="highlight">'; echo '<tr class="highlight">';
}
else else
{
printf('<tr class="%s">', $counter % 2 == 0 ? 'even' : 'odd'); printf('<tr class="%s">', $counter % 2 == 0 ? 'even' : 'odd');
}
printf('<td>%s</td><td>%s</td></tr>',$oid,$desc); printf('<td>%s</td><td>%s</td></tr>',$oid,$desc);
} }
@ -119,7 +130,9 @@ switch($entry['view']) {
$sattrs = $app['server']->SchemaAttributes(); $sattrs = $app['server']->SchemaAttributes();
if (! $sattrs || ! $app['server']->SchemaObjectClasses()) if (! $sattrs || ! $app['server']->SchemaObjectClasses())
{
error($schema_error_str, 'error', 'index.php'); error($schema_error_str, 'error', 'index.php');
}
printf('<small>%s:</small>',_('Jump to an attribute type')); printf('<small>%s:</small>',_('Jump to an attribute type'));
echo '<form action="cmd.php" method="get">'; echo '<form action="cmd.php" method="get">';
@ -132,18 +145,26 @@ switch($entry['view']) {
drawJSItems($sattrs); drawJSItems($sattrs);
echo '<select name="viewvalue" onchange="ajSHOWSCHEMA(\'attributes\',\'at\')" id="attributes">'; echo '<select name="viewvalue" onchange="ajSHOWSCHEMA(\'attributes\',\'at\')" id="attributes">';
} else } else
{
echo '<select name="viewvalue" onchange="submit()">'; echo '<select name="viewvalue" onchange="submit()">';
}
echo '<option value=""> - all -</option>'; echo '<option value=""> - all -</option>';
foreach ($sattrs as $name => $attr) foreach ($sattrs as $name => $attr)
{
printf('<option value="%s" %s>%s</option>', printf('<option value="%s" %s>%s</option>',
$name,$name == $entry['value'] ? 'selected="selected" ': '',$attr->getName(false)); $name, $name == $entry['value'] ? 'selected="selected" ' : '', $attr->getName(FALSE));
}
echo '</select>'; echo '</select>';
if (isAjaxEnabled()) if (isAjaxEnabled())
{
printf('<input type="button" value="%s" onclick="ajSHOWSCHEMA(\'attributes\',\'at\')"/>', _('Go')); printf('<input type="button" value="%s" onclick="ajSHOWSCHEMA(\'attributes\',\'at\')"/>', _('Go'));
}
else else
{
printf('<input type="submit" value="%s" />', _('Go')); printf('<input type="submit" value="%s" />', _('Go'));
}
echo '</div>'; echo '</div>';
echo '</form>'; echo '</form>';
echo '<br />'; echo '<br />';
@ -151,12 +172,18 @@ switch($entry['view']) {
foreach ($sattrs as $attr) { foreach ($sattrs as $attr) {
if (isAjaxEnabled() || (is_null($entry['value']) || ! trim($entry['value']) || $entry['value']==$attr->getName())) { if (isAjaxEnabled() || (is_null($entry['value']) || ! trim($entry['value']) || $entry['value']==$attr->getName())) {
if ((! is_null($entry['value']) && $entry['value']==$attr->getName()) || ! trim($entry['value'])) if ((! is_null($entry['value']) && $entry['value']==$attr->getName()) || ! trim($entry['value']))
$entry['viewed'] = true; {
$entry['viewed'] = TRUE;
}
if (isAjaxEnabled() && $entry['value']) if (isAjaxEnabled() && $entry['value'])
{
printf('<div id="at%s" style="display: %s">', $attr->getName(), strcasecmp($entry['value'], $attr->getName()) ? 'none' : 'block'); printf('<div id="at%s" style="display: %s">', $attr->getName(), strcasecmp($entry['value'], $attr->getName()) ? 'none' : 'block');
}
else else
{
printf('<div id="at%s">', $attr->getName()); printf('<div id="at%s">', $attr->getName());
}
echo '<table class="result_table" width="100%" border="0">'; echo '<table class="result_table" width="100%" border="0">';
printf('<tr class="heading"><td colspan="2"><a name="%s">%s</a></td></tr>', printf('<tr class="heading"><td colspan="2"><a name="%s">%s</a></td></tr>',
@ -190,16 +217,22 @@ switch($entry['view']) {
echo '<td>'; echo '<td>';
if (is_null($attr->getSupAttribute())) if (is_null($attr->getSupAttribute()))
{
printf('(%s)', _('none')); printf('(%s)', _('none'));
}
else { else {
$href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['attributes'],strtolower($attr->getSupAttribute()))); $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['attributes'],strtolower($attr->getSupAttribute())));
if (isAjaxEnabled()) if (isAjaxEnabled())
{
printf('<a href="cmd.php?%s" onclick="return ajSHOWSCHEMA(\'attributes\',\'at\',\'%s\');">%s</a>', printf('<a href="cmd.php?%s" onclick="return ajSHOWSCHEMA(\'attributes\',\'at\',\'%s\');">%s</a>',
$href, strtolower($attr->getSupAttribute()), $attr->getSupAttribute()); $href, strtolower($attr->getSupAttribute()), $attr->getSupAttribute());
}
else else
{
printf('<a href="cmd.php?%s">%s</a>', $href, $attr->getSupAttribute()); printf('<a href="cmd.php?%s">%s</a>', $href, $attr->getSupAttribute());
} }
}
echo '</td>'; echo '</td>';
break; break;
@ -208,16 +241,22 @@ switch($entry['view']) {
echo '<td>'; echo '<td>';
if (is_null($attr->getEquality())) if (is_null($attr->getEquality()))
{
printf('(%s)', _('not specified')); printf('(%s)', _('not specified'));
}
else { else {
$href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['matching_rules'],$attr->getEquality())); $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['matching_rules'],$attr->getEquality()));
if (isAjaxEnabled()) if (isAjaxEnabled())
{
printf('<a href="cmd.php?%s" onclick="return ajJUMP(\'%s\',\'%s\',\'%s\');">%s</a>', printf('<a href="cmd.php?%s" onclick="return ajJUMP(\'%s\',\'%s\',\'%s\');">%s</a>',
$href, $href, _('Matching Rules'), $attr->getEquality(), $attr->getEquality()); $href, $href, _('Matching Rules'), $attr->getEquality(), $attr->getEquality());
}
else else
{
printf('<a href="cmd.php?%s">%s</a>', $href, $attr->getEquality()); printf('<a href="cmd.php?%s">%s</a>', $href, $attr->getEquality());
} }
}
echo '</td>'; echo '</td>';
break; break;
@ -241,11 +280,15 @@ switch($entry['view']) {
} else { } else {
$href = htmlspecialchars(sprintf('%s&highlight_oid=%s',$entry['href']['syntaxes'],$attr->getSyntaxOID())); $href = htmlspecialchars(sprintf('%s&highlight_oid=%s',$entry['href']['syntaxes'],$attr->getSyntaxOID()));
if (isAjaxEnabled()) if (isAjaxEnabled())
{
printf('<a href="cmd.php?%s" onclick="return ajJUMP(\'%s\',\'%s\',\'%s\');">%s (%s)</a>', printf('<a href="cmd.php?%s" onclick="return ajJUMP(\'%s\',\'%s\',\'%s\');">%s (%s)</a>',
$href, $href, _('Syntaxes'), '', $attr->getType(), $attr->getSyntaxOID()); $href, $href, _('Syntaxes'), '', $attr->getType(), $attr->getSyntaxOID());
}
else else
{
printf('<a href="cmd.php?%s">%s (%s)</a>', $href, $attr->getType(), $attr->getSyntaxOID()); printf('<a href="cmd.php?%s">%s (%s)</a>', $href, $attr->getType(), $attr->getSyntaxOID());
} }
}
echo '</td>'; echo '</td>';
break; break;
@ -270,11 +313,15 @@ switch($entry['view']) {
echo '<td>'; echo '<td>';
if ( is_null($attr->getMaxLength())) if ( is_null($attr->getMaxLength()))
{
echo '(' . _('not applicable') . ')'; echo '(' . _('not applicable') . ')';
}
else else
{
printf('%s %s', number_format($attr->getMaxLength()), printf('%s %s', number_format($attr->getMaxLength()),
$attr->getMaxLength() > 1 ? _('characters') : _('character')); $attr->getMaxLength() > 1 ? _('characters') : _('character'));
}
echo '</td>'; echo '</td>';
break; break;
@ -283,17 +330,25 @@ switch($entry['view']) {
echo '<td>'; echo '<td>';
if (count($attr->getAliases()) == 0) if (count($attr->getAliases()) == 0)
{
printf('(%s)', _('none')); printf('(%s)', _('none'));
}
else else
foreach ($attr->getAliases() as $alias) { {
foreach ($attr->getAliases() as $alias)
{
$href = htmlspecialchars(sprintf('%s&viewvalue=%s', $entry['href']['attributes'], strtolower($alias))); $href = htmlspecialchars(sprintf('%s&viewvalue=%s', $entry['href']['attributes'], strtolower($alias)));
if (isAjaxEnabled()) if (isAjaxEnabled())
{
printf('<a href="cmd.php?%s" onclick="return ajSHOWSCHEMA(\'attributes\',\'at\',\'%s\');">%s</a>', printf('<a href="cmd.php?%s" onclick="return ajSHOWSCHEMA(\'attributes\',\'at\',\'%s\');">%s</a>',
$href, strtolower($alias), $alias); $href, strtolower($alias), $alias);
else } else
{
printf('<a href="cmd.php?%s">%s</a>', $href, $alias); printf('<a href="cmd.php?%s">%s</a>', $href, $alias);
} }
}
}
echo '</td>'; echo '</td>';
break; break;
@ -302,17 +357,25 @@ switch($entry['view']) {
echo '<td>'; echo '<td>';
if (count($attr->getUsedInObjectClasses()) == 0) if (count($attr->getUsedInObjectClasses()) == 0)
{
printf('(%s)', _('none')); printf('(%s)', _('none'));
}
else else
foreach ($attr->getUsedInObjectClasses() as $objectclass) { {
foreach ($attr->getUsedInObjectClasses() as $objectclass)
{
$href = htmlspecialchars(sprintf('%s&viewvalue=%s', $entry['href']['objectclasses'], strtolower($objectclass))); $href = htmlspecialchars(sprintf('%s&viewvalue=%s', $entry['href']['objectclasses'], strtolower($objectclass)));
if (isAjaxEnabled()) if (isAjaxEnabled())
{
printf('<a href="cmd.php?%s" onclick="return ajJUMP(\'%s\',\'%s\',\'%s\');">%s</a> ', printf('<a href="cmd.php?%s" onclick="return ajJUMP(\'%s\',\'%s\',\'%s\');">%s</a> ',
$href, $href, _('ObjectClasses'), strtolower($objectclass), $objectclass); $href, $href, _('ObjectClasses'), strtolower($objectclass), $objectclass);
else } else
{
printf('<a href="cmd.php?%s">%s</a> ', $href, $objectclass); printf('<a href="cmd.php?%s">%s</a> ', $href, $objectclass);
} }
}
}
echo '</td>'; echo '</td>';
break; break;
@ -335,7 +398,9 @@ switch($entry['view']) {
case 'matching_rules': case 'matching_rules':
$schema_matching_rules = $app['server']->MatchingRules(); $schema_matching_rules = $app['server']->MatchingRules();
if (! $schema_matching_rules) if (! $schema_matching_rules)
{
error($schema_error_str, 'error', 'index.php'); error($schema_error_str, 'error', 'index.php');
}
printf('<small>%s</small><br />',_('Jump to a matching rule')); printf('<small>%s</small><br />',_('Jump to a matching rule'));
@ -349,21 +414,29 @@ switch($entry['view']) {
drawJSItems($schema_matching_rules); drawJSItems($schema_matching_rules);
echo '<select name="viewvalue" onchange="ajSHOWSCHEMA(\'matchingrules\',\'mr\')" id="matchingrules">'; echo '<select name="viewvalue" onchange="ajSHOWSCHEMA(\'matchingrules\',\'mr\')" id="matchingrules">';
} else } else
{
echo '<select name="viewvalue" onchange="submit()">'; echo '<select name="viewvalue" onchange="submit()">';
}
echo '<option value=""> - all -</option>'; echo '<option value=""> - all -</option>';
foreach ($schema_matching_rules as $rule) foreach ($schema_matching_rules as $rule)
{
printf('<option value="%s" %s>%s</option>', printf('<option value="%s" %s>%s</option>',
$rule->getName(), $rule->getName(),
($rule->getName() == $entry['value'] ? 'selected="selected"' : ''), ($rule->getName() == $entry['value'] ? 'selected="selected"' : ''),
$rule->getName(false)); $rule->getName(FALSE));
}
echo '</select>'; echo '</select>';
if (isAjaxEnabled()) if (isAjaxEnabled())
{
printf('<input type="button" value="%s" onclick="ajSHOWSCHEMA(\'matchingrules\',\'mr\')"/>', _('Go')); printf('<input type="button" value="%s" onclick="ajSHOWSCHEMA(\'matchingrules\',\'mr\')"/>', _('Go'));
}
else else
{
printf('<input type="submit" value="%s" />', _('Go')); printf('<input type="submit" value="%s" />', _('Go'));
}
echo '</div>'; echo '</div>';
echo '</form>'; echo '</form>';
echo '<br />'; echo '<br />';
@ -381,19 +454,29 @@ switch($entry['view']) {
if (isAjaxEnabled() || (is_null($entry['value']) || ! trim($entry['value']) || $entry['value']==$rule->getName())) { if (isAjaxEnabled() || (is_null($entry['value']) || ! trim($entry['value']) || $entry['value']==$rule->getName())) {
if ((! is_null($entry['value']) && $entry['value']==$rule->getName()) || ! trim($entry['value'])) if ((! is_null($entry['value']) && $entry['value']==$rule->getName()) || ! trim($entry['value']))
$entry['viewed'] = true; {
$entry['viewed'] = TRUE;
}
if (null != $rule->getDescription()) if (null != $rule->getDescription())
{
$desc .= sprintf(' (%s)', $rule->getDescription()); $desc .= sprintf(' (%s)', $rule->getDescription());
}
if ( $rule->getIsObsolete()) if ( $rule->getIsObsolete())
{
$desc .= sprintf(' <span style="color:red">%s</span>', _('Obsolete')); $desc .= sprintf(' <span style="color:red">%s</span>', _('Obsolete'));
}
if (isAjaxEnabled() && $entry['value']) if (isAjaxEnabled() && $entry['value'])
{
printf('<tr class="%s" id="mr%s" style="display: %s">', $counter % 2 ? 'odd' : 'even', $rule->getName(), printf('<tr class="%s" id="mr%s" style="display: %s">', $counter % 2 ? 'odd' : 'even', $rule->getName(),
strcasecmp($entry['value'], $rule->getName()) ? 'none' : ''); strcasecmp($entry['value'], $rule->getName()) ? 'none' : '');
}
else else
{
printf('<tr class="%s" id="mr%s">', $counter % 2 ? 'odd' : 'even', $rule->getName()); printf('<tr class="%s" id="mr%s">', $counter % 2 ? 'odd' : 'even', $rule->getName());
}
printf('<td>%s</td>',$oid); printf('<td>%s</td>',$oid);
printf('<td>%s</td>',$desc); printf('<td>%s</td>',$desc);
@ -412,14 +495,20 @@ switch($entry['view']) {
printf('<select size="4" name="viewvalue" id="vv%s">',$rule->getName()); printf('<select size="4" name="viewvalue" id="vv%s">',$rule->getName());
foreach ($rule->getUsedByAttrs() as $attr) foreach ($rule->getUsedByAttrs() as $attr)
{
printf('<option>%s</option>', $attr); printf('<option>%s</option>', $attr);
}
echo '</select><br />'; echo '</select><br />';
if (isAjaxEnabled()) if (isAjaxEnabled())
{
printf('<input type="button" value="%s" onclick="return ajJUMP(\'cmd=schema&amp;view=attributes&amp;server_id=%s\',\'%s\',\'%s\',\'vv\');"/>', printf('<input type="button" value="%s" onclick="return ajJUMP(\'cmd=schema&amp;view=attributes&amp;server_id=%s\',\'%s\',\'%s\',\'vv\');"/>',
_('Go'), $app['server']->getIndex(), _('Attributes'), $rule->getName()); _('Go'), $app['server']->getIndex(), _('Attributes'), $rule->getName());
}
else else
{
printf('<input type="submit" value="%s" />', _('Go')); printf('<input type="submit" value="%s" />', _('Go'));
}
echo '</div>'; echo '</div>';
echo '</form>'; echo '</form>';
echo '</td></tr></table>'; echo '</td></tr></table>';
@ -435,7 +524,9 @@ switch($entry['view']) {
case 'objectclasses': case 'objectclasses':
$socs = $app['server']->SchemaObjectClasses(); $socs = $app['server']->SchemaObjectClasses();
if (! $socs) if (! $socs)
{
error($schema_error_str, 'error', 'index.php'); error($schema_error_str, 'error', 'index.php');
}
printf('<small>%s:</small>',_('Jump to an objectClass')); printf('<small>%s:</small>',_('Jump to an objectClass'));
@ -449,19 +540,27 @@ switch($entry['view']) {
drawJSItems($socs); drawJSItems($socs);
echo '<select name="viewvalue" onchange="ajSHOWSCHEMA(\'objectclasses\',\'oc\')" id="objectclasses">'; echo '<select name="viewvalue" onchange="ajSHOWSCHEMA(\'objectclasses\',\'oc\')" id="objectclasses">';
} else } else
{
echo '<select name="viewvalue" onchange="submit()">'; echo '<select name="viewvalue" onchange="submit()">';
}
echo '<option value=""> - all - </option>'; echo '<option value=""> - all - </option>';
foreach ($socs as $name => $oclass) foreach ($socs as $name => $oclass)
{
printf('<option value="%s" %s>%s</option>', printf('<option value="%s" %s>%s</option>',
$name,$name == $entry['value'] ? 'selected="selected" ': '',$oclass->getName(false)); $name, $name == $entry['value'] ? 'selected="selected" ' : '', $oclass->getName(FALSE));
}
echo '</select>'; echo '</select>';
if (isAjaxEnabled()) if (isAjaxEnabled())
{
printf('<input type="button" value="%s" onclick="ajSHOWSCHEMA(\'objectclasses\',\'oc\')"/>', _('Go')); printf('<input type="button" value="%s" onclick="ajSHOWSCHEMA(\'objectclasses\',\'oc\')"/>', _('Go'));
}
else else
{
printf('<input type="submit" value="%s" />', _('Go')); printf('<input type="submit" value="%s" />', _('Go'));
}
echo '</div>'; echo '</div>';
echo '</form>'; echo '</form>';
echo '<br />'; echo '<br />';
@ -469,68 +568,102 @@ switch($entry['view']) {
foreach ($socs as $name => $oclass) { foreach ($socs as $name => $oclass) {
if (isAjaxEnabled() || (is_null($entry['value']) || ! trim($entry['value']) || $entry['value']==$oclass->getName())) { if (isAjaxEnabled() || (is_null($entry['value']) || ! trim($entry['value']) || $entry['value']==$oclass->getName())) {
if ((! is_null($entry['value']) && $entry['value']==$oclass->getName()) || ! trim($entry['value'])) if ((! is_null($entry['value']) && $entry['value']==$oclass->getName()) || ! trim($entry['value']))
$entry['viewed'] = true; {
$entry['viewed'] = TRUE;
}
if (isAjaxEnabled() && $entry['value']) if (isAjaxEnabled() && $entry['value'])
{
printf('<div id="oc%s" style="display: %s">', $oclass->getName(), strcasecmp($entry['value'], $oclass->getName()) ? 'none' : ''); printf('<div id="oc%s" style="display: %s">', $oclass->getName(), strcasecmp($entry['value'], $oclass->getName()) ? 'none' : '');
}
else else
{
printf('<div id="oc%s">', $oclass->getName()); printf('<div id="oc%s">', $oclass->getName());
}
echo '<table class="result_table" width="100%" border="0">'; echo '<table class="result_table" width="100%" border="0">';
printf('<tr class="heading"><td colspan="4"><a name="%s">%s</a></td></tr>',$name,$oclass->getName(false)); printf('<tr class="heading"><td colspan="4"><a name="%s">%s</a></td></tr>',$name,$oclass->getName(false));
printf('<tr class="odd"><td colspan="4">%s: <b>%s</b></td></tr>',_('OID'),$oclass->getOID()); printf('<tr class="odd"><td colspan="4">%s: <b>%s</b></td></tr>',_('OID'),$oclass->getOID());
if ($oclass->getDescription()) if ($oclass->getDescription())
{
printf('<tr class="odd"><td colspan="4">%s: <b>%s</b></td></tr>', _('Description'), $oclass->getDescription()); printf('<tr class="odd"><td colspan="4">%s: <b>%s</b></td></tr>', _('Description'), $oclass->getDescription());
}
printf('<tr class="odd"><td colspan="4">%s: <b>%s</b></td></tr>',_('Type'),$oclass->getType()); printf('<tr class="odd"><td colspan="4">%s: <b>%s</b></td></tr>',_('Type'),$oclass->getType());
if ($oclass->getIsObsolete()) if ($oclass->getIsObsolete())
{
printf('<tr class="odd"><td colspan="4">%s</td></tr>', _('This objectClass is obsolete.')); printf('<tr class="odd"><td colspan="4">%s</td></tr>', _('This objectClass is obsolete.'));
}
printf('<tr class="odd"><td colspan="4">%s: <b>',_('Inherits from')); printf('<tr class="odd"><td colspan="4">%s: <b>',_('Inherits from'));
if (count($oclass->getSupClasses()) == 0) if (count($oclass->getSupClasses()) == 0)
{
printf('(%s)', _('none')); printf('(%s)', _('none'));
}
else else
foreach ($oclass->getSupClasses() as $i => $object_class) { {
foreach ($oclass->getSupClasses() as $i => $object_class)
{
$href = htmlspecialchars(sprintf('%s&viewvalue=%s', $entry['href']['objectclasses'], strtolower($object_class))); $href = htmlspecialchars(sprintf('%s&viewvalue=%s', $entry['href']['objectclasses'], strtolower($object_class)));
if (isAjaxEnabled()) if (isAjaxEnabled())
{
printf('<a href="cmd.php?%s" onclick="return ajSHOWSCHEMA(\'objectclasses\',\'oc\',\'%s\');">%s</a>', printf('<a href="cmd.php?%s" onclick="return ajSHOWSCHEMA(\'objectclasses\',\'oc\',\'%s\');">%s</a>',
$href, strtolower($object_class), $object_class); $href, strtolower($object_class), $object_class);
else } else
{
printf('<a href="cmd.php?%s&viewvalue=%s" title="%s">%s</a>', printf('<a href="cmd.php?%s&viewvalue=%s" title="%s">%s</a>',
$href, $object_class, _('Jump to this objectClass definition'), $object_class); $href, $object_class, _('Jump to this objectClass definition'), $object_class);
}
if ($i < count($oclass->getSupClasses()) - 1) if ($i < count($oclass->getSupClasses()) - 1)
{
echo ', '; echo ', ';
} }
}
}
echo '</b></td></tr>'; echo '</b></td></tr>';
printf('<tr class="odd"><td colspan="4">%s: <b>',_('Parent to')); printf('<tr class="odd"><td colspan="4">%s: <b>',_('Parent to'));
if (strcasecmp($oclass->getName(),'top') == 0) { if (strcasecmp($oclass->getName(),'top') == 0) {
$href = htmlspecialchars($entry['href']['objectclasses']); $href = htmlspecialchars($entry['href']['objectclasses']);
if (isAjaxEnabled()) if (isAjaxEnabled())
{
printf('<a href="cmd.php?%s" onclick="return ajSHOWSCHEMA(\'objectclasses\',\'oc\',\'\');">all</a>', printf('<a href="cmd.php?%s" onclick="return ajSHOWSCHEMA(\'objectclasses\',\'oc\',\'\');">all</a>',
$href); $href);
}
else else
{
printf('(<a href="cmd.php?%s">all</a>)', $href); printf('(<a href="cmd.php?%s">all</a>)', $href);
}
} elseif (count($oclass->getChildObjectClasses()) == 0) } elseif (count($oclass->getChildObjectClasses()) == 0)
{
printf('(%s)', _('none')); printf('(%s)', _('none'));
}
else else
foreach ($oclass->getChildObjectClasses() as $i => $object_class) { {
foreach ($oclass->getChildObjectClasses() as $i => $object_class)
{
$href = htmlspecialchars(sprintf('%s&viewvalue=%s', $entry['href']['objectclasses'], strtolower($object_class))); $href = htmlspecialchars(sprintf('%s&viewvalue=%s', $entry['href']['objectclasses'], strtolower($object_class)));
if (isAjaxEnabled()) if (isAjaxEnabled())
{
printf('<a href="cmd.php?%s" title="%s" onclick="return ajSHOWSCHEMA(\'objectclasses\',\'oc\',\'%s\');">%s</a>', printf('<a href="cmd.php?%s" title="%s" onclick="return ajSHOWSCHEMA(\'objectclasses\',\'oc\',\'%s\');">%s</a>',
$href, _('Jump to this objectClass definition'), strtolower($object_class), $object_class); $href, _('Jump to this objectClass definition'), strtolower($object_class), $object_class);
else } else
{
printf('<a href="cmd.php?%s" title="%s">%s</a>', $href, _('Jump to this objectClass definition'), $object_class); printf('<a href="cmd.php?%s" title="%s">%s</a>', $href, _('Jump to this objectClass definition'), $object_class);
}
if ($i < count($oclass->getChildObjectClasses()) - 1) if ($i < count($oclass->getChildObjectClasses()) - 1)
{
echo ', '; echo ', ';
} }
}
}
echo '</b></td></tr>'; echo '</b></td></tr>';
printf('<tr class="even"><td class="blank" rowspan="2" style="width: 5%%;">&nbsp;</td><td style="width: 45%%;"><b>%s</b></td><td style="width: 45%%;"><b>%s</b></td><td class="blank" rowspan="2" style="width: 5%%;">&nbsp;</td></tr>', printf('<tr class="even"><td class="blank" rowspan="2" style="width: 5%%;">&nbsp;</td><td style="width: 45%%;"><b>%s</b></td><td style="width: 45%%;"><b>%s</b></td><td class="blank" rowspan="2" style="width: 5%%;">&nbsp;</td></tr>',
@ -546,20 +679,28 @@ switch($entry['view']) {
echo '<li>'; echo '<li>';
$href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['attributes'],$attr->getName())); $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['attributes'],$attr->getName()));
if (isAjaxEnabled()) if (isAjaxEnabled())
{
printf('<a href="cmd.php?%s" onclick="return ajJUMP(\'%s\',\'%s\',\'%s\');">%s</a>', printf('<a href="cmd.php?%s" onclick="return ajJUMP(\'%s\',\'%s\',\'%s\');">%s</a>',
$href,$href,_('Attributes'),$attr->getName(),$attr->getName(false)); $href, $href, _('Attributes'), $attr->getName(), $attr->getName(FALSE));
}
else else
printf('<a href="cmd.php?%s">%s</a>',$href,$attr->getName(false)); {
printf('<a href="cmd.php?%s">%s</a>', $href, $attr->getName(FALSE));
}
if ($attr->getSource() != $oclass->getName(false)) { if ($attr->getSource() != $oclass->getName(false)) {
echo '<br />'; echo '<br />';
$href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower($attr->getSource()))); $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower($attr->getSource())));
printf('<small>(%s ',_('Inherited from')); printf('<small>(%s ',_('Inherited from'));
if (isAjaxEnabled()) if (isAjaxEnabled())
{
printf('<a href="cmd.php?%s" title="%s" onclick="return ajSHOWSCHEMA(\'objectclasses\',\'oc\',\'%s\');">%s</a>', printf('<a href="cmd.php?%s" title="%s" onclick="return ajSHOWSCHEMA(\'objectclasses\',\'oc\',\'%s\');">%s</a>',
$href, _('Jump to this objectClass definition'), strtolower($attr->getSource()), $attr->getSource()); $href, _('Jump to this objectClass definition'), strtolower($attr->getSource()), $attr->getSource());
}
else else
{
printf('<a href="cmd.php?%s">%s</a>', $href, $attr->getSource()); printf('<a href="cmd.php?%s">%s</a>', $href, $attr->getSource());
}
echo ')</small>'; echo ')</small>';
} }
echo '</li>'; echo '</li>';
@ -567,7 +708,9 @@ switch($entry['view']) {
echo '</ul>'; echo '</ul>';
} else } else
{
printf('(%s)', _('none')); printf('(%s)', _('none'));
}
echo '</td>'; echo '</td>';
echo '<td>'; echo '<td>';
@ -579,20 +722,28 @@ switch($entry['view']) {
echo '<li>'; echo '<li>';
$href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['attributes'],$attr->getName())); $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['attributes'],$attr->getName()));
if (isAjaxEnabled()) if (isAjaxEnabled())
{
printf('<a href="cmd.php?%s" onclick="return ajJUMP(\'%s\',\'%s\',\'%s\');">%s</a>', printf('<a href="cmd.php?%s" onclick="return ajJUMP(\'%s\',\'%s\',\'%s\');">%s</a>',
$href,$href,_('Attributes'),$attr->getName(),$attr->getName(false)); $href, $href, _('Attributes'), $attr->getName(), $attr->getName(FALSE));
}
else else
printf('<a href="cmd.php?%s">%s</a>',$href,$attr->getName(false)); {
printf('<a href="cmd.php?%s">%s</a>', $href, $attr->getName(FALSE));
}
if ($attr->getSource() != $oclass->getName(false)) { if ($attr->getSource() != $oclass->getName(false)) {
echo '<br />'; echo '<br />';
$href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower($attr->getSource()))); $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower($attr->getSource())));
printf('<small>(%s ',_('Inherited from')); printf('<small>(%s ',_('Inherited from'));
if (isAjaxEnabled()) if (isAjaxEnabled())
{
printf('<a href="cmd.php?%s" title="%s" onclick="return ajSHOWSCHEMA(\'objectclasses\',\'oc\',\'%s\');">%s</a>', printf('<a href="cmd.php?%s" title="%s" onclick="return ajSHOWSCHEMA(\'objectclasses\',\'oc\',\'%s\');">%s</a>',
$href, _('Jump to this objectClass definition'), strtolower($attr->getSource()), $attr->getSource()); $href, _('Jump to this objectClass definition'), strtolower($attr->getSource()), $attr->getSource());
}
else else
{
printf('<a href="cmd.php?%s">%s</a>', $href, $attr->getSource()); printf('<a href="cmd.php?%s">%s</a>', $href, $attr->getSource());
}
echo ')</small>'; echo ')</small>';
} }
@ -605,7 +756,9 @@ switch($entry['view']) {
echo '</ul>'; echo '</ul>';
} else } else
{
printf('(%s)', _('none')); printf('(%s)', _('none'));
}
echo '</td>'; echo '</td>';
echo '</tr>'; echo '</tr>';
@ -618,7 +771,9 @@ switch($entry['view']) {
} }
if (! is_null($entry['value']) && ! $entry['viewed']) if (! is_null($entry['value']) && ! $entry['viewed'])
{
error(sprintf(_('No such schema item: "%s"'), $entry['value']), 'error', 'index.php'); error(sprintf(_('No such schema item: "%s"'), $entry['value']), 'error', 'index.php');
}
function drawJSItems($object) { function drawJSItems($object) {
echo '<script type="text/javascript">'."\n"; echo '<script type="text/javascript">'."\n";

View File

@ -25,7 +25,9 @@ if (! count($attrs)) {
echo '<table class="result" border="0">'; echo '<table class="result" border="0">';
foreach ($attrs as $key => $values) { foreach ($attrs as $key => $values) {
if ($key == 'dn') if ($key == 'dn')
{
continue; continue;
}
echo '<tr class="list_item"><td class="heading" rowspan="2">'; echo '<tr class="list_item"><td class="heading" rowspan="2">';
@ -37,7 +39,9 @@ foreach ($attrs as $key => $values) {
$href,_('Click to view the schema definition for attribute type'),$sattr->getName(false),$sattr->getName(false)); $href,_('Click to view the schema definition for attribute type'),$sattr->getName(false),$sattr->getName(false));
} else } else
{
echo $key; echo $key;
}
echo '</td></tr>'; echo '</td></tr>';
@ -45,41 +49,56 @@ foreach ($attrs as $key => $values) {
echo '<table class="result" border="0">'; echo '<table class="result" border="0">';
if (is_array($values)) if (is_array($values))
foreach ($values as $value) { {
foreach ($values as $value)
{
$oidtext = ''; $oidtext = '';
print '<tr>'; print '<tr>';
if (preg_match('/^[0-9]+\.[0-9]+/',$value)) { if (preg_match('/^[0-9]+\.[0-9]+/', $value))
printf('<td rowspan="2" style="width: 5%%; vertical-align: top"><img src="%s/rfc.png" title="%s" alt="%s"/></td>', {
printf('<td rowspan='2' style='width: 5 %%; vertical - align: top'><img src=' % s / rfc . png' title=' % s' alt=' % s'/></td>',
IMGDIR,$value,htmlspecialchars($value)); IMGDIR,$value,htmlspecialchars($value));
if ($oidtext = support_oid_to_text($value)) if ($oidtext = support_oid_to_text($value))
{
if (isset($oidtext['ref'])) if (isset($oidtext['ref']))
printf('<td><acronym title="%s">%s</acronym></td>',$oidtext['ref'],$oidtext['title']); {
else printf('<td><acronym title=' % s'>%s</acronym></td>',$oidtext['ref'],$oidtext['title']); } else
{
printf('<td>%s</td>', $oidtext['title']); printf('<td>%s</td>', $oidtext['title']);
}
else } else
if (strlen($value) > 0) if (strlen($value) > 0)
{
printf('<td><small>%s</small></td>', $value); printf('<td><small>%s</small></td>', $value);
}
} else { } else
printf('<td rowspan="2" colspan="2">%s</td>',$value); {
printf('<td rowspan='2' colspan='2'>%s</td>',$value);
} }
print '</tr>'; print '</tr>';
if (isset($oidtext['desc']) && trim($oidtext['desc'])) if (isset($oidtext['desc']) && trim($oidtext['desc']))
{
printf('<tr><td><small>%s</small></td></tr>', $oidtext['desc']); printf('<tr><td><small>%s</small></td></tr>', $oidtext['desc']);
else } else
{
echo '<tr><td>&nbsp;</td></tr>'; echo '<tr><td>&nbsp;</td></tr>';
}
if ($oidtext) if ($oidtext)
echo '<tr><td colspan="2">&nbsp;</td></tr>'; {
echo '<tr><td colspan='2'>&nbsp;</td></tr>'; }
}
} }
else else
{
printf('<tr><td colspan="2">%s&nbsp;</td></tr>', $values); printf('<tr><td colspan="2">%s&nbsp;</td></tr>', $values);
}
echo '</table>'; echo '</table>';

View File

@ -16,9 +16,13 @@ $request['key'] = get_request('key','REQUEST');
$request['index'] = get_request('index','REQUEST'); $request['index'] = get_request('index','REQUEST');
if (get_request('global','REQUEST')) if (get_request('global','REQUEST'))
{
$request['dumpvar'] = &$GLOBALS; $request['dumpvar'] = &$GLOBALS;
}
else else
{
$request['dumpvar'] = &$_SESSION; $request['dumpvar'] = &$_SESSION;
}
if (isset($request['index']) && isset($request['key'])) { if (isset($request['index']) && isset($request['key'])) {
list($request['server'],$request['x']) = explode(':',$request['index']); list($request['server'],$request['x']) = explode(':',$request['index']);
@ -26,25 +30,33 @@ if (isset($request['index']) && isset($request['key'])) {
} }
if ($request['key']) if ($request['key'])
{
debug_dump($request['dumpvar'][$request['key']], 1); debug_dump($request['dumpvar'][$request['key']], 1);
}
if (! $_SESSION[APPCONFIG]->getValue('appearance','hide_debug_info')) { if (! $_SESSION[APPCONFIG]->getValue('appearance','hide_debug_info')) {
echo '<div style="font-size: 11px"><ul>'; echo '<div style="font-size: 11px"><ul>';
foreach (array_keys($request['dumpvar']) as $key) { foreach (array_keys($request['dumpvar']) as $key) {
if ((in_array($key,array('cache'))) && is_array($request['dumpvar'][$key])) if ((in_array($key,array('cache'))) && is_array($request['dumpvar'][$key]))
foreach (array_keys($request['dumpvar'][$key]) as $server) { {
foreach (array_keys($request['dumpvar'][$key][$server]) as $x) { foreach (array_keys($request['dumpvar'][$key]) as $server)
{
foreach (array_keys($request['dumpvar'][$key][$server]) as $x)
{
$index = sprintf('%s:%s', $server, $x); $index = sprintf('%s:%s', $server, $x);
printf('<li><span id="%s"><a href="javascript:get(\'%s\',\'%s\');">%s</a></span><div id="%sloading" style="display: none" ></div></li>', printf('<li><span id=' % s'><a href="javascript:get(\'%s\',\'%s\');">%s</a></span><div id=' % sloading' style='display: none' ></div></li>',
$key . $index,$key,$index,$key . '.' . $index,$key . $index,$key . $index); $key . $index,$key,$index,$key . '.' . $index,$key . $index,$key . $index);
} }
} }
}
else else
{
printf('<li><span id="%s"><a href="javascript:get(\'%s\',\'\');">%s</a></span><div id="%sloading" style="display: none" ></div></li>', printf('<li><span id="%s"><a href="javascript:get(\'%s\',\'\');">%s</a></span><div id="%sloading" style="display: none" ></div></li>',
$key, $key, $key, $key); $key, $key, $key, $key);
} }
}
echo '</ul></div>'; echo '</ul></div>';
} }
?> ?>

View File

@ -49,7 +49,9 @@ if ($request['dn']) {
} else { } else {
if ($app['server']->isReadOnly()) if ($app['server']->isReadOnly())
{
error(_('You cannot perform updates while server is in read-only mode'), 'error', 'index.php'); error(_('You cannot perform updates while server is in read-only mode'), 'error', 'index.php');
}
$request['page']->setContainer(get_request('container','REQUEST')); $request['page']->setContainer(get_request('container','REQUEST'));
$request['page']->accept(); $request['page']->accept();

View File

@ -24,7 +24,9 @@ if (get_request('cancel','REQUEST')) {
} }
if (! $request['dn'] || ! $app['server']->dnExists($request['dn'])) if (! $request['dn'] || ! $app['server']->dnExists($request['dn']))
{
error(sprintf(_('The entry (%s) does not exist.'), $request['dn']), 'error', 'index.php'); error(sprintf(_('The entry (%s) does not exist.'), $request['dn']), 'error', 'index.php');
}
$request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none')); $request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
$request['page']->setDN($request['dn']); $request['page']->setDN($request['dn']);
@ -46,7 +48,9 @@ if ($result) {
in_array($app['server']->getValue('login','auth_type'),array('cookie','session')) && in_array($app['server']->getValue('login','auth_type'),array('cookie','session')) &&
pla_compare_dns($app['server']->getLogin(),$request['dn']) === 0) pla_compare_dns($app['server']->getLogin(),$request['dn']) === 0)
$mustRelogin = true; {
$mustRelogin = TRUE;
}
} }
# If the user password was changed, not tell the to relogin. # If the user password was changed, not tell the to relogin.
@ -67,10 +71,14 @@ if ($result) {
$app['server']->getIndex(),$request['template']->getDNEncode()); $app['server']->getIndex(),$request['template']->getDNEncode());
foreach ($request['template']->getLDAPmodify() as $attr => $junk) foreach ($request['template']->getLDAPmodify() as $attr => $junk)
{
$redirect_url .= sprintf('&modified_attrs[]=%s', $attr); $redirect_url .= sprintf('&modified_attrs[]=%s', $attr);
}
if (get_request('meth','REQUEST') == 'ajax') if (get_request('meth','REQUEST') == 'ajax')
{
$redirect_url .= '&meth=ajax'; $redirect_url .= '&meth=ajax';
}
header("Location: $redirect_url"); header("Location: $redirect_url");
die(); die();

View File

@ -20,7 +20,9 @@ $request = array();
$request['dn'] = get_request('dn','REQUEST',true); $request['dn'] = get_request('dn','REQUEST',true);
if (! $request['dn'] || ! $app['server']->dnExists($request['dn'])) if (! $request['dn'] || ! $app['server']->dnExists($request['dn']))
{
error(sprintf(_('The entry (%s) does not exist.'), $request['dn']), 'error', 'index.php'); error(sprintf(_('The entry (%s) does not exist.'), $request['dn']), 'error', 'index.php');
}
$request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none')); $request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
$request['page']->setDN($request['dn']); $request['page']->setDN($request['dn']);
@ -69,19 +71,24 @@ if (count($request['template']->getLDAPmodify(true))) {
echo '<td><span style="white-space: nowrap;">'; echo '<td><span style="white-space: nowrap;">';
if (! $attribute->getOldValues()) if (! $attribute->getOldValues())
printf('<span style="color: green">[%s]</span>',_('attribute doesnt exist')); {
printf('<span style='color: green'>[%s]</span>',_('attribute doesnt exist')); }
$dv = $attribute->getRemovedValues(); $dv = $attribute->getRemovedValues();
foreach ($attribute->getOldValues() as $key => $value) { foreach ($attribute->getOldValues() as $key => $value) {
# For multiple values, we'll highlight the changed ones # For multiple values, we'll highlight the changed ones
if ($x = ((count($attribute->getOldValues()) > 5) && count($attribute->getValues()) && in_array($value,$dv))) if ($x = ((count($attribute->getOldValues()) > 5) && count($attribute->getValues()) && in_array($value,$dv)))
{
echo '<span style="color:#880000; background:#FFFFA0">'; echo '<span style="color:#880000; background:#FFFFA0">';
}
$request['page']->draw('OldValue',$attribute,$key); $request['page']->draw('OldValue',$attribute,$key);
# For multiple values, close the highlighting # For multiple values, close the highlighting
if ($x) if ($x)
{
echo '</span>'; echo '</span>';
}
echo '<br />'; echo '<br />';
} }
@ -92,19 +99,25 @@ if (count($request['template']->getLDAPmodify(true))) {
echo '<td><span style="white-space: nowrap;">'; echo '<td><span style="white-space: nowrap;">';
if (! $attribute->getValueCount() || $attribute->isForceDelete()) if (! $attribute->getValueCount() || $attribute->isForceDelete())
{
printf('<span style="color: red">[%s]</span>', _('attribute deleted')); printf('<span style="color: red">[%s]</span>', _('attribute deleted'));
}
$dv = $attribute->getAddedValues(); $dv = $attribute->getAddedValues();
foreach ($attribute->getValues() as $key => $value) { foreach ($attribute->getValues() as $key => $value) {
# For multiple values, we'll highlight the changed ones # For multiple values, we'll highlight the changed ones
if ($x = ((count($attribute->getValues()) > 5) && count($attribute->getOldValues()) && in_array($value,$dv))) if ($x = ((count($attribute->getValues()) > 5) && count($attribute->getOldValues()) && in_array($value,$dv)))
{
echo '<span style="color:#004400; background:#FFFFA0">'; echo '<span style="color:#004400; background:#FFFFA0">';
}
$request['page']->draw('CurrentValue',$attribute,$key); $request['page']->draw('CurrentValue',$attribute,$key);
# For multiple values, close the highlighting # For multiple values, close the highlighting
if ($x) if ($x)
{
echo '</span>'; echo '</span>';
}
echo '<br />'; echo '<br />';
} }
@ -116,7 +129,9 @@ if (count($request['template']->getLDAPmodify(true))) {
$input_onclick = ''; $input_onclick = '';
if ($attribute->isForceDelete() || (in_array($attribute->getName(),$mustattrs)) && $request['template']->getAttribute('objectclass')->justModified()) if ($attribute->isForceDelete() || (in_array($attribute->getName(),$mustattrs)) && $request['template']->getAttribute('objectclass')->justModified())
{
$input_disabled = 'disabled="disabled"'; $input_disabled = 'disabled="disabled"';
}
if ($attribute->getName() == 'objectclass') { if ($attribute->getName() == 'objectclass') {
$input_onclick = ''; $input_onclick = '';
@ -129,7 +144,9 @@ if (count($request['template']->getLDAPmodify(true))) {
foreach ($request['template']->getForceDeleteAttrs() as $ad_name) { foreach ($request['template']->getForceDeleteAttrs() as $ad_name) {
# Only if it is not a must attr by this objectclass now staying # Only if it is not a must attr by this objectclass now staying
if (! in_array($ad_name->getName(),getMustAttrs($attribute->getOldValues()))) if (! in_array($ad_name->getName(),getMustAttrs($attribute->getOldValues())))
{
$input_onclick .= sprintf("document.getElementById('skip_array_%s').disabled = false;", $ad_name->getName()); $input_onclick .= sprintf("document.getElementById('skip_array_%s').disabled = false;", $ad_name->getName());
}
$input_onclick .= sprintf("document.getElementById('skip_array_%s').checked = true;",$ad_name->getName()); $input_onclick .= sprintf("document.getElementById('skip_array_%s').checked = true;",$ad_name->getName());
$input_onclick .= "\n"; $input_onclick .= "\n";
@ -149,15 +166,21 @@ if (count($request['template']->getLDAPmodify(true))) {
# If the attributes arent force deleted... # If the attributes arent force deleted...
if ($input_onclick) if ($input_onclick)
{
$input_onclick .= 'if (this.checked) {'; $input_onclick .= 'if (this.checked) {';
}
else else
{
$input_onclick = 'onclick="if (this.checked) {'; $input_onclick = 'onclick="if (this.checked) {';
}
# IE: There are new objectclasses that result in new values. # IE: There are new objectclasses that result in new values.
foreach ($request['template']->getLDAPmodify(true) as $skipattr) { foreach ($request['template']->getLDAPmodify(true) as $skipattr) {
if (! $skipattr->getOldValues()) { if (! $skipattr->getOldValues()) {
if (! in_array($skipattr->getName(),$mustattrs)) if (! in_array($skipattr->getName(),$mustattrs))
{
$input_onclick .= sprintf("document.getElementById('skip_array_%s').disabled = true;", $skipattr->getName()); $input_onclick .= sprintf("document.getElementById('skip_array_%s').disabled = true;", $skipattr->getName());
}
$input_onclick .= sprintf("document.getElementById('skip_array_%s').checked = true;",$skipattr->getName()); $input_onclick .= sprintf("document.getElementById('skip_array_%s').checked = true;",$skipattr->getName());
$input_onclick .= "\n"; $input_onclick .= "\n";
@ -169,7 +192,9 @@ if (count($request['template']->getLDAPmodify(true))) {
foreach ($request['template']->getLDAPmodify(true) as $skipattr) { foreach ($request['template']->getLDAPmodify(true) as $skipattr) {
if (! $skipattr->getOldValues()) { if (! $skipattr->getOldValues()) {
if (! in_array($skipattr->getName(),$mustattrs)) if (! in_array($skipattr->getName(),$mustattrs))
{
$input_onclick .= sprintf("document.getElementById('skip_array_%s').disabled = false;", $skipattr->getName()); $input_onclick .= sprintf("document.getElementById('skip_array_%s').disabled = false;", $skipattr->getName());
}
$input_onclick .= sprintf("document.getElementById('skip_array_%s').checked = false;",$skipattr->getName()); $input_onclick .= sprintf("document.getElementById('skip_array_%s').checked = false;",$skipattr->getName());
$input_onclick .= "\n"; $input_onclick .= "\n";
@ -212,7 +237,9 @@ if (count($request['template']->getLDAPmodify(true))) {
$i = 0; $i = 0;
foreach ($request['template']->getForceDeleteAttrs() as $attribute) { foreach ($request['template']->getForceDeleteAttrs() as $attribute) {
if ($i++ != 0) if ($i++ != 0)
{
echo '</b>, <b>'; echo '</b>, <b>';
}
echo $_SESSION[APPCONFIG]->getFriendlyHTML($attribute); echo $_SESSION[APPCONFIG]->getFriendlyHTML($attribute);
} }
@ -227,10 +254,14 @@ if (count($request['template']->getLDAPmodify(true))) {
echo _('You made no changes'); echo _('You made no changes');
if (isAjaxEnabled()) if (isAjaxEnabled())
{
printf(' <a href="cmd.php?%s" onclick="return ajDISPLAY(\'BODY\',\'%s\',\'%s\');">%s</a>.', printf(' <a href="cmd.php?%s" onclick="return ajDISPLAY(\'BODY\',\'%s\',\'%s\');">%s</a>.',
htmlspecialchars($href), htmlspecialchars($href), _('Retrieving DN'), _('Go back')); htmlspecialchars($href), htmlspecialchars($href), _('Retrieving DN'), _('Go back'));
}
else else
{
printf(' <a href="cmd.php?%s">%s</a>.', htmlspecialchars($href), _('Go back')); printf(' <a href="cmd.php?%s">%s</a>.', htmlspecialchars($href), _('Go back'));
}
echo '</div>'; echo '</div>';
} }
@ -244,9 +275,13 @@ function getMustAttrs($oclasses) {
$soc = $app['server']->getSchemaObjectClass($value); $soc = $app['server']->getSchemaObjectClass($value);
if ($soc) if ($soc)
{
foreach ($soc->getMustAttrs() as $sma) foreach ($soc->getMustAttrs() as $sma)
{
array_push($mustattrs, $sma->getName()); array_push($mustattrs, $sma->getName());
} }
}
}
return $mustattrs; return $mustattrs;
} }

View File

@ -64,11 +64,15 @@ if (! isset($jpeg_data[$request['attr']][$request['index']])) {
} }
if (! is_array($jpeg_data[$request['attr']])) if (! is_array($jpeg_data[$request['attr']]))
{
$jpeg_data[$request['attr']] = array($jpeg_data[$request['attr']]); $jpeg_data[$request['attr']] = array($jpeg_data[$request['attr']]);
}
$obStatus = ob_get_status(); $obStatus = ob_get_status();
if (isset($obStatus['type']) && $obStatus['type'] && $obStatus['status']) if (isset($obStatus['type']) && $obStatus['type'] && $obStatus['status'])
{
ob_end_clean(); ob_end_clean();
}
header(sprintf('Content-type: %s',$request['type'])); header(sprintf('Content-type: %s',$request['type']));
header(sprintf('Content-disposition: inline; filename="%s"',$request['filename'])); header(sprintf('Content-disposition: inline; filename="%s"',$request['filename']));

View File

@ -24,7 +24,9 @@ class AJAXTree extends HTMLTree {
*/ */
protected function draw_item($item,$level,$first_child=true,$last_child=true) { protected function draw_item($item,$level,$first_child=true,$last_child=true) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$server = $this->getServer(); $server = $this->getServer();
@ -33,13 +35,19 @@ class AJAXTree extends HTMLTree {
if (is_string($level)) { if (is_string($level)) {
for ($i=0; $i<strlen($level); $i++) { for ($i=0; $i<strlen($level); $i++) {
if ($level[$i] == '0') if ($level[$i] == '0')
{
$code .= '0'; $code .= '0';
}
elseif ($level[$i] == '1') elseif ($level[$i] == '1')
{
$code .= '1'; $code .= '1';
} }
}
} elseif ($level > 0) } elseif ($level > 0)
{
$code = '0' * $level; $code = '0' * $level;
}
$level = strlen($code); $level = strlen($code);
@ -54,16 +62,22 @@ class AJAXTree extends HTMLTree {
# If the entry doesnt exist in the server, then return here with an empty string. # If the entry doesnt exist in the server, then return here with an empty string.
if (! $entry) if (! $entry)
{
return ''; return '';
}
# Get our children. # Get our children.
$child_count = $this->readChildrenNumber($entry->getDN()); $child_count = $this->readChildrenNumber($entry->getDN());
$nb = 0; $nb = 0;
if ($first_child) if ($first_child)
$nb += 1; {
++$nb;
}
if ($last_child) if ($last_child)
{
$nb += 2; $nb += 2;
}
$imgs['expand'] = array('tree_expand.png','tree_expand.png','tree_expand_corner.png', $imgs['expand'] = array('tree_expand.png','tree_expand.png','tree_expand_corner.png',
($level > 0) ? 'tree_expand_corner.png' : 'tree_expand_corner_first.png'); ($level > 0) ? 'tree_expand_corner.png' : 'tree_expand_corner_first.png');
@ -90,22 +104,30 @@ class AJAXTree extends HTMLTree {
$node_id = str_replace('=','_',$node_id); $node_id = str_replace('=','_',$node_id);
if ($level == 0) if ($level == 0)
{
printf('<tr><td class="spacer"></td><td colspan="%s">', $this->getDepth() + 3 - 1); printf('<tr><td class="spacer"></td><td colspan="%s">', $this->getDepth() + 3 - 1);
}
printf('<div id="jt%s" class="treemenudiv">',$node_id); printf('<div id="jt%s" class="treemenudiv">',$node_id);
echo $this->get_indentation($code); echo $this->get_indentation($code);
if (! $child_count) if (! $child_count)
{
printf('<img id="jt%snode" src="%s/%s" alt="--" class="imgs" style="border: 0px; vertical-align:text-top;" />', $node_id, IMGDIR, $imgs['tree'][$nb]); printf('<img id="jt%snode" src="%s/%s" alt="--" class="imgs" style="border: 0px; vertical-align:text-top;" />', $node_id, IMGDIR, $imgs['tree'][$nb]);
}
else { else {
printf('<a href="#" onclick="return opencloseTreeNode(\'%s\',\'%s\',\'%s\');">',$node_id,$parms['openclose'],IMGDIR); printf('<a href="#" onclick="return opencloseTreeNode(\'%s\',\'%s\',\'%s\');">',$node_id,$parms['openclose'],IMGDIR);
if ($entry->isOpened()) if ($entry->isOpened())
{
printf('<img id="jt%snode" src="%s/%s" alt="+-" class="imgs" style="border: 0px; vertical-align:text-top;" />', $node_id, IMGDIR, $imgs['collapse'][$nb]); printf('<img id="jt%snode" src="%s/%s" alt="+-" class="imgs" style="border: 0px; vertical-align:text-top;" />', $node_id, IMGDIR, $imgs['collapse'][$nb]);
}
else else
{
printf('<img id="jt%snode" src="%s/%s" alt="+-" class="imgs" style="border: 0px; vertical-align:text-top;" />', $node_id, IMGDIR, $imgs['expand'][$nb]); printf('<img id="jt%snode" src="%s/%s" alt="+-" class="imgs" style="border: 0px; vertical-align:text-top;" />', $node_id, IMGDIR, $imgs['expand'][$nb]);
}
echo '</a>'; echo '</a>';
} }
@ -124,13 +146,17 @@ class AJAXTree extends HTMLTree {
printf('<div id="jt%sson" style="display: %s" class="treemenudiv">',$node_id,($entry->isOpened() ? 'block' : 'none')); printf('<div id="jt%sson" style="display: %s" class="treemenudiv">',$node_id,($entry->isOpened() ? 'block' : 'none'));
if ($entry->isOpened()) if ($entry->isOpened())
{
$this->draw_children($entry, $code . $new_code[$nb]); $this->draw_children($entry, $code . $new_code[$nb]);
}
echo '</div>'; echo '</div>';
if ($level == 0) if ($level == 0)
{
echo '</td></tr>'; echo '</td></tr>';
} }
}
/** /**
* Expand and draw a child entry, when it is clicked on. This is using AJAX just to render this section of the tree. * Expand and draw a child entry, when it is clicked on. This is using AJAX just to render this section of the tree.
@ -139,13 +165,17 @@ class AJAXTree extends HTMLTree {
*/ */
public function draw_children($parent_entry,$code) { public function draw_children($parent_entry,$code) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$children = array(); $children = array();
foreach ($parent_entry->getChildren() as $child) { foreach ($parent_entry->getChildren() as $child) {
if (! $this->getEntry($child)) if (! $this->getEntry($child))
{
$this->addEntry($child); $this->addEntry($child);
}
array_push($children,$this->getEntry($child)); array_push($children,$this->getEntry($child));
} }
@ -155,7 +185,9 @@ class AJAXTree extends HTMLTree {
# If compression is on, we need to compress this output - but only if called by draw_tree_node # 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') if (function_exists('isCompress') && isCompress() && get_request('cmd','REQUEST') == 'draw_tree_node')
{
ob_start(); ob_start();
}
echo $first_child; echo $first_child;
@ -164,9 +196,13 @@ class AJAXTree extends HTMLTree {
$last = ($i == (count($children)-1)) && (! $last_child); $last = ($i == (count($children)-1)) && (! $last_child);
if (is_object($children[$i])) if (is_object($children[$i]))
{
$this->draw_item($children[$i]->getDN(), $code, $first, $last); $this->draw_item($children[$i]->getDN(), $code, $first, $last);
}
else else
{
echo '<br/>problem getting DN entry from ldap'; echo '<br/>problem getting DN entry from ldap';
}
echo "\n"; echo "\n";
} }
@ -187,7 +223,9 @@ class AJAXTree extends HTMLTree {
*/ */
protected function get_indentation($code) { protected function get_indentation($code) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$indent = ''; $indent = '';
@ -211,7 +249,9 @@ class AJAXTree extends HTMLTree {
*/ */
protected function draw_javascript() { protected function draw_javascript() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
parent::draw_javascript(); parent::draw_javascript();
printf('<script type="text/javascript" src="%slayersmenu-browser_detection.js"></script>',JSDIR); printf('<script type="text/javascript" src="%slayersmenu-browser_detection.js"></script>',JSDIR);
@ -226,17 +266,23 @@ class AJAXTree extends HTMLTree {
*/ */
private function create_before_child($entry,$level) { private function create_before_child($entry,$level) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
if (strlen($level) == 0) if (strlen($level) == 0)
{
return ''; return '';
}
$server = $this->getServer(); $server = $this->getServer();
$output = ''; $output = '';
if (! $server->isReadOnly() && ! $entry->isLeaf() && (count($entry->getChildren()) > 10) && $this->getServer()->isShowCreateEnabled() if (! $server->isReadOnly() && ! $entry->isLeaf() && (count($entry->getChildren()) > 10) && $this->getServer()->isShowCreateEnabled()
&& $_SESSION[APPCONFIG]->getValue('appearance','show_top_create')) && $_SESSION[APPCONFIG]->getValue('appearance','show_top_create'))
{
$output = $this->draw_create_new_entry($entry, $level, IMGDIR . '/tree_split.png'); $output = $this->draw_create_new_entry($entry, $level, IMGDIR . '/tree_split.png');
}
return $output; return $output;
} }
@ -249,16 +295,22 @@ class AJAXTree extends HTMLTree {
*/ */
private function create_after_child($entry,$level) { private function create_after_child($entry,$level) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
if (strlen($level) == 0) if (strlen($level) == 0)
{
return ''; return '';
}
$server = $this->getServer(); $server = $this->getServer();
$output = ''; $output = '';
if (! $server->isReadOnly() && ! $entry->isLeaf() && $this->getServer()->isShowCreateEnabled()) if (! $server->isReadOnly() && ! $entry->isLeaf() && $this->getServer()->isShowCreateEnabled())
{
$output = $this->draw_create_new_entry($entry, $level, IMGDIR . '/tree_corner.png'); $output = $this->draw_create_new_entry($entry, $level, IMGDIR . '/tree_corner.png');
}
return $output; return $output;
} }
@ -272,7 +324,9 @@ class AJAXTree extends HTMLTree {
*/ */
private function draw_create_new_entry($entry,$level,$img) { private function draw_create_new_entry($entry,$level,$img) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$output = ''; $output = '';
@ -286,11 +340,15 @@ class AJAXTree extends HTMLTree {
$output .= '&nbsp;'; $output .= '&nbsp;';
if (isAjaxEnabled()) if (isAjaxEnabled())
{
$output .= sprintf('<a href="cmd.php?%s" title="%s" class="phplm" onclick="return ajDISPLAY(\'BODY\',\'%s\',\'%s\');">', $output .= sprintf('<a href="cmd.php?%s" title="%s" class="phplm" onclick="return ajDISPLAY(\'BODY\',\'%s\',\'%s\');">',
htmlspecialchars($href), _('Create new entry here'), htmlspecialchars($href), _('Create new entry here'),
htmlspecialchars($href), _('Loading')); htmlspecialchars($href), _('Loading'));
}
else else
{
$output .= sprintf('<a href="cmd.php?%s" title="%s" class="phplm">', htmlspecialchars($href), _('Create new entry here')); $output .= sprintf('<a href="cmd.php?%s" title="%s" class="phplm">', htmlspecialchars($href), _('Create new entry here'));
}
$output .= _('Create new entry here'); $output .= _('Create new entry here');
$output .= '</a>'; $output .= '</a>';
@ -305,13 +363,19 @@ class AJAXTree extends HTMLTree {
*/ */
public function listOpenItems() { public function listOpenItems() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$result = array(); $result = array();
foreach ($this->entries as $dn => $value) foreach ($this->entries as $dn => $value)
{
if ($value->isOpened()) if ($value->isOpened())
{
array_push($result, $value->getDN()); array_push($result, $value->getDN());
}
}
return $result; return $result;
} }

File diff suppressed because it is too large Load Diff

View File

@ -26,10 +26,12 @@ class AttributeFactory {
default: default:
if (! $_SESSION[APPCONFIG]->getValue('appearance','hide_template_warning')) if (! $_SESSION[APPCONFIG]->getValue('appearance','hide_template_warning'))
{
system_message(array( system_message(array(
'title' => sprintf('%s [<i>%s</i>]', _('Unknown template [post] function'), $matches[1]), 'title' => sprintf('%s [<i>%s</i>]', _('Unknown template [post] function'), $matches[1]),
'body' => sprintf('%s <small>[%s]</small>', _('The template function is not known and will be ignored.'), $values['post']), 'body' => sprintf('%s <small>[%s]</small>', _('The template function is not known and will be ignored.'), $values['post']),
'type' => 'warn')); 'type' => 'warn'));
}
unset($values['post']); unset($values['post']);
} }
@ -38,16 +40,23 @@ class AttributeFactory {
# Check our helper functions exists # Check our helper functions exists
if (isset($values['helper']['value']) && ! is_array($values['helper']['value'])) if (isset($values['helper']['value']) && ! is_array($values['helper']['value']))
{
if (preg_match('/^=php\.(\w+)\((.*)\)$/', $values['helper']['value'], $matches)) if (preg_match('/^=php\.(\w+)\((.*)\)$/', $values['helper']['value'], $matches))
if (! in_array($matches[1],array('GetNextNumber','PasswordEncryptionTypes'))) { {
if ( ! in_array($matches[1], array('GetNextNumber', 'PasswordEncryptionTypes')))
{
if ( ! $_SESSION[APPCONFIG]->getValue('appearance', 'hide_template_warning')) if ( ! $_SESSION[APPCONFIG]->getValue('appearance', 'hide_template_warning'))
{
system_message(array( system_message(array(
'title' => sprintf('%s [<i>%s</i>]', _('Unknown template helper function'), $matches[1]), 'title' => sprintf('%s [<i>%s</i>]', _('Unknown template helper function'), $matches[1]),
'body' => sprintf('%s <small>[%s]</small>', _('The template helper function is not known and will be ignored.'), $values['helper']['value']), 'body' => sprintf('%s <small>[%s]</small>', _('The template helper function is not known and will be ignored.'), $values['helper']['value']),
'type' => 'warn')); 'type' => 'warn'));
}
unset($values['helper']['value']); unset($values['helper']['value']);
} }
}
}
# Check to see if the value is auto generated, our attribute type is dependant on the function called. # Check to see if the value is auto generated, our attribute type is dependant on the function called.
if (isset($values['value']) && ! is_array($values['value'])) { if (isset($values['value']) && ! is_array($values['value'])) {
@ -55,7 +64,9 @@ class AttributeFactory {
switch ($matches[1]) { switch ($matches[1]) {
case 'MultiList': case 'MultiList':
if (! isset($values['type'])) if (! isset($values['type']))
{
$values['type'] = 'multiselect'; $values['type'] = 'multiselect';
}
case 'PickList': case 'PickList':
return $this->newSelectionAttribute($name,$values,$server_id,$source); return $this->newSelectionAttribute($name,$values,$server_id,$source);
@ -70,10 +81,12 @@ class AttributeFactory {
default: default:
if (! $_SESSION[APPCONFIG]->getValue('appearance','hide_template_warning')) if (! $_SESSION[APPCONFIG]->getValue('appearance','hide_template_warning'))
{
system_message(array( system_message(array(
'title' => sprintf('%s [<i>%s</i>]', _('Unknown template function'), $matches[1]), 'title' => sprintf('%s [<i>%s</i>]', _('Unknown template function'), $matches[1]),
'body' => sprintf('%s <small>[%s]</small>', _('The template function is not known and will be ignored.'), $values['value']), 'body' => sprintf('%s <small>[%s]</small>', _('The template function is not known and will be ignored.'), $values['value']),
'type' => 'warn')); 'type' => 'warn'));
}
unset($values['value']); unset($values['value']);
} }
@ -81,12 +94,17 @@ class AttributeFactory {
} }
if (isset($values['type'])) if (isset($values['type']))
switch ($values['type']) { {
switch ($values['type'])
{
case 'password': case 'password':
if ( ! strcasecmp($name, 'sambaLMPassword') || ! strcasecmp($name, 'sambaNTPassword')) if ( ! strcasecmp($name, 'sambaLMPassword') || ! strcasecmp($name, 'sambaNTPassword'))
{
return $this->newSambaPasswordAttribute($name, $values, $server_id, $source); return $this->newSambaPasswordAttribute($name, $values, $server_id, $source);
else } else
{
return $this->newPasswordAttribute($name, $values, $server_id, $source); return $this->newPasswordAttribute($name, $values, $server_id, $source);
}
case 'multiselect': case 'multiselect':
case 'select': case 'select':
@ -95,6 +113,7 @@ class AttributeFactory {
case 'textarea': case 'textarea':
return $this->newMultiLineAttribute($name, $values, $server_id, $source); return $this->newMultiLineAttribute($name, $values, $server_id, $source);
} }
}
if (! strcasecmp($name,'objectClass')) { if (! strcasecmp($name,'objectClass')) {
return $this->newObjectClassAttribute($name,$values,$server_id,$source); return $this->newObjectClassAttribute($name,$values,$server_id,$source);

View File

@ -28,8 +28,14 @@ class BinaryAttribute extends Attribute {
} }
public function getFileName($i) { public function getFileName($i) {
if (isset($this->filenames[$i])) return $this->filenames[$i]; if (isset($this->filenames[$i]))
else return null; {
return $this->filenames[$i];
}
else
{
return NULL;
}
} }
public function addFileName($name, $i = -1) { public function addFileName($name, $i = -1) {
@ -45,8 +51,14 @@ class BinaryAttribute extends Attribute {
} }
public function getFilePath($i) { public function getFilePath($i) {
if (isset($this->filepaths[$i])) return $this->filepaths[$i]; if (isset($this->filepaths[$i]))
else return null; {
return $this->filepaths[$i];
}
else
{
return NULL;
}
} }
public function addFilePath($path, $i = -1) { public function addFilePath($path, $i = -1) {

View File

@ -26,14 +26,18 @@ class HTMLTree extends Tree {
*/ */
public function draw($onlytree=false) { public function draw($onlytree=false) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
static $js_drawn = false; static $js_drawn = false;
$server = $this->getServer(); $server = $this->getServer();
echo '<table class="tree" border="0">'; echo '<table class="tree" border="0">';
if (! $onlytree) if (! $onlytree)
{
$this->draw_server_name(); $this->draw_server_name();
}
$this->javascript = ''; $this->javascript = '';
$javascript_id = 0; $javascript_id = 0;
@ -46,14 +50,22 @@ class HTMLTree extends Tree {
$this->draw_menu(); $this->draw_menu();
if ($server->getAuthType() != 'config') if ($server->getAuthType() != 'config')
{
$this->draw_logged_in_user(); $this->draw_logged_in_user();
}
else else
{
printf('<tr><td class="blank" colspan="%s">&nbsp;</td></tr>', $this->getDepth() + 3); printf('<tr><td class="blank" colspan="%s">&nbsp;</td></tr>', $this->getDepth() + 3);
}
if ($server->isReadOnly()) if ($server->isReadOnly())
{
printf('<tr><td class="spacer"></td><td class="logged_in" colspan="%s">(%s)</td></tr>', $this->getDepth() + 3 - 1, _('read only')); printf('<tr><td class="spacer"></td><td class="logged_in" colspan="%s">(%s)</td></tr>', $this->getDepth() + 3 - 1, _('read only'));
}
else else
{
printf('<tr><td class="blank" colspan="%s">&nbsp;</td></tr>', $this->getDepth() + 3); 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" id="ajSID_%s_nodes">', printf('<tr><td>&nbsp;</td><td><div style="overflow: auto; %s%s" id="ajSID_%s_nodes">',
$_SESSION[APPCONFIG]->getValue('appearance','tree_width') ? sprintf('width: %spx; ',$_SESSION[APPCONFIG]->getValue('appearance','tree_width')) : '', $_SESSION[APPCONFIG]->getValue('appearance','tree_width') ? sprintf('width: %spx; ',$_SESSION[APPCONFIG]->getValue('appearance','tree_width')) : '',
@ -74,7 +86,9 @@ class HTMLTree extends Tree {
echo '</table>'; echo '</table>';
if (! $onlytree) if (! $onlytree)
{
echo '</div></td></tr>'; echo '</div></td></tr>';
}
echo '</table>'; echo '</table>';
return; return;
@ -107,11 +121,15 @@ class HTMLTree extends Tree {
$this->javascript .= sprintf('</form>'); $this->javascript .= sprintf('</form>');
if (preg_match('/,/',$base->getDN())) if (preg_match('/,/',$base->getDN()))
{
printf('<tr><td class="spacer"></td><td class="spacer"></td><td class="spacer"></td><td colspan="%s"><small>%s</small></td></tr>', printf('<tr><td class="spacer"></td><td class="spacer"></td><td class="spacer"></td><td colspan="%s"><small>%s</small></td></tr>',
$this->getDepth() + 3 - 3, _('This base cannot be created with PLA.')); $this->getDepth() + 3 - 3, _('This base cannot be created with PLA.'));
}
else else
{
printf('<tr><td class="spacer"></td><td class="spacer"></td><td class="spacer"></td><td colspan="%s"><small>%s <a href="javascript:document.getElementById(\'create_base_form_%s_%s\').submit()">%s</a></small></td></tr>', printf('<tr><td class="spacer"></td><td class="spacer"></td><td class="spacer"></td><td colspan="%s"><small>%s <a href="javascript:document.getElementById(\'create_base_form_%s_%s\').submit()">%s</a></small></td></tr>',
$this->getDepth() + 3 - 3, _('This base entry does not exist.'), $server->getIndex(), $javascript_id, _('Create it?')); $this->getDepth() + 3 - 3, _('This base entry does not exist.'), $server->getIndex(), $javascript_id, _('Create it?'));
}
} else { } else {
$this->draw_item($base->getDN(),-1); $this->draw_item($base->getDN(),-1);
@ -121,7 +139,9 @@ class HTMLTree extends Tree {
echo '</table>'; echo '</table>';
if (! $onlytree) if (! $onlytree)
{
echo '</div></td></tr>'; echo '</div></td></tr>';
}
# We are not logged in, draw a login... link. # We are not logged in, draw a login... link.
} else { } else {
@ -157,7 +177,9 @@ class HTMLTree extends Tree {
*/ */
protected function draw_server_name() { protected function draw_server_name() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$server = $this->getServer(); $server = $this->getServer();
@ -179,15 +201,22 @@ class HTMLTree extends Tree {
*/ */
protected function draw_menu() { protected function draw_menu() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$links = ''; $links = '';
if (is_array($_SESSION[APPCONFIG]->getValue('menu','session'))) if (is_array($_SESSION[APPCONFIG]->getValue('menu','session')))
foreach ($_SESSION[APPCONFIG]->getValue('menu','session') as $link => $title) { {
foreach ($_SESSION[APPCONFIG]->getValue('menu', 'session') as $link => $title)
{
if ($this->get_menu_item($link)) if ($this->get_menu_item($link))
{
$links .= sprintf('<td class="server_links">%s</td>', $this->get_menu_item($link)); $links .= sprintf('<td class="server_links">%s</td>', $this->get_menu_item($link));
} }
}
}
# Finally add our logout link. # Finally add our logout link.
$links .= sprintf('<td class="server_links">%s</td>',$this->get_logout_menu_item()); $links .= sprintf('<td class="server_links">%s</td>',$this->get_logout_menu_item());
@ -207,7 +236,9 @@ class HTMLTree extends Tree {
*/ */
protected function get_menu_item($item) { protected function get_menu_item($item) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$server = $this->getServer(); $server = $this->getServer();
$menu = array(); $menu = array();
@ -215,7 +246,9 @@ class HTMLTree extends Tree {
switch($item) { switch($item) {
case 'schema': case 'schema':
if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','schema')) if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','schema'))
{
return ''; return '';
}
$menu['cmd'] = 'schema'; $menu['cmd'] = 'schema';
$menu['ajax'] = _('Loading Schema'); $menu['ajax'] = _('Loading Schema');
@ -228,7 +261,9 @@ class HTMLTree extends Tree {
case 'search': case 'search':
if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','query_engine')) if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','query_engine'))
{
return ''; return '';
}
$menu['cmd'] = 'query_engine'; $menu['cmd'] = 'query_engine';
$menu['ajax'] = _('Loading Search'); $menu['ajax'] = _('Loading Search');
@ -241,7 +276,9 @@ class HTMLTree extends Tree {
case 'refresh': case 'refresh':
if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','refresh')) if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','refresh'))
{
return ''; return '';
}
$menu['cmd'] = 'refresh'; $menu['cmd'] = 'refresh';
$menu['href'] = '&noheader=1&purge=1'; $menu['href'] = '&noheader=1&purge=1';
@ -255,7 +292,9 @@ class HTMLTree extends Tree {
case 'server_info': case 'server_info':
if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','server_info')) if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','server_info'))
{
return ''; return '';
}
$menu['cmd'] = 'server_info'; $menu['cmd'] = 'server_info';
$menu['ajax'] = _('Loading Info'); $menu['ajax'] = _('Loading Info');
@ -268,11 +307,15 @@ class HTMLTree extends Tree {
case 'monitor': case 'monitor':
if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','monitor')) if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','monitor'))
{
return ''; return '';
}
$attrs = $server->getRootDSE(); $attrs = $server->getRootDSE();
if (! $attrs || ! isset($attrs['monitorcontext'])) if (! $attrs || ! isset($attrs['monitorcontext']))
{
return ''; return '';
}
$menu['cmd'] = 'monitor'; $menu['cmd'] = 'monitor';
$menu['ajax'] = _('Loading Monitor Info'); $menu['ajax'] = _('Loading Monitor Info');
@ -285,7 +328,9 @@ class HTMLTree extends Tree {
case 'import': case 'import':
if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','import_form') || ! $_SESSION[APPCONFIG]->isCommandAvailable('script','import') || $server->isReadOnly()) if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','import_form') || ! $_SESSION[APPCONFIG]->isCommandAvailable('script','import') || $server->isReadOnly())
{
return ''; return '';
}
$menu['cmd'] = 'import_form'; $menu['cmd'] = 'import_form';
$menu['ajax'] = _('Loading Import'); $menu['ajax'] = _('Loading Import');
@ -298,7 +343,9 @@ class HTMLTree extends Tree {
case 'export': case 'export':
if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','export_form') || ! $_SESSION[APPCONFIG]->isCommandAvailable('script','export')) if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','export_form') || ! $_SESSION[APPCONFIG]->isCommandAvailable('script','export'))
{
return ''; return '';
}
$menu['cmd'] = 'export_form'; $menu['cmd'] = 'export_form';
$menu['ajax'] = _('Loading Export'); $menu['ajax'] = _('Loading Export');
@ -316,33 +363,45 @@ class HTMLTree extends Tree {
$href_parms = htmlspecialchars(sprintf('cmd=%s&server_id=%s%s',$menu['cmd'],$server->getIndex(),isset($menu['href']) ? $menu['href'] : '')); $href_parms = htmlspecialchars(sprintf('cmd=%s&server_id=%s%s',$menu['cmd'],$server->getIndex(),isset($menu['href']) ? $menu['href'] : ''));
if (isAjaxEnabled()) if (isAjaxEnabled())
{
return sprintf('<a href="cmd.php?%s" onclick="return ajDISPLAY(\'%s\',\'%s\',\'%s\');" title="%s %s"><img src="%s/%s" alt="%s" /><br />%s</a>', return sprintf('<a href="cmd.php?%s" onclick="return ajDISPLAY(\'%s\',\'%s\',\'%s\');" title="%s %s"><img src="%s/%s" alt="%s" /><br />%s</a>',
$href_parms, $menu['div'], $href_parms, $menu['ajax'], $menu['title'], $server->getName(), IMGDIR, $menu['img'], $menu['name'], $menu['name']); $href_parms, $menu['div'], $href_parms, $menu['ajax'], $menu['title'], $server->getName(), IMGDIR, $menu['img'], $menu['name'], $menu['name']);
}
else else
{
return sprintf('<a href="cmd.php?%s" title="%s %s"><img src="%s/%s" alt="%s" /><br />%s</a>', return sprintf('<a href="cmd.php?%s" title="%s %s"><img src="%s/%s" alt="%s" /><br />%s</a>',
$href_parms, $menu['title'], $server->getName(), IMGDIR, $menu['img'], $menu['name'], $menu['name']); $href_parms, $menu['title'], $server->getName(), IMGDIR, $menu['img'], $menu['name'], $menu['name']);
} }
}
protected function get_logout_menu_item() { protected function get_logout_menu_item() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$server = $this->getServer(); $server = $this->getServer();
$href = sprintf('cmd.php?cmd=logout&server_id=%s',$server->getIndex()); $href = sprintf('cmd.php?cmd=logout&server_id=%s',$server->getIndex());
if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','logout') || in_array($server->getAuthType(),array('config','http','proxy','sasl'))) if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','logout') || in_array($server->getAuthType(),array('config','http','proxy','sasl')))
{
return ''; return '';
}
else else
{
return sprintf('<a href="%s" title="%s"><img src="%s/%s" alt="%s" /><br />%s</a>', return sprintf('<a href="%s" title="%s"><img src="%s/%s" alt="%s" /><br />%s</a>',
htmlspecialchars($href), _('Logout of this server'), IMGDIR, 'logout-big.png', _('logout'), _('logout')); htmlspecialchars($href), _('Logout of this server'), IMGDIR, 'logout-big.png', _('logout'), _('logout'));
} }
}
/** /**
* Draw the Logged in User * Draw the Logged in User
*/ */
protected function draw_logged_in_user() { protected function draw_logged_in_user() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$server = $this->getServer(); $server = $this->getServer();
@ -362,28 +421,39 @@ class HTMLTree extends Tree {
$bases = $server->getContainerTop($logged_in_dn); $bases = $server->getContainerTop($logged_in_dn);
if (is_array($bases) && count($bases)) if (is_array($bases) && count($bases))
{
array_push($logged_in_dn_array, $bases); array_push($logged_in_dn_array, $bases);
}
$rdn = $logged_in_dn; $rdn = $logged_in_dn;
# Some sanity checking here, in case our DN doesnt look like a DN # Some sanity checking here, in case our DN doesnt look like a DN
if (! is_array($logged_in_dn_array)) if (! is_array($logged_in_dn_array))
{
$logged_in_dn_array = array($logged_in_dn); $logged_in_dn_array = array($logged_in_dn);
}
if (trim($logged_in_dn)) { if (trim($logged_in_dn)) {
if ($server->dnExists($logged_in_dn)) if ($server->dnExists($logged_in_dn))
foreach ($logged_in_dn_array as $rdn_piece) { {
foreach ($logged_in_dn_array as $rdn_piece)
{
$href = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s', $server->getIndex(), rawurlencode($rdn)); $href = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s', $server->getIndex(), rawurlencode($rdn));
printf('<a href="%s">%s</a>', htmlspecialchars($href), pretty_print_dn($rdn_piece)); printf('<a href="%s">%s</a>', htmlspecialchars($href), pretty_print_dn($rdn_piece));
if ($rdn_piece != end($logged_in_dn_array)) if ($rdn_piece != end($logged_in_dn_array))
{
echo ','; echo ',';
}
$rdn = substr($rdn, (1 + strpos($rdn, ','))); $rdn = substr($rdn, (1 + strpos($rdn, ',')));
} }
}
else else
{
echo $logged_in_dn; echo $logged_in_dn;
}
} else { } else {
echo 'Anonymous'; echo 'Anonymous';
@ -401,7 +471,9 @@ class HTMLTree extends Tree {
*/ */
protected function draw_item($item,$level) { protected function draw_item($item,$level) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$server = $this->getServer(); $server = $this->getServer();
@ -416,7 +488,9 @@ class HTMLTree extends Tree {
# If the entry doesnt exist in the server, then return here with an empty string. # If the entry doesnt exist in the server, then return here with an empty string.
if (! $entry) if (! $entry)
{
return; return;
}
# Get our children. # Get our children.
$child_count = $this->readChildrenNumber($item); $child_count = $this->readChildrenNumber($item);
@ -432,15 +506,24 @@ class HTMLTree extends Tree {
# Is this node expanded? (deciding whether to draw "+" or "-") # Is this node expanded? (deciding whether to draw "+" or "-")
if ($entry->isOpened()) if ($entry->isOpened())
{
if ( ! $child_count && ! $this->getServer()->isShowCreateEnabled()) if ( ! $child_count && ! $this->getServer()->isShowCreateEnabled())
{
printf('<td class="expander"><img src="%s/minus.png" alt="-" /></td>', IMGDIR); printf('<td class="expander"><img src="%s/minus.png" alt="-" /></td>', IMGDIR);
else } else
{
printf('<td class="expander"><a href="%s"><img src="%s/minus.png" alt="-" /></a></td>', $href['collapse'], IMGDIR); printf('<td class="expander"><a href="%s"><img src="%s/minus.png" alt="-" /></a></td>', $href['collapse'], IMGDIR);
}
}
else else
if (($child_count !== false) && (! $child_count) && (! $this->getServer()->isShowCreateEnabled())) if (($child_count !== false) && (! $child_count) && (! $this->getServer()->isShowCreateEnabled()))
{
printf('<td class="expander"><img src="%s/minus.png" alt="-" /></td>', IMGDIR); printf('<td class="expander"><img src="%s/minus.png" alt="-" /></td>', IMGDIR);
}
else else
{
printf('<td class="expander"><a href="%s"><img src="%s/plus.png" alt="+" /></a></td>', $href['expand'], IMGDIR); printf('<td class="expander"><a href="%s"><img src="%s/plus.png" alt="+" /></a></td>', $href['expand'], IMGDIR);
}
printf('<td class="icon"><a href="%s" id="node_%s_%s"><img src="%s/%s" alt="img" /></a></td>', printf('<td class="icon"><a href="%s" id="node_%s_%s"><img src="%s/%s" alt="img" /></a></td>',
$href['edit'],$server->getIndex(),preg_replace('/=/','_',base64_encode($item)),IMGDIR,$entry->getIcon()); $href['edit'],$server->getIndex(),preg_replace('/=/','_',base64_encode($item)),IMGDIR,$entry->getIcon());
@ -449,7 +532,9 @@ class HTMLTree extends Tree {
printf('<a href="%s">%s</a>',$href['edit'],$this->get_formatted_dn($entry,$level)); printf('<a href="%s">%s</a>',$href['edit'],$this->get_formatted_dn($entry,$level));
if ($child_count) if ($child_count)
{
printf(' <span class="count">(%s)</span>', $child_count); printf(' <span class="count">(%s)</span>', $child_count);
}
echo '</span></td></tr>'; echo '</span></td></tr>';
@ -464,7 +549,9 @@ class HTMLTree extends Tree {
} }
foreach ($entry->getChildren() as $dnChildEntry) foreach ($entry->getChildren() as $dnChildEntry)
{
$this->draw_item($dnChildEntry, $level + 1); $this->draw_item($dnChildEntry, $level + 1);
}
# Always draw the "create new" link at the bottom of the listing # Always draw the "create new" link at the bottom of the listing
if (! $server->isReadOnly() && ! $entry->isLeaf() && $this->getServer()->isShowCreateEnabled()) { if (! $server->isReadOnly() && ! $entry->isLeaf() && $this->getServer()->isShowCreateEnabled()) {
@ -473,18 +560,26 @@ class HTMLTree extends Tree {
} }
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
{
debug_log('Leaving (%s,%s)', 33, 0, __FILE__, __LINE__, __METHOD__, $item, $level); debug_log('Leaving (%s,%s)', 33, 0, __FILE__, __LINE__, __METHOD__, $item, $level);
} }
}
protected function get_formatted_dn($entry,$level) { protected function get_formatted_dn($entry,$level) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
if ($level < 0) if ($level < 0)
{
return pretty_print_dn($entry->getDN()); return pretty_print_dn($entry->getDN());
}
else else
{
return draw_formatted_dn($this->getServer(), $entry); return draw_formatted_dn($this->getServer(), $entry);
} }
}
/** /**
* Print the HTML to show the "create new entry here". * Print the HTML to show the "create new entry here".
@ -495,7 +590,9 @@ class HTMLTree extends Tree {
*/ */
protected function draw_create_link($rdn,$level,$encoded_dn) { protected function draw_create_link($rdn,$level,$encoded_dn) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
# print the "Create New object" link. # print the "Create New object" link.
$href = htmlspecialchars(sprintf('cmd.php?cmd=template_engine&server_id=%s&container=%s',$this->getServerID(),$encoded_dn)); $href = htmlspecialchars(sprintf('cmd.php?cmd=template_engine&server_id=%s&container=%s',$this->getServerID(),$encoded_dn));
@ -513,7 +610,9 @@ class HTMLTree extends Tree {
*/ */
protected function draw_login_link() { protected function draw_login_link() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$server = $this->getServer(); $server = $this->getServer();
$href_parm = htmlspecialchars(sprintf('cmd=%s&server_id=%s',get_custom_file($server->getIndex(),'login_form',''),$server->getIndex())); $href_parm = htmlspecialchars(sprintf('cmd=%s&server_id=%s',get_custom_file($server->getIndex(),'login_form',''),$server->getIndex()));
@ -542,7 +641,9 @@ class HTMLTree extends Tree {
*/ */
protected function draw_javascript() { protected function draw_javascript() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
if ($this->javascript) { if ($this->javascript) {
echo "<!-- Forms for javascript submit to call to create base_dns -->\n"; echo "<!-- Forms for javascript submit to call to create base_dns -->\n";
@ -557,13 +658,17 @@ class HTMLTree extends Tree {
*/ */
public function getDepth() { public function getDepth() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$server = $this->getServer(); $server = $this->getServer();
# If we are not logged in # If we are not logged in
if (! $server->isLoggedIn(null)) if (! $server->isLoggedIn(null))
{
return 0; return 0;
}
static $depths = array(); static $depths = array();
@ -577,8 +682,10 @@ class HTMLTree extends Tree {
$depth = count(pla_explode_dn($dn->getDN()))+1-$basedepth; $depth = count(pla_explode_dn($dn->getDN()))+1-$basedepth;
if ($depth > $max) if ($depth > $max)
{
$max = $depth; $max = $depth;
} }
}
$depths[$server->getIndex()] = $max; $depths[$server->getIndex()] = $max;
} }

View File

@ -14,12 +14,15 @@
*/ */
class MassRender extends TemplateRender { class MassRender extends TemplateRender {
protected function drawMassFormReadWriteValueAttribute($attribute,$i,$j) { protected function drawMassFormReadWriteValueAttribute($attribute,$i,$j) {
if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); if (DEBUGTMP)
{
printf('<font size=' - 2'>%s</font><br />',__METHOD__); }
$val = $attribute->getValue($i); $val = $attribute->getValue($i);
if ($attribute->getHelper()) if ($attribute->getHelper())
echo '<table cellspacing="0" cellpadding="0" border=1><tr><td valign="top">'; {
echo '<table cellspacing="0" cellpadding="0" border=1><tr><td valign="top">'; }
printf('<input type="text" class="value" name="mass_values[%s][%s][%s]" id="new_values_%s_%s_%s" value="%s" %s%s %s %s/>', printf('<input type="text" class="value" name="mass_values[%s][%s][%s]" id="new_values_%s_%s_%s" value="%s" %s%s %s %s/>',
$j,htmlspecialchars($attribute->getName()),$i, $j,htmlspecialchars($attribute->getName()),$i,

File diff suppressed because it is too large Load Diff

View File

@ -23,33 +23,43 @@ class Query extends xmlTemplate {
*/ */
protected function storeTemplate($xmldata) { protected function storeTemplate($xmldata) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$server = $this->getServer(); $server = $this->getServer();
foreach ($xmldata['query'] as $xml_key => $xml_value) { foreach ($xmldata['query'] as $xml_key => $xml_value) {
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
{
debug_log('Foreach loop Key [%s] Value [%s]', 4, 0, __FILE__, __LINE__, __METHOD__, $xml_key, is_array($xml_value)); debug_log('Foreach loop Key [%s] Value [%s]', 4, 0, __FILE__, __LINE__, __METHOD__, $xml_key, is_array($xml_value));
}
switch ($xml_key) { switch ($xml_key) {
# Build our attribute list from the DN and Template. # Build our attribute list from the DN and Template.
case ('attributes'): case ('attributes'):
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
{
debug_log('Case [%s]', 4, 0, __FILE__, __LINE__, __METHOD__, $xml_key); debug_log('Case [%s]', 4, 0, __FILE__, __LINE__, __METHOD__, $xml_key);
}
if (is_array($xmldata['query'][$xml_key])) { if (is_array($xmldata['query'][$xml_key])) {
foreach ($xmldata['query'][$xml_key] as $tattrs) { foreach ($xmldata['query'][$xml_key] as $tattrs) {
foreach ($tattrs as $index => $details) { foreach ($tattrs as $index => $details) {
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
{
debug_log('Foreach tattrs Key [%s] Value [%s]', 4, 0, __FILE__, __LINE__, __METHOD__, debug_log('Foreach tattrs Key [%s] Value [%s]', 4, 0, __FILE__, __LINE__, __METHOD__,
$index, $details); $index, $details);
}
# If there is no schema definition for the attribute, it will be ignored. # If there is no schema definition for the attribute, it will be ignored.
if ($sattr = $server->getSchemaAttribute($index)) { if ($sattr = $server->getSchemaAttribute($index)) {
if (is_null($attribute = $this->getAttribute($sattr->getName()))) if (is_null($attribute = $this->getAttribute($sattr->getName())))
$attribute = $this->addAttribute($sattr->getName(false),array('values'=>array())); {
$attribute = $this->addAttribute($sattr->getName(FALSE), array('values' => array()));
}
$attribute->show(); $attribute->show();
$attribute->setXML($details); $attribute->setXML($details);
@ -63,20 +73,29 @@ class Query extends xmlTemplate {
# Build our bases list from the DN and Template. # Build our bases list from the DN and Template.
case ('bases'): case ('bases'):
if (isset($xmldata['query'][$xml_key]['base'])) if (isset($xmldata['query'][$xml_key]['base']))
{
if (is_array($xmldata['query'][$xml_key]['base'])) if (is_array($xmldata['query'][$xml_key]['base']))
{
$this->base = $xmldata['query'][$xml_key]['base']; $this->base = $xmldata['query'][$xml_key]['base'];
else } else
{
$this->base = array($xmldata['query'][$xml_key]['base']); $this->base = array($xmldata['query'][$xml_key]['base']);
}
}
else else
{
error(sprintf(_('In the XML file (%s), [%s] contains an unknown key.'), error(sprintf(_('In the XML file (%s), [%s] contains an unknown key.'),
$this->filename, $xml_key), 'error', 'index.php'); $this->filename, $xml_key), 'error', 'index.php');
}
$this->base = array_unique($this->base); $this->base = array_unique($this->base);
break; break;
default: default:
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
{
debug_log('Case [%s]', 4, 0, __FILE__, __LINE__, __METHOD__, $xml_key); debug_log('Case [%s]', 4, 0, __FILE__, __LINE__, __METHOD__, $xml_key);
}
# Some key definitions need to be an array, some must not be: # Some key definitions need to be an array, some must not be:
$allowed_arrays = array(''); $allowed_arrays = array('');
@ -85,15 +104,24 @@ class Query extends xmlTemplate {
# Items that must be stored lowercase # Items that must be stored lowercase
if (in_array($xml_key,$storelower)) if (in_array($xml_key,$storelower))
{
if (is_array($xml_value)) if (is_array($xml_value))
{
foreach ($xml_value as $index => $value) foreach ($xml_value as $index => $value)
{
$xml_value[$index] = strtolower($value); $xml_value[$index] = strtolower($value);
else }
} else
{
$xml_value = strtolower($xml_value); $xml_value = strtolower($xml_value);
}
}
# Items that must be stored as arrays # Items that must be stored as arrays
if (in_array($xml_key,$storearray) && ! is_array($xml_value)) if (in_array($xml_key,$storearray) && ! is_array($xml_value))
{
$xml_value = array($xml_value); $xml_value = array($xml_value);
}
# Items that should not be an array # Items that should not be an array
if (! in_array($xml_key,$allowed_arrays) && is_array($xml_value)) { if (! in_array($xml_key,$allowed_arrays) && is_array($xml_value)) {
@ -122,7 +150,9 @@ class Query extends xmlTemplate {
*/ */
public function accept() { public function accept() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$server = $this->getServer(); $server = $this->getServer();
@ -140,9 +170,13 @@ class Query extends xmlTemplate {
$attrs = preg_replace('/\s+/','',$attrs); $attrs = preg_replace('/\s+/','',$attrs);
if ($attrs) if ($attrs)
{
$query['attrs'] = explode(',', $attrs); $query['attrs'] = explode(',', $attrs);
}
else else
{
$query['attrs'] = array('*'); $query['attrs'] = array('*');
}
} else { } else {
$bases = $this->base; $bases = $this->base;
@ -152,9 +186,13 @@ class Query extends xmlTemplate {
} }
if (! $bases) if (! $bases)
{
$bases = $server->getBaseDN(); $bases = $server->getBaseDN();
}
elseif (! is_array($bases)) elseif (! is_array($bases))
{
$bases = explode('|', $bases); $bases = explode('|', $bases);
}
foreach ($bases as $base) { foreach ($bases as $base) {
$query['base'] = $base; $query['base'] = $base;
@ -169,11 +207,15 @@ class Query extends xmlTemplate {
$this->resultsdata[$base]['attrs'] = $query['attrs']; $this->resultsdata[$base]['attrs'] = $query['attrs'];
if ($this->getAttrSortOrder() == 'dn') if ($this->getAttrSortOrder() == 'dn')
{
usort($this->results[$base], 'pla_compare_dns'); usort($this->results[$base], 'pla_compare_dns');
}
elseif ($this->getAttrSortOrder()) elseif ($this->getAttrSortOrder())
{
masort($this->results[$base], $this->getAttrSortOrder()); masort($this->results[$base], $this->getAttrSortOrder());
} }
} }
}
/** /**
* This is temporary to get around objects that use a DN for rendering, for example jpegPhoto * This is temporary to get around objects that use a DN for rendering, for example jpegPhoto
@ -181,7 +223,9 @@ class Query extends xmlTemplate {
*/ */
public function setDN($dn) { public function setDN($dn) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs);
}
$this->dn = $dn; $this->dn = $dn;
} }
@ -191,7 +235,9 @@ class Query extends xmlTemplate {
*/ */
public function getDN() { public function getDN() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->dn); debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->dn);
}
return $this->dn; return $this->dn;
} }
@ -199,14 +245,20 @@ class Query extends xmlTemplate {
public function getDNEncode($url=true) { public function getDNEncode($url=true) {
// @todo Be nice to do all this in 1 location // @todo Be nice to do all this in 1 location
if ($url) if ($url)
{
return urlencode(preg_replace('/%([0-9a-fA-F]+)/', "%25\\1", $this->dn)); return urlencode(preg_replace('/%([0-9a-fA-F]+)/', "%25\\1", $this->dn));
}
else else
{
return preg_replace('/%([0-9a-fA-F]+)/', "%25\\1", $this->dn); return preg_replace('/%([0-9a-fA-F]+)/', "%25\\1", $this->dn);
} }
}
public function getAttrSortOrder() { public function getAttrSortOrder() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$result = array(); $result = array();
@ -214,21 +266,27 @@ class Query extends xmlTemplate {
masort($this->attributes,'ordersort'); masort($this->attributes,'ordersort');
foreach ($this->attributes as $attribute) foreach ($this->attributes as $attribute)
{
array_push($result, $attribute->getName()); array_push($result, $attribute->getName());
}
} else { } else {
$display = preg_replace('/,\s+/',',',get_request('orderby','REQUEST',false,'dn')); $display = preg_replace('/,\s+/',',',get_request('orderby','REQUEST',false,'dn'));
if (trim($display)) if (trim($display))
{
$result = explode(',', $display); $result = explode(',', $display);
} }
}
return implode(',',$result); return implode(',',$result);
} }
public function getAttrDisplayOrder() { public function getAttrDisplayOrder() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$result = array(); $result = array();
@ -236,20 +294,28 @@ class Query extends xmlTemplate {
masort($this->attributes,'order'); masort($this->attributes,'order');
foreach ($this->attributes as $attribute) foreach ($this->attributes as $attribute)
{
array_push($result, $attribute->getName()); array_push($result, $attribute->getName());
}
} else { } else {
$display = preg_replace('/,\s+/',',',get_request('display_attrs','REQUEST',false,'')); $display = preg_replace('/,\s+/',',',get_request('display_attrs','REQUEST',false,''));
if (trim($display)) if (trim($display))
{
$result = explode(',', $display); $result = explode(',', $display);
} }
}
# If our display order is empty, then dynamically build it # If our display order is empty, then dynamically build it
if (! count($result)) { if (! count($result)) {
foreach ($this->results as $details) foreach ($this->results as $details)
{
foreach ($details as $attrs) foreach ($details as $attrs)
{
$result = array_merge($result, array_keys(array_change_key_case($attrs))); $result = array_merge($result, array_keys(array_change_key_case($attrs)));
}
}
$result = array_unique($result); $result = array_unique($result);
sort($result); sort($result);
@ -269,14 +335,18 @@ class Query extends xmlTemplate {
*/ */
public function isVisible() { public function isVisible() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->visible); debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->visible);
}
return $this->visible; return $this->visible;
} }
public function getDescription() { public function getDescription() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->description); debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->description);
}
return $this->description; return $this->description;
} }

View File

@ -19,18 +19,31 @@ class QueryRender extends PageRender {
*/ */
public function accept() { public function accept() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); if (DEBUGTMP)
if (DEBUGTMP||DEBUGTMPSUB) printf('<font size=-2>* %s [GETquery:%s]</font><br />',__METHOD__,get_request('query','REQUEST')); {
if (DEBUGTMP||DEBUGTMPSUB) printf('<font size=-2>* %s [Page:%s]</font><br />',__METHOD__,get_request('page','REQUEST')); printf('<font size=-2>%s</font><br />', __METHOD__);
}
if (DEBUGTMP||DEBUGTMPSUB)
{
printf('<font size=-2>* %s [GETquery:%s]</font><br />', __METHOD__, get_request('query', 'REQUEST'));
}
if (DEBUGTMP||DEBUGTMPSUB)
{
printf('<font size=-2>* %s [Page:%s]</font><br />', __METHOD__, get_request('page', 'REQUEST'));
}
$this->template_id = $this->getTemplateChoice(); $this->template_id = $this->getTemplateChoice();
$this->page = get_request('page','REQUEST',false,1); $this->page = get_request('page','REQUEST',false,1);
# If we are the default template, make sure we pressed search # If we are the default template, make sure we pressed search
if ($this->template_id == 'none' && ! get_request('search','REQUEST')) if ($this->template_id == 'none' && ! get_request('search','REQUEST'))
{
$this->drawTemplateChoice(); $this->drawTemplateChoice();
}
elseif ($this->template_id) { elseif ($this->template_id) {
$templates = $this->getTemplates(); $templates = $this->getTemplates();
@ -47,7 +60,9 @@ class QueryRender extends PageRender {
*/ */
protected function getTemplates() { protected function getTemplates() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
return new Queries($this->server_id); return new Queries($this->server_id);
} }
@ -57,18 +72,27 @@ class QueryRender extends PageRender {
*/ */
protected function haveDefaultTemplate() { protected function haveDefaultTemplate() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$server = $this->getServer(); $server = $this->getServer();
if ($server->getValue('query','disable_default')) if ($server->getValue('query','disable_default'))
return false; {
return FALSE;
}
else else
return true; {
return TRUE;
}
} }
protected function drawTemplateChoice() { protected function drawTemplateChoice() {
if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); if (DEBUGTMP)
{
printf('<font size=-2>%s</font><br />', __METHOD__);
}
$server = $this->getServer(); $server = $this->getServer();
@ -97,13 +121,17 @@ class QueryRender extends PageRender {
echo '<td>'; echo '<td>';
echo '<select name="query">'; echo '<select name="query">';
if ($this->haveDefaultTemplate()) if ($this->haveDefaultTemplate())
{
printf('<option value="%s" %s>%s</option>', 'none', '', _('Custom Query')); printf('<option value="%s" %s>%s</option>', 'none', '', _('Custom Query'));
}
foreach ($templates->getTemplates() as $template) foreach ($templates->getTemplates() as $template)
{
printf('<option value="%s" %s>%s</option>', printf('<option value="%s" %s>%s</option>',
$template->getID(), $template->getID(),
($this->template_id == $template->getID() ? 'selected="selected"' : ''), ($this->template_id == $template->getID() ? 'selected="selected"' : ''),
$template->getDescription()); $template->getDescription());
}
echo '</select>'; echo '</select>';
echo '</td>'; echo '</td>';
echo '</tr>'; echo '</tr>';
@ -212,7 +240,9 @@ class QueryRender extends PageRender {
private function visitStart() { private function visitStart() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$this->drawTitle(_('Search Results')); $this->drawTitle(_('Search Results'));
$this->drawSubTitle(); $this->drawSubTitle();
@ -221,7 +251,9 @@ class QueryRender extends PageRender {
private function visitEnd() { private function visitEnd() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$server = $this->getServer(); $server = $this->getServer();
$afattrs = $this->getAFattrs(); $afattrs = $this->getAFattrs();
@ -243,7 +275,9 @@ class QueryRender extends PageRender {
$counter++; $counter++;
if (! $show = get_request('show','REQUEST')) if (! $show = get_request('show','REQUEST'))
$show = ($counter === 1 ? $this->getAjaxRef($base) : null); {
$show = ($counter === 1 ? $this->getAjaxRef($base) : NULL);
}
printf('<div id="DN%s" style="display: %s">', printf('<div id="DN%s" style="display: %s">',
$this->getAjaxRef($base), ($show == $this->getAjaxRef($base) ? 'block' : 'none')); $this->getAjaxRef($base), ($show == $this->getAjaxRef($base) ? 'block' : 'none'));
@ -284,18 +318,26 @@ class QueryRender extends PageRender {
# Ignore DN, we've already displayed it. # Ignore DN, we've already displayed it.
if ($attr == 'dn') if ($attr == 'dn')
{
continue 2; continue 2;
}
if (! isset($dndetails[$attr])) if (! isset($dndetails[$attr]))
{
continue 2; continue 2;
}
# Set our object with our values # Set our object with our values
$afattrs[$attr]->clearValue(); $afattrs[$attr]->clearValue();
if (is_array($dndetails[$attr])) if (is_array($dndetails[$attr]))
{
$afattrs[$attr]->initValue($dndetails[$attr]); $afattrs[$attr]->initValue($dndetails[$attr]);
}
else else
{
$afattrs[$attr]->initValue(array($dndetails[$attr])); $afattrs[$attr]->initValue(array($dndetails[$attr]));
}
echo '<tr class="list_item">'; echo '<tr class="list_item">';
echo '<td class="blank">&nbsp;</td>'; echo '<td class="blank">&nbsp;</td>';
@ -329,7 +371,9 @@ class QueryRender extends PageRender {
printf('<input type="hidden" name="server_id" value="%s" />',$server->getIndex()); printf('<input type="hidden" name="server_id" value="%s" />',$server->getIndex());
foreach ($this->template->resultsdata[$base]['attrs'] as $attr) foreach ($this->template->resultsdata[$base]['attrs'] as $attr)
{
printf('<input type="hidden" name="attrs[]" value="%s" />', $attr); printf('<input type="hidden" name="attrs[]" value="%s" />', $attr);
}
echo '</div>'; echo '</div>';
@ -362,7 +406,9 @@ class QueryRender extends PageRender {
# Is mass action enabled. # Is mass action enabled.
if ($_SESSION[APPCONFIG]->getValue('mass','enabled')) if ($_SESSION[APPCONFIG]->getValue('mass','enabled'))
{
printf('<td><input type="checkbox" id="ma_%s" name="dn[]" value="%s" onclick="this.checked=!this.checked;" /></td>', $j, $dndetails['dn']); printf('<td><input type="checkbox" id="ma_%s" name="dn[]" value="%s" onclick="this.checked=!this.checked;" /></td>', $j, $dndetails['dn']);
}
$href = sprintf('cmd=template_engine&server_id=%s&dn=%s',$server->getIndex(),$this->template->getDNEncode()); $href = sprintf('cmd=template_engine&server_id=%s&dn=%s',$server->getIndex(),$this->template->getDNEncode());
printf('<td class="icon"><a href="cmd.php?%s"><img src="%s/%s" alt="icon" /></a></td>', printf('<td class="icon"><a href="cmd.php?%s"><img src="%s/%s" alt="icon" /></a></td>',
@ -390,9 +436,13 @@ class QueryRender extends PageRender {
# Set our object with our values # Set our object with our values
$afattrs[$attr]->clearValue(); $afattrs[$attr]->clearValue();
if (is_array($dndetails[$attr])) if (is_array($dndetails[$attr]))
{
$afattrs[$attr]->initValue($dndetails[$attr]); $afattrs[$attr]->initValue($dndetails[$attr]);
}
else else
{
$afattrs[$attr]->initValue(array($dndetails[$attr])); $afattrs[$attr]->initValue(array($dndetails[$attr]));
}
echo '<td>'; echo '<td>';
$this->draw('CurrentValues',$afattrs[$attr]); $this->draw('CurrentValues',$afattrs[$attr]);
@ -409,7 +459,9 @@ class QueryRender extends PageRender {
printf('<td colspan="%s">',2+count(explode(',',$ado))); printf('<td colspan="%s">',2+count(explode(',',$ado)));
foreach ($mass_actions as $display => $action) foreach ($mass_actions as $display => $action)
{
printf('<button type="submit" name="cmd" value="%s">%s</button>&nbsp;&nbsp;', $action, $display); printf('<button type="submit" name="cmd" value="%s">%s</button>&nbsp;&nbsp;', $action, $display);
}
echo '</td>'; echo '</td>';
echo '</tr>'; echo '</tr>';
@ -433,8 +485,10 @@ class QueryRender extends PageRender {
} }
if (get_request('format','REQUEST',false,'table') == 'table') if (get_request('format','REQUEST',false,'table') == 'table')
{
printf('<script type="text/javascript" src="%sCheckAll.js"></script>', JSDIR); printf('<script type="text/javascript" src="%sCheckAll.js"></script>', JSDIR);
} }
}
public function drawSubTitle($subtitle=null) { public function drawSubTitle($subtitle=null) {
if (is_null($subtitle)) { if (is_null($subtitle)) {
@ -446,7 +500,9 @@ class QueryRender extends PageRender {
$subtitle .= '<br />'; $subtitle .= '<br />';
$subtitle .= sprintf('%s: <b>%s</b>',('Query'),$this->template->getID() != 'none' ? $this->template->getTitle() : _('Default')); $subtitle .= sprintf('%s: <b>%s</b>',('Query'),$this->template->getID() != 'none' ? $this->template->getTitle() : _('Default'));
if ($this->template->getName()) if ($this->template->getName())
$subtitle .= sprintf(' (<b>%s</b>)',$this->template->getName(false)); {
$subtitle .= sprintf(' (<b>%s</b>)', $this->template->getName(FALSE));
}
} }
} }
@ -455,20 +511,26 @@ class QueryRender extends PageRender {
private function getAFattrs() { private function getAFattrs() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$attribute_factory = new AttributeFactory(); $attribute_factory = new AttributeFactory();
$results = array(); $results = array();
foreach (explode(',',$this->template->getAttrDisplayOrder()) as $attr) foreach (explode(',',$this->template->getAttrDisplayOrder()) as $attr)
{
$results[strtolower($attr)] = $attribute_factory->newAttribute($attr, array('values' => array()), $this->getServerID()); $results[strtolower($attr)] = $attribute_factory->newAttribute($attr, array('values' => array()), $this->getServerID());
}
return $results; return $results;
} }
private function getAjaxRef($dn) { private function getAjaxRef($dn) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
return preg_replace('/=/','.',base64_encode($dn)); return preg_replace('/=/','.',base64_encode($dn));
} }
@ -480,7 +542,9 @@ class QueryRender extends PageRender {
echo 'var $items = new Array();'; echo 'var $items = new Array();';
$counter = 0; $counter = 0;
foreach ($this->template->results as $base => $results) foreach ($this->template->results as $base => $results)
{
printf("items[%s] = '%s';", $counter++, $this->getAjaxRef($base)); printf("items[%s] = '%s';", $counter++, $this->getAjaxRef($base));
}
echo 'return items;'; echo 'return items;';
echo '}</script>'; echo '}</script>';
echo "\n\n"; echo "\n\n";
@ -490,7 +554,9 @@ class QueryRender extends PageRender {
$counter = 0; $counter = 0;
foreach ($this->template->results as $base => $results) { foreach ($this->template->results as $base => $results) {
if (! $show = get_request('show','REQUEST')) if (! $show = get_request('show','REQUEST'))
$show = ($counter++ === 0 ? $this->getAjaxRef($base) : null); {
$show = ($counter++ === 0 ? $this->getAjaxRef($base) : NULL);
}
printf('<td id="CTL%s" onclick="return ajSHOWTHIS(\'DN\',\'%s\',\'CTL\');" style="background-color: %s;">%s</td>', printf('<td id="CTL%s" onclick="return ajSHOWTHIS(\'DN\',\'%s\',\'CTL\');" style="background-color: %s;">%s</td>',
$this->getAjaxRef($base), $this->getAjaxRef($base),
@ -534,12 +600,16 @@ class QueryRender extends PageRender {
$query_string = htmlspecialchars(sprintf('%s&format=%s&show=%s&focusbase=%s',array_to_query_string($_GET,array('format','meth')),$f,$this->getAjaxRef($base),$base)); $query_string = htmlspecialchars(sprintf('%s&format=%s&show=%s&focusbase=%s',array_to_query_string($_GET,array('format','meth')),$f,$this->getAjaxRef($base),$base));
if (isAjaxEnabled()) if (isAjaxEnabled())
{
printf('<a href="cmd.php?%s" onclick="return ajDISPLAY(\'BODY\',\'%s\',\'%s\');">%s</a>', printf('<a href="cmd.php?%s" onclick="return ajDISPLAY(\'BODY\',\'%s\',\'%s\');">%s</a>',
$query_string, $query_string, _('Loading Search'), _($f)); $query_string, $query_string, _('Loading Search'), _($f));
}
else else
{
printf('<a href="cmd.php?%s">%s</a>', $query_string, _($f)); printf('<a href="cmd.php?%s">%s</a>', $query_string, _($f));
} }
} }
}
echo ' ]</small>'; echo ' ]</small>';

View File

@ -28,9 +28,13 @@ class SelectionAttribute extends Attribute {
} }
if (isset($values['type']) && $values['type'] == 'multiselect') if (isset($values['type']) && $values['type'] == 'multiselect')
$this->multiple = true; {
$this->multiple = TRUE;
}
else else
$this->multiple = false; {
$this->multiple = FALSE;
}
} }
public function addOption($value,$description) { public function addOption($value,$description) {
@ -39,7 +43,9 @@ class SelectionAttribute extends Attribute {
public function addValue($new_val,$i=-1) { public function addValue($new_val,$i=-1) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$this->addOption($new_val,$i); $this->addOption($new_val,$i);
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -27,7 +27,9 @@ abstract class Tree {
protected function __construct($server_id) { protected function __construct($server_id) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$this->server_id = $server_id; $this->server_id = $server_id;
} }
@ -39,9 +41,11 @@ abstract class Tree {
* @param $server_id * @param $server_id
* @return object Tree * @return object Tree
*/ */
static public function getInstance($server_id) { public static function getInstance($server_id) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$tree = get_cached_item($server_id,'tree'); $tree = get_cached_item($server_id,'tree');
@ -49,14 +53,18 @@ abstract class Tree {
$server = $_SESSION[APPCONFIG]->getServer($server_id); $server = $_SESSION[APPCONFIG]->getServer($server_id);
if (! $server) if (! $server)
return null; {
return NULL;
}
$treeclass = $_SESSION[APPCONFIG]->getValue('appearance','tree'); $treeclass = $_SESSION[APPCONFIG]->getValue('appearance','tree');
$tree = new $treeclass($server_id); $tree = new $treeclass($server_id);
# If we are not logged in, just return the empty tree. # If we are not logged in, just return the empty tree.
if (is_null($server->getLogin(null))) if (is_null($server->getLogin(null)))
{
return $tree; return $tree;
}
foreach ($server->getBaseDN(null) as $base) { foreach ($server->getBaseDN(null) as $base) {
if ($base) { if ($base) {
@ -82,7 +90,9 @@ abstract class Tree {
*/ */
protected function getServerID() { protected function getServerID() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->server_id); debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->server_id);
}
return $this->server_id; return $this->server_id;
} }
@ -94,7 +104,9 @@ abstract class Tree {
*/ */
protected function getServer() { protected function getServer() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
return $_SESSION[APPCONFIG]->getServer($this->server_id); return $_SESSION[APPCONFIG]->getServer($this->server_id);
} }
@ -106,13 +118,19 @@ abstract class Tree {
*/ */
public function getBaseEntries() { public function getBaseEntries() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$return = array(); $return = array();
foreach ($this->entries as $details) foreach ($this->entries as $details)
{
if ($details->isBaseDN() AND (( ! $this->getServer()->getValue('server', 'hide_noaccess_base')) OR $details->isInLdap())) if ($details->isBaseDN() AND (( ! $this->getServer()->getValue('server', 'hide_noaccess_base')) OR $details->isInLdap()))
{
array_push($return, $details); array_push($return, $details);
}
}
return $return; return $return;
} }
@ -131,12 +149,16 @@ abstract class Tree {
*/ */
private function indexDN($dn) { private function indexDN($dn) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$index = strtolower(implode(',',pla_explode_dn($dn))); $index = strtolower(implode(',',pla_explode_dn($dn)));
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
{
debug_log('Result (%s)', 1, 0, __FILE__, __LINE__, __METHOD__, $index); debug_log('Result (%s)', 1, 0, __FILE__, __LINE__, __METHOD__, $index);
}
return $index; return $index;
} }
@ -149,14 +171,20 @@ abstract class Tree {
*/ */
public function getEntry($dn) { public function getEntry($dn) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$dnlower = $this->indexDN($dn); $dnlower = $this->indexDN($dn);
if (isset($this->entries[$dnlower])) if (isset($this->entries[$dnlower]))
{
return $this->entries[$dnlower]; return $this->entries[$dnlower];
}
else else
return null; {
return NULL;
}
} }
/** /**
@ -167,7 +195,9 @@ abstract class Tree {
*/ */
public function addEntry($dn) { public function addEntry($dn) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$server = $this->getServer(); $server = $this->getServer();
$dnlower = $this->indexDN($dn); $dnlower = $this->indexDN($dn);
@ -177,16 +207,22 @@ abstract class Tree {
# return; # return;
if (isset($this->entries[$dnlower])) if (isset($this->entries[$dnlower]))
{
debug_dump_backtrace('Calling add entry to an entry that ALREADY exists?', 1); debug_dump_backtrace('Calling add entry to an entry that ALREADY exists?', 1);
}
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
{
debug_log('New ENTRY (%s).', 64, 0, __FILE__, __LINE__, __METHOD__, $dn); debug_log('New ENTRY (%s).', 64, 0, __FILE__, __LINE__, __METHOD__, $dn);
}
$tree_factory = new TreeItem($server->getIndex(),$dn); $tree_factory = new TreeItem($server->getIndex(),$dn);
$tree_factory->setObjectClasses($server->getDNAttrValue($dn,'objectClass')); $tree_factory->setObjectClasses($server->getDNAttrValue($dn,'objectClass'));
if ((($isleaf = $server->getDNAttrValue($dn,'hassubordinates')) && ! strcasecmp($isleaf[0],'false'))) if ((($isleaf = $server->getDNAttrValue($dn,'hassubordinates')) && ! strcasecmp($isleaf[0],'false')))
{
$tree_factory->setLeaf(); $tree_factory->setLeaf();
}
$this->entries[$dnlower] = $tree_factory; $this->entries[$dnlower] = $tree_factory;
@ -200,7 +236,9 @@ abstract class Tree {
$parent_dn = $server->getContainer($dn); $parent_dn = $server->getContainer($dn);
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
{
debug_log('Parent DNs (%s)', 64, 0, __FILE__, __LINE__, __METHOD__, $parent_dn); debug_log('Parent DNs (%s)', 64, 0, __FILE__, __LINE__, __METHOD__, $parent_dn);
}
if ($parent_dn) { if ($parent_dn) {
$parent_entry = $this->getEntry($parent_dn); $parent_entry = $this->getEntry($parent_dn);
@ -224,21 +262,27 @@ abstract class Tree {
*/ */
public function delEntry($dn) { public function delEntry($dn) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$server = $this->getServer(); $server = $this->getServer();
$dnlower = $this->indexDN($dn); $dnlower = $this->indexDN($dn);
if (isset($this->entries[$dnlower])) if (isset($this->entries[$dnlower]))
{
unset($this->entries[$dnlower]); unset($this->entries[$dnlower]);
}
# Delete entry from parent's children as well. # Delete entry from parent's children as well.
$parent_dn = $server->getContainer($dn); $parent_dn = $server->getContainer($dn);
$parent_entry = $this->getEntry($parent_dn); $parent_entry = $this->getEntry($parent_dn);
if ($parent_entry) if ($parent_entry)
{
$parent_entry->delChild($dn); $parent_entry->delChild($dn);
} }
}
/** /**
* Rename an entry in the tree * Rename an entry in the tree
@ -248,7 +292,9 @@ abstract class Tree {
*/ */
public function renameEntry($dnOLD,$dnNEW) { public function renameEntry($dnOLD,$dnNEW) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$server = $this->getServer(); $server = $this->getServer();
$dnlowerOLD = $this->indexDN($dnOLD); $dnlowerOLD = $this->indexDN($dnOLD);
@ -256,7 +302,9 @@ abstract class Tree {
$this->entries[$dnlowerNEW] = $this->entries[$dnlowerOLD]; $this->entries[$dnlowerNEW] = $this->entries[$dnlowerOLD];
if ($dnlowerOLD != $dnlowerNEW) if ($dnlowerOLD != $dnlowerNEW)
{
unset($this->entries[$dnlowerOLD]); unset($this->entries[$dnlowerOLD]);
}
$this->entries[$dnlowerNEW]->rename($dnNEW); $this->entries[$dnlowerNEW]->rename($dnNEW);
# Update the parent's children # Update the parent's children
@ -265,12 +313,16 @@ abstract class Tree {
$parent_entry = $this->getEntry($parentNEW); $parent_entry = $this->getEntry($parentNEW);
if ($parent_entry) if ($parent_entry)
{
$parent_entry->addChild($dnNEW); $parent_entry->addChild($dnNEW);
}
$parent_entry = $this->getEntry($parentOLD); $parent_entry = $this->getEntry($parentOLD);
if ($parent_entry) if ($parent_entry)
{
$parent_entry->delChild($dnOLD); $parent_entry->delChild($dnOLD);
} }
}
/** /**
* Read the children of a tree entry * Read the children of a tree entry
@ -280,13 +332,17 @@ abstract class Tree {
*/ */
public function readChildren($dn,$nolimit=false) { public function readChildren($dn,$nolimit=false) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$server = $this->getServer(); $server = $this->getServer();
$dnlower = $this->indexDN($dn); $dnlower = $this->indexDN($dn);
if (! isset($this->entries[$dnlower])) if (! isset($this->entries[$dnlower]))
debug_dump_backtrace('Reading children on an entry that isnt set? '.$dnlower,true); {
debug_dump_backtrace('Reading children on an entry that isnt set? ' . $dnlower, TRUE);
}
$ldap['child_limit'] = $nolimit ? 0 : $_SESSION[APPCONFIG]->getValue('search','size_limit'); $ldap['child_limit'] = $nolimit ? 0 : $_SESSION[APPCONFIG]->getValue('search','size_limit');
$ldap['filter'] = $_SESSION[APPCONFIG]->getValue('appearance','tree_filter'); $ldap['filter'] = $_SESSION[APPCONFIG]->getValue('appearance','tree_filter');
@ -302,29 +358,41 @@ abstract class Tree {
} }
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
{
debug_log('Children of (%s) are (%s)', 64, 0, __FILE__, __LINE__, __METHOD__, $dn, $ldap['children']); debug_log('Children of (%s) are (%s)', 64, 0, __FILE__, __LINE__, __METHOD__, $dn, $ldap['children']);
}
# Relax our execution time, it might take some time to load this # Relax our execution time, it might take some time to load this
if ($nolimit) if ($nolimit)
{
@set_time_limit($_SESSION[APPCONFIG]->getValue('search', 'time_limit')); @set_time_limit($_SESSION[APPCONFIG]->getValue('search', 'time_limit'));
}
$this->entries[$dnlower]->readingChildren(true); $this->entries[$dnlower]->readingChildren(true);
foreach ($ldap['children'] as $child) { foreach ($ldap['children'] as $child) {
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
{
debug_log('Adding (%s)', 64, 0, __FILE__, __LINE__, __METHOD__, $child); debug_log('Adding (%s)', 64, 0, __FILE__, __LINE__, __METHOD__, $child);
}
if (! in_array($child,$this->entries[$dnlower]->getChildren())) if (! in_array($child,$this->entries[$dnlower]->getChildren()))
{
$this->entries[$dnlower]->addChild($child); $this->entries[$dnlower]->addChild($child);
} }
}
$this->entries[$dnlower]->readingChildren(false); $this->entries[$dnlower]->readingChildren(false);
if (count($this->entries[$dnlower]->getChildren()) == $ldap['child_limit']) if (count($this->entries[$dnlower]->getChildren()) == $ldap['child_limit'])
{
$this->entries[$dnlower]->setSizeLimited(); $this->entries[$dnlower]->setSizeLimited();
}
else else
{
$this->entries[$dnlower]->unsetSizeLimited(); $this->entries[$dnlower]->unsetSizeLimited();
} }
}
/** /**
* Return the number of children an entry has. Optionally autoread the child entry. * Return the number of children an entry has. Optionally autoread the child entry.
@ -334,16 +402,22 @@ abstract class Tree {
*/ */
protected function readChildrenNumber($dn,$nolimit=false) { protected function readChildrenNumber($dn,$nolimit=false) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$dnlower = $this->indexDN($dn); $dnlower = $this->indexDN($dn);
if (! isset($this->entries[$dnlower])) if (! isset($this->entries[$dnlower]))
debug_dump_backtrace('Reading children on an entry that isnt set?',true); {
debug_dump_backtrace('Reading children on an entry that isnt set?', TRUE);
}
# Read the entry if we havent got it yet. # Read the entry if we havent got it yet.
if (! $this->entries[$dnlower]->isLeaf() && ! $this->entries[$dnlower]->getChildren()) if (! $this->entries[$dnlower]->isLeaf() && ! $this->entries[$dnlower]->getChildren())
{
$this->readChildren($dn, $nolimit); $this->readChildren($dn, $nolimit);
}
return count($this->entries[$dnlower]->getChildren()); return count($this->entries[$dnlower]->getChildren());
} }

View File

@ -40,7 +40,9 @@ class TreeItem {
public function __construct($server_id,$dn) { public function __construct($server_id,$dn) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$this->server_id = $server_id; $this->server_id = $server_id;
$this->dn = $dn; $this->dn = $dn;
@ -53,7 +55,9 @@ class TreeItem {
*/ */
public function getDN() { public function getDN() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->dn); debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->dn);
}
return $this->dn; return $this->dn;
} }
@ -69,7 +73,9 @@ class TreeItem {
*/ */
public function getRDN() { public function getRDN() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
return get_rdn($this->getDN(),0,true); return get_rdn($this->getDN(),0,true);
} }
@ -79,7 +85,9 @@ class TreeItem {
*/ */
public function setBase() { public function setBase() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs);
}
$this->base_entry = true; $this->base_entry = true;
} }
@ -89,28 +97,36 @@ class TreeItem {
*/ */
public function isBaseDN() { public function isBaseDN() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->base_entry); debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->base_entry);
}
return $this->base_entry; return $this->base_entry;
} }
public function setObjectClasses($oc) { public function setObjectClasses($oc) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs);
}
$this->objectclasses = $oc; $this->objectclasses = $oc;
} }
public function getObjectClasses() { public function getObjectClasses() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->objectclasses); debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->objectclasses);
}
return $this->objectclasses; return $this->objectclasses;
} }
public function isInLDAP() { public function isInLDAP() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
return count($this->objectclasses) ? true : false; return count($this->objectclasses) ? true : false;
} }
@ -121,7 +137,9 @@ class TreeItem {
*/ */
public function getChildren() { public function getChildren() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->children); debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->children);
}
if ($this->childsort && ! $this->reading_children) { if ($this->childsort && ! $this->reading_children) {
usort($this->children,'pla_compare_dns'); usort($this->children,'pla_compare_dns');
@ -140,7 +158,9 @@ class TreeItem {
*/ */
public function isChildSorted() { public function isChildSorted() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->childsort); debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->childsort);
}
return $this->childsort; return $this->childsort;
} }
@ -150,7 +170,9 @@ class TreeItem {
*/ */
public function childSorted() { public function childSorted() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs);
}
$this->childsort = false; $this->childsort = false;
} }
@ -162,10 +184,14 @@ class TreeItem {
*/ */
public function addChild($dn) { public function addChild($dn) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
if (in_array($dn,$this->children)) if (in_array($dn,$this->children))
{
return; return;
}
array_push($this->children,$dn); array_push($this->children,$dn);
$this->childsort = true; $this->childsort = true;
@ -178,16 +204,20 @@ class TreeItem {
*/ */
public function delChild($dn) { public function delChild($dn) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
if ($this->children) { if ($this->children) {
# If the parent hasnt been opened in the tree, then there wont be any children. # If the parent hasnt been opened in the tree, then there wont be any children.
$index = array_search($dn,$this->children); $index = array_search($dn,$this->children);
if ($index !== false) if ($index !== false)
{
unset($this->children[$index]); unset($this->children[$index]);
} }
} }
}
/** /**
* Rename this DN. * Rename this DN.
@ -196,7 +226,9 @@ class TreeItem {
*/ */
public function rename($dn) { public function rename($dn) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$this->dn = $dn; $this->dn = $dn;
} }
@ -206,7 +238,9 @@ class TreeItem {
*/ */
public function isOpened() { public function isOpened() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->open); debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->open);
}
return $this->open; return $this->open;
} }
@ -216,7 +250,9 @@ class TreeItem {
*/ */
public function close() { public function close() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$this->open = false; $this->open = false;
} }
@ -226,7 +262,9 @@ class TreeItem {
*/ */
public function open() { public function open() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$this->open = true; $this->open = true;
} }
@ -236,7 +274,9 @@ class TreeItem {
*/ */
public function setLeaf() { public function setLeaf() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs);
}
$this->leaf = true; $this->leaf = true;
} }
@ -246,7 +286,9 @@ class TreeItem {
*/ */
public function isLeaf() { public function isLeaf() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->leaf); debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->leaf);
}
return $this->leaf; return $this->leaf;
} }
@ -257,10 +299,14 @@ class TreeItem {
*/ */
public function getIcon() { public function getIcon() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->icon); debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->icon);
}
if (! $this->icon) if (! $this->icon)
{
$this->icon = get_icon($this->server_id, $this->dn, $this->objectclasses); $this->icon = get_icon($this->server_id, $this->dn, $this->objectclasses);
}
return $this->icon; return $this->icon;
} }
@ -270,7 +316,9 @@ class TreeItem {
*/ */
public function setSizeLimited() { public function setSizeLimited() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs);
}
$this->size_limited = true; $this->size_limited = true;
} }
@ -280,7 +328,9 @@ class TreeItem {
*/ */
public function unsetSizeLimited() { public function unsetSizeLimited() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$this->size_limited = false; $this->size_limited = false;
} }
@ -290,21 +340,27 @@ class TreeItem {
*/ */
public function isSizeLimited() { public function isSizeLimited() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
return $this->size_limited; return $this->size_limited;
} }
public function setTemplate($template) { public function setTemplate($template) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 1, __FILE__, __LINE__, __METHOD__, $fargs);
}
$this->template = $template; $this->template = $template;
} }
public function getTemplate() { public function getTemplate() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 33, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
return $this->template; return $this->template;
} }

View File

@ -23,10 +23,14 @@ abstract class Visitor {
public function __call($method,$args) { public function __call($method,$args) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
if (! in_array($method,array('get','visit','draw'))) if (! in_array($method,array('get','visit','draw')))
{
debug_dump_backtrace(sprintf('Incorrect use of method loading [%s]', $method), 1); debug_dump_backtrace(sprintf('Incorrect use of method loading [%s]', $method), 1);
}
$methods = array(); $methods = array();
@ -41,7 +45,8 @@ abstract class Visitor {
while ($class && ! method_exists($this,$call)) { while ($class && ! method_exists($this,$call)) {
if (defined('DEBUGTMP') && DEBUGTMP) if (defined('DEBUGTMP') && DEBUGTMP)
printf('<font size=-2><i>Class (%s): Method doesnt exist (%s,%s)</i></font><br />',$class,get_class($this),$call); {
printf('<font size=' - 2'><i>Class (%s): Method doesnt exist (%s,%s)</i></font><br />',$class,get_class($this),$call); }
$class = get_parent_class($class); $class = get_parent_class($class);
$call = "$method$fnct$class"; $call = "$method$fnct$class";
@ -49,18 +54,22 @@ abstract class Visitor {
} }
if (defined('DEBUGTMP') && DEBUGTMP) if (defined('DEBUGTMP') && DEBUGTMP)
printf('<font size=-2><i>Calling Methods: %s</i></font><br />',implode('|',$methods)); {
printf('<font size=-2><i>Calling Methods: %s</i></font><br />', implode('|', $methods)); }
if (defined('DEBUGTMP') && DEBUGTMP && method_exists($this,$call)) if (defined('DEBUGTMP') && DEBUGTMP && method_exists($this,$call))
printf('<font size=-2>Method Exists: %s::%s (%s)</font><br />',get_class($this),$call,$args); {
printf('<font size=-2>Method Exists: %s::%s (%s)</font><br />', get_class($this), $call, $args); }
if (method_exists($this,$call)) { if (method_exists($this,$call)) {
$r = call_user_func_array(array($this,$call),$args); $r = call_user_func_array(array($this,$call),$args);
if (isset($r)) if (isset($r))
return $r; {
return $r; }
else else
return; {
return; }
} elseif (DEBUG_ENABLED) { } elseif (DEBUG_ENABLED) {
debug_log('Doesnt exist param (%s,%s)',1,0,__FILE__,__LINE__,__METHOD__,$method,$fnct); debug_log('Doesnt exist param (%s,%s)',1,0,__FILE__,__LINE__,__METHOD__,$method,$fnct);
@ -76,12 +85,15 @@ abstract class Visitor {
*/ */
public function getServerID() { public function getServerID() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',129,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->server_id); {
debug_log('Entered (%%)', 129, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->server_id); }
if (isset($this->server_id)) if (isset($this->server_id))
return $this->server_id; {
return $this->server_id; }
else else
return null; {
return NULL; }
} }
/** /**
@ -91,7 +103,8 @@ abstract class Visitor {
*/ */
protected function getServer() { protected function getServer() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); {
debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); }
return $_SESSION[APPCONFIG]->getServer($this->getServerID()); return $_SESSION[APPCONFIG]->getServer($this->getServerID());
} }

View File

@ -320,7 +320,7 @@ class Horde_Cipher_blowfish {
$keyPos = 0; $keyPos = 0;
} }
} }
$this->p[$i] = $this->p[$i] ^ $keyXor; $this->p[$i] ^= $keyXor;
} }
$encZero = array('L' => 0, 'R' => 0); $encZero = array('L' => 0, 'R' => 0);
@ -438,9 +438,11 @@ class Horde_Cipher_blowfish {
$unpack = unpack('N*', $block); $unpack = unpack('N*', $block);
if (! is_array($unpack)) if (! is_array($unpack))
{
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]', 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), $block, $key, app_version(), phpversion()), 'error', 'index.php'); serialize($unpack), $block, $key, app_version(), phpversion()), 'error', 'index.php');
}
list($L, $R) = array_values($unpack); list($L, $R) = array_values($unpack);

View File

@ -585,14 +585,22 @@ class Config {
static $CACHE = array(); static $CACHE = array();
if ($usecache && count($CACHE)) if ($usecache && count($CACHE))
{
return $CACHE; return $CACHE;
}
foreach ($this->default as $key => $vals) foreach ($this->default as $key => $vals)
{
$CACHE[$key] = $vals; $CACHE[$key] = $vals;
}
foreach ($this->custom as $key => $vals) foreach ($this->custom as $key => $vals)
{
foreach ($vals as $index => $val) foreach ($vals as $index => $val)
{
$CACHE[$key][$index]['value'] = $val; $CACHE[$key][$index]['value'] = $val;
}
}
return $CACHE; return $CACHE;
} }
@ -608,17 +616,27 @@ class Config {
$config = $this->getConfigArray(); $config = $this->getConfigArray();
if (! isset($config[$key])) if (! isset($config[$key]))
{
if ($fatal) if ($fatal)
{
error(sprintf('A call was made in [%s] to getValue requesting [%s] that isnt predefined.', error(sprintf('A call was made in [%s] to getValue requesting [%s] that isnt predefined.',
basename($_SERVER['PHP_SELF']),$key),'error',null,true); basename($_SERVER['PHP_SELF']), $key), 'error', NULL, TRUE);
else } else
{
return ''; return '';
}
}
if (! isset($config[$key][$index])) if (! isset($config[$key][$index]))
{
if ($fatal) if ($fatal)
error(sprintf('Requesting an index [%s] in key [%s] that isnt predefined.',$index,$key),'error',null,true); {
else error(sprintf('Requesting an index [%s] in key [%s] that isnt predefined.', $index, $key), 'error', NULL, TRUE);
} else
{
return ''; return '';
}
}
return isset($config[$key][$index]['value']) ? $config[$key][$index]['value'] : $config[$key][$index]['default']; return isset($config[$key][$index]['value']) ? $config[$key][$index]['value'] : $config[$key][$index]['default'];
} }
@ -630,9 +648,15 @@ class Config {
$result = array(); $result = array();
foreach ($this->default as $option => $details) foreach ($this->default as $option => $details)
{
foreach ($details as $param => $values) foreach ($details as $param => $values)
{
if (isset($values['untested']) && $values['untested']) if (isset($values['untested']) && $values['untested'])
{
array_push($result, sprintf('%s.%s', $option, $param)); array_push($result, sprintf('%s.%s', $option, $param));
}
}
}
return $result; return $result;
} }
@ -642,7 +666,9 @@ class Config {
*/ */
public function CheckCustom() { public function CheckCustom() {
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 3, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 3, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
if (isset($this->custom)) { if (isset($this->custom)) {
foreach ($this->custom as $masterkey => $masterdetails) { foreach ($this->custom as $masterkey => $masterdetails) {
@ -650,19 +676,27 @@ class Config {
if (isset($this->default->$masterkey)) { if (isset($this->default->$masterkey)) {
if (! is_array($masterdetails)) if (! is_array($masterdetails))
error(sprintf('Error in configuration file, [%s] should be an ARRAY.',$masterdetails),'error',null,true); {
error(sprintf('Error in configuration file, [%s] should be an ARRAY.', $masterdetails), 'error', NULL, TRUE);
}
foreach ($masterdetails as $key => $value) { foreach ($masterdetails as $key => $value) {
# Test that the key is correct. # Test that the key is correct.
if (! in_array($key,array_keys($this->default->$masterkey))) 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',null,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. # Test if its should be an array or not.
if (is_array($this->default->{$masterkey}[$key]['default']) && ! is_array($value)) 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',null,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)) 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',null,true); {
error(sprintf('Error in configuration file, %s[\'%s\'] should NOT be an array of values.', $masterkey, $key), 'error', NULL, TRUE);
}
} }
} else { } else {
@ -677,17 +711,23 @@ class Config {
*/ */
public function getCommandList() { public function getCommandList() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 3, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 3, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$config = $this->getConfigArray(false); $config = $this->getConfigArray(false);
masort($config['command'],'summary'); masort($config['command'],'summary');
if (isset($config['command']) && is_array($config['command'])) if (isset($config['command']) && is_array($config['command']))
{
return $config['command']; return $config['command'];
}
else else
{
return array(); return array();
} }
}
/** /**
* Simple ACL to see if commands can be run * Simple ACL to see if commands can be run
@ -696,7 +736,9 @@ class Config {
*/ */
public function isCommandAvailable($index='cmd') { public function isCommandAvailable($index='cmd') {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 3, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 3, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$a = func_get_args(); $a = func_get_args();
array_shift($a); array_shift($a);
@ -706,20 +748,30 @@ class Config {
$cmd = $this->getValue('commands',$index); $cmd = $this->getValue('commands',$index);
if (! is_string($a) || ! isset($cmd[$a])) if (! is_string($a) || ! isset($cmd[$a]))
return false; {
return FALSE;
}
else else
{
return $cmd[$a]; return $cmd[$a];
} }
}
public function configDefinition($key,$index,$config) { public function configDefinition($key,$index,$config) {
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 3, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 3, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
if (! is_array($config) || ! array_key_exists('desc',$config) || ! array_key_exists('default',$config)) if (! is_array($config) || ! array_key_exists('desc',$config) || ! array_key_exists('default',$config))
{
return; return;
}
if (isset($this->default->$key)) if (isset($this->default->$key))
{
$definition = $this->default->$key; $definition = $this->default->$key;
}
$definition[$index] = $config; $definition[$index] = $config;
$this->default->$key = $definition; $this->default->$key = $definition;
@ -730,7 +782,9 @@ class Config {
*/ */
private function getFriendlyAttrs() { private function getFriendlyAttrs() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 3, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 3, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
return array_change_key_case($this->getValue('appearance','friendly_attrs')); return array_change_key_case($this->getValue('appearance','friendly_attrs'));
} }
@ -744,23 +798,36 @@ class Config {
*/ */
public function getFriendlyName($attr) { public function getFriendlyName($attr) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 3, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 3, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
static $friendly_attrs; static $friendly_attrs;
if (! $friendly_attrs) if (! $friendly_attrs)
{
$friendly_attrs = $this->getFriendlyAttrs(); $friendly_attrs = $this->getFriendlyAttrs();
}
if (! is_object($attr)) if (! is_object($attr))
{
if (isset($friendly_attrs[$attr])) if (isset($friendly_attrs[$attr]))
{
return $friendly_attrs[$attr]; return $friendly_attrs[$attr];
else } else
{
return $attr; return $attr;
}
}
if (isset($friendly_attrs[$attr->getName()])) if (isset($friendly_attrs[$attr->getName()]))
{
return $friendly_attrs[$attr->getName()]; return $friendly_attrs[$attr->getName()];
}
else else
return $attr->getName(false); {
return $attr->getName(FALSE);
}
} }
/** /**
@ -772,7 +839,9 @@ class Config {
*/ */
public function haveFriendlyName($attr) { public function haveFriendlyName($attr) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 3, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 3, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
return $attr->getName(false) != $this->getFriendlyName($attr); return $attr->getName(false) != $this->getFriendlyName($attr);
} }
@ -785,13 +854,19 @@ class Config {
*/ */
public function getFriendlyHTML($attr) { public function getFriendlyHTML($attr) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 3, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 3, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
if ($this->haveFriendlyName($attr)) if ($this->haveFriendlyName($attr))
{
return sprintf('<acronym title="%s %s">%s</acronym>', return sprintf('<acronym title="%s %s">%s</acronym>',
_('Alias for'),$attr->getName(false),$this->getFriendlyName($attr)); _('Alias for'), $attr->getName(FALSE), $this->getFriendlyName($attr));
}
else else
return $attr->getName(false); {
return $attr->getName(FALSE);
}
} }
public function setServers($servers) { public function setServers($servers) {
@ -808,7 +883,9 @@ class Config {
*/ */
public function getServerList($visible=true) { public function getServerList($visible=true) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 3, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 3, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
return $this->servers->getServerList($visible); return $this->servers->getServerList($visible);
} }

View File

@ -138,8 +138,14 @@ private $sbox = array(array(array(14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12
* @return int * @return int
*/ */
private function x($i) { private function x($i) {
if ($i < 0) return 4294967296 - $i; if ($i < 0)
else return $i; {
return 4294967296 - $i;
}
else
{
return $i;
}
} }
/** /**
@ -205,7 +211,10 @@ private $sbox = array(array(array(14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12
$d = $this->lshift($this->sc[$i], $d); $d = $this->lshift($this->sc[$i], $d);
$cd = $c; $cd = $c;
for ($k = 0; $k < sizeof($d); $k++) $cd[] = $d[$k]; for ($k = 0; $k < sizeof($d); $k++)
{
$cd[] = $d[$k];
}
$ki[$i] = $this->permute($cd, $this->perm2, 48); $ki[$i] = $this->permute($cd, $this->perm2, 48);
} }
@ -220,8 +229,14 @@ private $sbox = array(array(array(14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12
for ($i = 0; $i < 16; $i++) { for ($i = 0; $i < 16; $i++) {
$er = $this->permute($r, $this->perm4, 48); $er = $this->permute($r, $this->perm4, 48);
if ($forw) $erk = $this->mxor($er, $ki[$i]); if ($forw)
else $erk = $this->mxor($er, $ki[15 - $i]); {
$erk = $this->mxor($er, $ki[$i]);
}
else
{
$erk = $this->mxor($er, $ki[15 - $i]);
}
for ($j = 0; $j < 8; $j++) { for ($j = 0; $j < 8; $j++) {
for ($k = 0; $k < 6; $k++) { for ($k = 0; $k < 6; $k++) {
@ -246,11 +261,20 @@ private $sbox = array(array(array(14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12
} }
$pcb = $this->permute($cb, $this->perm5, 32); $pcb = $this->permute($cb, $this->perm5, 32);
$r2 = $this->mxor($l, $pcb); $r2 = $this->mxor($l, $pcb);
for ($k = 0; $k < 32; $k++) $l[$k] = $r[$k]; for ($k = 0; $k < 32; $k++)
for ($k = 0; $k < 32; $k++) $r[$k] = $r2[$k]; {
$l[$k] = $r[$k];
}
for ($k = 0; $k < 32; $k++)
{
$r[$k] = $r2[$k];
}
} }
$rl = $r; $rl = $r;
for ($i = 0; $i < sizeof($l); $i++) $rl[] = $l[$i]; for ($i = 0; $i < sizeof($l); $i++)
{
$rl[] = $l[$i];
}
return $this->permute($rl, $this->perm6, 64); return $this->permute($rl, $this->perm6, 64);
} }
@ -270,7 +294,7 @@ private $sbox = array(array(array(14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12
$key[6] = (($str[5]&0x3F)<<1) | $this->unsigned_shift_r($str[6], 7); $key[6] = (($str[5]&0x3F)<<1) | $this->unsigned_shift_r($str[6], 7);
$key[7] = $str[6]&0x7F; $key[7] = $str[6]&0x7F;
for ($i = 0; $i < 8; $i++) { for ($i = 0; $i < 8; $i++) {
$key[$i] = ($key[$i] << 1); $key[$i] <<= 1;
} }
return $key; return $key;
} }
@ -352,13 +376,20 @@ private $sbox = array(array(array(14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12
*/ */
public function nthash($password = "") { public function nthash($password = "") {
if (function_exists('mhash')) if (function_exists('mhash'))
{
if (defined('MHASH_MD4')) if (defined('MHASH_MD4'))
{
return strtoupper(bin2hex(mhash(MHASH_MD4, iconv('UTF-8', 'UTF-16LE', $password)))); return strtoupper(bin2hex(mhash(MHASH_MD4, iconv('UTF-8', 'UTF-16LE', $password))));
else } else
{
return strtoupper(hash('md4', iconv("UTF-8", "UTF-16LE", $password))); return strtoupper(hash('md4', iconv("UTF-8", "UTF-16LE", $password)));
}
}
else else
{
error(_('Your PHP install does not have the mhash() function. Cannot do hashes.'), 'error', 'index.php'); error(_('Your PHP install does not have the mhash() function. Cannot do hashes.'), 'error', 'index.php');
} }
}
/** /**
* Unsigned shift operation for 32bit values. * Unsigned shift operation for 32bit values.
@ -371,13 +402,13 @@ private $sbox = array(array(array(14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12
private function unsigned_shift_r($a, $b) { private function unsigned_shift_r($a, $b) {
$z = 0x80000000; $z = 0x80000000;
if ($z & $a) { if ($z & $a) {
$a = ($a >> 1); $a >>= 1;
$a &= (~$z); $a &= (~$z);
$a |= 0x40000000; $a |= 0x40000000;
$a = ($a >> ($b - 1)); $a >>= ($b - 1);
} }
else { else {
$a = ($a >> $b); $a >>= $b;
} }
return $a; return $a;
} }

View File

@ -62,9 +62,13 @@ abstract class DS {
*/ */
public function setDefaults($defaults) { public function setDefaults($defaults) {
foreach ($defaults as $key => $details) foreach ($defaults as $key => $details)
{
foreach ($details as $setting => $value) foreach ($details as $setting => $value)
{
$this->default->{$key}[$setting] = $value; $this->default->{$key}[$setting] = $value;
} }
}
}
public function isDefaultKey($key) { public function isDefaultKey($key) {
return isset($this->default->$key); return isset($this->default->$key);
@ -83,19 +87,29 @@ abstract class DS {
*/ */
public function getValue($key,$setting,$fatal=true) { public function getValue($key,$setting,$fatal=true) {
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 1, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 1, __FILE__, __LINE__, __METHOD__, $fargs);
}
if (isset($this->custom->{$key}[$setting])) if (isset($this->custom->{$key}[$setting]))
{
return $this->custom->{$key}[$setting]; return $this->custom->{$key}[$setting];
}
elseif (isset($this->default->{$key}[$setting]) && array_key_exists('default',$this->default->{$key}[$setting])) elseif (isset($this->default->{$key}[$setting]) && array_key_exists('default',$this->default->{$key}[$setting]))
{
return $this->default->{$key}[$setting]['default']; return $this->default->{$key}[$setting]['default'];
}
elseif ($fatal) elseif ($fatal)
{
debug_dump_backtrace("Error trying to get a non-existant value ($key,$setting)", 1); debug_dump_backtrace("Error trying to get a non-existant value ($key,$setting)", 1);
}
else else
return null; {
return NULL;
}
} }
/** /**
@ -106,11 +120,13 @@ abstract class DS {
*/ */
public function setValue($key,$setting,$value) { public function setValue($key,$setting,$value) {
if (isset($this->custom->{$key}[$setting])) if (isset($this->custom->{$key}[$setting]))
{
system_message(array( system_message(array(
'title' => _('Configuration setting already defined.'), 'title' => _('Configuration setting already defined.'),
'body' => sprintf('A call has been made to reset a configuration value (%s,%s,%s)', 'body' => sprintf('A call has been made to reset a configuration value (%s,%s,%s)',
$key, $setting, $value), $key, $setting, $value),
'type' => 'info')); 'type' => 'info'));
}
$this->custom->{$key}[$setting] = $value; $this->custom->{$key}[$setting] = $value;
} }
@ -122,9 +138,15 @@ abstract class DS {
$result = array(); $result = array();
foreach ($this->default as $option => $details) foreach ($this->default as $option => $details)
{
foreach ($details as $param => $values) foreach ($details as $param => $values)
{
if (isset($values['untested']) && $values['untested']) if (isset($values['untested']) && $values['untested'])
{
array_push($result, sprintf('%s.%s', $option, $param)); array_push($result, sprintf('%s.%s', $option, $param));
}
}
}
return $result; return $result;
} }
@ -134,7 +156,9 @@ abstract class DS {
*/ */
public function getName() { public function getName() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
return $this->getValue('server','name'); return $this->getValue('server','name');
} }
@ -147,7 +171,9 @@ abstract class DS {
*/ */
public function getAuthType() { public function getAuthType() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
switch ($this->getValue('login','auth_type')) { switch ($this->getValue('login','auth_type')) {
case 'cookie': case 'cookie':
@ -173,45 +199,68 @@ abstract class DS {
*/ */
public function getLogin($method=null) { public function getLogin($method=null) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$method = $this->getMethod($method); $method = $this->getMethod($method);
# For anonymous binds # For anonymous binds
if ($method == 'anon') if ($method == 'anon')
{
if (isset($_SESSION['USER'][$this->index][$method]['name'])) if (isset($_SESSION['USER'][$this->index][$method]['name']))
{
return ''; return '';
else } else
return null; {
return NULL;
}
}
switch ($this->getAuthType()) { switch ($this->getAuthType()) {
case 'cookie': case 'cookie':
if (! isset($_COOKIE[$method.'-USER'])) if (! isset($_COOKIE[$method.'-USER']))
# If our bind_id is set, we'll pass that back for logins. # If our bind_id is set, we'll pass that back for logins.
return (! is_null($this->getValue('login','bind_id')) && $method == 'login') ? $this->getValue('login','bind_id') : null; {
return ( ! is_null($this->getValue('login', 'bind_id')) && $method == 'login') ? $this->getValue('login', 'bind_id') : NULL;
}
else else
{
return blowfish_decrypt($_COOKIE[$method . '-USER']); return blowfish_decrypt($_COOKIE[$method . '-USER']);
}
case 'config': case 'config':
if (! isset($_SESSION['USER'][$this->index][$method]['name'])) if (! isset($_SESSION['USER'][$this->index][$method]['name']))
{
return $this->getValue('login', 'bind_id'); return $this->getValue('login', 'bind_id');
}
else else
{
return blowfish_decrypt($_SESSION['USER'][$this->index][$method]['name']); return blowfish_decrypt($_SESSION['USER'][$this->index][$method]['name']);
}
case 'proxy': case 'proxy':
if (! isset($_SESSION['USER'][$this->index][$method]['proxy'])) if (! isset($_SESSION['USER'][$this->index][$method]['proxy']))
{
return $this->getValue('login', 'bind_id'); return $this->getValue('login', 'bind_id');
}
else else
{
return blowfish_decrypt($_SESSION['USER'][$this->index][$method]['proxy']); return blowfish_decrypt($_SESSION['USER'][$this->index][$method]['proxy']);
}
case 'http': case 'http':
case 'session': case 'session':
case 'sasl': case 'sasl':
if (! isset($_SESSION['USER'][$this->index][$method]['name'])) if (! isset($_SESSION['USER'][$this->index][$method]['name']))
# If our bind_id is set, we'll pass that back for logins. # If our bind_id is set, we'll pass that back for logins.
return (! is_null($this->getValue('login','bind_id')) && $method == 'login') ? $this->getValue('login','bind_id') : null; {
return ( ! is_null($this->getValue('login', 'bind_id')) && $method == 'login') ? $this->getValue('login', 'bind_id') : NULL;
}
else else
{
return blowfish_decrypt($_SESSION['USER'][$this->index][$method]['name']); return blowfish_decrypt($_SESSION['USER'][$this->index][$method]['name']);
}
default: default:
die(sprintf('Error: %s hasnt been configured for auth_type %s',__METHOD__,$this->getAuthType())); die(sprintf('Error: %s hasnt been configured for auth_type %s',__METHOD__,$this->getAuthType()));
@ -227,7 +276,9 @@ abstract class DS {
*/ */
protected function setLogin($user,$pass,$method=null) { protected function setLogin($user,$pass,$method=null) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$method = $this->getMethod($method); $method = $this->getMethod($method);
@ -242,7 +293,9 @@ abstract class DS {
case 'proxy': case 'proxy':
if (isset($_SESSION['USER'][$this->index][$method]['proxy'])) if (isset($_SESSION['USER'][$this->index][$method]['proxy']))
{
unset($_SESSION['USER'][$this->index][$method]['proxy']); unset($_SESSION['USER'][$this->index][$method]['proxy']);
}
case 'http': case 'http':
case 'session': case 'session':
@ -264,40 +317,59 @@ abstract class DS {
*/ */
protected function getPassword($method=null) { protected function getPassword($method=null) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$method = $this->getMethod($method); $method = $this->getMethod($method);
# For anonymous binds # For anonymous binds
if ($method == 'anon') if ($method == 'anon')
{
if (isset($_SESSION['USER'][$this->index][$method]['name'])) if (isset($_SESSION['USER'][$this->index][$method]['name']))
{
return ''; return '';
else } else
return null; {
return NULL;
}
}
switch ($this->getAuthType()) { switch ($this->getAuthType()) {
case 'cookie': case 'cookie':
if (! isset($_COOKIE[$method.'-PASS'])) if (! isset($_COOKIE[$method.'-PASS']))
# If our bind_id is set, we'll pass that back for logins. # If our bind_id is set, we'll pass that back for logins.
return (! is_null($this->getValue('login','bind_pass')) && $method == 'login') ? $this->getValue('login','bind_pass') : null; {
return ( ! is_null($this->getValue('login', 'bind_pass')) && $method == 'login') ? $this->getValue('login', 'bind_pass') : NULL;
}
else else
{
return blowfish_decrypt($_COOKIE[$method . '-PASS']); return blowfish_decrypt($_COOKIE[$method . '-PASS']);
}
case 'config': case 'config':
case 'proxy': case 'proxy':
if (! isset($_SESSION['USER'][$this->index][$method]['pass'])) if (! isset($_SESSION['USER'][$this->index][$method]['pass']))
{
return $this->getValue('login', 'bind_pass'); return $this->getValue('login', 'bind_pass');
}
else else
{
return blowfish_decrypt($_SESSION['USER'][$this->index][$method]['pass']); return blowfish_decrypt($_SESSION['USER'][$this->index][$method]['pass']);
}
case 'http': case 'http':
case 'session': case 'session':
case 'sasl': case 'sasl':
if (! isset($_SESSION['USER'][$this->index][$method]['pass'])) if (! isset($_SESSION['USER'][$this->index][$method]['pass']))
# If our bind_pass is set, we'll pass that back for logins. # If our bind_pass is set, we'll pass that back for logins.
return (! is_null($this->getValue('login','bind_pass')) && $method == 'login') ? $this->getValue('login','bind_pass') : null; {
return ( ! is_null($this->getValue('login', 'bind_pass')) && $method == 'login') ? $this->getValue('login', 'bind_pass') : NULL;
}
else else
{
return blowfish_decrypt($_SESSION['USER'][$this->index][$method]['pass']); return blowfish_decrypt($_SESSION['USER'][$this->index][$method]['pass']);
}
default: default:
die(sprintf('Error: %s hasnt been configured for auth_type %s',__METHOD__,$this->getAuthType())); die(sprintf('Error: %s hasnt been configured for auth_type %s',__METHOD__,$this->getAuthType()));
@ -311,14 +383,18 @@ abstract class DS {
*/ */
public function isLoggedIn($method=null) { public function isLoggedIn($method=null) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
static $CACHE = array(); static $CACHE = array();
$method = $this->getMethod($method); $method = $this->getMethod($method);
if (isset($CACHE[$this->index][$method]) && ! is_null($CACHE[$this->index][$method])) if (isset($CACHE[$this->index][$method]) && ! is_null($CACHE[$this->index][$method]))
{
return $CACHE[$this->index][$method]; return $CACHE[$this->index][$method];
}
$CACHE[$this->index][$method] = null; $CACHE[$this->index][$method] = null;
@ -326,10 +402,12 @@ abstract class DS {
switch ($this->getAuthType()) { switch ($this->getAuthType()) {
case 'config': case 'config':
if (! $CACHE[$this->index][$method] = $this->login($this->getLogin($method),$this->getPassword($method),$method)) if (! $CACHE[$this->index][$method] = $this->login($this->getLogin($method),$this->getPassword($method),$method))
{
system_message(array( system_message(array(
'title' => _('Unable to login.'), 'title' => _('Unable to login.'),
'body' => _('Your configuration file has authentication set to CONFIG based authentication, however, the userid/password failed to login'), 'body' => _('Your configuration file has authentication set to CONFIG based authentication, however, the userid/password failed to login'),
'type' => 'error')); 'type' => 'error'));
}
break; break;
@ -345,9 +423,13 @@ abstract class DS {
header(sprintf('WWW-Authenticate: Basic realm="%s %s"',app_name(),_('login'))); header(sprintf('WWW-Authenticate: Basic realm="%s %s"',app_name(),_('login')));
if ($_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.0') if ($_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.0')
header('HTTP/1.0 401 Unauthorized'); // http 1.0 method {
header('HTTP/1.0 401 Unauthorized');
} // http 1.0 method
else else
header('Status: 401 Unauthorized'); // http 1.1 method {
header('Status: 401 Unauthorized');
} // http 1.1 method
# If we still dont have login details... # If we still dont have login details...
if (! isset($_SERVER['PHP_AUTH_USER'])) { if (! isset($_SERVER['PHP_AUTH_USER'])) {
@ -370,7 +452,9 @@ abstract class DS {
$CACHE[$this->index][$method] = false; $CACHE[$this->index][$method] = false;
} else } else
$CACHE[$this->index][$method] = true; {
$CACHE[$this->index][$method] = TRUE;
}
} }
break; break;
@ -383,9 +467,13 @@ abstract class DS {
case 'sasl': case 'sasl':
# Propogate any given Kerberos credential cache location # Propogate any given Kerberos credential cache location
if (isset($_ENV['REDIRECT_KRB5CCNAME'])) if (isset($_ENV['REDIRECT_KRB5CCNAME']))
{
putenv(sprintf('KRB5CCNAME=%s', $_ENV['REDIRECT_KRB5CCNAME'])); putenv(sprintf('KRB5CCNAME=%s', $_ENV['REDIRECT_KRB5CCNAME']));
}
elseif (isset($_SERVER['KRB5CCNAME'])) elseif (isset($_SERVER['KRB5CCNAME']))
{
putenv(sprintf('KRB5CCNAME=%s', $_SERVER['KRB5CCNAME'])); putenv(sprintf('KRB5CCNAME=%s', $_SERVER['KRB5CCNAME']));
}
# Map the SASL auth ID to a DN # Map the SASL auth ID to a DN
$regex = $this->getValue('login', 'sasl_dn_regex'); $regex = $this->getValue('login', 'sasl_dn_regex');
@ -399,7 +487,9 @@ abstract class DS {
# Otherwise, use the user name as is # Otherwise, use the user name as is
# For GSSAPI Authentication + mod_auth_kerb and Basic Authentication # For GSSAPI Authentication + mod_auth_kerb and Basic Authentication
} else } else
{
$CACHE[$this->index][$method] = $this->login(isset($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'] : '', '', $method); $CACHE[$this->index][$method] = $this->login(isset($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'] : '', '', $method);
}
break; break;
@ -417,7 +507,9 @@ abstract class DS {
*/ */
public function logout($method=null) { public function logout($method=null) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$method = $this->getMethod($method); $method = $this->getMethod($method);
@ -436,7 +528,9 @@ abstract class DS {
case 'session': case 'session':
case 'sasl': case 'sasl':
if (isset($_SESSION['USER'][$this->index][$method])) if (isset($_SESSION['USER'][$this->index][$method]))
{
unset($_SESSION['USER'][$this->index][$method]); unset($_SESSION['USER'][$this->index][$method]);
}
return true; return true;
@ -450,24 +544,34 @@ abstract class DS {
*/ */
public function isVisible() { public function isVisible() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
return $this->getValue('server','visible'); return $this->getValue('server','visible');
} }
public function isReadOnly() { public function isReadOnly() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
if (! trim($this->getLogin(null)) && $_SESSION[APPCONFIG]->getValue('appearance','anonymous_bind_implies_read_only')) if (! trim($this->getLogin(null)) && $_SESSION[APPCONFIG]->getValue('appearance','anonymous_bind_implies_read_only'))
return true; {
return TRUE;
}
else else
{
return $this->getValue('server', 'read_only'); return $this->getValue('server', 'read_only');
} }
}
public function getIndex() { public function getIndex() {
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->index); debug_log('Entered (%%)', 17, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->index);
}
return $this->index; return $this->index;
} }
@ -483,22 +587,30 @@ abstract class DS {
*/ */
protected function getMethod($method=null) { protected function getMethod($method=null) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
static $CACHE = array(); static $CACHE = array();
# Immediately return if method is set. # Immediately return if method is set.
if (! is_null($method)) if (! is_null($method))
{
return $method; return $method;
}
# If we have been here already, then return our result # If we have been here already, then return our result
if (isset($CACHE[$this->index]) && ! is_null($CACHE)) if (isset($CACHE[$this->index]) && ! is_null($CACHE))
{
return $CACHE[$this->index]; return $CACHE[$this->index];
}
$CACHE[$this->index] = 'anon'; $CACHE[$this->index] = 'anon';
if ($this->isLoggedIn('user')) if ($this->isLoggedIn('user'))
{
$CACHE[$this->index] = 'user'; $CACHE[$this->index] = 'user';
}
return $CACHE[$this->index]; return $CACHE[$this->index];
} }
@ -508,7 +620,9 @@ abstract class DS {
*/ */
public function isSessionValid() { public function isSessionValid() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',17,1,__FILE__,__LINE__,__METHOD__,$fargs,true); {
debug_log('Entered (%%)', 17, 1, __FILE__, __LINE__, __METHOD__, $fargs, TRUE);
}
return true; return true;
} }
@ -519,12 +633,18 @@ abstract class DS {
*/ */
public function inactivityTime() { public function inactivityTime() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
if ($this->isLoggedIn() && ! in_array($this->getAuthType(),array('config','http'))) if ($this->isLoggedIn() && ! in_array($this->getAuthType(),array('config','http')))
{
return time() + ($this->getValue('login', 'timeout') * 60); return time() + ($this->getValue('login', 'timeout') * 60);
}
else else
return null; {
return NULL;
}
} }
} }
@ -654,17 +774,25 @@ class Datastore {
*/ */
public function setValue($key,$setting,$value) { public function setValue($key,$setting,$value) {
if (! $this->objects[$this->index]->isDefaultKey($key)) if (! $this->objects[$this->index]->isDefaultKey($key))
error("ERROR: Setting a key [$key] that isnt predefined.",'error',true); {
error("ERROR: Setting a key [$key] that isnt predefined.", 'error', TRUE);
}
if (! $this->objects[$this->index]->isDefaultSetting($key,$setting)) if (! $this->objects[$this->index]->isDefaultSetting($key,$setting))
error("ERROR: Setting a index [$key,$setting] that isnt predefined.",'error',true); {
error("ERROR: Setting a index [$key,$setting] that isnt predefined.", 'error', TRUE);
}
# Test if its should be an array or not. # Test if its should be an array or not.
if (is_array($this->objects[$this->index]->getValue($key,$setting)) && ! is_array($value)) if (is_array($this->objects[$this->index]->getValue($key,$setting)) && ! is_array($value))
error("Error in configuration file, {$key}['$setting'] SHOULD be an array of values.",'error',true); {
error("Error in configuration file, {$key}['$setting'] SHOULD be an array of values.", 'error', TRUE);
}
if (! is_array($this->objects[$this->index]->getValue($key,$setting)) && is_array($value)) if (! is_array($this->objects[$this->index]->getValue($key,$setting)) && is_array($value))
error("Error in configuration file, {$key}['$setting'] should NOT be an array of values.",'error',true); {
error("Error in configuration file, {$key}['$setting'] should NOT be an array of values.", 'error', TRUE);
}
# Store the value in the object. # Store the value in the object.
$this->objects[$this->index]->setValue($key,$setting,$value); $this->objects[$this->index]->setValue($key,$setting,$value);
@ -678,12 +806,16 @@ class Datastore {
*/ */
public function getServerList($isVisible=true) { public function getServerList($isVisible=true) {
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
static $CACHE; static $CACHE;
if (isset($CACHE[$isVisible])) if (isset($CACHE[$isVisible]))
{
return $CACHE[$isVisible]; return $CACHE[$isVisible];
}
$CACHE[$isVisible] = array(); $CACHE[$isVisible] = array();
@ -695,8 +827,12 @@ class Datastore {
} }
foreach ($this->objects as $id => $server) foreach ($this->objects as $id => $server)
{
if ( ! $isVisible || ($isVisible && $server->getValue('server', 'visible'))) if ( ! $isVisible || ($isVisible && $server->getValue('server', 'visible')))
{
$CACHE[$isVisible][$id] = $server; $CACHE[$isVisible][$id] = $server;
}
}
masort($CACHE[$isVisible],'name'); masort($CACHE[$isVisible],'name');
@ -711,17 +847,25 @@ class Datastore {
*/ */
public function Instance($index=null) { public function Instance($index=null) {
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
# If no index defined, then pick the lowest one. # If no index defined, then pick the lowest one.
if (is_null($index) || ! trim($index) || ! is_numeric($index)) if (is_null($index) || ! trim($index) || ! is_numeric($index))
{
$index = min($this->getServerList())->getIndex(); $index = min($this->getServerList())->getIndex();
}
if (! isset($this->objects[$index])) if (! isset($this->objects[$index]))
{
debug_dump_backtrace(sprintf('Error: Datastore instance [%s] doesnt exist?', htmlspecialchars($index)), 1); debug_dump_backtrace(sprintf('Error: Datastore instance [%s] doesnt exist?', htmlspecialchars($index)), 1);
}
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) if (defined('DEBUG_ENABLED') && DEBUG_ENABLED)
{
debug_log('Returning instance of database (%s)', 3, 0, __FILE__, __LINE__, __METHOD__, $index); debug_log('Returning instance of database (%s)', 3, 0, __FILE__, __LINE__, __METHOD__, $index);
}
return $this->objects[$index]; return $this->objects[$index];
} }
@ -734,11 +878,17 @@ class Datastore {
*/ */
public function InstanceName($name=null) { public function InstanceName($name=null) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
foreach ($this->getServerList(false) as $index) foreach ($this->getServerList(false) as $index)
{
if ($this->objects[$index]->getName() == $name) if ($this->objects[$index]->getName() == $name)
{
return $this->objects[$index]; return $this->objects[$index];
}
}
# If we get here, then no object with the name exists. # If we get here, then no object with the name exists.
return null; return null;
@ -752,11 +902,17 @@ class Datastore {
*/ */
public function InstanceId($id=null) { public function InstanceId($id=null) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
foreach ($this->getServerList(false) as $index) foreach ($this->getServerList(false) as $index)
{
if ($this->objects[$index->getIndex()]->getValue('server', 'id') == $id) if ($this->objects[$index->getIndex()]->getValue('server', 'id') == $id)
{
return $this->objects[$index->getIndex()]; return $this->objects[$index->getIndex()];
}
}
# If we get here, then no object with the name exists. # If we get here, then no object with the name exists.
return null; return null;

File diff suppressed because it is too large Load Diff

View File

@ -163,13 +163,19 @@ class ldap_pla extends ldap {
*/ */
public function isShowCreateEnabled() { public function isShowCreateEnabled() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','create')) if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','create'))
return false; {
return FALSE;
}
else else
{
return $this->getValue('appearance', 'show_create'); return $this->getValue('appearance', 'show_create');
} }
}
/** /**
* Fetch whether the user has configured a certain server login to be non anonymous * Fetch whether the user has configured a certain server login to be non anonymous
@ -182,16 +188,24 @@ class ldap_pla extends ldap {
*/ */
public function isAnonBindAllowed() { public function isAnonBindAllowed() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
# If only_login_allowed_dns is set, then we cant have anonymous. # If only_login_allowed_dns is set, then we cant have anonymous.
if (count($this->getValue('login','allowed_dns')) > 0) if (count($this->getValue('login','allowed_dns')) > 0)
$return = false; {
$return = FALSE;
}
else else
{
$return = $this->getValue('login', 'anon_bind'); $return = $this->getValue('login', 'anon_bind');
}
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
{
debug_log('Returning (%s)', 17, 0, __FILE__, __LINE__, __METHOD__, $return); debug_log('Returning (%s)', 17, 0, __FILE__, __LINE__, __METHOD__, $return);
}
return $return; return $return;
} }
@ -208,7 +222,9 @@ class ldap_pla extends ldap {
*/ */
public function isBranchRenameEnabled() { public function isBranchRenameEnabled() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
return $this->getValue('server','branch_rename'); return $this->getValue('server','branch_rename');
} }
@ -232,22 +248,31 @@ class ldap_pla extends ldap {
*/ */
public function isMultiLineAttr($attr_name, $val=null) { public function isMultiLineAttr($attr_name, $val=null) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
# Set default return # Set default return
$return = false; $return = false;
# First, check the optional val param for a \n or a \r # First, check the optional val param for a \n or a \r
if (! is_null($val) && (strpos($val,"\n") || strpos($val,"\r"))) if (! is_null($val) && (strpos($val,"\n") || strpos($val,"\r")))
$return = true; {
$return = TRUE;
}
# Next, compare strictly by name first # Next, compare strictly by name first
else else
{
foreach ($_SESSION[APPCONFIG]->getValue('appearance', 'multi_line_attributes') as $multi_line_attr_name) foreach ($_SESSION[APPCONFIG]->getValue('appearance', 'multi_line_attributes') as $multi_line_attr_name)
if (strcasecmp($multi_line_attr_name,$attr_name) == 0) { {
$return = true; if (strcasecmp($multi_line_attr_name, $attr_name) == 0)
{
$return = TRUE;
break; break;
} }
}
}
# If unfound, compare by syntax OID # If unfound, compare by syntax OID
if (! $return) { if (! $return) {
@ -257,16 +282,23 @@ class ldap_pla extends ldap {
$syntax_oid = $sattr->getSyntaxOID(); $syntax_oid = $sattr->getSyntaxOID();
if ($syntax_oid) if ($syntax_oid)
{
foreach ($_SESSION[APPCONFIG]->getValue('appearance', 'multi_line_syntax_oids') as $multi_line_syntax_oid) foreach ($_SESSION[APPCONFIG]->getValue('appearance', 'multi_line_syntax_oids') as $multi_line_syntax_oid)
if ($multi_line_syntax_oid == $syntax_oid) { {
$return = true; if ($multi_line_syntax_oid == $syntax_oid)
{
$return = TRUE;
break; break;
} }
} }
} }
}
}
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
{
debug_log('Returning (%s)', 17, 0, __FILE__, __LINE__, __METHOD__, $return); debug_log('Returning (%s)', 17, 0, __FILE__, __LINE__, __METHOD__, $return);
}
return $return; return $return;
} }
@ -283,15 +315,23 @@ class ldap_pla extends ldap {
private function isAttrTest($attr,$attrs,$except_dn) { private function isAttrTest($attr,$attrs,$except_dn) {
$attr = trim($attr); $attr = trim($attr);
if (! trim($attr) || ! count($attrs)) if (! trim($attr) || ! count($attrs))
return false; {
return FALSE;
}
# Is the user excluded? # Is the user excluded?
if ($except_dn && $this->userIsMember($this->getLogin(),$except_dn)) if ($except_dn && $this->userIsMember($this->getLogin(),$except_dn))
return false; {
return FALSE;
}
foreach ($attrs as $attr_name) foreach ($attrs as $attr_name)
{
if (strcasecmp($attr, trim($attr_name)) == 0) if (strcasecmp($attr, trim($attr_name)) == 0)
return true; {
return TRUE;
}
}
return false; return false;
} }
@ -309,7 +349,9 @@ class ldap_pla extends ldap {
*/ */
public function isAttrReadOnly($attr) { public function isAttrReadOnly($attr) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$attrs = $_SESSION[APPCONFIG]->getValue('appearance','readonly_attrs'); $attrs = $_SESSION[APPCONFIG]->getValue('appearance','readonly_attrs');
$except_dn = $_SESSION[APPCONFIG]->getValue('appearance','readonly_attrs_exempt'); $except_dn = $_SESSION[APPCONFIG]->getValue('appearance','readonly_attrs_exempt');
@ -330,7 +372,9 @@ class ldap_pla extends ldap {
*/ */
public function isAttrHidden($attr) { public function isAttrHidden($attr) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$attrs = $_SESSION[APPCONFIG]->getValue('appearance','hide_attrs'); $attrs = $_SESSION[APPCONFIG]->getValue('appearance','hide_attrs');
$except_dn = $_SESSION[APPCONFIG]->getValue('appearance','hide_attrs_exempt'); $except_dn = $_SESSION[APPCONFIG]->getValue('appearance','hide_attrs_exempt');
@ -347,16 +391,22 @@ class ldap_pla extends ldap {
*/ */
public function add($dn,$entry_array,$method=null) { public function add($dn,$entry_array,$method=null) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
foreach ($entry_array as $attr => $val) foreach ($entry_array as $attr => $val)
{
$entry_array[$attr] = dn_unescape($val); $entry_array[$attr] = dn_unescape($val);
}
$result = false; $result = false;
# Check our unique attributes. # Check our unique attributes.
if (! $this->checkUniqueAttrs($dn,$entry_array)) if (! $this->checkUniqueAttrs($dn,$entry_array))
return false; {
return FALSE;
}
if (run_hook('pre_entry_create',array('server_id'=>$this->index,'method'=>$method,'dn'=>$dn,'attrs'=>$entry_array))) { if (run_hook('pre_entry_create',array('server_id'=>$this->index,'method'=>$method,'dn'=>$dn,'attrs'=>$entry_array))) {
$result = @ldap_add($this->connect($method),dn_escape($dn),$entry_array); $result = @ldap_add($this->connect($method),dn_escape($dn),$entry_array);
@ -367,7 +417,9 @@ class ldap_pla extends ldap {
# If we created the base, delete it, then add it back # If we created the base, delete it, then add it back
if (get_request('create_base')) if (get_request('create_base'))
{
$tree->delEntry($dn); $tree->delEntry($dn);
}
$tree->addEntry($dn); $tree->addEntry($dn);
@ -394,7 +446,9 @@ class ldap_pla extends ldap {
*/ */
public function delete($dn,$method=null) { public function delete($dn,$method=null) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$result = false; $result = false;
@ -426,7 +480,9 @@ class ldap_pla extends ldap {
*/ */
public function rename($dn,$new_rdn,$container,$deleteoldrdn,$method=null) { public function rename($dn,$new_rdn,$container,$deleteoldrdn,$method=null) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$result = false; $result = false;
@ -457,11 +513,15 @@ class ldap_pla extends ldap {
*/ */
public function modify($dn,$attrs,$method=null) { public function modify($dn,$attrs,$method=null) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
# Check our unique attributes. # Check our unique attributes.
if (! $this->checkUniqueAttrs($dn,$attrs)) if (! $this->checkUniqueAttrs($dn,$attrs))
return false; {
return FALSE;
}
$result = false; $result = false;
$summary = array(); $summary = array();
@ -481,7 +541,9 @@ class ldap_pla extends ldap {
'type'=>'warn')); 'type'=>'warn'));
} else } else
{
$summary['add'][$attr]['new'] = $values; $summary['add'][$attr]['new'] = $values;
}
# For modify attributes # For modify attributes
} elseif (count($values)) { } elseif (count($values)) {
@ -511,12 +573,16 @@ class ldap_pla extends ldap {
'type'=>'warn')); 'type'=>'warn'));
} else } else
{
$summary['delete'][$attr]['old'] = $current_attrs[$attr]; $summary['delete'][$attr]['old'] = $current_attrs[$attr];
} }
} }
}
if (! count($attrs)) if (! count($attrs))
return false; {
return FALSE;
}
if (run_hook('pre_entry_modify',array('server_id'=>$this->index,'method'=>$method,'dn'=>$dn,'attrs'=>$attrs))) { if (run_hook('pre_entry_modify',array('server_id'=>$this->index,'method'=>$method,'dn'=>$dn,'attrs'=>$attrs))) {
$result = @ldap_modify($this->connect($method),$dn,$attrs); $result = @ldap_modify($this->connect($method),$dn,$attrs);
@ -525,9 +591,13 @@ class ldap_pla extends ldap {
run_hook('post_entry_modify',array('server_id'=>$this->index,'method'=>$method,'dn'=>$dn,'attrs'=>$attrs)); run_hook('post_entry_modify',array('server_id'=>$this->index,'method'=>$method,'dn'=>$dn,'attrs'=>$attrs));
foreach (array('add','modify','delete') as $mode) foreach (array('add','modify','delete') as $mode)
{
if (isset($summary[$mode])) if (isset($summary[$mode]))
{
foreach ($summary[$mode] as $attr => $values) foreach ($summary[$mode] as $attr => $values)
switch ($mode) { {
switch ($mode)
{
case 'add': case 'add':
run_hook(sprintf('post_attr_%s', $mode), run_hook(sprintf('post_attr_%s', $mode),
array('server_id' => $this->index, 'method' => $method, 'dn' => $dn, 'attr' => $attr, 'newvalue' => $values['new'])); array('server_id' => $this->index, 'method' => $method, 'dn' => $dn, 'attr' => $attr, 'newvalue' => $values['new']));
@ -546,6 +616,9 @@ class ldap_pla extends ldap {
default: default:
debug_dump_backtrace(sprintf('Unkown mode %s', $mode), 1); debug_dump_backtrace(sprintf('Unkown mode %s', $mode), 1);
} }
}
}
}
} else { } else {
system_message(array( system_message(array(
'title'=>_('Could not perform ldap_modify operation.'), 'title'=>_('Could not perform ldap_modify operation.'),
@ -570,13 +643,19 @@ class ldap_pla extends ldap {
*/ */
public function isAttrUnique($attr) { public function isAttrUnique($attr) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
# Should this attribute value be unique # Should this attribute value be unique
if (in_array_ignore_case($attr,$this->getValue('unique','attrs'))) if (in_array_ignore_case($attr,$this->getValue('unique','attrs')))
return true; {
return TRUE;
}
else else
return false; {
return FALSE;
}
} }
/** /**
@ -591,11 +670,15 @@ class ldap_pla extends ldap {
*/ */
public function checkUniqueAttrs($dn,$attrs) { public function checkUniqueAttrs($dn,$attrs) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
# If none of the attributes are defined unique, we'll return immediately; # If none of the attributes are defined unique, we'll return immediately;
if (! $checkattrs = array_intersect(arrayLower($this->getValue('unique','attrs')),array_keys(array_change_key_case($attrs)))) if (! $checkattrs = array_intersect(arrayLower($this->getValue('unique','attrs')),array_keys(array_change_key_case($attrs))))
return true; {
return TRUE;
}
# Check see and use our alternate uid_dn and password if we have it. # Check see and use our alternate uid_dn and password if we have it.
if (! $this->login($this->getValue('unique','dn'),$this->getValue('unique','pass'),'unique')) { if (! $this->login($this->getValue('unique','dn'),$this->getValue('unique','pass'),'unique')) {
@ -613,9 +696,15 @@ class ldap_pla extends ldap {
# Build our search filter to double check each attribute. # Build our search filter to double check each attribute.
$query['filter'] = '(|'; $query['filter'] = '(|';
foreach ($checkattrs as $attr) foreach ($checkattrs as $attr)
{
foreach ($attrs[$attr] as $val) foreach ($attrs[$attr] as $val)
{
if ($val) if ($val)
{
$query['filter'] .= sprintf('(%s=%s)', $attr, $val); $query['filter'] .= sprintf('(%s=%s)', $attr, $val);
}
}
}
$query['filter'] .= ')'; $query['filter'] .= ')';
$query['attrs'] = $checkattrs; $query['attrs'] = $checkattrs;
@ -629,20 +718,25 @@ class ldap_pla extends ldap {
# If we have a match. # If we have a match.
if (count($results)) if (count($results))
{
foreach ($results as $values) foreach ($results as $values)
# If one of the attributes is owned to somebody else, then we may as well die here. # If one of the attributes is owned to somebody else, then we may as well die here.
if ($values['dn'] != $dn) { {
if ($values['dn'] != $dn)
{
$href = sprintf('cmd.php?cmd=query_engine&server_id=%s&filter=%s&scope=sub&query=none&format=list&search=true', $this->index, $query['filter']); $href = sprintf('cmd.php?cmd=query_engine&server_id=%s&filter=%s&scope=sub&query=none&format=list&search=true', $this->index, $query['filter']);
system_message(array( system_message(array(
'title' => _('Attribute value would not be unique'), 'title' => _('Attribute value would not be unique'),
'body'=>sprintf('%s (<b><a href="%s">%s</a></b>)', 'body' => sprintf('%s (<b><a href=' % s'>%s</a></b>)',
_('This update has been or will be cancelled, it would result in an attribute value not being unique. You might like to search the LDAP server for the offending entry.'), _('This update has been or will be cancelled, it would result in an attribute value not being unique. You might like to search the LDAP server for the offending entry.'),
htmlspecialchars($href), htmlspecialchars($href),
_('Search')), _('Search')),
'type'=>'warn')); 'type'=>'warn'));
return false; return FALSE;
}
}
} }
} }
@ -655,11 +749,15 @@ class ldap_pla extends ldap {
*/ */
public function isSessionValid() { public function isSessionValid() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
# If inactiveTime() returns a value, we need to check that it has not expired. # If inactiveTime() returns a value, we need to check that it has not expired.
if (is_null($this->inactivityTime()) || ! $this->isLoggedIn()) if (is_null($this->inactivityTime()) || ! $this->isLoggedIn())
return true; {
return TRUE;
}
# If session has expired # If session has expired
if ((isset($_SESSION['ACTIVITY'][$this->getIndex()])) && ($_SESSION['ACTIVITY'][$this->getIndex()] < time())) { if ((isset($_SESSION['ACTIVITY'][$this->getIndex()])) && ($_SESSION['ACTIVITY'][$this->getIndex()] < time())) {

View File

@ -133,20 +133,30 @@ abstract class Export {
$attrs = preg_replace('/\s+/','',$attrs); $attrs = preg_replace('/\s+/','',$attrs);
if ($attrs) if ($attrs)
{
$query['attrs'] = explode(',', $attrs); $query['attrs'] = explode(',', $attrs);
}
else else
{
$query['attrs'] = array('*'); $query['attrs'] = array('*');
}
if (get_request('sys_attr')) { if (get_request('sys_attr')) {
if (! in_array('*',$query['attrs'])) if (! in_array('*',$query['attrs']))
{
array_push($query['attrs'], '*'); array_push($query['attrs'], '*');
}
array_push($query['attrs'],'+'); array_push($query['attrs'],'+');
} }
if (! $base) if (! $base)
{
$bases = $server->getBaseDN(); $bases = $server->getBaseDN();
}
else else
{
$bases = array($base); $bases = array($base);
}
foreach ($bases as $base) { foreach ($bases as $base) {
$query['base'] = $base; $query['base'] = $base;
@ -160,10 +170,12 @@ abstract class Export {
# If no result, there is a something wrong # If no result, there is a something wrong
if (! $this->results[$base] && $server->getErrorNum(null)) if (! $this->results[$base] && $server->getErrorNum(null))
{
system_message(array( system_message(array(
'title' => _('Encountered an error while performing search.'), 'title' => _('Encountered an error while performing search.'),
'body'=>ldap_error_msg($server->getErrorMessage(null),$server->getErrorNum(null)), 'body' => ldap_error_msg($server->getErrorMessage(NULL), $server->getErrorNum(NULL)),
'type' => 'error')); 'type' => 'error'));
}
$this->items += count($this->results[$base]); $this->items += count($this->results[$base]);
} }
@ -188,7 +200,9 @@ abstract class Export {
} }
if (get_request('compress','REQUEST') == 'on') if (get_request('compress','REQUEST') == 'on')
$this->compress = true; {
$this->compress = TRUE;
}
} }
public function isCompressed() { public function isCompressed() {
@ -223,8 +237,12 @@ abstract class Export {
*/ */
protected function isSafeAscii($str) { protected function isSafeAscii($str) {
for ($i=0;$i<strlen($str);$i++) for ($i=0;$i<strlen($str);$i++)
{
if (ord($str{$i}) < 32 || ord($str{$i}) > 127) if (ord($str{$i}) < 32 || ord($str{$i}) > 127)
return false; {
return FALSE;
}
}
return true; return true;
} }
@ -242,7 +260,7 @@ class ExportCSV extends Export {
private $multivalue_separator = ' | '; private $multivalue_separator = ' | ';
private $escapeCode = '"'; private $escapeCode = '"';
static public function getType() { public static function getType() {
return array('type'=>'CSV','description' => 'CSV (Spreadsheet)','extension'=>'csv'); return array('type'=>'CSV','description' => 'CSV (Spreadsheet)','extension'=>'csv');
} }
@ -259,8 +277,12 @@ class ExportCSV extends Export {
unset($dndetails['dn']); unset($dndetails['dn']);
foreach (array_keys($dndetails) as $key) foreach (array_keys($dndetails) as $key)
{
if ( ! in_array($key, $headers)) if ( ! in_array($key, $headers))
{
array_push($headers, $key); array_push($headers, $key);
}
}
} }
} }
@ -273,8 +295,10 @@ class ExportCSV extends Export {
$output .= sprintf('%s%s%s',$this->qualifier,$headers[$i],$this->qualifier); $output .= sprintf('%s%s%s',$this->qualifier,$headers[$i],$this->qualifier);
if ($i < $num_headers-1) if ($i < $num_headers-1)
{
$output .= $this->separator; $output .= $this->separator;
} }
}
# Drop out our DN header. # Drop out our DN header.
array_shift($headers); array_shift($headers);
@ -297,37 +321,53 @@ class ExportCSV extends Export {
$binary_attribute = $server->isAttrBinary($attr) ? 1 : 0; $binary_attribute = $server->isAttrBinary($attr) ? 1 : 0;
if (! is_array($entry[$attr])) if (! is_array($entry[$attr]))
{
$attr_values = array($entry[$attr]); $attr_values = array($entry[$attr]);
}
else else
{
$attr_values = $entry[$attr]; $attr_values = $entry[$attr];
}
$num_attr_values = count($attr_values); $num_attr_values = count($attr_values);
for ($i=0; $i<$num_attr_values; $i++) { for ($i=0; $i<$num_attr_values; $i++) {
if ($binary_attribute) if ($binary_attribute)
{
$output .= base64_encode($attr_values[$i]); $output .= base64_encode($attr_values[$i]);
}
else else
{
$output .= $this->LdapEscape($attr_values[$i]); $output .= $this->LdapEscape($attr_values[$i]);
}
if ($i < $num_attr_values-1) if ($i < $num_attr_values-1)
{
$output .= $this->multivalue_separator; $output .= $this->multivalue_separator;
} }
} }
}
$output .= $this->qualifier; $output .= $this->qualifier;
if ($j < $num_headers-1) if ($j < $num_headers-1)
{
$output .= $this->separator; $output .= $this->separator;
} }
}
$output .= $this->br; $output .= $this->br;
} }
if ($this->compress) if ($this->compress)
{
return gzencode($output); return gzencode($output);
}
else else
{
return $output; return $output;
} }
}
/** /**
* Function to escape data, where the qualifier happens to also * Function to escape data, where the qualifier happens to also
@ -347,7 +387,7 @@ class ExportCSV extends Export {
* @subpackage Export * @subpackage Export
*/ */
class ExportDSML extends Export { class ExportDSML extends Export {
static public function getType() { public static function getType() {
return array('type'=>'DSML','description' => _('DSML V.1 Export'),'extension'=>'xml'); return array('type'=>'DSML','description' => _('DSML V.1 Export'),'extension'=>'xml');
} }
@ -394,12 +434,16 @@ class ExportDSML extends Export {
# Display the objectClass attributes first # Display the objectClass attributes first
if (isset($dndetails['objectClass'])) { if (isset($dndetails['objectClass'])) {
if (! is_array($dndetails['objectClass'])) if (! is_array($dndetails['objectClass']))
{
$dndetails['objectClass'] = array($dndetails['objectClass']); $dndetails['objectClass'] = array($dndetails['objectClass']);
}
$output .= sprintf('%s<objectClass>%s',$indent['att'],$this->br); $output .= sprintf('%s<objectClass>%s',$indent['att'],$this->br);
foreach ($dndetails['objectClass'] as $ocValue) foreach ($dndetails['objectClass'] as $ocValue)
{
$output .= sprintf('%s<oc-value>%s</oc-value>%s', $indent['val'], $ocValue, $this->br); $output .= sprintf('%s<oc-value>%s</oc-value>%s', $indent['val'], $ocValue, $this->br);
}
$output .= sprintf('%s</objectClass>%s',$indent['att'],$this->br); $output .= sprintf('%s</objectClass>%s',$indent['att'],$this->br);
unset($dndetails['objectClass']); unset($dndetails['objectClass']);
@ -408,7 +452,9 @@ class ExportDSML extends Export {
# Display the attributes # Display the attributes
foreach ($dndetails as $key => $attr) { foreach ($dndetails as $key => $attr) {
if (! is_array($attr)) if (! is_array($attr))
{
$attr = array($attr); $attr = array($attr);
}
$output .= sprintf('%s<attr name="%s">%s',$indent['att'],$key,$this->br); $output .= sprintf('%s<attr name="%s">%s',$indent['att'],$key,$this->br);
@ -416,8 +462,10 @@ class ExportDSML extends Export {
$binary_mode = $server->isAttrBinary($key) ? 1 : 0; $binary_mode = $server->isAttrBinary($key) ? 1 : 0;
foreach ($attr as $value) foreach ($attr as $value)
{
$output .= sprintf('%s<value>%s</value>%s', $output .= sprintf('%s<value>%s</value>%s',
$indent['val'], ($binary_mode ? base64_encode($value) : htmlspecialchars($value)), $this->br); $indent['val'], ($binary_mode ? base64_encode($value) : htmlspecialchars($value)), $this->br);
}
$output .= sprintf('%s</attr>%s',$indent['att'],$this->br); $output .= sprintf('%s</attr>%s',$indent['att'],$this->br);
} }
@ -430,11 +478,15 @@ class ExportDSML extends Export {
$output .= sprintf('</dsml>%s',$this->br); $output .= sprintf('</dsml>%s',$this->br);
if ($this->compress) if ($this->compress)
{
return gzencode($output); return gzencode($output);
}
else else
{
return $output; return $output;
} }
} }
}
/** /**
* Export from LDAP using an LDIF format * Export from LDAP using an LDIF format
@ -446,7 +498,7 @@ class ExportLDIF extends Export {
# The maximum length of the ldif line # The maximum length of the ldif line
private $line_length = 76; private $line_length = 76;
static public function getType() { public static function getType() {
return array('type'=>'LDIF','description' => _('LDIF Export'),'extension'=>'ldif'); return array('type'=>'LDIF','description' => _('LDIF Export'),'extension'=>'ldif');
} }
@ -481,37 +533,54 @@ class ExportLDIF extends Export {
$title_string = sprintf('# %s %s: %s%s',_('Entry'),$counter,$dn,$this->br); $title_string = sprintf('# %s %s: %s%s',_('Entry'),$counter,$dn,$this->br);
if (strlen($title_string) > $this->line_length-3) if (strlen($title_string) > $this->line_length-3)
{
$title_string = substr($title_string, 0, $this->line_length - 3) . '...' . $this->br; $title_string = substr($title_string, 0, $this->line_length - 3) . '...' . $this->br;
}
$output .= $title_string; $output .= $title_string;
# Display dn # Display dn
if ($this->isSafeAscii($dn)) if ($this->isSafeAscii($dn))
{
$output .= $this->multiLineDisplay(sprintf('dn: %s', $dn)); $output .= $this->multiLineDisplay(sprintf('dn: %s', $dn));
}
else else
{
$output .= $this->multiLineDisplay(sprintf('dn:: %s', base64_encode($dn))); $output .= $this->multiLineDisplay(sprintf('dn:: %s', base64_encode($dn)));
}
# display the attributes # display the attributes
foreach ($dndetails as $key => $attr) { foreach ($dndetails as $key => $attr) {
if (! is_array($attr)) if (! is_array($attr))
{
$attr = array($attr); $attr = array($attr);
}
foreach ($attr as $value) foreach ($attr as $value)
{
if ( ! $this->isSafeAscii($value) || $server->isAttrBinary($key)) if ( ! $this->isSafeAscii($value) || $server->isAttrBinary($key))
{
$output .= $this->multiLineDisplay(sprintf('%s:: %s', $key, base64_encode($value))); $output .= $this->multiLineDisplay(sprintf('%s:: %s', $key, base64_encode($value)));
else } else
{
$output .= $this->multiLineDisplay(sprintf('%s: %s', $key, $value)); $output .= $this->multiLineDisplay(sprintf('%s: %s', $key, $value));
} }
}
}
$output .= $this->br; $output .= $this->br;
} }
} }
if ($this->compress) if ($this->compress)
{
return gzencode($output); return gzencode($output);
}
else else
{
return $output; return $output;
} }
}
/** /**
* Helper method to wrap ldif lines * Helper method to wrap ldif lines
@ -547,7 +616,7 @@ class ExportLDIF extends Export {
* @subpackage Export * @subpackage Export
*/ */
class ExportVCARD extends Export { class ExportVCARD extends Export {
static public function getType() { public static function getType() {
return array('type'=>'VCARD','description' => _('VCARD 2.1 Export'),'extension'=>'vcf'); return array('type'=>'VCARD','description' => _('VCARD 2.1 Export'),'extension'=>'vcf');
} }
@ -603,7 +672,9 @@ class ExportVCARD extends Export {
# Loop for the attributes # Loop for the attributes
foreach ($dndetails as $key => $attr) { foreach ($dndetails as $key => $attr) {
if (! is_array($attr)) if (! is_array($attr))
{
$attr = array($attr); $attr = array($attr);
}
# If an attribute of the ldap entry exist in the mapping array for vcard # If an attribute of the ldap entry exist in the mapping array for vcard
if (isset($this->mapping[$key])) { if (isset($this->mapping[$key])) {
@ -613,8 +684,12 @@ class ExportVCARD extends Export {
$output .= sprintf('%s:%s',$this->mapping[$key],$attr[0]); $output .= sprintf('%s:%s',$this->mapping[$key],$attr[0]);
if (isset($entry['ou'])) if (isset($entry['ou']))
{
foreach ($entry['ou'] as $ou_value) foreach ($entry['ou'] as $ou_value)
{
$output .= sprintf(';%s', $ou_value); $output .= sprintf(';%s', $ou_value);
}
}
# The attribute is binary. (to do : need to fold the line) # The attribute is binary. (to do : need to fold the line)
} elseif (in_array($key,array('audio','jpegphoto'))) { } elseif (in_array($key,array('audio','jpegphoto'))) {
@ -637,9 +712,13 @@ class ExportVCARD extends Export {
} }
if ($this->compress) if ($this->compress)
{
return gzencode($output); return gzencode($output);
}
else else
{
return $output; return $output;
} }
} }
}

File diff suppressed because it is too large Load Diff

View File

@ -106,9 +106,13 @@ abstract class Import {
public function getSource($attr) { public function getSource($attr) {
if (isset($this->source[$attr])) if (isset($this->source[$attr]))
{
return $this->source[$attr]; return $this->source[$attr];
}
else else
return null; {
return NULL;
}
} }
# @todo integrate hooks # @todo integrate hooks
@ -150,7 +154,7 @@ class ImportLDIF extends Import {
private $template; private $template;
public $error = array(); public $error = array();
static public function getType() { public static function getType() {
return array('type'=>'LDIF','description' => _('LDIF Import'),'extension'=>'ldif'); return array('type'=>'LDIF','description' => _('LDIF Import'),'extension'=>'ldif');
} }
@ -172,7 +176,9 @@ class ImportLDIF extends Import {
list($text,$version) = $this->getAttrValue(array_shift($lines)); list($text,$version) = $this->getAttrValue(array_shift($lines));
if ($version != 1) if ($version != 1)
{
return $this->error(sprintf('%s %s', _('LDIF import only suppports version 1'), $version), $lines); return $this->error(sprintf('%s %s', _('LDIF import only suppports version 1'), $version), $lines);
}
$haveVersion = true; $haveVersion = true;
$lines = $this->nextLines(); $lines = $this->nextLines();
@ -191,7 +197,9 @@ class ImportLDIF extends Import {
array_shift($lines); array_shift($lines);
} else } else
{
$changetype = 'add'; $changetype = 'add';
}
$this->template = new Template($this->server_id,null,null,$changetype); $this->template = new Template($this->server_id,null,null,$changetype);
@ -212,7 +220,9 @@ class ImportLDIF extends Import {
case 'modify': case 'modify':
if (! $server->dnExists($dn)) if (! $server->dnExists($dn))
{
return $this->error(sprintf('%s %s', _('DN does not exist'), $dn), $lines); return $this->error(sprintf('%s %s', _('DN does not exist'), $dn), $lines);
}
$this->template->setDN($dn); $this->template->setDN($dn);
$this->template->accept(false,true); $this->template->accept(false,true);
@ -224,7 +234,9 @@ class ImportLDIF extends Import {
case 'moddn': case 'moddn':
case 'modrdn': case 'modrdn':
if (! $server->dnExists($dn)) if (! $server->dnExists($dn))
{
return $this->error(sprintf('%s %s', _('DN does not exist'), $dn), $lines); return $this->error(sprintf('%s %s', _('DN does not exist'), $dn), $lines);
}
$this->template->setDN($dn); $this->template->setDN($dn);
$this->template->accept(); $this->template->accept();
@ -235,14 +247,20 @@ class ImportLDIF extends Import {
default: default:
if (! $server->dnExists($dn)) if (! $server->dnExists($dn))
{
return $this->error(_('Unkown change type'), $lines); return $this->error(_('Unkown change type'), $lines);
} }
}
} else } else
{
return $this->error(_('A valid dn line is required'), $lines); return $this->error(_('A valid dn line is required'), $lines);
}
} else } else
return false; {
return FALSE;
}
} }
/** /**
@ -255,9 +273,13 @@ class ImportLDIF extends Import {
# Get the DN # Get the DN
if (substr($value,0,1) == ':') if (substr($value,0,1) == ':')
{
$value = base64_decode(trim(substr($value, 1))); $value = base64_decode(trim(substr($value, 1)));
}
else else
{
$value = trim($value); $value = trim($value);
}
return array($attr,$value); return array($attr,$value);
} }
@ -284,21 +306,29 @@ class ImportLDIF extends Import {
/* If the next line begin with a space, we append it to the current row /* If the next line begin with a space, we append it to the current row
* else we push it into the array (unwrap)*/ * else we push it into the array (unwrap)*/
if ($this->isWrappedLine()) if ($this->isWrappedLine())
{
$current[$count] .= trim($this->_currentLine); $current[$count] .= trim($this->_currentLine);
}
elseif ($this->isCommentLine()) {} elseif ($this->isCommentLine()) {}
# Do nothing # Do nothing
elseif (! $this->isBlankLine()) elseif (! $this->isBlankLine())
{
$current[++$count] = trim($this->_currentLine); $current[++$count] = trim($this->_currentLine);
}
else else
$endEntryFound = true; {
$endEntryFound = TRUE;
}
} }
# Return the LDIF entry array # Return the LDIF entry array
return $current; return $current;
} else } else
{
return array(); return array();
} }
}
/** /**
* Private method to check if there is more entries in the input. * Private method to check if there is more entries in the input.
@ -394,19 +424,27 @@ class ImportLDIF extends Import {
if ($fh = @fopen($filename,'rb')) { if ($fh = @fopen($filename,'rb')) {
if (! $return = @fread($fh,filesize($filename))) if (! $return = @fread($fh,filesize($filename)))
{
return $this->error(_('Unable to read file for'), $value); return $this->error(_('Unable to read file for'), $value);
}
@fclose($fh); @fclose($fh);
} else } else
{
return $this->error(_('Unable to open file for'), $value); return $this->error(_('Unable to open file for'), $value);
}
} else } else
{
return $this->error(_('The url attribute value should begin with file:// for'), $value); return $this->error(_('The url attribute value should begin with file:// for'), $value);
}
# It's a string # It's a string
} else } else
{
$return = $value; $return = $value;
}
return trim($return); return trim($return);
} }
@ -425,11 +463,15 @@ class ImportLDIF extends Import {
} else } else
if ($attribute->hasBeenModified()) if ($attribute->hasBeenModified())
{
$attribute->addValue($value); $attribute->addValue($value);
}
else else
{
$attribute->setValue(array($value)); $attribute->setValue(array($value));
} }
} }
}
/** /**
* Build the attributes array for the entry when the change type is modify * Build the attributes array for the entry when the change type is modify
@ -438,7 +480,9 @@ class ImportLDIF extends Import {
*/ */
private function getModifyDetails($lines) { private function getModifyDetails($lines) {
if (! count($lines)) if (! count($lines))
{
return $this->error(_('Missing attributes for'), $lines); return $this->error(_('Missing attributes for'), $lines);
}
# While the array is not empty # While the array is not empty
while (count($lines)) { while (count($lines)) {
@ -452,7 +496,9 @@ class ImportLDIF extends Import {
$action_attribute_value = $attrvalue[1]; $action_attribute_value = $attrvalue[1];
if (! in_array($action_attribute,array('add','delete','replace'))) if (! in_array($action_attribute,array('add','delete','replace')))
{
return $this->error(_('Missing modify command add, delete or replace'), array_merge(array($currentLine), $lines)); return $this->error(_('Missing modify command add, delete or replace'), array_merge(array($currentLine), $lines));
}
$processline = true; $processline = true;
switch ($action_attribute) { switch ($action_attribute) {
@ -464,8 +510,10 @@ class ImportLDIF extends Import {
$attribute = $this->template->getAttribute($action_attribute_value); $attribute = $this->template->getAttribute($action_attribute_value);
if (is_null($attribute)) if (is_null($attribute))
{
return $this->error(sprintf('%s %s', _('Attempting to delete a non existant attribute'), $action_attribute_value), return $this->error(sprintf('%s %s', _('Attempting to delete a non existant attribute'), $action_attribute_value),
array_merge(array($currentLine), $lines)); array_merge(array($currentLine), $lines));
}
$deleteattr = true; $deleteattr = true;
@ -475,8 +523,10 @@ class ImportLDIF extends Import {
$attribute = $this->template->getAttribute($action_attribute_value); $attribute = $this->template->getAttribute($action_attribute_value);
if (is_null($attribute)) if (is_null($attribute))
{
return $this->error(sprintf('%s %s', _('Attempting to replace a non existant attribute'), $action_attribute_value), return $this->error(sprintf('%s %s', _('Attempting to replace a non existant attribute'), $action_attribute_value),
array_merge(array($currentLine), $lines)); array_merge(array($currentLine), $lines));
}
break; break;
@ -507,9 +557,13 @@ class ImportLDIF extends Import {
switch ($action_attribute) { switch ($action_attribute) {
case 'add': case 'add':
if (is_null($attribute)) if (is_null($attribute))
{
$attribute = $this->template->addAttribute($attr, array('values' => array($attribute_value_part))); $attribute = $this->template->addAttribute($attr, array('values' => array($attribute_value_part)));
}
else else
{
$attribute->addValue($attribute_value_part, -1); $attribute->addValue($attribute_value_part, -1);
}
$attribute->justModified(); $attribute->justModified();
@ -519,19 +573,27 @@ class ImportLDIF extends Import {
$deleteattr = false; $deleteattr = false;
if (($key = array_search($attribute_value_part,$attribute->getValues())) !== false) if (($key = array_search($attribute_value_part,$attribute->getValues())) !== false)
{
$attribute->delValue($key); $attribute->delValue($key);
}
else else
{
return $this->error(sprintf('%s %s', _('Delete value doesnt exist in DN'), $attribute_value_part), return $this->error(sprintf('%s %s', _('Delete value doesnt exist in DN'), $attribute_value_part),
array_merge(array($currentLine), $lines)); array_merge(array($currentLine), $lines));
}
break; break;
case 'replace': case 'replace':
if ($attribute->hasBeenModified()) if ($attribute->hasBeenModified())
{
$attribute->addValue($attribute_value_part, -1); $attribute->addValue($attribute_value_part, -1);
}
else else
{
$attribute->setValue(array($attribute_value_part)); $attribute->setValue(array($attribute_value_part));
}
break; break;
@ -540,20 +602,28 @@ class ImportLDIF extends Import {
} }
} else } else
{
return $this->error(sprintf('%s %s', _('The attribute to modify doesnt match the one specified by'), $action_attribute), return $this->error(sprintf('%s %s', _('The attribute to modify doesnt match the one specified by'), $action_attribute),
array_merge(array($currentLine), $lines)); array_merge(array($currentLine), $lines));
}
} else } else
{
return $this->error(sprintf('%s %s', _('Attribute not valid'), $currentLine), return $this->error(sprintf('%s %s', _('Attribute not valid'), $currentLine),
array_merge(array($currentLine), $lines)); array_merge(array($currentLine), $lines));
}
$currentLine = array_shift($lines); $currentLine = array_shift($lines);
if (trim($currentLine)) if (trim($currentLine))
$processline = true; {
$processline = TRUE;
}
} }
if ($action_attribute == 'delete' && $deleteattr) if ($action_attribute == 'delete' && $deleteattr)
{
$attribute->setValue(array()); $attribute->setValue(array());
}
} }
@ -571,7 +641,9 @@ class ImportLDIF extends Import {
# MODRDN MODDN should only be 2 or 3 lines. # MODRDN MODDN should only be 2 or 3 lines.
if (count($lines) != 2 && count($lines) !=3) if (count($lines) != 2 && count($lines) !=3)
{
return $this->error(_('Invalid entry'), $lines); return $this->error(_('Invalid entry'), $lines);
}
else { else {
$currentLine = array_shift($lines); $currentLine = array_shift($lines);
@ -598,17 +670,25 @@ class ImportLDIF extends Import {
$attrs['newsuperior'] = $attrvalue[1]; $attrs['newsuperior'] = $attrvalue[1];
} else } else
{
return $this->error(_('A valid newsuperior attribute should be specified'), $lines); return $this->error(_('A valid newsuperior attribute should be specified'), $lines);
}
} else } else
{
$attrs['newsuperior'] = $server->getContainer($this->template->getDN()); $attrs['newsuperior'] = $server->getContainer($this->template->getDN());
}
} else } else
{
return $this->error(_('A valid deleteoldrdn attribute should be specified'), $lines); return $this->error(_('A valid deleteoldrdn attribute should be specified'), $lines);
}
} else } else
{
return $this->error(_('A valid newrdn attribute should be specified'), $lines); return $this->error(_('A valid newrdn attribute should be specified'), $lines);
} }
}
# Well do something out of the ordinary here, since our template doesnt handle mod[r]dn yet. # Well do something out of the ordinary here, since our template doesnt handle mod[r]dn yet.
$this->template->modrdn = $attrs; $this->template->modrdn = $attrs;

View File

@ -27,13 +27,19 @@ class page {
public function __construct($index=null) { public function __construct($index=null) {
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
# If we done have a configuration, then our IMGDIR and CSS are not defined # If we done have a configuration, then our IMGDIR and CSS are not defined
if (! defined('IMGDIR')) if (! defined('IMGDIR'))
{
define('IMGDIR', 'images/default'); define('IMGDIR', 'images/default');
}
if (! defined('CSSDIR')) if (! defined('CSSDIR'))
{
define('CSSDIR', 'css/default'); define('CSSDIR', 'css/default');
}
$this->index = $index; $this->index = $index;
@ -42,9 +48,13 @@ class page {
$this->_app['logo'] = IMGDIR.'/logo-small.png'; $this->_app['logo'] = IMGDIR.'/logo-small.png';
if (! is_null($index)) if (! is_null($index))
{
$this->_app['urlcss'] = sprintf('%s/%s', CSSDIR, $_SESSION[APPCONFIG]->getValue('appearance', 'stylesheet')); $this->_app['urlcss'] = sprintf('%s/%s', CSSDIR, $_SESSION[APPCONFIG]->getValue('appearance', 'stylesheet'));
}
else else
{
$this->_app['urlcss'] = sprintf('%s/%s', CSSDIR, 'style.css'); $this->_app['urlcss'] = sprintf('%s/%s', CSSDIR, 'style.css');
}
# Default Values for configurable items. # Default Values for configurable items.
$this->_default['sysmsg']['error'] = IMGDIR.'/error-big.png'; $this->_default['sysmsg']['error'] = IMGDIR.'/error-big.png';
@ -67,13 +77,17 @@ class page {
header('Content-Encoding: gzip'); header('Content-Encoding: gzip');
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) if (defined('DEBUG_ENABLED') && DEBUG_ENABLED)
{
debug_log('Sent COMPRESSED header to browser and discarded (%s)', 129, 0, __FILE__, __LINE__, __METHOD__, $preOutput); debug_log('Sent COMPRESSED header to browser and discarded (%s)', 129, 0, __FILE__, __LINE__, __METHOD__, $preOutput);
} }
}
if (isset($_SESSION[APPCONFIG]) if (isset($_SESSION[APPCONFIG])
&& $_SESSION[APPCONFIG]->getValue('appearance','compress') && $_SESSION[APPCONFIG]->getValue('appearance','compress')
&& ini_get('zlib.output_compression')) && ini_get('zlib.output_compression'))
{
$this->setsysmsg(array('title' => _('Warning'), 'body' => _('WARNING: You cannot have PHP compression and application compression enabled at the same time. Please unset zlib.output_compression or set $config->custom->appearance[\'compress\']=false'), 'type' => 'warn')); $this->setsysmsg(array('title' => _('Warning'), 'body' => _('WARNING: You cannot have PHP compression and application compression enabled at the same time. Please unset zlib.output_compression or set $config->custom->appearance[\'compress\']=false'), 'type' => 'warn'));
}
# Turn back on output buffering. # Turn back on output buffering.
ob_start(); ob_start();
@ -86,7 +100,9 @@ class page {
/* Add to the HTML Header */ /* Add to the HTML Header */
public function head_add($html) { public function head_add($html) {
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$this->_head[] .= $html; $this->_head[] .= $html;
} }
@ -94,11 +110,15 @@ class page {
/* Print out the HTML header */ /* Print out the HTML header */
private function pageheader_print() { private function pageheader_print() {
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
# HTML prepage requirements. # HTML prepage requirements.
foreach ($this->_pageheader as $line) foreach ($this->_pageheader as $line)
{
echo $line . "\n"; echo $line . "\n";
}
# Page Title # Page Title
echo '<head>'; echo '<head>';
@ -106,16 +126,22 @@ class page {
$DNs = get_request('dn','REQUEST'); $DNs = get_request('dn','REQUEST');
if (is_array($DNs)) if (is_array($DNs))
{
$DNs = ''; $DNs = '';
}
if (isset($_SESSION[APPCONFIG])) if (isset($_SESSION[APPCONFIG]))
{
printf('<title>%s (%s) - %s%s</title>', printf('<title>%s (%s) - %s%s</title>',
$this->_app['title'], $this->_app['title'],
app_version(), app_version(),
$DNs ? htmlspecialchars($DNs) . ' ' : '', $DNs ? htmlspecialchars($DNs) . ' ' : '',
$_SESSION[APPCONFIG]->getValue('appearance', 'page_title')); $_SESSION[APPCONFIG]->getValue('appearance', 'page_title'));
}
else else
{
printf('<title>%s - %s</title>', $this->_app['title'], app_version()); printf('<title>%s - %s</title>', $this->_app['title'], app_version());
}
echo '<link rel="shortcut icon" href="images/favicon.ico" type="image/vnd.microsoft.icon" />'; echo '<link rel="shortcut icon" href="images/favicon.ico" type="image/vnd.microsoft.icon" />';
# Style sheet. # Style sheet.
@ -131,8 +157,12 @@ class page {
# HTML head requirements. # HTML head requirements.
if (is_array($this->_head) && count($this->_head)) if (is_array($this->_head) && count($this->_head))
{
foreach ($this->_head as $line) foreach ($this->_head as $line)
{
echo $line . "\n"; echo $line . "\n";
}
}
echo '</head>'; echo '</head>';
echo "\n"; echo "\n";
@ -140,12 +170,18 @@ class page {
private function head_print() { private function head_print() {
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
if (isset($_SESSION[APPCONFIG])) if (isset($_SESSION[APPCONFIG]))
{
$pagetitle = $_SESSION[APPCONFIG]->getValue('appearance', 'page_title') ? ' - ' . $_SESSION[APPCONFIG]->getValue('appearance', 'page_title') : ''; $pagetitle = $_SESSION[APPCONFIG]->getValue('appearance', 'page_title') ? ' - ' . $_SESSION[APPCONFIG]->getValue('appearance', 'page_title') : '';
}
else else
{
$pagetitle = ''; $pagetitle = '';
}
echo '<tr class="pagehead">'; echo '<tr class="pagehead">';
@ -155,18 +191,27 @@ class page {
echo '<td class="imagetop">'; echo '<td class="imagetop">';
$empty = true; $empty = true;
if (function_exists('cmd_control_pane')) if (function_exists('cmd_control_pane'))
{
foreach (cmd_control_pane('top') as $cmddetails) foreach (cmd_control_pane('top') as $cmddetails)
if ((isset($cmddetails['enable']) && $cmddetails['enable']) || ! isset($cmddetails['enable'])) { {
if ((isset($cmddetails['enable']) && $cmddetails['enable']) || ! isset($cmddetails['enable']))
{
if ( ! $empty) if ( ! $empty)
{
echo ' '; echo ' ';
}
printf('<a %s>%s</a>', $cmddetails['link'], $cmddetails['image']); printf('<a %s>%s</a>', $cmddetails['link'], $cmddetails['image']);
$empty = false; $empty = FALSE;
}
}
} }
if ($empty) if ($empty)
{
echo '&nbsp;'; echo '&nbsp;';
}
echo '</td>'; echo '</td>';
echo '</tr></table></div></td>'; echo '</tr></table></div></td>';
@ -176,27 +221,38 @@ class page {
private function control_print() { private function control_print() {
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
echo '<table class="control" width="100%" border="0">'; echo '<table class="control" width="100%" border="0">';
echo '<tr><td>'; echo '<tr><td>';
$empty = true; $empty = true;
if (function_exists('cmd_control_pane')) if (function_exists('cmd_control_pane'))
{
foreach (cmd_control_pane('main') as $cmddetails) foreach (cmd_control_pane('main') as $cmddetails)
if ((isset($cmddetails['enable']) && trim($cmddetails['enable'])) || ! isset($cmddetails['enable'])) { {
if ((isset($cmddetails['enable']) && trim($cmddetails['enable'])) || ! isset($cmddetails['enable']))
{
if ( ! $empty) if ( ! $empty)
{
echo ' | '; echo ' | ';
}
printf('<a %s>%s</a>', $cmddetails['link'], printf('<a %s>%s</a>', $cmddetails['link'],
(isset($_SESSION[APPCONFIG]) && $_SESSION[APPCONFIG]->getValue('appearance', 'control_icons')) ? $cmddetails['image'] : $cmddetails['title']); (isset($_SESSION[APPCONFIG]) && $_SESSION[APPCONFIG]->getValue('appearance', 'control_icons')) ? $cmddetails['image'] : $cmddetails['title']);
$empty = false; $empty = FALSE;
}
}
} }
echo '</td>'; echo '</td>';
if ($empty) if ($empty)
{
echo '<td>&nbsp;</td>'; echo '<td>&nbsp;</td>';
}
echo '</tr>'; echo '</tr>';
echo '</table>'; echo '</table>';
@ -204,13 +260,19 @@ class page {
protected function tree() { protected function tree() {
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
if (! isset($_SESSION[APPCONFIG])) if (! isset($_SESSION[APPCONFIG]))
{
return; return;
}
if (is_null($this->index)) if (is_null($this->index))
{
$this->index = min(array_keys($_SESSION[APPCONFIG]->getServerList())); $this->index = min(array_keys($_SESSION[APPCONFIG]->getServerList()));
}
if (count($_SESSION[APPCONFIG]->getServerList()) > 1) { if (count($_SESSION[APPCONFIG]->getServerList()) > 1) {
echo '<form id="server_select" action="cmd.php" method="post">'; echo '<form id="server_select" action="cmd.php" method="post">';
@ -233,30 +295,42 @@ class page {
public function block_add($side,$object) { public function block_add($side,$object) {
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
if (! is_object($object)) if (! is_object($object))
{
error(sprintf('block_add called with [%s], but it is not an object', serialize($object))); error(sprintf('block_add called with [%s], but it is not an object', serialize($object)));
}
$this->_block[$side][] = $object; $this->_block[$side][] = $object;
} }
private function block_print($side) { private function block_print($side) {
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
if (! isset($this->_block[$side])) if (! isset($this->_block[$side]))
{
return; return;
}
printf('<td class="%s" colspan="2">',$side); printf('<td class="%s" colspan="2">',$side);
foreach ($this->_block[$side] as $object) foreach ($this->_block[$side] as $object)
{
echo $object->draw($side); echo $object->draw($side);
}
echo '</td>'; echo '</td>';
} }
private function sysmsg() { private function sysmsg() {
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
if (isset($this->sysmsg)) { if (isset($this->sysmsg)) {
foreach ($this->sysmsg as $index => $details) { foreach ($this->sysmsg as $index => $details) {
@ -276,30 +350,43 @@ class page {
} }
if (isset($details['title'])) if (isset($details['title']))
{
printf('<tr><td class="icon" rowspan="2"><img src="%s" alt="%s" /></td><td class="head">%s</td></tr>', printf('<tr><td class="icon" rowspan="2"><img src="%s" alt="%s" /></td><td class="head">%s</td></tr>',
$icon, $details['type'], $details['title']); $icon, $details['type'], $details['title']);
}
if (isset($details['body'])) if (isset($details['body']))
if (is_array($details['body'])) { {
if (is_array($details['body']))
{
echo '<tr><td class="body">'; echo '<tr><td class="body">';
foreach ($details['body'] as $line) foreach ($details['body'] as $line)
{
printf('%s<br />', $line); printf('%s<br />', $line);
}
echo '</td></tr>'; echo '</td></tr>';
} else } else
{
printf('<tr><td class="body">%s</td></tr>', $details['body']); printf('<tr><td class="body">%s</td></tr>', $details['body']);
} }
} }
} }
}
}
private function body($raw=false) { private function body($raw=false) {
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
# Add the Session System Messages # Add the Session System Messages
if (isset($_SESSION['sysmsg']) && is_array($_SESSION['sysmsg'])) { if (isset($_SESSION['sysmsg']) && is_array($_SESSION['sysmsg'])) {
foreach ($_SESSION['sysmsg'] as $msg) foreach ($_SESSION['sysmsg'] as $msg)
{
$this->setsysmsg($msg); $this->setsysmsg($msg);
}
unset($_SESSION['sysmsg']); unset($_SESSION['sysmsg']);
} }
@ -312,13 +399,19 @@ class page {
} }
if (isset($this->_block['body'])) if (isset($this->_block['body']))
{
foreach ($this->_block['body'] as $object) foreach ($this->_block['body'] as $object)
{
echo $object->draw('body', $raw); echo $object->draw('body', $raw);
} }
}
}
private function footer_print() { private function footer_print() {
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
printf('<tr class="foot"><td><small>%s</small></td><td colspan="2"><div id="ajFOOT">%s</div>%s</td></tr>', printf('<tr class="foot"><td><small>%s</small></td><td colspan="2"><div id="ajFOOT">%s</div>%s</td></tr>',
isCompress() ? '[C]' : '&nbsp;', isCompress() ? '[C]' : '&nbsp;',
@ -334,7 +427,9 @@ class page {
*/ */
public function show($frame,$compress=false,$raw=false) { public function show($frame,$compress=false,$raw=false) {
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
# If the body is called via AJAX, and compression is enable, we need to compress the output # If the body is called via AJAX, and compression is enable, we need to compress the output
if ($compress && ob_get_level() && isCompress()) { if ($compress && ob_get_level() && isCompress()) {
@ -360,8 +455,10 @@ class page {
ob_end_clean(); ob_end_clean();
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) if (defined('DEBUG_ENABLED') && DEBUG_ENABLED)
{
debug_log('Sending COMPRESSED output to browser[(%s),%s]', 129, 0, __FILE__, __LINE__, __METHOD__, debug_log('Sending COMPRESSED output to browser[(%s),%s]', 129, 0, __FILE__, __LINE__, __METHOD__,
strlen($output), $output); strlen($output), $output);
}
print gzencode($output); print gzencode($output);
} }
@ -369,7 +466,9 @@ class page {
public function display($filter=array()) { public function display($filter=array()) {
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
# Control what is displayed. # Control what is displayed.
$display = array( $display = array(
@ -400,7 +499,9 @@ class page {
echo '<table class="page" border="0" width="100%">'; echo '<table class="page" border="0" width="100%">';
if ($display['HEAD']) if ($display['HEAD'])
{
$this->head_print(); $this->head_print();
}
# Control Line # Control Line
if ($display['CONTROL']) { if ($display['CONTROL']) {
@ -434,7 +535,9 @@ class page {
# Page Footer # Page Footer
if ($display['FOOT']) if ($display['FOOT'])
{
$this->footer_print(); $this->footer_print();
}
# Finish HTML # Finish HTML
echo '</table>'; echo '</table>';
@ -447,8 +550,10 @@ class page {
ob_end_clean(); ob_end_clean();
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) if (defined('DEBUG_ENABLED') && DEBUG_ENABLED)
{
debug_log('Sending COMPRESSED output to browser[(%s),%s]', 129, 0, __FILE__, __LINE__, __METHOD__, debug_log('Sending COMPRESSED output to browser[(%s),%s]', 129, 0, __FILE__, __LINE__, __METHOD__,
strlen($output), $output); strlen($output), $output);
}
print gzencode($output); print gzencode($output);
} }
@ -456,21 +561,33 @@ class page {
public function setsysmsg($data) { public function setsysmsg($data) {
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
if (! is_array($data)) if (! is_array($data))
{
return; return;
}
if (isset($this->sysmsg)) if (isset($this->sysmsg))
{
$msgnum = count($this->sysmsg) + 1; $msgnum = count($this->sysmsg) + 1;
}
else else
{
$msgnum = 1; $msgnum = 1;
}
foreach (array('title','body','type') as $index) foreach (array('title','body','type') as $index)
{
if (isset($data[$index])) if (isset($data[$index]))
{
$this->sysmsg[$msgnum][$index] = $data[$index]; $this->sysmsg[$msgnum][$index] = $data[$index];
} }
} }
}
}
/** /**
* This class draws a block. * This class draws a block.
@ -499,19 +616,27 @@ class block {
$output = ''; $output = '';
if ($raw) if ($raw)
{
$output .= $this->body; $output .= $this->body;
}
else { else {
$output .= sprintf('<table class="%s">',$side); $output .= sprintf('<table class="%s">',$side);
if (isset($this->title)) if (isset($this->title))
{
$output .= sprintf('<tr><td class="head">%s</td></tr>', $this->title); $output .= sprintf('<tr><td class="head">%s</td></tr>', $this->title);
}
if (isset($this->body)) if (isset($this->body))
{
$output .= sprintf('<tr><td>%s</td></tr>', $this->body); $output .= sprintf('<tr><td>%s</td></tr>', $this->body);
}
if (isset($this->footer)) if (isset($this->footer))
{
$output .= sprintf('<tr><td class="foot">%s</td></tr>', $this->foot); $output .= sprintf('<tr><td class="foot">%s</td></tr>', $this->foot);
}
$output .= '</table>'; $output .= '</table>';
} }

File diff suppressed because it is too large Load Diff

View File

@ -29,9 +29,13 @@ function app_session_get_id() {
$id_hex = hexdec($id_md5[0]) + 1; $id_hex = hexdec($id_md5[0]) + 1;
$ip_hex = hexdec($ip_md5[0]); $ip_hex = hexdec($ip_md5[0]);
if ($ip_hex <= app_session_id_ip_min) if ($ip_hex <= app_session_id_ip_min)
{
$ip_len = app_session_id_ip_min; $ip_len = app_session_id_ip_min;
}
else else
{
$ip_len = $ip_hex - 1; $ip_len = $ip_hex - 1;
}
$new_id = substr($id_md5, 0, $id_hex) . $new_id = substr($id_md5, 0, $id_hex) .
substr($ip_md5, $ip_hex, $ip_len) . substr($ip_md5, $ip_hex, $ip_len) .
@ -51,9 +55,13 @@ function app_session_verify_id() {
$id_hex = hexdec($check_id[0]) + 1; $id_hex = hexdec($check_id[0]) + 1;
$ip_hex = hexdec($ip_md5[0]); $ip_hex = hexdec($ip_md5[0]);
if ($ip_hex <= app_session_id_ip_min) if ($ip_hex <= app_session_id_ip_min)
{
$ip_len = app_session_id_ip_min; $ip_len = app_session_id_ip_min;
}
else else
{
$ip_len = $ip_hex - 1; $ip_len = $ip_hex - 1;
}
$ip_ses = substr($check_id, $id_hex, $ip_len); $ip_ses = substr($check_id, $id_hex, $ip_len);
$ip_ver = substr($ip_md5, $ip_hex, $ip_len); $ip_ver = substr($ip_md5, $ip_hex, $ip_len);
@ -79,7 +87,9 @@ function app_session_start() {
# If we have a sysmsg before our session has started, then preserve it. # If we have a sysmsg before our session has started, then preserve it.
if (isset($_SESSION['sysmsg'])) if (isset($_SESSION['sysmsg']))
{
$sysmsg = $_SESSION['sysmsg']; $sysmsg = $_SESSION['sysmsg'];
}
/* If session.auto_start is on in the server's PHP configuration (php.ini), then /* If session.auto_start is on in the server's PHP configuration (php.ini), then
* we will have problems loading our schema cache since the session will have started * we will have problems loading our schema cache since the session will have started
@ -87,11 +97,15 @@ function app_session_start() {
* session to prevent this problem. * session to prevent this problem.
*/ */
if (ini_get('session.auto_start') && ! array_key_exists(app_session_id_init,$_SESSION)) if (ini_get('session.auto_start') && ! array_key_exists(app_session_id_init,$_SESSION))
{
@session_destroy(); @session_destroy();
}
# Do we already have a session? # Do we already have a session?
if (@session_id()) if (@session_id())
{
return; return;
}
@session_name(APP_SESSION_ID); @session_name(APP_SESSION_ID);
@session_start(); @session_start();
@ -116,11 +130,16 @@ function app_session_start() {
@header('Cache-control: private'); // IE 6 Fix @header('Cache-control: private'); // IE 6 Fix
if (app_session_id_paranoid && ! app_session_verify_id()) if (app_session_id_paranoid && ! app_session_verify_id())
{
error('Session inconsistent or session timeout', 'error', 'index.php'); error('Session inconsistent or session timeout', 'error', 'index.php');
}
# Check we have the correct version of the SESSION cache # Check we have the correct version of the SESSION cache
if (isset($_SESSION['cache']) || isset($_SESSION[app_session_id_init])) { if (isset($_SESSION['cache']) || isset($_SESSION[app_session_id_init])) {
if (! is_array($_SESSION[app_session_id_init])) $_SESSION[app_session_id_init] = array(); if (! is_array($_SESSION[app_session_id_init]))
{
$_SESSION[app_session_id_init] = array();
}
if (! isset($_SESSION[app_session_id_init]['version']) || ! isset($_SESSION[app_session_id_init]['config']) || ! isset($_SESSION[app_session_id_init]['name']) if (! isset($_SESSION[app_session_id_init]['version']) || ! isset($_SESSION[app_session_id_init]['config']) || ! isset($_SESSION[app_session_id_init]['name'])
|| $_SESSION[app_session_id_init]['name'] !== app_name() || $_SESSION[app_session_id_init]['name'] !== app_name()
@ -143,25 +162,37 @@ function app_session_start() {
$config_file = CONFDIR.'config.php'; $config_file = CONFDIR.'config.php';
$config = check_config($config_file); $config = check_config($config_file);
if (! $config) if (! $config)
{
debug_dump_backtrace('config is empty?', 1); debug_dump_backtrace('config is empty?', 1);
}
} else { } else {
# Sanity check, specially when upgrading from a previous release. # Sanity check, specially when upgrading from a previous release.
if (isset($_SESSION['cache'])) if (isset($_SESSION['cache']))
{
foreach (array_keys($_SESSION['cache']) as $id) foreach (array_keys($_SESSION['cache']) as $id)
{
if (isset($_SESSION['cache'][$id]['tree']['null']) && ! is_object($_SESSION['cache'][$id]['tree']['null'])) if (isset($_SESSION['cache'][$id]['tree']['null']) && ! is_object($_SESSION['cache'][$id]['tree']['null']))
{
unset($_SESSION['cache'][$id]); unset($_SESSION['cache'][$id]);
} }
} }
}
}
}
# If we came via index.php, then set our $config. # If we came via index.php, then set our $config.
if (! isset($_SESSION[APPCONFIG]) && isset($config)) if (! isset($_SESSION[APPCONFIG]) && isset($config))
{
$_SESSION[APPCONFIG] = $config; $_SESSION[APPCONFIG] = $config;
}
# Restore our sysmsg's if there were any. # Restore our sysmsg's if there were any.
if ($sysmsg) { if ($sysmsg) {
if (! isset($_SESSION['sysmsg']) || ! is_array($_SESSION['sysmsg'])) if (! isset($_SESSION['sysmsg']) || ! is_array($_SESSION['sysmsg']))
{
$_SESSION['sysmsg'] = array(); $_SESSION['sysmsg'] = array();
}
$_SESSION['sysmsg'] = array_merge($_SESSION['sysmsg'],$sysmsg); $_SESSION['sysmsg'] = array_merge($_SESSION['sysmsg'],$sysmsg);
} }

View File

@ -43,16 +43,20 @@ class xml2array {
$this->strXmlData = xml_parse($this->resParser,$strInputXML); $this->strXmlData = xml_parse($this->resParser,$strInputXML);
if (! $this->strXmlData) if (! $this->strXmlData)
{
die(sprintf('XML error: %s at line %d in file %s', die(sprintf('XML error: %s at line %d in file %s',
xml_error_string(xml_get_error_code($this->resParser)), xml_error_string(xml_get_error_code($this->resParser)),
xml_get_current_line_number($this->resParser), xml_get_current_line_number($this->resParser),
$filename)); $filename));
}
xml_parser_free($this->resParser); xml_parser_free($this->resParser);
$output = array(); $output = array();
foreach ($this->arrOutput as $key => $values) foreach ($this->arrOutput as $key => $values)
{
$output[$key] = $this->cleanXML($values); $output[$key] = $this->cleanXML($values);
}
#return $this->arrOutput; #return $this->arrOutput;
return $output; return $output;
@ -71,7 +75,9 @@ class xml2array {
$cnt = count($this->stack_ref[$name]); $cnt = count($this->stack_ref[$name]);
$this->stack_ref[$name][$cnt] = array(); $this->stack_ref[$name][$cnt] = array();
if (isset($attrs)) if (isset($attrs))
{
$this->stack_ref[$name][$cnt] = $attrs; $this->stack_ref[$name][$cnt] = $attrs;
}
$this->push_pos($this->stack_ref[$name][$cnt]); $this->push_pos($this->stack_ref[$name][$cnt]);
@ -79,7 +85,9 @@ class xml2array {
$this->stack_ref[$name]=array(); $this->stack_ref[$name]=array();
if (isset($attrs)) if (isset($attrs))
{
$this->stack_ref[$name] = $attrs; $this->stack_ref[$name] = $attrs;
}
$this->push_pos($this->stack_ref[$name]); $this->push_pos($this->stack_ref[$name]);
} }
@ -89,11 +97,15 @@ class xml2array {
if (trim($tagData) != '') { if (trim($tagData) != '') {
if (isset($this->stack_ref['#text'])) if (isset($this->stack_ref['#text']))
{
$this->stack_ref['#text'] .= $tagData; $this->stack_ref['#text'] .= $tagData;
}
else else
{
$this->stack_ref['#text'] = $tagData; $this->stack_ref['#text'] = $tagData;
} }
} }
}
private function tagClosed($parser,$name) { private function tagClosed($parser,$name) {
$this->pop_pos(); $this->pop_pos();
@ -108,10 +120,14 @@ class xml2array {
private function cleanXML($details) { private function cleanXML($details) {
# Quick processing for the final branch of the XML array. # Quick processing for the final branch of the XML array.
if (is_array($details) && isset($details['#text'])) if (is_array($details) && isset($details['#text']))
{
return $details['#text']; return $details['#text'];
}
elseif (is_array($details) && isset($details['ID']) && count($details) == 1) elseif (is_array($details) && isset($details['ID']) && count($details) == 1)
{
return $details['ID']; return $details['ID'];
}
$cleanXML = array(); $cleanXML = array();
@ -125,21 +141,32 @@ class xml2array {
# More detailed processing... # More detailed processing...
if (is_array($details)) if (is_array($details))
{
foreach ($details as $key => $values) foreach ($details as $key => $values)
if (is_numeric($key) && isset($values['ID']) && count($values) > 1) { {
if (is_numeric($key) && isset($values['ID']) && count($values) > 1)
{
$key = $values['ID']; $key = $values['ID'];
unset($values['ID']); unset($values['ID']);
$cleanXML[$key] = $this->cleanXML($values); $cleanXML[$key] = $this->cleanXML($values);
} elseif (isset($values['#text'])) } elseif (isset($values['#text']))
{
$cleanXML[$key] = $this->cleanXML($values); $cleanXML[$key] = $this->cleanXML($values);
} elseif (is_array($values))
elseif (is_array($values)) {
$cleanXML[$key] = $this->cleanXML($values); $cleanXML[$key] = $this->cleanXML($values);
}
}
}
if (! $cleanXML) if (! $cleanXML)
{
return $details; return $details;
}
else else
{
return $cleanXML; return $cleanXML;
} }
} }
}

View File

@ -20,7 +20,9 @@ abstract class xmlTemplates {
public function __construct($server_id) { public function __construct($server_id) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$this->server_id = $server_id; $this->server_id = $server_id;
$server = $_SESSION[APPCONFIG]->getServer($this->server_id); $server = $_SESSION[APPCONFIG]->getServer($this->server_id);
@ -31,7 +33,9 @@ abstract class xmlTemplates {
# Try to get the templates from our CACHE. # Try to get the templates from our CACHE.
if ($this->templates = get_cached_item($server_id,$class['item'])) { if ($this->templates = get_cached_item($server_id,$class['item'])) {
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
{
debug_log('Using CACHED templates', 4, 0, __FILE__, __LINE__, __METHOD__); debug_log('Using CACHED templates', 4, 0, __FILE__, __LINE__, __METHOD__);
}
# See if the template_time has expired to see if we should reload the templates. # See if the template_time has expired to see if we should reload the templates.
foreach ($this->templates as $index => $template) { foreach ($this->templates as $index => $template) {
@ -62,7 +66,9 @@ abstract class xmlTemplates {
} }
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
{
debug_log('Templates refreshed', 4, 0, __FILE__, __LINE__, __METHOD__); debug_log('Templates refreshed', 4, 0, __FILE__, __LINE__, __METHOD__);
}
# See if there are any new template files # See if there are any new template files
$index = max(array_keys($this->templates))+1; $index = max(array_keys($this->templates))+1;
@ -70,17 +76,23 @@ abstract class xmlTemplates {
$dir = $class['dir'].$type; $dir = $class['dir'].$type;
$dh = opendir($dir); $dh = opendir($dir);
if (! $type) if (! $type)
{
$type = 'template'; $type = 'template';
}
while ($file = readdir($dh)) { while ($file = readdir($dh)) {
# Ignore any files that are not XML files. # Ignore any files that are not XML files.
if (! preg_match('/.xml$/',$file)) if (! preg_match('/.xml$/',$file))
{
continue; continue;
}
# Ignore any files that are not the predefined custom files. # Ignore any files that are not the predefined custom files.
if ($_SESSION[APPCONFIG]->getValue('appearance','custom_templates_only') if ($_SESSION[APPCONFIG]->getValue('appearance','custom_templates_only')
&& ! preg_match("/^${custom_prefix}/",$file)) && ! preg_match("/^${custom_prefix}/",$file))
{
continue; continue;
}
$filename = sprintf('%s/%s',$dir,$file); $filename = sprintf('%s/%s',$dir,$file);
@ -102,7 +114,9 @@ abstract class xmlTemplates {
} else { } else {
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
{
debug_log('Parsing templates', 4, 0, __FILE__, __LINE__, __METHOD__); debug_log('Parsing templates', 4, 0, __FILE__, __LINE__, __METHOD__);
}
# Need to reset this, as get_cached_item() returns null if nothing cached. # Need to reset this, as get_cached_item() returns null if nothing cached.
$this->templates = array(); $this->templates = array();
@ -113,17 +127,23 @@ abstract class xmlTemplates {
$dir = $class['dir'].$type; $dir = $class['dir'].$type;
$dh = opendir($class['dir'].$type); $dh = opendir($class['dir'].$type);
if (! $type) if (! $type)
{
$type = 'template'; $type = 'template';
}
while ($file = readdir($dh)) { while ($file = readdir($dh)) {
# Ignore any files that are not XML files. # Ignore any files that are not XML files.
if (! preg_match('/.xml$/',$file)) if (! preg_match('/.xml$/',$file))
{
continue; continue;
}
# Ignore any files that are not the predefined custom files. # Ignore any files that are not the predefined custom files.
if ($_SESSION[APPCONFIG]->getValue('appearance','custom_templates_only') if ($_SESSION[APPCONFIG]->getValue('appearance','custom_templates_only')
&& ! preg_match("/^${custom_prefix}/",$file)) && ! preg_match("/^${custom_prefix}/",$file))
{
continue; continue;
}
$filename = sprintf('%s/%s',$dir,$file); $filename = sprintf('%s/%s',$dir,$file);
@ -136,7 +156,9 @@ abstract class xmlTemplates {
} }
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
{
debug_log('Templates loaded', 4, 0, __FILE__, __LINE__, __METHOD__); debug_log('Templates loaded', 4, 0, __FILE__, __LINE__, __METHOD__);
}
if ($changed) { if ($changed) {
masort($this->templates,'title'); masort($this->templates,'title');
@ -149,7 +171,9 @@ abstract class xmlTemplates {
*/ */
private function getClassVars() { private function getClassVars() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$class = array(); $class = array();
@ -190,26 +214,38 @@ abstract class xmlTemplates {
*/ */
public function getTemplates($type=null,$container=null,$disabled=false) { public function getTemplates($type=null,$container=null,$disabled=false) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$result = array(); $result = array();
if (is_array($this->templates)) if (is_array($this->templates))
foreach ($this->templates as $details) { {
foreach ($this->templates as $details)
{
# Clone this, as we'll disable some templates, as a result of the container being requested. # Clone this, as we'll disable some templates, as a result of the container being requested.
$template = clone $details; $template = clone $details;
if (! is_null($container) && ($regexp = $template->getRegExp()) && (! @preg_match('/'.$regexp.'/i',$container))) { if ( ! is_null($container) && ($regexp = $template->getRegExp()) && ( ! @preg_match('/' . $regexp . '/i', $container)))
$template->setInvalid(_('This template is not valid in this container'),true); {
$template->setInvalid(_('This template is not valid in this container'), TRUE);
if ($_SESSION[APPCONFIG]->getValue('appearance', 'hide_template_regexp')) if ($_SESSION[APPCONFIG]->getValue('appearance', 'hide_template_regexp'))
{
$template->setInvisible(); $template->setInvisible();
} }
}
if ($template->isVisible() && ( ! $disabled || ! $template->isAdminDisabled())) if ($template->isVisible() && ( ! $disabled || ! $template->isAdminDisabled()))
{
if (is_null($type) || ( ! is_null($type) && $template->isType($type))) if (is_null($type) || ( ! is_null($type) && $template->isType($type)))
{
array_push($result, $template); array_push($result, $template);
} }
}
}
}
return $result; return $result;
} }
@ -222,13 +258,19 @@ abstract class xmlTemplates {
*/ */
public function getTemplate($templateid) { public function getTemplate($templateid) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$class = $this->getClassVars(); $class = $this->getClassVars();
foreach ($this->templates as $template) foreach ($this->templates as $template)
{
if ($template->getID() === $templateid) if ($template->getID() === $templateid)
{
return clone $template; return clone $template;
}
}
# If we get here, the template ID didnt exist, so return a blank template, which be interpreted as the default template # If we get here, the template ID didnt exist, so return a blank template, which be interpreted as the default template
$object = new $class['name']($this->server_id,null,null,'default'); $object = new $class['name']($this->server_id,null,null,'default');
@ -240,12 +282,16 @@ abstract class xmlTemplates {
*/ */
private function getTemplateFiles() { private function getTemplateFiles() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$result = array(); $result = array();
foreach ($this->templates as $template) foreach ($this->templates as $template)
{
array_push($result, $template->getFileName()); array_push($result, $template->getFileName());
}
return $result; return $result;
} }
@ -275,7 +321,9 @@ abstract class xmlTemplate {
public function __construct($server_id,$name=null,$filename=null,$type=null,$id=null) { public function __construct($server_id,$name=null,$filename=null,$type=null,$id=null) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$this->server_id = $server_id; $this->server_id = $server_id;
$this->name = $name; $this->name = $name;
@ -286,7 +334,9 @@ abstract class xmlTemplate {
# If there is no filename, then this template is a default template. # If there is no filename, then this template is a default template.
if (is_null($filename)) if (is_null($filename))
{
return; return;
}
# If we have a filename, parse the template file and build the object. # If we have a filename, parse the template file and build the object.
$objXML = new xml2array(); $objXML = new xml2array();
@ -302,11 +352,17 @@ abstract class xmlTemplate {
*/ */
protected function getAttrID($attr) { protected function getAttrID($attr) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
foreach ($this->attributes as $index => $attribute) foreach ($this->attributes as $index => $attribute)
{
if (strtolower($attr) == $attribute->getName() || in_array(strtolower($attr), $attribute->getAliases())) if (strtolower($attr) == $attribute->getName() || in_array(strtolower($attr), $attribute->getAliases()))
{
return $index; return $index;
}
}
return null; return null;
} }
@ -316,7 +372,9 @@ abstract class xmlTemplate {
*/ */
public function getFileName() { public function getFileName() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->filename); debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->filename);
}
return $this->filename; return $this->filename;
} }
@ -326,13 +384,19 @@ abstract class xmlTemplate {
*/ */
public function getID() { public function getID() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs, $this->id); debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs, $this->id);
}
if ($this->name) if ($this->name)
return sprintf('%s:%s',$this->getName(false),$this->id); {
return sprintf('%s:%s', $this->getName(FALSE), $this->id);
}
else else
{
return 'none'; return 'none';
} }
}
/** /**
* Return the template name * Return the template name
@ -341,20 +405,28 @@ abstract class xmlTemplate {
*/ */
public function getName($lower=true) { public function getName($lower=true) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->name); debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->name);
}
if ($lower) if ($lower)
{
return strtolower($this->name); return strtolower($this->name);
}
else else
{
return $this->name; return $this->name;
} }
}
/** /**
* Get the Template read time. * Get the Template read time.
*/ */
public function getReadTime() { public function getReadTime() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->readtime); debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->readtime);
}
return $this->readtime; return $this->readtime;
} }
@ -366,7 +438,9 @@ abstract class xmlTemplate {
*/ */
protected function getServer() { protected function getServer() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs);
}
return $_SESSION[APPCONFIG]->getServer($this->getServerID()); return $_SESSION[APPCONFIG]->getServer($this->getServerID());
} }
@ -378,7 +452,9 @@ abstract class xmlTemplate {
*/ */
protected function getServerID() { protected function getServerID() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->server_id); debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->server_id);
}
return $this->server_id; return $this->server_id;
} }
@ -391,12 +467,18 @@ abstract class xmlTemplate {
*/ */
public function isType($type) { public function isType($type) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs, $this->type); debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs, $this->type);
}
if ($this->type == $type) if ($this->type == $type)
return true; {
return TRUE;
}
else else
return false; {
return FALSE;
}
} }
/** /**
@ -404,7 +486,9 @@ abstract class xmlTemplate {
*/ */
public function getType() { public function getType() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->type); debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->type);
}
return $this->type; return $this->type;
} }
@ -414,10 +498,14 @@ abstract class xmlTemplate {
*/ */
public function getTitle() { public function getTitle() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
if (! isset($this->title) && ! isset($this->description)) if (! isset($this->title) && ! isset($this->description))
{
return ''; return '';
}
return isset($this->title) ? $this->title : $this->description; return isset($this->title) ? $this->title : $this->description;
} }
@ -432,10 +520,14 @@ abstract class xmlTemplate {
*/ */
public function addAttribute($name,$value,$source=null) { public function addAttribute($name,$value,$source=null) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
if (! is_array($value)) if (! is_array($value))
{
debug_dump_backtrace('Value should be an array()', 1); debug_dump_backtrace('Value should be an array()', 1);
}
$server = $this->getServer(); $server = $this->getServer();
@ -443,10 +535,12 @@ abstract class xmlTemplate {
$attribute_factory = new AttributeFactory(); $attribute_factory = new AttributeFactory();
if (preg_match('/;/',$name)) if (preg_match('/;/',$name))
{
system_message(array( system_message(array(
'title' => 'phpLDAPadmin doesnt support RFC3866.', 'title' => 'phpLDAPadmin doesnt support RFC3866.',
'body' => sprintf('%s {%s} (%s)', 'PLA might not do what you expect...', $name, (is_array($value) ? serialize($value) : $value)), 'body' => sprintf('%s {%s} (%s)', 'PLA might not do what you expect...', $name, (is_array($value) ? serialize($value) : $value)),
'type' => 'warn')); 'type' => 'warn'));
}
# If there isnt a schema item for this attribute # If there isnt a schema item for this attribute
$attribute = $attribute_factory->newAttribute($name,$value,$server->getIndex(),$source); $attribute = $attribute_factory->newAttribute($name,$value,$server->getIndex(),$source);
@ -454,7 +548,9 @@ abstract class xmlTemplate {
$attrid = $this->getAttrID($attribute->getName()); $attrid = $this->getAttrID($attribute->getName());
if (is_null($attrid)) if (is_null($attrid))
{
array_push($this->attributes, $attribute); array_push($this->attributes, $attribute);
}
return $attribute; return $attribute;
} }
@ -466,12 +562,16 @@ abstract class xmlTemplate {
*/ */
public function getAttributeNames() { public function getAttributeNames() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
$result = array(); $result = array();
foreach ($this->attributes as $attribute) foreach ($this->attributes as $attribute)
{
array_push($result, $attribute->getName()); array_push($result, $attribute->getName());
}
return $result; return $result;
} }
@ -484,11 +584,17 @@ abstract class xmlTemplate {
*/ */
public function getAttribute($name) { public function getAttribute($name) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
{
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs); debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
}
foreach ($this->attributes as $attribute) foreach ($this->attributes as $attribute)
{
if (($attribute->getName() == strtolower($name)) || in_array(strtolower($name), $attribute->getAliases())) if (($attribute->getName() == strtolower($name)) || in_array(strtolower($name), $attribute->getAliases()))
{
return $attribute; return $attribute;
}
}
return null; return null;
} }