<?php
$x = 1;
$self = basename($HTTP_SERVER_VARS['SCRIPT_NAME']);
$home = "index.php";

$querystr = isset($HTTP_SERVER_VARS['QUERY_STRING']) ? $HTTP_SERVER_VARS['QUERY_STRING'] : '';
$ref =isset($HTTP_SERVER_VARS['HTTP_REFERER']) ? (strpos($HTTP_SERVER_VARS['HTTP_REFERER'],".php") ? basename($HTTP_SERVER_VARS['HTTP_REFERER'],$querystr) : $home) : $home;
if (!isset($HTTP_COOKIE_VARS['eDenter_user']) || !isset($HTTP_COOKIE_VARS['eDenter_list'])) {

	if (isset($HTTP_GET_VARS['login']) && $HTTP_GET_VARS['login']=='ko') {
?>

		
<p><<4-nologin>></p>
<p><a href="javascript:history.back();" target="_self"><<4-indietro>></a></p>

<?php	
	}
	else {
		if (isset($HTTP_GET_VARS['action']) && $HTTP_GET_VARS['action']=="reg_new") {
?>
<form name="form1" method="post" action="logcheck.php">
        
  <table border="0" width="0" class="tabellalogin">
    <tr> 
      <td><b><<4-nomeutente>>: </b></td>
      <td align="right"> 
        <input type="text" name="user" maxlength="100">
      </td>
    </tr>
    <tr> 
      <td><b><<4-password>>: </b></td>
      <td align="right"> 
        <input type="password" name="pw" maxlength="100">
      </td>
    </tr>
    <tr> 
      <td><b><<4-pass_conf>>: </b></td>
      <td align="right"> 
        <input type="password" name="pw_conf" maxlength="100">
      </td>
    </tr>
    <tr> 
      <td><b><<4-ordine_nome>>: </b></td>
      <td align="right"> 
        <input type="text" name="full_name" maxlength="100">
      </td>
    </tr>
    <tr> 
      <td><<4-ordine_ragione_sociale>>: </td>
      <td align="right"> 
        <input type="text" name="corp" maxlength="100">
      </td>
    </tr>
    <tr> 
      <td><<4-ordine_partita_iva>>: </td>
      <td align="right"> 
        <input type="text" name="cf_piva" maxlength="100">
      </td>
    </tr>
    <tr> 
      <td><<4-ordine_indirizzo>>: </td>
      <td align="right"> 
        <input type="text" name="addr" maxlength="100">
      </td>
    </tr>
    <tr> 
      <td><<4-ordine_cap>>: </td>
      <td align="right"> 
        <input type="text" name="zip" maxlength="100">
      </td>
    </tr>
    <tr> 
      <td><<4-ordine_localita>>: </td>
      <td align="right"> 
        <input type="text" name="city" maxlength="100">
      </td>
    </tr>
    <tr> 
      <td colspan="2"> 
        <hr>
      </td>
    </tr>
    <tr> 
      <td colspan="2"> 
        <p><b><<4-ordine_spedizione>>:</b></p>
      </td>
    </tr>
    <tr> 
      <td><<4-ordine_denominazione>>: </td>
      <td align="right"> 
        <input type="text" name="del_name" maxlength="100">
      </td>
    </tr>
    <tr> 
      <td><<4-ordine_indirizzo>>: </td>
      <td align="right"> 
        <input type="text" name="del_addr" maxlength="100">
      </td>
    </tr>
    <tr> 
      <td><<4-ordine_cap>>: </td>
      <td align="right"> 
        <input type="text" name="del_zip" maxlength="100">
      </td>
    </tr>
    <tr> 
      <td><<4-ordine_localita>>: </td>
      <td align="right"> 
        <input type="text" name="del_city" maxlength="100">
      </td>
    </tr>
    <tr> 
      <td colspan="2"> 
        <hr>
      </td>
    </tr>
    <tr> 
      <td><<4-ordine_stato>>: </td>
      <td align="right"> 
        <input type="text" name="country" maxlength="100">
      </td>
    </tr>
    <tr> 
      <td><b><<4-ordine_email>>: </b></td>
      <td align="right"> 
        <input type="text" name="email" maxlength="100">
      </td>
    </tr>
    <tr> 
      <td><<4-ordine_telefono>>: </td>
      <td align="right"> 
        <input type="text" name="phone" maxlength="100">
      </td>
    </tr>
    <tr> 
      <td colspan="2"> 
        <hr>
      </td>
    </tr>
    <tr> 
      <td colspan="2"> 
        <table border="0" cellspacing="0" cellpadding="0" class="tabellalogin">
          <tr> 
            <td><<4-ordine_note>>: &nbsp;</td>
            <td align="right"> 
              <textarea name="notes" cols="35" rows="3"></textarea>
            </td>
          </tr>
        </table>
      </td>
    </tr>
    <tr> 
      <td colspan="2"> 
        <hr>
      </td>
    </tr>
    <tr> 
      <td colspan="2"> 
        <table border="0" cellspacing="0" cellpadding="0" width="400" class="tabellalogin">
          <tr> 
            <td valign="top" width="0"> 
              <input type="checkbox" name="news" value="1" checked>
            </td>
            <td align="left" valign="top"><<4-iscrizione_newsletter>></td>
          </tr>
        </table>
      </td>
    </tr>
    <tr> 
      <td colspan="2"> 
        <hr>
      </td>
    </tr>
    <tr> 
      <td colspan="2"> 
        <table border="0" cellspacing="0" cellpadding="0" width="400">
          <tr> 
            <td valign="top"> <<1-datipers>><br>
              <input type="hidden" name="new_usr" value="1">
              <input type="hidden" name="refer" value="<?php echo $ref; ?>">
            </td>
          </tr>
        </table>
      </td>
    </tr>
    <tr> 
      <td colspan="2"> 
        <div align="center"> 
          <input type="submit" name="Submit" value="<<4-invia>>">
        </div>
      </td>
    </tr>
  </table>
        </form> 
  
<?php
		}
		else {
?>

		
<p><<4-login>></p>

<form name="form1" method="post" action="logcheck.php">
  <table border="0" cellspacing="1" cellpadding="1" class="tabellalogin">
    <tr>
      <td nowrap><<4-nomeutente>>: </td>
      <td>
        <input type="text" name="user" maxlength="100">
      </td>
    </tr>
    <tr>
      <td nowrap><<4-password>>:</td>
      <td>
        <input type="password" name="pw" maxlength="12">
      </td>
    </tr>
  </table>
  <p>
    <input type="submit" name="Submit" value="<<4-invia>>">
  </p>
  <p><<4-nuovo_cliente>> <a href="login<<1-IDlingua>>.php?action=reg_new" target="_self"><<4-registrati>></a></p>
</form>
<p> 
  <?php
  		}
	}
}
else {
	$id = GetCliente();
	if ($id < 1) { die(); }
	$query = "select * from clienti where cust_id=$id";
	$res =  mysql_query($query,$conn);
	$row = mysql_fetch_array($res);
	if (isset($HTTP_GET_VARS['action']) && $HTTP_GET_VARS['action']=="edit") {
?>
<form name="edit" method="post" action="logcheck.php">
        
  <table border="0" width="0" class="tabellalogin">
    <tr> 
      <td><b><<4-nomeutente>>: </b></td>
      <td align="right"> 
        <table border="0" cellspacing="0" cellpadding="0" width="152">
          <tr>
            <td align="left"> 
              <input type="hidden" name="user" value="<?php echo  MakeClean($row["user"]); ?>">
              <?php echo  htmlentities($row["user"]); ?>
            </td>
          </tr>
        </table>
        
      </td>
    </tr>
    <tr> 
      <td><b><<4-ordine_nome>>: </b></td>
      <td align="right"> 
        <input type="text" name="full_name" maxlength="100" value="<?php echo  MakeClean($row["full_name"]); ?>">
      </td>
    </tr>
    <tr> 
      <td><<4-ordine_ragione_sociale>>: </td>
      <td align="right"> 
        <input type="text" name="corp" maxlength="100" value="<?php echo  MakeClean($row["corp"]); ?>">
      </td>
    </tr>
    <tr> 
      <td><<4-ordine_partita_iva>>: </td>
      <td align="right"> 
        <input type="text" name="cf_piva" maxlength="100" value="<?php echo  MakeClean($row["cf_piva"]); ?>">
      </td>
    </tr>
    <tr> 
      <td><<4-ordine_indirizzo>>: </td>
      <td align="right"> 
        <input type="text" name="addr" maxlength="100" value="<?php echo  MakeClean($row["addr"]); ?>">
      </td>
    </tr>
    <tr> 
      <td><<4-ordine_cap>>: </td>
      <td align="right"> 
        <input type="text" name="zip" maxlength="100" value="<?php echo  MakeClean($row["zip"]); ?>">
      </td>
    </tr>
    <tr> 
      <td><<4-ordine_localita>>: </td>
      <td align="right"> 
        <input type="text" name="city" maxlength="100" value="<?php echo  MakeClean($row["city"]); ?>">
      </td>
    </tr>
    <tr> 
      <td colspan="2"> 
        <hr>
      </td>
    </tr>
    <tr> 
      <td colspan="2"> 
        <p><b><<4-ordine_spedizione>>:</b></p>
      </td>
    </tr>
    <tr> 
      <td><<4-ordine_denominazione>>: </td>
      <td align="right"> 
        <input type="text" name="del_name" maxlength="100" value="<?php echo  MakeClean($row["del_name"]); ?>">
      </td>
    </tr>
    <tr> 
      <td><<4-ordine_indirizzo>>: </td>
      <td align="right"> 
        <input type="text" name="del_addr" maxlength="100" value="<?php echo  MakeClean($row["del_addr"]); ?>">
      </td>
    </tr>
    <tr> 
      <td><<4-ordine_cap>>: </td>
      <td align="right"> 
        <input type="text" name="del_zip" maxlength="100" value="<?php echo  MakeClean($row["del_zip"]); ?>">
      </td>
    </tr>
    <tr> 
      <td><<4-ordine_localita>>: </td>
      <td align="right"> 
        <input type="text" name="del_city" maxlength="100" value="<?php echo  MakeClean($row["del_city"]); ?>">
      </td>
    </tr>
    <tr> 
      <td colspan="2"> 
        <hr>
      </td>
    </tr>
    <tr> 
      <td><<4-ordine_stato>>: </td>
      <td align="right"> 
        <input type="text" name="country" maxlength="100" value="<?php echo  MakeClean($row["country"]); ?>">
      </td>
    </tr>
    <tr> 
      <td><b><<4-ordine_email>>: </b></td>
      <td align="right"> 
        <input type="text" name="email" maxlength="100" value="<?php echo  MakeClean($row["email"]); ?>">
      </td>
    </tr>
    <tr> 
      <td><<4-ordine_telefono>>: </td>
      <td align="right"> 
        <input type="text" name="phone" maxlength="100" value="<?php echo  MakeClean($row["phone"]); ?>">
      </td>
    </tr>
    <tr> 
      <td colspan="2"> 
        <hr>
      </td>
    </tr>
    <tr> 
      <td colspan="2"> 
        <table border="0" cellspacing="0" cellpadding="0" width="400" class="tabellalogin">
          <tr> 
            <td><<4-ordine_note>>: &nbsp;</td>
            <td align="right"> 
              <textarea name="notes" cols="35" rows="3"><?php echo  $row["notes"]; ?></textarea>
            </td>
          </tr>
        </table>
      </td>
    </tr>
    <tr> 
      <td colspan="2"> 
        <hr>
      </td>
    </tr>
    <tr> 
      <td colspan="2"> 
        <table border="0" cellspacing="0" cellpadding="0" width="400" class="tabellalogin">
          <tr> 
            <td valign="top" width="0"> 
              <input type="checkbox" <?php if($row["news"] == "1") {echo "checked";} ?> name="news" value="1">
            </td>
            <td align="left" width="100%" valign="top"><<4-iscrizione_newsletter>></td>
          </tr>
        </table>
      </td>
    </tr>
    <tr> 
      <td colspan="2"> 
        <hr>
      </td>
    </tr>
    <tr> 
      <td>&nbsp;</td>
      <td> 
        <input type="hidden" name="new_usr" value="0">
        <input type="hidden" name="refer" value="<?php echo $ref; ?>">
      </td>
    </tr>
    <tr> 
      <td colspan="2"> 
        <div align="center"> 
          <input type="submit" name="Submit" value="<<4-salva>>">
        </div>
      </td>
    </tr>
  </table>
        </form> <?php
	}
	
	else {			
			
?>
  <<4-benvenuto>> <b><?php echo htmlentities($row["user"]); ?></b> <<4-modifica_dati1>>
<ul class="opzionilogin">
  <li><a href="login<<1-IDlingua>>.php?action=edit" target="_self"><<4-modifica_dati2>></a></li>
  <li><a href="login<<1-IDlingua>>.php?m=-1" target="_self"><<4-consulta_ordini>></a></li>
</ul>
<?php
	}
}
?>
