Location: PHPKode > projects > phpBannerEx > adm_log.php
<?
#################################################################################################
#
#  project              : phpBannerEx
#  filename             : .php
#  last modified by     : 
#  e-mail               : hide@address.com
#  purpose              :
#
#################################################################################################

#  Include Configs & Variables
#################################################################################################
require("admin/config.php");
require("library.php");

db_connect();
ReadConfig();

$user = authorize();

if($user[ur_id] != 1) {
  unauthorize();
  print "<script> document.location=document.location; </script>";
  exit;
}


function main_list() {
  global $f_time, $f_ipaddr, $f_site, $f_action, $lang;

  if(!isset($f_time))   { $f_time = 1; }
  if(!isset($f_action)) { $f_action = 1; }

  echo "<center>\n";

  echo "<form name=\"frmLog\" method=post>\n";
  echo "<h1>".get_msg(log,$lang)."</h1>\n";
  echo "<table class=list width=70%>\n";
  echo "  <tr>\n";
  echo "    <th class=list>".get_msg(time,$lang)."</th>\n";
  echo "    <th class=list>".get_msg(ipaddr,$lang)."</th>\n";
  echo "    <th class=list>".get_msg(site,$lang)."</th>\n";
  echo "    <th class=list>".get_msg(action,$lang)."</th>\n";
  echo "  </tr>\n";
  echo "  <tr>\n";
  echo "    <th class=list>\n";
  $s_time[$f_time] = " selected";
  echo "      <select name=f_time onchange=\"javascript:document.frmLog.submit();\">\n";
  echo "        <option value=1$s_time[1]>".get_msg(onlast,$lang)." 1 ".get_msg(day,$lang)."</option>\n";
  echo "        <option value=5$s_time[5]>".get_msg(onlast,$lang)." 5 ".get_msg(days,$lang)."</option>\n";
  echo "        <option value=10$s_time[10]>".get_msg(onlast,$lang)." 10 ".get_msg(days,$lang)."</option>\n";
  echo "        <option value=30$s_time[30]>".get_msg(onlast,$lang)." 30 ".get_msg(days,$lang)."</option>\n";
  echo "      </select>\n";
  echo "    </th>\n";
  echo "    <th class=list><input type=text name=f_ipaddr value=\"$f_ipaddr\"></th>\n";
  echo "    <th class=list><input type=text name=f_site value=\"$f_site\"></th>\n";
  echo "    <th class=list>\n";
  $s_action[$f_action] = " selected";
  echo "      <select name=f_action onchange=\"javascript:document.frmLog.submit();\">\n";
  echo "        <option value=1$s_action[1]>".get_msg(all,$lang)."</option>\n";
  echo "        <option value=2$s_action[2]>".get_msg(show_me,$lang)."</option>\n";
  echo "        <option value=3$s_action[3]>".get_msg(show_my,$lang)."</option>\n";
  echo "        <option value=4$s_action[4]>".get_msg(click_me,$lang)."</option>\n";
  echo "        <option value=5$s_action[5]>".get_msg(click_my,$lang)."</option>\n";
  echo "      </select>\n";
  echo "    </th>\n";
  echo "  </tr>\n";

  $where_str = "(lg_time BETWEEN date_sub(now(), interval $f_time day) AND now())";

  if($f_action == 2) {
    $where_str .= " AND (lg_show_me > 0)";
  } else if ($f_action == 3) {
    $where_str .= " AND (lg_show_my > 0)";
  } else if ($f_action == 4) {
    $where_str .= " AND (lg_click_me > 0)";
  } else if ($f_action == 5) {
    $where_str .= " AND (lg_click_my > 0)";
  }

  if($f_ipaddr) { $where_str .= " AND (lg_ipaddr like '%$f_ipaddr%')"; }
  if($f_site)   { $where_str .= " AND ((st_name like '%$f_site%') OR (ur_name like '%$f_site%'))"; }

  $sql = "SELECT *
          FROM log
          LEFT JOIN site ON (lg_site_ref=st_id)
          LEFT JOIN user ON (st_user_ref=ur_id)
          WHERE $where_str
          ORDER BY lg_time DESC";
  $res = db_query($sql);
  while($row = mysql_fetch_array($res)) {
    echo "  <tr>\n";
    echo "    <td class=list>$row[lg_time]</td>\n";
    echo "    <td class=list>$row[lg_ipaddr]</td>\n";
    if($row[st_id]) {
      $site = "$row[st_name] ($row[ur_name])";
    } else {
      $site = "System banner";
    }
    echo "    <td class=list>$site</td>\n";
    if($row[lg_show_me]) {
      $action = get_msg(show_me,$lang);
    } else if($row[lg_show_my]) {
      $action = get_msg(show_my,$lang);
    } else if($row[lg_click_me]) {
      $action = get_msg(click_me,$lang);
    } else if($row[lg_click_my]) {
      $action = get_msg(click_my,$lang);
    }
    echo "    <td class=list>$action</td>\n";
    echo "   </tr>\n";
  }
  echo "</table>\n";
  echo "<p>\n";
  echo "<input type=submit value=\"".get_msg(submit,$lang)."\">\n";
  echo "</form>\n";

  echo "</center>\n";
}

include($addheader);

include("adm_menu.inc");

if(!$act) { main_list(); }

include("$addfooter");

?>
Return current item: phpBannerEx