diff -r 2cd8c1649ba9 -r 58094faf794d inc/toolkit.inc.php
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/toolkit.inc.php Tue Apr 10 22:40:43 2007 +0000
@@ -0,0 +1,295 @@
+
+session_start();
+// +--------------------------------------------------------------------+
+// | PowerAdmin |
+// +--------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PowerAdmin Team |
+// +--------------------------------------------------------------------+
+// | This source file is subject to the license carried by the overal |
+// | program PowerAdmin as found on http://poweradmin.sf.net |
+// | The PowerAdmin program falls under the QPL License: |
+// | http://www.trolltech.com/developer/licensing/qpl.html |
+// +--------------------------------------------------------------------+
+// | Authors: Roeland Nieuwenhuis trancer nl> |
+// | Sjeemz sjeemz nl> |
+// +--------------------------------------------------------------------+
+
+// Filename: toolkit.inc.php
+// Startdate: 26-10-2002
+// Description: general functions needed on a large variety of locations.
+// Kills the db.inc.php.
+// If you include this file you include the whole 'backend'
+//
+// $Id: toolkit.inc.php,v 1.13 2003/02/24 01:46:31 azurazu Exp $
+//
+
+/*************
+ * Constants *
+ *************/
+
+define(ROWAMOUNT, 500);
+
+if (isset($_GET["start"])) {
+ define(ROWSTART, (($_GET["start"] - 1) * ROWAMOUNT));
+ } else {
+ define(ROWSTART, 0);
+}
+
+if (isset($_GET["letter"])) {
+ define(LETTERSTART, $_GET["letter"]);
+ $_SESSION["letter"] = $_GET["letter"];
+} elseif(isset($_SESSION["letter"])) {
+ define(LETTERSTART, $_SESSION["letter"]);
+} else {
+ define(LETTERSTART, "a");
+}
+
+if(!@include_once("config.inc.php"))
+{
+ error("You have to create a config.inc.php!");
+}
+
+if(is_file( dirname(__FILE__) . '/../install.php'))
+{
+ error("You have to remove install.php before this program will run");
+}
+
+if(is_file( dirname(__FILE__) . '/../migrator.php'))
+{
+ error("You have to remove migrator.php before this program will run");
+}
+
+/* Database connection */
+
+require_once("database.inc.php");
+// Generates $db variable to access database.
+
+/*************
+ * Includes *
+ *************/
+
+require_once("error.inc.php");
+require_once("auth.inc.php");
+require_once("users.inc.php");
+require_once("dns.inc.php");
+require_once("record.inc.php");
+
+
+/*************
+ * Functions *
+ *************/
+
+/*
+ * Display the page option: [1] [2] .. [n]
+ */
+
+function show_pages($amount,$rowamount,$id='')
+{
+ if ($amount > $rowamount) {
+ if (!isset($_GET["start"])) $_GET["start"]=1;
+ echo "
Show page ";
+ for ($i=1;$i<=ceil($amount / $rowamount);$i++) {
+ if ($_GET["start"] == $i) {
+ echo "[ ".$i." ] ";
+ } else {
+ echo "[ ".$i." ] ";
+ }
+ }
+ echo "";
+ }
+}
+
+/*
+ * Display the alphabetic option: [0-9] [a] [b] .. [z]
+ */
+
+function show_letters($letterstart,$doms)
+{
+ foreach ($doms as $dom) {
+ if (is_numeric($dom["name"][0])) {
+ $letter_taken["0"] = 1;
+ } else {
+ $letter_taken[$dom["name"][0]] = 1;
+ }
+ }
+
+ echo "Show domains beginning with:
";
+ if ($letterstart == 1) {
+ echo "[ 0-9 ] ";
+ } elseif ($letter_taken["0"] != 1) {
+ echo "[ 0-9 ] ";
+ } else {
+ echo "[ 0-9 ] ";
+ }
+
+ foreach (range('a','z') as $letter) {
+ if ($letterstart === $letter) {
+ echo "[ ".$letter." ] ";
+ } elseif ($letter_taken[$letter] != 1) {
+ echo "[ ".$letter." ] ";
+ } else {
+ echo "[ ".$letter." ] ";
+ }
+ }
+}
+
+/*
+ * Print a nice useraimed error.
+ */
+function error($msg)
+{
+ // General function for printing critical errors.
+ if ($msg)
+ {
+ include_once("header.inc.php");
+ ?>
+ Oops! An error occured!
+
+ = nl2br($msg) ?>
<< back
|
+
+ include_once("footer.inc.php");
+ die();
+ }
+ else
+ {
+ include_once("footer.inc.php");
+ die("No error specified!");
+ }
+}
+
+/*
+ * Something has been done nicely, display a message and a back button.
+ */
+function message($msg)
+{
+ include_once("header.inc.php");
+ ?>
+ Success!
+
+
+
+
+ if($msg)
+ {
+ echo nl2br($msg);
+ }
+ else
+ {
+ echo "Successful!";
+ }
+ ?>
+
+
+
+ << back
+
+ |
+
+ include_once("footer.inc.php");
+}
+
+
+/*
+ * Reroute a user to a cleanpage of (if passed) arg
+ */
+
+function clean_page($arg='')
+{
+ if (!$arg)
+ {
+ header("Location: ".$_SERVER["PHP_SELF"]."?time=".time());
+ exit;
+ }
+ else
+ {
+ if (preg_match('!\?!si', $arg))
+ {
+ $add = "&time=";
+ }
+ else
+ {
+ $add = "?time=";
+ }
+ header("Location: $arg$add".time());
+ exit;
+ }
+}
+
+function level($l)
+{
+ if ($_SESSION["level"] >= $l)
+ {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+function xs($zoneid)
+{
+ global $db;
+ if (is_numeric($zoneid) && is_numeric($_SESSION["level"]))
+ {
+ $result = $db->query("SELECT id FROM zones WHERE owner=".$_SESSION["userid"]." AND domain_id=$zoneid");
+ $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");
+
+ if ($result->numRows() == 1 || $_SESSION["level"] >= 5)
+ {
+ $_SESSION[$zoneid."_ispartial"] = 0;
+ return true;
+ }
+ elseif ($result_extra->numRows() == 1)
+ {
+ $_SESSION[$zoneid."_ispartial"] = 1;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+}
+
+function get_status($res)
+{
+ if ($res == '0')
+ {
+ return "Inactive";
+ }
+ elseif ($res == '1')
+ {
+ return "Active";
+ }
+}
+
+function parse_template_value($val, $domain, $webip, $mailip)
+{
+ $val = str_replace('##DOMAIN##', $domain, $val);
+ $val = str_replace('##WEBIP##', $webip, $val);
+ $val = str_replace('##MAILIP##', $mailip, $val);
+ return $val;
+}
+
+
+/*
+ * Validates an email address.
+ * Checks if there is something before the at '@' sign and its followed by a domain and a tld of minimum 2
+ * and maximum of 4 characters.
+ */
+function is_valid_email($email)
+{
+ if(!eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.([a-z]{2,6}$)", $email))
+ {
+ return false;
+ }
+ return true;
+}
+?>