/program/lib/toolslib.php - tools
main entry point for tools (called from /program/main_admin.php)
this routine dispatches the tasks, If the specified task is not recognised, the default task TASK_TOOLS_INTRO is executed.
display an introductory text for tools + menu
display the tools menu
show an introductory text for backup tool OR stream a ZIP-file to the browser
If we arrive here via the tools menu, the parameter download is not set. In that case we show an introductory text with a link that yields a ZIP-file with the backup.
If the user follows the download link, we arrive here too but with the download parameter set. We then dump the database in a variable and subsequently compress it in a ZIP-file which we stream to the browser. We do code some things in the basename of the backup:
The parameter download is currently set to 'zip'. However, we do attempt to send the plain uncompressed data if that parameter is set to 'sql' (quick and dirty). Oh well. hopefully there is enough memory to accomodate backups of moderate sized sites.
Note that we need space to compress the data; a informal test yielded that we need about 160% of the uncompressed size of the backup (tested with a small testset). Rule of the thumb for memory: the more the merrier but at least twice the size of the uncompressed backup.
quick and dirty logfile viewer
this constructs a table of the HTML-variety with the contents of the logtable. fields displayed are: datim, IP-address, username, logpriority and message we use a LEFT JOIN in order to get to a meaningful username rather than a numeric user_id an attempt is made to start with the last page of the logs because that would probably be the most interesting part. We paginate the log in order to keep it manageable.
<Rant>
I used to use the built-in constants like LOG_INFO and LOG_DEBUG to allow for different levels of logging (see logger()). To my complete surprise logging didn't work at all on Windows (it did on Linux). The reason was that LOG_DEBUG and LOG_INFO and LOG_NOTICE are all defined to be the same value. WTF? Any test based on LOG_DEBUG and LOG_INFO being different would fail, hence no logging at all. The mind boggles! So, instead of using built-in constants I had to define my own and do a global search&replace. Aaarghhhhhh!!!!
</Rant>
Documentation generated on Sat, 1 Oct 2011 00:27:44 +0200 by phpDocumentor 1.4.0