Translations of this page: en bg cs de fi fr hu it ja pl ru tr zh

This is an old revision of the document!


API for events registration (pun_admin_events)

PunBB 1.3 official extension

  • Status: under development
  • Current version: 0.8

General idea

Adds an gear to logging events and GUI for browsing logs.

Specification

Functionality

Extension allow to use API for events registration.

Interface

  • Link “Events” at the “Management” tab in administration menu.
  • “Events page”:
    • At this page all registered events are shown.
    • Filters for events:
      • By date from
      • By date to
      • By event's type
      • By IP
      • By username
      • By comment
      • Sort by
      • Sort direction
    • Fields of table with events:
      • IP
      • Event type
      • Event's comment
      • Event date
      • Username of user, who rouse the event

Database

  • New table pun_admin_events
Field Type Default Description
ip VARCHAR(15) 0.0.0.0 IP-address of user, who cause the event
type VARCHAR(64) Type of the event.
comment VARCHAR(255) Some comment about event.
user_id INT(10) NULL User id who cause the event.
user_name VARCHAR(255) NULL Username of user who cause the event.
date INT(10) UNSIGNED Date of the event.

API documentation

Functions

pun_admin_event

Register an event.

void pun_admin_event(string $type, [string $comment = '', [bool $search_user = true]])

  • string $type: Type of registered events. (Example: “Topic”)
  • string $comment: Comment of registered events. (Example: “Topic under ID 100 has been deleted.”)
  • bool $search_user: If set to true function try to determine user, who cause the event.

Examples

Example 1

First example show how to register posts and topics deletion at your forum. Add this peace of code after line 92 of ”<FORUM_ROOT>/delete.php”.

<?php
include FORUM_ROOT.'extensions/pun_admin_events/pun_admin_events.php';
pun_admin_event('Topic', 'Topic under ID '.$cur_post['tid'].' has been deleted.', true);
?>

Add this after after line 102 of ”<FORUM_ROOT>/delete.php”.

<?php
include FORUM_ROOT.'extensions/pun_admin_events/pun_admin_events.php';
pun_admin_event('Post', 'Post under ID '.$cur_post['tid'].' has been deleted.', true);
?>
Example 2

You can use this extension not only for registration of forum's events, and for other purposes. This example shows how to register file downloading via php script:

<?php
define('FORUM_ROOT', './');
include FORUM_ROOT.'extensions/pun_admin_events/pun_admin_events.php';
 
function download($file, $content_type = 'text/html')
{
	if (is_readable($file))
	{
		$fp = fopen($file, 'rb');
 
		header('Content-Type: '.$content_type);
		header('Content-Length: '.filesize($file));
 
		fpassthru($fp);
 
		pun_admin_event('download', 'The file "'.$file.'" has been downloaded.');
	}
	else
		pun_admin_event('download_error', 'Error upon downloading file "'.$file.'"');
}
 
$downloads = array('documentation');
if (isset($_GET['id']) && is_scalar($_GET['id']) && in_array($_GET['id'], $downloads))
{
	download($_GET['id']);
	die();
}
 
?>

Screenshots


Personal Tools