inc/toolkit.inc.php
author rejo
Wed, 26 Mar 2008 07:40:14 +0000
changeset 83 90fbb34b3d97
parent 82 c255196bc447
child 90 d7bee09d98fe
permissions -rwxr-xr-x
[feladat @ 183] Bugfix. When changing the username of an existing user, an sql error was shown due to bad quoting of a variable.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
     1
<?php
47
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     2
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     3
/*  PowerAdmin, a friendly web-based admin tool for PowerDNS.
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     4
 *  See <https://rejo.zenger.nl/poweradmin> for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     5
 *
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     6
 *  Copyright 2007, 2008  Rejo Zenger <rejo@zenger.nl>
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     7
 *
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     8
 *  This program is free software: you can redistribute it and/or modify
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     9
 *  it under the terms of the GNU General Public License as published by
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    10
 *  the Free Software Foundation, either version 3 of the License, or
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    11
 *  (at your option) any later version.
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    12
 *
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    13
 *  This program is distributed in the hope that it will be useful,
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    16
 *  GNU General Public License for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    17
 *
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    18
 *  You should have received a copy of the GNU General Public License
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    20
 */
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    21
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    22
session_start();
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    23
74
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    24
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    25
if(!@include_once("config.inc.php"))
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    26
{
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    27
	error( _('You have to create a config.inc.php!') );
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    28
}
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    29
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    30
if(is_file( dirname(__FILE__) . '/../install.php'))
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    31
{
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    32
	error( _('You have to remove install.php before this program will run') );
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    33
}
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    34
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    35
if(is_file( dirname(__FILE__) . '/../migrator.php'))
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    36
{
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    37
        error( _('You have to remove migrator.php before this program will run') );
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    38
}
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    39
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    40
/*************
74
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    41
 * Constants *
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    42
 *************/
79
0c0aa144356a [feladat @ 156]
peter
parents: 77
diff changeset
    43
