Jump to content
MakeWebGames

code line help


Kasabian
 Share

Recommended Posts

Re: code line help

A simple search can help you with that...

 

<?php
define("CONSTANT", "Hello world.");
echo CONSTANT; // outputs "Hello world."
echo Constant; // outputs "Constant" and issues a notice.

define("GREETING", "Hello you.", true);
echo GREETING; // outputs "Hello you."
echo Greeting; // outputs "Hello you."

?>

 

Taken from http://www.php.net/define

Link to comment
Share on other sites

Guest Anonymous

Re: code line help

It's often used as a mechanism to prevent a file from being executed *unless* it was included from somewhere else.

For example, Assuming the following (and rather daft) file:

 

<?php /* mypass.php */
if (!defined('SECURE_LABEL')) { die("Access Denied"); }
echo "Your password is 'elephant'";
?>

 

Now, if somebody tries to call the file directly - usually by typing the full url into the address bar, they will just see "Access Denied";

In order to gain access to that file, you could do:

 

<?php /* mysecurepass.php */
define('SECURE_LABEL', true);
include("mypass.php");
?>

 

Now, if anybody navigates to mysecurepass.php, the mypass.php will be include, but this time, as SECURE_LABEL was defined, it will actually show your password.

For obvious reasons, DON'T DO THIS, however it does hopefully exhibit how using manifest constants (in your case MONO_ON, in mine SECURE_LABEL) can be used to provide a limited for of protection.

Personally, I find little need for this type of protection, however there are a lot of scripts that use it.

Link to comment
Share on other sites

Re: code line help

I used this way on my ptc to stop the some script's from outsider's.

I also used this to stop people from going to the config.php as many people were looking for it at some point. Another way is if some one find's a way to exploit your game in uploading a file such as a file that will connect to config.php and then fetch data from it this can be used.

For example:

in config.php:

if(!defined('Config_Connect'))
{
   die("Your not allowed to be here");
}
else
{
   $_CONFIG = array(.....);
}

 

Then in register.php, globals.php, fpass.php, login.php You add

 

define("Config_Connect");

 

It's just another way to secure some script's from outsider's.

Link to comment
Share on other sites

Re: code line help

 

I used this way on my ptc to stop the some script's from outsider's.

I also used this to stop people from going to the config.php as many people were looking for it at some point. Another way is if some one find's a way to exploit your game in uploading a file such as a file that will connect to config.php and then fetch data from it this can be used.

For example:

in config.php:

if(!defined('Config_Connect'))
{
   die("Your not allowed to be here");
}
else
{
   $_CONFIG = array(.....);
}

 

Then in register.php, globals.php, fpass.php, login.php You add

 

define("Config_Connect");

 

It's just another way to secure some script's from outsider's.

Interesting Method Kyle...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...