Skip to content

Commit

Permalink
Bug fixing in backup system
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrowicaksono committed Sep 6, 2011
1 parent 2599ee7 commit 0bf949c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
4 changes: 1 addition & 3 deletions admin/modules/system/backup.php
Expand Up @@ -23,13 +23,11 @@

// key to authenticate
define('INDEX_AUTH', '1');
// key to get full database access
define('DB_ACCESS', 'fa');

// main system configuration
require '../../../sysconfig.inc.php';
// IP based access limitation
require LIB_DIR.'ip_based_access.inc.php';
require_once LIB_DIR.'ip_based_access.inc.php';
do_checkIP('smc');
do_checkIP('smc-system');
// start the session
Expand Down
51 changes: 26 additions & 25 deletions lib/ip_based_access.inc.php
Expand Up @@ -25,33 +25,34 @@
die("can not access this file directly");
}

function do_checkIP ($module = 'general')
{
global $sysconf;
if (isset($sysconf['ipaccess'][''.$module.''])) {
$accmod = $sysconf['ipaccess'][''.$module.''];
} else {
die ('Invalid access module');
}
#$accmod = $sysconf['ipaccess'][''.$module.''];
$is_allowed = false;
$remote_addr = $_SERVER['REMOTE_ADDR'];
if (($accmod != 'all') AND (is_array($accmod))) {
foreach ($accmod as $value) {
$pattern = "/^".$value."/i";
if (preg_match($pattern, $remote_addr)) {
$is_allowed = true;
}
if (!function_exists('do_checkIP')) {
function do_checkIP ($module = 'general')
{
global $sysconf;
if (isset($sysconf['ipaccess'][''.$module.''])) {
$accmod = $sysconf['ipaccess'][''.$module.''];
} else {
die ('Invalid access module');
}
} elseif ($accmod == 'all') {
$is_allowed = true;
} else {
#$accmod = $sysconf['ipaccess'][''.$module.''];
$is_allowed = false;
}

if (!$is_allowed) {
echo 'Stop here! Access now allowed.';
exit();
$remote_addr = $_SERVER['REMOTE_ADDR'];
if (($accmod != 'all') AND (is_array($accmod))) {
foreach ($accmod as $value) {
$pattern = "/^".$value."/i";
if (preg_match($pattern, $remote_addr)) {
$is_allowed = true;
}
}
} elseif ($accmod == 'all') {
$is_allowed = true;
} else {
$is_allowed = false;
}
if (!$is_allowed) {
echo 'Stop here! Access now allowed.';
exit();
}
}
}

Expand Down

0 comments on commit 0bf949c

Please sign in to comment.