address book saves stuff between instances
[squirrelmail.git] / src / addrbook_search_html.php
1 <?php
2 /**
3 ** addrbook_search.php
4 **
5 ** Handle addressbook searching with pure html. This file is included from compose.php
6 **
7 **/
8
9 session_start();
10
11 if (!isset($config_php))
12 include("../config/config.php");
13 if (!isset($strings_php))
14 include("../functions/strings.php");
15 if (!isset($page_header_php))
16 include("../functions/page_header.php");
17 if (!isset($imap_php))
18 include("../functions/imap.php");
19 if (!isset($date_php))
20 include("../functions/date.php");
21 if (!isset($mime_php))
22 include("../functions/mime.php");
23 if (!isset($smtp_php))
24 include("../functions/smtp.php");
25 if (!isset($display_messages_php))
26 include("../functions/display_messages.php");
27 if (!isset($addressbook_php))
28 include("../functions/addressbook.php");
29
30 include("../src/load_prefs.php");
31
32
33 echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
34 displayPageHeader($color, "None");
35 //<form method=post action="compose.php?html_addr_search=true">
36
37 $body = stripslashes($body);
38 $send_to = stripslashes($send_to);
39 $send_to_cc = stripslashes($send_to_cc);
40 $send_to_bcc = stripslashes($send_to_bcc);
41 $subject = stripslashes($subject);
42
43 echo "<center>";
44 echo "<form method=post action=\"compose.php?html_addr_search=true\">";
45 echo " <input type=text value=\"$query\"name=query>";
46 echo " <input type=submit value=Submit>";
47 echo " <input type=hidden value=\"$body\" name=body>";
48 echo " <input type=hidden value=\"$subject\" name=subject>";
49 echo " <input type=hidden value=\"$send_to\" name=send_to>";
50 echo " <input type=hidden value=\"$send_to_cc\" name=send_to_cc>";
51 echo " <input type=hidden value=\"$send_to_bcc\" name=send_to_bcc>";
52 echo "</form>";
53 echo "</center>";
54
55 if(!empty($query)) {
56 $abook = addressbook_init();
57 $res = $abook->s_search($query);
58
59 if(!is_array($res)) {
60 printf("<P ALIGN=center><BR>%s:<br>%s</P>\n</BODY></HTML>\n",
61 _("Your search failed with the following error(s)"),
62 $abook->error);
63 exit;
64 }
65
66 if(sizeof($res) == 0) {
67 printf("<P ALIGN=center><BR>%s.</P>\n</BODY></HTML>\n",
68 _("No persons matching your search was found"));
69 exit;
70 }
71
72 // List search results
73 $line = 0;
74 print "<table border=0 width=\"98%\" align=center>";
75 printf("<tr bgcolor=\"$color[9]\"><TH align=left>&nbsp;".
76 "<TH align=left>&nbsp;%s<TH align=left>&nbsp;%s".
77 "<TH align=left>&nbsp;%s<TH align=left width=\"10%%\">".
78 "&nbsp;%s</tr>\n",
79 _("Name"), _("E-mail"), _("Info"), _("Source"));
80
81 ?>
82 <form method=post action"compose.php?html_addr_search_done=true">
83 <?
84 echo " <input type=hidden value=\"$body\" name=body>";
85 echo " <input type=hidden value=\"$subject\" name=subject>";
86 echo " <input type=hidden value=\"$send_to\" name=send_to>";
87 echo " <input type=hidden value=\"$send_to_cc\" name=send_to_cc>";
88 echo " <input type=hidden value=\"$send_to_bcc\" name=send_to_bcc>";
89
90 while(list($key, $row) = each($res)) {
91 printf("<tr%s nowrap><td nowrap align=center width=\"5%%\">".
92 "<input type=checkbox name=send_to_search[] value=\"%s\">&nbsp;To".
93 "<input type=checkbox name=send_to_cc_search[] value=\"%s\">&nbsp;Cc&nbsp;".
94 "<td nowrap>&nbsp;%s&nbsp;<td nowrap>&nbsp;".
95 "%s".
96 "<td nowrap>&nbsp;%s&nbsp;<td nowrap>&nbsp;%s</tr>\n",
97 ($line % 2) ? " bgcolor=\"$color[0]\"" : "", $row["email"],
98 $row["email"], $row["name"], $row["email"],
99 $row["label"], $row["source"]);
100 $line++;
101 }
102 print "</TABLE>";
103 echo "<input type=hidden value=1 name=html_addr_search_done>";
104 echo "<center><input type=submit value=addr_search_done name=\"Use Addresses\"></center>";
105 echo "</form>";
106 }
107
108 ?>