Location: PHPKode > projects > XennoBB > xennobb/admin/logs.php
<?php
/*

  Copyright (C) 2005-2011 UserDot
  Visit XennoBB at www.userdot.net/projects/xennobb
  Originally based on PunBB www.punbb.org

  XennoBB is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published
  by the Free Software Foundation; either version 2 of the License,
  or (at your option) any later version.

  XennoBB is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  MA 02110-1301 USA

 */
define('IN_FORUM_ADMIN', 1);
require dirname(__FILE__) . '/../include/init.php';
if ($forum_user['g_id'] != USER_ADMIN)
    BB_Functions::Message($lang['No permission']);
$exists_levels = array('3', '2', '1', '0');
$level = (isset($_GET['level']) && in_array($_GET['level'], $exists_levels)) ? $_GET['level'] : '';
$where_sql = ($level != '') ? " WHERE code='" . $db->escape($level) . "'" : '';
if (isset($_GET['delete']))
{
    if ($_GET['delete'] == 'all')
        $result = $db->query('DELETE FROM ' . $db_prefix . 'logs') or BB_Functions::Error('Cannot remove logs', __FILE__, __LINE__, $db->error());
    elseif (in_array($_GET['delete'], $exists_levels))
        $result = $db->query('DELETE FROM ' . $db_prefix . 'logs WHERE code=' . intval($_GET['delete'])) or BB_Functions::Error('Cannot remove logs', __FILE__, __LINE__, $db->error());
    header('location: ' . bb_website_url . '/admin/logs.php');
    exit;
}
$result = $db->query("SELECT count(*) FROM " . $db_prefix . "logs" . $where_sql) or BB_Functions::Error('Cannot retrieve logs.', __FILE__, __LINE__, $db->error());
$num_logs = $db->result($result);
$num_pages = ceil($num_logs / 20);
$p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p'];
$start_from = 20 * ($p - 1);
$paging_links = '<strong class="pagination">' . $lang['Pages'] . '</strong> ' . BB_Core::Paginate($num_pages, $p, 'logs.php?level=' . $level);
$result = $db->query('SELECT * FROM ' . $db_prefix . 'logs' . $where_sql . ' ORDER BY date DESC LIMIT ' . $db->escape($start_from) . ', 20') or BB_Functions::Error('Cannot retrieve logs.', __FILE__, __LINE__, $db->error());
$cms_custom_title_page = $lang['Admin'] . $lang['admin_logging'];
if (is_file(dirname(__FILE__) . '/../include/templates/' . $forum_user['template'] . '/forum_admin.tpl'))
    $cms_main_template = dirname(__FILE__) . '/../include/templates/' . $forum_user['template'] . '/forum_admin.tpl';
else
    $cms_main_template = dirname(__FILE__) . '/../include/templates/Default/forum_admin.tpl';
require dirname(__FILE__) . '/../include/header.php';
?>
<div class="blockform">
    <h2><a href="<?php echo bb_website_url; ?>/admin/logs.php"><?php if ($level == '')
    echo '<strong>' . $lang['fetch_all_logs'] . '</strong>'; else
    echo $lang['fetch_all_logs']; ?></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="<?php echo bb_website_url; ?>/admin/logs.php?level=0"><?php if ($level == '0')
    printf('<strong>' . $lang['fetch_log_level'] . '</strong>', 0); else
    printf($lang['fetch_log_level'], 0); ?></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="<?php echo bb_website_url; ?>/admin/logs.php?level=1"><?php if ($level == '1')
    printf('<strong>' . $lang['fetch_log_level'] . '</strong>', 1); else
    printf($lang['fetch_log_level'], 1); ?></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="<?php echo bb_website_url; ?>/admin/logs.php?level=2"><?php if ($level == '2')
    printf('<strong>' . $lang['fetch_log_level'] . '</strong>', 2); else
    printf($lang['fetch_log_level'], 2); ?></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="<?php echo bb_website_url; ?>/admin/logs.php?level=3"><?php if ($level == '3')
    printf('<strong>' . $lang['fetch_log_level'] . '</strong>', 3); else
    printf($lang['fetch_log_level'], 3); ?></a></h2>
</div>
<div class="blockform">
    <h2><span><?php echo $lang['admin_log']; ?></span></h2>
    <div class="box">
        <div class="inbox">
            <table>
                <thead>
                    <tr>
                        <th><?php echo $lang['Username'] ?></th>
                        <th><?php echo $lang['IP'] ?></th>
                        <th><?php echo $lang['Date'] ?></th>
                        <th><?php echo $lang['Action'] ?></th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    if ($db->num_rows($result))
                    {
                        while ($log_data = $db->fetch_assoc($result))
                        {
                            ?>
                            <tr>
                                <td class="xbb_log<?php echo $log_data['code'] ?>"><?php echo $log_data['user_name'] ?></td>
                                <td class="xbb_log<?php echo $log_data['code'] ?>"><?php echo $log_data['user_ip'] ?></td>
                                <td class="xbb_log<?php echo $log_data['code'] ?>"><?php echo $log_data['date'] ?></td>
                                <td class="xbb_log<?php echo $log_data['code'] ?>"><?php echo $log_data['log'] ?></td>
                            </tr>
        <?php
    }
}
?>
                </tbody>
            </table>
        </div>
        <div class="linksb">
            <div class="inbox">
                <p class="pagelink"><?php echo $paging_links ?></p>
            </div>
        </div>
        <div class="inbox">
            <ul>
                <li><a href="<?php echo bb_website_url; ?>/admin/logs.php?delete=all" onclick="return window.confirm('<?php echo $lang['confirm_delete_log']; ?>')"><?php echo $lang['delete_all_log']; ?></a></li>
                <li><a href="<?php echo bb_website_url; ?>/admin/logs.php?delete=0" onclick="return window.confirm('<?php echo $lang['confirm_delete_log']; ?>')"><?php printf($lang['delete_log_level'], 0); ?></a></li>
                <li><a href="<?php echo bb_website_url; ?>/admin/logs.php?delete=1" onclick="return window.confirm('<?php echo $lang['confirm_delete_log']; ?>')"><?php printf($lang['delete_log_level'], 1); ?></a></li>
                <li><a href="<?php echo bb_website_url; ?>/admin/logs.php?delete=2" onclick="return window.confirm('<?php echo $lang['confirm_delete_log']; ?>')"><?php printf($lang['delete_log_level'], 2); ?></a></li>
                <li><a href="<?php echo bb_website_url; ?>/admin/logs.php?delete=3" onclick="return window.confirm('<?php echo $lang['confirm_delete_log']; ?>')"><?php printf($lang['delete_log_level'], 3); ?></a></li>
            </ul>
        </div>
    </div>
</div>
<?php
require dirname(__FILE__) . '/../include/footer.php';
?>
Return current item: XennoBB