Beehive PHP Cross Reference Discussion Forums

Source: /admin_visitor_log.php - 252 lines - 11087 bytes - Summary - Text - Print

   1  <?php
   2  
   3  /*======================================================================
   4  Copyright Project Beehive Forum 2002
   5  
   6  This file is part of Beehive Forum.
   7  
   8  Beehive Forum is free software; you can redistribute it and/or modify
   9  it under the terms of the GNU General Public License as published by
  10  the Free Software Foundation; either version 3 of the License, or
  11  (at your option) any later version.
  12  
  13  Beehive Forum is distributed in the hope that it will be useful,
  14  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16  GNU General Public License for more details.
  17  
  18  You should have received a copy of the GNU General Public License
  19  along with Beehive; if not, write to the Free Software
  20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  21  USA
  22  ======================================================================*/
  23  
  24  // Bootstrap
  25  require_once  'boot.php';
  26  
  27  // Required includes
  28  require_once  BH_INCLUDE_PATH . 'admin.inc.php';
  29  require_once  BH_INCLUDE_PATH . 'banned.inc.php';
  30  require_once  BH_INCLUDE_PATH . 'constants.inc.php';
  31  require_once  BH_INCLUDE_PATH . 'form.inc.php';
  32  require_once  BH_INCLUDE_PATH . 'format.inc.php';
  33  require_once  BH_INCLUDE_PATH . 'header.inc.php';
  34  require_once  BH_INCLUDE_PATH . 'html.inc.php';
  35  require_once  BH_INCLUDE_PATH . 'session.inc.php';
  36  require_once  BH_INCLUDE_PATH . 'user.inc.php';
  37  require_once  BH_INCLUDE_PATH . 'word_filter.inc.php';
  38  // End Required includes
  39  
  40  // Check we're logged in correctly
  41  if (!session::logged_in()) {
  42      html_guest_error();
  43  }
  44  
  45  // Check we have Admin / Moderator access
  46  if (!(session::check_perm(USER_PERM_ADMIN_TOOLS, 0))) {
  47      html_draw_error(gettext("You do not have permission to use this section."));
  48  }
  49  
  50  // Perform additional admin login.
  51  admin_check_credentials();
  52  
  53  if (isset($_GET['page']) && is_numeric($_GET['page'])) {
  54      $page = ($_GET['page'] > 0) ? $_GET['page'] : 1;
  55  } else {
  56      $page = 1;
  57  }
  58  
  59  $error_msg_array = array();
  60  
  61  if (isset($_POST['prune_log'])) {
  62  
  63      $valid = true;
  64  
  65      if (isset($_POST['remove_days']) && is_numeric($_POST['remove_days'])) {
  66          $remove_days = $_POST['remove_days'];
  67      } else {
  68          $remove_days = 0;
  69      }
  70  
  71      if ($valid) {
  72  
  73          if (admin_prune_visitor_log($remove_days)) {
  74  
  75              header_redirect("admin_visitor_log.php?webtag=$webtag&pruned=true");
  76              exit;
  77  
  78          } else {
  79  
  80              $error_msg_array[] = gettext("Failed To Prune Visitor Log");
  81              $valid = false;
  82          }
  83      }
  84  }
  85  
  86  html_draw_top(sprintf('title=%s', gettext("Admin - Visitor Log")), 'class=window_title', 'main_css=admin.css');
  87  
  88  $admin_visitor_log_array = admin_get_visitor_log($page);
  89  
  90  echo "<h1>", gettext("Admin"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" />", gettext("Visitor Log"), "</h1>\n";
  91  
  92  if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
  93  
  94      html_display_error_array($error_msg_array, '86%', 'center');
  95  
  96  } else if (isset($_GET['pruned'])) {
  97  
  98      html_display_success_msg(gettext("Successfully Pruned Visitor Log"), '86%', 'center');
  99  
 100  } else if (sizeof($admin_visitor_log_array['user_array']) < 1) {
 101  
 102      html_display_warning_msg(gettext("No Visitors Logged"), '86%', 'center');
 103  }
 104  
 105  echo "<br />\n";
 106  echo "<div align=\"center\">\n";
 107  echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"86%\">\n";
 108  echo "    <tr>\n";
 109  echo "      <td align=\"left\">\n";
 110  echo "        <table class=\"box\" width=\"100%\">\n";
 111  echo "          <tr>\n";
 112  echo "            <td align=\"left\" class=\"posthead\">\n";
 113  echo "               <table width=\"100%\">\n";
 114  echo "                 <tr>\n";
 115  echo "                   <td class=\"subhead\" align=\"left\" style=\"white-space: nowrap\">", gettext("Member"), "</td>\n";
 116  echo "                   <td class=\"subhead\" align=\"left\" style=\"white-space: nowrap\">", gettext("Last Visit"), "</td>\n";
 117  echo "                   <td class=\"subhead\" align=\"left\" style=\"white-space: nowrap\">", gettext("Last IP Address"), "</td>\n";
 118  echo "                   <td class=\"subhead\" align=\"left\" style=\"white-space: nowrap\">", gettext("Referer"), "</td>\n";
 119  echo "                 </tr>\n";
 120  
 121  if (sizeof($admin_visitor_log_array['user_array']) > 0) {
 122  
 123      foreach ($admin_visitor_log_array['user_array'] as $visitor) {
 124  
 125          echo "                 <tr>\n";
 126  
 127          if (isset($visitor['SID']) && !is_null($visitor['SID'])) {
 128  
 129              echo "                   <td class=\"postbody\" align=\"left\" style=\"white-space: nowrap\"><a href=\"{$visitor['URL']}\" target=\"_blank\">", word_filter_add_ob_tags($visitor['NAME'], true), "</a></td>\n";
 130  
 131          } else if ($visitor['UID'] > 0) {
 132  
 133              echo "                   <td class=\"postbody\" align=\"left\" style=\"white-space: nowrap\"><a href=\"user_profile.php?webtag=$webtag&amp;uid={$visitor['UID']}\" target=\"_blank\" class=\"popup 650x500\">", word_filter_add_ob_tags(format_user_name($visitor['LOGON'], $visitor['NICKNAME']), true), "</a></td>\n";
 134  
 135          } else {
 136  
 137              echo "                   <td class=\"postbody\" align=\"left\" style=\"white-space: nowrap\">", word_filter_add_ob_tags(format_user_name($visitor['LOGON'], $visitor['NICKNAME']), true), "</td>\n";
 138          }
 139  
 140          if (isset($visitor['LAST_LOGON']) && $visitor['LAST_LOGON'] > 0) {
 141              echo "                   <td class=\"postbody\" align=\"left\" width=\"100\">", format_time($visitor['LAST_LOGON']), "</td>\n";
 142          } else {
 143              echo "                   <td class=\"postbody\" align=\"left\" width=\"100\">", gettext("Unknown"), "</td>\n";
 144          }
 145  
 146          if (isset($visitor['IPADDRESS']) && strlen($visitor['IPADDRESS']) > 0) {
 147  
 148              if (ip_is_banned($visitor['IPADDRESS'])) {
 149  
 150                  echo "                   <td class=\"postbody\" align=\"left\" width=\"200\"><a href=\"admin_banned.php?webtag=$webtag&amp;unban_ipaddress={$visitor['IPADDRESS']}&amp;ret=", rawurlencode(get_request_uri(true, false)), "\" target=\"_self\">{$visitor['IPADDRESS']}</a>&nbsp;(", gettext("Banned"), ")&nbsp;</td>\n";
 151  
 152              } else {
 153  
 154                  echo "                   <td class=\"postbody\" align=\"left\" width=\"200\"><a href=\"admin_banned.php?webtag=$webtag&amp;ban_ipaddress={$visitor['IPADDRESS']}&amp;ret=", rawurlencode(get_request_uri(true, false)), "\" target=\"_self\">{$visitor['IPADDRESS']}</a>&nbsp;</td>\n";
 155              }
 156  
 157          } else {
 158  
 159              echo "                   <td class=\"postbody\" align=\"left\" width=\"200\">", gettext("Unknown"), "</td>\n";
 160          }
 161  
 162          if (isset($visitor['REFERER']) && strlen(trim($visitor['REFERER'])) > 0) {
 163  
 164              $visitor['REFERER_FULL'] = $visitor['REFERER'];
 165  
 166              if (!$visitor['REFERER'] = split_url($visitor['REFERER'])) {
 167                  if (mb_strlen($visitor['REFERER_FULL']) > 25) {
 168                      $visitor['REFERER'] = mb_substr($visitor['REFERER_FULL'], 0, 25);
 169                      $visitor['REFERER'] .= "&hellip;";
 170                  }
 171              }
 172  
 173              if (referer_is_banned($visitor['REFERER'])) {
 174                  echo "                   <td class=\"posthead\" align=\"left\" style=\"white-space: nowrap\">&nbsp;<a href=\"admin_banned.php?webtag=$webtag&amp;unban_referer=", rawurlencode($visitor['REFERER_FULL']), "&amp;ret=", rawurlencode(get_request_uri(true, false)), "\" title=\"{$visitor['REFERER_FULL']}\">{$visitor['REFERER']}</a>&nbsp;<a href=\"{$visitor['REFERER_FULL']}\" target=\"_blank\"><img src=\"", html_style_image('link.png'), "\" border=\"0\" align=\"top\" alt=\"", gettext("External Link"), "\" title=\"", gettext("External Link"), "\" /></a>&nbsp;(", gettext("Banned"), ")</td>\n";
 175              } else {
 176                  echo "                   <td class=\"posthead\" align=\"left\" style=\"white-space: nowrap\">&nbsp;<a href=\"admin_banned.php?webtag=$webtag&amp;ban_referer=", rawurlencode($visitor['REFERER_FULL']), "&amp;ret=", rawurlencode(get_request_uri(true, false)), "\" title=\"{$visitor['REFERER_FULL']}\">{$visitor['REFERER']}</a>&nbsp;<a href=\"{$visitor['REFERER_FULL']}\" target=\"_blank\"><img src=\"", html_style_image('link.png'), "\" border=\"0\" align=\"top\" alt=\"", gettext("External Link"), "\" title=\"", gettext("External Link"), "\" /></a></td>\n";
 177              }
 178  
 179          } else {
 180  
 181              echo "                   <td class=\"posthead\" align=\"left\" style=\"white-space: nowrap\">&nbsp;", gettext("Unknown"), "</td>\n";
 182          }
 183  
 184          echo "                 </tr>\n";
 185      }
 186  }
 187  
 188  echo "                 <tr>\n";
 189  echo "                   <td align=\"left\" class=\"postbody\">&nbsp;</td>\n";
 190  echo "                 </tr>\n";
 191  echo "               </table>\n";
 192  echo "             </td>\n";
 193  echo "           </tr>\n";
 194  echo "         </table>\n";
 195  echo "      </td>\n";
 196  echo "    </tr>\n";
 197  echo "    <tr>\n";
 198  echo "      <td align=\"left\">&nbsp;</td>\n";
 199  echo "    </tr>\n";
 200  echo "    <tr>\n";
 201  echo "      <td align=\"center\">";
 202  
 203  html_page_links("admin_visitor_log.php?webtag=$webtag", $page, $admin_visitor_log_array['user_count'], 10);
 204  
 205  echo "      </td>\n";
 206  echo "    </tr>\n";
 207  echo "    <tr>\n";
 208  echo "      <td align=\"left\">&nbsp;</td>\n";
 209  echo "    </tr>\n";
 210  echo "  </table>\n";
 211  echo "  <form accept-charset=\"utf-8\" action=\"admin_visitor_log.php\" method=\"post\" target=\"_self\">\n";
 212  echo "  ", form_input_hidden("webtag", htmlentities_array($webtag)), "\n";
 213  echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"86%\">\n";
 214  echo "    <tr>\n";
 215  echo "      <td align=\"left\">\n";
 216  echo "        <table class=\"box\" width=\"100%\">\n";
 217  echo "          <tr>\n";
 218  echo "            <td align=\"left\" class=\"posthead\">\n";
 219  echo "              <table class=\"posthead\" width=\"100%\">\n";
 220  echo "                <tr>\n";
 221  echo "                  <td align=\"left\" class=\"subhead\">", gettext("Options"), "</td>\n";
 222  echo "                </tr>\n";
 223  echo "                <tr>\n";
 224  echo "                  <td align=\"center\">\n";
 225  echo "                    <table class=\"posthead\" width=\"95%\">\n";
 226  echo "                      <tr>\n";
 227  echo "                        <td align=\"left\" width=\"250\" style=\"white-space: nowrap\">", gettext("Remove Entries Older Than (Days)"), ":</td>\n";
 228  echo "                        <td align=\"left\">", form_input_text('remove_days', '30', 15, 4), "</td>\n";
 229  echo "                      </tr>\n";
 230  echo "                      <tr>\n";
 231  echo "                        <td align=\"left\">&nbsp;</td>\n";
 232  echo "                      </tr>\n";
 233  echo "                    </table>\n";
 234  echo "                  </td>\n";
 235  echo "                </tr>\n";
 236  echo "              </table>\n";
 237  echo "            </td>\n";
 238  echo "          </tr>\n";
 239  echo "        </table>\n";
 240  echo "      </td>\n";
 241  echo "    </tr>\n";
 242  echo "    <tr>\n";
 243  echo "      <td>&nbsp;</td>\n";
 244  echo "    </tr>\n";
 245  echo "    <tr>\n";
 246  echo "      <td colspan=\"2\" align=\"center\">", form_submit("prune_log", gettext("Prune Log")), "</td>\n";
 247  echo "    </tr>\n";
 248  echo "  </table>\n";
 249  echo "  </form>\n";
 250  echo "</div>\n";
 251  
 252  html_draw_bottom();

title

Description

title

Description

title

Description

title

title

Body