From: Kurt Zeilenga Date: Sun, 29 Nov 1998 22:20:20 +0000 (+0000) Subject: Update contrib software. X-Git-Tag: OPENLDAP_REL_ENG_1_1_BETA~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1b01c41401b8cb684e8da5599f851bc4a4e93b32;p=thirdparty%2Fopenldap.git Update contrib software. --- diff --git a/contrib/gtk-tool/ChangeLog b/contrib/gtk-tool/ChangeLog new file mode 100644 index 0000000000..dbd38b36de --- /dev/null +++ b/contrib/gtk-tool/ChangeLog @@ -0,0 +1,32 @@ +ChangeLog for gtk-tool + +28/11/1998 - Pele + * Fixes, enhancements, started using ldap utility api + * It now traverses the whole tree at startup, not sure if it's smart + but I did it because of something that has no relevance to network + traffic + +27/11/1998 - Pele + * Added viewports, both sides now scroll automatically + * Brought back the "cache" stuff, now data gets reused if it's allready + available without redundant searches/listings. + * Editing pixmaps by hand is so much, er, fun! + * Miniscule fixes + +26/11/1998 - Pele + * Added nice icons in the browser pane - looks decent now. + * Fixed scrolling in the data (right) pane - now scrolls if there is + a long tab + * removed class My_Scroller + * removed file Gtk_LdapItem.cc (useless) + * commented-out the part where data gets reused instead of re-querying + the server, stupid I know, but for the time being if resolves some + problems with replacement of right pane. + * Misc. fixes + +26/11/1998 - Pele + * First appearance of ChangeLog + * Fixed removal of scrolled window on the right hand side + thus making gtk-tool a viable project to be worked on + * added command-line parameter parsing - now accepts + -s for server, -p for port, -b for baseDN diff --git a/contrib/gtk-tool/Gtk_LdapTreeItem.cc b/contrib/gtk-tool/Gtk_LdapTreeItem.cc index a7d0e1b43b..7efcb58d6c 100644 --- a/contrib/gtk-tool/Gtk_LdapTreeItem.cc +++ b/contrib/gtk-tool/Gtk_LdapTreeItem.cc @@ -1,14 +1,67 @@ #include "Gtk_LdapTreeItem.h" +#include Gtk_LdapTreeItem::Gtk_LdapTreeItem() : Gtk_TreeItem() { + this->objectClass = NULL; } -Gtk_LdapTreeItem::Gtk_LdapTreeItem(char *c, My_Window *w) : Gtk_TreeItem(c) { + +Gtk_LdapTreeItem::Gtk_LdapTreeItem(char *c, My_Window *w) : Gtk_TreeItem() { this->rdn = c; this->par = w; + this->objectClass = NULL; } + Gtk_LdapTreeItem::Gtk_LdapTreeItem(GtkTreeItem *t) : Gtk_TreeItem(t) { } -int Gtk_LdapTreeItem::search() { + +Gtk_LdapTreeItem::~Gtk_LdapTreeItem() { + cout << "Bye" << endl; + delete this; +} + +void Gtk_LdapTreeItem::setType(int t) { + cout << "Gtk_LdapTreeItem::setType(" << t << ")" << endl; + Gtk_Pixmap *xpm_icon; + Gtk_Label *label; + if (this->getchild() != NULL) { + xpm_label = new Gtk_HBox(GTK_HBOX(this->getchild()->gtkobj())); + xpm_label->remove_c(xpm_label->children()->nth_data(0)); + xpm_label->remove_c(xpm_label->children()->nth_data(0)); + } + else xpm_label = new Gtk_HBox(); + if (strcasecmp(this->objectClass,"organization") == 0) + xpm_icon=new Gtk_Pixmap(*xpm_label, root_node); + else if (strcasecmp(this->objectClass,"organizationalunit") == 0) + xpm_icon=new Gtk_Pixmap(*xpm_label, branch_node); + else if (strcasecmp(this->objectClass,"person") == 0) + xpm_icon=new Gtk_Pixmap(*xpm_label, leaf_node); + else xpm_icon=new Gtk_Pixmap(*xpm_label, general_node); + label = new Gtk_Label(this->rdn); + xpm_label->pack_start(*xpm_icon, false, false, 1); + xpm_label->pack_start(*label, false, false, 1); + if (this->getchild() == NULL) this->add(xpm_label); + label->show(); + xpm_label->show(); + xpm_icon->show(); +} + +int Gtk_LdapTreeItem::showDetails() { + cout << "Gtk_LdapTreeItem::showDetails()" << endl; + if (this->notebook != NULL) { + if (par->viewport->getchild() != NULL) { + par->viewport->remove_c(par->viewport->getchild()->gtkobj()); + } + par->viewport->add(this->notebook); + this->notebook->show(); + par->viewport->show(); + return 0; + } + else this->getDetails(); + this->showDetails(); +} + +int Gtk_LdapTreeItem::getDetails() { + cout << "Gtk_LdapTreeItem::getDetails()" << endl; int error, entriesCount; BerElement *ber; LDAPMessage *entry; @@ -17,49 +70,36 @@ int Gtk_LdapTreeItem::search() { Gtk_Label *label; GList *child_list; Gtk_Notebook *g; - if (this->notebook != NULL) { - if (par->scroller2->children != NULL) { - par->scroller2->remove_child(0); - } - par->scroller2->add_child(this->notebook); - // par->scroller2->remove((Gtk_Object)par->scroller2->children()->first()); - this->notebook->reparent(par->scroller2); - this->notebook->show(); - par->scroller2->show(); - return 0; - } + Gtk_Viewport *viewport; error = ldap_search_s(this->ld, this->dn, LDAP_SCOPE_BASE, "objectclass=*", NULL, 0, &result_identifier); entriesCount = ldap_count_entries(ld, result_identifier); if (entriesCount == 0) return 0; notebook = new Gtk_Notebook(); notebook->set_tab_pos(GTK_POS_LEFT); - gchar *titles[] = { "values" }; + const gchar *titles[] = { "values" }; for (entry = ldap_first_entry(ld, result_identifier); entry != NULL; entry = ldap_next_entry(ld, result_identifier)) { for (attribute = ldap_first_attribute(ld, entry, &ber); attribute != NULL; attribute = ldap_next_attribute(ld, entry, ber)) { - table = new Gtk_CList(1, titles); values = ldap_get_values(ld, entry, attribute); + if (strcasecmp(attribute, "objectclass") == 0) { + if (strcasecmp(values[0],"top") == 0) + this->objectClass = strdup(values[1]); + else this->objectClass = values[0]; + } + table = new Gtk_CList(1, titles); for (int i=0; iappend(t); } ldap_value_free(values); label = new Gtk_Label(attribute); - notebook->append_page(table, label); + notebook->append_page(*table, *label); table->show(); label->show(); } } - if (par->scroller2 != NULL) { - cout << "Scroller2 exists" << endl; - if (par->scroller2->children[0] != NULL) { - cout << "There are children in scroller2" << endl; - par->scroller2->remove_child(0); - } - par->scroller2->add_child(this->notebook); - this->notebook->show(); - par->scroller2->show(); - } + this->setType(1); + cout << "."; return 0; } void Gtk_LdapTreeItem::select_impl() { @@ -68,16 +108,19 @@ void Gtk_LdapTreeItem::select_impl() { Gtk_c_signals_Item *sig=(Gtk_c_signals_Item *)internal_getsignalbase(); if (!sig->select) return; sig->select(GTK_ITEM(gtkobj())); - this->search(); + this->showDetails(); } + void Gtk_LdapTreeItem::collapse_impl() { - cout << this->dn << " collapsed" << endl; +// cout << this->dn << " collapsed" << endl; Gtk_c_signals_TreeItem *sig=(Gtk_c_signals_TreeItem *)internal_getsignalbase(); if (!sig->collapse) return; sig->collapse(GTK_TREE_ITEM(gtkobj())); // gtk_widget_hide(GTK_WIDGET(GTK_TREE(GTK_TREE_ITEM (this->gtkobj())->subtree))); } + void Gtk_LdapTreeItem::expand_impl() { +// cout << this->dn << " expanded" << endl; Gtk_c_signals_TreeItem *sig=(Gtk_c_signals_TreeItem *)internal_getsignalbase(); if (!sig->expand) return; sig->expand(GTK_TREE_ITEM(gtkobj())); diff --git a/contrib/gtk-tool/Gtk_LdapTreeItem.h b/contrib/gtk-tool/Gtk_LdapTreeItem.h index 1e728ef337..ee8f711a1e 100644 --- a/contrib/gtk-tool/Gtk_LdapTreeItem.h +++ b/contrib/gtk-tool/Gtk_LdapTreeItem.h @@ -4,6 +4,15 @@ #include #include #include +/*#include "XPMLabelBox.h"*/ +#include "icons/root_node.h" +#include "icons/branch_node.h" +#include "icons/leaf_node.h" +#include "icons/general_node.h" + +#define ROOT_NODE 1 +#define BRANCH_NODE 2 +#define LEAF_NODE 3 class My_Window; @@ -11,14 +20,19 @@ class Gtk_LdapTreeItem : public Gtk_TreeItem { public: char *dn; char *rdn; + char *objectClass; LDAP *ld; LDAPMessage *result_identifier; My_Window *par; Gtk_Notebook *notebook; + Gtk_HBox *xpm_label; Gtk_LdapTreeItem(); Gtk_LdapTreeItem(char *c, My_Window *w); Gtk_LdapTreeItem(GtkTreeItem *t); - int search(); + ~Gtk_LdapTreeItem(); + void setType(int t); + int getDetails(); + int showDetails(); void select_impl(); void collapse_impl(); void expand_impl(); diff --git a/contrib/gtk-tool/Makefile b/contrib/gtk-tool/Makefile index 4fc862a060..65a52f157f 100644 --- a/contrib/gtk-tool/Makefile +++ b/contrib/gtk-tool/Makefile @@ -2,14 +2,14 @@ HOME_LOCATION=$(shell pwd) CC= gcc CPLUS= g++ OPTS=-g -DmyDEBUG -INCLUDES=`gtkmm-config --cflags` -I/usr/include -I/usr/local/gnome/include -I. -LDFLAGS=`gtkmm-config --libs` -L/usr/lib -L/usr/X11/lib -L/usr/local/gnome/lib -L/usr/local/ldap/lib -lldap -llber +INCLUDES=`gtkmm-config --cflags` -I. +LDFLAGS=`gtkmm-config --libs` -L/usr/lib -L/usr/X11/lib -L/usr/local/gnome/lib -L/usr/local/ldap/lib -lldap -llber -L/usr/local/kerberos/lib -lkrb5 -lkrb4 LIBS=-lXext -lgtkmm -lX11 -lXt -lXxf86dga .EXPORT_ALL_VARIABLES: -SOURCES= My_Window.cc My_Scroller.cc Gtk_LdapTreeItem.cc main.cc -OBJECTS= My_Window.o My_Scroller.o Gtk_LdapTreeItem.o main.o +SOURCES= My_Window.cc Gtk_LdapTreeItem.cc main.cc +OBJECTS= My_Window.o Gtk_LdapTreeItem.o main.o ################################################################################ diff --git a/contrib/gtk-tool/My_Window.cc b/contrib/gtk-tool/My_Window.cc index 38d433b0c5..6fbe8c45c9 100644 --- a/contrib/gtk-tool/My_Window.cc +++ b/contrib/gtk-tool/My_Window.cc @@ -9,31 +9,40 @@ My_Window::My_Window(GtkWindowType t) : Gtk_Window(t) { this->scroller = new Gtk_ScrolledWindow(); this->scroller->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); // this->scroller->set_usize(this->height(), 400); - pane->add1(this->scroller); + pane->add1(*this->scroller); this->scroller->show(); - this->scroller2 = new My_Scroller(); +// this->scroller2 = new My_Scroller(); + this->scroller2 = new Gtk_ScrolledWindow(); + this->viewport = new Gtk_Viewport(); this->scroller2->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - pane->add2(this->scroller2); + this->scroller2->add(*this->viewport); + pane->add2(*this->scroller2); this->scroller2->show(); top_hbox = new Gtk_HBox(); this->urlfield = new Gtk_Entry(); - top_hbox->pack_start(this->urlfield, TRUE, TRUE, 1); + top_hbox->pack_start(*this->urlfield, TRUE, TRUE, 1); this->urlfield->show(); this->display_button = new Gtk_Button("Display"); connect_to_method(this->display_button->clicked, this, &do_display); - top_hbox->pack_end(this->display_button, FALSE, FALSE, 1); + top_hbox->pack_end(*this->display_button, FALSE, FALSE, 1); this->display_button->show(); main_hbox = new Gtk_VBox(); - main_hbox->pack_start(top_hbox, FALSE, TRUE, 1); - main_hbox->pack_end(pane, TRUE, TRUE, 1); + main_hbox->pack_start(*top_hbox, FALSE, TRUE, 1); + main_hbox->pack_end(*pane, TRUE, TRUE, 1); top_hbox->show(); pane->show(); this->add(main_hbox); main_hbox->show(); } + +My_Window::~My_Window() { + cout << "~My_Window()" << endl; + delete this; +} + void My_Window::do_display() { cout << this->urlfield->get_text() << endl; } @@ -72,7 +81,9 @@ Gtk_LdapItem* My_Window::make_tree(My_Window *p, LDAP* l_i, char* b_d) { treeitem = new Gtk_LdapTreeItem(c, p); treeitem->dn = b_d; treeitem->ld = l_i; treeresult = new Gtk_LdapItem(); + treeitem->getDetails(); if (entriesCount == 0) { + // treeitem->setType(LEAF_NODE); treeresult->treeitem = new Gtk_LdapTreeItem(*treeitem); treeresult->tree = NULL; return treeresult; @@ -86,19 +97,20 @@ Gtk_LdapItem* My_Window::make_tree(My_Window *p, LDAP* l_i, char* b_d) { s = ldap_explode_dn(ldap_get_dn(l_i, entry), 1); subtreeresult = make_tree(p, l_i, ldap_get_dn(l_i, entry)); subtreeitem = new Gtk_LdapTreeItem(*subtreeresult->treeitem); - subtree->append(subtreeitem); - printf("inserting %s into %s", s[0], c); + // printf("inserting %s into %s", s[0], c); + subtree->append(*subtreeitem); if (subtreeresult->tree != NULL) { - printf("."); + // printf("."); subsubtree = new Gtk_Tree(*subtreeresult->tree); - printf("."); - subtreeitem->set_subtree(subsubtree); - printf("."); + // printf("."); + subtreeitem->set_subtree(*subsubtree); + // printf("."); } subtreeitem->show(); - printf("\n"); + // printf("\n"); entry = ldap_next_entry(l_i, entry); } +// treeitem->setType(BRANCH_NODE); treeresult->treeitem = new Gtk_LdapTreeItem(*treeitem); treeresult->tree = new Gtk_Tree(*subtree); return treeresult; diff --git a/contrib/gtk-tool/My_Window.h b/contrib/gtk-tool/My_Window.h index 7ccce31346..f39091ef0a 100644 --- a/contrib/gtk-tool/My_Window.h +++ b/contrib/gtk-tool/My_Window.h @@ -4,7 +4,7 @@ #include "gtk.h" #include #include -#include "My_Scroller.h" +/*#include "My_Scroller.h"*/ #include "Gtk_LdapItem.h" #include "Gtk_LdapTreeItem.h" class Gtk_LdapTreeItem; @@ -13,12 +13,14 @@ class My_Scroller; class My_Window : public Gtk_Window { public: - Gtk_ScrolledWindow *scroller; - My_Scroller *scroller2; + Gtk_ScrolledWindow *scroller, *scroller2; + Gtk_Viewport *viewport; +// My_Scroller *scroller2; Gtk_Entry *urlfield; Gtk_Button *display_button; Gtk_Paned *pane; My_Window(GtkWindowType t); + ~My_Window(); void do_display(); void expand(Gtk_TreeItem *t); gint delete_event_impl(GdkEventAny *); diff --git a/contrib/gtk-tool/README b/contrib/gtk-tool/README index 35f0660548..fd9a625cb3 100644 --- a/contrib/gtk-tool/README +++ b/contrib/gtk-tool/README @@ -1,13 +1,33 @@ -This is the first version of this README -gtk-tool v0.5delta +README for gtk-tool v0.6 This package has been tested and run with the latest Gtk+/Gtk-- OpenLDAP 1.1-devel. This thing doesn't run as it should, please read TODO! +Just type 'make' to compile and if you have all the necessary stuff it'll do so. +You do need the latest version of Gtk+ and Gtk-- (which may be tricky to build). +After that, hopefully all goes well, you start the thing by doing: +./main + +It will default to base of o=University of Michigan, c=US", localhost, and +LDAP_PORT (389). This is because OpenLDAP comes with the UMICH ldif and the +assumption is that many of you have actually created a test db with that data +(to see that people don't lie when they say OpenLDAP actually works or +something). If you want to change any of these do ./main -h and it will give +you a list of supported parameters. + +In short this is what you can do: + +./main -h ldap-server.somewhere.net -p 28345 -b "o=OpenLDAP Foundation, c=US" + I really couldn't think of anything else to put here (at the moment that is). But please feel free to add whatever else you consider neccessary to understanding how this thing works. Enjoy, and I hope this can be useful to you in some miniscule way. +All emails to -devel list, and plase make sure you put "GTK-TOOL" +in the subject line, so other people who are not interested don't +have to read our garbage. + Pele +pele@openldap.org diff --git a/contrib/gtk-tool/TODO b/contrib/gtk-tool/TODO index a9ce70d042..c8aebd7057 100644 --- a/contrib/gtk-tool/TODO +++ b/contrib/gtk-tool/TODO @@ -1,22 +1,14 @@ LOADS!!! -Someone please figure out how to _remove_ a widget from a container -in Gtk+/Gtk--. As far as I know, and from my discussion with a -certain person, it can't due to a design flaw of Gtk+ people. We -need that first to be able to continue. The bug is reproducable -when you start the thing, it automatically goes to the top node, -i.e. University of Michigan, if you expand the tree a bit, then -click on any one of the items available, it'll blow. That's because -it needs to remove the contents in the right side of the browser -window to be able to insert new things about the current node. And -I didn't want to be an idiot and do it by some other means, because, -as they've taught me in school, OO programming is meant to be used -in a black-box fashion. If all else fails, then we'll start thinking -about stupid solutions and their consenquences. No pun intended. +Priorities: + Make it useful! + Implement searches + port to autoconf (anyone? it should be easy) -All emails to -devel list, and plase make sure you put "GTK-TOOL" -in the subject line, so other people who are not interested don't -have to read our garbage. +Optional: + comments in the source code + port it to NT so we can use it with the NT port of OpenLDAP + (is there a NT port of Gtk+?) Pele pele@openldap.org diff --git a/contrib/gtk-tool/main.cc b/contrib/gtk-tool/main.cc index c5dfb272d3..44c8e41aa5 100644 --- a/contrib/gtk-tool/main.cc +++ b/contrib/gtk-tool/main.cc @@ -11,37 +11,65 @@ int main(int argc, char **argv) { Gtk_LdapItem *treeresult; Gtk_Tree *tree, *subtree; Gtk_LdapTreeItem *treeitem; + Gtk_Viewport *viewport; LDAPMessage **thing; LDAP *ld; - char *base_dn; + char *host = NULL; + char *base_dn = NULL; + int c, port = 0; + + while ((c = getopt(argc, argv, "b:s:p:h")) != -1) { + switch (c) { + case 'b': + base_dn = optarg; break; + case 's': + host = strdup(optarg); break; + case 'p': + port = atoi(optarg); break; + case 'h': + default: + fprintf(stderr, "Usage: %s [-s server] [-p port] [-b base_dn]\n", argv[0]); + exit(-1); + } + } + +// if (base_dn == NULL) base_dn = ldap_get_option(NULL, LDAP_OPT_BASE); + if (base_dn == NULL) base_dn = "o=University of Michigan, c=US"; + if (host == NULL) ldap_get_option(NULL, LDAP_OPT_HOST_NAME, host); + //host = "localhost"; + if (port == 0) port = LDAP_PORT; Gtk_Main m(&argc, &argv); window = new My_Window(GTK_WINDOW_TOPLEVEL); - if ((ld = ldap_open("localhost", LDAP_PORT))==NULL) { + if ((ld = ldap_open(host, port)) == NULL) { perror("connection"); } tree = new Gtk_Tree(); - base_dn = "o=University of Michigan, c=US"; treeresult = window->make_tree(window, ld, base_dn); treeitem = new Gtk_LdapTreeItem(*treeresult->treeitem); - tree->append(treeitem); +// treeresult->treeitem->setType(ROOT_NODE); + tree->append(*treeitem); if (treeresult->tree != NULL) { subtree = new Gtk_Tree(*treeresult->tree); - printf("inserting %s into root\n", base_dn); - treeitem->set_subtree(subtree); + // cout << "Inserting " << base_dn << " into root" << endl; + treeitem->set_subtree(*subtree); } treeitem->show(); - window->scroller->add(tree); + viewport = new Gtk_Viewport(); + viewport->add(tree); + window->scroller->add(viewport); tree->show(); + viewport->show(); window->scroller->show(); - treeitem->search(); + treeitem->showDetails(); +// treeitem->select(); window->set_title("Hello"); window->activate(); - window->set_usize(450, 450); + window->set_usize(600, 500); window->show(); diff --git a/contrib/php3-tool/at.conf b/contrib/php3-tool/at.conf index 9d567611db..b47e498431 100644 --- a/contrib/php3-tool/at.conf +++ b/contrib/php3-tool/at.conf @@ -31,7 +31,7 @@ naminglink,Naming Link,TRUE nobatchupdates,No Batch Updates,FALSE notice,Notice,TRUE o,Organization,TRUE -objectclass,Object Class,FALSE +objectclass,Object Class,TRUE onvacation,On Vacation,TRUE ou,Organizational Unit,TRUE owner,Owner,TRUE diff --git a/contrib/php3-tool/images/I.gif b/contrib/php3-tool/images/I.gif new file mode 100644 index 0000000000..e9067b2030 Binary files /dev/null and b/contrib/php3-tool/images/I.gif differ diff --git a/contrib/php3-tool/images/L.gif b/contrib/php3-tool/images/L.gif new file mode 100644 index 0000000000..a11cead6f8 Binary files /dev/null and b/contrib/php3-tool/images/L.gif differ diff --git a/contrib/php3-tool/images/Lminus.gif b/contrib/php3-tool/images/Lminus.gif new file mode 100644 index 0000000000..c316c834a7 Binary files /dev/null and b/contrib/php3-tool/images/Lminus.gif differ diff --git a/contrib/php3-tool/images/Lplus.gif b/contrib/php3-tool/images/Lplus.gif new file mode 100644 index 0000000000..701c16c778 Binary files /dev/null and b/contrib/php3-tool/images/Lplus.gif differ diff --git a/contrib/php3-tool/images/T.gif b/contrib/php3-tool/images/T.gif new file mode 100644 index 0000000000..5803c1d50a Binary files /dev/null and b/contrib/php3-tool/images/T.gif differ diff --git a/contrib/php3-tool/images/Tminus.gif b/contrib/php3-tool/images/Tminus.gif new file mode 100644 index 0000000000..1a3b056898 Binary files /dev/null and b/contrib/php3-tool/images/Tminus.gif differ diff --git a/contrib/php3-tool/images/Tplus.gif b/contrib/php3-tool/images/Tplus.gif new file mode 100644 index 0000000000..536dbc9a1b Binary files /dev/null and b/contrib/php3-tool/images/Tplus.gif differ diff --git a/contrib/php3-tool/images/foldericon.gif b/contrib/php3-tool/images/foldericon.gif new file mode 100644 index 0000000000..96b709eaf0 Binary files /dev/null and b/contrib/php3-tool/images/foldericon.gif differ diff --git a/contrib/php3-tool/images/htmlicon.gif b/contrib/php3-tool/images/htmlicon.gif new file mode 100644 index 0000000000..2a8fd4f300 Binary files /dev/null and b/contrib/php3-tool/images/htmlicon.gif differ diff --git a/contrib/php3-tool/images/openfoldericon.gif b/contrib/php3-tool/images/openfoldericon.gif new file mode 100644 index 0000000000..c60c811a60 Binary files /dev/null and b/contrib/php3-tool/images/openfoldericon.gif differ diff --git a/contrib/php3-tool/images/top.gif b/contrib/php3-tool/images/top.gif new file mode 100644 index 0000000000..7284af16f3 Binary files /dev/null and b/contrib/php3-tool/images/top.gif differ diff --git a/contrib/php3-tool/images/topopen.gif b/contrib/php3-tool/images/topopen.gif new file mode 100644 index 0000000000..9aa42400ca Binary files /dev/null and b/contrib/php3-tool/images/topopen.gif differ diff --git a/contrib/php3-tool/images/white.gif b/contrib/php3-tool/images/white.gif new file mode 100644 index 0000000000..6a62ac8b2a Binary files /dev/null and b/contrib/php3-tool/images/white.gif differ diff --git a/contrib/php3-tool/include/ldap_entry.inc b/contrib/php3-tool/include/ldap_entry.inc new file mode 100644 index 0000000000..eb9d387578 --- /dev/null +++ b/contrib/php3-tool/include/ldap_entry.inc @@ -0,0 +1,105 @@ +\n"; + $this->link_identifier = $l_i; + } + + cfunction getAttributes() { + $i=0; + $attrib = new ldap_entry_attribute($this->dn); + $n = ldap_first_attribute($this->link_identifier, $this->r_e_i, &$ber); + while ($n) { + $attrib->name = $n; + $attrib->getValues($this->link_identifier,$this->r_e_i); + $this->attributes[$i] = $attrib; + $i++; + $attrib = new ldap_entry_attribute($this->dn); + $n = ldap_next_attribute($this->link_identifier, $this->r_e_i, $ber); + } + } + + cfunction formatHTMLDN($dn) { + global $FILE, $host; + $string = ""; + $attribs = ldap_explode_dn($dn, 0); + $names = ldap_explode_dn($dn, 1); + for ($i=0; $i<$attribs["count"]; $i++) { + $s = $attribs[$i]; + for ($j=$i+1; $j<$attribs["count"]; $j++) { + $s .= ",".$attribs[$j]; + } + if (($s[0] == "c") && ($s[1] == "n")) { + $string .= "".$names[$i].""; + } + else { + $string .= "".$names[$i].""; + } + if ($i<$attribs["count"]-1) { $string .= ", "; } + } + return $string; + } + + cfunction formatHTMLAttributes() { + global $FILE, $host; + $s = ""; + $s .= "\n\t"; + $s .= ''; + $s .= "\n\t\t

