<?
require("mb_conf.php");
require("config.php");
require("mb_fn1.php");
require("mb_subm.php");
$msgs_fl="msg1_".$intlang.".php"; require("$msgs_fl");
$msgs_fl="msg2_".$intlang.".php"; require("$msgs_fl");

foreach ($mbfld_lst as $mbfld11)
{ 
$cat_fields[$mbfld11]=$mb_fields[$mbfld11];
}

start();

if ($md=='mbactivate'){mb_activate();}

if ($md=="") {mb_form();}
if ($md=="submitmb"){submit_mb();}

function mb_form()
{
global $subscr_url, $html_header, $html_footer, $cat_fields, $fields_val, $ct, 
$photos_count, $ed_id, $ed_passw, $exp_period, $rightform_html, 
$select_text, $categories, $phptomaxsize, $incl_prevphoto, $prviewphotomax,
 $prphotolimits, $pr_lim_height, $pr_lim_width, $incl_mtmdfile, $multim_link,
$multim_ext, $mtmdfile_maxs, $ad_ind_width,
$tbclr_1, $tbclr_2, $tbclr_3, $tbclr_4, $fntclr_1, $msg, $msg2;

 
$time1=time();
$date_posted=get_date($time1); 
 
echo $html_header;

$tbl_col=$tbclr_4;
$td_height='10';

echo "
<p>
<center> 
<table  ><tr><td valign='top'>

<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; <font size='+1'>
<a href='index.php?ct=$ct'>".$categories[$ct][0]."
</b></a> 
</font> </font>
<hr size='1'>
<font FACE='ARIAL, HELVETICA' COLOR='#000099' size='-1'>
<b>".$msg2['membship_subscr']."</b> </font>

<form action='$subscr_url?md=submitmb' method='post' >
<table   width='550' border=0 bgcolor='$tbclr_2' cellspacing=1 cellpadding=0>
<tr><td>
<font FACE='ARIAL, HELVETICA' COLOR='$tbclr_4' size='-1'>
<b> ".$msg2['fill_out_the_form']."</b>
</font>
<table width='100%' border=0 cellspacing=1 cellpadding=1>
<tr>
<td bgcolor='$tbl_col' height='$td_height' width='30%' >
<font FACE='ARIAL, HELVETICA' COLOR='#000099' size='-1'> 
".$msg2['Date_Posted_m'].":          
</font>
</td><td bgcolor='$tbl_col' width='70%'>
<font FACE='ARIAL, HELVETICA' COLOR='#000099' size='-1'>
 &nbsp; $date_posted  
</font>
</td></tr>
";



foreach ($cat_fields as $key => $value )
{
if (ereg ('url',$key))
{
if ($fields_val[$key]==""){$fields_val[$key]="http://";}
}

if ($cat_fields[$key][5] == '1')
{$cat_fields[$key][0]=$cat_fields[$key][0]."<font color='#cc0000'>* </font>";}

if ($cat_fields[$key][4] == 'select')
{
$aa4=split(':',$cat_fields[$key][3]);
$t_size=$aa4[0];
$t_max=$aa4[1];
echo "
<tr>
<td height='$td_height' bgcolor='$tbl_col' >
<font FACE='ARIAL, HELVETICA' COLOR='#000099' size='-1'>
".$cat_fields[$key][0].":
</font>
</td><td bgcolor='$tbl_col'>
<select name='$key' size='$t_size' class=formst>
 <option>$select_text<checked>
".$cat_fields[$key][7]."</select></td></tr>
";
}

if ($cat_fields[$key][4] == 'checkbox')
{
$aa5=split('<option>',$cat_fields[$key][7]);
echo "
<tr>
<td height='$td_height' bgcolor='$tbl_col' >
<font FACE='ARIAL, HELVETICA' COLOR='#000099' size='-1'>
".$cat_fields[$key][0].":
</font>
</td><td bgcolor='$tbl_col'>
";
$i_aa5=0;
foreach ($aa5 as $value1)
{
$i_aa5++;
if ($value1!=""){
$namechbx=$key.$i_aa5;
echo " 
<input type='checkbox' name='$namechbx' value='$value1' $fields_val[$namechbx]> $value1 <br>
";
}
}
echo "</select></td></tr>";
}


if ($cat_fields[$key][4] == 'text'){
$aa4=split(':',$cat_fields[$key][3]);
$t_size=$aa4[0];
$t_max=$aa4[1];
echo "
<tr>
<td height='$td_height' bgcolor='$tbl_col' >
<font FACE='ARIAL, HELVETICA' COLOR='#000099' size='-1'>
".$cat_fields[$key][0].":
</font>
</td><td bgcolor='$tbl_col'>
";
 
echo "
<input type='text' name='$key' size='$t_size' value='".$fields_val[$key]."' maxlength='$t_max' class=formst>
</td></tr>
";
 
}
if ($cat_fields[$key][4] == 'textarea'){
$aa4=split(':',$cat_fields[$key][3]);
$t_rows=$aa4[1];
$t_cols=$aa4[0];
$t_max=$aa4[2];
echo "
<tr>
<td height='$td_height' bgcolor='$tbl_col' >
<font FACE='ARIAL, HELVETICA' COLOR='#000099' size='-1'>
".$cat_fields[$key][0].":
<br><font size='-2' color='#aaaaaa'> ".$msg2['not_more_then']." 
 $t_max ".$msg2['chars_ms']."</font>
</font>
</td><td bgcolor='$tbl_col'>
";
if (($cat_fields[$key][7]!="") and ($ed_add=='submitad'))
{
echo "
<b>
<font FACE='ARIAL, HELVETICA' COLOR='#000099' size='-2'>
".$msg2['Delete_unnecessary_options'].":<br>
</b>
</font>
";
 $fields_val[$key]=$cat_fields[$key][7];
}
echo "
<textarea name='$key'   rows='$t_rows' cols='$t_cols' maxsize='$t_max' class=formst>".$fields_val[$key]."</textarea>
</td></tr>
";
}
}
 
echo "
</td></tr>
</table></td></tr>
</table>
<font FACE='ARIAL, HELVETICA' color='#000000'  size='-2'>
<b>".$msg2['fields_marked_ms']."
</b></font>
<p>
";

global $usevrfcode;
if ($usevrfcode=="yes"){include_once("vrfuncs.php"); echo vrchtml();}

echo "
<font FACE='ARIAL, HELVETICA' color='#000000'  size='-1'><b>
<input type='submit' value='".$msg2['Submit_ms']."' class=formst></b></font>
<hr size='1'>
<input type='hidden' name='ed_id' value='$ed_id'>
<input type='hidden' name='ed_passw' value='$ed_passw'>
</form>
</td><td valign='top'>
$rightform_html   
</td></tr></table> </center>
$html_footer
";

}

