1
|
1 |
<? |
|
2 |
session_start(); |
|
3 |
|
|
4 |
/************* |
|
5 |
* Constants * |
|
6 |
*************/ |
|
7 |
|
23
|
8 |
define(ROWAMOUNT, 50); |
1
|
9 |
|
|
10 |
if (isset($_GET["start"])) { |
|
11 |
define(ROWSTART, (($_GET["start"] - 1) * ROWAMOUNT)); |
|
12 |
} else { |
|
13 |
define(ROWSTART, 0); |
|
14 |
} |
|
15 |
|
|
16 |
if (isset($_GET["letter"])) { |
|
17 |
define(LETTERSTART, $_GET["letter"]); |
|
18 |
$_SESSION["letter"] = $_GET["letter"]; |
|
19 |
} elseif(isset($_SESSION["letter"])) { |
|
20 |
define(LETTERSTART, $_SESSION["letter"]); |
|
21 |
} else { |
|
22 |
define(LETTERSTART, "a"); |
|
23 |
} |
|
24 |
|
|
25 |
if(!@include_once("config.inc.php")) |
|
26 |
{ |
6
|
27 |
error( _('You have to create a config.inc.php!') ); |
1
|
28 |
} |
|
29 |
|
|
30 |
if(is_file( dirname(__FILE__) . '/../install.php')) |
|
31 |
{ |
6
|
32 |
error( _('You have to remove install.php before this program will run') ); |
1
|
33 |
} |
|
34 |
|
|
35 |
if(is_file( dirname(__FILE__) . '/../migrator.php')) |
|
36 |
{ |
6
|
37 |
error( _('You have to remove migrator.php before this program will run') ); |
1
|
38 |
} |
|
39 |
|
|
40 |
/* Database connection */ |
|
41 |
|
|
42 |
require_once("database.inc.php"); |
|
43 |
// Generates $db variable to access database. |
|
44 |
|
13
|
45 |
|
|
46 |
// Array of the available zone types |
|
47 |
$server_types = array("MASTER", "SLAVE", "NATIVE"); |
|
48 |
|
|
49 |
|
1
|
50 |
/************* |
|
51 |
* Includes * |
|
52 |
*************/ |
|
53 |
|
|
54 |
require_once("error.inc.php"); |
|
55 |
require_once("auth.inc.php"); |
3
|
56 |
require_once("i18n.inc.php"); |
1
|
57 |
require_once("users.inc.php"); |
|
58 |
require_once("dns.inc.php"); |
|
59 |
require_once("record.inc.php"); |
|
60 |
|
|
61 |
|
|
62 |
/************* |
|
63 |
* Functions * |
|
64 |
*************/ |
|
65 |
|
|
66 |
/* |
|
67 |
* Display the page option: [1] [2] .. [n] |
|
68 |
*/ |
|
69 |
|
|
70 |
function show_pages($amount,$rowamount,$id='') |
|
71 |
{ |
|
72 |
if ($amount > $rowamount) { |
|
73 |
if (!isset($_GET["start"])) $_GET["start"]=1; |
13
|
74 |
echo _('Show page') . "<br>"; |
1
|
75 |
for ($i=1;$i<=ceil($amount / $rowamount);$i++) { |
|
76 |
if ($_GET["start"] == $i) { |
|
77 |
echo "[ <b>".$i."</b> ] "; |
|
78 |
} else { |
|
79 |
echo "[ <a href=\"".$_SERVER["PHP_SELF"]."?start=".$i; |
|
80 |
if ($id!='') echo "&id=".$id; |
|
81 |
echo "\">".$i."</a> ] "; |
|
82 |
} |
|
83 |
} |
|
84 |
} |
|
85 |
} |
|
86 |
|
|
87 |
/* |
|
88 |
* Display the alphabetic option: [0-9] [a] [b] .. [z] |
|
89 |
*/ |
|
90 |
|
29
|
91 |
function show_letters($letterstart,$userid=true) |
1
|
92 |
{ |
29
|
93 |
echo _('Show zones beginning with:') . "<br>"; |
|
94 |
|
|
95 |
$letter = "[[:digit:]]"; |
|
96 |
if ($letterstart == "0") |
|
97 |
{ |
|
98 |
echo "[ <span class=\"lettertaken\">0-9</span> ] "; |
|
99 |
} |
|
100 |
elseif (zone_letter_start($letter,$userid)) |
|
101 |
{ |
32
|
102 |
echo "[ <a href=\"".$_SERVER["PHP_SELF"]."?letter=1\">0-9</a> ] "; |
29
|
103 |
} |
|
104 |
else |
|
105 |
{ |
|
106 |
echo "[ <span class=\"letternotavailble\">0-9</span> ] "; |
|
107 |
} |
1
|
108 |
|
29
|
109 |
foreach (range('a','z') as $letter) |
|
110 |
{ |
|
111 |
if ($letter == $letterstart) |
|
112 |
{ |
|
113 |
echo "[ <span class=\"lettertaken\">".$letter."</span> ] "; |
|
114 |
} |
|
115 |
elseif (zone_letter_start($letter,$userid)) |
|
116 |
{ |
|
117 |
echo "[ <a href=\"".$_SERVER["PHP_SELF"]."?letter=".$letter."\">".$letter."</a> ] "; |
|
118 |
} |
|
119 |
else |
|
120 |
{ |
|
121 |
echo "[ <span class=\"letternotavailble\">".$letter."</span> ] "; |
|
122 |
} |
|
123 |
} |
|
124 |
} |
|
125 |
|
|
126 |
function zone_letter_start($letter,$userid=true) |
|
127 |
{ |
|
128 |
global $db; |
|
129 |
$sqlq = "SELECT domains.id AS domain_id, |
|
130 |
zones.owner, |
|
131 |
records.id, |
|
132 |
domains.name AS domainname |
|
133 |
FROM domains |
|
134 |
LEFT JOIN zones ON domains.id=zones.domain_id |
|
135 |
LEFT JOIN records ON records.domain_id=domains.id |
|
136 |
WHERE 1"; |
|
137 |
if((!level(5) || !$userid) && !level(10) && !level(5)) |
|
138 |
{ |
|
139 |
$sqlq .= " AND zones.owner=".$_SESSION["userid"]; |
|
140 |
} |
|
141 |
$sqlq .= " AND substring(domains.name,1,1) REGEXP '^".$letter."' LIMIT 1"; |
|
142 |
$result = $db->query($sqlq); |
|
143 |
$numrows = $result->numRows(); |
|
144 |
if ( $numrows == "1" ) |
|
145 |
{ |
|
146 |
return 1; |
|
147 |
} |
|
148 |
else |
|
149 |
{ |
|
150 |
return 0; |
|
151 |
} |
1
|
152 |
} |
|
153 |
|
|
154 |
/* |
|
155 |
* Print a nice useraimed error. |
|
156 |
*/ |
|
157 |
function error($msg) |
|
158 |
{ |
|
159 |
// General function for printing critical errors. |
|
160 |
if ($msg) |
|
161 |
{ |
|
162 |
include_once("header.inc.php"); |
|
163 |
?> |
13
|
164 |
<p><? echo _('Oops! An error occured!'); ?></p> |
|
165 |
<p><? echo nl2br($msg) ?></p> |
1
|
166 |
<? |
|
167 |
include_once("footer.inc.php"); |
|
168 |
die(); |
|
169 |
} |
|
170 |
else |
|
171 |
{ |
|
172 |
include_once("footer.inc.php"); |
|
173 |
die("No error specified!"); |
|
174 |
} |
|
175 |
} |
|
176 |
|
|
177 |
/* |
|
178 |
* Something has been done nicely, display a message and a back button. |
|
179 |
*/ |
|
180 |
function message($msg) |
|
181 |
{ |
|
182 |
include_once("header.inc.php"); |
|
183 |
?> |
4
|
184 |
<P><TABLE CLASS="messagetable"><TR><TD CLASS="message"><H2><? echo _('Success!'); ?></H2> |
1
|
185 |
<BR> |
|
186 |
<FONT STYLE="font-weight: Bold"> |
|
187 |
<P> |
|
188 |
<? |
|
189 |
if($msg) |
|
190 |
{ |
|
191 |
echo nl2br($msg); |
|
192 |
} |
|
193 |
else |
|
194 |
{ |
4
|
195 |
echo _('Successful!'); |
1
|
196 |
} |
|
197 |
?> |
|
198 |
</P> |
|
199 |
<BR> |
|
200 |
<P> |
4
|
201 |
<a href="javascript:history.go(-1)"><< <? echo _('back'); ?></a></FONT> |
1
|
202 |
</P> |
|
203 |
</TD></TR></TABLE></P> |
|
204 |
<? |
|
205 |
include_once("footer.inc.php"); |
|
206 |
} |
|
207 |
|
|
208 |
|
|
209 |
/* |
|
210 |
* Reroute a user to a cleanpage of (if passed) arg |
|
211 |
*/ |
|
212 |
|
|
213 |
function clean_page($arg='') |
|
214 |
{ |
|
215 |
if (!$arg) |
|
216 |
{ |
|
217 |
header("Location: ".$_SERVER["PHP_SELF"]."?time=".time()); |
|
218 |
exit; |
|
219 |
} |
|
220 |
else |
|
221 |
{ |
|
222 |
if (preg_match('!\?!si', $arg)) |
|
223 |
{ |
|
224 |
$add = "&time="; |
|
225 |
} |
|
226 |
else |
|
227 |
{ |
|
228 |
$add = "?time="; |
|
229 |
} |
|
230 |
header("Location: $arg$add".time()); |
|
231 |
exit; |
|
232 |
} |
|
233 |
} |
|
234 |
|
|
235 |
function level($l) |
|
236 |
{ |
|
237 |
if ($_SESSION["level"] >= $l) |
|
238 |
{ |
|
239 |
return 1; |
|
240 |
} |
|
241 |
else |
|
242 |
{ |
|
243 |
return 0; |
|
244 |
} |
|
245 |
} |
|
246 |
|
|
247 |
function xs($zoneid) |
|
248 |
{ |
|
249 |
global $db; |
|
250 |
if (is_numeric($zoneid) && is_numeric($_SESSION["level"])) |
|
251 |
{ |
|
252 |
$result = $db->query("SELECT id FROM zones WHERE owner=".$_SESSION["userid"]." AND domain_id=$zoneid"); |
|
253 |
$result_extra = $db->query("SELECT record_owners.id FROM record_owners,records WHERE record_owners.user_id=".$_SESSION["userid"]." AND records.domain_id = $zoneid AND records.id = record_owners.record_id LIMIT 1"); |
|
254 |
|
|
255 |
if ($result->numRows() == 1 || $_SESSION["level"] >= 5) |
|
256 |
{ |
|
257 |
$_SESSION[$zoneid."_ispartial"] = 0; |
|
258 |
return true; |
|
259 |
} |
|
260 |
elseif ($result_extra->numRows() == 1) |
|
261 |
{ |
|
262 |
$_SESSION[$zoneid."_ispartial"] = 1; |
|
263 |
return true; |
|
264 |
} |
|
265 |
else |
|
266 |
{ |
|
267 |
return false; |
|
268 |
} |
|
269 |
} |
|
270 |
else |
|
271 |
{ |
|
272 |
return false; |
|
273 |
} |
|
274 |
} |
|
275 |
|
|
276 |
function get_status($res) |
|
277 |
{ |
|
278 |
if ($res == '0') |
|
279 |
{ |
4
|
280 |
return "<FONT CLASS=\"inactive\">" . _('Inactive') . "</FONT>"; |
1
|
281 |
} |
|
282 |
elseif ($res == '1') |
|
283 |
{ |
4
|
284 |
return "<FONT CLASS=\"active\">" . _('Active') . "</FONT>"; |
1
|
285 |
} |
|
286 |
} |
|
287 |
|
|
288 |
function parse_template_value($val, $domain, $webip, $mailip) |
|
289 |
{ |
|
290 |
$val = str_replace('##DOMAIN##', $domain, $val); |
|
291 |
$val = str_replace('##WEBIP##', $webip, $val); |
|
292 |
$val = str_replace('##MAILIP##', $mailip, $val); |
|
293 |
return $val; |
|
294 |
} |
|
295 |
|
|
296 |
|
|
297 |
/* |
|
298 |
* Validates an email address. |
|
299 |
* Checks if there is something before the at '@' sign and its followed by a domain and a tld of minimum 2 |
|
300 |
* and maximum of 4 characters. |
|
301 |
*/ |
|
302 |
function is_valid_email($email) |
|
303 |
{ |
|
304 |
if(!eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.([a-z]{2,6}$)", $email)) |
|
305 |
{ |
|
306 |
return false; |
|
307 |
} |
|
308 |
return true; |
|
309 |
} |
|
310 |
?> |