Parse error
Parse error: parse error, unexpected $ in /home/www/gendringenc2.freehostia.com/knvb.php on line 277
Dit is knvb.php:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?PHP
error_reporting(0);
include 'socket.class.php';
class KnvbRipper
{
protected $contents;
protected $email;
protected $password;
protected $club_url;
protected $mode;
protected $errors;
protected $output;
public function __construct($email, $password, $club_url, $mode = 'uitslagen')
{
$this -> email = $email;
$this -> password = $password;
$this -> club_url = $club_url;
$this -> mode = $mode;
$this -> errors = array();
}
protected function get_contents()
{
if(!empty($this -> contents))
{
return;
}
// Log in on knvb.nl
$post = new HttpPostRequest();
$post -> set_ip("www.knvb.nl", 80);
$post -> set_file("mijn");
$post -> add_var("method", "login");
$post -> add_var("email", $this -> email); // Je email
$post -> add_var("password", $this -> password); // je wachtwoord
$post -> include_headers();
$post -> use_redirect(false);
if($post -> request())
{
// Ok, we logged in now on knvb.nl
// Get ranking now
$get = new HttpGetRequest();
$get -> set_ip("www.knvb.nl", 80);
// Zet hier onder de URL van je team pagina
$get -> set_file($this -> club_url);
$get -> include_headers();
// Get cookies setted by the login page
$cookies = $post -> get_cookies();
foreach($cookies as $name => $value)
{
$get -> set_cookie($name, $value);
}
if($get -> request())
{
$this -> contents = $get -> get_contents();
return true;
}
else
{
$this -> errors[] = $get -> get_error();
return false;
}
}
else
{
$this -> errors[] = $post -> get_error();
return false;
}
return false;
}
protected function parse()
{
switch($this -> mode)
{
case 'uitslagen':
list(, $contents) = explode('<td width="100%" align="left" valign="middle" class="Agreenheader">Uitslagen</td>', $this -> contents);
list($contents) = explode('<td class="Agreenheader">Stand </td>', $contents);
preg_match_all('#<tr( class="clubselectie")?>(\s+)<td class="scoretd">(.*?)</td>(\s+)<td class="scoretd">(.*?)</td>(\s+)<td class="scoretd">(.*?)</td>(\s+)<td class="scoretd">(.*?)(\s+)</td>(\s+)</tr>#si', $contents, $matches, PREG_SET_ORDER);
$this -> output = array();
$i = 0;
foreach($matches as $info)
{
$this -> output[$i]['datum'] = $info[3];
$this -> output[$i]['club1'] = $info[5];
$this -> output[$i]['club2'] = $info[7];
$this -> output[$i]['uitslag'] = $info[9];
$i++;
}
break;
case 'stand':
list(, $contents) = explode('<td class="Agreenheader">Stand_ </td>', $this -> contents);
list($contents) = explode('<td width="100%" align="left" valign="middle" class="Agreenheader">Uitleg</td>', $contents);
preg_match_all('#<tr( class="clubselectie")?>
error_reporting(0);
include 'socket.class.php';
class KnvbRipper
{
protected $contents;
protected $email;
protected $password;
protected $club_url;
protected $mode;
protected $errors;
protected $output;
public function __construct($email, $password, $club_url, $mode = 'uitslagen')
{
$this -> email = $email;
$this -> password = $password;
$this -> club_url = $club_url;
$this -> mode = $mode;
$this -> errors = array();
}
protected function get_contents()
{
if(!empty($this -> contents))
{
return;
}
// Log in on knvb.nl
$post = new HttpPostRequest();
$post -> set_ip("www.knvb.nl", 80);
$post -> set_file("mijn");
$post -> add_var("method", "login");
$post -> add_var("email", $this -> email); // Je email
$post -> add_var("password", $this -> password); // je wachtwoord
$post -> include_headers();
$post -> use_redirect(false);
if($post -> request())
{
// Ok, we logged in now on knvb.nl
// Get ranking now
$get = new HttpGetRequest();
$get -> set_ip("www.knvb.nl", 80);
// Zet hier onder de URL van je team pagina
$get -> set_file($this -> club_url);
$get -> include_headers();
// Get cookies setted by the login page
$cookies = $post -> get_cookies();
foreach($cookies as $name => $value)
{
$get -> set_cookie($name, $value);
}
if($get -> request())
{
$this -> contents = $get -> get_contents();
return true;
}
else
{
$this -> errors[] = $get -> get_error();
return false;
}
}
else
{
$this -> errors[] = $post -> get_error();
return false;
}
return false;
}
protected function parse()
{
switch($this -> mode)
{
case 'uitslagen':
list(, $contents) = explode('<td width="100%" align="left" valign="middle" class="Agreenheader">Uitslagen</td>', $this -> contents);
list($contents) = explode('<td class="Agreenheader">Stand </td>', $contents);
preg_match_all('#<tr( class="clubselectie")?>(\s+)<td class="scoretd">(.*?)</td>(\s+)<td class="scoretd">(.*?)</td>(\s+)<td class="scoretd">(.*?)</td>(\s+)<td class="scoretd">(.*?)(\s+)</td>(\s+)</tr>#si', $contents, $matches, PREG_SET_ORDER);
$this -> output = array();
$i = 0;
foreach($matches as $info)
{
$this -> output[$i]['datum'] = $info[3];
$this -> output[$i]['club1'] = $info[5];
$this -> output[$i]['club2'] = $info[7];
$this -> output[$i]['uitslag'] = $info[9];
$i++;
}
break;
case 'stand':
list(, $contents) = explode('<td class="Agreenheader">Stand_ </td>', $this -> contents);
list($contents) = explode('<td width="100%" align="left" valign="middle" class="Agreenheader">Uitleg</td>', $contents);
preg_match_all('#<tr( class="clubselectie")?>
$this -> output = array();
$i = 0;
foreach($matches as $info)
{
$this -> output[$i]['nummer'] = $info[3];
$this -> output[$i]['club'] = $info[5];
$this -> output[$i]['gespeeld'] = $info[7];
$this -> output[$i]['gewonnen'] = $info[9];
$this -> output[$i]['gelijk'] = $info[11];
$this -> output[$i]['verloren'] = $info[13];
$this -> output[$i]['punten'] = $info[15];
$this -> output[$i]['goals_voor'] = $info[17];
$this -> output[$i]['goals_tegen'] = $info[19];
$this -> output[$i]['doelsaldo'] = ( $info[17] - $info[19] );
$i++;
}
break;
case 'programma':
preg_match_all('#<tr( class="clubselectie")?>(\s+)<td class="scoretd" nowrap="nowrap">(.*?)</td>(\s+)<td class="scoretd">(.*?)</td>(\s+)<td class="scoretd">(.*?)</td>(\s+)<td class="scoretd">(.*?)</td>(\s+)<td valign="middle" align="right" class="scoretd">(.*?)</td>#si', $this -> contents, $matches, PREG_SET_ORDER);
$this -> output = array();
$i = 0;
foreach($matches as $info)
{
$this -> output[$i]['datum'] = $info[3];
$this -> output[$i]['tijd'] = $info[5];
$this -> output[$i]['teams'] = $info[7];
$this -> output[$i]['accomedatie'] = $info[9];
$i++;
}
break;
default:
$this -> errors[] = "Ongeldige mode";
break;
}
}
public function rip($mode = '')
{
if(!empty($mode))
{
$this -> mode = $mode;
}
$this -> get_contents();
$this -> parse();
return $this -> output;
}
public function get_errors()
{
return $this -> errors;
}
}
// Parameter 1: je email
// Parameter 2: je wachtwoord
// Parameter 3: Club URL
// Om die te krijgen ga je gewoon naar je team pagina, waar je alle uitslagen en standen ziet,
// en kopieer dan de hele url, wat ACHTER www.knvb.nl/ staat (dus zonder de slash van te voren)
// Parameter 4: Mode, uitslagen of stand
$ripper = new KnvbRipper('email', 'ww', 'clubs_comp/team_standen?club_id=BBKS69K&team_id=179072&comp_id=OO-0247**-15-137077!', 'stand');
echo "<pre>", print_r($ripper -> rip()), "</pre>";
echo "<pre>", print_r($ripper -> rip('uitslagen')), "</pre>";
echo "<pre>", print_r($ripper -> rip('programma')), "</pre>";
if(count($ripper -> get_errors()))
{
die(implode("<br />", $ripper -> get_errors()));
}
function getProgramma()
{
GLOBAL $ripper;
foreach( $ripper->rip( 'programma' ) AS $key )
{
echo 'Datum: ' . $key['datum'] . '<br /> Tijd: ' . $key['tijd'] . '<br /> Teams: ' . $key['teams'] . '<br /> Accomedatie: ' . $key['accomedatie'] . '';
}
function getUitslagen()
{
GLOBAL $ripper;
echo "<table border='0' cellpadding='0' cellspacing='0'>";
echo "<tr>";
echo "<td width='125'><b>Datum</b></td>";
echo "<td width='150'>Thuis</td>";
echo "<td align='left' width='150'>Uit</td>";
echo "<td align='left' width='50'>Uitslag</td>";
echo "</tr>";
foreach( $ripper->rip( 'stand' ) AS $key )
{
echo "<tr>";
echo "<td align='left'>".$key['datum']."</td>";
echo "<td align='left'>".$key['club1']."</td>";
echo "<td align='left'>".$key['club2']."</td>";
echo "<td align='left'>".$key['uitslag']."</td>";
echo "</tr>";
}
echo "</table>";
}
function getProgramma()
{
GLOBAL $ripper;
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>";
echo "<tr>";
echo "<td align='left' width='100'><b>Datum</b></td>";
echo "<td align='left' width='50'><b>Tijd</b></td>";
echo "<td align='left' width='250'><b>Wedstrijd</b></td>";
echo "<td align='left' width='250'><b>Accommodatie</b></td>";
echo "</tr>";
foreach( $ripper->rip( 'programma' ) AS $key )
{
echo "<tr>";
echo "<td align='left'>".$key['datum']."</td>";
echo "<td align='left'>".$key['tijd']."</td>";
echo "<td align='left'>".$key['teams']."</td>";
echo "<td align='left'>".$key['accomedatie']."</td>"; echo "</tr>";
}
echo "</table>";
}
function getStand()
{
GLOBAL $ripper;
echo "<table border='0' cellpadding='0' cellspacing='0'>";
echo "<tr>";
echo "<td width='30'>#</td>";
echo "<td width='150'>Elftal</td>";
echo "<td align='center' width='30'>G</td>";
echo "<td align='center' width='30'>W</td>";
echo "<td align='center' width='30'>GL</td>";
echo "<td align='center' width='30'>V</td>";
echo "<td align='center' width='30'>P</td>";
echo "<td align='center' width='50'>DPV</td>";
echo "<td align='center' width='50'>DPT</td>";
echo "<td align='center' width='30'>PM</td>";
echo "</tr>";
foreach( $ripper->rip( 'stand' ) AS $key )
{
echo "<tr>";
echo "<td>".$key['nummer']."</td>";
echo "<td>".$key['club']."</td>";
echo "<td align='center'>".$key['gespeeld']."</td>";
echo "<td align='center'>".$key['gewonnen']."</td>";
echo "<td align='center'>".$key['gelijk']."</td>";
echo "<td align='center'>".$key['verloren']."</td>";
echo "<td align='center'>".$key['punten']."</td>";
echo "<td align='center'>".$key['goals_voor']."</td>";
echo "<td align='center'>".$key['goals_tegen']."</td>";
echo "<td align='center'>".$key['punten_mindering']."</td>";
echo "</tr>";
}
echo "</table>";
}
?>
Gewijzigd op 01/01/1970 01:00:00 door Yannick
Krijg je gaan "parse error" meer dan weet je dat het ergens in die code zit.
Code (php)
regel 182 tot 189
Als je niet genoeg info heb heb je een probleem :P
eerst maak je een hele nette klasse vervolgs maak je waardeloze functies die gebruik maken van globals. Je bent op het einde een } vergeten!
Modedit:
Lees even de regels wat betreft plaatsen van code
Gewijzigd op 01/01/1970 01:00:00 door Yannick
Gokje: je hebt dit niet zelf geschreven.
misschien ergens een aantal print_r()'s die voor deze output zorgen?
Ik heb dit inderdaad niet zelf geschreven :P, dat was inderdaad de oplossing, dankjewel.
GLOBAL is echt iets uit 1950 inmiddels als je het mij vraagt....