/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.
download records from the log table in CSV format
this sends the contents of the logtable upto (but excluding) the record with pkey = $pivot to the user in CSV format
the suggested filename contains the name of the host and the first and the last pkey of the records exported. This allows for downloading logs from different hosts and multiple times from the same host without name clashes.
If there are errors or no records nothing is sent to the user (but we do try to log the event).
Note The number Nr displayed in the overview (see logview_show()) is just a number starting at 1 every time. The download file works with the real record pkey.
helper routine to translate a numeric priority to human readable text
look up the symbolic name of priority $p
[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]
ask for confirmation and/or maybe execute pruning of log messages table
shows confirmation screen including download link and also actually process the deletions if the user confirmed. We give the user another opportunity to download the selected records before pruning.
show entries from log table in a neat HTML-table (possibly paginated)
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.
handle confirmation and actual delete of a session
this single routine handles
show a table with sessions
display a table with sessions and locked nodes per session
If $id is NULL, all current sessions+locks are displayed, if $id is a specific session_id only that session is displayed. (used in the session delete chore, see sessions_delete()).
If $show_delete is TRUE a link is displayed that allows the user to delete a session, if FALSE no link is displayed.
close the HTML-table
show the header of the HTML-table
| D | sss | ctime | atime | username (full_name) | ip_addr | | nnn | ltime | link_text (title) |
the HTML-table has 5 or 6 columns, depending on $show_delete. the header takes two rows: one for the session information, and another for the node lock information.
Parameter $class is used for styling of the table header.
show locked node information from a single (combined) record
the HTML-table has 5 or 6 columns, depending on $show_delete. Parameter $class is used for styling of the table row. The value is toggled between 'odd' and 'even'.
show an overview of currently existing sessions
show session information from a single (combined) record
the HTML-table has 5 or 6 columns, depending on $show_delete. Parameter $class is used for styling of the table row. The value is toggled between 'odd' and 'even'.
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 view / download / prune tool
this is the dispatcher that decides whether to show entries, download entries or prune the logs
main entry point for session management
helper routine to construct something that looks like this hosts name
Documentation generated on Tue, 28 Jun 2016 19:12:18 +0200 by phpDocumentor 1.4.0