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.

*<br />

* Enable sessions<br />

*/<br />

session_start();<br />

/*<br />

* Include necessary files<br />

*/<br />

include_once '../../../sys/config/db-cred.inc.php';<br />

/*<br />

* Define constants for config info<br />

*/<br />

foreach ( $C as $name => $val )<br />

{<br />

define($name, $val);<br />

}<br />

/*<br />

* Create a lookup array for form actions<br />

*/<br />

$actions = array(<br />

'event_view' => array(<br />

'object' => 'Calendar',<br />

'method' => 'displayEvent'<br />

)<br />

);<br />

/*<br />

* Make sure the anti-CSRF token was passed <strong>and</strong> that the<br />

* requested action exists in the lookup array<br />

*/<br />

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

{<br />

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

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

}<br />

/*<br />

* Check for an ID <strong>and</strong> sanitize it if found<br />

*/<br />

if ( isset($_POST['event_id']) )<br />

{<br />

$id = (int) $_POST['event_id'];<br />

}<br />

else { $id = NULL; }<br />

echo $obj->$use_array['method']($id);<br />

function __autoload($class_name)<br />

{<br />

CHAPTER 7 ■ ENHANCING THE USER INTERFACE WITH JQUERY<br />

249

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

Saved successfully!

Ooh no, something went wrong!