]> git.sur5r.net Git - openldap/blob - contrib/php3-tool/index.php3
Tentative fix for ITS #402. (Not tested yet.) If successful, this patch
[openldap] / contrib / php3-tool / index.php3
1 <!DOCTYPE PUBLIC HTML "-//W3C//HTML3.2 Final//En">
2 <html>
3 <head>
4         <!-- copyright, (C) Predrag Balorda, OpenLDAP Foundation, 1998 -->
5         <title>PHP3 Thingy</title>
6         <link rel="stylesheet" type="text/css" href="style.css">
7 </head>
8 <body>
9 <?
10 include ('include/preferences.inc');
11 include ('include/ldap_manager.inc');
12 include ('include/query_manager.inc');
13 include ('include/search_form.inc');
14 $FILE = "http://$HTTP_HOST$SCRIPT_NAME";
15 $JPEGFILE = "http://$HTTP_HOST/ldap/php3-tool/ldap-photo.php3";
16 $qm = new query_manager;
17 $lm = new ldap_manager;
18 $prefs = new preferences;
19
20 function main() {
21         $main_start_time = microtime();
22         global $lm, $qm, $prefs, $FILE;
23         $qm = new query_manager;
24         $lm = new ldap_manager;
25         $prefs = new preferences;
26         $lm->ldap_action = $qm->get_action();
27         $lm->base_dn = $qm->get_base_dn();
28         $lm->host = $qm->get_host();
29         $lm->search_filter = $qm->get_search_filter();
30         $prefs->loadPreferences();
31         display_advanced_form();
32         if (!$lm->connect($lm->host)) {
33                 echo "Couldn't connect to <b>".$lm->host."</b><br>\n";
34                 echo "Bye";
35                 return 0;
36         }
37         if (!$lm->ldapTakeAction($lm->ldap_action) || $lm->entriesCount == 0) {
38                 echo "Didn't find anything for ".$lm->ldap_action." on ".$lm->search_filter." from ".$lm->base_dn."<br>\n";
39                 return 0;
40         }
41         else {
42         //      echo "I got <b>".$lm->entriesCount."</b> entries for ".$lm->ldap_action." on ".$lm->search_filter." from ".$lm->base_dn."<br>\n";
43                 $get_entries_s_t = microtime();
44                 $lm->getEntries();
45                 $get_entries_e_t = microtime();
46         //      echo "Disconnecting from <b>".$lm->host."</b><br>\n";
47                 $lm->disconnect();
48         }
49         if (($qm->get_mode() == "tree") && ($lm->ldap_action == "list")) {
50                 $display_entries_s_t = microtime();
51                 ?><table width="100%" border=1 cellpadding=0 cellspacing=0>
52                 <tr>
53                         <td bgcolor="#9380DB" align=center valign=absmiddle>
54                                 <h3 class=head><?echo $lm->formatHTMLBaseDN($lm->base_dn);?></h3>
55                                 </td>
56                         </tr>
57                 </table>
58                 <p>
59                 <script language="JavaScript" src="javascript/expandable-outlines.js">
60                 </script><?
61                 $tokens = array( 0 => " ", 1 => ",");
62                 $e = $lm->entries[0];
63                 $s = ldap_dn2ufn($e->dn);
64                 $firstel = $lm->stripString($s, $tokens);
65                 for ($i=0; $i<count($lm->entries); $i++) {
66                         $c = "";
67                         $e = $lm->entries[$i];
68                         $s = ldap_dn2ufn($e->dn);
69                         $tin = $lm->stripString($s, $tokens);
70                         ?><div id="<? echo $tin; ?>Parent" class=parent>
71                         <h3 class=subsection>
72                         <a href="#" onClick="expandIt('<? echo $tin; ?>'); return false">
73                         <img name="imEx" src="false.gif" border=0 alt=""></a>
74                         <? $n = ldap_explode_dn($e->dn, 1); echo $n[0]; ?></h3>
75                         </div>
76                         <div id="<? echo $tin; ?>Child" class=child>
77                         <table border=1 cellspacing=0 cellpadding=0>
78                         <? $c .= $e->formatHTMLAttributes(); echo $c; ?>
79                         </table>
80                         <br>
81                         </div><?
82                 }
83                 ?><script language="JavaScript"><!--
84                 if (NS4) {
85                         firstEl = "<? echo $firstel; ?>Parent";
86                         firstInd = getIndex(firstEl);
87                         showAll();
88                         arrange();
89                 }
90                 //--></script><?
91         }
92         else {
93                 $display_entries_s_t = microtime();
94                 $c = $lm->formatHTMLEntries();
95                 echo $c;
96         }
97         $display_entries_e_t = microtime();
98 //      echo "<div align=right valign=bottom>";
99 //      $t1 = $lm->calculateTime("getEntries()", $get_entries_s_t, $get_entries_e_t);
100 //      $t2 = $lm->calculateTime("displayEntries()", $display_entries_s_t, $display_entries_e_t);
101 //      $main_end_time = microtime();
102 //      $t3 = $lm->calculateTime("main()", $main_start_time, $main_end_time);
103 //      $t = $t3 - ($t1 + $t2);
104 //      echo "Ether : ".$t." seconds<br>\n";
105 //      echo "</div>";
106         return 1;
107 }
108 $return = main();
109 ?>
110 </body>
111 </html>