<?php
/*
#****************************************************************************#
# Ultimate Locator                                                              #
# Professional Zip Code Locator Systems          support@ultimatelocator.com #
# Copyright 2004 PageSkills.com Internet Services    www.ultimatelocator.com #
# Release Date: 2/01/2004                                                    #
#                                                                            #
#   Ultimate Locator is protected by the copyright                           #
#   laws and international copyright treaties, as well as other              #
#   intellectual property laws and treaties.                                 #
#   Distribution without approved license is illegal and is                  #
#   punishable by law.                                                       #
#                                                                            #
#   A license is good toward one domain only.  You must purchase             #
#   additional licenses if you wish to install this software on              #
#   additional domains (websites). We do offer Reseller Packages.            #
#****************************************************************************#
*/

require_once("admin/config.php");

$fp=fopen("$user_path/printresult.htm","r");
$str=fread($fp,filesize("$user_path/printresult.htm"));

$st=explode("{##}",$str);

$query="Select * from location where id='$id'";
$data=mysql_query($query,$zip_connection);
$str1="";

$query="Select hide as h1 from setfield";
$data1=mysql_query($query,$zip_connection);

        if(mysql_result($data,0,"name")!="" && mysql_result($data1,0,"h1")==0)
        {
        $str1.=$st[1];
        $str1=str_replace("{nameonly}",mysql_result($data,0,"name"),$str1);
        }


        if(mysql_result($data,0,"address1")!="" && mysql_result($data1,1,"h1")==0)
        {
        $str1.=$st[1];
        $str1=str_replace("{nameonly}",mysql_result($data,0,"address1"),$str1);
        }

        if(mysql_result($data,0,"address2")!="" && mysql_result($data1,1,"h1")==0)
        {
        $str1.=$st[1];
        $str1=str_replace("{nameonly}",mysql_result($data,0,"address2"),$str1);
        }

        if(mysql_result($data,0,"city")!="" && mysql_result($data1,2,"h1")==0)
        {
        $scity=mysql_result($data,0,"city");
        }

        if(mysql_result($data,0,"state")!="" && mysql_result($data1,3,"h1")==0)
        {
        $sstate=mysql_result($data,0,"state");
        }

        if(mysql_result($data,0,"country")!="" && mysql_result($data1,4,"h1")==0)
        {
        $scountry=mysql_result($data,0,"country");
        }

        if(mysql_result($data,0,"zip")!="" && mysql_result($data1,5,"h1")==0)
        {
        $szip=mysql_result($data,0,"zip");
        }

        if(isset($scity) || isset($sstate) || isset($scountry) || isset($szip))
        {

                        if(!isset($scity))
                        {
                        $scity="";
                        }
                        if(!isset($sstate))
                        {
                        $sstate="";
                        }
                        if(!isset($scountry))
                        {
                        $scountry="";
                        }
                        if(!isset($szip))
                        {
                        $szip="";
                        }

        $str1.=$st[1];
        $str1=str_replace("{nameonly}","$scity "."$sstate "."$scountry "."$szip ",$str1);
        }



        if(mysql_result($data,0,"telephone")!="" && mysql_result($data1,6,"h1")==0)
        {
        $str1.=str_replace("{labelname}","Telephone:",$st[2]);
        $str1=str_replace("{name}",mysql_result($data,0,"telephone"),$str1);
        }

        if(mysql_result($data,0,"fax")!="" && mysql_result($data1,7,"h1")==0)
        {
        $str1.=str_replace("{labelname}","Fax:",$st[2]);
        $str1=str_replace("{name}",mysql_result($data,0,"fax"),$str1);
        }

        if(mysql_result($data,0,"email")!="" && mysql_result($data1,8,"h1")==0)
        {
        $str1.=str_replace("{labelname}","Email:",$st[2]);
        $str1=str_replace("{name}","<a href=\"mailto:".mysql_result($data,0,"email")."\">".mysql_result($data,0,"email")."</a>",$str1);
        }

        if(mysql_result($data,0,"website")!="" && mysql_result($data1,9,"h1")==0)
        {
                if($website_link_target==0)
                {
                $target="";
                }
                if($website_link_target==1)
                {
                $target="_blank";
                }

        $str1.=str_replace("{labelname}","Website:",$st[2]);
        $str1=str_replace("{name}","<a href=\"http://".mysql_result($data,0,"website")."\" target=\"$target\">"."http://".mysql_result($data,0,"website")."</a>",$str1);
        }


        if($users1!="" && mysql_result($data,0,"user1")!="" && mysql_result($data1,10,"h1")==0)
        {
        $str1.=str_replace("{labelname}",$users1,$st[2]);
        $str1=str_replace("{name}",mysql_result($data,0,"user1"),$str1);
        }

        if($users2!="" && mysql_result($data,0,"user2")!="" && mysql_result($data1,11,"h1")==0)
        {
        $str1.=str_replace("{labelname}",$users2,$st[2]);
        $str1=str_replace("{name}",mysql_result($data,0,"user2"),$str1);
        }

        if($users3!="" && mysql_result($data,0,"user3")!="" && mysql_result($data1,12,"h1")==0)
        {
        $str1.=str_replace("{labelname}",$users3,$st[2]);
        $str1=str_replace("{name}",mysql_result($data,0,"user3"),$str1);
        }

        if($users4!="" && mysql_result($data,0,"user4")!="" && mysql_result($data1,13,"h1")==0)
        {
        $str1.=str_replace("{labelname}",$users4,$st[2]);
        $str1=str_replace("{name}",mysql_result($data,0,"user4"),$str1);
        }

        if($users5!="" && mysql_result($data,0,"user5")!="" && mysql_result($data1,14,"h1")==0)
        {
        $str1.=str_replace("{labelname}",$users5,$st[2]);
        $str1=str_replace("{name}",mysql_result($data,0,"user5"),$str1);
        }

$str1=$st[0].$str1.$st[3];

        if(!isset($dist))
        {
        $dist="";
        }
$str1=str_replace("{distance}",$dist,$str1);
$str1=str_replace("{images}",$image_path,$str1);
$str1=str_replace("{headtext}",$headtext,$str1);

echo $str1;

?>