Location: PHPKode > scripts > Amailer > amailer/login.php
<?
include "commono_db.php";
include "confi.php";


function sorry() {
global $rec, $result, $times, $time, $user_tablename, $hm;

$result = mysql_query("SELECT * FROM admin");
while($rec = mysql_fetch_array($result)) {
$trys = $rec['try'];
}

if($trys > 5) {
die("<h1> Sorry </h1><br>
<b> Your have tried more then 6 times to enter your password/username, please wait untill 2 hours untill you can try again to login.<br>
Thank you --");

  }
  
}

$result = mysql_query("SELECT * FROM admin");
while($rec = mysql_fetch_array($result)) {
$trys = $rec['try'];
$times = $rec['time'];
}

if($time != $times) {
$result = mysql_query("UPDATE admin ". "SET try = '0', time = '0'" . "WHERE id='1'");
}

sorry();



$exclude_dirs = array('/', '/images');
$exclude_files = array('index.php', 'mysql.php', 'log.php', 'confi.php', 'admin.php', 'ver.php',
                       'commono_db.php', 'mysqlinfo.php', 'setup.php', 'howtouse.html');
$user_tablename = 'admin';

function login_form() {
   global $PHP_SELF;
?>
<p>&nbsp;</p>
<p>&nbsp;</p>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
  <tr>
    <td width="100%">
    <p align="center"><font face="Courier"><b>Admin Login:</b></font></td>
  </tr>
</table>
<form method="POST" action="<?=$PHP_SELF?>">
 <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
    <tr>
      <td width="32%">&nbsp;</td>
      <td width="11%"><font size="2" face="Courier New">Username:</font></td>
      <td width="60%"><font size="2">
      <input type="text" name="userid" size="20" style="font-family: Courier New; font-size: 8pt; border: 1px solid #FFFFFF; background-color: #C0C0C0"> </font></td>
    </tr>
    <tr>
      <td width="32%">&nbsp;</td>
      <td width="11%"><font size="2" face="Courier New">Password:</font></td>
      <td width="60%"><font size="2">
      <input type="password" name="userpassword" size="20" style="font-family: Courier New; font-size: 8pt; border: 1px solid #FFFFFF; background-color: #C0C0C0"></font></td>
    </tr>
  </table>
  <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
    <tr>
      <td width="43%">&nbsp;</td>
      <td width="11%">
      <input type="submit" value="Submit" name="B3" style="font-family: Courier New; font-size: 8pt; border: 1px solid #FFFFFF; background-color: #C0C0C0"></td>
      <td width="46%">
      <input type="reset" value="Reset" name="B4" style="font-family: Courier New; font-size: 8pt; border: 1px solid #FFFFFF; background-color: #C0C0C0"></td>
    </tr>
  </table>
</form>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
  <tr>
    <td width="100%">
    <p align="center"><font face="Courier" size="2">You have only 5 tries to 
    login.</font></td>
  </tr>
</table>

<?
}

function do_authentication() {
global $PHP_ATUH_USER, $PHP_AUTH_PW, $PHP_SELF;
global $userid, $userpassword, $register_script;
global $default_dbname, $user_tablename;
global $MYSQL_ERROR, $MYSQL_ERRON, $trys, $try;
global $check, $time;

if(!isset($userid)) {
   login_form();
   exit;
}
else session_register("userid", "userpassword");
$query = "SELECT admin_username FROM $user_tablename
          WHERE  admin_username = '$userid'
		  AND admin_password = '$userpassword'";
$result = mysql_query($query);

if(!mysql_num_rows($result)) {
   session_unregister("userid");
   session_unregister("userpassword");
   echo "Authorization failed. " . 
   "Click on the following link to try again,<BR>\n";
   echo "<a href=\"$PHP_SELF\" style=\"text-decoration: none\"><font color=\"#071378\">Login</font></a><br>";

$result = mysql_query("SELECT * FROM admin");
while($rec = mysql_fetch_array($result)) {
$try = $rec['try'];
}
$trys = $try + 1;
$result = mysql_query("UPDATE $user_tablename ". "SET try= '$trys', time = '$time'" . "WHERE id='1'");
echo "Number of tries: $trys";
$result = mysql_query("SELECT * FROM admin");
while($rec = mysql_fetch_array($result)) {
$trys = $rec['try'];
}

if($trys > 5) {
header("Location: login.php?module=sorry");
}  
   exit;
 }
}
$filepath = dirname($PHP_SELF);
$filename = basename($PHP_SELF);

if($filepath == '') $filepath = '/';

$auth_done = 0;

for($j=0; $j < count($exclude_dirs); $j++) {
   if($exclude_dirs[$j] == $filepath) break;
   else {
      for($i=0; $i < count($exclude_files); $i++) {
	     if($exclude_files[$i] == $filename) break;
		 else {
		   session_start();
		   do_authentication();
		   $auth_done = 1;
		   break;
		  }
		 }
		}
		if($auth_done) break;
	}
if(isset($module)) {

function logout() {
global $userpassword, $userid, $PHP_SELF, $check;

if($check == "yes") {
   session_unregister("userid");
   session_unregister("userpassword");
   
echo "<p align=\"center\"><b>You have successfully logged out</b></p>";
echo "<p align=\"center\"><a href=\"index.php\" style=\"text-decoration: none\">";
echo "<font color=\"#071378\">Please click here to return to AMAILER.</font></a></p>";
} else {
echo "<h2>UNKNOWN URL</h2>";
 }
}



switch($module) {
case "logout":
logout();
break;
case "sorry":
sorry();
break;
 }
}
?>
Return current item: Amailer