Changes

Jump to navigation Jump to search
1,178 bytes added ,  06:44, 29 November 2019
This [[Module Library|XQuery Module]] contains functions for performing admin-centric operations that are restricted to such as managing database users with [[User Management|Admin Permissions]]. Existing users can be listed, and soon morelog data.
=Conventions=
All functions and errors in this module are assigned to the {{Code|<code><nowiki>http://basex.org/modules/admin}} </nowiki></code> namespace, which is statically bound to the {{Code|admin}} prefix.<br/>All errors are assigned to the {{Code|http://basex.org/errors}} namespace, which is statically bound to the {{Code|bxerr}} prefix.
=Functions=
==admin:userssessions== {|width='100%'
|-
| width='90120' | '''Signatures'''|{{Func|admin:userssessions||element(usersession)*}}<br/>{{Func|admin:users|$db as item()|element(user)*}}<br/>
|-
| '''Summary'''
|Returns an element sequence, containing with all registered users along with their access permissions.<br/>If a [[Database Module#Database Nodes|currently opened database node]] {{Code|$db}} is specifiedsessions, including the user name, users registered for a particular address (IP:port) and an optionally opened database will be returned.<br/>The output of this function is similar to and the [[Commands#SHOW_USERS{{Command|SHOW USERS]] SESSIONS}} commandis similar.
|-
| '''Examples'''
|
* {{Code|admin:userssessions()}} returns may e.g. return <code><session user permission="admin">admin<address="127.0.0.1:6286" database="factbook"/user></code> if no additional users have been created.* {{Code|admin:users("factbook")}} returns all users that have particularly registered for the specified database.
|}
==admin:sessionslogs== {|width='100%'
|-
| width='90120' | '''Signatures'''|{{Func|admin:sessionslogs||element(sessionfile)*}}<br/>{{Func|admin:logs|$date as xs:string|element(entry)*}}<br/>{{Func|admin:logs|$date as xs:string, $merge as xs:boolean|element(entry)*}}<br/>
|-
| '''Summary'''
|Returns an element sequence with [[Logging]] data compiled by the database or HTTP server:* If no argument is specified, a list of all currently opened sessionslog files will be returned, including the user name, address (IP:port) file size and an optionally opened databasedate.<br/>The output * If a {{Code|$date}} is specified, the contents of this function a single log file will be returned.* If {{Code|$merge}} is similar set to true, related log entries will be merged. Please note that the [[Commands#SHOW_SESSIONS|SHOW SESSIONS]] commandmerge might not be 100% successful, as log entries may be ambiguous.
|-
| '''Examples'''
|
* {{Code|admin:sessionslogs()}} may e.g. return <code><session userfile size="admin834367" address="127/>2015-01-23</file></code> if a single log file exists.0* {{Code|admin:logs() ! admin:logs(.0)}} lists the contents of all log files.1|} ==admin:6286" databasewrite-log== {| width='100%'|-| width="factbook"'120' | '''Signatures'''|{{Func|admin:write-log|$text as xs:string|empty-sequence()}}<br/>{{Func|admin:write-log|$text as xs:string, $type as xs:string|empty-sequence()}}|-| '''Summary'''|Writes a string to the database logs, along with current user data (timestamp, user name). An optional log {{Code|$type}} can be specified. If omitted, the log type is {{Code|INFO}}.<br/code>If the function is called from a database client, the IP will be logged. Otherwise, the string {{Code|SERVER}} will be logged.|-| '''Errors'''|{{Error|type|#Errors}} Type string contains whitespaces.
|}
==admin:delete-logs== {|width='100%'
|-
| width='90120' | '''Signatures'''|{{Func|admin:logs||element(file)*}}<br/>{{Func|admin:delete-logs|$date as xs:datestring|elementempty-sequence(entry)*}}<br/>
|-
| '''Summary'''
|Returns [[Logging]] data compiled by Deletes the database or HTTP server.log entries from the specified <br/code>If no argument is specified, a list of all log files will be returned, including the file size and $date.<br/code>If a {{Code|$date}} is specified, the contents of a single log file will be returned. An empty sequence will be returned if no logging data exists for the specified date.
|-
| '''ExamplesErrors'''|* {{CodeError|today|admin:logs()#Errors}} may return Today's log file cannot be deleted.<codebr/><{{Error|delete|#Errors}} An error occurred while deleting a log file date.|} =Errors= {| class="wikitable" width="2013-01-23100%" size! width="834367110"/></code> if |Code|Description|-|{{Code|delete}}|An error occurred while deleting a single log file exists.* |-|{{Code|admin:logs(xs:date(today}}|Today'2013s log file cannot be deleted.|-01-23'))|{{Code|type}} will list all log entries of the specified date|Type string contains whitespaces.
|}
=Changelog=
The ;Version 9.2 * Updated: [[#admin:write-log|admin:write-log]]: type string may contain more characters ;Version 9.0 * Updated: error codes updated; errors now use the module namespace ;Version 8.3 * Updated: [[#admin:write-log|admin:write-log]]: optional log type added ;Version 8.2 * Added: [[#admin:delete-logs|admin:delete-logs]] ;Version 8.0 * Added: [[#admin:write-log|admin:write-log]]* Deleted: admin:users (renamed to [[User Module was introduced with #user:list-details|user:list-details]]) ;Version 7.48.2 * Updated: [[#admin:users|admin:users]]: md5-encoded password added to output.* Updated: [[#admin:logs|admin:logs]]: represent name of log files as string value; {{Code|$merge}} argument added.
[[Category:XQuery]]The Module was introduced with Version 7.5.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu