1
+ − 1
<?
+ − 2
session_start ();
+ − 3
+ − 4
/*************
+ − 5
* Constants *
+ − 6
*************/
+ − 7
+ − 8
define ( ROWAMOUNT , 500 );
+ − 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
+ − 91
function show_letters ( $letterstart , $doms )
+ − 92
{
+ − 93
foreach ( $doms as $dom ) {
+ − 94
if ( is_numeric ( $dom [ "name" ][ 0 ])) {
+ − 95
$letter_taken [ "0" ] = 1 ;
+ − 96
} else {
+ − 97
$letter_taken [ $dom [ "name" ][ 0 ]] = 1 ;
+ − 98
}
+ − 99
}
+ − 100
13
+ − 101
echo _ ( 'Show zones beginning with:' ) . "<br>" ;
1
+ − 102
if ( $letterstart == 1 ) {
+ − 103
echo "[ <b>0-9</b> ] " ;
+ − 104
} elseif ( $letter_taken [ "0" ] != 1 ) {
+ − 105
echo "[ 0-9 ] " ;
+ − 106
} else {
+ − 107
echo "[ <a href= \" " . $_SERVER [ "PHP_SELF" ] . "?letter=1 \" >0-9</a> ] " ;
+ − 108
}
+ − 109
+ − 110
foreach ( range ( 'a' , 'z' ) as $letter ) {
+ − 111
if ( $letterstart === $letter ) {
13
+ − 112
echo "[ <span class= \" lettertaken \" >" . $letter . "</span> ] " ;
1
+ − 113
} elseif ( $letter_taken [ $letter ] != 1 ) {
13
+ − 114
echo "[ <span class= \" letternotavailble \" >" . $letter . "</span> ] " ;
1
+ − 115
} else {
+ − 116
echo "[ <a href= \" " . $_SERVER [ "PHP_SELF" ] . "?letter=" . $letter . " \" >" . $letter . "</a> ] " ;
+ − 117
}
+ − 118
}
+ − 119
}
+ − 120
+ − 121
/*
+ − 122
* Print a nice useraimed error.
+ − 123
*/
+ − 124
function error ( $msg )
+ − 125
{
+ − 126
// General function for printing critical errors.
+ − 127
if ( $msg )
+ − 128
{
+ − 129
include_once ( "header.inc.php" );
+ − 130
?>
13
+ − 131
<p> <? echo _ ( 'Oops! An error occured!' ); ?> </p>
+ − 132
<p> <? echo nl2br ( $msg ) ?> </p>
1
+ − 133
<?
+ − 134
include_once ( "footer.inc.php" );
+ − 135
die ();
+ − 136
}
+ − 137
else
+ − 138
{
+ − 139
include_once ( "footer.inc.php" );
+ − 140
die ( "No error specified!" );
+ − 141
}
+ − 142
}
+ − 143
+ − 144
/*
+ − 145
* Something has been done nicely, display a message and a back button.
+ − 146
*/
+ − 147
function message ( $msg )
+ − 148
{
+ − 149
include_once ( "header.inc.php" );
+ − 150
?>
4
+ − 151
<P><TABLE CLASS="messagetable"><TR><TD CLASS="message"><H2> <? echo _ ( 'Success!' ); ?> </H2>
1
+ − 152
<BR>
+ − 153
<FONT STYLE="font-weight: Bold">
+ − 154
<P>
+ − 155
<?
+ − 156
if ( $msg )
+ − 157
{
+ − 158
echo nl2br ( $msg );
+ − 159
}
+ − 160
else
+ − 161
{
4
+ − 162
echo _ ( 'Successful!' );
1
+ − 163
}
+ − 164
?>
+ − 165
</P>
+ − 166
<BR>
+ − 167
<P>
4
+ − 168
<a href="javascript:history.go(-1)"><< <? echo _ ( 'back' ); ?> </a></FONT>
1
+ − 169
</P>
+ − 170
</TD></TR></TABLE></P>
+ − 171
<?
+ − 172
include_once ( "footer.inc.php" );
+ − 173
}
+ − 174
+ − 175
+ − 176
/*
+ − 177
* Reroute a user to a cleanpage of (if passed) arg
+ − 178
*/
+ − 179
+ − 180
function clean_page ( $arg = '' )
+ − 181
{
+ − 182
if ( ! $arg )
+ − 183
{
+ − 184
header ( "Location: " . $_SERVER [ "PHP_SELF" ] . "?time=" . time ());
+ − 185
exit ;
+ − 186
}
+ − 187
else
+ − 188
{
+ − 189
if ( preg_match ( '!\?!si' , $arg ))
+ − 190
{
+ − 191
$add = "&time=" ;
+ − 192
}
+ − 193
else
+ − 194
{
+ − 195
$add = "?time=" ;
+ − 196
}
+ − 197
header ( "Location: $arg$add " . time ());
+ − 198
exit ;
+ − 199
}
+ − 200
}
+ − 201
+ − 202
function level ( $l )
+ − 203
{
+ − 204
if ( $_SESSION [ "level" ] >= $l )
+ − 205
{
+ − 206
return 1 ;
+ − 207
}
+ − 208
else
+ − 209
{
+ − 210
return 0 ;
+ − 211
}
+ − 212
}
+ − 213
+ − 214
function xs ( $zoneid )
+ − 215
{
+ − 216
global $db ;
+ − 217
if ( is_numeric ( $zoneid ) && is_numeric ( $_SESSION [ "level" ]))
+ − 218
{
+ − 219
$result = $db -> query ( "SELECT id FROM zones WHERE owner=" . $_SESSION [ "userid" ] . " AND domain_id= $zoneid " );
+ − 220
$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" );
+ − 221
+ − 222
if ( $result -> numRows () == 1 || $_SESSION [ "level" ] >= 5 )
+ − 223
{
+ − 224
$_SESSION [ $zoneid . "_ispartial" ] = 0 ;
+ − 225
return true ;
+ − 226
}
+ − 227
elseif ( $result_extra -> numRows () == 1 )
+ − 228
{
+ − 229
$_SESSION [ $zoneid . "_ispartial" ] = 1 ;
+ − 230
return true ;
+ − 231
}
+ − 232
else
+ − 233
{
+ − 234
return false ;
+ − 235
}
+ − 236
}
+ − 237
else
+ − 238
{
+ − 239
return false ;
+ − 240
}
+ − 241
}
+ − 242
+ − 243
function get_status ( $res )
+ − 244
{
+ − 245
if ( $res == '0' )
+ − 246
{
4
+ − 247
return "<FONT CLASS= \" inactive \" >" . _ ( 'Inactive' ) . "</FONT>" ;
1
+ − 248
}
+ − 249
elseif ( $res == '1' )
+ − 250
{
4
+ − 251
return "<FONT CLASS= \" active \" >" . _ ( 'Active' ) . "</FONT>" ;
1
+ − 252
}
+ − 253
}
+ − 254
+ − 255
function parse_template_value ( $val , $domain , $webip , $mailip )
+ − 256
{
+ − 257
$val = str_replace ( '##DOMAIN##' , $domain , $val );
+ − 258
$val = str_replace ( '##WEBIP##' , $webip , $val );
+ − 259
$val = str_replace ( '##MAILIP##' , $mailip , $val );
+ − 260
return $val ;
+ − 261
}
+ − 262
+ − 263
+ − 264
/*
+ − 265
* Validates an email address.
+ − 266
* Checks if there is something before the at '@' sign and its followed by a domain and a tld of minimum 2
+ − 267
* and maximum of 4 characters.
+ − 268
*/
+ − 269
function is_valid_email ( $email )
+ − 270
{
+ − 271
if ( ! eregi ( "^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])* \\ .([a-z]{2,6}$)" , $email ))
+ − 272
{
+ − 273
return false ;
+ − 274
}
+ − 275
return true ;
+ − 276
}
+ − 277
?>