Jason Posted April 21, 2011 Report Share Posted April 21, 2011 Can you protect a .php file, so when an admin logs in they can acess the php file.. This code does not work for .php <?php if(!Auth::LoggedIn()) { Debug::showCritical('Please login first'); die(); } if(!PilotGroups::group_has_perm(Auth::$usergroups, ACCESS_ADMIN)) { Debug::showCritical('Unauthorized access'); die(); } ?> I Really need this, and i cannot make the php file intoa .tpl If this is possible please let me know Quote Link to comment Share on other sites More sharing options...
Tom Posted April 21, 2011 Report Share Posted April 21, 2011 include('path/to/codon.config.php'); //continue as if it were in phpVMS Quote Link to comment Share on other sites More sharing options...
Jason Posted April 21, 2011 Author Report Share Posted April 21, 2011 Tom, here is what i found to work: <?php include '../core/codon.config.php'; if(!Auth::LoggedIn() && !PilotGroups::group_has_perm(Auth::$usergroups, ACCESS_ADMIN)) { Debug::showCritical('Unauthorized access!'); die(); } ?> Everything works fine, and the file is secure, and will only allow admins However i get this error: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/sfg/public_html/va/Easy_Upload_Templates/unzipper.php:2) in /home/sfg/public_html/va/core/codon.config.php on line 40 Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted April 21, 2011 Moderators Report Share Posted April 21, 2011 That means there is already a session started, i had this when i force a pilot to view page a before page b, as phpvms starts sessions, just do a google to destroy a session, add that to the top of that code and see what happens. Quote Link to comment Share on other sites More sharing options...
Jason Posted April 21, 2011 Author Report Share Posted April 21, 2011 That means there is already a session started, i had this when i force a pilot to view page a before page b, as phpvms starts sessions, just do a google to destroy a session, add that to the top of that code and see what happens. Mark, Could you help me with this one.... I google searched it and came up with several codes like this: session_destroy(); This does not work by itself, can you show me how to implement that code into: <?php include '../core/codon.config.php'; if(!Auth::LoggedIn() && !PilotGroups::group_has_perm(Auth::$usergroups, ACCESS_ADMIN)) { Debug::showCritical('Unauthorized access!'); die(); } ?> Thanks! Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted April 22, 2011 Moderators Report Share Posted April 22, 2011 What seems to be happening is that Easy_Upload_Templates/unzipper.php is starting a session, so does phpvms, you can either try to distroy the Easy_Upload_Templates/unzipper.php session, but im thinking its there for a reason or if the thing is working just put error reporting='0', At the top of the page put between the php tags, error_reporting(0); Quote Link to comment Share on other sites More sharing options...
Jason Posted April 22, 2011 Author Report Share Posted April 22, 2011 Thank You Mark!! That works great, and has got ride of the error, If any one needs the final code, here it is: <?php error_reporting(0); include '../core/codon.config.php'; if(!Auth::LoggedIn() && !PilotGroups::group_has_perm(Auth::$usergroups, ACCESS_ADMIN)) { Debug::showCritical('Unauthorized access!'); die(); } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.