php function randGame res request http freegames at ua news rand 200 p

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
function randGame(){
$res = request('http://freegames.at.ua/news/'.rand(1,200));
preg_match_all('/<div id="entryID\d+">(.*?)<div class="eDetails" >/si', $res, $data);
$game = $data[1][rand(0, count($data[1]) - 1)];
preg_match('/src="(.*?)"/', $game, $img);
$img = $img[1];
preg_match('/alt="(.*?)"/', $game, $name);
$name = $name[1];
$s = '<div style="text-align:left;clear:both;padding-top:2px;padding-bottom:2px;">';
preg_match('/'.$s.'(.*?)<\/div>/si', $game, $d);
$d = $d[1];
$d = preg_replace('/<font(.*?)<\/font>/si', '', $d);
$d = preg_replace('/<(.*?)>/', '', $d);
$d = preg_replace('/Описание\:\s?/si', '', $d);
$d = trim($d);
if(empty($d))
$d = 'АФИГЕННАЯ ИГРУХА!';
return array(iconv('UTF-8', 'Windows-1251', $name), $img, $d);
}
function request($link){
return file_get_contents($link);
}
?>