First of all, due to the redeclare error, it seems that you are including one or more files several times (unless you have copied the declaration of the exdbcleanup function, of course). Try using include_once() instead of include().
There's only one file included (ezscript.php) and it's done with an include_once. Removing it gives an "Undefined class name 'ezscript'" error, so i suppose it should be included.
I also tried to use the createFolderObject() function proposed in the above mentioned link, but that gives me an "Call to a member function on a non-object" error.
As the error msg says, the function eZDBCleanup() is declared twice; once in index.php at around line 182 and then again in ezscript.php at around line 1096.
I think this problem occurs because you are trying to run your script as a view to a module in addition to including the ezscript.php file. If I'm not mistaking, files that include the ezscript.php file are meant to be run separately, outside the ez interface.