2 require_once("{$GLOBALS['srcdir']}/sql.inc");
4 function newEvent($event, $user, $groupname, $comments="") {
5 $adodb = $GLOBALS['adodb']['db'];
6 $sql = "insert into log ( date, event, user, groupname, comments ) " .
7 "values ( NOW(), " . $adodb->qstr($event) . "," . $adodb->qstr($user) .
8 "," . $adodb->qstr($groupname) . "," .$adodb->qstr($comments) . ")";
9 return sqlInsertClean($sql);
12 function getEventByDate($date, $user="", $cols="DISTINCT date, event, user, groupname, comments")
14 $sql = "SELECT $cols FROM log WHERE date >= '$date 00:00:00' AND date <= '$date 23:59:59'";
15 if ($user) $sql .= " AND user LIKE '$user'";
16 $sql .= " ORDER BY date DESC LIMIT 5000";
17 $res = sqlStatement($sql);
18 for($iter=0; $row=sqlFetchArray($res); $iter++) {
25 * Get records from the LOG table
26 * using the optional parameters:
27 * date : a specific date (defaults to today)
28 * user : a specific user (defaults to none)
29 * cols : gather specific columns (defaults to date,event,user,groupname,comments)
30 * sortby : sort the results by (defaults to none)
34 function getEvents($params)
36 // parse the parameters
37 $cols = "DISTINCT date, event, user, groupname, comments";
38 if (isset($params['cols']) && $params['cols'] != "") $cols = $params['cols'];
40 $date = date("Y-m-d", time());
41 if (isset($params['date']) && $params['date'] != "") $date= $params['date'];
44 if (isset($params['user']) && $params['user'] != "") $user= $params['user'];
47 if (isset($params['sortby']) && $params['sortby'] != "") $sortby = $params['sortby'];
50 $sql = "SELECT $cols FROM log WHERE date >= '$date 00:00:00' AND date <= '$date 23:59:59'";
51 if ($user != "") $sql .= " AND user LIKE '$user'";
52 if ($sortby != "") $sql .= " ORDER BY ".$sortby." DESC "; // descending order
53 $sql .= " LIMIT 5000";
54 $res = sqlStatement($sql);
55 for($iter=0; $row=sqlFetchArray($res); $iter++) {