function rss_activity_log($sys, $entries) { global $SERVER_URL, $login; $sql_params = array(); $limit = $where = ''; switch ($GLOBALS['db_type']) { case 'mysqli': case 'mysql': case 'postgresql': $limit .= ' LIMIT ' . $entries; break; case 'oracle': $where .= ' AND ROWNUM <= ' . $entries; break; } $sql = 'SELECT wel.cal_login, wel.cal_user_cal, wel.cal_type, wel.cal_date, wel.cal_time, wel.cal_text, ' . ($sys ? 'wel.cal_log_id FROM webcal_entry_log wel WHERE wel.cal_entry_id = 0' : 'we.cal_id, we.cal_name, wel.cal_log_id, we.cal_type, we.cal_description FROM webcal_entry_log wel, webcal_entry we WHERE wel.cal_entry_id = we.cal_id' . $where) . ' ORDER BY wel.cal_log_id DESC' . $limit; $rows = dbi_get_cached_rows($sql, $sql_params); $ret = ''; for ($i = 0; $i < count($rows) && $i < $entries; $i++) { $row = $rows[$i]; $num = 0; $l_login = $row[0]; $l_user = $row[1]; $l_type = $row[2]; $l_date = $row[3]; $l_time = $row[4]; $l_text = $row[5]; if ($sys) { $l_id = $row[6]; $l_description = ''; } else { $l_eid = $row[6]; $l_ename = $row[7]; $l_id = $row[8]; $l_etype = $row[9]; $l_description = $row[10]; // convert lines to <br> if no HTML formatting found if (strpos($l_description, "</") == false) { $l_description = nl2br($l_description); } } $num++; $unixtime = date_to_epoch($l_date . $l_time); $subject = display_activity_log($l_type, $l_text, "\n"); $ret .= "<item>\n" . ' <title><![CDATA[' . $subject . ': ' . htmlspecialchars($l_ename) . ']]></title>' . "\n <link>" . $SERVER_URL . 'view_entry.php?id=' . $l_eid . "</link>\n" . ' <description><![CDATA[' . $l_description . ']]></description>' . "\n"; //$ret .= // ' <category><![CDATA[' . $category . ']]></category>' . "\n"; /* RSS 2.0 date format Wed, 02 Oct 2002 13:00:00 GMT */ $ret .= '<pubDate>' . gmdate('D, d M Y H:i:s', $unixtime) . ' GMT</pubDate>' . "\n" . ' <guid>' . $SERVER_URL . 'view_entry.php?id=' . $l_eid . '&friendly=1&rssuser='******'&date=' . $l_date . "</guid>\n"; $ret .= "</item>\n\n"; } return $ret; }
function generate_activity_log($id = '', $sys = false, $startid = '') { global $GENERAL_USE_GMT, $nextpage, $PAGE_SIZE; $nextpage = ''; $size = $id ? 'h3' : 'h2'; $sql_params = array(); if (!empty($id)) { $sql_params[] = $id; } $sql_params[] = $startid; $ret = "<{$size}>" . ($sys ? translate('System Log') : translate('Activity Log')) . ($sys ? '' : ' <a href="rss_activity_log.php">' . '<img src="images/rss.png" width="14" height="14" alt="RSS 2.0 - ' . translate('Activity Log') . '" border="0"/></a>') . "</{$size}>" . display_admin_link() . ' <table class="embactlog"> <tr> <th class="usr">' . translate('User') . '</th> <th class="cal">' . translate('Calendar') . '</th> <th class="scheduled">' . translate('Date') . '/' . translate('Time') . '</th>' . ($sys || $id ? '' : ' <th class="dsc">' . translate('Event') . '</th>') . ' <th class="action">' . translate('Action') . '</th> </tr>'; $sql = 'SELECT wel.cal_login, wel.cal_user_cal, wel.cal_type, wel.cal_date, wel.cal_time, wel.cal_text, ' . ($sys ? 'wel.cal_log_id FROM webcal_entry_log wel WHERE wel.cal_entry_id = 0' : 'we.cal_id, we.cal_name, wel.cal_log_id, we.cal_type FROM webcal_entry_log wel, webcal_entry we WHERE wel.cal_entry_id = we.cal_id') . (empty($id) ? '' : ' AND we.cal_id = ?') . (empty($startid) ? '' : ' AND wel.cal_log_id <= ?') . ' ORDER BY wel.cal_log_id DESC'; $res = dbi_execute($sql, $sql_params); if ($res) { $num = 0; while ($row = dbi_fetch_row($res)) { $l_login = $row[0]; $l_user = $row[1]; $l_type = $row[2]; $l_date = $row[3]; $l_time = $row[4]; $l_text = $row[5]; if ($sys) { $l_id = $row[6]; } else { $l_eid = $row[6]; $l_ename = $row[7]; $l_id = $row[8]; $l_etype = $row[9]; } $num++; if ($num > $PAGE_SIZE) { $nextpage = $l_id; break; } else { $ret .= ' <tr' . ($num % 2 ? ' class="odd"' : '') . '> <td>' . $l_login . '</td> <td>' . $l_user . '</td> <td>' . date_to_str($l_date) . ' ' . display_time($l_date . $l_time, !empty($GENERAL_USE_GMT) && $GENERAL_USE_GMT == 'Y' ? 3 : 2) . '</td> <td>' . (!$sys && !$id ? '<a title="' . htmlspecialchars($l_ename) . '" href="view_entry.php?id=' . $l_eid . '">' . htmlspecialchars($l_ename) . '</a></td> <td>' : '') . display_activity_log($l_type, $l_text) . '</td> </tr>'; } } dbi_free_result($res); } return $ret . ' </table>'; }