Skip to content

Commit

Permalink
Made a lot of small changes to allow PHP to run with error_reporting …
Browse files Browse the repository at this point in the history
…E_ALL without giving notices.

Most functions have been checked but some situations might give a notice.
  • Loading branch information
pbeernink committed Mar 10, 2008
1 parent 82aee19 commit 1eb98a9
Show file tree
Hide file tree
Showing 16 changed files with 88 additions and 79 deletions.
4 changes: 2 additions & 2 deletions add_record.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
error(ERR_RECORD_ACCESS_DENIED);
}

if ($_POST["commit"]) {
if (isset($_POST["commit"]) && isset($_POST['zoneid']) && isset($_POST['name']) && isset($_POST['type']) && isset($_POST['content']) && isset($_POST['ttl']) && isset($_POST['prio']) ) {
$ret = add_record($_POST["zoneid"], $_POST["name"], $_POST["type"], $_POST["content"], $_POST["ttl"], $_POST["prio"]);
if ($ret != '1') {
die("$ret");
Expand Down Expand Up @@ -63,7 +63,7 @@
} elseif (strtoupper($c) == 'A') {
$add = " SELECTED";
} else {
unset($add);
$add = '';
}
?><option<?php echo $add ?> value="<?php echo $c ?>"><?php echo $c ?></option><?php
}
Expand Down
20 changes: 10 additions & 10 deletions add_supermaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
error(ERR_LEVEL_5);
}

