diff -r c72d6d51f3d3 -r c255196bc447 inc/toolkit.inc.php --- a/inc/toolkit.inc.php Wed Mar 12 20:45:56 2008 +0000 +++ b/inc/toolkit.inc.php Tue Mar 25 22:45:31 2008 +0000 @@ -22,7 +22,6 @@ session_start(); - if(!@include_once("config.inc.php")) { error( _('You have to create a config.inc.php!') ); @@ -79,6 +78,9 @@ require_once("dns.inc.php"); require_once("record.inc.php"); +$db = dbConnect(); +doAuthenticate(); + /************* * Functions * @@ -92,7 +94,7 @@ { if ($amount > $rowamount) { if (!isset($_GET["start"])) $_GET["start"]=1; - echo _('Show page') . "
"; + echo _('Show page') . ":
"; for ($i=1;$i<=ceil($amount / $rowamount);$i++) { if ($_GET["start"] == $i) { echo "[ ".$i." ] "; @@ -111,7 +113,7 @@ function show_letters($letterstart,$userid=true) { - echo _('Show zones beginning with:') . "
"; + echo _('Show zones beginning with') . ":
"; $letter = "[[:digit:]]"; if ($letterstart == "1") @@ -148,68 +150,42 @@ { global $db; global $sql_regexp; - $sqlq = "SELECT domains.id AS domain_id, - zones.owner, - records.id, - domains.name AS domainname - FROM domains - LEFT JOIN zones ON domains.id=zones.domain_id - LEFT JOIN records ON records.domain_id=domains.id - WHERE 1=1"; - if((!level(5) || !$userid) && !level(10) && !level(5)) - { - // First select the zones for which we have ownership on one or more records. - $query = 'SELECT records.domain_id FROM records, record_owners WHERE user_id = '.$db->quote($_SESSION['userid']).' AND records.id = record_owners.record_id'; - $result = $db->query($query); - $zones = array(); - if (!PEAR::isError($result)) { - $zones = $result->fetchCol(); - } - - $sqlq .= " AND (zones.owner=".$db->quote($_SESSION["userid"]); - if (count($zones) > 0) { - $sqlq .= ' OR zones.domain_id IN ('.implode(',', $zones).') '; - - } - $sqlq .= ')'; - } - $sqlq .= " AND substring(domains.name,1,1) ".$sql_regexp." ".$db->quote("^".$letter); - $db->setLimit(1); - $result = $db->query($sqlq); + $query = "SELECT + domains.id AS domain_id, + zones.owner, + records.id, + domains.name AS domainname + FROM domains + LEFT JOIN zones ON domains.id=zones.domain_id + LEFT JOIN records ON records.domain_id=domains.id + AND substring(domains.name,1,1) ".$sql_regexp." ".$db->quote("^".$letter); + $db->setLimit(1); + $result = $db->query($query); $numrows = $result->numRows(); - if ( $numrows == "1" ) - { + if ( $numrows == "1" ) { return 1; - } - else - { + } else { return 0; } } -/* - * Print a nice useraimed error. - */ -function error($msg) -{ - // General function for printing critical errors. - if ($msg) - { - include_once("header.inc.php"); - ?> -

-

- Error: " . $msg . "\n"; + } else { + echo "
" . _('An unknown error has occurred.') . "
\n"; } } +function success($msg) { + if ($msg) { + echo "
" . $msg . "
\n"; + } else { + echo "
" . _('Something has been successfully performed. What exactly, however, will remain a mystery.') . "
\n"; + } +} + + /* * Something has been done nicely, display a message and a back button. */ @@ -268,47 +244,6 @@ } } -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=".$db->quote($_SESSION["userid"])." AND domain_id=".$db->quote($zoneid)); - $db->setLimit(1); - $result_extra = $db->query("SELECT record_owners.id FROM record_owners,records WHERE record_owners.user_id=".$db->quote($_SESSION["userid"])." AND records.domain_id = ".$db->quote($zoneid)." AND records.id = record_owners.record_id"); - - 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) { @@ -344,4 +279,20 @@ } return true; } + + +function v_num($string) { + if (!eregi("^[0-9]+$", $string)) { + return false ; + } else { + return true ; + } +} + +function debug_r($array) { + echo "
\n";
+	print_r($array);
+	echo "
\n"; +} + ?>