<?
require("config.php");
include("funcs1.php");
if ($flattchext!=""){include("flattch.php");}
$msgs_fl="msg1_".$intlang.".php"; require("$msgs_fl");

$dstnem=$_REQUEST['dstnem'];

foreach ($categories as $key => $value){
if ($key!="evntcl" and  $key!="evcl_rpl")
{$ms22=split("_",$key); if ($ms22[0]== 'title'){$ttlvl=$categories[$key];} else
{$categories[$key][0]=$ttlvl.": ".$categories[$key][0];}}}

if ($md=="logout") {  logout();}

connect_to_db(); 

if (($HTTP_GET_VARS['ammlk'] !="") and ($admpassw1==""))
{$admpassw1=$HTTP_GET_VARS['ammlk'];
$admcookpassw=$HTTP_GET_VARS['ammlk'];
}

if ($md=="print_menu") 
{
if($admpassw1 != $adm_passw) {
if ($ammlk != $adm_passw){
$inc_passw="incorrect password !"; 
printpasswordform($inc_passw);
exit;
}
}

setcookie("admcookpassw", $admpassw1);
print_menu();
exit;
}

if($admcookpassw != $adm_passw){
if ($admcookpassw != ""){
$inc_passw= "Incorrect password or cookies does not work"; 
}
printpasswordform($inc_passw);
exit;
}

if ($md=="") print_menu();
if ($md=="create_db") create_db();
if ($md=="create_tb") create_tb();
if ($md=="replcad") {replcad($_REQUEST['adid']);}
if ($md=="sql_tb") print_sql_tb();
if ($md=="moderate") {include("funcs2.php"); moderate(); }
if ($md=="adm_delete") {include("funcs2.php"); adm_delete();}
if ($md=="make_ads_visible") make_ads_visible();
if ($md=="make_ads_unvisible") make_ads_unvisible();
if ($md=="admrate_ads") admrate_ads();
if ($md=="getemails") getemails($ct);
if ($md=="spmwform") {include("spamgrd.php"); spmwform();}
if ($md=="spmwsave") {include("spamgrd.php"); spmwsave();}
if ($md=="spamadsdel") {include("funcs2.php"); include("spamgrd.php"); spamadsdel();}
if ($md=="csvform") {include("csvld.php"); csvform();}
if ($md=="inputcsv") {include("csvld.php"); inputcsv();}

if ($md=="submdeltad") {include("funcs2.php"); submdeltad();}
if ($md=="brdllist") { include("funcs2.php"); brdllist();}


