Where to put if ( ! defined('BASEPATH')) exit('No direct script access allowed'); - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Where to put if ( ! defined('BASEPATH')) exit('No direct script access allowed'); (/showthread.php?tid=59106) Pages:
1
2
|
Where to put if ( ! defined('BASEPATH')) exit('No direct script access allowed'); - El Forum - 08-24-2013 [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 Where to put if ( ! defined('BASEPATH')) exit('No direct script access allowed'); - El Forum - 09-02-2013 [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? Where to put if ( ! defined('BASEPATH')) exit('No direct script access allowed'); - El Forum - 09-02-2013 [eluser]Otemu[/eluser] Hi, Good answers for you here http://ellislab.com/forums/viewthread/228527/ and here http://ellislab.com/forums/viewthread/228527/ Where to put if ( ! defined('BASEPATH')) exit('No direct script access allowed'); - El Forum - 09-02-2013 [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. Where to put if ( ! defined('BASEPATH')) exit('No direct script access allowed'); - El Forum - 09-02-2013 [eluser]InsiteFX[/eluser] BASEPATH is defined in the index.php file, the if should be placed in all CodeIgniter files at the top. Where to put if ( ! defined('BASEPATH')) exit('No direct script access allowed'); - El Forum - 09-02-2013 [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? Where to put if ( ! defined('BASEPATH')) exit('No direct script access allowed'); - El Forum - 09-02-2013 [eluser]InsiteFX[/eluser] I told you above it is defined in index.php Yes place it at the top of all your files. Where to put if ( ! defined('BASEPATH')) exit('No direct script access allowed'); - El Forum - 09-02-2013 [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? Where to put if ( ! defined('BASEPATH')) exit('No direct script access allowed'); - El Forum - 09-02-2013 [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. Where to put if ( ! defined('BASEPATH')) exit('No direct script access allowed'); - El Forum - 09-02-2013 [eluser]sessions[/eluser] Now I see it! Thank you! |