commit | author | age
|
8bd4d9
|
1 |
<?php |
JK |
2 |
echo STAR.'Pobieranie danych...'; |
|
3 |
$humor = @file_get_contents('http://ddserv.vsdsoftware.pl/eksport/'); |
|
4 |
|
|
5 |
if(!$humor) { |
|
6 |
echo FAIL; |
|
7 |
return FALSE; |
|
8 |
} |
|
9 |
|
|
10 |
echo OK; |
|
11 |
echo STAR.'Sprawdzanie formatu odpowiedzi...'; |
|
12 |
|
|
13 |
if(strpos($humor, '<img src="')!==FALSE) { |
|
14 |
preg_match('/\<img src=\"(.*)\" border/', $humor, $humor); |
|
15 |
$humor = $humor[1]; |
|
16 |
|
|
17 |
echo ' obrazek'.OK; |
|
18 |
echo STAR.'Pobieranie obrazka...'; |
|
19 |
|
|
20 |
$img = @file_get_contents($humor); |
|
21 |
if(!$img) { |
|
22 |
echo FAIL; |
|
23 |
return FALSE; |
|
24 |
} |
|
25 |
|
|
26 |
@unlink('humor.txt'); |
|
27 |
file_put_contents('./humor.jpg', $img); |
|
28 |
file_put_contents('./archiwum/'.date('j.m.Y').'.jpg', $img); |
|
29 |
|
|
30 |
echo OK; |
|
31 |
return FALSE; |
|
32 |
} |
|
33 |
elseif(strpos($humor, '<td class="text">')!==FALSE) |
|
34 |
{ |
|
35 |
echo ' tekst'.OK; |
|
36 |
echo STAR.'Zapisywanie odpowiedzi'; |
|
37 |
$humor = explode('<td class="text">', $humor); |
|
38 |
$humor = explode('</td>', $humor[1]); |
|
39 |
$humor = strip_tags(str_replace('<br>', "\n", $humor[0])); |
|
40 |
} |
|
41 |
else |
|
42 |
{ |
|
43 |
echo FAIL; |
|
44 |
return FALSE; |
|
45 |
} |
|
46 |
|
|
47 |
$humor = trim($humor); |
|
48 |
|
|
49 |
if(empty($humor)) { |
|
50 |
echo FAIL; |
|
51 |
return FALSE; |
|
52 |
} |
|
53 |
|
|
54 |
$humor = iconv('iso-8859-2', 'utf-8', $humor); |
|
55 |
|
|
56 |
file_put_contents('./humor.txt', $humor); |
|
57 |
file_put_contents('./archiwum/'.date('j.m.Y').'.txt', trim($humor)); |
|
58 |
|
|
59 |
echo OK; |
|
60 |
?> |