function submit_mb()
{
global $db_entry, $visible_val, $cat_fields, $email, $HTTP_POST_VARS;
global $photo_url, $photo_path, $id_count, 
$userfile, $userfile_name, $sndadmnotif,
$photos_url, $photos_path, $photos_count, $moderating, $ad_idnum, $memb_acc_act;

global $usevrfcode;
if ($usevrfcode=="yes"){include_once("vrfuncs.php");ch_vrcode();}

check_login_info($HTTP_POST_VARS['login']); 

check_fields();

if ($memb_acc_act=="0")
{$visible_val="1";}
else
{$visible_val="0";}

$idnum=get_idnum();
 
$sql_query=add_sql_entry($idnum);
mysql_query("$sql_query");

if ($sndadmnotif=="yes"){include("mb_admml.php"); mbeml_to_adm($idnum);}
 
print_subm_mb($ad_idnum);
exit;
}



function print_subm_mb($ad_idnum)
{
global $cat_fields, $photos_count, $html_header, $html_footer, $id,$HTTP_POST_VARS, $idnum1,
$ct, $categories, $ad_second_width, $left_width_sp, $exp_period, $incl_prevphoto,
$prphotolimits, $pr_lim_width, $pr_lim_height, $previewphoto_path, $previewphoto_url,
$moderating, $savepherr, $memb_acc_act,
$tbclr_1, $tbclr_2, $tbclr_3, $tbclr_4, $fntclr_1, $crcrdprocss, $msg, $msg2;

$sdtpcol="#ffffff";
$sdtpcol1="#ffcccc";

 $row=get_edit_info($ad_idnum);

$time1=$row['time'];
$date_posted=get_date($time1); 

$time22=$row['exptime'];
$date_expp=get_date($time22); 
 
$idnum1=$row['idnum'];

 

if ($memb_acc_act=='0') 
{ $info11="
".$msg2['Thanks_for_subscribing']."
";
}

if ($memb_acc_act=='e')
{
send_act_ms();
$info11="
".$msg2['thanks_activate_3days']."
";
}

if ($memb_acc_act=='a') 
{ $info11="
".$msg2['thanks_activated_asap']."
";
}


if ($memb_acc_act=='c') 
{ 
setcookie('cook_login', $HTTP_POST_VARS['login']);
setcookie('cook_passw', $HTTP_POST_VARS['passw']);
$info11="
 ".$msg2['Thanks_for_subscribing_2']."<p>
<a href='$crcrdprocss'>".$msg2['click_here_to_activate']."
 
";
}
 
echo $html_header;
echo "
<center><table width='500'><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]."</a>
</b> 
</font> 
<hr size='1'>
<center>
<font FACE='ARIAL, HELVETICA' COLOR='#000099' > 
<b> $info11 </b></font>
</center><p>
";

