apache_request_headers

(PHP 4 >= 4.3.0, PHP 5)

apache_request_headers -- Осуществить выборку всех заголовков HTTP запросов

Описание

array apache_request_headers ( void )

Функция apache_request_headers() возвращает ассоциативный массив, содержащий все заголовки текущего HTTP запроса. Эта функция доступна только в том случае, если PHP работает в качестве модуля Apache.

Замечание: В версиях PHP, более ранних, чем 4.3.0, функция apache_request_headers() имела наименование getallheaders(). В PHP версии 4.3.0 и последующих версиях, имя getallheaders() является псевдонимом функции apache_request_headers().

Пример 1. Пример использования apache_request_headers()

<?php
$headers
= apache_request_headers();

foreach (
$headers as $header => $value) {
   echo
"$header: $value <br />\n";
}
?>

Замечание: Также вы можете получить значения наиболее широко используемых CGI переменных, читая их из окружения сервера; это работает независимо от того, установлен PHP в качестве модуля Apache или нет. Для того, чтобы получить список всех доступных переменных окружения, используйте функцию phpinfo().



apache_request_headers
php [at] barryhunter [.] co [.] uk
09-Sep-2005 04:00
Surly this could be rewritten as

function list_dirs($path, $target)
{
   $list = scandir($path);
   $url = $_SERVER['HTTP_HOST'];
    
   foreach ($list as $number => $filename)
   {
       if ( $filename !== '.' && $filename !== '..' && !is_file($filename) )
       {
           if ($target == '')
           {
               // Print Dirs with link
               print ("<a href=\"http://$url/$filename\">$filename</a> <br>\n");
           }
           else
           {
               // Print Dirs with link
               print ("<a href=\"http://$url/$filename\" target=\"$target\">$filename</a> <br>\n");
           }
              
       }
   }
}

which would then not require apache. I havent tested this but looks to do exactly the same.
renich at woralelandia dot com
21-Apr-2005 10:50
Here is a simple listing function. It accepts a path and target. Examples listed bellow

function list_dirs($path, $target)
{
   $list = scandir($path);
  
   foreach ($list as $number => $filename)
   {
       if ( $filename !== '.' && $filename !== '..' && !is_file($filename) )
       {
           // Asign more readable and logic variables
           $dir = $filename;
           $url = apache_request_headers();
          
           if ($target == '')
           {
               // Print Dirs with link
               print ("<a href=\"http://$url[Host]/$dir\">$dir</a> <br>\n");
           }
           else
           {
               // Print Dirs with link
               print ("<a href=\"http://$url[Host]/$dir\" target=\"$target\">$dir</a> <br>\n");
           }
              
       }
   }
}

Examples:

1.- List actual dir with no target option

<?php

list_dirs
('.', '');

?>

2.- List "mydir" with a "_blank" as target name

<?php

list_dirs
('/home/renich/www/mydir', '_blank')

?>

Notes:
- Its a simple function and it uses a function that interacts with apache. I don't know what will happen if you request a file list of a directory outside of the apache realm!
- Not fully tested!

<apache_noteapache_reset_timeout>
 Last updated: Tue, 15 Nov 2005