Where to put if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
[eluser]sessions[/eluser]
Sorry if this has been asked hundreds of times here, I did a quick search before posting.. Where should this line go.. if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ..just controllers? controllers and models? why or why not? Thanks
[eluser]sessions[/eluser]
Do you use this line in your own projects: if ( ! defined(‘BASEPATH’)) exit(‘No direct script access allowed’); ? It's in the controller file in a fresh CI download. What is it for and does it only belong in controllers or models too?
[eluser]Otemu[/eluser]
Hi, Good answers for you here http://ellislab.com/forums/viewthread/228527/ and here http://ellislab.com/forums/viewthread/228527/
[eluser]sessions[/eluser]
Thanks, That article linked to this: http://ellislab.com/forums/viewthread/93620/ where someone said: "Making sure BASEPATH is defined is just a simple way to know that CI has been loaded." which basically answers my question. But does the line: if ( ! defined(‘BASEPATH’)) exit(‘No direct script access allowed’); only belong in controllers? why? Edit: also where is BASEPATH defined in the framework? i found online people say it's defined in index.php...but which index.php? there's one in the root, controllers folder, etc. All that I checked so far didn't have it.
[eluser]InsiteFX[/eluser]
BASEPATH is defined in the index.php file, the if should be placed in all CodeIgniter files at the top.
[eluser]sessions[/eluser]
The constant BASEPATH is referred to at the top of all controllers that I saw. But where is it defined? You mentioned they go at the top of all files. So you put that line of code in models too?
[eluser]InsiteFX[/eluser]
I told you above it is defined in index.php Yes place it at the top of all your files.
[eluser]sessions[/eluser]
Every index.php file I've checked says this: Code: <html> There is an index.php in root, controllers folder, etc. Can you tell me which index.php file it is defined in?
[eluser]InsiteFX[/eluser]
If you read the other index files they have a .html extension not .php There is only one index.php file and it is in the root.
|
Welcome Guest, Not a member yet? Register Sign In |