echo "
<table width='100%' bgcolor='$tbclr_1' border=0 cellspacing=3 cellpadding=3>
<tr>
<td bgcolor='$tbclr_1'>
<font FACE='ARIAL, HELVETICA' color='#000088' size='-1'>
  &nbsp; <b>".$msg2['Your_membership_info'].":</b></font>
</td>
</tr>
</table>
<table width='100%'  bgcolor='$tbclr_4' cellspacing=5 cellpadding=5>
<tr><td>
<font size=-1>
<font color='#007700' >&nbsp;&nbsp;# : </font><font color='#aa0000'>
".$row['idnum']."
</font>; 
&nbsp;
<font color='#007700' >  ".$msg2['Date_Posted_m'].": </font> <font color='#aa0000' >
 $date_posted </font>;
&nbsp;
<font color='#007700' >  ".$msg2['Expire_date_m'].": </font> <font color='#aa0000' >
 $date_expp </font>;
 
<table width='100%'  border=0 bordercolor='#ffffff' cellspacing=3 cellpadding=0>
";

$sdtpcol=$tbclr_4;
foreach ( $cat_fields as $key => $value )
{
echo "
<tr><td colspan='2' height='1' bgcolor='$sdtpcol1'><spacer type='block' height='1' width='1'></td></tr>
<tr><td bgcolor='$sdtpcol' width='40%'>
<font FACE='ARIAL, HELVETICA' COLOR='#000088' size='-1'>
&nbsp; ".$cat_fields[$key][0].":</font>
</td><td bgcolor='$sdtpcol' width='60%'>
<font FACE='ARIAL, HELVETICA' COLOR='BLACK' size='-1'>
 ".$row[$key]." &nbsp; </td></tr>
";
}

echo "
<tr><td colspan='2' height='1' bgcolor='$sdtpcol1'><spacer type='block' height='1' width='1'></td></tr>
</table></td></tr></table>
";

echo "
<p>
<center>
<font FACE='ARIAL, HELVETICA' COLOR='#000088' size='-1'>
 
</font>
</center>
<p>
";

echo  "
<hr size='1'>
</tr></td></table>
";

echo $html_footer;

exit;
}

function send_act_ms()
{
global $HTTP_POST_VARS, $subscr_url, $welc_mb_email, $act_mb_subj, $adm_email, $idnum1;

$pss1=$HTTP_POST_VARS['passw'];
$pss2=crypt($pss1, 'aa');
$pss2=ereg_replace('&', '', $pss2);

$memb_act_link=$subscr_url."?md=mbactivate&id=$idnum1&ps1=$pss1&ps2=$pss2";

$welc_mb_email=ereg_replace('!--member_name--!',$HTTP_POST_VARS['contact_name'],$welc_mb_email);
$welc_mb_email=ereg_replace('!--member_login--!',$HTTP_POST_VARS['login'],$welc_mb_email);
$welc_mb_email=ereg_replace('!--member_password--!',$HTTP_POST_VARS['passw'],$welc_mb_email);
$welc_mb_email=ereg_replace('!--memb_act_link--!', $memb_act_link,$welc_mb_email);

sndmail1($HTTP_POST_VARS['email'], $act_mb_subj, $welc_mb_email, $adm_email);
}

function sndmail1($ml_to, $ml_subj, $ml_info, $ml_from)
{
mail($ml_to, $ml_subj, $ml_info, "From: $ml_from");
}

function sndmail1_bak($ml_to, $ml_subj, $ml_info, $ml_from)
{
echo "
<br>
<br>To : $ml_to
<br>From: $ml_from
<br>Subject: $ml_subj
<br>Info: $ml_info
";
}

function mb_activate()
{
global $table_mb, $html_header, $html_footer, $md, $id, $ps1, $ps2, $msg, $msg2;

$pss2=crypt($ps1,'aa');
$pss2=ereg_replace('&', '', $pss2);

if ($ps2!=$pss2)
{
echo $html_header;
echo "
<center> <font FACE='ARIAL, HELVETICA' COLOR='#000099' font size='+1'>
<b> ".$msg2['Incorrect_activating']." </b>
</font>
</center>
";
echo $html_footer;
exit;
}

$sql_query="update $table_mb set visible=1 where  idnum=$id ";
mysql_query("$sql_query");

echo $html_header;
echo "
<center> <font FACE='ARIAL, HELVETICA' COLOR='#000099' font size='+1'>
".$msg2['mb_act_successfully']."
</font>
</center>
";
echo $html_footer;
exit;
}

?>