<?php
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2006                                            */
/* http://www.php-maximus.fr                                            */
/* dev@php-maximus.org                                                  */
/*                                                                      */
/* This program 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.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
defined('MAXIMUS') or die ('Access denied block client login ba MAXIMUS directly...');

$modname = "Banner_Ads";
get_lang($modname);
$content = "";
global $nukeurl, $baclient, $bacookie, $anonymous, $sitekey;
$ba_config = baget_configs();
// Banner Client Login
if (is_baclient($baclient)) {
  $cltname = addslashes( $bacookie[1] );
  $content .= _BA_WEL.", <b>$cltname</b>.<br />(<a href=\"modules.php?name=$modname&amp;op=BALogout\">"._BA_LOGOUT."</a>)\n";
  $content .= "<hr noshade size='1'>\n";
  $sql = "SELECT `cid` FROM `".TABLE_NSNBA_CLIENTS."` WHERE `login`='$cltname'";
  if ( !($result = $GLOBALS['db']->sql_query($sql)) )
{ query_die(BLOCK_ERROR, 'Could not obtain _nsnba_clients', '', __LINE__, __FILE__, $sql);}
  $row = $GLOBALS['db']->sql_fetchrow($result);
  $cid = $GLOBALS['db']->XMFnum($row['cid']);
  $sql1 = "SELECT `cid` FROM `".TABLE_NSNBA_BANNERS."` WHERE `cid`='$cid' AND `active`='1'";
  if ( !($result1 = $GLOBALS['db']->sql_query($sql1)) )
{ query_die(BLOCK_ERROR, 'Could not obtain _nsnba_banners', '', __LINE__, __FILE__, $sql1);}
  $actban = $GLOBALS['db']->sql_numrows($result1);
  $sql2 = "SELECT `cid` FROM `".TABLE_NSNBA_BANNERS."` WHERE `cid`='$cid' AND `active`='0'";
  if ( !($result2 = $GLOBALS['db']->sql_query($sql2)) )
{ query_die(BLOCK_ERROR, 'Could not obtain _nsnba_banners', '', __LINE__, __FILE__, $sql2);}
  $expban = $GLOBALS['db']->sql_numrows($result2);
  $sql3 = "SELECT `cid` FROM `".TABLE_NSNBA_BANNERS."` WHERE `cid`='$cid' AND `active`='-1'";
  if ( !($result3 = $GLOBALS['db']->sql_query($sql3)) )
{ query_die(BLOCK_ERROR, 'Could not obtain _nsnba_banners', '', __LINE__, __FILE__, $sql3);}
  $penban = $GLOBALS['db']->sql_numrows($result3);
  $totban = $actban + $expban + $penban;
  $content .= "<b><a href=\"modules.php?name=$modname\">"._BA_BANS."</a>:</b><br />\n";
  $content .= "<big><b>&middot;</b></big> "._BA_PEN.": <b>$penban</b><br />\n";
  $content .= "<big><b>&middot;</b></big> "._BA_ACT.": <b>$actban</b><br />\n";
  $content .= "<big><b>&middot;</b></big> "._BA_INA.": <b>$expban</b><br />\n";
  $content .= "<big><b>&middot;</b></big> "._BA_TOT.": <b>$totban</b><br />\n";
  $GLOBALS['db']->sql_freeresult($result);$GLOBALS['db']->sql_freeresult($result1);$GLOBALS['db']->sql_freeresult($result2);$GLOBALS['db']->sql_freeresult($result3);
} else {
  mt_srand ((double)microtime()*1000000);
  $maxran = 1000000;
  $random_num = mt_rand(0, $maxran);
  $content .= _BA_WEL.", <b>$anonymous</b>.<br />\n";
  $content .= "<hr noshade size='1' />\n";
  $content .= "<table border='0' cellpadding='0' cellspacing='0'>\n";
  $content .= "<tr><form action=\"modules.php?name=$modname\" method=\"post\">\n";
  $content .= "<td>"._BA_CLTID.": <input type=\"text\" name=\"login\" size=\"12\" maxlength=\"25\" /><br />\n";
  $content .= _BA_PASS.": <input type=\"password\" name=\"pass\" size=\"12\" maxlength=\"10\" /><br />\n";
  if (extension_loaded("gd") AND ($ba_config['usegfxcheck'] == 2 OR $ba_config['usegfxcheck'] == 3)) {
    $content .=""._BA_SECCODE.": <img src=\"modules.php?name=$modname&amp;op=BAgfx&amp;random_num=$random_num\" border=\"1\" height=\"20\" width=\"80\" alt=\""._BA_SECCODE."\" title=\""._BA_SECCODE."\" /><br />\n";
    $content .=""._BA_TYPECODE.": <input type=\"text\" name=\"gfx_check\" size=\"10\" maxlenght=\"8\" /><br />\n";
    $content .="<input type=\"hidden\" name=\"random_num\" value=\"$random_num\" />\n";
  }
  $content .= "<input type=\"hidden\" name=\"op\" value=\"BALogin\" />\n";
  $content .= "<input type=\"submit\" value=\"".strtoupper(_BA_LOGIN)."\" /> (<a href=\"modules.php?name=$modname&amp;op=BAClientNew\">"._BA_REGS."</a>)</td>\n";
  $content .= "</form></tr>\n";
  $content .= "</table>\n";
}