Example #1
0
<?php

$id = generate_id();
$now = time();
$expires = $now + intval($_POST['ttl']);
$attachment = empty($_POST['attachment']) ? null : $_POST['attachment'];
$grid->db->insert('message', array('id' => $id, 'user_id' => $grid->user->id, 'content' => $params['content'], 'parent_id' => 0, 'server_id' => $grid->meta['server_id'], 'file_id' => $attachment, 'expires' => $expires, 'created' => $now, 'updated' => $now));
blink_leds($params['content']);
update_user();
if (!empty($attachment)) {
    attach_file($id, $attachment);
}
$container = get_container();
$url = empty($container) ? GRID_URL . 'forum' : GRID_URL . "c/{$container->id}";
if (!empty($container)) {
    $grid->db->update('message', array('parent_id' => "c/{$container->id}"), $id);
    $grid->db->update('container', array('updated' => $now), $container->id);
}
$this->redirect($url);
exit;
Example #2
0
    print _('Building snapshot of tree to copy... ');
    flush();
    $snapshot_tree = build_tree($ldapserver_src, $dn_src, array(), $filter);
    printf('<span style="color:green">%s</span><br />', _('Success'));
    flush();
    # Prevent script from bailing early on a long delete
    @set_time_limit(0);
    $copy_result = r_copy_dn($ldapserver_src, $ldapserver_dst, $snapshot_tree, $dn_src, $dn_dst);
    print '</small>';
} else {
    $copy_result = copy_dn($ldapserver_src, $ldapserver_dst, $dn_src, $dn_dst);
}
if ($copy_result) {
    $edit_url = sprintf('template_engine.php?server_id=%s&amp;dn=%s', $server_id_dst, rawurlencode($dn_dst));
    $new_rdn = get_rdn($dn_dst);
    $container = get_container($dn_dst);
    printf('<center>%s<a href="%s">%s</a></center>', _('Copy successful! Would you like to '), $edit_url, _('view the new entry'));
    echo '<!-- refresh the tree view (with the new DN renamed) and redirect to the edit_dn page -->';
    echo '<script type="text/javascript" language="javascript">parent.left_frame.location.reload();</script>';
    echo '</body></html>';
    if ($do_remove) {
        sleep(2);
        $delete_url = sprintf('delete_form.php?server_id=%s&dn=%s', $server_id_dst, rawurlencode($dn_src));
        echo '<!-- redirect to the delete form -->';
        printf('<script type="text/javascript" language="javascript">parent.right_frame.location="%s" </script>', $delete_url);
    }
}
function r_copy_dn($ldapserver_src, $ldapserver_dst, $snapshottree, $root_dn, $dn_dst)
{
    if (DEBUG_ENABLED) {
        debug_log('r_copy_dn: Entered with (%s,%s,%s,%s,%s)', 1, $ldapserver_src->server_id, $ldapserver_dst->server_id, $snapshottree, $root_dn, $dn_dst);
 *
 *  - dn (rawurlencoded)
 *  - server_id
 *
 * @package phpLDAPadmin
 */
/**
 */
require './common.php';
if (!$ldapserver->haveAuthInfo()) {
    pla_error(_('Not enough information to login to server. Please check your configuration.'));
}
$dn = isset($_GET['dn']) ? $_GET['dn'] : '';
$encoded_dn = rawurlencode($dn);
$rdn = get_rdn($dn);
$container = get_container($dn);
$attrs = $ldapserver->getDNAttrs($dn);
$select_server_html = server_select_list($ldapserver->server_id, true, 'server_id_dst');
include './header.php';
?>

<body>

<h3 class="title"><?php 
echo _('Compare another DN with') . '&nbsp;' . $rdn;
?>
</h3>
<h3 class="subtitle"><?php 
echo _('Server');
?>
: <b><?php 
}
/* Has the use already begun to descend into a specific server tree? */
if ($server_id !== false && $container !== false) {
    check_server_id($server_id) or pla_error("Bad server_id: " . htmlspecialchars($server_id));
    have_auth_info($server_id) or pla_error("Not enough information to login to server. " . "Please check your configuration.");
    pla_ldap_connect($server_id) or pla_error("Coult not connect to LDAP server.");
    $dn_list = get_container_contents($server_id, $container);
    $base_dn = $servers[$server_id]['base'];
    if (!$base_dn) {
        $base_dn = try_to_get_root_dn($server_id);
    }
    if ($container == $base_dn) {
        $parent_container = false;
        $up_href = "entry_chooser.php?form_element={$return_form_element}";
    } else {
        $parent_container = get_container($container);
        $up_href = "entry_chooser.php?form_element={$return_form_element}&amp;server_id={$server_id}&amp;container=" . rawurlencode($parent_container);
    }
    echo "&nbsp;<a href=\"{$up_href}\" style=\"text-decoration:none\">" . "<img src=\"images/up.png\"> Back Up...</a><br />\n";
    if (count($dn_list) == 0) {
        echo "&nbsp;&nbsp;&nbsp;(no entries)<br />\n";
    } else {
        foreach ($dn_list as $dn) {
            $href = "javascript:returnDN( '{$dn}' )";
            echo "&nbsp;&nbsp;&nbsp;<a href=\"entry_chooser.php?form_element={$return_form_element}" . "&amp;server_id={$server_id}&amp;container=" . rawurlencode($dn) . "\"><img src=\"images/plus.png\" /></a> " . "<a href=\"{$href}\">" . htmlspecialchars($dn) . "</a><br />\n";
        }
    }
} else {
    foreach ($servers as $id => $server) {
        if ($server['host']) {
            echo "<b>" . htmlspecialchars($server['name']) . "</b><br />\n";
 /**
  * Given a DN string and a path like syntax, this returns the parent container portion of the string.
  * @param string $dn The DN whose container string to return.
  * @param string $path Either '/', '.' or a series of '../'
  * @return string The container
  * @see get_rdn
  * @see get_container
  */
 function getContainerParent($container, $path)
 {
     if (DEBUG_ENABLED) {
         debug_log('%s:getContainerParent(): Entered with (%s,%s)', 17, get_class($this), $container, $path);
     }
     $top = $this->getContainerTop($container);
     if ($path == '/') {
         return $top;
     } elseif ($path == '.') {
         return $container;
     } else {
         $parenttree = explode('/', $path);
         foreach ($parenttree as $index => $value) {
             if ($value == '..') {
                 if (get_container($container)) {
                     $container = get_container($container);
                 }
                 if ($container == $top) {
                     break;
                 }
             } else {
                 break;
             }
         }
         return $container;
     }
 }
Example #6
0
    echo get_rdn("dc=com");
    echo "<br>\n";
    echo "Should be Fred: ";
    echo get_rdn("Fred");
    echo "<br>\n";
}
// testing get_container()
if (false) {
    echo "Should be ou=People-copy1,ou=People-copy2,ou=People2,dc=example,dc=com: ";
    var_dump(get_container("uid=bäb,ou=People-copy1,ou=People-copy2,ou=People2,dc=example,dc=com"));
    echo "<br>\n";
    echo "Should be null: ";
    var_dump(get_container("dc=com"));
    echo "<br>\n";
    echo "Should be null: ";
    var_dump(get_container("Fred"));
    echo "<br>\n";
}
// tests pla_explode_dn()
if (false) {
    var_dump(pla_explode_dn("cn=<stuff>,dc=example,dc=<com>"));
}
if (false) {
    $password = '******';
    foreach (array('md5', 'md5crypt', 'sha', 'ssha', 'smd5', 'crypt', 'clear') as $enc_type) {
        $crypted_password = password_hash($password, $enc_type);
        print "[" . $enc_type . "] " . $crypted_password . "<br />";
        print "  Test: " . (password_check($crypted_password, $password) ? "passed" : "failed");
        print "\n";
        //unset($crypted_password);
        flush();
Example #7
0
    echo "Building snapshot of tree to copy... ";
    flush();
    build_tree($source_server_id, $source_dn, $snapshot_tree);
    echo " <span style=\"color:green\">Success</span><br />\n";
    flush();
    // prevent script from bailing early on a long delete
    @set_time_limit(0);
    $copy_result = r_copy_dn($source_server_id, $dest_server_id, $snapshot_tree, $source_dn, $dest_dn);
    echo "</small>\n";
} else {
    $copy_result = copy_dn($source_server_id, $source_dn, $dest_server_id, $dest_dn);
}
if ($copy_result) {
    $edit_url = "edit.php?server_id={$dest_server_id}&dn=" . rawurlencode($dest_dn);
    $new_rdn = get_rdn($dest_dn);
    $container = get_container($dest_dn);
    if (session_is_registered('tree')) {
        $tree = $_SESSION['tree'];
        $tree_icons = $_SESSION['tree_icons'];
        if (isset($tree[$dest_server_id][$container])) {
            $tree[$dest_server_id][$container][] = $dest_dn;
            sort($tree[$dest_server_id][$container]);
            $tree_icons[$dest_server_id][$dest_dn] = get_icon($dest_server_id, $dest_dn);
            $_SESSION['tree'] = $tree;
            $_SESSION['tree_icons'] = $tree_icons;
            session_write_close();
        }
    }
    ?>
		<!-- refresh the tree view (with the new DN renamed)
		and redirect to the edit_dn page -->
Example #8
0
            }
        } else {
            $new_entry[$attr] = $vals;
        }
    }
}
# Check the user-defined custom call back first
if (run_hook('pre_entry_create', array('server_id' => $ldapserver->server_id, 'dn' => $new_dn, 'attrs' => $new_entry))) {
    $add_result = $ldapserver->add($new_dn, $new_entry);
}
if ($add_result) {
    run_hook('post_entry_create', array('server_id' => $ldapserver->server_id, 'dn' => $new_dn, 'attrs' => $new_entry));
    if ($redirect) {
        $redirect_url = $redirect;
    } else {
        $redirect_url = sprintf('template_engine.php?server_id=%s&dn=%s', $ldapserver->server_id, rawurlencode($new_dn));
    }
    echo '<html><head>';
    $tree = get_cached_item($ldapserver->server_id, 'tree');
    $container = get_container($new_dn);
    if (isset($tree['browser'][$container]['open']) && $tree['browser'][$container]['open'] || in_array($new_dn, $ldapserver->getBaseDN())) {
        echo '<!-- refresh the tree view (with the new DN renamed) and redirect to the edit_dn page -->';
        printf('<script language="javascript">parent.left_frame.location.reload();location.href="%s"</script>', $redirect_url);
    }
    printf('<meta http-equiv="refresh" content="0; url=%s" />', $redirect_url);
    echo '</head><body>';
    printf('%s <a href="%s">%s</a>.', _('Redirecting...'), $redirect_url, _('here'));
    echo '</body></html>';
} else {
    pla_error(_('Could not add the object to the LDAP server.'), $ldapserver->error(), $ldapserver->errno());
}