<!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">
Cristiano Verondini ha scritto:
<blockquote cite="mid:633BFB43-BD9D-4D00-8BA5-91C26073D9E0@verondini.it"
 type="cite">
  <pre wrap="">On 06/ott/07, at 08:14, Alessandro Marinuzzi wrote:
  </pre>
  <blockquote type="cite">
    <blockquote type="cite">
      <pre wrap="">web/www.sitoweb.it/home/script.php

la root in questo caso &egrave; home ma appena metto lo script l&igrave; non mi da
nulla, pagina bianca! mentre se lo metto in:

web/www.sitoweb.it/home/dir/script.php

lo script restituisce dir

Come aggirare? e come ottenere solo il nome della root?
      </pre>
    </blockquote>
  </blockquote>
  <pre wrap=""><!---->        Forse non ho capito quello che intendi, ma nel primo caso mi  
verrebbe da dire che il path &egrave; home/ mentre nel secondo home/dir/
  </pre>
</blockquote>
la home corrisponde a / quindi non mi restituisce home ma bens&igrave; un bel
nulla...<br>
<blockquote cite="mid:633BFB43-BD9D-4D00-8BA5-91C26073D9E0@verondini.it"
 type="cite">
  <blockquote type="cite">
    <pre wrap="">ho trovato una soluzione che non mi piace ma funziona:

&lt;?php
  $dir = basename(dirname($_SERVER['PHP_SELF']),"/");
  if ($dir == "") {
    $path = "root";
  } else {
    $path = basename(dirname($_SERVER['PHP_SELF']),"/");
  }
  echo $path;
?&gt;

ce ne sono di migliori? Ciao e grazie :-)
    </pre>
  </blockquote>
  <pre wrap=""><!---->
        Io lavorerei su __FILE__
  </pre>
</blockquote>
provata anche questa strada... vengo al dunque: ho uno script che
genera un archivio tar tramite una classe e vorrei aggiungere il nome
della directory all'interno dell'archivio in base alla directory dove
risiede lo script.<br>
<pre>&lt;?php  
  ini_set('memory_limit', '-1');
  ini_set('register_globals', 0);
  ini_set('max_execution_time', 0);
  //=============================================================
  $rel_path = basename(dirname($_SERVER['PHP_SELF']),"/");
  if ($rel_path == "") {
    $cwd_path = $_SERVER['HTTP_HOST'];
  } else {
    $cwd_path = basename(dirname($_SERVER['PHP_SELF']),"/");
  }
  //=============================================================
  $password = "changeme";
  //=============================================================
  $tar_file = "$cwd_path.tar";
  //=============================================================
  if (!isset($_POST['password'])) {
    echo 'FORM HTML';
  } else {
    if ($_POST['password'] == $password) {
      Class Tar_Archive {
        var $tar_file;
        var $fp;
        function Tar_Archive($tar_file) {
          $this-&gt;tar_file = $tar_file;
          $this-&gt;fp = fopen($this-&gt;tar_file, "wb");
          $tree = $this-&gt;build_tree();
          $this-&gt;process_tree($tree);
          fputs($this-&gt;fp, pack("a512", ""));
          fclose($this-&gt;fp);
          header("Pragma: public");
          header("Expires: 0");
          header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
          header("Cache-Control: private",false);
          header("Content-Type: application/octet-stream");
          header("Content-Disposition: attachment; filename=".basename($tar_file).";");
          header("Content-Transfer-Encoding: binary");
          header("Content-Length: ".filesize($tar_file));
          readfile($tar_file);
          unlink($tar_file);
        }
        function build_tree($dir = '.') {
          $handle = opendir($dir);
          while(false !== ($readdir = readdir($handle))) {
            if ($readdir != '.' &amp;&amp; $readdir != '..') {
              $path = $dir.'/'.$readdir;
              if (!is_link($path)) {
                if (is_file($path)) {
                  $output[] = substr($path, 2, strlen($path));
                } elseif (is_dir($path)) {
                  $output[] = substr($path, 2, strlen($path)).'/';
                  $output = array_merge($output, $this-&gt;build_tree($path));
                }
              }
            }
          }
          closedir($handle);
          return $output;
        }
        function process_tree($tree) {
          foreach($tree as $pathfile) {
            if (substr($pathfile, -1, 1) == '/') {
              fputs($this-&gt;fp, $this-&gt;build_header($pathfile));
            } elseif ($pathfile != $this-&gt;tar_file) {
              $filesize = filesize($pathfile);
              $block_len = 512*ceil($filesize/512)-$filesize;
              fputs($this-&gt;fp, $this-&gt;build_header($pathfile));
              fputs($this-&gt;fp, file_get_contents($pathfile));
              fputs($this-&gt;fp, pack("a".$block_len, ""));
            }
          }
          return true;
        }
        function build_header($pathfile) {
          if (strlen($pathfile) &gt; 99) die('Error');
            $info = stat($pathfile);
            if (is_dir($pathfile)) $info[7] = 0;
              $header = pack("a100a8a8a8a12A12a8a1a100a255", $pathfile, sprintf("%6s ", decoct($info[2])), sprintf("%6s ", decoct($info[4])), sprintf("%6s ", decoct($info[5])), sprintf("%11s ",decoct($info[7])), sprintf("%11s", decoct($info[9])), sprintf("%8s", " "), (is_dir($pathfile) ? "5" : "0"), "", "");
              clearstatcache();
              $checksum = 0;
              for ($i = 0; $i &lt; 512; $i++) {
                $checksum += ord(substr($header,$i,1));
              }
              $checksum_data = pack("a8", sprintf("%6s ", decoct($checksum)));
              for ($i = 0, $j = 148; $i &lt; 7; $i++, $j++) {
                $header[$j] = $checksum_data[$i];
              }  
              return $header;
        }
      }
      $tar = &amp; new Tar_Archive("$tar_file");
    } else {
      echo 'FORM HTML';
    }
  }
?&gt;
</pre>
Con queste modifiche ottengo un archivio in base alla dir dove si trova
ma all'interno dell'archivio manca la dir radice in pratica l'archivio
non viene scompattato in una diretory ma bens&igrave; vengono scompattati
tutti i file e dir nello 'spazio libero' mentre io invece vorrei una
situazione di questo tipo:<br>
<br>
archivio.tar =&gt; dir dinamica =&gt; tutti i file e dir<br>
<br>
invece ho:<br>
<br>
archivio.tar =&gt; tutti i file e dir<br>
<br>
spero di essermi spiegato... avevo provato a fare una cosa sporca come
questa:<br>
<br>
<pre>$tree = $this-&gt;build_tree(getcwd());
</pre>
ma funziona solo sotto windows e con molte perplessit&agrave;....<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>