Merge branch 'bug-942' into release
[cacert-devel.git] / pages / account / 49.php
1 <? /*
2 LibreSSL - CAcert web application
3 Copyright (C) 2004-2008 CAcert Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; version 2 of the License.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */ ?>
18 <?
19 $userid=0; if(array_key_exists('userid',$_GET)) $userid=intval($_GET['userid']);
20 if($userid <= 0)
21 {
22 $domainsearch = $domain = mysql_escape_string(stripslashes($_POST['domain']));
23 if(!strstr($domain, "%"))
24 $domainsearch = "%$domain%";
25 if(preg_match("/^\d+$/",$domain))
26 $domainsearch = "";
27 $query = "select `users`.`id` as `id`, `domains`.`domain` as `domain`, `domains`.`id`as `domid` from `users`,`domains`
28 where `users`.`id`=`domains`.`memid` and
29 (`domains`.`domain` like '$domainsearch' or `domains`.`id`='$domain') and
30 `domains`.`deleted`=0 and `users`.`deleted`=0 and
31 `users`.`verified`=1
32 group by `users`.`id` limit 100";
33 $res = mysql_query($query);
34 if(mysql_num_rows($res) >= 1) { ?>
35 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
36 <tr>
37 <td colspan="5" class="title"><?=_("Select Specific Account Details")?></td>
38 </tr>
39 <?
40 while($row = mysql_fetch_assoc($res))
41 { ?>
42 <tr>
43 <td class="DataTD"><?=_("Domain")?>:</td>
44 <td class="DataTD"><?=$row['domid']?></td>
45 <td class="DataTD"><a href="account.php?id=43&amp;userid=<?=$row['id']?>"><?=sanitizeHTML($row['domain'])?></a></td>
46 </tr>
47 <? } if(mysql_num_rows($res) >= 100) { ?>
48 <tr>
49 <td class="DataTD" colspan="3"><?=_("Only the first 100 rows are displayed.")?></td>
50 </tr>
51 <? } else { ?>
52 <tr>
53 <td class="DataTD" colspan="3"><? printf(_("%s rows displayed."), mysql_num_rows($res)); ?></td>
54 </tr>
55 <? } ?>
56 </table><br><br>
57 <? } elseif(mysql_num_rows($res) == 1) {
58 $row = mysql_fetch_assoc($res);
59 $_GET['userid'] = intval($row['id']);
60 } else {
61 printf(_("No personal domains found matching %s"), sanitizeHTML($domain));
62 }
63
64 $query = "select `orgid`,`domain`,`id` from `orgdomains` where `domain` like '$domainsearch' or `id`='$domain' limit 100";
65 $res = mysql_query($query);
66 if(mysql_num_rows($res) >= 1) { ?>
67 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
68 <tr>
69 <td colspan="5" class="title"><?=_("Select Specific Account Details")?></td>
70 </tr>
71 <?
72 while($row = mysql_fetch_assoc($res))
73 { ?>
74 <tr>
75 <td class="DataTD"><?=_("Domain")?>:</td>
76 <td class="DataTD"><?=$row['id']?></td>
77 <td class="DataTD"><a href="account.php?id=26&amp;orgid=<?=intval($row['orgid'])?>"><?=sanitizeHTML($row['domain'])?></a></td>
78 </tr>
79 <? } if(mysql_num_rows($res) >= 100) { ?>
80 <tr>
81 <td class="DataTD" colspan="3"><?=_("Only the first 100 rows are displayed.")?></td>
82 </tr>
83 <? } else { ?>
84 <tr>
85 <td class="DataTD" colspan="3"><? printf(_("%s rows displayed."), mysql_num_rows($res)); ?></td>
86 </tr>
87 <? } ?>
88 </table><br><br>
89 <? } elseif(mysql_num_rows($res) == 1) {
90 $row = mysql_fetch_assoc($res);
91 $_GET['userid'] = intval($row['id']);
92 } else {
93 printf(_("No organisational domains found matching %s"), sanitizeHTML($domain));
94 }
95 }
96
97 if($userid > 0)
98 {
99 header("location: account.php?id=43&userid=".intval($_GET['userid']));
100 exit;
101 }
102 ?>
103