<?
function mb_log_out()
{
global $cat_fields, $photos_count, $html_header, $html_footer, $id,
$ct, $categories, $ad_second_width, $left_width_sp, $exp_period, $msg, $msg2, $cook_login;
 
$cook_login=""; 
setcookie("cook_login");
setcookie("cook_passw");
$message="
<font FACE='ARIAL, HELVETICA' COLOR='#000099' size='+1'>
<b><center>
".$msg2['log_out_success']."
</center></b>
</font>
";
echo $html_header;
echo "
<center><table width='600'><tr><td>
<font FACE='ARIAL, HELVETICA' COLOR='BLACK'> <font size=-1>
<b><a href='index.php'>".$msg['top'].":</a></b></font>
&nbsp; 
<font FACE='ARIAL, HELVETICA' COLOR='#000099' size=-1> 
<b>&nbsp; 
<a href='index.php?ct=$ct'>".$categories[$ct][0]."
</b></a> 
</font> 
<hr size='1'><p>
$message
<p><hr size='1'>
</tr></td></table>
</center>
";
echo $html_footer;
exit;
}

function check_mb_login($md_type)
{
global $ct, $categories, $subscr_url, $cook_login, 
$cook_passw, $f_login, $f_passw, $table_mb, $ch_numtp,
$mb_checktime, $mb_max_nads, $crcrdprocss;
include("mb_conf.php");

if ($f_login!='')
{
$cook_login=$f_login; 
$cook_passw=$f_passw;
}

if ($cook_login==''){print_mb_logf($md_type,'');}
else {check_mb_logp($cook_login,$cook_passw,$md_type);}

setcookie("cook_login", $cook_login);
setcookie("cook_passw",$cook_passw);

if (($md_type=="add_form") and ($ch_numtp=="yes")){checknadtp($cook_login);}

}

function check_mb_logp($cook_login,$cook_passw,$md_type)
{
global $subscr_url, $cat_fields, $table_mb, $ct, $categories, 
$adm_passw, $ammlk, $html_header, $html_footer, $crcrdprocss, $msg2; 
 
$sql_query="select idnum, visible, exptime from $table_mb where 
login='$cook_login' and passw='$cook_passw' ";
$sql_res=mysql_query("$sql_query");
$row=mysql_fetch_array($sql_res);
if ($row['idnum']==""){$count1=0;} else {$count1=1;}

if (($cook_passw==$adm_passw) or ($ammlk==$adm_passw)){$count1=5;}

if ($count1 < 1)
{
$inc_passw="
<font FACE='ARIAL, HELVETICA' color='#880000'  >
<b>".$msg2['Incorrect_membership_nick']."</b>
</font>
";
print_mb_logf($md_type,$inc_passw);
}

if ($row['visible']=="0"){
setcookie("cook_login", $cook_login);
setcookie("cook_passw",$cook_passw);

$mssg1="
<font FACE='ARIAL, HELVETICA' color='#000088'  >
<b><font color='#880000'>".$msg2['your_mb_not_activated']."</font>
<p> <a href='$crcrdprocss'>".$msg2['click_here_to_activate']."
</b>
</font>
";
print_mb_inf($mssg1);

 

exit;
}

$time_now=time();
if ($row['exptime'] < $time_now){
setcookie("cook_login", $cook_login);
setcookie("cook_passw",$cook_passw);
$mssg1="
<font FACE='ARIAL, HELVETICA' color='#000088'  >
<b><font color='#880000'> ".$msg2['your_mb_acc_expired']."</font>
<br> <a href='$crcrdprocss'> ".$msg2['click_to_update']."
</font>
";
print_mb_inf($mssg1);
exit;
}
}

