Page 1 of 1

Stuck with Defined('') protection want to understand

Posted: Fri Aug 03, 2007 9:03 pm
by galvar2bos
Hi all,
I am sure all of you are great programers but First i am no code programmer i am just trying to learn to run my sites, will the problem is i got a code from the web to protect my files ,1st i want to know how to work it out then i will try other things but can't let it go without a fight thanx all

***** PLEASE USE

Code: Select all

TAG WHEN POSTING CODE *****[/color]

Code: Select all

<?php

if ( ! defined( 'myname' ) )
{
	print "You cannot access this file directly.";
	exit();
}

customer data here
?>
now i can't access my files :?: :roll: what is the method to access them

all i want is to protect the file not to be opened directly but how to implement it in a frame or something like

display the contents in a frame or echo the source code as the file is a customer data please i am stuck and can't launch this small site

thanx in advance

Descriptive Subjects

Posted: Fri Aug 03, 2007 9:32 pm
by hawleyjr
Hello and welcome to the forum.

You may want to look into using session variables.
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.

Posted: Sat Aug 04, 2007 12:43 am
by volka
if ( ! defined( 'myname' ) )
Tests whether a constant myname exists.
Another php file can define that constant prior to including the protected file

Code: Select all

define('myname', true);
require 'protected/file.php';
But the browser cannot set the constant in the http request. If you want to protect your files from being called outside your (html) frame set this is the wrong approach.