can someone please explain this code
Posted by: pabs (81.199.4.---)
Date: June 20, 2006 03:19PM

<?php
// define $authorized = true only if user is authenticated
if (authenticated_user()) {
$authorized = true;
}

if ($authorized) {
include "/bar/foo/data.php";
}
?>

Options: ReplyQuote
Re: can someone please explain this code
Posted by: drivingmenuts (---.austin.res.rr.com)
Date: June 21, 2006 12:41AM

There are two parts
1. The script calls the authenticated_user function, which does its thing and returns a true if the user is allowed to access or false if not. If the user is allowed access, then it sets the variable authenticated to the value true.
2. Then, it check to see if the variable authenticated is true. If it is, it includes a file, which presumably does things that an unauthenticated user would not be allowed to see.

The code can be shortened:

<?php

if (authenticated_user()) {
$authorized=true;
include "whateverfileyouwerelookingfor.php";
}

?>

It saves a wee bit of time.

Options: ReplyQuote


Sorry, only registered users may post in this forum.