function replcad($adid)
{
global  $table_ads, $ct;
 
$sql_query="update $table_ads set catname='$ct' where idnum=$adid";

if (@mysql_query("$sql_query")){

$message="
<font FACE='ARIAL, HELVETICA' size='-1'>
<b>
<a href='index.php?md=details&id=$adid'>Ad (id# $adid)</a> has been moved successfully !
</b></font>
";
}

else{
$message="
<font FACE='ARIAL, HELVETICA' size='-1'>
<b>
Incorrect query !
</b></font>
";
}
 
admin_message($message);
exit;
}



function brdllist()
{
global $HTTP_POST_VARS, $table_ads, $categories, $html_footer, $html_header;


echo"
<html><body bgcolor='#ffffff'>
<font FACE='ARIAL, HELVETICA' size='-1'>
<b><a href='admin.php'>Top:</a></b> Browse/Delete Ads List
</font>
<p> 
";
$sql_query="select * from $table_ads where visible=1
order by idnum desc limit ".$HTTP_POST_VARS['lads']." ";

$sql_res=mysql_query("$sql_query");

echo "
<form action='admin.php?md=submdeltad' method='post'>
<font FACE='ARIAL, HELVETICA' size='-1' color='#000088'>
";

while ($row = mysql_fetch_array ($sql_res))
{
$idnum=$row['idnum'];
$time1=$row['time'];
$date_posted=get_date($time1); 
$catname=$row['catname'];
if ($row['adphotos']=='yes'){$phvl1="<font color='#bb0000' size=-2>pic</font>";}else{$phvl1="";} 
echo "<p>
<font size='-2'><b>
(<input type='checkbox' name='delad[]' value='$idnum'>delete
<a href='index.php?md=editform&ed_id=$idnum' target='_blank'>edit</a>)</b></font> &nbsp 
<a href='index.php?md=details&id=$idnum' target='_blank'><b>".$row['title']."</a></b> $phvl1
&nbsp;-&nbsp; <font size='-2'><b> #$idnum, $date_posted; ".$categories[$catname][0].",
".$row['email'].", ".$row['ipaddr1']." ".$row['login'].".</b> </font>";  
}  
 
echo "<p>
<input type='submit' value='Delete checked ads'></form> 
</font>
</body></html>
";
exit;

}



function submdeltad()
{
global $HTTP_POST_VARS, $table_ads;
$array_id=get_array_id($list_id);

$admss=$HTTP_POST_VARS['submad'];
if ($admss!=""){
foreach ($admss  as $value)
{
$sql_query="update $table_ads set visible=1 where idnum=$value";
mysql_query("$sql_query");
}

}


$admss=$HTTP_POST_VARS['delad'];
if ($admss!=""){
foreach ($admss as $value)
{
delete_photos($value);
$sql_query="delete from $table_ads where idnum=$value";
mysql_query("$sql_query");
 
}
}

$message="
<font FACE='ARIAL, HELVETICA' size='-1'>
<b>
Query has been processed successfully !
</b></font>
"; 
admin_message($message);
exit;
}
 
 
function getemails($ct)
{
global  $table_ads, $categories, $html_footer, $html_header, $dstnem;

$cattitle11=$categories[$ct][0];
if ($ct==""){$cattitle11="all";}
echo "
<html>
<body bgcolor='#ffffff'>
";
echo "
<p>
<font FACE='ARIAL, HELVETICA' size='-1'>
<a href='admin.php'>Home:</a> <br>
<b> E-mail List. Category: <font color='#000099'>$cattitle11 </font>
 </b><p> ";
 if ($dstnem==""){
echo"
<font size='-2'><b>(Click on the link to see ad with this email)</b>
</font>
<p>
";
}
if ($dstnem==""){
echo "<a href='admin.php?md=getemails&ct=$ct&dstnem=1'>
print list without duplicating e-mails</a><p>"; 
}
$sellct1="idnum, email";
if ($dstnem=="1"){ $sellct1="distinct email";}
$whrecat11="catname='$ct' and";
if ($ct==""){$whrecat11="";}
$sql_query="select $sellct1 from $table_ads where $whrecat11 visible=1
order by email";
$sql_res=mysql_query("$sql_query");
$email1112="0";
if ($dstnem==""){
while ($row = mysql_fetch_array ($sql_res))
{
$email1112="1";
if ($row['email']!=""){
echo "
<a href='index.php?ct=$ct&md=details&id=".$row['idnum']."'>
".$row['email']."</a> <br>
";
}
}
}
else
{

while ($row = mysql_fetch_array ($sql_res))
{
$email1112="1";
if ($row['email']!=""){
echo $row['email']."<br>";
}
}
}

if ($email1112=="0")
{echo "<p><font color='#aa0000'>No ads in this category</font>";}
echo "</font> <p>";
echo "
</body>
</html>
";
exit;
}

function make_ads_visible()
{
global $list_id, $table_ads;
$array_id=get_array_id($list_id);
foreach ($array_id as $value)
{
$sql_query="update $table_ads set visible=1 where idnum=$value";
mysql_query("$sql_query");
}
$message="
<font FACE='ARIAL, HELVETICA' size='-1'>
<b>
Submitted ads have been replaced to the ads index
</b></font>
"; 
admin_message($message);
exit;
}
 

function admrate_ads()
{
global $list_id, $table_ads, $ads_rt;
$array_id=get_array_id($list_id);

if ($ads_rt==0){$ads_rt="NULL";}

foreach ($array_id as $value)
{
$sql_query="update $table_ads set adrate=$ads_rt where idnum=$value";
mysql_query("$sql_query");
}
$message="
<font FACE='ARIAL, HELVETICA' size='-1'>
<b>
Submitted ads have been rated !
</b></font>
"; 
admin_message($message);
exit;
}

function make_ads_unvisible()
{
global $list_id, $table_ads;
$array_id=get_array_id($list_id);
foreach ($array_id as $value)
{
$sql_query="update $table_ads set visible=2 where idnum=$value";
mysql_query("$sql_query");
}

$message="
<font FACE='ARIAL, HELVETICA' size='-1'>
<b>
Submitted ads have been replaced to the invisible folder
</b></font>
"; 
admin_message($message);
exit;
}

function adm_delete()
{
global $list_id, $table_ads;
$array_id=get_array_id($list_id);
foreach ($array_id as $value)
{
delete_photos($value);
$sql_query="delete from $table_ads where idnum=$value";
mysql_query("$sql_query");
 
}
$message=
"<font FACE='ARIAL, HELVETICA'> <center>
<b> Ads have been deleted succesfully </b>
</center>
</font>
";
admin_message($message);
exit;
}

function logout()
{
setcookie("admcookpassw", "0");
printpasswordform("Log out Ok !");
exit;
} 

function get_moder_num($vis)
{
global $cat_fields, $table_ads,  $page, $adsonpage ; 
$sql_query="select count(idnum) from $table_ads where 
visible=$vis";
$sql_res=mysql_query("$sql_query");
$row=mysql_fetch_row($sql_res);
$count=$row[0];
return $count;
}

function moderate()
{
global $cat_fields, $table_ads,  $page, $adsonpage, $vis, $html_header,
$html_footer; 

if ($vis=="0") $mode_text="new posted ads";
if ($vis=="2") $mode_text="univisible ads";
if ($vis=="3") $mode_text="ads edited by users";

 
$count=get_moder_num($vis);
echo $html_header;
echo"
<table width='650' >
<tr><td>
<font FACE='ARIAL, HELVETICA' size='-1'>
<b><a href='admin.php'>Top:</b>
</font>
</td></tr></table>
<table width='650' bgcolor='#dddddd'>
<tr><td>
<font FACE='ARIAL, HELVETICA'>
<b>Browsing $mode_text</b>
</font>
</td></tr></table>
";
echo"
 <table width='650' bgcolor='#eeeeee'>
<tr><td>
<font FACE='ARIAL, HELVETICA' size='-1'>
Pages:".moder_pages_list($count)."
</td></tr></table>
</center><p>
";

echo get_moder_ads();
echo $html_footer;
exit;
}

 
function get_moder_ads()
{
global $cat_fields, $gener_fields, $specific_fields, 
$table_ads, $ct, $page,$adsonpage, $vis, $ads_fields; 

$html_ads="";
$start_num=($page-1)*$adsonpage; 
if($page=="")$start_num=0;
$sql_query="select * from $table_ads where visible=$vis
order by idnum desc limit $start_num, $adsonpage";
 $sql_res=mysql_query("$sql_query");
$html_ads=$html_ads."<p>";

$html_ads=$html_ads."
<form action='admin.php?md=submdeltad' method='post'>
";

$key22="";

while ($row = mysql_fetch_array ($sql_res))
{$key22="1";
$html_ads=$html_ads.print_moder_ad($row);
}
 
if ($key22==""){$html_ads=$html_ads."<p><font FACE='ARIAL, HELVETICA' size=-1>No ads in this folder</font><p>";}

 
$html_ads=$html_ads."
<input type='submit' value='Submit'></form> 
";
return $html_ads;
}

function print_moder_ad ($row)
{
global $cat_fields, $photos_count, $all_fields, $photo_path,$photo_url,
$previewphoto_path,$prphotolimits,$pr_lim_width,$pr_lim_height,
$previewphoto_url,  $select_text, $real_format, $ads_fields, $categories;

$html_ad="
<table width='650' bgcolor='#eeeeee'><tr><td>
<font FACE='ARIAL, HELVETICA' size=-1>
";
$idnum=$row['idnum'];

$time1=$row['time'];
$date_posted=get_date($time1); 
$catname=$row['catname'];
if ($row['login']!="")
{
$html_ad=$html_ad."member:  
<a href='index.php?md=browse&mblogin=".$row['login']."&visunvis=1'><b>
".$row['login']."</b></a><br>";
}
$html_ad=$html_ad."Category: <b>".$categories[$catname][0]."</b><br>";
$html_ad=$html_ad."id: $idnum; Date posted: $date_posted<br>";
foreach ($ads_fields as $key => $value) 
{
if (($row[$key]!="") and
($row[$key]!=$select_text) and ($row[$key]!='http://')
and ($row[$key]!='NULL') and ($row[$key]!='null'))
{
if ($all_fields[$key][6]=='real') {$row[$key]=sprintf($real_format, $row[$key]);}
$html_ad=$html_ad."
<font color='#000099'>".$ads_fields[$key][0]."</font> : $row[$key] <br>
";
}
}

get_jpg_path($idnum);

$html_ad=$html_ad."<br>";

for($i=1; $i<=$photos_count; $i++)
{
 if (file_exists($photo_path[$i])){
$html_ad=$html_ad."&nbsp; <a href='$photo_url[$i]'><img src='sph.php?id=$idnum&wd=60&np=$i' border=0></a>";
}
}
 
 

$html_ad=$html_ad.print_multimed1($idnum,$row);

$html_ad=$html_ad."<br>
<a href='index.php?md=editform&ed_id=$idnum' target='edit$idnum'>
<font size='-2'><b>Edit this ad </a>
&nbsp;&nbsp; 
Submit ad<input type='checkbox' name='submad[]' value='$idnum'>
&nbsp;&nbsp; 
Delete ad<input type='checkbox' name='delad[]' value='$idnum'>
</b></font>
</td></tr></table><p>";
return $html_ad;
}
 
function print_multimed1($idnum,$row)
{
global $incl_mtmdfile,$multimedia_path, $multimedia_url, $multim_link, $msg;
$mm_link="";  
if ($incl_mtmdfile=='yes')
{
get_att_path($idnum);

if (file_exists($multimedia_path)) 
{
$attflsz1=round(filesize($multimedia_path)/1000);
if ($attflsz1==0){$attflsz1=1;}
$mm_link="
<p><li>".$msg['multimedia_file'].": 
<a href='$multimedia_url'><b>".$row['attfltl']." (".$row['attflext'].", ".$attflsz1."Kb)</b></a></li>
";
 
}

if (($row['flsrvur1']!="") and ($row['flsrvur1']!="http://")){
$mm_link=$mm_link."<p><b>
<li><a href='".$row['flsrvur1']."' target='_blank'>".$row['flsrvtl1']."</a></li>
</b>";
}

if (($row['flsrvur2']!="") and ($row['flsrvur2']!="http://")){
$mm_link=$mm_link."<p><b>
<li><a href='".$row['flsrvur2']."' target='_blank'>".$row['flsrvtl2']."</a></li>
</b>";
}
if ($row['embdcod']!=""){
$embdcode=ereg_replace('<', '&#060;', $row['embdcod']);
$embdcode=ereg_replace('>', '&#062;', $embdcode);
$mm_link=$mm_link."<p> Embeded code: $embdcode" ;
}
}

global $dsplhltpht;
if (($dsplhltpht=="yes") and (($row['adrate'] < 1) or ($row['adrate']==""))){$mm_link="";}
 
return  $mm_link;
}



function moder_pages_list($ads_count)
{
global $adsonpage, $ct, $page, $vis;

$num_pages=($ads_count-$ads_count%$adsonpage)/$adsonpage;
if ($ads_count%$adsonpage > 0) {$num_pages++;}
$list_pages="";
for ($i = 1; $i <= $num_pages; $i++) 
{
if ($i != $page){
$list_pages=$list_pages."[<a href='admin.php?md=moderate&vis=$vis&page=$i'>$i</a>]";
}
else
{
$list_pages=$list_pages."[$i]";
}
}
return $list_pages;
}

function  printpasswordform($inc_passw)
{
global $html_header, $html_footer;

echo $html_header; 
echo "

<table width='100%' bgcolor='#dddddd' border=0 cellspacing=0 cellpadding=1>
<tr><td> 
<font FACE='ARIAL, HELVETICA' >
<b> Admin Interface </b>
</font>
</td></tr></table>
<p>
<font FACE='ARIAL, HELVETICA' COLOR='#990000'  >
<b> $inc_passw </b>
</font>
<p>
<form action='admin.php?md=print_menu' method='post'>
<font FACE='ARIAL, HELVETICA' COLOR='#000099' size='-1'>
<b>
Input admin password : </b></font>
<input type='password' name='admpassw1'>
<input type='submit' value='Submit'>
</form>
<font FACE='ARIAL, HELVETICA' COLOR='#000099' size='-2'>
<br><b>(Cookies must be set up)
 </b></font>
 
<p>
</center>
";
echo $html_footer;
exit;
}

function print_menu()
{
global $html_header, $html_footer, $db_name, $table_ads, 
$moderating, $categories, $use_spmg;
echo $html_header;
echo "<center>
<p>
<table width='100%' bgcolor='#dddddd' border=0 cellspacing=0 cellpadding=1>
<tr><td> 
<font FACE='ARIAL, HELVETICA' >
&nbsp; <b> Admin Interface </b> 
</font>
</td></tr></table>
<p>

<table width='950'  border=0 cellspacing=0 cellpadding=1>
<tr><td width='50%' valign='top'>
 
<table width='450'  border=0 cellspacing=0 cellpadding=1>
<tr><td> 
<font FACE='ARIAL, HELVETICA' COLOR='#000099' size='-1'>
<b> 
<a href='admconf.php' >Setting Options</a> &nbsp; &nbsp; &nbsp;
<a href='mbadm.php' >Membership Database</a>
</b>
</font>
</td></tr></table>
<p> 
<table width='450' bgcolor='#dddddd' border=0 cellspacing=0 cellpadding=1>
<tr><td> 
<font FACE='ARIAL, HELVETICA' size=-1>
<b>Browse Moderated Folders</b>
</font></td></tr><tr><td>
<TABLE   bgcolor='#ffffff' border='0' cellspacing=0 cellpadding=0 WIDTH='100%' >
<tr><td> 
<font FACE='ARIAL, HELVETICA' size='-1' color='#000088'>
<a href='admin.php?md=moderate&vis=0' >New Posted Ads</a> (".get_moder_num("0").")
<br><a href='admin.php?md=moderate&vis=3' >Ads Edited by Users</a> (".get_moder_num("3").")
<br><a href='admin.php?md=moderate&vis=2' >Invisible Ads</a> (".get_moder_num("2").")  
";
if ($use_spmg=="yes")
{
echo "
<br><a href='admin.php?md=moderate&vis=4' target='_blank'>Spam Ads</a> 
(".get_moder_num("4").") &nbsp;&nbsp;
  <a href='admin.php?md=spamadsdel'  >Delete Spam Ads</a> 
&nbsp;&nbsp;
<a href='admin.php?md=spmwform' target='_blank'>Edit Spam Words</a>
";
}
echo "
</font>
</td></tr></table>
</td></tr></table>
<p>
";

echo "
<table width='450' bgcolor='#dddddd' border=0 cellspacing=0 cellpadding=1>
<tr><td> 
<font FACE='ARIAL, HELVETICA' size=-1>
<b>Make Ads Visible/Invisible</b>
</font></td></tr><tr><td>
<TABLE   bgcolor='#ffffff' border='0' cellspacing=0 cellpadding=0 WIDTH='100%' >
<tr><td> 
<table><tr><td>
<form action='admin.php?md=make_ads_visible' method='post'>
<center>
<b> Ads ID#:
</b><input type='text' name='list_id'>
</td><td>
<input type='submit' value='Make Ads Visible'>
</form>
</td></tr><tr><td> 
<form action='admin.php?md=make_ads_unvisible' method='post'>
<center>
<b> Ads ID#:</b><input type='text' name='list_id'>
</td><td>
<input type='submit' value='Make Ads Invisible'>
</td></tr></table>
</form>

<font FACE='ARIAL, HELVETICA' size=-2><b>
separate by comma, e.g. if you input 12,22,34-37,40  then ads with the following id will be
submitted: 12,22,34,35,36,37,40 
</b></font>
</center>
 

</td></tr></table>
</td></tr></table>

<p>
<table width='450' bgcolor='#dddddd' border=0 cellspacing=0 cellpadding=1>
<tr><td> 
<font FACE='ARIAL, HELVETICA' size=-1>
<b>Delete Ads</b>
</font></td></tr><tr><td>
<TABLE   bgcolor='#ffffff' border='0' cellspacing=0 cellpadding=0 WIDTH='100%' >
<tr><td> 

<form action='admin.php?md=adm_delete' method='post'>
<center>
<b> Ads ID#:</b><input type='text' name='list_id'>
<input type='submit' value='Delete'>
</center>
<p><font FACE='ARIAL, HELVETICA' size=-2><b>
Separate by comma, e.g. if you input 12,22,34-37,40  then  ads with the following id will be
deleted: 12,22,34,35,36,37,40 
</b></font>
 
</form>

</td></tr></table>
</td></tr></table>

<p>
<table width='450' bgcolor='#dddddd' border=0 cellspacing=0 cellpadding=1>
<tr><td> 
<font FACE='ARIAL, HELVETICA' size=-1>
<b>Browse/Delete Ads List</b>
</font></td></tr><tr><td>
<TABLE   bgcolor='#ffffff' border='0' cellspacing=0 cellpadding=0 WIDTH='100%' >
<tr><td> 

<form action='admin.php?md=brdllist' method='post'>
<center>
<b> Browse last: <input type='text' name='lads' value='100' size='5'>ads</b>
<input type='submit' value='Submit'>
</center>
 
 
</form>

</td></tr></table>
</td></tr></table>

</td><td width='50%' valign='top'>
<table width='450' bgcolor='#dddddd' border=0 cellspacing=0 cellpadding=1>
<tr><td> 
<font FACE='ARIAL, HELVETICA' size=-1>
<b>Rate Ads:</b>
</font></td></tr><tr><td>
<TABLE   bgcolor='#ffffff' border='0' cellspacing=0 cellpadding=0 WIDTH='100%' >
<tr><td> 

<form action='admin.php?md=admrate_ads' method='post'>
<center>
<b> Ads rate:</b><input type='text' name='ads_rt' size='3'>
<b> Ads ID#:</b><input type='text' name='list_id'>
<input type='submit' value='Rate'>
</center>
<p><font FACE='ARIAL, HELVETICA' size=-2><b>
Separate by comma, e.g. if you input 12,22,34-37,40  then  ads with the following id will be
rated: 12,22,34,35,36,37,40 
</b>
<br>
All ads with rate > 0 will be placed on the top of ads list
</font>
 
</form>

</td></tr></table>
</td></tr></table>

<p>
<table width='450' bgcolor='#dddddd' border=0 cellspacing=0 cellpadding=1>
<tr><td> 
<font FACE='ARIAL, HELVETICA' size=-1>
<b>Edit Ad</b>
</font></td></tr><tr><td>
<TABLE   bgcolor='#ffffff' border='0' cellspacing=0 cellpadding=0 WIDTH='100%' >
<tr><td> <center>
<form action='index.php?md=editform' method='post'>
<b>Ad ID#:</b><input type='text' name='ed_id'>
<input type='submit' value='Edit'>
</center>
</form>
</td></tr></table>
</td></tr></table>

<p>
<table width='450' bgcolor='#dddddd' border=0 cellspacing=0 cellpadding=1>
<tr><td> 
<font FACE='ARIAL, HELVETICA' size=-1>
<b>Uploading ads from *.csv file</b>
</font></td></tr><tr><td>
<TABLE   bgcolor='#ffffff' border='0' cellspacing=0 cellpadding=0 WIDTH='100%' >
<tr><td> <center>
<form action='admin.php' method='get'>
<input type='hidden' name='md' value='csvform'>
<select name='ct' size=1>
<option selected>Choose category
";
foreach ($categories as $key => $value)
{
$aa2=split("_",$key);
if($aa2[0] != 'title'){
echo "<option value='$key'>".$categories[$key][0];
}
}
echo "
</select>
<input type='submit' value='Submit'>
</center>
</form>
</td></tr></table>
</td></tr></table>


<p>
<table width='450' bgcolor='#dddddd' border=0 cellspacing=0 cellpadding=1>
<tr><td> 
<font FACE='ARIAL, HELVETICA' size=-1>
<b>Move Ad to other category</b>
</font></td></tr><tr><td>
<TABLE   bgcolor='#ffffff' border='0' cellspacing=0 cellpadding=0 WIDTH='100%' >
<tr><td> 
<form action='admin.php' method='get' target='_blank'>
<input type='hidden' name='md' value='replcad'>
<font FACE='ARIAL, HELVETICA' size=-1>
Ad with ID:
<input type='text' name='adid' size='3'>
move to: <br>
<select name='ct' size=1>
<option value='' selected>Choose category
";
foreach ($categories as $key => $value)
{
$aa2=split("_",$key);
if($aa2[0] != 'title'){
echo "<option value='$key'>".$categories[$key][0];
}
}
echo "
</select>
<input type='submit' value='Submit'>
</center>
</form>
</td></tr></table>
</td></tr></table>



<p>
<table width='450' bgcolor='#dddddd' border=0 cellspacing=0 cellpadding=1>
<tr><td> 
<font FACE='ARIAL, HELVETICA' size=-1>
<b>Print E-Mail Lists</b>
</font></td></tr><tr><td>
<TABLE   bgcolor='#ffffff' border='0' cellspacing=0 cellpadding=0 WIDTH='100%' >
<tr><td> 

<form action='admin.php' method='get' target='_blank'>
<input type='hidden' name='md' value='getemails'>
<select name='ct' size=1>
<option value='' selected>All Categories
";
foreach ($categories as $key => $value)
{
$aa2=split("_",$key);
if($aa2[0] != 'title'){
echo "<option value='$key'>".$categories[$key][0];
}
}
echo "
</select>
<input type='submit' value='Submit'>
</center>
</form>
 
</td></tr></table>
</td></tr></table>

</td></tr></table>
<p>
<TABLE   bgcolor='#ffffff' border='0' cellspacing=0 cellpadding=0 WIDTH='100%' >
<font FACE='ARIAL, HELVETICA' size=-1>
<p> <a href='admin.php?md=logout'>Log Out</a> 
</font>
</td></tr></table>
<p>";
echo $html_footer;
exit;
}

function print_cat_name2($key)
{
global $categories;
echo "
<nobr><a href='admin.php?ct=$key&md=getemails'>".$categories[$key][0]."</a></nobr>&nbsp;&nbsp;
"; 
}

function get_array_id($string_id)
{
$i=0;
$string1=split(",",$string_id);
foreach ($string1 as $value1)
{
$string2=split("-", $value1);
if ($string2[1]!="")
{
for ($j=$string2[0];$j<=$string2[1];$j++)
{$array_id[$i]=$j; $i++;}
}
else{$array_id[$i]=$value1; $i++;}
}
return $array_id;
}

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