Skip to content

Commit

Permalink
Validation function moved to related file.
Browse files Browse the repository at this point in the history
  • Loading branch information
edmondas committed Jan 28, 2022
1 parent a28cf51 commit c2ae290
Show file tree
Hide file tree
Showing 24 changed files with 90 additions and 54 deletions.
5 changes: 3 additions & 2 deletions add_record.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
* @copyright 2010-2022 Poweradmin Development Team
* @license https://opensource.org/licenses/GPL-3.0 GPL
*/
require_once('inc/toolkit.inc.php');
require_once 'inc/toolkit.inc.php';
require_once 'inc/validation.inc.php';
require_once 'inc/syslog.inc.php';

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

global $pdnssec_use;

Expand Down
5 changes: 3 additions & 2 deletions add_zone_master.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
* @copyright 2010-2022 Poweradmin Development Team
* @license https://opensource.org/licenses/GPL-3.0 GPL
*/
require_once("inc/toolkit.inc.php");
require_once 'inc/toolkit.inc.php';
require_once 'inc/validation.inc.php';
require_once 'inc/syslog.inc.php';

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

echo " <script type=\"text/javascript\" src=\"inc/helper.js\"></script>";

Expand Down
5 changes: 3 additions & 2 deletions add_zone_slave.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
* @copyright 2010-2022 Poweradmin Development Team
* @license https://opensource.org/licenses/GPL-3.0 GPL
*/
require_once("inc/toolkit.inc.php");
require_once 'inc/toolkit.inc.php';
require_once 'inc/validation.inc.php';
require_once 'inc/syslog.inc.php';

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

global $dns_third_level_check;

Expand Down
6 changes: 4 additions & 2 deletions add_zone_templ_record.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
* @copyright 2010-2022 Poweradmin Development Team
* @license https://opensource.org/licenses/GPL-3.0 GPL
*/
require_once("inc/toolkit.inc.php");
include_once("inc/header.inc.php");
require_once 'inc/toolkit.inc.php';
require_once 'inc/validation.inc.php';

include_once 'inc/header.inc.php';

global $dns_ttl;

Expand Down
6 changes: 4 additions & 2 deletions bulk_registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
* @copyright 2010-2022 Poweradmin Development Team
* @license https://opensource.org/licenses/GPL-3.0 GPL
*/
require_once("inc/toolkit.inc.php");
include_once("inc/header.inc.php");
require_once 'inc/toolkit.inc.php';
require_once 'inc/validation.inc.php';

include_once 'inc/header.inc.php';

