Jump to content

Recommended Posts

Posted

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

Posted

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

  • Moderators
Posted

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.

Posted
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!

  • Moderators
Posted

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);

Posted

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();
}
?>

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...