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

View File

@ -21,7 +21,9 @@ $request['dn'] = get_request('dn','REQUEST',true);
# Check if the entry exists.
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']->setDN($request['dn']);
@ -37,10 +39,14 @@ $ldap['attrs']['must'] = array();
foreach ($request['template']->getAttribute('objectclass')->getValues() as $oclass_name) {
# Exclude "top" if its there.
if (! strcasecmp('top',$oclass_name))
{
continue;
}
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']);
@ -49,12 +55,18 @@ $ldap['attrs']['must'] = array_unique($ldap['attrs']['must']);
* but that the object does not currently contain */
$ldap['attrs']['need'] = array();
foreach ($ldap['attrs']['must'] as $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
foreach ($ldap['attrs']['need'] as $index => $values)
{
$ldap['attrs']['need'][$index]->show();
}
if (count($ldap['attrs']['need']) > 0) {
$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>';
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
{
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="dn" value="%s" />',htmlspecialchars($request['dn']));
@ -87,11 +102,15 @@ if (count($ldap['attrs']['need']) > 0) {
$counter = 0;
echo '<tr><td colspan="2">';
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>';
foreach ($ldap['attrs']['need'] as $count => $attr)
$request['page']->draw('Template',$attr);
{
$request['page']->draw('Template', $attr);
}
echo '</table>';
@ -108,7 +127,9 @@ if (count($ldap['attrs']['need']) > 0) {
$app['server']->getIndex(),rawurlencode($request['dn']));
if (get_request('meth','REQUEST') == 'ajax')
{
$href .= '&meth=ajax';
}
header(sprintf('Location: %s',$href));
die();

View File

@ -19,7 +19,9 @@ $request['attr'] = get_request('attr','GET',true);
# Check if the entry exists.
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']->setDN($request['dn']);
@ -46,9 +48,12 @@ 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 '<div>';
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
{
echo '<input type="hidden" name="cmd" value="update" />';
}
}
printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
@ -71,7 +76,9 @@ if (! strcasecmp($request['attr'],'objectclass') || get_request('meth','REQUEST'
echo '<table border="0"><tr><td>';
for ($i=0;$i<$request['count'];$i++) {
if ($i > 0)
{
echo '<br/>';
}
$request['page']->draw('CurrentValue',$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();
foreach ($request['attribute']->getValues() as $oclass)
{
unset($socs[strtolower($oclass)]);
}
# Draw objectClass selection
echo '<table border="0">';
@ -105,7 +114,9 @@ if (! strcasecmp($request['attr'],'objectclass') || get_request('meth','REQUEST'
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
if (($oclass->getType() == 'structural') && ! $oclass->isRelated($request['attribute']->getValues()))
continue;
{
continue;
}
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>';
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>',
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 '</form>';
@ -136,14 +149,20 @@ if (! strcasecmp($request['attr'],'objectclass') || get_request('meth','REQUEST'
$sattr = $app['server']->getSchemaAttribute($request['attr']);
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())
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())
{
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 />';
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']) {
default:
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'))
$app['script_cmd'] = HTDOCDIR.$www['cmd'].'.php';
{
$app['script_cmd'] = HTDOCDIR . $www['cmd'] . '.php';
}
elseif (file_exists('welcome.php'))
{
$app['script_cmd'] = 'welcome.php';
}
else
$app['script_cmd'] = null;
{
$app['script_cmd'] = NULL;
}
}
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.
# 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 this is a READ-WRITE operation, the LDAP server must not be in READ-ONLY mode.
if ($app['server']->isReadOnly() && ! in_array(get_request('cmd','REQUEST'),$app['readwrite_cmds']))
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php');
{
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 (! $_SESSION[APPCONFIG]->isCommandAvailable('script',$www['cmd'])) {
@ -56,7 +68,9 @@ if (trim($www['cmd'])) {
}
if ($app['script_cmd'])
{
include $app['script_cmd'];
}
# Refresh a frame - this is so that one frame can trigger another frame to be refreshed.
if (isAjaxEnabled() && get_request('refresh','REQUEST') && get_request('refresh','REQUEST') != get_request('frame','REQUEST')) {
@ -73,7 +87,11 @@ $www['page']->block_add('body',$www['body']);
ob_end_clean();
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
{
$www['page']->display();
}

View File

@ -9,6 +9,8 @@
*/
if (! defined('LIBDIR'))
define('LIBDIR',sprintf('%s/',realpath('../lib/')));
{
define('LIBDIR', sprintf('%s/', realpath('../lib/')));
}
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'));
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']))
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']->setDN($request['dnSRC']);
@ -88,16 +92,22 @@ sort($attrs_all);
foreach ($attrs_all as $attr) {
# Has the config.php specified that this attribute is to be hidden or shown?
if ($ldap['SRC']->isAttrHidden($attr) || $ldap['DST']->isAttrHidden($attr))
{
continue;
}
$attributeSRC = $request['templateSRC']->getAttribute($attr);
$attributeDST = $request['templateDST']->getAttribute($attr);
# Get the values and see if they are the same.
if ($attributeSRC && $attributeDST && ($attributeSRC->getValues() == $attributeDST->getValues()))
{
echo '<tr>';
}
else
{
echo '<tr>';
}
foreach (array('src','dst') as $side) {
# If we are on the source side, show the attribute name.
@ -109,7 +119,9 @@ foreach ($attrs_all as $attr) {
echo '</td>';
if ($request['pageSRC']->getServerID() == $request['pageDST']->getServerID())
{
echo '<td class="title">&nbsp;</td>';
}
else {
echo '<td class="note" style="text-align: right;">';
@ -126,7 +138,9 @@ foreach ($attrs_all as $attr) {
case 'dst':
if ($attributeDST) {
if ($attributeSRC && ($request['pageSRC']->getServerID() == $request['pageDST']->getServerID()))
{
echo '<td class="title">&nbsp;</td>';
}
else {
echo '<td class="title" >';
@ -151,9 +165,13 @@ foreach ($attrs_all as $attr) {
# Get the values and see if they are the same.
if ($attributeSRC && $attributeDST && ($attributeSRC->getValues() == $attributeDST->getValues()))
{
echo '<tr style="background-color: #F0F0F0;">';
}
else
{
echo '<tr>';
}
foreach (array('src','dst') as $side) {
echo '<td class="value" colspan="2"><table border="0">';
@ -163,17 +181,25 @@ foreach ($attrs_all as $attr) {
case 'src':
if ($attributeSRC && count($attributeSRC->getValues()))
$request['pageSRC']->draw('CurrentValues',$attributeSRC);
{
$request['pageSRC']->draw('CurrentValues', $attributeSRC);
}
else
{
echo '&nbsp;';
}
break;
case 'dst':
if ($attributeDST && count($attributeDST->getValues()))
$request['pageDST']->draw('CurrentValues',$attributeDST);
{
$request['pageDST']->draw('CurrentValues', $attributeDST);
}
else
{
echo '&nbsp;';
}
break;
}

View File

@ -18,7 +18,9 @@ $request['dn'] = get_request('dn','GET');
# Check if the entry exists.
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']->setDN($request['dn']);

View File

@ -22,20 +22,30 @@ $ldap['DST'] = $_SESSION[APPCONFIG]->getServer(get_request('server_id_dst'));
# Error checking
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())
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']))
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'])))
{
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())
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['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
foreach ($request['templateDST']->getAttributes(true) as $sattribute)
if ($sattribute->getValues() && ! $sattribute->isInternal()) {
{
if ($sattribute->getValues() && ! $sattribute->isInternal())
{
$sattribute->show();
$sattribute->setMaxValueCount(count($sattribute->getValues()));
}
}
$request['pageDST']->accept();
@ -92,13 +105,17 @@ if ($request['recursive']) {
$copy_result = copy_dn($ldap['SRC'],$ldap['DST'],$request['dnSRC'],$request['dnDST'],$request['remove']);
if ($copy_result)
{
$copy_message = sprintf('%s %s: <b>%s</b> %s',
$request['remove'] ? _('Move successful') : _('Copy successful'),
_('DN'),$request['dnDST'],_('has been created.'));
_('DN'), $request['dnDST'], _('has been created.'));
}
else
{
$copy_message = sprintf('%s %s: <b>%s</b> %s',
$request['remove'] ? _('Move NOT successful') : _('Copy NOT successful'),
_('DN'),$request['dnDST'],_('has NOT been created.'));
_('DN'), $request['dnDST'], _('has NOT been created.'));
}
}
}
@ -115,7 +132,9 @@ if ($copy_result) {
function r_copy_dn($serverSRC,$serverDST,$snapshottree,$dnSRC,$dnDST,$remove) {
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();
@ -127,7 +146,9 @@ function r_copy_dn($serverSRC,$serverDST,$snapshottree,$dnSRC,$dnDST,$remove) {
$copy_result = copy_dn($serverSRC,$serverDST,$dnSRC,$dnDST,false);
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.')));
@ -138,27 +159,35 @@ function r_copy_dn($serverSRC,$serverDST,$snapshottree,$dnSRC,$dnDST,$remove) {
$copy_message = array_merge($copy_message,array_values($copy_result));
if (! $copy_result)
$hadError = true;
{
$hadError = TRUE;
}
}
if (! $hadError && $remove) {
$delete_result = $serverSRC->delete($dnSRC);
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 {
$copy_result = copy_dn($serverSRC,$serverDST,$dnSRC,$dnDST,$remove);
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'),
_('DN'),$dnDST,_('has been created.')));
_('DN'), $dnDST, _('has been created.')));
}
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'),
_('DN'),$dnDST,_('has NOT been created.')));
_('DN'), $dnDST, _('has NOT been created.')));
}
}
return $copy_message;
@ -166,7 +195,9 @@ function r_copy_dn($serverSRC,$serverDST,$snapshottree,$dnSRC,$dnDST,$remove) {
function copy_dn($serverSRC,$serverDST,$dnSRC,$dnDST,$remove) {
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['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
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
return $serverDST->add($request['templateDST']->getDN(),$request['templateDST']->getLDAPadd());
{
return $serverDST->add($request['templateDST']->getDN(), $request['templateDST']->getLDAPadd());
}
}
function build_tree($server,$dn,$buildtree) {
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
$children = $server->getContainerContents($dn,null,0);
@ -198,11 +235,15 @@ function build_tree($server,$dn,$buildtree) {
if (count($children)) {
$buildtree[$dn] = $children;
foreach ($children as $child_dn)
$buildtree = build_tree($server,$child_dn,$buildtree);
{
$buildtree = build_tree($server, $child_dn, $buildtree);
}
}
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;
}

View File

@ -17,7 +17,9 @@ $request['dn'] = get_request('dn','GET');
# Check if the entry exists.
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']->setDN($request['dn']);
@ -93,11 +95,14 @@ echo '</table>';
echo '</form>';
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
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();
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...
$tree = get_cached_item($app['server']->getIndex(),'tree');
@ -39,17 +41,23 @@ if (! $request['container'] && ! get_request('create_base')) {
# Check our RDN
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())
error(_('The RDN field is empty?'),'error','index.php');
{
error(_('The RDN field is empty?'), 'error', 'index.php');
}
# Some other attribute checking...
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.
# @todo this isIgnoredAttr() function is missing?
if ($attribute->isRequired() && ! count($attribute->getValues()) && ! $app['server']->isIgnoredAttr($attr->getName()))
{
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
@ -60,25 +68,34 @@ if ($add_result) {
$href = sprintf('cmd=template_engine&server_id=%s',$app['server']->getIndex());
if ($request['redirect'])
{
$redirect_url = $request['redirect'];
}
else if ($action_number == 2)
{
$redirect_url = sprintf('cmd.php?%s&template=%s&container=%s',
$href,'default',$request['template']->getContainerEncode());
$href, 'default', $request['template']->getContainerEncode());
}
else
{
$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)
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) {
$create_message = sprintf('%s %s: <b>%s</b> %s',
_('Creation successful!'),_('DN'),$request['template']->getDN(),_('has been created.'));
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(
'title'=>_('Create Entry'),

View File

@ -20,7 +20,9 @@ $request['page']->accept();
$request['template'] = $request['page']->getTemplate();
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...
$tree = get_cached_item($app['server']->getIndex(),'tree');
@ -33,17 +35,23 @@ if (! $request['container']) {
# Check our RDN
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())
error(_('The RDN field is empty?'),'error','index.php');
{
error(_('The RDN field is empty?'), 'error', 'index.php');
}
# Some other attribute checking...
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.
# @todo this isIgnoredAttr() function is missing?
if ($attribute->isRequired() && ! count($attribute->getValues()) && ! $app['server']->isIgnoredAttr($attr->getName()))
{
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
@ -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="template" value="%s" />',$request['template']->getID());
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";
$request['page']->drawHiddenAttributes();
@ -100,7 +109,9 @@ if (count($request['template']->getLDAPadd(true))) {
$input_onclick = '';
if ($attribute->isRequired())
{
$input_disabled = 'disabled="disabled"';
}
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);
@ -133,10 +144,14 @@ if (count($request['template']->getLDAPadd(true))) {
echo _('You made no changes');
if (isAjaxEnabled())
{
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
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>';
}

View File

@ -16,7 +16,9 @@ $request = array();
$request['dn'] = get_request('dn','REQUEST',true);
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.
$result = $app['server']->delete($request['dn']);
@ -25,7 +27,9 @@ if ($result) {
$redirect_url = '';
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(
'title'=>_('Delete DN'),
@ -33,8 +37,10 @@ if ($result) {
'type'=>'info'),
sprintf('index.php?server_id=%s%s',$app['server']->getIndex(),$redirect_url));
} else
{
system_message(array(
'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)),
'type'=>'error'));
'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)),
'type' => 'error'));
}

View File

@ -17,7 +17,9 @@ $request['attr'] = get_request('attr','REQUEST',true);
$request['index'] = get_request('index','REQUEST',true);
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[$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']));
if (! isset($update_array[$request['attr']][$request['index']]))
{
system_message(array(
'title'=>_('Could not delete attribute value.'),
'body'=>sprintf('%s. %s/%s',_('The attribute value does not exist'),$request['attr'],$request['index']),
'type'=>'warn'),$redirect_url);
'title' => _('Could not delete attribute value.'),
'body' => sprintf('%s. %s/%s', _('The attribute value does not exist'), $request['attr'], $request['index']),
'type' => 'warn'), $redirect_url);
}
else {
unset($update_array[$request['attr']][$request['index']]);
foreach ($update_array as $key => $values)
{
$update_array[$key] = array_values($values);
}
$result = $app['server']->modify($request['dn'],$update_array);
if ($result) {
foreach ($update_array as $attr => $junk)
$redirect_url .= sprintf('&modified_attrs[]=%s',$attr);
{
$redirect_url .= sprintf('&modified_attrs[]=%s', $attr);
}
header("Location: $redirect_url");
die();

View File

@ -22,10 +22,12 @@ $request['template'] = $request['page']->getTemplate();
# Check if the entry exists.
if (! $request['dn'] || ! $app['server']->dnExists($request['dn']))
{
system_message(array(
'title'=>_('Entry does not exist'),
'body'=>sprintf('%s (%s)',_('The entry does not exist'),$request['dn']),
'type'=>'error'),'index.php');
'title' => _('Entry does not exist'),
'body' => sprintf('%s (%s)', _('The entry does not exist'), $request['dn']),
'type' => 'error'), 'index.php');
}
# 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);
@ -106,7 +108,9 @@ if (count($request['children'])) {
$i = 0;
printf('<select size="%s" multiple disabled style="background:white; color:black;width:500px" >',min(10,count($request['search'])));
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 "\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']));
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']));
# Dump the binary data to the browser
$obStatus = ob_get_status();
if (isset($obStatus['type']) && $obStatus['type'] && $obStatus['status'])
if (isset($obStatus['type']) && $obStatus['type'] && $obStatus['status'])
{
ob_end_clean();
}
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.

View File

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

View File

@ -46,7 +46,9 @@ if (isset($app['server']) && ! is_null($request['container'])) {
foreach ($app['server']->getBaseDN() as $base) {
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)) {
$parent_container = false;
@ -67,33 +69,42 @@ if (isset($app['server']) && ! is_null($request['container'])) {
echo '</tr>';
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
foreach ($request['children'] as $dn) {
$href['return'] = sprintf("javascript:returnDN('%s%s')",($request['rdn'] ? sprintf('%s,',$request['rdn']) : ''),str_replace('\\','\\\\',$dn));
{
foreach ($request['children'] as $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',
$app['server']->getIndex(),$request['form'],$request['element'],$request['rdn'],rawurlencode($dn));
$app['server']->getIndex(), $request['form'], $request['element'], $request['rdn'], rawurlencode($dn));
echo '<tr>';
echo '<td class="blank">&nbsp;</td>';
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);
if (is_null($entry)) {
if (is_null($entry))
{
$tree->addEntry($dn);
$entry = $tree->getEntry($dn);
}
if ($entry)
{
$item = draw_formatted_dn($app['server'], $entry);
else
} else
{
$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 "\n\n";
}
}
# Draw the root of the selection tree (ie, list all the servers)
} else {

View File

@ -24,8 +24,10 @@ $types = $request['export']->getType();
# send the header
if ($request['file']) {
$obStatus = ob_get_status();
if (isset($obStatus['type']) && $obStatus['type'] && $obStatus['status'])
if (isset($obStatus['type']) && $obStatus['type'] && $obStatus['status'])
{
ob_end_clean();
}
header('Content-type: application/download');
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>';
foreach ($available_scopes as $id => $desc)
{
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),$desc);
htmlspecialchars($id), $id, ($id == $request['scope']) ? 'checked="checked"' : '',
htmlspecialchars($id), $desc);
}
echo '</td>';
@ -123,9 +125,11 @@ echo '<fieldset style="height: 100px">';
printf('<legend>%s</legend>',_('Line ends'));
foreach ($available_formats as $id => $desc)
{
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),$desc);
htmlspecialchars($id), htmlspecialchars($id), ($request['format'] == $id) ? ' checked="checked"' : '',
htmlspecialchars($id), $desc);
}
echo '</fieldset>';
echo '</td></tr>';
@ -149,13 +153,21 @@ echo '</form>';
*/
function get_line_end_format() {
if (is_browser('win'))
{
return 'win';
}
elseif (is_browser('unix'))
{
return 'unix';
}
elseif (is_browser('mac'))
{
return 'mac';
}
else
{
return 'unix';
}
}
/**
@ -166,9 +178,13 @@ function get_line_end_format() {
*/
function get_user_agent_string() {
if (isset($_SERVER['HTTP_USER_AGENT']))
{
return strtolower($_SERVER['HTTP_USER_AGENT']);
}
else
{
return '';
}
}
/**
@ -208,8 +224,12 @@ function is_browser($type) {
);
if (isset($agents[$type]))
return in_array(get_user_agent_string(),$agents[$type]);
{
return in_array(get_user_agent_string(), $agents[$type]);
}
else
return false;
{
return FALSE;
}
}

View File

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

View File

@ -19,11 +19,17 @@
$dir = opendir( '.' );
while( ( $file = readdir( $dir ) ) !== false ) {
if( $file == '.' || $file == '..' )
continue;
{
continue;
}
if( ! preg_match( '/\.png$/', $file ) )
continue;
{
continue;
}
if( $file == 'phpLDAPadmin_logo1.png' )
continue;
{
continue;
}
$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());
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 {
printf(' <span style="color:red;">%s</span></small><br /><br />',_('Failed'));
@ -84,7 +85,9 @@ while (! $request['import']->eof()) {
}
if (! $request['continuous_mode'])
{
break;
}
}
function display_pla_parse_error($request) {
@ -103,7 +106,9 @@ function display_pla_parse_error($request) {
printf('<tr><td colspan=2><b>%s</b>:</td></tr>',_('Data'));
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 '</center>';

View File

@ -13,7 +13,9 @@
require './common.php';
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']->drawTitle(sprintf('<b>%s</b>',_('Import')));

View File

@ -33,72 +33,104 @@ error_reporting(-1);
# General functions needed to proceed.
ob_start();
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));
}
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));
}
if (ob_get_level())
{
ob_end_clean();
}
# Make sure this PHP install has 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>');
}
require LIBDIR.'functions.php';
spl_autoload_register("autoload");
# Define the path to our configuration file.
if (defined('CONFDIR'))
$app['config_file'] = CONFDIR.'config.php';
{
$app['config_file'] = CONFDIR . 'config.php';
}
else
{
$app['config_file'] = 'config.php';
}
# Make sure this PHP install has session support
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
if (! extension_loaded('gettext'))
{
system_message(array(
'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>',
'type'=>'error'));
'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>',
'type' => 'error'));
}
# Make sure this PHP install has all our required extensions
if (! extension_loaded('ldap'))
{
system_message(array(
'title'=>_('Missing required extension'),
'body'=>'Your install of PHP appears to be missing LDAP support.<br /><br />Please install LDAP support before using phpLDAPadmin.<br /><small>(Dont forget to restart your web server afterwards)</small>',
'type'=>'error'));
'title' => _('Missing required extension'),
'body' => 'Your install of PHP appears to be missing LDAP support.<br /><br />Please install LDAP support before using phpLDAPadmin.<br /><small>(Dont forget to restart your web server afterwards)</small>',
'type' => 'error'));
}
# Make sure that we have php-xml loaded.
if (! function_exists('xml_parser_create'))
{
system_message(array(
'title'=>_('Missing required extension'),
'body'=>'Your install of PHP appears to be missing XML support.<br /><br />Please install XML support before using phpLDAPadmin.<br /><small>(Dont forget to restart your web server afterwards)</small>',
'type'=>'error'));
'title' => _('Missing required extension'),
'body' => 'Your install of PHP appears to be missing XML support.<br /><br />Please install XML support before using phpLDAPadmin.<br /><small>(Dont forget to restart your web server afterwards)</small>',
'type' => 'error'));
}
/**
* Helper functions.
* Our required helper functions are defined in functions.php
*/
if (isset($app['function_files']) && is_array($app['function_files']))
foreach ($app['function_files'] as $file_name ) {
if (! file_exists($file_name))
error(sprintf('Fatal error: Required file "%s" does not exist.',$file_name),'error',null,true);
{
foreach ($app['function_files'] as $file_name)
{
if ( ! file_exists($file_name))
{
error(sprintf('Fatal error: Required file "%s" does not exist.', $file_name), 'error', NULL, TRUE);
}
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);
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);
}
ob_start();
require $file_name;
if (ob_get_level()) ob_end_clean();
if (ob_get_level())
{
ob_end_clean();
}
}
}
# Configuration File check
if (! file_exists($app['config_file'])) {
@ -122,7 +154,9 @@ if (! $config = check_config($app['config_file'])) {
}
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())) {
system_message(array(
@ -131,17 +165,21 @@ if (! preg_match('/^([0-9]+\.?)+/',app_version())) {
'type'=>'info','special'=>true));
if (count($_SESSION[APPCONFIG]->untested()))
{
system_message(array(
'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())),
'type'=>'info','special'=>true));
'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())),
'type' => 'info', 'special' => TRUE));
}
$server = $_SESSION[APPCONFIG]->getServer(get_request('server_id','REQUEST'));
if (count($server->untested()))
{
system_message(array(
'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())),
'type'=>'info','special'=>true));
'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())),
'type' => 'info', 'special' => TRUE));
}
}
include './cmd.php';

View File

@ -16,22 +16,28 @@ $user['login'] = get_request('login');
$user['password'] = get_request('login_pass');
if ($user['login'] && ! strlen($user['password']))
{
system_message(array(
'title'=>_('Authenticate to server'),
'body'=>_('You left the password blank.'),
'type'=>'warn'),
sprintf('cmd.php?cmd=login_form&server_id=%s',get_request('server_id','REQUEST')));
'title' => _('Authenticate to server'),
'body' => _('You left the password blank.'),
'type' => 'warn'),
sprintf('cmd.php?cmd=login_form&server_id=%s', get_request('server_id', 'REQUEST')));
}
if ($app['server']->login($user['login'],$user['password'],'user'))
{
system_message(array(
'title'=>_('Authenticate to server'),
'body'=>_('Successfully logged into server.'),
'type'=>'info'),
sprintf('cmd.php?server_id=%s',get_request('server_id','REQUEST')));
'title' => _('Authenticate to server'),
'body' => _('Successfully logged into server.'),
'type' => 'info'),
sprintf('cmd.php?server_id=%s', get_request('server_id', 'REQUEST')));
}
else
{
system_message(array(
'title'=>_('Failed to Authenticate to server'),
'body'=>_('Invalid Username or Password.'),
'type'=>'error'),
sprintf('cmd.php?cmd=login_form&server_id=%s',get_request('server_id','REQUEST')));
'title' => _('Failed to Authenticate to server'),
'body' => _('Invalid Username or Password.'),
'type' => 'error'),
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')));
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
header('Status: 401 Unauthorized'); // http 1.1 method
{
header('Status: 401 Unauthorized');
} // http 1.1 method
return;
@ -59,7 +63,8 @@ if ($app['server']->getAuthType() == 'http') {
echo '<input type="hidden" name="nodecode[login_pass]" value="1" />';
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>';
@ -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 ($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>',
_('Anonymous'));
}
printf('<tr><td colspan="2" style="text-align: center;"><input type="submit" name="submit" value="%s" /></td></tr>',
_('Authenticate'));
@ -93,6 +100,8 @@ if ($app['server']->getAuthType() == 'http') {
echo '<script type="text/javascript">document.getElementById("login").focus()</script>';
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()));
} else
{
system_message(array(
'title'=>_('Failed to Logout of server'),
'body'=>_('Please report this error to the admins.'),
'type'=>'error'),
sprintf('index.php?server_id=%s',$app['server']->getIndex()));
'title' => _('Failed to Logout of server'),
'body' => _('Please report this error to the admins.'),
'type' => 'error'),
sprintf('index.php?server_id=%s', $app['server']->getIndex()));
}

View File

@ -16,23 +16,29 @@ $request = array();
$request['dn'] = get_request('dn','REQUEST');
if (! $request['dn'])
{
system_message(array(
'title'=>_('No entry selected'),
'body'=>_('No entry was selected to delete'),
'type'=>'warn'),'index.php');
'title' => _('No entry selected'),
'body' => _('No entry was selected to delete'),
'type' => 'warn'), 'index.php');
}
if (! is_array($request['dn']))
{
$request['dn'] = array($request['dn']);
}
$request['children'] = array();
$request['parent'] = array();
foreach ($request['dn'] as $dn) {
# Check if the entry exists.
if (! $dn || ! $app['server']->dnExists($dn))
{
system_message(array(
'title'=>_('Entry does not exist'),
'body'=>sprintf('%s (%s/%s)',_('The entry does not exist and will be ignored'),$dn),
'type'=>'error'));
'title' => _('Entry does not exist'),
'body' => sprintf('%s (%s/%s)', _('The entry does not exist and will be ignored'), $dn),
'type' => 'error'));
}
# We search all children, not only the visible children in the tree
if (! in_array_ignore_case($dn,$request['children'])) {
@ -49,16 +55,21 @@ echo '<center>';
echo '<table class="forminput" border="0">';
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
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>';
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)
{
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>';
@ -82,7 +93,9 @@ if (count($request['children'])) {
}
foreach ($request['search'] as $value)
array_push($request['delete'],$value['dn']);
{
array_push($request['delete'], $value['dn']);
}
echo '<tr>';
echo '<td colspan="4">';
@ -109,7 +122,9 @@ if (count($request['children'])) {
echo '<tr><td colspan="4"><center>';
printf('<select size="%s" multiple disabled style="background:white; color:black;width:500px" >',min(10,count($request['delete'])));
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 '</center></td></tr>';
echo "\n";
@ -123,7 +138,9 @@ echo '<form action="cmd.php" method="post">';
echo '<input type="hidden" name="cmd" value="rdelete" />';
printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
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'])));
echo '</form>';
echo '</center></td>';

View File

@ -40,14 +40,18 @@ foreach ($request['dn'] as $dn) {
# Mark our attributes to edit as shown.
foreach ($template->getAttributes(true) as $attribute) {
if ($attribute->isInternal())
{
continue;
}
if (in_array_ignore_case($attribute->getName(),$request['attrs']) || in_array('*',$request['attrs'])) {
$attribute->show();
# Get a list of our columns (we are not interested in these attribute values)
if (! isset($attrcols[$attribute->getName()]))
{
$attrcols[$attribute->getName()] = $attribute;
}
}
}
@ -57,7 +61,9 @@ foreach ($request['dn'] as $dn) {
usort($attrcols,'sortAttrs');
if (! count($request['page']))
{
header('Location: index.php');
}
# We'll render this forms Title with the first DN's object.
$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());
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>';
@ -99,7 +106,9 @@ foreach ($request['page'] as $j => $page) {
echo '<td>';
if ($attribute) {
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.
} else {
@ -115,7 +124,9 @@ foreach ($request['page'] as $j => $page) {
}
if (! $match)
{
printf('<center><small>%s</small></center>', _('Attribute not available'));
}
}
echo '</td>';

View File

@ -32,7 +32,9 @@ foreach ($request['dn'] as $index => $dn) {
# Simulate the requirements for *Render->accept()
if (! isset($request['mass_values'][$index]))
{
continue;
}
$_REQUEST['new_values'] = $request['mass_values'][$index];
@ -41,7 +43,9 @@ foreach ($request['dn'] as $index => $dn) {
$render->accept(true);
if ($render->getTemplate()->getLDAPmodify(false,$index))
{
$request['update'][$index] = $render;
}
}
# We can use the $render to give us a title
@ -57,9 +61,13 @@ if (count($request['update'])) {
$result = $app['server']->modify($template->getDN(),$template->getLDAPmodify(false,$index));
if ($result)
printf('%s: <b>%s</b><br>',$template->getDN(),_('Modification successful!'));
{
printf('%s: <b>%s</b><br>', $template->getDN(), _('Modification successful!'));
}
else
printf('%s: <b>%s</b><br>',$template->getDN(),_('Modification NOT successful!'));
{
printf('%s: <b>%s</b><br>', $template->getDN(), _('Modification NOT successful!'));
}
}
} else {
@ -69,7 +77,9 @@ if (count($request['update'])) {
echo '<input type="hidden" name="confirm" value="1" />';
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 '<tr><td>';
@ -117,13 +127,17 @@ if (count($request['update'])) {
foreach ($attribute->getValues() as $key => $value) {
# For multiple values, we'll highlight the changed ones
if ((count($attribute->getValues()) > 5) && in_array($value,$attribute->getAddedValues()))
{
echo '<span style="color:#004400; background:#FFFFA0">';
}
$page->draw('CurrentValue',$attribute,$key);
# For multiple values, close the highlighting
if ((count($attribute->getValues()) > 5) && in_array($value,$attribute->getAddedValues()))
{
echo '</span>';
}
echo '<br />';
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;">';
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) {
# For multiple values, we'll highlight the changed ones
if ((count($attribute->getOldValues()) > 5) && in_array($value,$attribute->getRemovedValues()) && count($attribute->getValues()))
{
echo '<span style="color:#880000; background:#FFFFA0">';
}
$page->draw('OldValue',$attribute,$key);
# For multiple values, close the highlighting
if ((count($attribute->getOldValues()) > 5) && in_array($value,$attribute->getRemovedValues()) && count($attribute->getValues()))
{
echo '</span>';
}
echo '<br />';
}

View File

@ -22,9 +22,13 @@ $request['page']->accept(true);
$request['template'] = $request['page']->getTemplate();
if (! is_null($request['dn']))
{
$rdn = get_rdn($request['dn']);
}
else
$rdn = null;
{
$rdn = NULL;
}
# Get all current group members
$current_members = $app['server']->getDNAttrValue($request['dn'],$request['attr']);
@ -63,9 +67,13 @@ printf('%s <b>%s</b> %s <b>%s</b>:',
$possible_members = array();
for ($i=0;$i<count($possible_values);$i++) {
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
$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.
@ -82,9 +90,12 @@ echo '<br />';
echo '<form action="cmd.php" method="post" class="add_value" id="member">';
echo '<div>';
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
{
echo '<input type="hidden" name="cmd" value="update" />';
}
echo '</div>';
echo '<table class="modify_members">';
@ -107,7 +118,9 @@ switch ($request['attr']) {
$possible = sprintf('(,%s,)',$matches[1]);
if (! in_array($possible,$current_members))
printf('<option>%s</option>',$possible);
{
printf('<option>%s</option>', $possible);
}
}
break;
@ -115,7 +128,9 @@ switch ($request['attr']) {
case ('memberuid' || 'member' || 'uniquemember'):
foreach ($possible_members as $possible) {
if (! in_array($possible,$current_members))
printf('<option>%s</option>',$possible);
{
printf('<option>%s</option>', $possible);
}
}
break;
@ -129,7 +144,9 @@ echo '<td>';
echo '<select name="members" size="10" multiple="multiple">';
foreach ($current_members as $current)
printf('<option>%s</option>',htmlspecialchars($current));
{
printf('<option>%s</option>', htmlspecialchars($current));
}
echo '</select>';
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.
* update_confirm.php will see this as old_values[member-attribute][item] */
for ($i=0; $i<count($current_members); $i++)
{
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.
* 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);
if (! isset($attrs['monitorcontext']) || ! count($results))
{
system_message(array(
'title'=>_('Monitoring context does not exist'),
'body'=>sprintf('%s: <b>%s</b>',_('Could not obtain the monitor context for this server'),$app['server']->getName()),
'type'=>'warn'),'index.php');
'title' => _('Monitoring context does not exist'),
'body' => sprintf('%s: <b>%s</b>', _('Could not obtain the monitor context for this server'), $app['server']->getName()),
'type' => 'warn'), 'index.php');
}
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'));
@ -67,7 +69,9 @@ foreach (array(
printf('<td style="width: 10%%;">%s</td><td style="width: 20%%;">%s</td>',_('Type'),'namingContext');
foreach ($attrs as $attr)
printf('<td style="width: 20%%;">%s</td>',$attr);
{
printf('<td style="width: 20%%;">%s</td>', $attr);
}
echo '</tr>';
@ -83,12 +87,17 @@ foreach (array(
$seealso = is_array($results[$key]['seealso']) ? $results[$key]['seealso'] : array($results[$key]['seealso']);
foreach ($seealso as $db)
{
if (isset($results[$db]['namingcontexts']))
{
printf('<acronym title="%s">%s</acronym><br/>',
isset($results[$db]['labeleduri']) ? implode(' ',$results[$db]['labeleduri']) : _('Internal'),
implode(' ',$results[$db]['namingcontexts']));
else
printf('%s ',implode(' ',$results[$db]['monitoredinfo']));
isset($results[$db]['labeleduri']) ? implode(' ', $results[$db]['labeleduri']) : _('Internal'),
implode(' ', $results[$db]['namingcontexts']));
} else
{
printf('%s ', implode(' ', $results[$db]['monitoredinfo']));
}
}
} else {
echo '&nbsp;';
@ -99,20 +108,29 @@ foreach (array(
echo '<td>';
if (isset($results[$key][$attr])) {
if (! is_array($results[$key][$attr]))
{
$sc = array($results[$key][$attr]);
}
else
{
$sc = $results[$key][$attr];
}
if (strcasecmp('supportedcontrol',$attr) == 0)
foreach ($sc as $control) {
{
foreach ($sc as $control)
{
$oidtotext = support_oid_to_text($control);
printf('<acronym title="%s">%s</acronym><br/>',
$control,$oidtotext['title']);
$control, $oidtotext['title']);
}
}
else
printf('%s ',implode('<br/>',$sc));
{
printf('%s ', implode('<br/>', $sc));
}
} else {
echo '&nbsp;';
@ -207,14 +225,20 @@ foreach (array(
echo '<table class="result_table" border="0" width="100%">';
if (isset($results[$dn]['monitoropinitiated']))
{
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']))
{
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']))
{
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
foreach ($results as $key => $value) {

View File

@ -56,9 +56,13 @@ if ($request['action'] == 'compare') {
echo '&nbsp;&nbsp;&nbsp;&nbsp;<b>';
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
printf('<span class="bad">%s</span>',_('Passwords do not match!'));
{
printf('<span class="bad">%s</span>', _('Passwords do not match!'));
}
echo '</b>';
}

View File

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

View File

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

View File

@ -17,9 +17,13 @@ if (get_request('purge','REQUEST')) {
del_cached_item($app['server']->getIndex(),'tree');
if ($tree)
{
$openDNs = $tree->listOpenItems();
}
else
{
$openDNs = array();
}
$tree = Tree::getInstance($app['server']->getIndex());
@ -37,10 +41,14 @@ if (get_request('purge','REQUEST')) {
set_cached_item($app['server']->getIndex(),'tree','null',$tree);
}
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()));
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()));
}
else
header(sprintf('Location: cmd.php?server_id=%s',$app['server']->getIndex()));
{
header(sprintf('Location: cmd.php?server_id=%s', $app['server']->getIndex()));
}
die();

View File

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

View File

@ -25,7 +25,9 @@ if (! count($attrs)) {
echo '<table class="result" border="0">';
foreach ($attrs as $key => $values) {
if ($key == 'dn')
{
continue;
}
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));
} else
{
echo $key;
}
echo '</td></tr>';
@ -45,41 +49,56 @@ foreach ($attrs as $key => $values) {
echo '<table class="result" border="0">';
if (is_array($values))
foreach ($values as $value) {
{
foreach ($values as $value)
{
$oidtext = '';
print '<tr>';
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>',
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>',
IMGDIR,$value,htmlspecialchars($value));
if ($oidtext = support_oid_to_text($value))
{
if (isset($oidtext['ref']))
printf('<td><acronym title="%s">%s</acronym></td>',$oidtext['ref'],$oidtext['title']);
else
printf('<td>%s</td>',$oidtext['title']);
else
{
printf('<td><acronym title=' % s'>%s</acronym></td>',$oidtext['ref'],$oidtext['title']); } else
{
printf('<td>%s</td>', $oidtext['title']);
}
} else
if (strlen($value) > 0)
printf('<td><small>%s</small></td>',$value);
{
printf('<td><small>%s</small></td>', $value);
}
} else {
printf('<td rowspan="2" colspan="2">%s</td>',$value);
} else
{
printf('<td rowspan='2' colspan='2'>%s</td>',$value);
}
print '</tr>';
if (isset($oidtext['desc']) && trim($oidtext['desc']))
printf('<tr><td><small>%s</small></td></tr>',$oidtext['desc']);
else
{
printf('<tr><td><small>%s</small></td></tr>', $oidtext['desc']);
} else
{
echo '<tr><td>&nbsp;</td></tr>';
}
if ($oidtext)
echo '<tr><td colspan="2">&nbsp;</td></tr>';
{
echo '<tr><td colspan='2'>&nbsp;</td></tr>'; }
}
}
else
printf('<tr><td colspan="2">%s&nbsp;</td></tr>',$values);
{
printf('<tr><td colspan="2">%s&nbsp;</td></tr>', $values);
}
echo '</table>';

View File

@ -16,9 +16,13 @@ $request['key'] = get_request('key','REQUEST');
$request['index'] = get_request('index','REQUEST');
if (get_request('global','REQUEST'))
{
$request['dumpvar'] = &$GLOBALS;
}
else
{
$request['dumpvar'] = &$_SESSION;
}
if (isset($request['index']) && isset($request['key'])) {
list($request['server'],$request['x']) = explode(':',$request['index']);
@ -26,24 +30,32 @@ if (isset($request['index']) && isset($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')) {
echo '<div style="font-size: 11px"><ul>';
foreach (array_keys($request['dumpvar']) as $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) {
$index = sprintf('%s:%s',$server,$x);
{
foreach (array_keys($request['dumpvar'][$key]) as $server)
{
foreach (array_keys($request['dumpvar'][$key][$server]) as $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>',
$key.$index,$key,$index,$key.'.'.$index,$key.$index,$key.$index);
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);
}
}
}
}
else
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);
{
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);
}
}
echo '</ul></div>';
}

View File

@ -49,7 +49,9 @@ if ($request['dn']) {
} else {
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']->accept();

View File

@ -24,7 +24,9 @@ if (get_request('cancel','REQUEST')) {
}
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']->setDN($request['dn']);
@ -46,7 +48,9 @@ if ($result) {
in_array($app['server']->getValue('login','auth_type'),array('cookie','session')) &&
pla_compare_dns($app['server']->getLogin(),$request['dn']) === 0)
$mustRelogin = true;
{
$mustRelogin = TRUE;
}
}
# If the user password was changed, not tell the to relogin.
@ -67,10 +71,14 @@ if ($result) {
$app['server']->getIndex(),$request['template']->getDNEncode());
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')
{
$redirect_url .= '&meth=ajax';
}
header("Location: $redirect_url");
die();

View File

@ -20,7 +20,9 @@ $request = array();
$request['dn'] = get_request('dn','REQUEST',true);
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']->setDN($request['dn']);
@ -69,19 +71,24 @@ if (count($request['template']->getLDAPmodify(true))) {
echo '<td><span style="white-space: nowrap;">';
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();
foreach ($attribute->getOldValues() as $key => $value) {
# For multiple values, we'll highlight the changed ones
if ($x = ((count($attribute->getOldValues()) > 5) && count($attribute->getValues()) && in_array($value,$dv)))
{
echo '<span style="color:#880000; background:#FFFFA0">';
}
$request['page']->draw('OldValue',$attribute,$key);
# For multiple values, close the highlighting
if ($x)
{
echo '</span>';
}
echo '<br />';
}
@ -92,19 +99,25 @@ if (count($request['template']->getLDAPmodify(true))) {
echo '<td><span style="white-space: nowrap;">';
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();
foreach ($attribute->getValues() as $key => $value) {
# For multiple values, we'll highlight the changed ones
if ($x = ((count($attribute->getValues()) > 5) && count($attribute->getOldValues()) && in_array($value,$dv)))
{
echo '<span style="color:#004400; background:#FFFFA0">';
}
$request['page']->draw('CurrentValue',$attribute,$key);
# For multiple values, close the highlighting
if ($x)
{
echo '</span>';
}
echo '<br />';
}
@ -116,7 +129,9 @@ if (count($request['template']->getLDAPmodify(true))) {
$input_onclick = '';
if ($attribute->isForceDelete() || (in_array($attribute->getName(),$mustattrs)) && $request['template']->getAttribute('objectclass')->justModified())
{
$input_disabled = 'disabled="disabled"';
}
if ($attribute->getName() == 'objectclass') {
$input_onclick = '';
@ -129,7 +144,9 @@ if (count($request['template']->getLDAPmodify(true))) {
foreach ($request['template']->getForceDeleteAttrs() as $ad_name) {
# Only if it is not a must attr by this objectclass now staying
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 .= "\n";
@ -149,15 +166,21 @@ if (count($request['template']->getLDAPmodify(true))) {
# If the attributes arent force deleted...
if ($input_onclick)
{
$input_onclick .= 'if (this.checked) {';
}
else
{
$input_onclick = 'onclick="if (this.checked) {';
}
# IE: There are new objectclasses that result in new values.
foreach ($request['template']->getLDAPmodify(true) as $skipattr) {
if (! $skipattr->getOldValues()) {
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 .= "\n";
@ -169,7 +192,9 @@ if (count($request['template']->getLDAPmodify(true))) {
foreach ($request['template']->getLDAPmodify(true) as $skipattr) {
if (! $skipattr->getOldValues()) {
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 .= "\n";
@ -212,7 +237,9 @@ if (count($request['template']->getLDAPmodify(true))) {
$i = 0;
foreach ($request['template']->getForceDeleteAttrs() as $attribute) {
if ($i++ != 0)
{
echo '</b>, <b>';
}
echo $_SESSION[APPCONFIG]->getFriendlyHTML($attribute);
}
@ -227,10 +254,14 @@ if (count($request['template']->getLDAPmodify(true))) {
echo _('You made no changes');
if (isAjaxEnabled())
{
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
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>';
}
@ -244,8 +275,12 @@ function getMustAttrs($oclasses) {
$soc = $app['server']->getSchemaObjectClass($value);
if ($soc)
{
foreach ($soc->getMustAttrs() as $sma)
array_push($mustattrs,$sma->getName());
{
array_push($mustattrs, $sma->getName());
}
}
}
return $mustattrs;

View File

@ -64,11 +64,15 @@ if (! isset($jpeg_data[$request['attr']][$request['index']])) {
}
if (! is_array($jpeg_data[$request['attr']]))
{
$jpeg_data[$request['attr']] = array($jpeg_data[$request['attr']]);
}
$obStatus = ob_get_status();
if (isset($obStatus['type']) && $obStatus['type'] && $obStatus['status'])
{
ob_end_clean();
}
header(sprintf('Content-type: %s',$request['type']));
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) {
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();
@ -33,13 +35,19 @@ class AJAXTree extends HTMLTree {
if (is_string($level)) {
for ($i=0; $i<strlen($level); $i++) {
if ($level[$i] == '0')
{
$code .= '0';
}
elseif ($level[$i] == '1')
{
$code .= '1';
}
}
} elseif ($level > 0)
{
$code = '0' * $level;
}
$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 (! $entry)
{
return '';
}
# Get our children.
$child_count = $this->readChildrenNumber($entry->getDN());
$nb = 0;
if ($first_child)
$nb += 1;
{
++$nb;
}
if ($last_child)
{
$nb += 2;
}
$imgs['expand'] = array('tree_expand.png','tree_expand.png','tree_expand_corner.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);
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);
echo $this->get_indentation($code);
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 {
printf('<a href="#" onclick="return opencloseTreeNode(\'%s\',\'%s\',\'%s\');">',$node_id,$parms['openclose'],IMGDIR);
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
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>';
}
@ -124,12 +146,16 @@ class AJAXTree extends HTMLTree {
printf('<div id="jt%sson" style="display: %s" class="treemenudiv">',$node_id,($entry->isOpened() ? 'block' : 'none'));
if ($entry->isOpened())
$this->draw_children($entry,$code.$new_code[$nb]);
{
$this->draw_children($entry, $code . $new_code[$nb]);
}
echo '</div>';
if ($level == 0)
{
echo '</td></tr>';
}
}
/**
@ -139,13 +165,17 @@ class AJAXTree extends HTMLTree {
*/
public function draw_children($parent_entry,$code) {
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();
foreach ($parent_entry->getChildren() as $child) {
if (! $this->getEntry($child))
{
$this->addEntry($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 (function_exists('isCompress') && isCompress() && get_request('cmd','REQUEST') == 'draw_tree_node')
{
ob_start();
}
echo $first_child;
@ -164,9 +196,13 @@ class AJAXTree extends HTMLTree {
$last = ($i == (count($children)-1)) && (! $last_child);
if (is_object($children[$i]))
$this->draw_item($children[$i]->getDN(),$code,$first,$last);
{
$this->draw_item($children[$i]->getDN(), $code, $first, $last);
}
else
{
echo '<br/>problem getting DN entry from ldap';
}
echo "\n";
}
@ -187,7 +223,9 @@ class AJAXTree extends HTMLTree {
*/
protected function get_indentation($code) {
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 = '';
@ -211,7 +249,9 @@ class AJAXTree extends HTMLTree {
*/
protected function draw_javascript() {
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();
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) {
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)
{
return '';
}
$server = $this->getServer();
$output = '';
if (! $server->isReadOnly() && ! $entry->isLeaf() && (count($entry->getChildren()) > 10) && $this->getServer()->isShowCreateEnabled()
&& $_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;
}
@ -249,16 +295,22 @@ class AJAXTree extends HTMLTree {
*/
private function create_after_child($entry,$level) {
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)
{
return '';
}
$server = $this->getServer();
$output = '';
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;
}
@ -272,7 +324,9 @@ class AJAXTree extends HTMLTree {
*/
private function draw_create_new_entry($entry,$level,$img) {
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 = '';
@ -286,11 +340,15 @@ class AJAXTree extends HTMLTree {
$output .= '&nbsp;';
if (isAjaxEnabled())
{
$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),_('Loading'));
htmlspecialchars($href), _('Create new entry here'),
htmlspecialchars($href), _('Loading'));
}
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 .= '</a>';
@ -305,13 +363,19 @@ class AJAXTree extends HTMLTree {
*/
public function listOpenItems() {
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();
foreach ($this->entries as $dn => $value)
{
if ($value->isOpened())
array_push($result,$value->getDN());
{
array_push($result, $value->getDN());
}
}
return $result;
}

File diff suppressed because it is too large Load Diff

View File

@ -26,10 +26,12 @@ class AttributeFactory {
default:
if (! $_SESSION[APPCONFIG]->getValue('appearance','hide_template_warning'))
{
system_message(array(
'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']),
'type'=>'warn'));
'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']),
'type' => 'warn'));
}
unset($values['post']);
}
@ -38,16 +40,23 @@ class AttributeFactory {
# Check our helper functions exists
if (isset($values['helper']['value']) && ! is_array($values['helper']['value']))
if (preg_match('/^=php\.(\w+)\((.*)\)$/',$values['helper']['value'],$matches))
if (! in_array($matches[1],array('GetNextNumber','PasswordEncryptionTypes'))) {
if (! $_SESSION[APPCONFIG]->getValue('appearance','hide_template_warning'))
{
if (preg_match('/^=php\.(\w+)\((.*)\)$/', $values['helper']['value'], $matches))
{
if ( ! in_array($matches[1], array('GetNextNumber', 'PasswordEncryptionTypes')))
{
if ( ! $_SESSION[APPCONFIG]->getValue('appearance', 'hide_template_warning'))
{
system_message(array(
'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']),
'type'=>'warn'));
'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']),
'type' => 'warn'));
}
unset($values['helper']['value']);
}
}
}
# 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'])) {
@ -55,7 +64,9 @@ class AttributeFactory {
switch ($matches[1]) {
case 'MultiList':
if (! isset($values['type']))
{
$values['type'] = 'multiselect';
}
case 'PickList':
return $this->newSelectionAttribute($name,$values,$server_id,$source);
@ -70,10 +81,12 @@ class AttributeFactory {
default:
if (! $_SESSION[APPCONFIG]->getValue('appearance','hide_template_warning'))
{
system_message(array(
'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']),
'type'=>'warn'));
'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']),
'type' => 'warn'));
}
unset($values['value']);
}
@ -81,20 +94,26 @@ class AttributeFactory {
}
if (isset($values['type']))
switch ($values['type']) {
{
switch ($values['type'])
{
case 'password':
if (! strcasecmp($name,'sambaLMPassword') || ! strcasecmp($name,'sambaNTPassword'))
return $this->newSambaPasswordAttribute($name,$values,$server_id,$source);
else
return $this->newPasswordAttribute($name,$values,$server_id,$source);
if ( ! strcasecmp($name, 'sambaLMPassword') || ! strcasecmp($name, 'sambaNTPassword'))
{
return $this->newSambaPasswordAttribute($name, $values, $server_id, $source);
} else
{
return $this->newPasswordAttribute($name, $values, $server_id, $source);
}
case 'multiselect':
case 'select':
return $this->newSelectionAttribute($name,$values,$server_id,$source);
return $this->newSelectionAttribute($name, $values, $server_id, $source);
case 'textarea':
return $this->newMultiLineAttribute($name,$values,$server_id,$source);
return $this->newMultiLineAttribute($name, $values, $server_id, $source);
}
}
if (! strcasecmp($name,'objectClass')) {
return $this->newObjectClassAttribute($name,$values,$server_id,$source);

View File

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

View File

@ -26,14 +26,18 @@ class HTMLTree extends Tree {
*/
public function draw($onlytree=false) {
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;
$server = $this->getServer();
echo '<table class="tree" border="0">';
if (! $onlytree)
{
$this->draw_server_name();
}
$this->javascript = '';
$javascript_id = 0;
@ -46,14 +50,22 @@ class HTMLTree extends Tree {
$this->draw_menu();
if ($server->getAuthType() != 'config')
{
$this->draw_logged_in_user();
}
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())
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
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">',
$_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>';
if (! $onlytree)
{
echo '</div></td></tr>';
}
echo '</table>';
return;
@ -107,11 +121,15 @@ class HTMLTree extends Tree {
$this->javascript .= sprintf('</form>');
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>',
$this->getDepth()+3-3,_('This base cannot be created with PLA.'));
$this->getDepth() + 3 - 3, _('This base cannot be created with PLA.'));
}
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>',
$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 {
$this->draw_item($base->getDN(),-1);
@ -121,7 +139,9 @@ class HTMLTree extends Tree {
echo '</table>';
if (! $onlytree)
{
echo '</div></td></tr>';
}
# We are not logged in, draw a login... link.
} else {
@ -157,7 +177,9 @@ class HTMLTree extends Tree {
*/
protected function draw_server_name() {
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();
@ -179,15 +201,22 @@ class HTMLTree extends Tree {
*/
protected function draw_menu() {
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 = '';
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))
$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.
$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) {
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();
$menu = array();
@ -215,7 +246,9 @@ class HTMLTree extends Tree {
switch($item) {
case 'schema':
if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','schema'))
{
return '';
}
$menu['cmd'] = 'schema';
$menu['ajax'] = _('Loading Schema');
@ -228,7 +261,9 @@ class HTMLTree extends Tree {
case 'search':
if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','query_engine'))
{
return '';
}
$menu['cmd'] = 'query_engine';
$menu['ajax'] = _('Loading Search');
@ -241,7 +276,9 @@ class HTMLTree extends Tree {
case 'refresh':
if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','refresh'))
{
return '';
}
$menu['cmd'] = 'refresh';
$menu['href'] = '&noheader=1&purge=1';
@ -255,7 +292,9 @@ class HTMLTree extends Tree {
case 'server_info':
if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','server_info'))
{
return '';
}
$menu['cmd'] = 'server_info';
$menu['ajax'] = _('Loading Info');
@ -268,11 +307,15 @@ class HTMLTree extends Tree {
case 'monitor':
if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','monitor'))
{
return '';
}
$attrs = $server->getRootDSE();
if (! $attrs || ! isset($attrs['monitorcontext']))
{
return '';
}
$menu['cmd'] = 'monitor';
$menu['ajax'] = _('Loading Monitor Info');
@ -285,7 +328,9 @@ class HTMLTree extends Tree {
case 'import':
if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','import_form') || ! $_SESSION[APPCONFIG]->isCommandAvailable('script','import') || $server->isReadOnly())
{
return '';
}
$menu['cmd'] = 'import_form';
$menu['ajax'] = _('Loading Import');
@ -298,7 +343,9 @@ class HTMLTree extends Tree {
case 'export':
if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','export_form') || ! $_SESSION[APPCONFIG]->isCommandAvailable('script','export'))
{
return '';
}
$menu['cmd'] = 'export_form';
$menu['ajax'] = _('Loading Export');
@ -316,25 +363,35 @@ class HTMLTree extends Tree {
$href_parms = htmlspecialchars(sprintf('cmd=%s&server_id=%s%s',$menu['cmd'],$server->getIndex(),isset($menu['href']) ? $menu['href'] : ''));
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>',
$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
{
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() {
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();
$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')))
{
return '';
}
else
{
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'));
}
}
/**
@ -342,7 +399,9 @@ class HTMLTree extends Tree {
*/
protected function draw_logged_in_user() {
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();
@ -362,28 +421,39 @@ class HTMLTree extends Tree {
$bases = $server->getContainerTop($logged_in_dn);
if (is_array($bases) && count($bases))
array_push($logged_in_dn_array,$bases);
{
array_push($logged_in_dn_array, $bases);
}
$rdn = $logged_in_dn;
# Some sanity checking here, in case our DN doesnt look like a DN
if (! is_array($logged_in_dn_array))
{
$logged_in_dn_array = array($logged_in_dn);
}
if (trim($logged_in_dn)) {
if ($server->dnExists($logged_in_dn))
foreach ($logged_in_dn_array as $rdn_piece) {
$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));
{
foreach ($logged_in_dn_array as $rdn_piece)
{
$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));
if ($rdn_piece != end($logged_in_dn_array))
{
echo ',';
}
$rdn = substr($rdn,(1 + strpos($rdn,',')));
$rdn = substr($rdn, (1 + strpos($rdn, ',')));
}
}
else
{
echo $logged_in_dn;
}
} else {
echo 'Anonymous';
@ -401,7 +471,9 @@ class HTMLTree extends Tree {
*/
protected function draw_item($item,$level) {
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();
@ -416,7 +488,9 @@ class HTMLTree extends Tree {
# If the entry doesnt exist in the server, then return here with an empty string.
if (! $entry)
{
return;
}
# Get our children.
$child_count = $this->readChildrenNumber($item);
@ -432,15 +506,24 @@ class HTMLTree extends Tree {
# Is this node expanded? (deciding whether to draw "+" or "-")
if ($entry->isOpened())
if (! $child_count && ! $this->getServer()->isShowCreateEnabled())
printf('<td class="expander"><img src="%s/minus.png" alt="-" /></td>',IMGDIR);
else
printf('<td class="expander"><a href="%s"><img src="%s/minus.png" alt="-" /></a></td>',$href['collapse'],IMGDIR);
{
if ( ! $child_count && ! $this->getServer()->isShowCreateEnabled())
{
printf('<td class="expander"><img src="%s/minus.png" alt="-" /></td>', IMGDIR);
} else
{
printf('<td class="expander"><a href="%s"><img src="%s/minus.png" alt="-" /></a></td>', $href['collapse'], IMGDIR);
}
}
else
if (($child_count !== false) && (! $child_count) && (! $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
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>',
$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));
if ($child_count)
printf(' <span class="count">(%s)</span>',$child_count);
{
printf(' <span class="count">(%s)</span>', $child_count);
}
echo '</span></td></tr>';
@ -464,7 +549,9 @@ class HTMLTree extends Tree {
}
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
if (! $server->isReadOnly() && ! $entry->isLeaf() && $this->getServer()->isShowCreateEnabled()) {
@ -473,17 +560,25 @@ class HTMLTree extends Tree {
}
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) {
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)
{
return pretty_print_dn($entry->getDN());
}
else
return draw_formatted_dn($this->getServer(),$entry);
{
return draw_formatted_dn($this->getServer(), $entry);
}
}
/**
@ -495,7 +590,9 @@ class HTMLTree extends Tree {
*/
protected function draw_create_link($rdn,$level,$encoded_dn) {
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.
$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() {
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();
$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() {
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) {
echo "<!-- Forms for javascript submit to call to create base_dns -->\n";
@ -557,13 +658,17 @@ class HTMLTree extends Tree {
*/
public function getDepth() {
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();
# If we are not logged in
if (! $server->isLoggedIn(null))
{
return 0;
}
static $depths = array();
@ -577,7 +682,9 @@ class HTMLTree extends Tree {
$depth = count(pla_explode_dn($dn->getDN()))+1-$basedepth;
if ($depth > $max)
{
$max = $depth;
}
}
$depths[$server->getIndex()] = $max;

View File

@ -14,12 +14,15 @@
*/
class MassRender extends TemplateRender {
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);
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/>',
$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) {
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();
foreach ($xmldata['query'] as $xml_key => $xml_value) {
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) {
# Build our attribute list from the DN and Template.
case ('attributes'):
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])) {
foreach ($xmldata['query'][$xml_key] as $tattrs) {
foreach ($tattrs as $index => $details) {
if (DEBUG_ENABLED)
debug_log('Foreach tattrs Key [%s] Value [%s]',4,0,__FILE__,__LINE__,__METHOD__,
$index,$details);
{
debug_log('Foreach tattrs Key [%s] Value [%s]', 4, 0, __FILE__, __LINE__, __METHOD__,
$index, $details);
}
# If there is no schema definition for the attribute, it will be ignored.
if ($sattr = $server->getSchemaAttribute($index)) {
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->setXML($details);
@ -63,20 +73,29 @@ class Query extends xmlTemplate {
# Build our bases list from the DN and Template.
case ('bases'):
if (isset($xmldata['query'][$xml_key]['base']))
{
if (is_array($xmldata['query'][$xml_key]['base']))
{
$this->base = $xmldata['query'][$xml_key]['base'];
else
} else
{
$this->base = array($xmldata['query'][$xml_key]['base']);
}
}
else
{
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);
break;
default:
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:
$allowed_arrays = array('');
@ -85,15 +104,24 @@ class Query extends xmlTemplate {
# Items that must be stored lowercase
if (in_array($xml_key,$storelower))
{
if (is_array($xml_value))
{
foreach ($xml_value as $index => $value)
{
$xml_value[$index] = strtolower($value);
else
}
} else
{
$xml_value = strtolower($xml_value);
}
}
# Items that must be stored as arrays
if (in_array($xml_key,$storearray) && ! is_array($xml_value))
{
$xml_value = array($xml_value);
}
# Items that should not be an array
if (! in_array($xml_key,$allowed_arrays) && is_array($xml_value)) {
@ -122,7 +150,9 @@ class Query extends xmlTemplate {
*/
public function accept() {
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();
@ -140,9 +170,13 @@ class Query extends xmlTemplate {
$attrs = preg_replace('/\s+/','',$attrs);
if ($attrs)
$query['attrs'] = explode(',',$attrs);
{
$query['attrs'] = explode(',', $attrs);
}
else
{
$query['attrs'] = array('*');
}
} else {
$bases = $this->base;
@ -152,9 +186,13 @@ class Query extends xmlTemplate {
}
if (! $bases)
{
$bases = $server->getBaseDN();
}
elseif (! is_array($bases))
$bases = explode('|',$bases);
{
$bases = explode('|', $bases);
}
foreach ($bases as $base) {
$query['base'] = $base;
@ -169,9 +207,13 @@ class Query extends xmlTemplate {
$this->resultsdata[$base]['attrs'] = $query['attrs'];
if ($this->getAttrSortOrder() == 'dn')
usort($this->results[$base],'pla_compare_dns');
{
usort($this->results[$base], 'pla_compare_dns');
}
elseif ($this->getAttrSortOrder())
masort($this->results[$base],$this->getAttrSortOrder());
{
masort($this->results[$base], $this->getAttrSortOrder());
}
}
}
@ -181,7 +223,9 @@ class Query extends xmlTemplate {
*/
public function setDN($dn) {
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;
}
@ -191,7 +235,9 @@ class Query extends xmlTemplate {
*/
public function getDN() {
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;
}
@ -199,14 +245,20 @@ class Query extends xmlTemplate {
public function getDNEncode($url=true) {
// @todo Be nice to do all this in 1 location
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
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() {
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();
@ -214,13 +266,17 @@ class Query extends xmlTemplate {
masort($this->attributes,'ordersort');
foreach ($this->attributes as $attribute)
array_push($result,$attribute->getName());
{
array_push($result, $attribute->getName());
}
} else {
$display = preg_replace('/,\s+/',',',get_request('orderby','REQUEST',false,'dn'));
if (trim($display))
$result = explode(',',$display);
{
$result = explode(',', $display);
}
}
return implode(',',$result);
@ -228,7 +284,9 @@ class Query extends xmlTemplate {
public function getAttrDisplayOrder() {
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();
@ -236,20 +294,28 @@ class Query extends xmlTemplate {
masort($this->attributes,'order');
foreach ($this->attributes as $attribute)
array_push($result,$attribute->getName());
{
array_push($result, $attribute->getName());
}
} else {
$display = preg_replace('/,\s+/',',',get_request('display_attrs','REQUEST',false,''));
if (trim($display))
$result = explode(',',$display);
{
$result = explode(',', $display);
}
}
# If our display order is empty, then dynamically build it
if (! count($result)) {
foreach ($this->results as $details)
{
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);
sort($result);
@ -269,14 +335,18 @@ class Query extends xmlTemplate {
*/
public function isVisible() {
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;
}
public function getDescription() {
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;
}

View File

@ -19,18 +19,31 @@ class QueryRender extends PageRender {
*/
public function accept() {
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||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'));
if (DEBUGTMP)
{
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->page = get_request('page','REQUEST',false,1);
# If we are the default template, make sure we pressed search
if ($this->template_id == 'none' && ! get_request('search','REQUEST'))
{
$this->drawTemplateChoice();
}
elseif ($this->template_id) {
$templates = $this->getTemplates();
@ -47,7 +60,9 @@ class QueryRender extends PageRender {
*/
protected function getTemplates() {
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);
}
@ -57,18 +72,27 @@ class QueryRender extends PageRender {
*/
protected function haveDefaultTemplate() {
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();
if ($server->getValue('query','disable_default'))
return false;
{
return FALSE;
}
else
return true;
{
return TRUE;
}
}
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();
@ -97,13 +121,17 @@ class QueryRender extends PageRender {
echo '<td>';
echo '<select name="query">';
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)
{
printf('<option value="%s" %s>%s</option>',
$template->getID(),
($this->template_id == $template->getID() ? 'selected="selected"' : ''),
$template->getDescription());
}
echo '</select>';
echo '</td>';
echo '</tr>';
@ -212,7 +240,9 @@ class QueryRender extends PageRender {
private function visitStart() {
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->drawSubTitle();
@ -221,7 +251,9 @@ class QueryRender extends PageRender {
private function visitEnd() {
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();
$afattrs = $this->getAFattrs();
@ -243,7 +275,9 @@ class QueryRender extends PageRender {
$counter++;
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">',
$this->getAjaxRef($base), ($show == $this->getAjaxRef($base) ? 'block' : 'none'));
@ -284,18 +318,26 @@ class QueryRender extends PageRender {
# Ignore DN, we've already displayed it.
if ($attr == 'dn')
{
continue 2;
}
if (! isset($dndetails[$attr]))
{
continue 2;
}
# Set our object with our values
$afattrs[$attr]->clearValue();
if (is_array($dndetails[$attr]))
{
$afattrs[$attr]->initValue($dndetails[$attr]);
}
else
{
$afattrs[$attr]->initValue(array($dndetails[$attr]));
}
echo '<tr class="list_item">';
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());
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>';
@ -362,7 +406,9 @@ class QueryRender extends PageRender {
# Is mass action 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());
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
$afattrs[$attr]->clearValue();
if (is_array($dndetails[$attr]))
{
$afattrs[$attr]->initValue($dndetails[$attr]);
}
else
{
$afattrs[$attr]->initValue(array($dndetails[$attr]));
}
echo '<td>';
$this->draw('CurrentValues',$afattrs[$attr]);
@ -409,7 +459,9 @@ class QueryRender extends PageRender {
printf('<td colspan="%s">',2+count(explode(',',$ado)));
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 '</tr>';
@ -433,7 +485,9 @@ class QueryRender extends PageRender {
}
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) {
@ -446,7 +500,9 @@ class QueryRender extends PageRender {
$subtitle .= '<br />';
$subtitle .= sprintf('%s: <b>%s</b>',('Query'),$this->template->getID() != 'none' ? $this->template->getTitle() : _('Default'));
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() {
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();
$results = array();
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;
}
private function getAjaxRef($dn) {
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));
}
@ -480,7 +542,9 @@ class QueryRender extends PageRender {
echo 'var $items = new Array();';
$counter = 0;
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 '}</script>';
echo "\n\n";
@ -490,7 +554,9 @@ class QueryRender extends PageRender {
$counter = 0;
foreach ($this->template->results as $base => $results) {
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>',
$this->getAjaxRef($base),
@ -534,10 +600,14 @@ 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));
if (isAjaxEnabled())
{
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
printf('<a href="cmd.php?%s">%s</a>',$query_string,_($f));
{
printf('<a href="cmd.php?%s">%s</a>', $query_string, _($f));
}
}
}

View File

@ -28,9 +28,13 @@ class SelectionAttribute extends Attribute {
}
if (isset($values['type']) && $values['type'] == 'multiselect')
$this->multiple = true;
{
$this->multiple = TRUE;
}
else
$this->multiple = false;
{
$this->multiple = FALSE;
}
}
public function addOption($value,$description) {
@ -39,7 +43,9 @@ class SelectionAttribute extends Attribute {
public function addValue($new_val,$i=-1) {
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);
}

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) {
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;
}
@ -39,9 +41,11 @@ abstract class Tree {
* @param $server_id
* @return object Tree
*/
static public function getInstance($server_id) {
public static function getInstance($server_id) {
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');
@ -49,14 +53,18 @@ abstract class Tree {
$server = $_SESSION[APPCONFIG]->getServer($server_id);
if (! $server)
return null;
{
return NULL;
}
$treeclass = $_SESSION[APPCONFIG]->getValue('appearance','tree');
$tree = new $treeclass($server_id);
# If we are not logged in, just return the empty tree.
if (is_null($server->getLogin(null)))
{
return $tree;
}
foreach ($server->getBaseDN(null) as $base) {
if ($base) {
@ -82,7 +90,9 @@ abstract class Tree {
*/
protected function getServerID() {
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;
}
@ -94,7 +104,9 @@ abstract class Tree {
*/
protected function getServer() {
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);
}
@ -106,13 +118,19 @@ abstract class Tree {
*/
public function getBaseEntries() {
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();
foreach ($this->entries as $details)
if ($details->isBaseDN() AND ((! $this->getServer()->getValue('server','hide_noaccess_base')) OR $details->isInLdap()))
array_push($return,$details);
{
if ($details->isBaseDN() AND (( ! $this->getServer()->getValue('server', 'hide_noaccess_base')) OR $details->isInLdap()))
{
array_push($return, $details);
}
}
return $return;
}
@ -131,12 +149,16 @@ abstract class Tree {
*/
private function indexDN($dn) {
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)));
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;
}
@ -149,14 +171,20 @@ abstract class Tree {
*/
public function getEntry($dn) {
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);
if (isset($this->entries[$dnlower]))
{
return $this->entries[$dnlower];
}
else
return null;
{
return NULL;
}
}
/**
@ -167,7 +195,9 @@ abstract class Tree {
*/
public function addEntry($dn) {
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();
$dnlower = $this->indexDN($dn);
@ -177,16 +207,22 @@ abstract class Tree {
# return;
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)
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->setObjectClasses($server->getDNAttrValue($dn,'objectClass'));
if ((($isleaf = $server->getDNAttrValue($dn,'hassubordinates')) && ! strcasecmp($isleaf[0],'false')))
{
$tree_factory->setLeaf();
}
$this->entries[$dnlower] = $tree_factory;
@ -200,7 +236,9 @@ abstract class Tree {
$parent_dn = $server->getContainer($dn);
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) {
$parent_entry = $this->getEntry($parent_dn);
@ -224,20 +262,26 @@ abstract class Tree {
*/
public function delEntry($dn) {
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();
$dnlower = $this->indexDN($dn);
if (isset($this->entries[$dnlower]))
{
unset($this->entries[$dnlower]);
}
# Delete entry from parent's children as well.
$parent_dn = $server->getContainer($dn);
$parent_entry = $this->getEntry($parent_dn);
if ($parent_entry)
{
$parent_entry->delChild($dn);
}
}
/**
@ -248,7 +292,9 @@ abstract class Tree {
*/
public function renameEntry($dnOLD,$dnNEW) {
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();
$dnlowerOLD = $this->indexDN($dnOLD);
@ -256,7 +302,9 @@ abstract class Tree {
$this->entries[$dnlowerNEW] = $this->entries[$dnlowerOLD];
if ($dnlowerOLD != $dnlowerNEW)
{
unset($this->entries[$dnlowerOLD]);
}
$this->entries[$dnlowerNEW]->rename($dnNEW);
# Update the parent's children
@ -265,11 +313,15 @@ abstract class Tree {
$parent_entry = $this->getEntry($parentNEW);
if ($parent_entry)
{
$parent_entry->addChild($dnNEW);
}
$parent_entry = $this->getEntry($parentOLD);
if ($parent_entry)
{
$parent_entry->delChild($dnOLD);
}
}
/**
@ -280,13 +332,17 @@ abstract class Tree {
*/
public function readChildren($dn,$nolimit=false) {
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();
$dnlower = $this->indexDN($dn);
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['filter'] = $_SESSION[APPCONFIG]->getValue('appearance','tree_filter');
@ -302,28 +358,40 @@ abstract class Tree {
}
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
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);
foreach ($ldap['children'] as $child) {
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()))
{
$this->entries[$dnlower]->addChild($child);
}
}
$this->entries[$dnlower]->readingChildren(false);
if (count($this->entries[$dnlower]->getChildren()) == $ldap['child_limit'])
{
$this->entries[$dnlower]->setSizeLimited();
}
else
{
$this->entries[$dnlower]->unsetSizeLimited();
}
}
/**
@ -334,16 +402,22 @@ abstract class Tree {
*/
protected function readChildrenNumber($dn,$nolimit=false) {
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);
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.
if (! $this->entries[$dnlower]->isLeaf() && ! $this->entries[$dnlower]->getChildren())
$this->readChildren($dn,$nolimit);
{
$this->readChildren($dn, $nolimit);
}
return count($this->entries[$dnlower]->getChildren());
}

View File

@ -40,7 +40,9 @@ class TreeItem {
public function __construct($server_id,$dn) {
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->dn = $dn;
@ -53,7 +55,9 @@ class TreeItem {
*/
public function getDN() {
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;
}
@ -69,7 +73,9 @@ class TreeItem {
*/
public function getRDN() {
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);
}
@ -79,7 +85,9 @@ class TreeItem {
*/
public function setBase() {
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;
}
@ -89,28 +97,36 @@ class TreeItem {
*/
public function isBaseDN() {
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;
}
public function setObjectClasses($oc) {
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;
}
public function getObjectClasses() {
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;
}
public function isInLDAP() {
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;
}
@ -121,7 +137,9 @@ class TreeItem {
*/
public function getChildren() {
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) {
usort($this->children,'pla_compare_dns');
@ -140,7 +158,9 @@ class TreeItem {
*/
public function isChildSorted() {
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;
}
@ -150,7 +170,9 @@ class TreeItem {
*/
public function childSorted() {
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;
}
@ -162,10 +184,14 @@ class TreeItem {
*/
public function addChild($dn) {
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))
{
return;
}
array_push($this->children,$dn);
$this->childsort = true;
@ -178,14 +204,18 @@ class TreeItem {
*/
public function delChild($dn) {
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 the parent hasnt been opened in the tree, then there wont be any children.
$index = array_search($dn,$this->children);
if ($index !== false)
{
unset($this->children[$index]);
}
}
}
@ -196,7 +226,9 @@ class TreeItem {
*/
public function rename($dn) {
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;
}
@ -206,7 +238,9 @@ class TreeItem {
*/
public function isOpened() {
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;
}
@ -216,7 +250,9 @@ class TreeItem {
*/
public function close() {
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;
}
@ -226,7 +262,9 @@ class TreeItem {
*/
public function open() {
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;
}
@ -236,7 +274,9 @@ class TreeItem {
*/
public function setLeaf() {
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;
}
@ -246,7 +286,9 @@ class TreeItem {
*/
public function isLeaf() {
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;
}
@ -257,10 +299,14 @@ class TreeItem {
*/
public function getIcon() {
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)
$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;
}
@ -270,7 +316,9 @@ class TreeItem {
*/
public function setSizeLimited() {
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;
}
@ -280,7 +328,9 @@ class TreeItem {
*/
public function unsetSizeLimited() {
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;
}
@ -290,21 +340,27 @@ class TreeItem {
*/
public function isSizeLimited() {
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;
}
public function setTemplate($template) {
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;
}
public function getTemplate() {
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;
}

View File

@ -23,10 +23,14 @@ abstract class Visitor {
public function __call($method,$args) {
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')))
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();
@ -41,7 +45,8 @@ abstract class Visitor {
while ($class && ! method_exists($this,$call)) {
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);
$call = "$method$fnct$class";
@ -49,18 +54,22 @@ abstract class Visitor {
}
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))
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)) {
$r = call_user_func_array(array($this,$call),$args);
if (isset($r))
return $r;
{
return $r; }
else
return;
{
return; }
} elseif (DEBUG_ENABLED) {
debug_log('Doesnt exist param (%s,%s)',1,0,__FILE__,__LINE__,__METHOD__,$method,$fnct);
@ -76,12 +85,15 @@ abstract class Visitor {
*/
public function getServerID() {
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))
return $this->server_id;
{
return $this->server_id; }
else
return null;
{
return NULL; }
}
/**
@ -91,7 +103,8 @@ abstract class Visitor {
*/
protected function getServer() {
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());
}

View File

@ -320,7 +320,7 @@ class Horde_Cipher_blowfish {
$keyPos = 0;
}
}
$this->p[$i] = $this->p[$i] ^ $keyXor;
$this->p[$i] ^= $keyXor;
}
$encZero = array('L' => 0, 'R' => 0);
@ -438,9 +438,11 @@ class Horde_Cipher_blowfish {
$unpack = unpack('N*', $block);
if (! is_array($unpack))
{
error(
sprintf('BLOWFISH: decryptBock()<br>We expected unpack to produce an array, but instead it produced [%s]. This function was entered with (%s,%s). If you think that this is a bug, then please tell the PLA developers how you got here. You are using PLA [%s,%s]',
serialize($unpack),$block,$key,app_version(),phpversion()),'error','index.php');
serialize($unpack), $block, $key, app_version(), phpversion()), 'error', 'index.php');
}
list($L, $R) = array_values($unpack);

View File

@ -585,14 +585,22 @@ class Config {
static $CACHE = array();
if ($usecache && count($CACHE))
{
return $CACHE;
}
foreach ($this->default as $key => $vals)
{
$CACHE[$key] = $vals;
}
foreach ($this->custom as $key => $vals)
{
foreach ($vals as $index => $val)
{
$CACHE[$key][$index]['value'] = $val;
}
}
return $CACHE;
}
@ -608,17 +616,27 @@ class Config {
$config = $this->getConfigArray();
if (! isset($config[$key]))
{
if ($fatal)
{
error(sprintf('A call was made in [%s] to getValue requesting [%s] that isnt predefined.',
basename($_SERVER['PHP_SELF']),$key),'error',null,true);
else
basename($_SERVER['PHP_SELF']), $key), 'error', NULL, TRUE);
} else
{
return '';
}
}
if (! isset($config[$key][$index]))
{
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 isset($config[$key][$index]['value']) ? $config[$key][$index]['value'] : $config[$key][$index]['default'];
}
@ -630,9 +648,15 @@ class Config {
$result = array();
foreach ($this->default as $option => $details)
{
foreach ($details as $param => $values)
{
if (isset($values['untested']) && $values['untested'])
array_push($result,sprintf('%s.%s',$option,$param));
{
array_push($result, sprintf('%s.%s', $option, $param));
}
}
}
return $result;
}
@ -642,7 +666,9 @@ class Config {
*/
public function CheckCustom() {
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)) {
foreach ($this->custom as $masterkey => $masterdetails) {
@ -650,19 +676,27 @@ class Config {
if (isset($this->default->$masterkey)) {
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) {
# Test that the key is correct.
if (! in_array($key,array_keys($this->default->$masterkey)))
error(sprintf('Error in configuration file, [%s] has not been defined as a configurable variable.',$key),'error',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.
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))
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 {
@ -677,16 +711,22 @@ class Config {
*/
public function getCommandList() {
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);
masort($config['command'],'summary');
if (isset($config['command']) && is_array($config['command']))
{
return $config['command'];
}
else
{
return array();
}
}
/**
@ -696,7 +736,9 @@ class Config {
*/
public function isCommandAvailable($index='cmd') {
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();
array_shift($a);
@ -706,20 +748,30 @@ class Config {
$cmd = $this->getValue('commands',$index);
if (! is_string($a) || ! isset($cmd[$a]))
return false;
{
return FALSE;
}
else
{
return $cmd[$a];
}
}
public function configDefinition($key,$index,$config) {
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))
{
return;
}
if (isset($this->default->$key))
{
$definition = $this->default->$key;
}
$definition[$index] = $config;
$this->default->$key = $definition;
@ -730,7 +782,9 @@ class Config {
*/
private function getFriendlyAttrs() {
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'));
}
@ -744,23 +798,36 @@ class Config {
*/
public function getFriendlyName($attr) {
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;
if (! $friendly_attrs)
{
$friendly_attrs = $this->getFriendlyAttrs();
}
if (! is_object($attr))
{
if (isset($friendly_attrs[$attr]))
{
return $friendly_attrs[$attr];
else
} else
{
return $attr;
}
}
if (isset($friendly_attrs[$attr->getName()]))
{
return $friendly_attrs[$attr->getName()];
}
else
return $attr->getName(false);
{
return $attr->getName(FALSE);
}
}
/**
@ -772,7 +839,9 @@ class Config {
*/
public function haveFriendlyName($attr) {
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);
}
@ -785,13 +854,19 @@ class Config {
*/
public function getFriendlyHTML($attr) {
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))
{
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
return $attr->getName(false);
{
return $attr->getName(FALSE);
}
}
public function setServers($servers) {
@ -808,7 +883,9 @@ class Config {
*/
public function getServerList($visible=true) {
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);
}

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
*/
private function x($i) {
if ($i < 0) return 4294967296 - $i;
else return $i;
if ($i < 0)
{
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);
$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);
}
@ -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++) {
$er = $this->permute($r, $this->perm4, 48);
if ($forw) $erk = $this->mxor($er, $ki[$i]);
else $erk = $this->mxor($er, $ki[15 - $i]);
if ($forw)
{
$erk = $this->mxor($er, $ki[$i]);
}
else
{
$erk = $this->mxor($er, $ki[15 - $i]);
}
for ($j = 0; $j < 8; $j++) {
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);
$r2 = $this->mxor($l, $pcb);
for ($k = 0; $k < 32; $k++) $l[$k] = $r[$k];
for ($k = 0; $k < 32; $k++) $r[$k] = $r2[$k];
for ($k = 0; $k < 32; $k++)
{
$l[$k] = $r[$k];
}
for ($k = 0; $k < 32; $k++)
{
$r[$k] = $r2[$k];
}
}
$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);
}
@ -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[7] = $str[6]&0x7F;
for ($i = 0; $i < 8; $i++) {
$key[$i] = ($key[$i] << 1);
$key[$i] <<= 1;
}
return $key;
}
@ -352,12 +376,19 @@ private $sbox = array(array(array(14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12
*/
public function nthash($password = "") {
if (function_exists('mhash'))
{
if (defined('MHASH_MD4'))
return strtoupper(bin2hex(mhash(MHASH_MD4,iconv('UTF-8','UTF-16LE',$password))));
else
return strtoupper(hash('md4', iconv("UTF-8","UTF-16LE",$password)));
{
return strtoupper(bin2hex(mhash(MHASH_MD4, iconv('UTF-8', 'UTF-16LE', $password))));
} else
{
return strtoupper(hash('md4', iconv("UTF-8", "UTF-16LE", $password)));
}
}
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');
}
}
/**
@ -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) {
$z = 0x80000000;
if ($z & $a) {
$a = ($a >> 1);
$a >>= 1;
$a &= (~$z);
$a |= 0x40000000;
$a = ($a >> ($b - 1));
$a >>= ($b - 1);
}
else {
$a = ($a >> $b);
$a >>= $b;
}
return $a;
}

View File

@ -62,8 +62,12 @@ abstract class DS {
*/
public function setDefaults($defaults) {
foreach ($defaults as $key => $details)
{
foreach ($details as $setting => $value)
{
$this->default->{$key}[$setting] = $value;
}
}
}
public function isDefaultKey($key) {
@ -83,19 +87,29 @@ abstract class DS {
*/
public function getValue($key,$setting,$fatal=true) {
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]))
{
return $this->custom->{$key}[$setting];
}
elseif (isset($this->default->{$key}[$setting]) && array_key_exists('default',$this->default->{$key}[$setting]))
{
return $this->default->{$key}[$setting]['default'];
}
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
return null;
{
return NULL;
}
}
/**
@ -106,11 +120,13 @@ abstract class DS {
*/
public function setValue($key,$setting,$value) {
if (isset($this->custom->{$key}[$setting]))
{
system_message(array(
'title'=>_('Configuration setting already defined.'),
'body'=>sprintf('A call has been made to reset a configuration value (%s,%s,%s)',
$key,$setting,$value),
'type'=>'info'));
'title' => _('Configuration setting already defined.'),
'body' => sprintf('A call has been made to reset a configuration value (%s,%s,%s)',
$key, $setting, $value),
'type' => 'info'));
}
$this->custom->{$key}[$setting] = $value;
}
@ -122,9 +138,15 @@ abstract class DS {
$result = array();
foreach ($this->default as $option => $details)
{
foreach ($details as $param => $values)
{
if (isset($values['untested']) && $values['untested'])
array_push($result,sprintf('%s.%s',$option,$param));
{
array_push($result, sprintf('%s.%s', $option, $param));
}
}
}
return $result;
}
@ -134,7 +156,9 @@ abstract class DS {
*/
public function getName() {
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');
}
@ -147,7 +171,9 @@ abstract class DS {
*/
public function getAuthType() {
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')) {
case 'cookie':
@ -173,45 +199,68 @@ abstract class DS {
*/
public function getLogin($method=null) {
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);
# For anonymous binds
if ($method == 'anon')
{
if (isset($_SESSION['USER'][$this->index][$method]['name']))
{
return '';
else
return null;
} else
{
return NULL;
}
}
switch ($this->getAuthType()) {
case 'cookie':
if (! isset($_COOKIE[$method.'-USER']))
# 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
return blowfish_decrypt($_COOKIE[$method.'-USER']);
{
return blowfish_decrypt($_COOKIE[$method . '-USER']);
}
case 'config':
if (! isset($_SESSION['USER'][$this->index][$method]['name']))
return $this->getValue('login','bind_id');
{
return $this->getValue('login', 'bind_id');
}
else
{
return blowfish_decrypt($_SESSION['USER'][$this->index][$method]['name']);
}
case 'proxy':
if (! isset($_SESSION['USER'][$this->index][$method]['proxy']))
return $this->getValue('login','bind_id');
{
return $this->getValue('login', 'bind_id');
}
else
{
return blowfish_decrypt($_SESSION['USER'][$this->index][$method]['proxy']);
}
case 'http':
case 'session':
case 'sasl':
if (! isset($_SESSION['USER'][$this->index][$method]['name']))
# 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
{
return blowfish_decrypt($_SESSION['USER'][$this->index][$method]['name']);
}
default:
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) {
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);
@ -242,7 +293,9 @@ abstract class DS {
case 'proxy':
if (isset($_SESSION['USER'][$this->index][$method]['proxy']))
{
unset($_SESSION['USER'][$this->index][$method]['proxy']);
}
case 'http':
case 'session':
@ -264,40 +317,59 @@ abstract class DS {
*/
protected function getPassword($method=null) {
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);
# For anonymous binds
if ($method == 'anon')
{
if (isset($_SESSION['USER'][$this->index][$method]['name']))
{
return '';
else
return null;
} else
{
return NULL;
}
}
switch ($this->getAuthType()) {
case 'cookie':
if (! isset($_COOKIE[$method.'-PASS']))
# 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
return blowfish_decrypt($_COOKIE[$method.'-PASS']);
{
return blowfish_decrypt($_COOKIE[$method . '-PASS']);
}
case 'config':
case 'proxy':
if (! isset($_SESSION['USER'][$this->index][$method]['pass']))
return $this->getValue('login','bind_pass');
{
return $this->getValue('login', 'bind_pass');
}
else
{
return blowfish_decrypt($_SESSION['USER'][$this->index][$method]['pass']);
}
case 'http':
case 'session':
case 'sasl':
if (! isset($_SESSION['USER'][$this->index][$method]['pass']))
# 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
{
return blowfish_decrypt($_SESSION['USER'][$this->index][$method]['pass']);
}
default:
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) {
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();
$method = $this->getMethod($method);
if (isset($CACHE[$this->index][$method]) && ! is_null($CACHE[$this->index][$method]))
{
return $CACHE[$this->index][$method];
}
$CACHE[$this->index][$method] = null;
@ -326,10 +402,12 @@ abstract class DS {
switch ($this->getAuthType()) {
case 'config':
if (! $CACHE[$this->index][$method] = $this->login($this->getLogin($method),$this->getPassword($method),$method))
{
system_message(array(
'title'=>_('Unable to login.'),
'body'=>_('Your configuration file has authentication set to CONFIG based authentication, however, the userid/password failed to login'),
'type'=>'error'));
'title' => _('Unable to login.'),
'body' => _('Your configuration file has authentication set to CONFIG based authentication, however, the userid/password failed to login'),
'type' => 'error'));
}
break;
@ -345,9 +423,13 @@ abstract class DS {
header(sprintf('WWW-Authenticate: Basic realm="%s %s"',app_name(),_('login')));
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
header('Status: 401 Unauthorized'); // http 1.1 method
{
header('Status: 401 Unauthorized');
} // http 1.1 method
# If we still dont have login details...
if (! isset($_SERVER['PHP_AUTH_USER'])) {
@ -370,7 +452,9 @@ abstract class DS {
$CACHE[$this->index][$method] = false;
} else
$CACHE[$this->index][$method] = true;
{
$CACHE[$this->index][$method] = TRUE;
}
}
break;
@ -383,9 +467,13 @@ abstract class DS {
case 'sasl':
# Propogate any given Kerberos credential cache location
if (isset($_ENV['REDIRECT_KRB5CCNAME']))
putenv(sprintf('KRB5CCNAME=%s',$_ENV['REDIRECT_KRB5CCNAME']));
{
putenv(sprintf('KRB5CCNAME=%s', $_ENV['REDIRECT_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
$regex = $this->getValue('login', 'sasl_dn_regex');
@ -399,7 +487,9 @@ abstract class DS {
# Otherwise, use the user name as is
# For GSSAPI Authentication + mod_auth_kerb and Basic Authentication
} else
{
$CACHE[$this->index][$method] = $this->login(isset($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'] : '', '', $method);
}
break;
@ -417,7 +507,9 @@ abstract class DS {
*/
public function logout($method=null) {
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);
@ -436,7 +528,9 @@ abstract class DS {
case 'session':
case 'sasl':
if (isset($_SESSION['USER'][$this->index][$method]))
{
unset($_SESSION['USER'][$this->index][$method]);
}
return true;
@ -450,24 +544,34 @@ abstract class DS {
*/
public function isVisible() {
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');
}
public function isReadOnly() {
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'))
return true;
{
return TRUE;
}
else
return $this->getValue('server','read_only');
{
return $this->getValue('server', 'read_only');
}
}
public function getIndex() {
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;
}
@ -483,22 +587,30 @@ abstract class DS {
*/
protected function getMethod($method=null) {
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();
# Immediately return if method is set.
if (! is_null($method))
{
return $method;
}
# If we have been here already, then return our result
if (isset($CACHE[$this->index]) && ! is_null($CACHE))
{
return $CACHE[$this->index];
}
$CACHE[$this->index] = 'anon';
if ($this->isLoggedIn('user'))
{
$CACHE[$this->index] = 'user';
}
return $CACHE[$this->index];
}
@ -508,7 +620,9 @@ abstract class DS {
*/
public function isSessionValid() {
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;
}
@ -519,12 +633,18 @@ abstract class DS {
*/
public function inactivityTime() {
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')))
return time()+($this->getValue('login','timeout')*60);
{
return time() + ($this->getValue('login', 'timeout') * 60);
}
else
return null;
{
return NULL;
}
}
}
@ -654,17 +774,25 @@ class Datastore {
*/
public function setValue($key,$setting,$value) {
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))
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.
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))
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.
$this->objects[$this->index]->setValue($key,$setting,$value);
@ -678,12 +806,16 @@ class Datastore {
*/
public function getServerList($isVisible=true) {
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;
if (isset($CACHE[$isVisible]))
{
return $CACHE[$isVisible];
}
$CACHE[$isVisible] = array();
@ -695,8 +827,12 @@ class Datastore {
}
foreach ($this->objects as $id => $server)
if (! $isVisible || ($isVisible && $server->getValue('server','visible')))
{
if ( ! $isVisible || ($isVisible && $server->getValue('server', 'visible')))
{
$CACHE[$isVisible][$id] = $server;
}
}
masort($CACHE[$isVisible],'name');
@ -711,17 +847,25 @@ class Datastore {
*/
public function Instance($index=null) {
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 (is_null($index) || ! trim($index) || ! is_numeric($index))
{
$index = min($this->getServerList())->getIndex();
}
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)
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];
}
@ -734,11 +878,17 @@ class Datastore {
*/
public function InstanceName($name=null) {
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)
{
if ($this->objects[$index]->getName() == $name)
{
return $this->objects[$index];
}
}
# If we get here, then no object with the name exists.
return null;
@ -752,11 +902,17 @@ class Datastore {
*/
public function InstanceId($id=null) {
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)
if ($this->objects[$index->getIndex()]->getValue('server','id') == $id)
{
if ($this->objects[$index->getIndex()]->getValue('server', 'id') == $id)
{
return $this->objects[$index->getIndex()];
}
}
# If we get here, then no object with the name exists.
return null;

File diff suppressed because it is too large Load Diff

View File

@ -163,12 +163,18 @@ class ldap_pla extends ldap {
*/
public function isShowCreateEnabled() {
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'))
return false;
{
return FALSE;
}
else
return $this->getValue('appearance','show_create');
{
return $this->getValue('appearance', 'show_create');
}
}
/**
@ -182,16 +188,24 @@ class ldap_pla extends ldap {
*/
public function isAnonBindAllowed() {
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 (count($this->getValue('login','allowed_dns')) > 0)
$return = false;
{
$return = FALSE;
}
else
$return = $this->getValue('login','anon_bind');
{
$return = $this->getValue('login', 'anon_bind');
}
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;
}
@ -208,7 +222,9 @@ class ldap_pla extends ldap {
*/
public function isBranchRenameEnabled() {
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');
}
@ -232,22 +248,31 @@ class ldap_pla extends ldap {
*/
public function isMultiLineAttr($attr_name, $val=null) {
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
$return = false;
# First, check the optional val param for a \n or a \r
if (! is_null($val) && (strpos($val,"\n") || strpos($val,"\r")))
$return = true;
{
$return = TRUE;
}
# Next, compare strictly by name first
else
foreach ($_SESSION[APPCONFIG]->getValue('appearance','multi_line_attributes') as $multi_line_attr_name)
if (strcasecmp($multi_line_attr_name,$attr_name) == 0) {
$return = true;
{
foreach ($_SESSION[APPCONFIG]->getValue('appearance', 'multi_line_attributes') as $multi_line_attr_name)
{
if (strcasecmp($multi_line_attr_name, $attr_name) == 0)
{
$return = TRUE;
break;
}
}
}
# If unfound, compare by syntax OID
if (! $return) {
@ -257,16 +282,23 @@ class ldap_pla extends ldap {
$syntax_oid = $sattr->getSyntaxOID();
if ($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;
{
foreach ($_SESSION[APPCONFIG]->getValue('appearance', 'multi_line_syntax_oids') as $multi_line_syntax_oid)
{
if ($multi_line_syntax_oid == $syntax_oid)
{
$return = TRUE;
break;
}
}
}
}
}
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;
}
@ -283,15 +315,23 @@ class ldap_pla extends ldap {
private function isAttrTest($attr,$attrs,$except_dn) {
$attr = trim($attr);
if (! trim($attr) || ! count($attrs))
return false;
{
return FALSE;
}
# Is the user excluded?
if ($except_dn && $this->userIsMember($this->getLogin(),$except_dn))
return false;
{
return FALSE;
}
foreach ($attrs as $attr_name)
if (strcasecmp($attr,trim($attr_name)) == 0)
return true;
{
if (strcasecmp($attr, trim($attr_name)) == 0)
{
return TRUE;
}
}
return false;
}
@ -309,7 +349,9 @@ class ldap_pla extends ldap {
*/
public function isAttrReadOnly($attr) {
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');
$except_dn = $_SESSION[APPCONFIG]->getValue('appearance','readonly_attrs_exempt');
@ -330,7 +372,9 @@ class ldap_pla extends ldap {
*/
public function isAttrHidden($attr) {
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');
$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) {
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)
{
$entry_array[$attr] = dn_unescape($val);
}
$result = false;
# Check our unique attributes.
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))) {
$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 (get_request('create_base'))
{
$tree->delEntry($dn);
}
$tree->addEntry($dn);
@ -394,7 +446,9 @@ class ldap_pla extends ldap {
*/
public function delete($dn,$method=null) {
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;
@ -426,7 +480,9 @@ class ldap_pla extends ldap {
*/
public function rename($dn,$new_rdn,$container,$deleteoldrdn,$method=null) {
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;
@ -457,11 +513,15 @@ class ldap_pla extends ldap {
*/
public function modify($dn,$attrs,$method=null) {
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.
if (! $this->checkUniqueAttrs($dn,$attrs))
return false;
{
return FALSE;
}
$result = false;
$summary = array();
@ -481,7 +541,9 @@ class ldap_pla extends ldap {
'type'=>'warn'));
} else
{
$summary['add'][$attr]['new'] = $values;
}
# For modify attributes
} elseif (count($values)) {
@ -511,12 +573,16 @@ class ldap_pla extends ldap {
'type'=>'warn'));
} else
{
$summary['delete'][$attr]['old'] = $current_attrs[$attr];
}
}
}
if (! count($attrs))
return false;
{
return FALSE;
}
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);
@ -525,27 +591,34 @@ class ldap_pla extends ldap {
run_hook('post_entry_modify',array('server_id'=>$this->index,'method'=>$method,'dn'=>$dn,'attrs'=>$attrs));
foreach (array('add','modify','delete') as $mode)
{
if (isset($summary[$mode]))
{
foreach ($summary[$mode] as $attr => $values)
switch ($mode) {
{
switch ($mode)
{
case 'add':
run_hook(sprintf('post_attr_%s',$mode),
array('server_id'=>$this->index,'method'=>$method,'dn'=>$dn,'attr'=>$attr,'newvalue'=>$values['new']));
run_hook(sprintf('post_attr_%s', $mode),
array('server_id' => $this->index, 'method' => $method, 'dn' => $dn, 'attr' => $attr, 'newvalue' => $values['new']));
break;
case 'modify':
run_hook(sprintf('post_attr_%s',$mode),
array('server_id'=>$this->index,'method'=>$method,'dn'=>$dn,'attr'=>$attr,'oldvalue'=>$values['old'],'newvalue'=>$values['new']));
run_hook(sprintf('post_attr_%s', $mode),
array('server_id' => $this->index, 'method' => $method, 'dn' => $dn, 'attr' => $attr, 'oldvalue' => $values['old'], 'newvalue' => $values['new']));
break;
case 'delete':
run_hook(sprintf('post_attr_%s',$mode),
array('server_id'=>$this->index,'method'=>$method,'dn'=>$dn,'attr'=>$attr,'oldvalue'=>$values['old']));
run_hook(sprintf('post_attr_%s', $mode),
array('server_id' => $this->index, 'method' => $method, 'dn' => $dn, 'attr' => $attr, 'oldvalue' => $values['old']));
break;
default:
debug_dump_backtrace(sprintf('Unkown mode %s',$mode),1);
debug_dump_backtrace(sprintf('Unkown mode %s', $mode), 1);
}
}
}
}
} else {
system_message(array(
'title'=>_('Could not perform ldap_modify operation.'),
@ -570,13 +643,19 @@ class ldap_pla extends ldap {
*/
public function isAttrUnique($attr) {
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
if (in_array_ignore_case($attr,$this->getValue('unique','attrs')))
return true;
{
return TRUE;
}
else
return false;
{
return FALSE;
}
}
/**
@ -591,11 +670,15 @@ class ldap_pla extends ldap {
*/
public function checkUniqueAttrs($dn,$attrs) {
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 (! $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.
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.
$query['filter'] = '(|';
foreach ($checkattrs as $attr)
{
foreach ($attrs[$attr] as $val)
{
if ($val)
$query['filter'] .= sprintf('(%s=%s)',$attr,$val);
{
$query['filter'] .= sprintf('(%s=%s)', $attr, $val);
}
}
}
$query['filter'] .= ')';
$query['attrs'] = $checkattrs;
@ -629,21 +718,26 @@ class ldap_pla extends ldap {
# If we have a match.
if (count($results))
{
foreach ($results as $values)
# If one of the attributes is owned to somebody else, then we may as well die here.
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']);
{
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']);
system_message(array(
'title'=>_('Attribute value would not be unique'),
'body'=>sprintf('%s (<b><a href="%s">%s</a></b>)',
'title' => _('Attribute value would not be unique'),
'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.'),
htmlspecialchars($href),
_('Search')),
'type'=>'warn'));
return false;
return FALSE;
}
}
}
}
# If we get here, then it must be OK?
@ -655,11 +749,15 @@ class ldap_pla extends ldap {
*/
public function isSessionValid() {
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 (is_null($this->inactivityTime()) || ! $this->isLoggedIn())
return true;
{
return TRUE;
}
# If session has expired
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);
if ($attrs)
$query['attrs'] = explode(',',$attrs);
{
$query['attrs'] = explode(',', $attrs);
}
else
{
$query['attrs'] = array('*');
}
if (get_request('sys_attr')) {
if (! in_array('*',$query['attrs']))
array_push($query['attrs'],'*');
{
array_push($query['attrs'], '*');
}
array_push($query['attrs'],'+');
}
if (! $base)
{
$bases = $server->getBaseDN();
}
else
{
$bases = array($base);
}
foreach ($bases as $base) {
$query['base'] = $base;
@ -160,10 +170,12 @@ abstract class Export {
# If no result, there is a something wrong
if (! $this->results[$base] && $server->getErrorNum(null))
{
system_message(array(
'title'=>_('Encountered an error while performing search.'),
'body'=>ldap_error_msg($server->getErrorMessage(null),$server->getErrorNum(null)),
'type'=>'error'));
'title' => _('Encountered an error while performing search.'),
'body' => ldap_error_msg($server->getErrorMessage(NULL), $server->getErrorNum(NULL)),
'type' => 'error'));
}
$this->items += count($this->results[$base]);
}
@ -188,7 +200,9 @@ abstract class Export {
}
if (get_request('compress','REQUEST') == 'on')
$this->compress = true;
{
$this->compress = TRUE;
}
}
public function isCompressed() {
@ -223,8 +237,12 @@ abstract class Export {
*/
protected function isSafeAscii($str) {
for ($i=0;$i<strlen($str);$i++)
{
if (ord($str{$i}) < 32 || ord($str{$i}) > 127)
return false;
{
return FALSE;
}
}
return true;
}
@ -242,7 +260,7 @@ class ExportCSV extends Export {
private $multivalue_separator = ' | ';
private $escapeCode = '"';
static public function getType() {
public static function getType() {
return array('type'=>'CSV','description' => 'CSV (Spreadsheet)','extension'=>'csv');
}
@ -259,8 +277,12 @@ class ExportCSV extends Export {
unset($dndetails['dn']);
foreach (array_keys($dndetails) as $key)
if (! in_array($key,$headers))
array_push($headers,$key);
{
if ( ! in_array($key, $headers))
{
array_push($headers, $key);
}
}
}
}
@ -273,7 +295,9 @@ class ExportCSV extends Export {
$output .= sprintf('%s%s%s',$this->qualifier,$headers[$i],$this->qualifier);
if ($i < $num_headers-1)
{
$output .= $this->separator;
}
}
# Drop out our DN header.
@ -297,36 +321,52 @@ class ExportCSV extends Export {
$binary_attribute = $server->isAttrBinary($attr) ? 1 : 0;
if (! is_array($entry[$attr]))
{
$attr_values = array($entry[$attr]);
}
else
{
$attr_values = $entry[$attr];
}
$num_attr_values = count($attr_values);
for ($i=0; $i<$num_attr_values; $i++) {
if ($binary_attribute)
{
$output .= base64_encode($attr_values[$i]);
}
else
{
$output .= $this->LdapEscape($attr_values[$i]);
}
if ($i < $num_attr_values-1)
{
$output .= $this->multivalue_separator;
}
}
}
$output .= $this->qualifier;
if ($j < $num_headers-1)
{
$output .= $this->separator;
}
}
$output .= $this->br;
}
if ($this->compress)
{
return gzencode($output);
}
else
{
return $output;
}
}
/**
@ -347,7 +387,7 @@ class ExportCSV extends Export {
* @subpackage Export
*/
class ExportDSML extends Export {
static public function getType() {
public static function getType() {
return array('type'=>'DSML','description' => _('DSML V.1 Export'),'extension'=>'xml');
}
@ -394,12 +434,16 @@ class ExportDSML extends Export {
# Display the objectClass attributes first
if (isset($dndetails['objectClass'])) {
if (! is_array($dndetails['objectClass']))
{
$dndetails['objectClass'] = array($dndetails['objectClass']);
}
$output .= sprintf('%s<objectClass>%s',$indent['att'],$this->br);
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);
unset($dndetails['objectClass']);
@ -408,7 +452,9 @@ class ExportDSML extends Export {
# Display the attributes
foreach ($dndetails as $key => $attr) {
if (! is_array($attr))
{
$attr = array($attr);
}
$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;
foreach ($attr as $value)
{
$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);
}
@ -430,9 +478,13 @@ class ExportDSML extends Export {
$output .= sprintf('</dsml>%s',$this->br);
if ($this->compress)
{
return gzencode($output);
}
else
{
return $output;
}
}
}
@ -446,7 +498,7 @@ class ExportLDIF extends Export {
# The maximum length of the ldif line
private $line_length = 76;
static public function getType() {
public static function getType() {
return array('type'=>'LDIF','description' => _('LDIF Export'),'extension'=>'ldif');
}
@ -481,26 +533,39 @@ class ExportLDIF extends Export {
$title_string = sprintf('# %s %s: %s%s',_('Entry'),$counter,$dn,$this->br);
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;
# Display dn
if ($this->isSafeAscii($dn))
$output .= $this->multiLineDisplay(sprintf('dn: %s',$dn));
{
$output .= $this->multiLineDisplay(sprintf('dn: %s', $dn));
}
else
$output .= $this->multiLineDisplay(sprintf('dn:: %s',base64_encode($dn)));
{
$output .= $this->multiLineDisplay(sprintf('dn:: %s', base64_encode($dn)));
}
# display the attributes
foreach ($dndetails as $key => $attr) {
if (! is_array($attr))
{
$attr = array($attr);
}
foreach ($attr as $value)
if (! $this->isSafeAscii($value) || $server->isAttrBinary($key))
$output .= $this->multiLineDisplay(sprintf('%s:: %s',$key,base64_encode($value)));
else
$output .= $this->multiLineDisplay(sprintf('%s: %s',$key,$value));
{
if ( ! $this->isSafeAscii($value) || $server->isAttrBinary($key))
{
$output .= $this->multiLineDisplay(sprintf('%s:: %s', $key, base64_encode($value)));
} else
{
$output .= $this->multiLineDisplay(sprintf('%s: %s', $key, $value));
}
}
}
$output .= $this->br;
@ -508,9 +573,13 @@ class ExportLDIF extends Export {
}
if ($this->compress)
{
return gzencode($output);
}
else
{
return $output;
}
}
/**
@ -547,7 +616,7 @@ class ExportLDIF extends Export {
* @subpackage Export
*/
class ExportVCARD extends Export {
static public function getType() {
public static function getType() {
return array('type'=>'VCARD','description' => _('VCARD 2.1 Export'),'extension'=>'vcf');
}
@ -603,7 +672,9 @@ class ExportVCARD extends Export {
# Loop for the attributes
foreach ($dndetails as $key => $attr) {
if (! is_array($attr))
{
$attr = array($attr);
}
# If an attribute of the ldap entry exist in the mapping array for vcard
if (isset($this->mapping[$key])) {
@ -613,8 +684,12 @@ class ExportVCARD extends Export {
$output .= sprintf('%s:%s',$this->mapping[$key],$attr[0]);
if (isset($entry['ou']))
{
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)
} elseif (in_array($key,array('audio','jpegphoto'))) {
@ -637,9 +712,13 @@ class ExportVCARD extends Export {
}
if ($this->compress)
{
return gzencode($output);
}
else
{
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) {
if (isset($this->source[$attr]))
{
return $this->source[$attr];
}
else
return null;
{
return NULL;
}
}
# @todo integrate hooks
@ -150,7 +154,7 @@ class ImportLDIF extends Import {
private $template;
public $error = array();
static public function getType() {
public static function getType() {
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));
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;
$lines = $this->nextLines();
@ -191,7 +197,9 @@ class ImportLDIF extends Import {
array_shift($lines);
} else
{
$changetype = 'add';
}
$this->template = new Template($this->server_id,null,null,$changetype);
@ -212,7 +220,9 @@ class ImportLDIF extends Import {
case 'modify':
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->accept(false,true);
@ -224,7 +234,9 @@ class ImportLDIF extends Import {
case 'moddn':
case 'modrdn':
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->accept();
@ -235,14 +247,20 @@ class ImportLDIF extends Import {
default:
if (! $server->dnExists($dn))
return $this->error(_('Unkown change type'),$lines);
{
return $this->error(_('Unkown change type'), $lines);
}
}
} else
return $this->error(_('A valid dn line is required'),$lines);
{
return $this->error(_('A valid dn line is required'), $lines);
}
} else
return false;
{
return FALSE;
}
}
/**
@ -255,9 +273,13 @@ class ImportLDIF extends Import {
# Get the DN
if (substr($value,0,1) == ':')
$value = base64_decode(trim(substr($value,1)));
{
$value = base64_decode(trim(substr($value, 1)));
}
else
{
$value = trim($value);
}
return array($attr,$value);
}
@ -284,20 +306,28 @@ class ImportLDIF extends Import {
/* If the next line begin with a space, we append it to the current row
* else we push it into the array (unwrap)*/
if ($this->isWrappedLine())
{
$current[$count] .= trim($this->_currentLine);
}
elseif ($this->isCommentLine()) {}
# Do nothing
elseif (! $this->isBlankLine())
{
$current[++$count] = trim($this->_currentLine);
}
else
$endEntryFound = true;
{
$endEntryFound = TRUE;
}
}
# Return the LDIF entry array
return $current;
} else
{
return array();
}
}
/**
@ -394,19 +424,27 @@ class ImportLDIF extends Import {
if ($fh = @fopen($filename,'rb')) {
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);
} else
return $this->error(_('Unable to open file for'),$value);
{
return $this->error(_('Unable to open file for'), $value);
}
} 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
} else
{
$return = $value;
}
return trim($return);
}
@ -425,9 +463,13 @@ class ImportLDIF extends Import {
} else
if ($attribute->hasBeenModified())
{
$attribute->addValue($value);
}
else
{
$attribute->setValue(array($value));
}
}
}
@ -438,7 +480,9 @@ class ImportLDIF extends Import {
*/
private function getModifyDetails($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 (count($lines)) {
@ -452,7 +496,9 @@ class ImportLDIF extends Import {
$action_attribute_value = $attrvalue[1];
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;
switch ($action_attribute) {
@ -464,8 +510,10 @@ class ImportLDIF extends Import {
$attribute = $this->template->getAttribute($action_attribute_value);
if (is_null($attribute))
return $this->error(sprintf('%s %s',_('Attempting to delete a non existant attribute'),$action_attribute_value),
array_merge(array($currentLine),$lines));
{
return $this->error(sprintf('%s %s', _('Attempting to delete a non existant attribute'), $action_attribute_value),
array_merge(array($currentLine), $lines));
}
$deleteattr = true;
@ -475,8 +523,10 @@ class ImportLDIF extends Import {
$attribute = $this->template->getAttribute($action_attribute_value);
if (is_null($attribute))
return $this->error(sprintf('%s %s',_('Attempting to replace a non existant attribute'),$action_attribute_value),
array_merge(array($currentLine),$lines));
{
return $this->error(sprintf('%s %s', _('Attempting to replace a non existant attribute'), $action_attribute_value),
array_merge(array($currentLine), $lines));
}
break;
@ -507,9 +557,13 @@ class ImportLDIF extends Import {
switch ($action_attribute) {
case 'add':
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
$attribute->addValue($attribute_value_part,-1);
{
$attribute->addValue($attribute_value_part, -1);
}
$attribute->justModified();
@ -519,19 +573,27 @@ class ImportLDIF extends Import {
$deleteattr = false;
if (($key = array_search($attribute_value_part,$attribute->getValues())) !== false)
{
$attribute->delValue($key);
}
else
return $this->error(sprintf('%s %s',_('Delete value doesnt exist in DN'),$attribute_value_part),
array_merge(array($currentLine),$lines));
{
return $this->error(sprintf('%s %s', _('Delete value doesnt exist in DN'), $attribute_value_part),
array_merge(array($currentLine), $lines));
}
break;
case 'replace':
if ($attribute->hasBeenModified())
$attribute->addValue($attribute_value_part,-1);
{
$attribute->addValue($attribute_value_part, -1);
}
else
{
$attribute->setValue(array($attribute_value_part));
}
break;
@ -540,20 +602,28 @@ class ImportLDIF extends Import {
}
} else
return $this->error(sprintf('%s %s',_('The attribute to modify doesnt match the one specified by'),$action_attribute),
array_merge(array($currentLine),$lines));
{
return $this->error(sprintf('%s %s', _('The attribute to modify doesnt match the one specified by'), $action_attribute),
array_merge(array($currentLine), $lines));
}
} else
return $this->error(sprintf('%s %s',_('Attribute not valid'),$currentLine),
array_merge(array($currentLine),$lines));
{
return $this->error(sprintf('%s %s', _('Attribute not valid'), $currentLine),
array_merge(array($currentLine), $lines));
}
$currentLine = array_shift($lines);
if (trim($currentLine))
$processline = true;
{
$processline = TRUE;
}
}
if ($action_attribute == 'delete' && $deleteattr)
{
$attribute->setValue(array());
}
}
@ -571,7 +641,9 @@ class ImportLDIF extends Import {
# MODRDN MODDN should only be 2 or 3 lines.
if (count($lines) != 2 && count($lines) !=3)
return $this->error(_('Invalid entry'),$lines);
{
return $this->error(_('Invalid entry'), $lines);
}
else {
$currentLine = array_shift($lines);
@ -598,16 +670,24 @@ class ImportLDIF extends Import {
$attrs['newsuperior'] = $attrvalue[1];
} else
return $this->error(_('A valid newsuperior attribute should be specified'),$lines);
{
return $this->error(_('A valid newsuperior attribute should be specified'), $lines);
}
} else
{
$attrs['newsuperior'] = $server->getContainer($this->template->getDN());
}
} else
return $this->error(_('A valid deleteoldrdn attribute should be specified'),$lines);
{
return $this->error(_('A valid deleteoldrdn attribute should be specified'), $lines);
}
} 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.

View File

@ -27,13 +27,19 @@ class page {
public function __construct($index=null) {
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 (! defined('IMGDIR'))
define('IMGDIR','images/default');
{
define('IMGDIR', 'images/default');
}
if (! defined('CSSDIR'))
define('CSSDIR','css/default');
{
define('CSSDIR', 'css/default');
}
$this->index = $index;
@ -42,9 +48,13 @@ class page {
$this->_app['logo'] = IMGDIR.'/logo-small.png';
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
$this->_app['urlcss'] = sprintf('%s/%s',CSSDIR,'style.css');
{
$this->_app['urlcss'] = sprintf('%s/%s', CSSDIR, 'style.css');
}
# Default Values for configurable items.
$this->_default['sysmsg']['error'] = IMGDIR.'/error-big.png';
@ -67,13 +77,17 @@ class page {
header('Content-Encoding: gzip');
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])
&& $_SESSION[APPCONFIG]->getValue('appearance','compress')
&& 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.
ob_start();
@ -86,7 +100,9 @@ class page {
/* Add to the HTML Header */
public function head_add($html) {
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;
}
@ -94,11 +110,15 @@ class page {
/* Print out the HTML header */
private function pageheader_print() {
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.
foreach ($this->_pageheader as $line)
echo $line."\n";
{
echo $line . "\n";
}
# Page Title
echo '<head>';
@ -106,16 +126,22 @@ class page {
$DNs = get_request('dn','REQUEST');
if (is_array($DNs))
{
$DNs = '';
}
if (isset($_SESSION[APPCONFIG]))
{
printf('<title>%s (%s) - %s%s</title>',
$this->_app['title'],
app_version(),
$DNs ? htmlspecialchars($DNs).' ' : '',
$_SESSION[APPCONFIG]->getValue('appearance','page_title'));
$DNs ? htmlspecialchars($DNs) . ' ' : '',
$_SESSION[APPCONFIG]->getValue('appearance', 'page_title'));
}
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" />';
# Style sheet.
@ -131,8 +157,12 @@ class page {
# HTML head requirements.
if (is_array($this->_head) && count($this->_head))
{
foreach ($this->_head as $line)
echo $line."\n";
{
echo $line . "\n";
}
}
echo '</head>';
echo "\n";
@ -140,12 +170,18 @@ class page {
private function head_print() {
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]))
$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
{
$pagetitle = '';
}
echo '<tr class="pagehead">';
@ -155,18 +191,27 @@ class page {
echo '<td class="imagetop">';
$empty = true;
if (function_exists('cmd_control_pane'))
{
foreach (cmd_control_pane('top') as $cmddetails)
if ((isset($cmddetails['enable']) && $cmddetails['enable']) || ! isset($cmddetails['enable'])) {
if (! $empty)
{
if ((isset($cmddetails['enable']) && $cmddetails['enable']) || ! isset($cmddetails['enable']))
{
if ( ! $empty)
{
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)
{
echo '&nbsp;';
}
echo '</td>';
echo '</tr></table></div></td>';
@ -176,27 +221,38 @@ class page {
private function control_print() {
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 '<tr><td>';
$empty = true;
if (function_exists('cmd_control_pane'))
{
foreach (cmd_control_pane('main') as $cmddetails)
if ((isset($cmddetails['enable']) && trim($cmddetails['enable'])) || ! isset($cmddetails['enable'])) {
if (! $empty)
{
if ((isset($cmddetails['enable']) && trim($cmddetails['enable'])) || ! isset($cmddetails['enable']))
{
if ( ! $empty)
{
echo ' | ';
}
printf('<a %s>%s</a>',$cmddetails['link'],
(isset($_SESSION[APPCONFIG]) && $_SESSION[APPCONFIG]->getValue('appearance','control_icons')) ? $cmddetails['image'] : $cmddetails['title']);
printf('<a %s>%s</a>', $cmddetails['link'],
(isset($_SESSION[APPCONFIG]) && $_SESSION[APPCONFIG]->getValue('appearance', 'control_icons')) ? $cmddetails['image'] : $cmddetails['title']);
$empty = false;
$empty = FALSE;
}
}
}
echo '</td>';
if ($empty)
{
echo '<td>&nbsp;</td>';
}
echo '</tr>';
echo '</table>';
@ -204,13 +260,19 @@ class page {
protected function tree() {
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]))
{
return;
}
if (is_null($this->index))
{
$this->index = min(array_keys($_SESSION[APPCONFIG]->getServerList()));
}
if (count($_SESSION[APPCONFIG]->getServerList()) > 1) {
echo '<form id="server_select" action="cmd.php" method="post">';
@ -233,30 +295,42 @@ class page {
public function block_add($side,$object) {
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))
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;
}
private function block_print($side) {
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]))
{
return;
}
printf('<td class="%s" colspan="2">',$side);
foreach ($this->_block[$side] as $object)
{
echo $object->draw($side);
}
echo '</td>';
}
private function sysmsg() {
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)) {
foreach ($this->sysmsg as $index => $details) {
@ -276,30 +350,43 @@ class page {
}
if (isset($details['title']))
{
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 (is_array($details['body'])) {
{
if (is_array($details['body']))
{
echo '<tr><td class="body">';
foreach ($details['body'] as $line)
printf('%s<br />',$line);
{
printf('%s<br />', $line);
}
echo '</td></tr>';
} 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) {
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
if (isset($_SESSION['sysmsg']) && is_array($_SESSION['sysmsg'])) {
foreach ($_SESSION['sysmsg'] as $msg)
{
$this->setsysmsg($msg);
}
unset($_SESSION['sysmsg']);
}
@ -312,13 +399,19 @@ class page {
}
if (isset($this->_block['body']))
{
foreach ($this->_block['body'] as $object)
echo $object->draw('body',$raw);
{
echo $object->draw('body', $raw);
}
}
}
private function footer_print() {
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>',
isCompress() ? '[C]' : '&nbsp;',
@ -334,7 +427,9 @@ class page {
*/
public function show($frame,$compress=false,$raw=false) {
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 ($compress && ob_get_level() && isCompress()) {
@ -360,8 +455,10 @@ class page {
ob_end_clean();
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED)
debug_log('Sending COMPRESSED output to browser[(%s),%s]',129,0,__FILE__,__LINE__,__METHOD__,
strlen($output),$output);
{
debug_log('Sending COMPRESSED output to browser[(%s),%s]', 129, 0, __FILE__, __LINE__, __METHOD__,
strlen($output), $output);
}
print gzencode($output);
}
@ -369,7 +466,9 @@ class page {
public function display($filter=array()) {
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.
$display = array(
@ -400,7 +499,9 @@ class page {
echo '<table class="page" border="0" width="100%">';
if ($display['HEAD'])
{
$this->head_print();
}
# Control Line
if ($display['CONTROL']) {
@ -434,7 +535,9 @@ class page {
# Page Footer
if ($display['FOOT'])
{
$this->footer_print();
}
# Finish HTML
echo '</table>';
@ -447,8 +550,10 @@ class page {
ob_end_clean();
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED)
debug_log('Sending COMPRESSED output to browser[(%s),%s]',129,0,__FILE__,__LINE__,__METHOD__,
strlen($output),$output);
{
debug_log('Sending COMPRESSED output to browser[(%s),%s]', 129, 0, __FILE__, __LINE__, __METHOD__,
strlen($output), $output);
}
print gzencode($output);
}
@ -456,19 +561,31 @@ class page {
public function setsysmsg($data) {
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))
{
return;
}
if (isset($this->sysmsg))
{
$msgnum = count($this->sysmsg) + 1;
}
else
{
$msgnum = 1;
}
foreach (array('title','body','type') as $index)
{
if (isset($data[$index]))
{
$this->sysmsg[$msgnum][$index] = $data[$index];
}
}
}
}
@ -499,19 +616,27 @@ class block {
$output = '';
if ($raw)
{
$output .= $this->body;
}
else {
$output .= sprintf('<table class="%s">',$side);
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))
$output .= sprintf('<tr><td>%s</td></tr>',$this->body);
{
$output .= sprintf('<tr><td>%s</td></tr>', $this->body);
}
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>';
}

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;
$ip_hex = hexdec($ip_md5[0]);
if ($ip_hex <= app_session_id_ip_min)
{
$ip_len = app_session_id_ip_min;
}
else
{
$ip_len = $ip_hex - 1;
}
$new_id = substr($id_md5, 0, $id_hex) .
substr($ip_md5, $ip_hex, $ip_len) .
@ -51,9 +55,13 @@ function app_session_verify_id() {
$id_hex = hexdec($check_id[0]) + 1;
$ip_hex = hexdec($ip_md5[0]);
if ($ip_hex <= app_session_id_ip_min)
{
$ip_len = app_session_id_ip_min;
}
else
{
$ip_len = $ip_hex - 1;
}
$ip_ses = substr($check_id, $id_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 (isset($_SESSION['sysmsg']))
{
$sysmsg = $_SESSION['sysmsg'];
}
/* 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
@ -87,11 +97,15 @@ function app_session_start() {
* session to prevent this problem.
*/
if (ini_get('session.auto_start') && ! array_key_exists(app_session_id_init,$_SESSION))
{
@session_destroy();
}
# Do we already have a session?
if (@session_id())
{
return;
}
@session_name(APP_SESSION_ID);
@session_start();
@ -116,11 +130,16 @@ function app_session_start() {
@header('Cache-control: private'); // IE 6 Fix
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
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'])
|| $_SESSION[app_session_id_init]['name'] !== app_name()
@ -143,25 +162,37 @@ function app_session_start() {
$config_file = CONFDIR.'config.php';
$config = check_config($config_file);
if (! $config)
debug_dump_backtrace('config is empty?',1);
{
debug_dump_backtrace('config is empty?', 1);
}
} else {
# Sanity check, specially when upgrading from a previous release.
if (isset($_SESSION['cache']))
{
foreach (array_keys($_SESSION['cache']) as $id)
{
if (isset($_SESSION['cache'][$id]['tree']['null']) && ! is_object($_SESSION['cache'][$id]['tree']['null']))
{
unset($_SESSION['cache'][$id]);
}
}
}
}
}
# If we came via index.php, then set our $config.
if (! isset($_SESSION[APPCONFIG]) && isset($config))
{
$_SESSION[APPCONFIG] = $config;
}
# Restore our sysmsg's if there were any.
if ($sysmsg) {
if (! isset($_SESSION['sysmsg']) || ! is_array($_SESSION['sysmsg']))
{
$_SESSION['sysmsg'] = array();
}
$_SESSION['sysmsg'] = array_merge($_SESSION['sysmsg'],$sysmsg);
}

View File

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

View File

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