9 Mar 2010

Zmienne środowiskowe w PHP

[REDIRECT_nokeepalive] => 1
[REDIRECT_ssl-unclean-shutdown] => 1
[REDIRECT_downgrade-1_0] => 1
[REDIRECT_force-response-1_0] => 1
[REDIRECT_SCRIPT_URL] => /tag/gmap/
[REDIRECT_SCRIPT_URI] => <a class="mce_ws_kod" href="http://kody.wig.pl/tag/gmap/">http://kody.wig.pl/tag/gmap/</a>
[REDIRECT_STATUS] => 200
[nokeepalive] => 1
[ssl-unclean-shutdown] => 1
[downgrade-1_0] => 1
[force-response-1_0] => 1
[SCRIPT_URL] => /tag/gmap/
[SCRIPT_URI] => <a class="mce_ws_kod" href="http://kody.wig.pl/tag/gmap/">http://kody.wig.pl/tag/gmap/</a>
[HTTP_ACCEPT] => image/gif, ... */*
[HTTP_REFERER] => <a class="mce_ws_kod" href="http://www.google.pl/search?hl=pl&q=kody+gmap">http://www.google.pl/search?hl=pl&q=kody+gmap</a>
[HTTP_ACCEPT_LANGUAGE] => pl
[HTTP_UA_CPU] => x86
[HTTP_ACCEPT_ENCODING] => gzip, deflate
[HTTP_USER_AGENT] => Mozilla/4.0 (compatible; MSIE 7.0;)
[HTTP_HOST] => kody.wig.pl
[HTTP_CONNECTION] => Keep-Alive
[HTTP_COOKIE] => __utma=48955324.
[PATH] => /usr/local/bin:/usr/bin:/bin
[SERVER_SIGNATURE] =>
[SERVER_SOFTWARE] => Apache
[SERVER_NAME] => kody.wig.pl
[SERVER_ADDR] => 62.2.2.2
[SERVER_PORT] => 80
[REMOTE_ADDR] => 212.11.11.11
[DOCUMENT_ROOT] => /htdocs
[SERVER_ADMIN] => [no address given]
[SCRIPT_FILENAME] => /www/index.php
[REMOTE_PORT] => 53249
[REDIRECT_URL] => /tag/gmap/
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /tag/gmap/
[SCRIPT_NAME] => /index.php
[PHP_SELF] => /index.php
[REQUEST_TIME] => 1268126900
[argv] => Array
(
)
[argc] => 0
18 Cze 2009

Porównanie zawartości plików

$file_1 = 'mapy_01.txt';
$file_2 = 'chelm_02.txt';

$table_1 = file( $file_1 );
$table_2 = file( $file_2 );

for($i=0, $cnt=count($table_1); $i<$cnt; $i++) {
 $tab = explode("\t", chop($table_1[$i] ));

$key = $tab[0].' '.$tab[1].' '.$tab[2];
 $table_test[$key]=$key;
}

for($i=0, $cnt=count($table_2); $i<$cnt; $i++) {
 $table_2[$i] = chop($table_2[$i]);
 $tab = explode("\t", $table_2[$i]);

$key = $tab[3].' '.$tab[4].' '.$tab[5];
 if(!isset($table_test[$key])) {
  $table_niema[] = $table_2[$i];
 }
}
echo "Plik drugi";
echo '<pre>'; print_r($table_2); echo '</pre>';

echo "Brak w pliku pierwszym";
echo '<pre>'; print_r($table_niema); echo '</pre>';
13 Gru 2008

Ilość plików w poszczególnych katalogach galerii

define ('PATH_IMAGE_GALERIA', PATH_IMAGE . 'galeria/');
foreach (glob(PATH_IMAGE_GALERIA.'*', GLOB_ONLYDIR) as $filename) {
$galeria_folder = substr(strrchr($filename, '/'), 1 );
$galeria_strony[$galeria_folder] = count(glob($filename . "/*.*"));
}
$dump = print_r($galeria_strony, true);
echo nl2br($dump);

Array
(
[php] => 4
[css] => 0
[javascript] => 0
[html] => 0
[http] => 1
[vba] => 0
[vbscript] => 1
)