<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=iso-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
David Scatigna ha scritto:
<blockquote cite="mid:46DEAC62.7020708@tomato.it" type="cite">
  <pre wrap="">1euro al giorno e questo spazio e' tuo. <a class="moz-txt-link-abbreviated" href="mailto:info@ziobudda.net">info@ziobudda.net</a>
___________FINE_____SPONSOR_______________________________

Cristiano Verondini wrote:

  </pre>
  <blockquote type="cite">
    <blockquote type="cite">
      <pre wrap="">Ecco il file modificato ma anche cos&igrave; non funge ;-(
      </pre>
    </blockquote>
    <pre wrap="">    Controlla a mano che i file generati abbiano senso. Controlla che 
algoritmo di cifratura si aspetta apache e verifica che il tuo crypt() 
richieda quell'algoritmo.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
uhm... a memoria credo che su win le pass siano in chiaro
  </pre>
</blockquote>
Non criptate intendi? Ma io le genero criptate e quindi inserisco poi
in chiaro nella maschera di autenticazione la pass ma ho dovuto invece
inserire in chiaro la pass criptata... ma perch&egrave; succede tutto su
win?!?!<br>
<br>
Cmq ho aggiornato lo script che adesso genera anche opzionalmente anche
codice per proteggere singoli file...<br>
<pre>&lt;?php
if (($_POST['username']) &amp;&amp; ($_POST['password'])) {
  $username = $_POST['username'];
  $password = $_POST['password'];
  $denyfile = $_POST['denyfile'];
?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" <a class="moz-txt-link-rfc2396E" href="http://www.w3.org/TR/xhtml1/DTD/strict.dtd">"http://www.w3.org/TR/xhtml1/DTD/strict.dtd"</a>&gt;
&lt;html <a class="moz-txt-link-freetext" href="xml:lang=">xml:lang=</a>"it" xmlns=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/1999/xhtml">"http://www.w3.org/1999/xhtml"</a> dir="ltr"&gt;
&lt;head&gt;
&lt;title&gt;Questo script genera i file .htaccess e .htpasswd&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;?php
if ((substr($_SERVER['DOCUMENT_ROOT'],-1,1) == "/") &amp;&amp; (substr($_SERVER['PHP_SELF'],0,1) =="/")) {
  $path = $_SERVER['DOCUMENT_ROOT'] . substr(dirname($_SERVER['PHP_SELF']),1) . "/.htpasswd";
} else {
  $path = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . "/.htpasswd";}
  if (strtoupper(substr(PHP_OS,0,3) == 'WIN')) {
    $eol = "\r\n";
  } elseif (strtoupper(substr(PHP_OS,0,3) == 'MAC')) {
    $eol = "\r";
  } else {
    $eol = "\n";
  }
  if (!empty($denyfile)) {
    $tmp1 = fopen(".htaccess", "a+");
    $tmp2 .= "AuthType Basic" . $eol;
    $tmp2 .= "AuthName \"Area Protetta\"" . $eol;
    $tmp2 .= "AuthUserFile $path" . $eol;
    $tmp2 .= "&lt;Files " . $denyfile . "&gt;" . $eol;
    $tmp2 .= "Require valid-user" . $eol;
    $tmp2 .= "&lt;/Files&gt;" . $eol;
    fwrite($tmp1, $tmp2);
    fclose($tmp1);
    unset($tmp1);
    unset($tmp2);
  } else {
    $tmp1 = fopen(".htaccess", "a+");
    $tmp2 .= "AuthType Basic" . $eol;
    $tmp2 .= "AuthName \"Area Protetta\"" . $eol;
    $tmp2 .= "AuthUserFile $path" . $eol;
    $tmp2 .= "Require valid-user" . $eol;
    fwrite($tmp1, $tmp2);
    fclose($tmp1);
    unset($tmp1);
    unset($tmp2);
  }
  $tmp1 = fopen(".htpasswd", "a+");
  $tmp2 = "$username:" . crypt($password,CRYPT_STD_DES) . $eol;
  fwrite($tmp1, $tmp2);
  fclose($tmp1);
  unset($tmp1);
  unset($tmp2);
  exit("&lt;h2&gt;.htaccess e .htpasswd generati correttamente!&lt;/h2&gt;\n&lt;/body&gt;\n&lt;/html&gt;");
}
?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" <a class="moz-txt-link-rfc2396E" href="http://www.w3.org/TR/xhtml1/DTD/strict.dtd">"http://www.w3.org/TR/xhtml1/DTD/strict.dtd"</a>&gt;
&lt;html <a class="moz-txt-link-freetext" href="xml:lang=">xml:lang=</a>"it" xmlns=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/1999/xhtml">"http://www.w3.org/1999/xhtml"</a> dir="ltr"&gt;
&lt;head&gt;
&lt;title&gt;Questo script genera i file .htaccess e .htpasswd&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form method="post" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;"&gt;
&lt;p&gt;&lt;label for="username"&gt;Username&lt;/label&gt;: &lt;input type="text" id="username" name="username" /&gt; (Richiesta)&lt;/p&gt;
&lt;p&gt;&lt;label for="password"&gt;Password&lt;/label&gt;: &lt;input type="text" id="password" name="password" /&gt; (Richiesta)&lt;/p&gt;
&lt;p&gt;&lt;label for="denyfile"&gt;Nega File&lt;/label&gt;: &lt;input type="text" id="denyfile" name="denyfile" /&gt; (Opzionale)&lt;/p&gt;
&lt;p&gt;&lt;input type="submit" value="Genera i file" /&gt;&lt;/p&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
Spero che a qualcuno sia utile questo script... Ciao e fatemi sapere...<br>
<br>
<pre class="moz-signature" cols="76">-- 
Alessandro Marinuzzi
--------------------
<a class="moz-txt-link-freetext" href="http://www.alecos.it">http://www.alecos.it</a>
--------------------</pre>
</body>
</html>