<?php
function curl_get_contents($url) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
// curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_COOKIEFILE, "cookiefile");
curl_setopt($curl, CURLOPT_COOKIEJAR, "cookiefile"); # SAME cookiefile
curl_setopt($curl, CURLOPT_URL, $url);
return curl_exec($curl);
};
////////////////////////////////////////////////////////////////////////////////
/// Скрипт для организации ЧЕМПИОНАТА КОЛЛИЗИОНИСТОВ ВСОЛа ///
/// ///
////////////////////////////////////////////////////////////////////////////////
set_time_limit(0);
$start_time = microtime(1);
$is_end = true;
$id = $_POST["id"];
$season = $_POST["season"];
$start_link = "<a href="";
$middle_link = "">";
$end_link = "</a>";
$team_URL = "http://virtualsoccer.ru/roster.php?num=$id";
$team_content = curl_get_contents($team_URL);
$tmp_string = iconv("utf-8", "windows-1251", $team_content);
$pattern = "Сервер в режиме генерации матчей - дождитесь завершения игрового дня";
if(substr_count($tmp_string, $pattern) != 0){
echo("В настоящий момент статистику вывести невозможно.<p>\n");
echo("Причина:<p>\n");
echo("Сервер ВСОЛа в режиме генерации матчей.<p>\n");
echo("<a href="../index.php">на главную</a><p>$tmp_string\n");
$is_end = false;
}
elseif($is_end){
$pattern = "Выбранной команды не существует";
if(substr_count($tmp_string, $pattern) != 0){
echo("Не балуйся!<p>\n");
echo("Вводи номер реально существующей команды!<p>");
echo("Шуруй на главную страницу.<p>\n");
echo("<a href="../index.php">на главную</a><p>\n");
$is_end = false;
}
///////////////////////////////////////////////////////////////////////////////////////////////
/// TOK - данный блок получает со страницы полное название команды ($team = $data[3];) со ссылкой ($team_link = $start_link.$team_URL.$middle_link.$team.$end_link;)
elseif($is_end){
$pattern = "|<a href="roster\.php\?num=([0-9]{1,5})" class="mnu"(>)([^<]{1,})+|";
if( !( preg_match($pattern, $team_content, $data) ) )
{
// print(" --- ! ! ! --- FATAL ERROR --- ! ! ! ---
\n");
}
else
{
$team = $data[3];
$team_link = $start_link.$team_URL.$middle_link.$team.$end_link;
$team_link = iconv("utf-8", "windows-1251", $team_link);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
$pattern = "<a target="_blank" href="viewmatch\.php\?day=";
$seasons_URLs = "http://virtualsoccer.ru/roster_m.php?num=$id&season=".$season;
$seasons_link = $start_link.$seasons_URLs.$middle_link."Season $season".$end_link;
$season_content = curl_get_contents($seasons_URLs);
$data = split($pattern, $season_content);
print "<span style='color : #FFD700'><h2>$team_link</h2></span><pre>";
print "<h4>$seasons_link</h4><pre>";
$plus = 0;
$minus = 0;
for($j = 1; $j < count($data); $j++){
$match_pattern = "|([0-9]{1,8})&match_id=([0-9]{1,10})"|";
if((preg_match($match_pattern, $data[$j], $match_data))){
$matches_URLs[$j] = "http://virtualsoccer.ru/viewmatch.php?day=$match_data[1]&match_id=$match_data[2]";
$string = $matches_URLs[$j];
$matches_link[$j] = $start_link.$string.$middle_link."Match #$j".$end_link;
$string = $matches_link[$j];
$string = $matches_URLs[$j];
$match_content[$j] = curl_get_contents($string);
$tmp_pattern = "|roster.php\?num=([0-9]{1,5})|";
if(preg_match($tmp_pattern, $match_content[$j], $tmp_array))
{
if($tmp_array[1] == $id)
{
$away = 0; // 0 is home, 1 is away match
}
else
{
$away = 1;
}
}
if($away == 0){
$tmp_pattern = "|<i><font color="#([[:alnum:]]{6})">([^<]{1,})<td class="txt" bgcolor="#e5f7e6">([^<]{1,})<a href="javascript:Hint\(4|";
if(preg_match($tmp_pattern, $match_content[$j], $tmp_array)){
$style[$j] = $tmp_array[1]; // style contain brit, kat, spart, bb, comb or norm
}
}
else{
$tmp_pattern = "|Hint\(4, 'hint\.php\?id=',280,460\)"><img src="pics/question\.gif" border=0 style="position: relative; top: 1px; left: 2px;" width=11 height=11></a><td class="txt" colspan=3><i>(<font color="#([[:alnum:]]{6})">)?([^<]{1,})+|";
if(preg_match($tmp_pattern, $match_content[$j], $tmp_array)){
$style[$j] = $tmp_array[2];
}
}
$style[$j] = iconv("utf-8", "windows-1251", $style[$j]);
$kolliz_plus = "00FF00";
$kolliz_minus = "FF0000";
if ($style[$j] == $kolliz_plus){
$plus = $plus + 10;
}
if ($style[$j] == $kolliz_minus){
$minus = $minus + 5;
}
// echo '<pre>';
// echo $style[$j];
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
else{
print(" --- ! ! ! --- FATAL ERROR --- ! ! ! ---
\n");
}
}
$summa = $plus - $minus;
$finish_time = microtime(1);
$generation_time = $finish_time - $start_time;
echo '<pre>';
echo $summa;
echo '<pre>';
print "Информация была собрана за $generation_time секунд\n";
}
}
?>
Если Вы уже зарегистрированы на Портале - войдите в систему, если Вы еще не регистрировались - пройдите простую процедуру регистрации.