if($_POST["submit"])
if(isset($_POST["submit"]))
{
$master_ip = $_POST["master_ip"];
$ns_name = $_POST["ns_name"];
$account = $_POST["account"];
if (!$error)
$master_ip = (isset($_POST['master_ip']) ? $_POST["master_ip"] : '');
$ns_name = (isset($_POST['ns_name']) ? $_POST["ns_name"] : '');
$account = (isset($_POST["account"]) ? $_POST['account'] : '');
if (!isset($error))
{
if (!is_valid_ip($master_ip) && !is_valid_ip6($master_ip))
{
Expand All @@ -57,11 +57,11 @@

include_once("inc/header.inc.php");

if ($error != "")
if ((isset($error)) && ($error != ""))
{
?><div class="error"><?php echo _('Error'); ?>: <?php echo $error; ?></div><?php
}
elseif ($success != "")
elseif ((isset($success)) && ($success != ""))
{
?><div class="success"><?php echo $success; ?></div><?php
}
Expand All @@ -73,19 +73,19 @@
<tr>
<td class="n"><?php echo _('IP address of supermaster'); ?>:</td>
<td class="n">
<input type="text" class="input" name="master_ip" value="<?php if ($error) print $_POST["master_ip"]; ?>">
<input type="text" class="input" name="master_ip" value="<?php if (isset($error)) print $_POST["master_ip"]; ?>">
</td>
</tr>
<tr>
<td class="n"><?php echo _('Hostname in NS record'); ?>:</td>
<td class="n">
<input type="text" class="input" name="ns_name" value="<?php if ($error) print $_POST["ns_name"]; ?>">
<input type="text" class="input" name="ns_name" value="<?php if (isset($error)) print $_POST["ns_name"]; ?>">
</td>
</tr>
<tr>
<td class="n"><?php echo _('Account'); ?>:</td>
<td class="n">
<input type="text" class="input" name="account" value="<?php if ($error) print $_POST["account"]; ?>">
<input type="text" class="input" name="account" value="<?php if (isset($error)) print $_POST["account"]; ?>">
</td>
</tr>
<tr>
Expand Down
26 changes: 13 additions & 13 deletions add_zone_master.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@

}

if ($_POST["submit"])
if (isset($_POST["submit"]))
{
$domain = trim($_POST["domain"]);
$owner = $_POST["owner"];
$webip = $_POST["webip"];
$mailip = $_POST["mailip"];
$empty = $_POST["empty"];
$dom_type = isset($_POST["dom_type"]) ? $_POST["dom_type"] : "NATIVE";
$domain = (isset($_POST['domain']) ? trim($_POST["domain"]) : '');
$owner = (isset($_POST['owner']) ? $_POST["owner"] : 0 );
$webip = (isset($_POST["webip"]) ? $_POST['webip'] : '');
$mailip = (isset($_POST["mailip"]) ? $_POST['mailip'] : '');
$empty = (isset($_POST["empty"]) ? $_POST['empty'] : 0);
$dom_type = (isset($_POST["dom_type"]) ? $_POST["dom_type"] : "NATIVE");
if(!$empty)
{
$empty = 0;
Expand All @@ -43,7 +43,7 @@
$error = "Web or Mail ip is invalid!";
}
}
if (!$error)
if (!isset($error))
{
if (!is_valid_domain($domain))
{
Expand All @@ -64,11 +64,11 @@

include_once("inc/header.inc.php");

if ($error != "")
if ((isset($error)) && ($error != ""))
{
?><div class="error"><?php echo _('Error'); ?>: <?php echo $error; ?></div><?php
}
elseif ($success != "")
elseif ((isset($success)) && ($success != ""))
{
?><div class="success"><?php echo $success; ?></div><?php
}
Expand All @@ -87,19 +87,19 @@
<tr>
<td class="n"><?php echo _('Zone name'); ?>:</td>
<td class="n">
<input type="text" class="input" name="domain" value="<?php if ($error) print $_POST["domain"]; ?>">
<input type="text" class="input" name="domain" value="<?php if (isset($error)) print $_POST["domain"]; ?>">
</td>
</tr>
<tr>
<td class="n"><?php echo _('Web IP'); ?>:</td>
<td class="n">
<input type="text" class="input" name="webip" value="<?php if ($error) print $_POST["webip"]; ?>">
<input type="text" class="input" name="webip" value="<?php if (isset($error)) print $_POST["webip"]; ?>">
</td>
</tr>
<tr>
<td class="n"><?php echo _('Mail IP'); ?>:</TD>
<td class="n">
<input type="text" class="input" name="mailip" value="<?php if ($error) print $_POST["mailip"]; ?>">
<input type="text" class="input" name="mailip" value="<?php if (isset($error)) print $_POST["mailip"]; ?>">
</td>
</tr>
<tr>
Expand Down
14 changes: 7 additions & 7 deletions add_zone_slave.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@

}

if ($_POST["submit"])
if (isset($_POST["submit"]))
{
$domain = trim($_POST["domain"]);
$owner = $_POST["owner"];
$slave_master = $_POST["slave_master"];
$dom_type = "SLAVE";
if (!$error)
if (!isset($error))
{
if (!is_valid_domain($domain))
{
Expand All @@ -49,7 +49,7 @@
}
else
{
if(add_domain($domain, $owner, $webip, $mailip, $empty, $dom_type, $slave_master))
if(add_domain($domain, $owner, '', '', 1, $dom_type, $slave_master))
{
$success = _('Successfully added slave zone.');
}
Expand All @@ -59,11 +59,11 @@

include_once("inc/header.inc.php");

if ($error != "")
if ((isset($error)) && ($error != ""))
{
?><div class="error"><?php echo _('Error'); ?>: <?php echo $error; ?></div><?php
}
elseif ($success != "")
elseif ((isset($success)) && ($success != ""))
{
?><div class="success"><?php echo $success; ?></div><?php
}
Expand All @@ -77,13 +77,13 @@
<tr>
<td class="n"><?php echo _('Zone name'); ?>:</td>
<td class="n">
<input type="text" class="input" name="domain" value="<?php if ($error) print $_POST["domain"]; ?>">
<input type="text" class="input" name="domain" value="<?php if (isset($error)) print $_POST["domain"]; ?>">
</td>
</tr>
<tr>
<td class="n"><?php echo _('IP of master NS'); ?>:</td>
<td class="n">
<input type="text" class="input" name="slave_master" value="<?php if ($error) print $_POST["slave_master"]; ?>">
<input type="text" class="input" name="slave_master" value="<?php if (isset($error)) print $_POST["slave_master"]; ?>">
</td>
</tr>
<tr>
Expand Down
4 changes: 2 additions & 2 deletions change_password.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

require_once("inc/toolkit.inc.php");

if($_POST["submit"])
if(isset($_POST["submit"]))
{
if(strlen($_POST["newpass"]) < 8)
if((!isset($_POST['newpass'])) || (strlen($_POST["newpass"]) < 8))
{
error('Password length should be at least 8 characters.');
}
Expand Down
6 changes: 3 additions & 3 deletions delete_domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@

}

if ($_GET["id"]) {
if ($_GET["confirm"] == '0') {
if (isset($_GET["id"])) {
if ((isset($_GET["confirm"])) && ($_GET['confirm'] == '0')) {
clean_page("index.php");
} elseif ($_GET["confirm"] == '1') {
} elseif ((isset($_GET["confirm"])) && ($_GET['confirm'] == '1')) {
delete_domain($_GET["id"]);
clean_page("index.php");
}
Expand Down
6 changes: 3 additions & 3 deletions delete_supermaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@

}

if ($_GET["master_ip"]) {
if ($_GET["confirm"] == '0') {
if (isset($_GET["master_ip"])) {
if ((isset($_GET['confirm'])) && ($_GET["confirm"] == '0')) {
clean_page("index.php");
} elseif ($_GET["confirm"] == '1') {
} elseif ((isset($_GET["confirm"])) && ($_GET['confirm'] == '1')) {
delete_supermaster($_GET["master_ip"]);
clean_page("index.php");
}
Expand Down
4 changes: 2 additions & 2 deletions edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
$users = show_users();
foreach ($users as $u)
{
unset($add);
$add = '';
if ($u["id"] == $info["ownerid"])
{
$add = " SELECTED";
Expand Down Expand Up @@ -155,7 +155,7 @@
<?php
foreach($server_types as $s)
{
unset($add);
$add = '';
if ($s == $domain_type)
{
$add = " SELECTED";
Expand Down
19 changes: 11 additions & 8 deletions edit_record.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

require_once("inc/toolkit.inc.php");

if (isset($_GET["delid"])) {
if (isset($_GET["delid"]) && isset($_GET['delid']) && isset($_GET['id'])) {
delete_record_owner($_GET["domain"],$_GET["delid"],$_GET["id"]);
}

Expand All @@ -32,11 +32,14 @@
error(ERR_RECORD_ACCESS_DENIED);
}

if ($_POST["commit"])
if (isset($_GET['domain'])) {
$domain_name = get_domain_name_from_id($_GET['domain']);
}
if (isset($_POST["commit"]) && isset($_POST['recordid']) && isset($_POST['domainid']) && isset($_POST['name']) && isset($_POST['type']) && isset($_POST['content']) && isset($_POST['ttl']) && isset($_POST['prio']))
{
edit_record($_POST["recordid"], $_POST["domainid"], $_POST["name"], $_POST["type"], $_POST["content"], $_POST["ttl"], $_POST["prio"]);
clean_page("edit.php?id=".$_POST["domainid"]);
} elseif($_SESSION["partial_".get_domain_name_from_id($_GET["domain"])] == 1)
} elseif(isset($_SESSION['partial_'.$domain_name]) && ($_SESSION["partial_".$domain_name] == 1))
{
$db->setLimit(1);
$checkPartial = $db->queryOne("SELECT id FROM record_owners WHERE record_id=".$db->quote($_GET["id"])." AND user_id=".$db->quote($_SESSION["userid"]));
Expand All @@ -46,7 +49,7 @@
}
include_once("inc/header.inc.php");
?>
<h2><?php echo _('Edit record in zone'); ?> "<?php echo get_domain_name_from_id($_GET["domain"]) ?>"</h2>
<h2><?php echo _('Edit record in zone'); ?> "<?php echo $domain_name ?>"</h2>
<?php

$x_result = $db->query("SELECT r.id,u.fullname FROM record_owners as r, users as u WHERE r.record_id=".$db->quote($_GET['id'])." AND u.id=r.user_id");
Expand Down Expand Up @@ -98,19 +101,19 @@
if ($_SESSION[$_GET["domain"]."_ispartial"] == 1)
{
?>
<input type="hidden" name="name" value="<?php echo trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.')?>" class="input">
<input type="hidden" name="name" value="<?php echo trim(str_replace($domain_name, '', $rec["name"]), '.')?>" class="input">

<?php echo trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.') ?>
<?php echo trim(str_replace($domain_name, '', $rec["name"]), '.') ?>
<?php
}
else
{
?>
<input type="text" name="name" value="<?php echo trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.') ?>" class="input">
<input type="text" name="name" value="<?php echo trim(str_replace($domain_name, '', $rec["name"]), '.') ?>" class="input">
<?php
}
?>
.<?php echo get_domain_name_from_id($_GET["domain"]) ?>
.<?php echo $domain_name ?>
</td>
<td class="n">IN</td>
<td>
Expand Down
5 changes: 3 additions & 2 deletions inc/auth.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

session_start();
//session_start();

if (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] == "logout")
{
Expand Down Expand Up @@ -52,7 +52,7 @@
$_SESSION["userid"] = $rowObj["id"];
$_SESSION["name"] = $rowObj["fullname"];
$_SESSION["level"] = $rowObj["level"];
if($_POST["authenticate"])
if(isset($_POST["authenticate"]))
{
//If a user has just authenticated, redirect him to index with timestamp, so post-data gets lost.
session_write_close();
Expand Down Expand Up @@ -117,6 +117,7 @@ function auth($msg="",$type="success")

function logout($msg="")
{
$type = '';
if ( $msg == "" ) {
$msg = _('You have logged out.');
$type = "success";
Expand Down
2 changes: 2 additions & 0 deletions inc/dns.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ function validate_input($zoneid, $type, &$content, &$name, &$prio, &$ttl)
if($name == '*')
{
$wildcard = true;
} else {
$wildcard = false;
}

if ($name=="0") {
Expand Down
Loading

0 comments on commit 1eb98a9

Please sign in to comment.