$owner = "-1";
if ((isset($_POST['owner'])) && (v_num($_POST['owner']))) {
Expand Down
5 changes: 3 additions & 2 deletions delete_domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
* @copyright 2010-2022 Poweradmin Development Team
* @license https://opensource.org/licenses/GPL-3.0 GPL
*/
require_once("inc/toolkit.inc.php");
require_once 'inc/toolkit.inc.php';
require_once 'inc/validation.inc.php';
require_once 'inc/syslog.inc.php';

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

global $pdnssec_use;

Expand Down
6 changes: 4 additions & 2 deletions delete_perm_templ.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
* @copyright 2010-2022 Poweradmin Development Team
* @license https://opensource.org/licenses/GPL-3.0 GPL
*/
require_once("inc/toolkit.inc.php");
include_once("inc/header.inc.php");
require_once 'inc/toolkit.inc.php';
require_once 'inc/validation.inc.php';

include_once 'inc/header.inc.php';

$perm_templ = "-1";
if (isset($_GET['id']) && (v_num($_GET['id']))) {
Expand Down
5 changes: 3 additions & 2 deletions delete_record.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
* @copyright 2010-2022 Poweradmin Development Team
* @license https://opensource.org/licenses/GPL-3.0 GPL
*/
require_once("inc/toolkit.inc.php");
require_once 'inc/toolkit.inc.php';
require_once 'inc/validation.inc.php';
require_once 'inc/syslog.inc.php';

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

global $pdnssec_use;

Expand Down
6 changes: 4 additions & 2 deletions delete_supermaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
* @copyright 2010-2022 Poweradmin Development Team
* @license https://opensource.org/licenses/GPL-3.0 GPL
*/
require_once("inc/toolkit.inc.php");
include_once("inc/header.inc.php");
require_once 'inc/toolkit.inc.php';
require_once 'inc/validation.inc.php';

include_once 'inc/header.inc.php';

$master_ip = "-1";
if (isset($_GET['master_ip']) && (is_valid_ipv4($_GET['master_ip']) || is_valid_ipv6($_GET['master_ip']))) {
Expand Down
6 changes: 4 additions & 2 deletions delete_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
* @copyright 2010-2022 Poweradmin Development Team
* @license https://opensource.org/licenses/GPL-3.0 GPL
*/
require_once("inc/toolkit.inc.php");
include_once("inc/header.inc.php");
require_once 'inc/toolkit.inc.php';
require_once 'inc/validation.inc.php';

include_once 'inc/header.inc.php';

do_hook('verify_permission' , 'user_edit_own' ) ? $perm_edit_own = "1" : $perm_edit_own = "0";
do_hook('verify_permission' , 'user_edit_others' ) ? $perm_edit_others = "1" : $perm_edit_others = "0";
Expand Down
6 changes: 4 additions & 2 deletions delete_zone_templ.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
* @copyright 2010-2022 Poweradmin Development Team
* @license https://opensource.org/licenses/GPL-3.0 GPL
*/
require_once("inc/toolkit.inc.php");
include_once("inc/header.inc.php");
require_once 'inc/toolkit.inc.php';
require_once 'inc/validation.inc.php';

include_once 'inc/header.inc.php';

$zone_templ_id = "-1";
if (isset($_GET['id']) && (v_num($_GET['id']))) {
Expand Down
6 changes: 4 additions & 2 deletions delete_zone_templ_record.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
* @copyright 2010-2022 Poweradmin Development Team
* @license https://opensource.org/licenses/GPL-3.0 GPL
*/
require_once("inc/toolkit.inc.php");
include_once("inc/header.inc.php");
require_once 'inc/toolkit.inc.php';
require_once 'inc/validation.inc.php';

include_once 'inc/header.inc.php';

$record_id = "-1";
if (isset($_GET['id']) && v_num($_GET['id'])) {
Expand Down
6 changes: 4 additions & 2 deletions dnssec.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
* @copyright 2010-2022 Poweradmin Development Team
* @license https://opensource.org/licenses/GPL-3.0 GPL
*/
require_once("inc/toolkit.inc.php");
include_once("inc/header.inc.php");
require_once 'inc/toolkit.inc.php';
require_once 'inc/validation.inc.php';

include_once 'inc/header.inc.php';

global $pdnssec_use;
global $perm_meta_edit;
Expand Down
4 changes: 3 additions & 1 deletion dnssec_add_key.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
* @copyright 2010-2022 Poweradmin Development Team
* @license https://opensource.org/licenses/GPL-3.0 GPL
*/
require_once("inc/toolkit.inc.php");
require_once 'inc/toolkit.inc.php';
require_once 'inc/validation.inc.php';

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

$zone_id = "-1";
Expand Down
6 changes: 4 additions & 2 deletions dnssec_delete_key.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
* @copyright 2010-2022 Poweradmin Development Team
* @license https://opensource.org/licenses/GPL-3.0 GPL
*/
require_once("inc/toolkit.inc.php");
include_once("inc/header.inc.php");
require_once 'inc/toolkit.inc.php';
require_once 'inc/validation.inc.php';

include_once 'inc/header.inc.php';

global $pdnssec_use;

Expand Down
6 changes: 4 additions & 2 deletions dnssec_ds_dnskey.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
* @copyright 2010-2022 Poweradmin Development Team
* @license https://opensource.org/licenses/GPL-3.0 GPL
*/
require_once("inc/toolkit.inc.php");
include_once("inc/header.inc.php");
require_once 'inc/toolkit.inc.php';
require_once 'inc/validation.inc.php';

include_once 'inc/header.inc.php';

global $pdnssec_use;
global $perm_view;
Expand Down
6 changes: 4 additions & 2 deletions dnssec_edit_key.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
* @copyright 2010-2022 Poweradmin Development Team
* @license https://opensource.org/licenses/GPL-3.0 GPL
*/
require_once("inc/toolkit.inc.php");
include_once("inc/header.inc.php");
require_once 'inc/toolkit.inc.php';
require_once 'inc/validation.inc.php';

include_once 'inc/header.inc.php';

global $pdnssec_use;

Expand Down
1 change: 1 addition & 0 deletions edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

require_once 'inc/toolkit.inc.php';
require_once 'inc/pagination.inc.php';
require_once 'inc/validation.inc.php';

include_once 'inc/header.inc.php';

Expand Down
6 changes: 4 additions & 2 deletions edit_perm_templ.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
* @copyright 2010-2022 Poweradmin Development Team
* @license https://opensource.org/licenses/GPL-3.0 GPL
*/
require_once("inc/toolkit.inc.php");
include_once("inc/header.inc.php");
require_once 'inc/toolkit.inc.php';
require_once 'inc/validation.inc.php';

include_once 'inc/header.inc.php';

$id = "-1";
if ((isset($_GET['id'])) || (v_num($_GET['id']))) {
Expand Down
6 changes: 4 additions & 2 deletions edit_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
* @copyright 2010-2022 Poweradmin Development Team
* @license https://opensource.org/licenses/GPL-3.0 GPL
*/
require_once("inc/toolkit.inc.php");
include_once("inc/header.inc.php");
require_once 'inc/toolkit.inc.php';
require_once 'inc/validation.inc.php';

include_once 'inc/header.inc.php';

$edit_id = "-1";
if (isset($_GET['id']) && v_num($_GET['id'])) {
Expand Down
1 change: 1 addition & 0 deletions edit_zone_templ.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
*/
require_once 'inc/toolkit.inc.php';
require_once 'inc/pagination.inc.php';
require_once 'inc/validation.inc.php';

include_once 'inc/header.inc.php';

Expand Down
6 changes: 4 additions & 2 deletions edit_zone_templ_record.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
* @copyright 2010-2022 Poweradmin Development Team
* @license https://opensource.org/licenses/GPL-3.0 GPL
*/
require_once("inc/toolkit.inc.php");
include_once("inc/header.inc.php");
require_once 'inc/toolkit.inc.php';
require_once 'inc/validation.inc.php';

include_once 'inc/header.inc.php';

$record_id = "-1";
if (isset($_GET['id']) && v_num($_GET['id'])) {
Expand Down
15 changes: 0 additions & 15 deletions inc/toolkit.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
require_once "dnssec.inc.php";
require_once "templates.inc.php";

//do_hook('hook_post_includes');
do_hook('authenticate');

/* * ***********
Expand All @@ -132,17 +131,3 @@ function success($msg) {
echo " <div class=\"success\">" . _('Something has been successfully performed. What exactly, however, will remain a mystery.') . "</div>\n";
}
}

/** Validate numeric string
*
* @param string $string number
*
* @return boolean true if number, false otherwise
*/
function v_num($string) {
if (!preg_match("/^[0-9]+$/i", $string)) {
return false;
} else {
return true;
}
}
14 changes: 14 additions & 0 deletions inc/validation.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,17 @@ function is_valid_email($address) {
}
return true;
}

/** Validate numeric string
*
* @param string $string number
*
* @return boolean true if number, false otherwise
*/
function v_num($string) {
if (!preg_match("/^[0-9]+$/i", $string)) {
return false;
} else {
return true;
}
}

0 comments on commit c2ae290

Please sign in to comment.