developer_execute() { execute this code only }
declare it in an include file or something:
<? developer_execute() { if($_SERVER['REMOTE_ADDR'] == "000.000.000.000") { echo "i've done something just for ip 000.000.000.000"; } else { echo ""; } } ?>
execute it anywhere you like:
<? developer_execute(); ?>
So, the above will execute if your ip address is the same as the one in the function, which seems to be what you want, although I don't like the idea of code relying on an IP address because:
- it might change - an ip can be spoofed
Consider the following pseudo code:
domain based as per my last email
function local_only() { if(domain is LAN domain) { // do this } }
or session based with a logged in user of the right clearance level
function developer_only() { if($_SESSION['auth_level'] = 'developer') { // do this } }
I just wouldn't rely on an IP of the remote user.
Justin
On Monday, August 11, 2003, at 10:12 AM, Mike Morton wrote:
Justin:
Not ColdFusion - ancient language by Brian Fox called MetaHTML - actually a
VERY good language - just not supported or developed anymore as far as I can
tell ;)
Anyhow - that is one solution that I had not thought of - but ideally I
would like to use a function rather than an IF statement - just the anal
developer attutude that is in me ;)
For instance, in an IF statement, is there a way to reference, or access the
code/etc contained within the { } ? If there was, then this solution:
developer_execute() { execute this code only }
Where the function developer_execute would be defined as: function developer_execute() { if(getenv("REMOTE_ADDR")=="000.000.000.000") { %body } }
Would work - I am just hitting the wall as to how to reference the code between { and } represented in the function definition by %body
Anybody?
On 8/10/03 7:46 PM, "Justin French" <[EMAIL PROTECTED]> wrote:
Sounds like you're trying to replicated something in ColdFusion?
I have a few blocks of code on my pages which are only executed on my development server, not the live server -- is this what you want?
if(ereg("192.168.0.",$_SERVER['SERVER_ADDR'])) { $local = 1; } else { $local = 0; }
if($local) { // do whatever you want }
Justin
On Monday, August 11, 2003, at 12:50 AM, Mike Morton wrote:
In a language that I used to program in - for development we used to be able to make a function that basically just executed everything inbetween: <hidecode> Print "This is html printed" <some programming code> Print "this is more code"; </hidecode>
So basically everything in between hidecode and /hidecode is executed the same as if the hide code did not exist - except that the hidecode container would be something like:
Function hidecode() { if(getenv("remoteaddress")=="myaddress") { %s (all code contained within the tags) } }
So - the question is does PHP have some way that I cannot see to do this?
I realize that I could create a function and pass everything in as an argument - but that would involve putting everything into variables, and overall being just a pain in the ass to add and remove the container.
Is PHP too sophisticated a language to be able to do this easily and quickly? Or am I just missing some form of function that is totally obvious?
Finally - yes, I know that I could slap an if tag around it - but that
is
also a big pain in the ass to add and remove each if tag when you go
'live'
with the change, as opposed to a quick find and replace with a
container
function like this...
TIA
-- Cheers
Mike Morton
**************************************************** * * Tel: 905-465-1263 * Email: [EMAIL PROTECTED] * ****************************************************
"Indeed, it would not be an exaggeration to describe the history of the
computer industry for the past decade as a massive effort to keep up with
Apple."
- Byte Magazine
Given infinite time, 100 monkeys could type out the complete works of
Shakespeare. Win 98 source code? Eight monkeys, five minutes.
-- NullGrey
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
--- [This E-mail scanned for viruses]
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php