function checknadtp($cook_login)
{
global $cat_fields, $table_ads, $ct, $page, $adsonpage,
$html_header, $html_footer, $mb_checktime, $mb_max_nads, $categories, $msg, $msg2; 

$timech1=time() - $mb_checktime*86400;
$sql_query="select count(idnum) from $table_ads where
 login='$cook_login' and time > $timech1";
$sql_res=mysql_query("$sql_query");
$row=mysql_fetch_row($sql_res);
$count=$row[0];

if ($count >= $mb_max_nads)
{
$message="
<font FACE='ARIAL, HELVETICA' COLOR='#990000'>
<center><b>
".$msg2['exceeded_max_number']." ($mb_max_nads) ".$msg2['allowed_to_place_per']."
  ($mb_checktime days).
".$msg2['Try_again_later_1']."
<p>
<font size='-1' color='#000000'>
<a href='index.php?md=browse&mblogin=$cook_login&visunvis=1'>".$msg2['Click_to_see_ads']."
</font>
</b>
</center>
</font>
";

echo $html_header;
echo "
<center><table width='600'><tr><td>
<font FACE='ARIAL, HELVETICA' COLOR='BLACK'> <font size=-1>
<b><a href='index.php'> ".$msg['top'].":</a></b></font>
&nbsp; 
<font FACE='ARIAL, HELVETICA' COLOR='#000099' size=-1> 
<b>&nbsp; 
<a href='index.php?ct=$ct'>".$categories[$ct][0]."
</b></a> 
</font> 
<hr size='1'><p>
$message
<p><hr size='1'>
</tr></td></table>
</center>
";
echo $html_footer;
exit;
}
}

function print_mb_inf($mssg1)
{
global $subscr_url, $cook_login, $cook_passw, $html_header, $html_footer, $categories, $ct,
$tbclr_1, $tbclr_2, $tbclr_3, $tbclr_4, $fntclr_1, $msg;
echo $html_header;
echo "
<center>
<table width='500' bgcolor='$tbclr_4' border=0 cellspacing=1 cellpadding=0><tr>
  <td valign='top'>
 
<font FACE='ARIAL, HELVETICA' COLOR='BLACK'> <font size=-1>
<a href='index.php'>".$msg['top'].":</a> 
<b><a href='index.php?md=browse&ct=$ct'>".$categories[$ct][0]."</a></b>
</font> 
 <p>
<font FACE='ARIAL, HELVETICA' color='#000088'>
$mssg1
</font>
 </td></tr></table>
<p>
";
echo $html_footer;
exit;

}

function print_mb_logf($md_type,$mssg1)
{
global $subscr_url, $cook_login, $cook_passw, $html_header, $html_footer, $categories, $ct,
$tbclr_1, $tbclr_2, $tbclr_3, $tbclr_4, $fntclr_1, $msg, $msg2;
echo $html_header;
echo "
<center>
<table width='500' bgcolor='$tbclr_2' border=0 cellspacing=1 cellpadding=0><tr>
  <td valign='top'>
<TABLE WIDTH='100%'  border=0 BGCOLOR='$tbclr_4' cellspacing='1' cellpadding='10' > 
<tr>
<TD  VALIGN=TOP>
<font FACE='ARIAL, HELVETICA' COLOR='BLACK'> <font size=-1>
<a href='index.php'>".$msg['top'].":</a> 
<b><a href='index.php?md=browse&ct=$ct'>".$categories[$ct][0]."</a></b>
</font> 
<table width='100%' border=0 cellspacing=3 cellpadding=3>
<tr>
<td bgcolor='$tbclr_1'>
<font FACE='ARIAL, HELVETICA' color='#000088' size=+1>
&nbsp;&nbsp; <b>".$msg2['Membership_Area']."</b></font>
</td>
</tr>
</table>
<p>
<font FACE='ARIAL, HELVETICA' color='#000088' size=+1>
$mssg1
</font>
<p>
 
<form action='index.php?ct=$ct&md=$md_type' method='post'>
<table width='100%'>
<tr><td width='50%'>
<table>
<tr><td>
<font FACE='ARIAL, HELVETICA' color='#000088' size=-1>
<b>".$msg2['Nickname_mbe'].":</b>
</font>
</td><td>
<input type='text' name='f_login' size='15' value='$cook_login' class=formst>
</td></tr>
<tr><td>
<font FACE='ARIAL, HELVETICA' color='#000088' size=-1>
<b>".$msg2['Password_mbe'].":</b>
</font>
</td><td> 
<input type='password' name='f_passw' size='15' value='$cook_passw' class=formst>
</td></tr></table><font FACE='ARIAL, HELVETICA' color='#000088' size=-1><b>
<input type='submit' value='".$msg2['Submit_mbe']."' 
class=formst STYLE='FONT-WEIGHT: bold;'></b></font>
</form>

</td><td width='50%' valign='top'>
<center>
<font FACE='ARIAL, HELVETICA' color='#000088'  >
<b><a href='$subscr_url?ct=$ct' target='signupfrm'>".$msg2['Sign_Up_1']."</a></b>
<p>
<font size='-1'> 
<a href='index.php?md=forgmbpassw'>".$msg2['Forgot_mb_password']."</a>
<p> <a href='mbprf.php'>".$msg2['edit_your_profile']."</a>
</b></font>
</center>
</td></tr></table>

</td></tr></table>
</td></tr></table>
</center> 
<p>

";
echo $html_footer;
exit;
}

