Exemplo n.º 1
0
/**
 * Returns an HTML-beautified version of a DN.
 * Internally, this function makes use of pla_explode_dn() to break the
 * the DN into its components. It then glues them back together with
 * "pretty" HTML. The returned HTML is NOT to be used as a real DN, but
 * simply displayed.
 *
 * @param string $dn The DN to pretty-print.
 * @return string
 */
function pretty_print_dn($dn)
{
    if (DEBUG_ENABLED) {
        debug_log('pretty_print_dn(): Entered with (%s)', 1, $dn);
    }
    if (!is_dn_string($dn)) {
        pla_error(sprintf(_('DN %s is not an LDAP distinguished name.'), $dn));
    }
    $dn = pla_explode_dn($dn);
    foreach ($dn as $i => $element) {
        $element = htmlspecialchars($element);
        $element = explode('=', $element, 2);
        $element = implode('<span style="color: blue; font-family: courier; font-weight: bold">=</span>', $element);
        $dn[$i] = $element;
    }
    $dn = implode('<span style="color:red; font-family:courier; font-weight: bold;">,</span>', $dn);
    return $dn;
}
Exemplo n.º 2
0
if (isset($_GET['form']) && $_GET['form'] == 'advanced') {
    $js_on_change_string = 'onChange="document.forms[0].base_dn.value=servers[document.forms[0].server_id.value].base_dn"';
}
if (isset($ldapserver)) {
    $server_menu_html = server_select_list($ldapserver->server_id, true, 'server_id', $js_on_change_string);
    $server_info_list = server_info_list();
}
$filter = isset($_GET['filter']) ? clean_search_vals($_GET['filter']) : null;
$attr = isset($_GET['attribute']) ? $_GET['attribute'] : null;
# grab the base dn for the search
if (isset($_GET['base_dn']) && $_GET['base_dn']) {
    $base_dn = $_GET['base_dn'];
    $base_dn_is_invalid = false;
    $base_dn_does_not_exist = false;
    if (trim($base_dn)) {
        if (!is_dn_string($base_dn)) {
            $base_dn_is_invalid = true;
        } elseif (!$ldapserver->dnExists($base_dn)) {
            $base_dn_does_not_exist = true;
        }
    }
    $base_dns = array($base_dn);
} else {
    if (isset($ldapserver)) {
        $base_dns = $ldapserver->getBaseDN();
    }
}
$criterion = isset($_GET['criterion']) ? $_GET['criterion'] : null;
if (isset($_GET['form'])) {
    $_SESSION['form'] = $_GET['form'];
}
Exemplo n.º 3
0
                        echo $input_name;
                        ?>
" id="<?php 
                        echo $input_id;
                        ?>
" value="<?php 
                        echo htmlspecialchars($val);
                        ?>
" />

					<?php 
                    }
                    continue;
                }
            }
            if (is_dn_string($val) || $ldapserver->isDNAttr($attr)) {
                ?>

				<a title="<?php 
                echo sprintf(_('Go to %s'), htmlspecialchars($val));
                ?>
" href="template_engine.php?server_id=<?php 
                echo $ldapserver->server_id;
                ?>
&amp;dn=<?php 
                echo rawurlencode($val);
                ?>
"><img style="vertical-align: top" src="images/go.png" /></a>

			<?php 
            } elseif (is_mail_string($val)) {
Exemplo n.º 4
0
        print_r(pla_verbose_error($num));
    }
}
// tests is_dn_string()
if (false) {
    $dn_strs = array(' cn=joe,dc=example,dc=com', 'cn = joe, dc= example, dc =com', '  cn=asdf asdf, ou= foo bar, o =foo bar, dc=com', 'cn=True!=False,dc=example,dc=com');
    $not_dn_strs = array(' asdf asdf ', '== asdf asdf ', ' = = = = = = = =');
    echo "All should be true:\n";
    foreach ($dn_strs as $str) {
        echo "\"{$str}\"\n";
        var_dump(is_dn_string($str));
    }
    echo "\nAll should be false:\n";
    foreach ($not_dn_strs as $str) {
        echo "\"{$str}\"\n";
        var_dump(is_dn_string($str));
    }
}
// tests pla_compare_dns()
if (false) {
    echo "Should all be 0:<br>";
    $dns1 = array('cn=joe,dc=example,dc=com', 'cn=joe,dc=example,dc=com', 'cn = bob, dc= example,dc =com');
    $dns2 = array('cn=joe,dc=example,dc=com', 'CN =joe,dc=Example,dc =com', 'cn= bob, dc= example,dc =com');
    for ($i = 0; $i < count($dns1); $i++) {
        var_dump(pla_compare_dns($dns1[$i], $dns2[$i]));
        echo "\n";
    }
    echo "Should all be ! 0:<br>";
    $dns1 = array('dc=test,dc=example,dc=com', 'cn=Fred,cn=joe,dc=example,dc=com', 'cn=joe2,dc=example,dc=com', 'cn = bob, dc= example,dc =com');
    $dns2 = array('dc=example, dc=com', 'cn=joe,dc=example,dc=com', 'CN =joe,dc=Example2,dc =com', 'cn= 2bob, dc= example,dc =com');
    for ($i = 0; $i < count($dns1); $i++) {
Exemplo n.º 5
0
 /** DRAW ICONS FOR ATTRIBUTES VALUES **/
 protected function drawIconAttribute($attribute, $val)
 {
     if (DEBUGTMP) {
         printf('<font size=-2>%s</font><br />', __METHOD__);
     }
     if (is_dn_string($val) || $this->getServer()->isDNAttr($attribute->getName())) {
         $this->draw('DnValueIcon', $attribute, $val);
     } elseif (is_mail_string($val)) {
         $this->draw('MailValueIcon', $attribute, $val);
     } elseif (is_url_string($val)) {
         $this->draw('UrlValueIcon', $attribute, $val);
     } else {
         if ($icon = $attribute->getIcon()) {
             printf('<img src="%s" alt="Icon" style="float: right;" />&nbsp;', $icon);
         }
     }
 }