The problem is largely a cakephp problem, there is nothing specifically wrong with the code you have developed as long as I call it from an php page that is not integrated with cakephp.
You can see some discussion on it at vbulletin.org.
vbulletin.org/forum/showthread.php?
...
From what I have seen, this error happens the minute I attempt to include global.php. I've been trying to get this to work for a couple months on and off as a pet project, however my php skills are just not up to the task.
Unfortunately PHP is my hobby, my career is ABAP programming so I just don't have the time to learn as much as I'd like.
Anyway, if you have any idea's that would be great!