03.11.2010., 22:00
|
#10
|
aaaa
Datum registracije: Jul 2002
Lokacija: Velika Gorica
Postovi: 93
|
Citiraj:
Autor Bubba
Zanimljivo ovo cudo, hmm...
Je's da je overhead monstruozan, ali...
Objaviti svoj kod? 
|
Ovo je last-modified.php
Code:
<?php
echo "\r\nRead URL-s from check.txt file.\r\n\r\n";
if (file_exists("check.txt")){
// reads entire file into a string
$file = file_get_contents("check.txt");
$lines = split_file_by_line($file);
// blank var
$txt_array = array();
foreach ($lines as $line_num => $line_string){
if(preg_match("/^[a-zA-Z]+[:\/\/]+[A-Za-z0-9\-_]+\\.+[A-Za-z0-9\.\/%&=\?\-_]+$/i", $line_string)){
$link = $line_string;
$ch = curl_init();
$timeout = 25; // set to zero for no timeout
curl_setopt($ch, CURLOPT_URL, $link);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
$header = curl_exec($ch);
curl_close($ch);
$lines = split_file_by_line($header);
foreach ($lines as $key => $line){
// find Last-Modified
if (strpos($line, "Last-Modified: ") !== false){
$line_array = explode("Last-Modified: ", $line);
$txt_array[$line_num] = $line_array[1]."\t".$line_string;
echo "Checking: $line_string\r\n\r\n";
}
unset($line_array);
}
}
}
} else {
echo "\r\nError: file check.txt not found.\r\n\r\n";
}
if (count($txt_array) > 0){
echo "\r\nCreate report.txt file.\r\n\r\n";
// create filename
$fp = fopen("report.txt", "w");
fwrite($fp, $txt_line."autor: Matej Posavec\r\n");
fwrite($fp, $txt_line."web: www.rulac.net\r\n\r\n");
foreach ($txt_array as $txt_line){
fwrite($fp, $txt_line."\r\n");
}
fclose($fp);
}
// debug
/*
echo "<pre>";
print_r($txt_array);
echo "</pre>";
*/
function split_file_by_line($file){
// convert windows to unix
$file = str_replace("\r\n", "\n", $file);
// convert mac to unix
$file = str_replace("\r", "\n", $file);
// split a string by string
$lines = explode("\n", $file);
return $lines;
}
?>
I na kraju pretvorim sa
Code:
bamcompile -c -e:php_curl.dll -d -i:icon.ico last-modified.php
php_curl.dll sam nabavio sa php-4.4.4-Win32.zip, a on da bi radio treba libeay32.dll and ssleay32.dll.
Vjerojatno bi se CURL mogao zamjeniti sa nekom starijom PHP funkcijom, ali velim bio je to copy/past nabrzaka pa je ispalo kako je ispalo. Također i ove kozmetička ikona je poždrala prostora.
|
|
|