".$this->formatHTMLDN($this->dn)."

\n"; + $s .= "\t\t\n\t\n"; + $c = count($this->attributes); + for ($i=0; $i<$c; $i++) { + $attrib = $this->attributes[$i]; + if ($attrib->isVisible($attrib->name) == "TRUE") { + $s .= $attrib->formatHTMLValues(); + } + } + $a = $this->attributes[0]; + $v = $a->values[1]; + if ($v == "organizationalUnit" || $v == "organization") { + $s .= "\n\t\n"; + $s .= "\t\tdn).">Browse\n"; + $s .= "\t\t\n\t\n"; + } + else if ($v == "person") { + $s .= "\n\t\n"; + $s .= "\t\tdn).">Modify\n"; + $s .= "\t\t\n\t\n"; + } + else { + $s .= "\n\t\n\t\t \n\t\t\n\t\n"; + } + return $s; + } + + cfunction display() { + global $FILE, $host; + echo ""; + echo "

".ldap_dn2ufn($this->dn)."

"; + echo ""; + $c = count($this->attributes); + for ($i=0; $i<$c; $i++) { + $attrib = $this->attributes[$i]; + $attrib->display(); + } + $a = $this->attributes[0]; + $v = $a->values[1]; + if ($v == "organizationalUnit" || $v == "organization") { + echo ""; + echo "dn).">Browse"; + echo ""; + } + else { + echo " "; + } + } +} +?> diff --git a/contrib/php3-tool/include/ldap_entry_attribute.inc b/contrib/php3-tool/include/ldap_entry_attribute.inc new file mode 100644 index 0000000000..1d2167c2b4 --- /dev/null +++ b/contrib/php3-tool/include/ldap_entry_attribute.inc @@ -0,0 +1,169 @@ +\n"; + $this->dn = $d; + $a = ldap_explode_dn($this->dn, 1); + $this->cn = $a[0]; + } + + cfunction getAttributeName($string) { + global $prefs; + for ($i=0; $iattribute_names); $i++) { + if ($prefs->attribute_names[$i][0] == $string) { + return $prefs->attribute_names[$i][1]; + } + } + return $string; + } + cfunction isVisible($string) { + global $prefs; + for ($i=0; $iattribute_names); $i++) { + if ($prefs->attribute_names[$i][0] == $string) { + return $prefs->attribute_names[$i][2]; + } + } + return "FALSE"; + } + + cfunction getValues($l_i, $r_e_i) { + //echo "My name is ".$this->name."
\n"; + $this->values = ldap_get_values($l_i, $r_e_i, $this->name); + } + + cfunction display() { + echo "\n\t\n"; + echo "\t\t".$this->name."\n\t\t\n\t\n"; + echo "
    \n"; + for($i=0; $i<$this->values["count"]; $i++) { + //echo "Displaying value ".$i."
    \n"; + echo "
  • "; + $this->displayValue($i); + echo "
    \n"; + } + echo "
