02.06.2013 Views

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

222<br />

CHAPTER 6 ■ PASSWORD PROTECTION SENSITIVE ACTIONS AND AREAS<br />

if ( $_POST['token']==$_SESSION['token']<br />

&& isset($actions[$_POST['action']]) )<br />

{<br />

$use_array = $actions[$_POST['action']];<br />

$obj = new $use_array['object']($dbo);<br />

if ( TRUE === $msg=$obj->$use_array['method']() )<br />

{<br />

header($use_array['header']);<br />

exit;<br />

}<br />

else<br />

{<br />

// If an error occured, output it <strong>and</strong> end execution<br />

die ( $msg );<br />

}<br />

}<br />

else<br />

{<br />

// Redirect to the main index if the token/action is invalid<br />

header("Location: ../../");<br />

exit;<br />

}<br />

function __autoload($class_name)<br />

{<br />

$filename = '../../../sys/class/class.'<br />

. strtolower($class_name) . '.inc.php';<br />

if ( file_exists($filename) )<br />

{<br />

include_once $filename;<br />

}<br />

}<br />

?><br />

Save this file, then navigate to http://localhost/, <strong>and</strong> click the Log Out button at the bottom of the<br />

calendar. Clicking this button causes the message below the calendar to now read, “Logged Out!” (see<br />

Figure 6-8).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!