define('ROWAMOUNT', $ROWAMOUNT);
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    44
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    45
if (isset($_GET["start"])) {
79
0c0aa144356a [feladat @ 156]
peter
parents: 77
diff changeset
    46
   define('ROWSTART', (($_GET["start"] - 1) * ROWAMOUNT));
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    47
   } else {
79
0c0aa144356a [feladat @ 156]
peter
parents: 77
diff changeset
    48
   define('ROWSTART', 0);
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    49
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    50
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    51
if (isset($_GET["letter"])) {
79
0c0aa144356a [feladat @ 156]
peter
parents: 77
diff changeset
    52
   define('LETTERSTART', $_GET["letter"]);
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    53
   $_SESSION["letter"] = $_GET["letter"];
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    54
} elseif(isset($_SESSION["letter"])) {
79
0c0aa144356a [feladat @ 156]
peter
parents: 77
diff changeset
    55
   define('LETTERSTART', $_SESSION["letter"]);
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    56
} else {
79
0c0aa144356a [feladat @ 156]
peter
parents: 77
diff changeset
    57
   define('LETTERSTART', "a");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    58
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    59
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    60
/* Database connection */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    61
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    62
require_once("database.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    63
// Generates $db variable to access database.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    64
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
    65
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
    66
// Array of the available zone types
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
    67
$server_types = array("MASTER", "SLAVE", "NATIVE");
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
    68
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
    69
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    70
/*************
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    71
 * Includes  *
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    72
 *************/
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    73
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    74
require_once("error.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    75
require_once("auth.inc.php");
3
64525a2eb098 [feladat @ 4]
rejo
parents: 1
diff changeset
    76
require_once("i18n.inc.php");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    77
require_once("users.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    78
require_once("dns.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    79
require_once("record.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    80
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    81
$db = dbConnect();
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    82
doAuthenticate();
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    83
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    84
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    85
/*************
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    86
 * Functions *
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    87
 *************/
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    88
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    89
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    90
 * Display the page option: [1] [2] .. [n]
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    91
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    92
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    93
function show_pages($amount,$rowamount,$id='')
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    94
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    95
   if ($amount > $rowamount) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    96
      if (!isset($_GET["start"])) $_GET["start"]=1;
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    97
      echo _('Show page') . ":<br>";
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    98
      for ($i=1;$i<=ceil($amount / $rowamount);$i++) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    99
         if ($_GET["start"] == $i) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   100
            echo "[ <b>".$i."</b> ] ";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   101
         } else {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   102
            echo "[ <a href=\"".$_SERVER["PHP_SELF"]."?start=".$i;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   103
	    if ($id!='') echo "&id=".$id;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   104
	    echo "\">".$i."</a> ] ";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   105
         }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   106
      }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   107
   }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   108
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   109
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   110
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   111
 * Display the alphabetic option: [0-9] [a] [b] .. [z]
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   112
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   113
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   114
function show_letters($letterstart,$userid=true)
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   115
{
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   116
        echo _('Show zones beginning with') . ":<br>";
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   117
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   118
	$letter = "[[:digit:]]";
77
e55145eab223 [feladat @ 124]
rejo
parents: 76
diff changeset
   119
	if ($letterstart == "1")
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   120
	{
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   121
		echo "[ <span class=\"lettertaken\">0-9</span> ] ";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   122
	}
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   123
	elseif (zone_letter_start($letter,$userid))
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   124
	{
32
0c2497c1ac01 [feladat @ 79]
rejo
parents: 29
diff changeset
   125
		echo "[ <a href=\"".$_SERVER["PHP_SELF"]."?letter=1\">0-9</a> ] ";
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   126
	}
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   127
	else
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   128
	{
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   129
		echo "[ <span class=\"letternotavailble\">0-9</span> ] ";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   130
	}
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   131
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   132
        foreach (range('a','z') as $letter)
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   133
        {
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   134
                if ($letter == $letterstart)
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   135
                {
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   136
                        echo "[ <span class=\"lettertaken\">".$letter."</span> ] ";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   137
                }
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   138
                elseif (zone_letter_start($letter,$userid))
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   139
                {
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   140
                        echo "[ <a href=\"".$_SERVER["PHP_SELF"]."?letter=".$letter."\">".$letter."</a> ] ";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   141
                }
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   142
                else
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   143
                {
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   144
                        echo "[ <span class=\"letternotavailble\">".$letter."</span> ] ";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   145
                }
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   146
        }
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   147
}
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   148
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   149
function zone_letter_start($letter,$userid=true)
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   150
{
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   151
        global $db;
55
a885f557678f [feladat @ 102]
peter
parents: 47
diff changeset
   152
	global $sql_regexp;
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   153
        $query = "SELECT 
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   154
			domains.id AS domain_id,
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   155
			zones.owner,
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   156
			records.id,
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   157
			domains.name AS domainname
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   158
			FROM domains
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   159
			LEFT JOIN zones ON domains.id=zones.domain_id 
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   160
			LEFT JOIN records ON records.domain_id=domains.id
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   161
			AND substring(domains.name,1,1) ".$sql_regexp." ".$db->quote("^".$letter);
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   162
	$db->setLimit(1);
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   163
        $result = $db->query($query);
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   164
        $numrows = $result->numRows();
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   165
        if ( $numrows == "1" ) {
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   166
                return 1;
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   167
        } else {
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   168
                return 0;
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   169
        }
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   170
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   171
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   172
function error($msg) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   173
	if ($msg) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   174
		echo "     <div class=\"error\">Error: " . $msg . "</div>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   175
	} else {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   176
		echo "     <div class=\"error\">" . _('An unknown error has occurred.') . "</div>\n"; 
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   177
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   178
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   179
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   180
function success($msg) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   181
	if ($msg) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   182
		echo "     <div class=\"success\">" . $msg . "</div>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   183
	} else {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   184
		echo "     <div class=\"success\">" . _('Something has been successfully performed. What exactly, however, will remain a mystery.') . "</div>\n"; 
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   185
	}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   186
}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   187
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   188
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   189
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   190
 * Something has been done nicely, display a message and a back button.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   191
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   192
function message($msg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   193
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   194
    include_once("header.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   195
    ?>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   196
    <P><TABLE CLASS="messagetable"><TR><TD CLASS="message"><H2><?php echo _('Success!'); ?></H2>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   197
    <BR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   198
	<FONT STYLE="font-weight: Bold">
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   199
	<P>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   200
	<?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   201
    if($msg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   202
    {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   203
        echo nl2br($msg);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   204
    }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   205
    else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   206
    {
4
55ed92aa7cf5 [feladat @ 5]
rejo
parents: 3
diff changeset
   207
        echo _('Successful!');
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   208
    }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   209
    ?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   210
    </P>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   211
    <BR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   212
    <P>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   213
    <a href="javascript:history.go(-1)">&lt;&lt; <?php echo _('back'); ?></a></FONT>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   214
    </P>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   215
    </TD></TR></TABLE></P>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   216
    <?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   217
    include_once("footer.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   218
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   219
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   220
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   221
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   222
 * Reroute a user to a cleanpage of (if passed) arg
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   223
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   224
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   225
function clean_page($arg='')
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   226
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   227
	if (!$arg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   228
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   229
		header("Location: ".$_SERVER["PHP_SELF"]."?time=".time());
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   230
		exit;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   231
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   232
	else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   233
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   234
		if (preg_match('!\?!si', $arg))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   235
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   236
			$add = "&time=";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   237
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   238
		else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   239
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   240
			$add = "?time=";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   241
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   242
		header("Location: $arg$add".time());
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   243
		exit;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   244
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   245
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   246
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   247
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   248
function get_status($res)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   249
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   250
	if ($res == '0')
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   251
	{
4
55ed92aa7cf5 [feladat @ 5]
rejo
parents: 3
diff changeset
   252
		return "<FONT CLASS=\"inactive\">" . _('Inactive') . "</FONT>";
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   253
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   254
	elseif ($res == '1')
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   255
	{
4
55ed92aa7cf5 [feladat @ 5]
rejo
parents: 3
diff changeset
   256
		return "<FONT CLASS=\"active\">" . _('Active') . "</FONT>";
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   257
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   258
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   259
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   260
function parse_template_value($val, $domain, $webip, $mailip)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   261
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   262
	$val = str_replace('##DOMAIN##', $domain, $val);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   263
	$val = str_replace('##WEBIP##', $webip, $val);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   264
	$val = str_replace('##MAILIP##', $mailip, $val);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   265
	return $val;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   266
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   267
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   268
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   269
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   270
 * Validates an email address.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   271
 * Checks if there is something before the at '@' sign and its followed by a domain and a tld of minimum 2
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   272
 * and maximum of 4 characters.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   273
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   274
function is_valid_email($email)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   275
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   276
	if(!eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.([a-z]{2,6}$)", $email))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   277
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   278
		return false;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   279
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   280
	return true;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   281
}
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   282
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   283
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   284
function v_num($string) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   285
	if (!eregi("^[0-9]+$", $string)) { 
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   286
		return false ;
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   287
	} else {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   288
		return true ;
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   289
	}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   290
}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   291
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   292
function debug_r($array) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   293
	echo "<pre style=\"border: 2px solid blue;\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   294
	print_r($array);
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   295
	echo "</pre>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   296
}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   297
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   298
?>