<?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                                 */
/************************************************************************/
/********************************************************/
/* NSN Banner Ads                                       */
/* By: NukeScripts Network (webmaster@nukescripts.net)  */
/* http://www.nukescripts.net                           */
/* Copyright © 2000-2005 by NukeScripts Network         */
/********************************************************/

$pagetitle = ": "._BA_TITLE." - "._BA_CLTPASMAIL;
if(!is_baclient($baclient)) {
  $cname = baclear_text($cname);
  $code = baclear_text($code);
  $result = $db->sql_query("SELECT `email`, `passwd` FROM `".TABLE_NSNBA_CLIENTS."` WHERE `login`='$cname'");
  $numrows = $db->sql_numrows($result);
  incoh();
  if($numrows == 0) {
    title(_BA_CLTNOCLT);
    Max_OpenTable();
    echo "<center>"._BA_NOINFO."</center>";
    Max_CloseTable();
  } else {
    $host_name = $_SERVER['REMOTE_ADDR'];
    if(isset($nsnst_const)) { $host_name = $nsnst_const['remote_ip']; }
    $result = $db->sql_query("SELECT `email`, `passwd` FROM `".TABLE_NSNBA_CLIENTS."` WHERE `login`='$cname'");
    list ($email, $pass) = $db->sql_fetchrow($result);
    $areyou = substr($pass, 0, 10);
    if($areyou==$code) {
      $newpass=BAPass();
      $message = _BA_CLTACC." '$cname' "._BA_AT." $sitename "._BA_CLTACC2." $host_name "._BA_CLTACC3.": $newpass\n\n "._BA_CLTACC4." $nukeurl/modules.php?name=$module_name\n\n"._BA_CLTACC5;
      $subject = _BA_CLTPASSFOR." $cname";
      if($email != "") {
        mail($email, $subject, $message, "From: $adminmail\nReturn-Path: $adminmail\nX-Mailer: PHP/" . phpversion());
      }
      $cryptpass = md5($newpass);
      $query = "UPDATE `".TABLE_NSNBA_CLIENTS."` SET `passwd`='$cryptpass' WHERE `login`='$cname'";
      if(!$db->sql_query($query)) {
        title(_BA_CLTDBERR);
        Max_OpenTable();
        echo _BA_CONTADMN;
        echo "<center>"._GOBACK."</center>";
        Max_CloseTable();
      } elseif($email=="") {
        title(_BA_ERR_INVEML);
        Max_OpenTable();
        echo _BA_CONTADMN2;
        echo "<center>"._GOBACK."</center>";
        Max_CloseTable();
      } else {
        title(_BA_CLTPASMAIL);
        Max_OpenTable();
        echo "<center>"._BA_MAILPASS." $cname.</center>";
        echo "<center>"._GOBACK."</center>";
        Max_CloseTable();
      }
    } else {
      $host_name = $_SERVER['REMOTE_ADDR'];
      if(isset($nsnst_const)) { $host_name = $nsnst_const['remote_ip']; }
      $result = $db->sql_query("SELECT `email`, `passwd` FROM `".TABLE_NSNBA_CLIENTS."` WHERE `login`='$cname'");
      list ($email, $pass) = $db->sql_fetchrow($result);
      $areyou = substr($pass, 0, 10);
      $message =  _BA_CLTACC." '$cname' "._BA_AT." $sitename "._BA_CLTACC2." $host_name "._BA_CLTACC6.": $areyou \n\n"._BA_CLTACC7." $nukeurl/modules.php?name=$module_name&op=BAClientPassLost\n"._BA_CLTACC8;
      $subject= _BA_CLTCODEFOR." $cname";
      if($email != "") {
        mail($email, $subject, $message, "From: $adminmail\nReturn-Path: $adminmail\nX-Mailer: PHP/" . phpversion());
      }
      title(_BA_CLTCODMAIL);
      Max_OpenTable();
      echo "<center>"._BA_MAILCODE." $cname</center><br />\n";
      echo "<center>"._GOBACK."</center>";
      Max_CloseTable();
    }
  }
  incof();
} else {
  redirect_url("modules.php?name=$module_name");
}

?>