File/program/lib/toolslib.php

Description

/program/lib/toolslib.php - tools

Constants
TASK_BACKUPTOOL = backuptool (line 31)
TASK_LOGVIEW = logview (line 32)
TASK_TOOLS_INTRO = intro (line 29)
TASK_TRANSLATETOOL = translatetool (line 30)
Functions
job_tools (line 45)

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.

  • return: results are returned as output in $output
  • todo: fix permissions for backup tool! perhaps another bit?
void job_tools (object &$output)
  • object &$output: collects the html output
show_tools_intro (line 113)

display an introductory text for tools + menu

  • return: results are returned as output in $output
void show_tools_intro (object &$output)
  • object &$output: collects the html output
show_tools_menu (line 125)

display the tools menu

  • return: results are returned as output in $output
void show_tools_menu (object &$output, [string $current_task = NULL])
  • object &$output: collects the html output
  • string $current_task: indicate the current menu selection (if any)
task_backuptool (line 203)

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 hostname
  • the database name
  • the database prefix
  • the date and the time
which should be enough to distinguish nearly all backups if you happen to have a lot of different ones. Note that the URL is also encoded as a comment in the .ZIP.

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.

  • return: displayed via $output OR ZIP-file streamed to the browser
output task_backuptool (object &$output)
  • object &$output: collects output to show to user
task_logview (line 291)

quick and dirty logfile viewer

this constructs a table 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.

  • return: displayed via $output
  • todo: should we allow for fancy selection mechanisms on the logfile or is that over the top?
output task_logview (object &$output)
  • object &$output: collects output to show to user

Documentation generated on Wed, 11 May 2011 23:45:39 +0200 by phpDocumentor 1.4.0