\n"; + echo "\n\n"; + } + + cfunction formatHTMLValues() { + $ct = $this->values["count"]; + $str = ""; + $str .= "\n\t\n"; + $n = $this->getAttributeName($this->name); + $str .= "\t\t".$n."\n\t\t\n\t\n\t\t
    \n"; + // if ($ct > 1) { + // $str .= "\t\t
      \n"; + // } + for ($i=0; $i<$this->values["count"]; $i++) { + $str .= "\t\t\t
    • "; + $str .= $this->formatHTMLValue($i); + $str .= "
      \n"; + } + //if ($ct > 1) { $str .= "\t\t\t
    \n"; } + $str .= "\t\t\t
\n\t\t\n\t\n"; + return $str; + } + + cfunction formatHTMLValue($index) { + global $prefs, $FILE, $host; + $p = ""; + switch ($this->name) { + case "cn": + $p .= "dn).">".$this->values[$index].""; + break; + case "ou": + $p .= "dn).">".$this->values[$index].""; + break; + case "seealso": + case "member": + case "requeststo": + case "errorsto": + case "owner": + case "lastmodifiedby": + case "modifiersname": + $p .= "values[$index]).">".ldap_dn2ufn($this->values[$index]).""; + break; + case "mail": + $p .= "values[$index].">".$this->values[$index].""; + break; + case "postaladdress": + case "homepostaladdress": + $i=0; + $tok = strtok($this->values[$index], "$"); + while ($tok) { + $p .= $i." ".$tok."
\n"; + $tok = strtok("$"); + $i++; + } + break; + case "labeledurl": + $tok = strtok($this->values[$index], " "); + $tok2 = strtok("\0"); + $p .= ''.$tok2.''; + break; + case "lastmodifiedtime": + case "modifytimestamp": + $t = $this->values[$index]; + $hour = (int) $t[6].$t[7]; + $minute = (int) $t[8].$t[9]; + $second = (int) $t[10].$t[11]; + $month = (int) $t[2].$t[3]; + $day = (int) $t[4].$t[5]; + $year = (int) $t[0].$t[1]; + $timestamp = mktime($hour, $minute, $second, $month, $day, $year); + $date = date("h:i:sa, on l, dS of F Y", $timestamp); + $p .= $date; + break; + case "jpegphoto": + $p .= 'Image of '.$this->cn.''; + break; + default: + $p .= $this->values[$index]; + break; + } + return $p; + } + + cfunction displayValue($index) { + //echo "ldap_entry_attribute.displayValue(".$index.")
\n"; + global $FILE, $host; + if ($this->name == "cn") { + print "dn).">".$this->values[$index].""; + } + else if ($this->name == "ou") { + print "dn).">".$this->values[$index].""; + } + else if ($this->name == "seealso" || $this->name == "member" || $this->name == "requeststo" || $this->name == "errorsto" || $this->name == "owner" || $this->name == "lastmodifiedby" || $this->name == "modifiersname") { + print "values[$index]).">".ldap_dn2ufn($this->values[$index]).""; + } + else if ($this->name == "mail") { + print "values[$index].">".$this->values[$index].""; + } + else if ($this->name == "labeledurl") { + $tok = strtok($this->values[$index], " "); + $tok2 = strtok("\0"); + print ''.$tok2.''; + } + else if ($this->name == "lastmodifiedtime" || $this->name == "modifytimestamp") { + $t = $this->values[$index]; + $hour = (int) $t[6].$t[7]; + $minute = (int) $t[8].$t[9]; + $second = (int) $t[10].$t[11]; + $month = (int) $t[2].$t[3]; + $day = (int) $t[4].$t[5]; + $year = (int) $t[0].$t[1]; + $timestamp = mktime($hour, $minute, $second, $month, $day, $year); + $date = date("h:i:sa, on l, dS of F Y", $timestamp); + // $date = getdate($timestamp); + // $date = getdate($this->values[$index]); + // echo "".$date["hours"].":".$date["minutes"].", + // ".$date["weekday"].",".$date["month"]." ".$date["mday"].", ".$date["year"]."
\n"; + print $date; + } + else { + print $this->values[$index]; + } + } +} +?> diff --git a/contrib/php3-tool/include/ldap_manager.inc b/contrib/php3-tool/include/ldap_manager.inc new file mode 100644 index 0000000000..6db3fc7911 --- /dev/null +++ b/contrib/php3-tool/include/ldap_manager.inc @@ -0,0 +1,115 @@ +link_identifier = ldap_connect($host); + if ($this->link_identifier) return 1; + return 0; + } + + function disconnect() { + ldap_close($this->link_identifier); + } + + function ldapTakeAction($a = "search") { + $func_ptr = "ldap_".$a; + if ($this->result_identifier = $func_ptr($this->link_identifier, $this->base_dn, $this->search_filter)) { + $this->entriesCount = ldap_count_entries($this->link_identifier, $this->result_identifier); + return 1; + } + return 0; + } + + cfunction getEntries() { + $i=0; + $entry = new ldap_entry($this->link_identifier); + $entry->r_e_i = ldap_first_entry($this->link_identifier, $this->result_identifier); + while($entry->r_e_i) { + $entry->dn = ldap_get_dn($this->link_identifier, $entry->r_e_i); + $entry->getAttributes(); + $this->entries[$i] = $entry; + $i++; + $r = $entry->r_e_i; + $entry = new ldap_entry($this->link_identifier); + $entry->r_e_i = ldap_next_entry($this->link_identifier, $r); + } +// ldap_free_result($this->result_identifier); + } + + cfunction displayEntries() { + echo $this->formatHTMLEntries(); + } + + cfunction formatHTMLBaseDN($dn) { + global $FILE, $host; + $string = ""; + $attribs = ldap_explode_dn($dn, 0); + $names = ldap_explode_dn($dn, 1); + for ($i=0; $i<$attribs["count"]; $i++) { + $s = $attribs[$i]; + for ($j=$i+1; $j<$attribs["count"]; $j++) { + $s .= ",".$attribs[$j]; + } + if (($s[0] == "c") && ($s[1] == "n")) { + $string .= "".$names[$i].", "; + } + else { + $string .= "".$names[$i].", "; + } + } + return $string; + } + + cfunction formatHTMLEntries() { + $string = ""; + $string .= ''; + $string .= "\n"; + for ($i=0; $ientries); $i++) { + $e = $this->entries[$i]; + $string .= $e->formatHTMLAttributes(); + } + $string .= "
\n"; + return $string; + } + + cfunction calculateTime($string, $s_t, $e_t) { + $tok1 = strtok($s_t, " "); + $msecs1 = $tok1; + $tok1 = strtok(" "); + $secs1 = $tok1; + + $tok2 = strtok($e_t, " "); + $msecs2 = $tok2; + $tok2 = strtok(" "); + $secs2 = $tok2; + $t_t = (float) ($secs2 + $msecs2) - (float) ($secs1 + $msecs1); + echo "execution time for ".$string." : ".$t_t." seconds
\n"; + // echo "start: ".$secs1."
\n"; + // echo "end: ".$secs2."
\n"; + return (float) $t_t; + } + + cfunction stripString($string, $tokens) { + $s = $string; + for ($i=0; $i diff --git a/contrib/php3-tool/include/preferences.inc b/contrib/php3-tool/include/preferences.inc new file mode 100644 index 0000000000..11ca8f04f0 --- /dev/null +++ b/contrib/php3-tool/include/preferences.inc @@ -0,0 +1,155 @@ +"; + $sect = array(); + for ($i=0; $isections); $i++) { + $sect = $this->sections[$i]; + // echo $sect[0]."
"; + if ($sect[0] == $s) { + // echo "Found ".$sect[0]."
"; + return $sect[1]; + } + } + // echo "Didn't find ".$s."
"; + } + cfunction get($s) { + $class = explode(".", $s); + $sect = $this->getSection($class[0]); + $values = array(); + $values = $sect[1]; + for ($i=0; $i"; + if ($values[0] == $class[1]) { + // echo "Found ".$values[0]."
"; + return $values[1]; + } + } + // echo "Didn't find ".$class[1]."
"; + } + cfunction getName($s) { + $n = trim(strtok($s, "{")); + return $n; + } + cfunction getBody($s) { + $i = strpos($s, "{") + 1; + $j = strpos($s, "}") - 1; + $tok = substr($s, $i, $j-$i); + return $tok; + } + cfunction getValues($b) { + $t = '" ","\" ","\n"'; + $av_pairs = array(); + $pairs = array(); + $av_pair = array(); + $pairs = explode(";", $b); + for ($i=0; $istripString($av_pair[1], $t)); + // echo "
  • ".$av_pair[0].":".$av_pair[1]; + $av_pairs[$i] = $av_pair; + } + return $av_pairs; + } + cfunction getStatements($s) { + $i = 0; + $end = strpos($s, "}"); + while($end != FALSE) { + $tok = substr($s, 0, $end+1); + $s = substr($s, $end+1, strlen($s)); + // echo "
      "; + $this->sections[$i] = $this->getStatement($tok); + // echo "
    \n"; + $end = strpos($s, "}"); + $i++; + } + // echo count($this->sections)." sections
    "; + } + cfunction getStatement($s) { + $values[0] = $this->getName($s); +// echo "
  • Name ".$values[0]; + $body = $this->getBody($s); +// echo "
  • Values
      "; + $values[1] = $this->getValues($body); +// echo "
  • "; + return $values; + } + cfunction loadPreferences() { + if (count($preferences) != 0) { + echo "I have got ".count($this->sections)." preferences here
    \n"; + } + else { + $fp = fopen("php3tool.conf", "r"); + $i = 0; + $string = ""; + while (!feof($fp)) { + $string .= fgets($fp, 80); + } + fclose($fp); + $this->getStatements($string); + } + $this->loadAttributeNames($this->get("PATH.attributes")); + } + + cfunction loadAttributeNames($s = "at.conf") { + // global $attribute_names; + if (count($this->attribute_names) != 0) { + //This is bullshit here..how do we make php3 + //preserve an array in memory between re-loads? + //And no, I'm not going to send it every time + //I make a subsequent request.. + //If we don't fix these things it won't run + //on anything smaller than a StarFire 10000 + //EVEN THOUGH this stuff is suprisingly fast. + echo "I have got attribute_names here
    \n"; + } + else { + //echo "I dont have attribute_names here
    \n"; + $fp = fopen($s, "r"); + $i = 0; + while (!feof($fp)) { + $string = ""; + $foo = ""; + $string = fgets($fp, 80); + $foo = strtok($string, ","); + $this->attribute_names[$i][0] = $foo; + $foo = strtok(","); + $this->attribute_names[$i][1] = $foo; + $foo = strtok("\n"); + $this->attribute_names[$i][2] = $foo; + $i++; + } + } + // echo "Hello world:".count($this->attribute_names)."\n"; + // for ($i=0; $iattribute_names)-1; $i++) { + // echo $this->attribute_names[$i][0]." - ".$this->attribute_names[$i][1]." - ".$this->attribute_names[$i][2]."
    \n"; + // } + return $this->attribute_names; + } + + cfunction stripString($string, $tokens) { + $s = $string; + for ($i=0; $i diff --git a/contrib/php3-tool/include/query_manager.inc b/contrib/php3-tool/include/query_manager.inc new file mode 100644 index 0000000000..a5a40210e5 --- /dev/null +++ b/contrib/php3-tool/include/query_manager.inc @@ -0,0 +1,141 @@ +
    > +
    + + + +
    +\n"; + for ($i=0; $i\n"; + echo "\n\t\n"; + echo $parameter[0]; + echo "\t\t\n\t"; + echo "\n\t\n"; + echo "\t\t\n"; + echo "\t\t\n\t\n"; + echo "\t\t\n"; + echo "\t\t\n\t\n\n"; + } + echo "\n"; + } + + cfunction display_console() { + echo ''; + echo ''; + echo '

    LDAP Console

    '; + $things = array( + 0 => array("Bind (authenticate) to the directory.", "bind", "who"), + 1 => array("Change the search base.", "cb", "where"), + 2 => array("Change information associated with an entry","change","entry"), + 3 => array("Create a new group entry","create","group"), + 4 => array("Edit a complete Directory entry","vedit","entry"), + 5 => array("Find an entry in the directory.","find","entry") + ); + $this->makeForm($things); + echo ''; + $things = array( + 0 => array("Change the group base.","groupbase","where"), + 1 => array("Display detailed help for a function","help","command"), + 2 => array("Subscribe to a group.","join","group"), + 3 => array("List the groups owned by someone","list","who"), + 4 => array("List out the groups in which someone is a member.", "memberships", "who"), + 5 => array("Remove obsolete entries from a group.", "purge", "group") + ); + $this->makeForm($things); + echo '
    '; + } +} +?> diff --git a/contrib/php3-tool/include/search_form.inc b/contrib/php3-tool/include/search_form.inc new file mode 100644 index 0000000000..6dee433ad7 --- /dev/null +++ b/contrib/php3-tool/include/search_form.inc @@ -0,0 +1,80 @@ + + + + + + + + +
    > +
    + + +
    + + + + +
    +

    +

    > + Find + within + whose
    + + + + +
    +

    +
    + diff --git a/contrib/php3-tool/javascript/expandable-outlines.js b/contrib/php3-tool/javascript/expandable-outlines.js new file mode 100644 index 0000000000..83c1c937af --- /dev/null +++ b/contrib/php3-tool/javascript/expandable-outlines.js @@ -0,0 +1,133 @@ + var bV=parseInt(navigator.appVersion); + NS4=(document.layers) ? true : false; + IE4=((document.all)&&(bV>=4))?true:false; + ver4 = (NS4 || IE4) ? true : false; + function expandIt(){return} + function expandAll(){return} + isExpanded = false; + + function getIndex(el) { + ind = null; + for (i=0; i"); + if (NS4) { + write(".parent {position:absolute; visibility:hidden}"); + write(".child {position:absolute; visibility:hidden}"); + write(".regular {position:absolute; visibility:hidden}") + } + else { + write(".child {display:none}") + } + write("\n"); +} +onload = initIt; diff --git a/contrib/php3-tool/javascript/resize.js b/contrib/php3-tool/javascript/resize.js new file mode 100644 index 0000000000..01dfc1b80f --- /dev/null +++ b/contrib/php3-tool/javascript/resize.js @@ -0,0 +1,21 @@ +/** + * resize.js 0.3 970811 + * by gary smith + * js component for "reloading page onResize" + */ + +if(!window.saveInnerWidth) { + window.onresize = resize; + window.saveInnerWidth = window.innerWidth; + window.saveInnerHeight = window.innerHeight; +} + +function resize() { + if (saveInnerWidth < window.innerWidth || + saveInnerWidth > window.innerWidth || + saveInnerHeight > window.innerHeight || + saveInnerHeight < window.innerHeight ) + { + window.history.go(0); + } +} diff --git a/contrib/php3-tool/php3tool.conf b/contrib/php3-tool/php3tool.conf new file mode 100644 index 0000000000..a71123c4bd --- /dev/null +++ b/contrib/php3-tool/php3tool.conf @@ -0,0 +1,10 @@ +PATH { + attributes: "at.conf"; + photo: "ldap-photo.php3"; +} + +BASE { + basedn: "o=University of Michigan, c=US"; + other: "o=Balorda and Balorda, c=UK"; + other: "o=Simpson Family, c=ES"; +} diff --git a/contrib/php3-tool/style.css b/contrib/php3-tool/style.css new file mode 100644 index 0000000000..f27247ca48 --- /dev/null +++ b/contrib/php3-tool/style.css @@ -0,0 +1,24 @@ + BODY,B,P,H2,H1 { + font-family: lucida sans unicode; + } + BODY,P { + font-weight: bold; + font-size: 12pt; + } + .form { + font-size: 10pt; + color: #003333; + } + H3 { + font-family: Verdana,Arial,Helvetica; + font-size: 12pt; + font-weight: bold; + } + .head { + font-size: 13pt; + color: #003333; + } + .subsection { + font-size: 12pt; + color: #003333; + }