#!/usr/bin/perl


########################################################
#                                                      #
# Gestdb v1.0 by Michela Fontana                       #
# Website : http://www.calzatura.com                   #
# Created : 15/10/2001                                 #
#                                                      #
########################################################

############   ADJUST THESE VARIABLES   ################

        use CGI;
        use DBI;

# Get the form variables

	if ($ENV{'REQUEST_METHOD'} eq 'GET') {
        	$buffer = $ENV{'QUERY_STRING'};
	}	
	else {
        	read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
	}

# Break em up into a format the script can read

	@pairs = split(/&/, $buffer);
	foreach $pair (@pairs) {
        	($name, $value) = split(/=/, $pair);
        	$value =~ tr/+/ /;
        	$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
        	$FORM{$name} = $value;
	}

$id = $FORM{'id'};

print "Content-type: text/html\n\n";

##################################################################################

# Open DB connection
$dbh = DBI->connect("DBI:mysql:calzatura_com_calzatura:mysql.register.it", GS1219_CALZATURA, michela);
if (!dbh) { print "Errore!"; }


($id, $titoloita, $titoloeng, $titolospa,
$redita, $redeng, $redspa, 
$fotoA, $fotoB, $fotoC, $fotoD,
$tit1ita, $tit1eng, $tit1spa,
$tit2ita, $tit2eng, $tit2spa,
$tit3ita, $tit3eng, $tit3spa,
$tit4ita, $tit4eng, $tit4spa,
$azienda, $imgazienda,
$rivista, $imgrivista, $numrivista, $datarivista,
$user, $password, $datains) = $dbh->selectrow_array("SELECT 
    ID, TITOLOITA, TITOLOENG, TITOLOSPA,
    REDITA, REDENG, REDSPA,
    FOTOA, FOTOB, FOTOC, FOTOD,
    TIT1ITA, TIT1ENG, TIT1SPA,
    TIT2ITA, TIT2ENG, TIT2SPA,
    TIT3ITA, TIT3ENG, TIT3SPA,
    TIT4ITA, TIT4ENG, TIT4SPA,
    AZIENDA, IMGAZIENDA,
    RIVISTA, IMGRIVISTA, NUMRIVISTA, DATARIVISTA,
    USER, PASSWORD, DATAINS
                          FROM Redazionali
                          WHERE ID='$id'");
$i = $currentline;
$trovato = 'no';
$ident = '';



($ragionesociale,$indirizzo,$cap,$citta,$provincia,$nazione,$mail,$imgragione) = $dbh->selectrow_array("SELECT RAGIONESOCIALE,INDIRIZZO,CAP,CITTA,PROVINCIA,NAZIONE,MAIL,IMMAGINE FROM Base WHERE ID='$azienda'");
($nomenazione,$imgnazione) = $dbh->selectrow_array("SELECT NAZIONE,IMMAGINE FROM Nazioni WHERE ID='$nazione'");

$fotourlA='http://www.calzatura.com/cgi/redazionali/'.$fotoA;
$fotourlB='http://www.calzatura.com/cgi/redazionali/'.$fotoB;
$fotourlC='http://www.calzatura.com/cgi/redazionali/'.$fotoC;
$fotourlD='http://www.calzatura.com/cgi/redazionali/'.$fotoD;

print "<body bgcolor=#CCCCCC>
<table border=0 cellpadding=0 cellspacing=3 width=100%>
  <tr>
    <td width=15% valign=middle><p align=left><img src=$imgragione width=120 height=60 alt='$ragionesociale' border=0></td>
    <td width=85% bgcolor=#808080 valign=middle><p align=center><font face=Verdana color=#FFFFFF><strong>$ragionesociale</strong></font></td>
  </tr>
</table>

<table border=0 width=100%>
  <tr>
    <td width=50%>

      <table border=0 cellpadding=3 cellspacing=0 width=100% height=100%>
        <tr>
          <td width=15% bgcolor=#CDDEFD valign=top><font face=Verdana color=#000080><small><small><strong>A</strong>zienda:</small></small></font></td>
          <td width=60% bgcolor=#CDDEFD valign=top><font face=Verdana color=#000080><small><small><strong>$ragionesociale</strong><br>
          $indirizzo<br>
          $cap $citta ($provincia)<br>
          $nomenazione</small></small></font></td>
          <td width=25% bgcolor=#CDDEFD>
          <form method=POST action=contatta.cgi>
          <input type=hidden name=mail value=$mail>
          <input type=hidden name=azienda value='$azienda'>
          <input type=hidden name=id value='$id'>
          <div align=center><center><p><input type=submit value=Contatta name=B1 style='background-color: rgb(255,255,255); border: thin solid rgb(0,0,128)'></p></center></div></td>
          </form>
        </tr>
      </table></td>

     <td width=50%>

       <table border=0 cellpadding=3 cellspacing=3 width=100%>
         <tr>
           <td width=30% bgcolor=#CDDEFD><p align=center><font face=Verdana color=#000080><small><small><strong>";

if ($rivista eq 'Ars Arpel') {
print "P</strong>ubblicato su:<br><a href=http://www.calzatura.com/web/arsarpel/index.htm target=_blank><img src=http://www.calzatura.com/cgi/riviste/arpel.jpg width=70 height=35 alt='$rivista' border=0></a>";
}

if ($rivista eq 'Ars Sutoria') {
print "P</strong>ubblicato su:<br><a href=http://www.calzatura.com/web/arsarpel/index.htm target=_blank><img src=http://www.calzatura.com/cgi/riviste/ars.jpg width=70 height=35 alt='$rivista' border=0></a>";
}

if ($rivista eq 'Fotoshoe') {
print "P</strong>ubblicato su:<br><img src=http://www.calzatura.com/cgi/riviste/fotoshoe.jpg width=70 height=35 alt='$rivista' border=0>";
}

if ($rivista eq 'International Technology') {
print "P</strong>ubblicato su:<br><a href=http://www.calzatura.com/web/internationaltechnology/index.htm target=_blank><img src=http://www.calzatura.com/cgi/riviste/it.jpg width=70 height=35 alt='$rivista' border=0></a>";
}

if ($rivista eq 'Leather International') {
print "P</strong>ubblicato su:<br><img src=http://www.calzatura.com/cgi/riviste/leather.jpg width=70 height=35 border=0>";
}

if ($rivista eq 'Serma') {
print "P</strong>ubblicato su:<br><a href=http://www.serma.net target=_blank><img src=http://www.calzatura.com/cgi/riviste/serma.jpg width=70 height=35 alt='$rivista' border=0></a>";
}

if ($rivista eq 'Shoe Intelligence') {
print "P</strong>ubblicato su:<br><a href=http://www.calzatura.com/web/shoeintelligence/index.htm target=_blank><img src=http://www.calzatura.com/cgi/riviste/shoeintelligence.jpg width=70 height=35 alt=$rivista' border=0></a>";
}

print "</small></small></font></td>
       <td width=70% bgcolor=#CDDEFD valign=middle><font face=Verdana color=#000080><small><small><strong>";

if ($rivista ne '') {
print "$rivista</strong><br>";
}

if ($numrivista ne '') {
print "N° &nbsp;&nbsp; $numrivista &nbsp;&nbsp; ";
}

@vardata = split(/-/,$datarivista);

if ($datarivista ne '0000-00-00') {
print "&nbsp; Del &nbsp; $vardata[1] $vardata[0]";
}

print "</small></small></font></td>
     </tr>
   </table></td>
</tr>
</table>
<div align=center>

<table border=0 cellpadding=3 cellspacing=3 width=100%>
  <tr>
    <td width=100% bgcolor=#000080><p align=center><font face=Verdana color=#ffffff><small><strong>$titoloita</small></font></td>
  </tr>
</table>
<div align=center><center>";

if ($fotoA ne '') {

print "<table border=0 cellpadding=3 cellspacing=0 width=100%>
  <tr>
    <td valign=top width=178><div align=center><center><table border=0 cellpadding=0
    cellspacing=0 width=100% height=150>
      <tr>
        <td bgcolor=#CDDEFD height=1><small><small><small><small><small><small>
        &nbsp;&nbsp;&nbsp;&nbsp; </small></small></small></small></small></small></td>
        <td bgcolor=#CDDEFD height=1></td>
        <td bgcolor=#CDDEFD height=1><small><small><small><small><small><small>
        &nbsp;&nbsp;&nbsp;&nbsp; </small></small></small></small></small></small></td>
      </tr>
      <tr>
        <td bgcolor=#CDDEFD height=106 width=1></td>
        <td bgcolor=#95B9FB height=150 width=150 valign=middle><p align=center><img
        src=$fotourlA width=150 height=150 alt='$tit1ita'></td>
        <td bgcolor=#CDDEFD height=106></td>
      </tr>
      <tr>
        <td bgcolor=#CDDEFD height=1><small><small><small><small><small><small>&nbsp;</small></small></small></small></small></small></td>
        <td bgcolor=#CDDEFD height=1><font face=Verdana size=1 color=#000080>$tit1ita</font></td>
        <td bgcolor=#CDDEFD height=1><small><small><small><small><small><small></small></small></small></small></small></small></td>
      </tr>
    </table>";
}

print "</center></div><p align=left><br>
    <br>
    <br>
    </p>
    <div align=center><center>";

if ($fotoB ne '') {
print "<table border=0 cellpadding=0 cellspacing=0 width=100%
    height=150>
      <tr>
        <td bgcolor=#CDDEFD height=1><small><small><small><small><small><small>
        &nbsp;&nbsp;&nbsp;&nbsp; </small></small></small></small></small></small></td>
        <td bgcolor=#CDDEFD height=1></td>
        <td bgcolor=#CDDEFD height=1><small><small><small><small><small><small>
        &nbsp;&nbsp;&nbsp;&nbsp; </small></small></small></small></small></small></td>
      </tr>
      <tr>
        <td bgcolor=#CDDEFD height=106 width=1></td>
        <td bgcolor=#95B9FB height=150 width=150 valign=middle><p align=center><img
        src=$fotourlB width=150 height=150 alt='$tit2ita'></td>
        <td bgcolor=#CDDEFD height=106></td>
      </tr>
      <tr>
        <td bgcolor=#CDDEFD height=1><small><small><small><small><small><small>&nbsp;</small></small></small></small></small></small></td>
        <td bgcolor=#CDDEFD height=1><font face=Verdana size=1 color=#000080>$tit2ita</font></td>
        <td bgcolor=#CDDEFD height=1><small><small><small><small><small><small></small></small></small></small></small></small></td>
      </tr>
    </table>";
}

print "</center></div></td>
    <td width=448 valign=top><font face=Verdana size=2 color=#000080>$redita</font></td>
    <td width=149 valign=top><div align=center><center>";

if ($fotoC ne '') {
print "<table border=0 cellpadding=0
    cellspacing=0 width=100% height=150>
      <tr>
        <td bgcolor=#CDDEFD height=1><small><small><small><small><small><small>
        &nbsp;&nbsp;&nbsp;&nbsp; </small></small></small></small></small></small></td>
        <td bgcolor=#CDDEFD height=1></td>
        <td bgcolor=#CDDEFD height=1><small><small><small><small><small><small>
        &nbsp;&nbsp;&nbsp;&nbsp; </small></small></small></small></small></small></td>
      </tr>
      <tr>
        <td bgcolor=#CDDEFD height=106 width=1></td>
        <td bgcolor=#95B9FB height=150 width=150 valign=middle><p align=center><img
        src=$fotourlC width=150 height=150 alt='$tit3ita'></td>
        <td bgcolor=#CDDEFD height=106></td>
      </tr>
      <tr>
        <td bgcolor=#CDDEFD height=1><small><small><small><small><small><small>&nbsp;</small></small></small></small></small></small></td>
        <td bgcolor=#CDDEFD height=1><font face=Verdana size=1 color=#000080>$tit3ita</font></td>
        <td bgcolor=#CDDEFD height=1><small><small><small><small><small><small></small></small></small></small></small></small></td>
      </tr>
    </table>";
}

print "</center></div><p align=right><br>
    <br>
    <br>
    </p>
    <div align=center><center>";

if ($fotoD ne '') {
print "<table border=0 cellpadding=0 cellspacing=0 width=100%
    height=150>
      <tr>
        <td bgcolor=#CDDEFD height=1><small><small><small><small><small><small>
        &nbsp;&nbsp;&nbsp;&nbsp; </small></small></small></small></small></small></td>
        <td bgcolor=#CDDEFD height=1></td>
        <td bgcolor=#CDDEFD height=1><small><small><small><small><small><small>
        &nbsp;&nbsp;&nbsp;&nbsp; </small></small></small></small></small></small></td>
      </tr>
      <tr>
        <td bgcolor=#CDDEFD height=106 width=1></td>
        <td bgcolor=#95B9FB height=150 width=150 valign=middle><p align=center><img
        src=$fotourlD width=150 height=150 alt='$tit4ita'></td>
        <td bgcolor=#CDDEFD height=106></td>
      </tr>
      <tr>
        <td bgcolor=#CDDEFD height=1><small><small><small><small><small><small>&nbsp;</small></small></small></small></small></small></td>
        <td bgcolor=#CDDEFD height=1><font face=Verdana size=1 color=#000080>$tit4ita</font></td>
        <td bgcolor=#CDDEFD height=1><small><small><small><small><small><small></small></small></small></small></small></small></td>
      </tr>
    </table>";
}

print "</center></div></td>
  </tr>
</table>
</center></div>";


print "<hr><p align=center><font FACE=arial,helvetica size=1 color=#FF0000><a
HREF=http://www.calzatura.com target=_top>Calzatura</a></font><font
FACE=arial,helvetica COLOR=000000 size=1> E-Mail: <a
href=mailto:info\@calzatura.com>info\@calzatura.com</a><br>
All Rights Reserved.</font></p>";

$dbh->disconnect;

exit;

##################################################################################


sub error {    
	$noshow = 1;
	print "<CENTER><FONT $font><h2>File Access Error</h2><P><B>You have an error in your PATH configuration variables in the $ENV{'SCRIPT_NAME'} file.</B><P>Your server reports that your BASE path is : $ENV{'DOCUMENT_ROOT'}<BR>Note that this is reported as your BASE path, not the FULL path to your files.<P>If you require help installing this script please consider purchasing the professional version of this script. Your purchase includes full tech support and installation.<P><B>Get it at : <A HREF=http://www.getperl.com/easysearch/>http://www.getperl.com/easysearch/</A></B></FONT></CENTER><P>\n";
	&footer;
}
