summaryrefslogtreecommitdiff
path: root/includes/sys_log.php
blob: 60c765c0ff5f362868f9f4ec0a90d21359b66c05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php

/**
 * Write a log entry.
 * This should be used to log user's activity.
 *
 * @param
 *          $message
 */
function engelsystem_log($message) {
  global $user;

  if (isset($user)) {
    $nick = $user['Nick'];
  } else {
    $nick = "Guest";
  }

  LogEntry_create($nick, $message);
}

/**
 * Generates a PHP Stacktrace.
 */
function debug_string_backtrace() {
  ob_start();
  debug_print_backtrace();
  $trace = ob_get_contents();
  ob_end_clean();

  // Remove first item from backtrace as it's this function which
  // is redundant.
  $trace = preg_replace('/^#0\s+' . __FUNCTION__ . "[^\n]*\n/", '', $trace, 1);

  // Renumber backtrace items.
  $trace = preg_replace('/^#(\d+)/me', '\'#\' . ($1 - 1)', $trace);

  return $trace;
}

?>