Merge branch 'bug-1394' into testserver-stable
[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_real_escape_string(trim(stripslashes($_POST['domain'])));
23 if(!strstr($domain, "%")) {
24 $domainsearch = "%$domain%";
25 }
26
27 //check if request is id if not set search ID to -1
28 if(preg_match('/^#(\d+)$/', $domain, $match)) {
29 $domainsearch = "";
30 $domainid = intval($match[1]);
31 } else {
32 $domainid = -1;
33 }
34
35 $query = "select `users`.`id` as `id`, `domains`.`domain` as `domain`, `domains`.`id`as `domid` from `users`,`domains`
36 where `users`.`id`=`domains`.`memid` and
37 (`domains`.`domain` like '$domainsearch' or `domains`.`id`='$domainid') and
38 `domains`.`deleted`=0 and `users`.`deleted`=0 and
39 `users`.`verified`=1
40 group by `users`.`id` limit 100";
41 $res = mysql_query($query);
42 if(mysql_num_rows($res) > 1) { ?>
43 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
44 <tr>
45 <td colspan="5" class="title"><?=_("Select Specific User Account Details")?></td>
46 </tr>
47 <? while($row = mysql_fetch_assoc($res)) { ?>
48 <tr>
49 <td class="DataTD"><?=_("Domain")?>:</td>
50 <td class="DataTD"><?=$row['domid']?></td>
51 <td class="DataTD"><a href="account.php?id=43&amp;userid=<?=$row['id']?>"><?=sanitizeHTML($row['domain'])?></a></td>
52 </tr>
53 <? }
54 if(mysql_num_rows($res) >= 100) { ?>
55 <tr>
56 <td class="DataTD" colspan="3"><?=_("Only the first 100 rows are displayed.")?></td>
57 </tr>
58 <? } else { ?>
59 <tr>
60 <td class="DataTD" colspan="3"><? printf(_("%s rows displayed."), mysql_num_rows($res)); ?></td>
61 </tr>
62 <? } ?>
63 </table><br><br>
64 <? } elseif(mysql_num_rows($res) == 1) {
65 $row = mysql_fetch_assoc($res);
66 $userid = intval($row['id']);
67 } else {
68 ?><table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
69 <tr>
70 <td colspan="5" class="title"><?printf(_("No personal domains found matching %s"), sanitizeHTML($domain));?></td>
71 </tr>
72 </table><br><br><?
73 }
74 $query = "select `orgid`,`domain`,`id` from `orgdomains` where `domain` like '$domainsearch' or `id`='$domainid' limit 100";
75 $res = mysql_query($query);
76 if(mysql_num_rows($res) > 1) { ?>
77 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
78 <tr>
79 <td colspan="5" class="title"><?=_("Select Specific Organisation Account Details")?></td>
80 </tr>
81 <? while($row = mysql_fetch_assoc($res)) { ?>
82 <tr>
83 <td class="DataTD"><?=_("Domain")?>:</td>
84 <td class="DataTD"><?=$row['id']?></td>
85 <td class="DataTD"><a href="account.php?id=26&amp;orgid=<?=intval($row['orgid'])?>"><?=sanitizeHTML($row['domain'])?></a></td>
86 </tr>
87 <? }
88 if(mysql_num_rows($res) >= 100) { ?>
89 <tr>
90 <td class="DataTD" colspan="3"><?=_("Only the first 100 rows are displayed.")?></td>
91 </tr>
92 <? } else { ?>
93 <tr>
94 <td class="DataTD" colspan="3"><? printf(_("%s rows displayed."), mysql_num_rows($res)); ?></td>
95 </tr>
96 <? } ?>
97 </table><br><br>
98 <? } elseif(mysql_num_rows($res) == 1) {
99 $row = mysql_fetch_assoc($res);
100 $userid = intval($row['id']);
101 } else {
102 ?><table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
103 <tr>
104 <td colspan="5" class="title"><?printf(_("No organisational domains found matching %s"), sanitizeHTML($domain));?></td>
105 </tr>
106 </table><br><br><?
107 }
108 }
109
110 if($userid > 0)
111 {
112 header("location: account.php?id=43&userid=".intval($userid));
113 exit;
114 }
115 ?>
116