function forgot_mb_passw()
{
global $cat_fields, $photos_count, $html_header, $html_footer, $id,
$ct, $categories, $ad_second_width, $left_width_sp, $exp_period, $msg, $msg2;
 

$message="
<form action='index.php?ct=$ct&md=sendmbps' method='post'>
<font FACE='ARIAL, HELVETICA' COLOR='#000088' size='-1'>
".$msg2['inp_email_sent_pssw']." 
<input type='text' name='ps_email' size='15' class=formst>
 
<input type='hidden' name='ct' value='$ct'>
<input type='submit' value='Send Password'  class=formst STYLE='FONT-WEIGHT: bold;'>
</font>
</form>
";
 
echo $html_header;
echo "
<center><table width='600'><tr><td>
<font FACE='ARIAL, HELVETICA' COLOR='BLACK'> <font size=-1>
<b><a href='index.php'>".$msg['top'].":</a></b></font>
&nbsp; 
<font FACE='ARIAL, HELVETICA' COLOR='#000099'> 
<b>&nbsp; 
<a href='index.php?ct=$ct'>".$categories[$ct][0]."
</b></a> 
</font> 
<hr size='1'><p>
$message
<p><hr size='1'>
</tr></td></table>
</center>
";
echo $html_footer;
exit;
}

 

function send_mb_passw($ps_email)
{
global $cat_fields, $table_mb, $adm_email, $ct, $msg2;
 
 
$ps_email=check_email2($ps_email);
$sql_query="select count(idnum) from $table_mb where email='$ps_email' and visible=1";
 
$sql_res=mysql_query("$sql_query");
$row1=mysql_fetch_row($sql_res);
$count22=$row1[0];
$kll221="0";
if ($count22 > 0 )
{

$sql_query="select login, passw from $table_mb where email='$ps_email' and visible=1";
$sql_res=mysql_query("$sql_query");
 
 
while ($row = mysql_fetch_array ($sql_res))
{
 
$kll221="1";
$p_message="
Nickname: ".$row['login'].";
Password: ".$row['passw'].";
";
$p_subject="".$msg2['Your_mb_login']."";
 
mail($ps_email, $p_subject, $p_message, "From: $adm_email");
} 
}
 
if ($kll221=="0")
{
$info_message="
<center><font FACE='ARIAL, HELVETICA' COLOR='#000099' font size='+1'><b>
".$msg2['e_mail_mb']." <b> $ps_email </b> ".$msg2['not_found_mb_db']."
</b></center></font>
";
output_message2($info_message);
exit;
}

$info_message="
<center><font FACE='ARIAL, HELVETICA' COLOR='#000099' font size='+1'><b>
".$msg2['mb_lgpss_sent_to_email']."
</b></center></font>
";
output_message2($info_message);

exit;
}

function check_email2($email)
{
global $msg2;
$email=ereg_replace(' ', '', $email);
$a1=split('@', $email);
$a2=split('\.',$email);

if (($a1[0] == "") or ($a1[1] == "") or ($a2[0] == "") or ($a2[1] == ""))
{
$message="
<font FACE='ARIAL, HELVETICA' COLOR='#000000' >
<b> ".$msg2['e_mail_mb']." <font color='#AA0000'> $email</font> ".$msg2['has_incorr_format']." </b>  
 <font size='-1' color='#000088'>
<p> ".$msg2['use_back_button_r']."
</font></font>
";
output_message2($message);
exit;
}
return $email;
}


function output_message2($message)
{
global $cat_fields, $photos_count, $html_header, $html_footer, $id,
$ct, $categories, $ad_second_width, $left_width_sp, $exp_period, $msg;
echo $html_header;
echo "
<center><table width='600'><tr><td>
<font FACE='ARIAL, HELVETICA' COLOR='BLACK'> <font size=-1>
<b><a href='index.php'>".$msg['top'].":</a></b></font>
&nbsp; 
<font FACE='ARIAL, HELVETICA' COLOR='#000099'> 
<b>&nbsp; 
<a href='index.php?ct=$ct'>".$categories[$ct][0]."
</b></a> 
</font> 
<hr size='1'><p>
$message
<p><hr size='1'>
</tr></td></table>
</center>
";
echo $html_footer;
exit;
}

?>