Elseif/if & REMOTE_ADDR stuff

Status
Not open for further replies.

Weasel

👄 I'd intercept me
Nov 25, 2011
4,132
2,456
Hi!

I am trying to alter the class.core.php file from Kryptos's RevCMS 1.9.9.9 at the maintance part, so when it haves someone's IP it skips the code. For now, I'm using this. But it isn't working and still redirects me to the maintance page.

I am using this script:

PHP:
elseif($_GET['url'] != 'maintenance')
{
header('Location: '.$_CONFIG['hotel']['url'].'/maintenance');
 
}
if($_SERVER['REMOTE_ADDR'] == $_SERVER['127.0.0.1'])
{
header('Location: '.$_CONFIG['hotel']['url'].'/index');
exit;
}

Anyone who can help me?

Thnx in advance.
 

Adonn

New Member
Mar 25, 2011
27
4
Umm, try checking $_SERVER['REMOTE_ADDR'] with just '127.0.0.1', instead of just $_SERVER['127.0.0.1'].

EDIT: A bit of explanation to help:
$_SERVER['REMOTE_ADDR'] holds a string of the client's IP, and I don't think that $_SERVER has an IP field in the form of a string.

EDIT (Again): Including the rewritten code
elseif($_GET['url'] != 'maintenance')
{
header('Location: '.$_CONFIG['hotel']['url'].'/maintenance');

}
if(
$_SERVER['REMOTE_ADDR'] == '127.0.0.1')
{
header('Location: '.$_CONFIG['hotel']['url'].'/index');
exit;
}
 

M8than

yes
Mar 16, 2012
463
102
PHP:
elseif($_GET['url'] != 'maintenance')
 
{
 
if($_SERVER['REMOTE_ADDR'] == '127.0.0.1')
 
{
 
header('Location: '.$_CONFIG['hotel']['url'].'/index');
 
} else {
 
header('Location: '.$_CONFIG['hotel']['url'].'/maintenance');
 
}
 
}

Say thank you to your master

Actualy can u give the whole code for the page please. I need to edit the index one.
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,132
2,456
Actualy can u give the whole code for the page please. I need to edit the index one.

Original class.core.php (if this is what you meant) without my failing edit:

PHP:
<?php 
 
namespace Revolution;
if(!defined('IN_INDEX')) { die('Sorry, you cannot access this file.'); }
class core implements iCore
{
 
final public function getOnline()
{
global $engine;
return $engine->result("SELECT users_online FROM server_status");
}
 
final public function getStatus()
{
global $engine;
return $engine->result("SELECT status FROM server_status");
}
 
final public function systemError($who, $txt)
{
die('<b>' . $who . ' - RevCMS: </b><br /> <center>' . $txt . '</center>');
}
 
final public function handleCall($k)
{
global $users, $template, $_CONFIG;
 
if($_CONFIG['hotel']['in_maint'] == false)
{
if(!isset($_SESSION['user']['id']))
{
switch($k)
{
case "index":
case null:
case "login":
$users->login();
break;
 
case "register":
$users->register();
break;
 
case "forgot":
$users->forgotten();
break;
 
case "maintenance":
case "ToS":
//
break;
 
case "me":
case "account":
case "news":
header('Location: '.$_CONFIG['hotel']['url'].'/index');
exit;
break;
 
default:
//Nothing
break;
}
}
else
{
if($_SESSION['user']['ip_last'] != $_SERVER['REMOTE_ADDR'])
{
header('Location: '.$_CONFIG['hotel']['url'].'/logout');
}
 
switch($k)
{
case "index":
case null:
header('Location: '.$_CONFIG['hotel']['url'].'/me');
exit;
break;
 
case "register":
header('Location: '.$_CONFIG['hotel']['url'].'/me');
exit;
break;
 
case "forgot":
header('Location: '.$_CONFIG['hotel']['url'].'/me');
exit;
break;
 
case "client":
$users->createSSO($_SESSION['user']['id']);
$users->updateUser($_SESSION['user']['id'], 'ip_last', $_SERVER['REMOTE_ADDR']);
$template->setParams('sso', $users->getInfo($_SESSION['user']['id'], 'auth_ticket'));
break;
 
case "help":
$users->help();
break;
 
case "account":
$users->updateAccount();
break;
 
default:
//nothing
break;
}
}
}
elseif($_GET['url'] != 'maintenance')
{
header('Location: '.$_CONFIG['hotel']['url'].'/maintenance');
exit;
}
}
 
final public function handleCallHK($k)
{
global $users, $engine, $_CONFIG;
 
if($_SESSION["in_hk"] != true)
{
if(isset($_SESSION['user']['id']))
{
if($k == 'login')
{
$users->loginHK();
}
else
{
header("Location:".$_CONFIG['hotel']['url']."/ase/login");
exit;
}
}
else
{
header("Location:".$_CONFIG['hotel']['url']."/index");
exit;
}
}
else
{
if(!isset($k))
{
header("Location:".$_CONFIG['hotel']['url']."/ase/dash");
exit;
}
else
{
if($k == 'balist')
{
 
if(isset($_GET["unban"]))
{
$user = $engine->secure($_GET["unban"]);
$engine->query("DELETE FROM bans WHERE id = '" . $user . "'");
header("Location: ".$_CONFIG['hotel']['url']."/ase/banlist");
exit;
}
}
}
}
}
 
final public function hashed($password)
{
return md5($password);
}
}
?>

Here are the index.php (wwwroot file) and maintance.php file (tpl file)
PHP:
<?php 
define('IN_INDEX', 1);
 
require_once 'global.php';
 
$core->handleCall($engine->secure($_GET['url']));
 
$template->html->get($engine->secure($_GET['url']));
 
$template->outputTPL();
?>

PHP:
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <title>{hotelName} &middot; Maintenance</title>
        
        <link rel="stylesheet" href="{url}/app/tpl/skins/Habbo/styles/maintenance.css" type="text/css">
    </head>
    
    <body>
    
        <div id="container">
            <div id="content">
                <div id="header" class="clearfix">
                    <h1><span></span></h1>
                </div>
                <div id="process-content">
                    <div class="fireman">
                        <h1>Maintenance break!</h1>
                        <p>Sorry! {hotelName} is being worked on at the moment.<br><br>-----------.COM<p>
                    </div>
                    <div class="tweet-container">
                        <h2>What's going on?</h2>
                        <div class="tweet">
Text
                        </div>
                    </div>
                    <div id="footer">
                        <p class="copyright">Footer thingo</p>
                    </div>
                </div>
            </div>
        </div>
    
    </body>
</html>
 

JammDrops

New Member
Jun 27, 2012
3
0
Try this:-

PHP:
elseif($_GET['url'] != 'maintenance' && $_SERVER['REMOTE_ADDR'] !== '127.0.0.1')
{
header('Location: '.$_CONFIG['hotel']['url'].'/maintenance');
}
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,132
2,456
Try this:-

PHP:
elseif($_GET['url'] != 'maintenance' && $_SERVER['REMOTE_ADDR'] !== '127.0.0.1')
{
header('Location: '.$_CONFIG['hotel']['url'].'/maintenance');
}

Well, it didn't work untill I removed the ! at !==. Now it redirects me to the index page, but it doesn't let me login (it just stays on index.php)
 
Status
Not open for further replies.

Users who are viewing this thread

Top