knvb-ripper-class
class.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
include 'class.socket.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]['thuis_club'] = $info[5];
$this -> output[$i]['uit_club'] = $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">Programma</td>', $contents);
preg_match_all('#<tr(.*?)>(\s+)(\s+)<td align="left" class="scoretd">(\d+.)</td>(\s+)<td align="left" class="scoretd">(.*?)</td>(\s+)<td align="center" class="scoretd">(\d+)</td>(\s+)<td align="center" class="scoretd">(\d+)</td>(\s+)<td align="center" class="scoretd">(\d+)</td>(\s+)<td align="center" class="scoretd">(\d+)</td>(\s+)<td align="center" class="scoretd"><b>(\d+)</b></td>(\s+)<td align="center" class="scoretd">(\d+)</td>(\s+)<td align="center" class="scoretd">(\d+)</td>(\s+)<td align="center" class="scoretd">(.*?)</td>(\s+)</tr>#si', $contents, $matches, PREG_SET_ORDER);
$this -> output = array();
$i = 0;
foreach($matches as $info)
{
$this -> output[$i]['eigenclub'] = (($info[1]) ? '1' : '');
$this -> output[$i]['nummer'] = $info[4];
$this -> output[$i]['club'] = $info[6];
$this -> output[$i]['gespeeld'] = $info[8];
$this -> output[$i]['gewonnen'] = $info[10];
$this -> output[$i]['gelijk'] = $info[12];
$this -> output[$i]['verloren'] = $info[14];
$this -> output[$i]['punten'] = $info[16];
$this -> output[$i]['goals_voor'] = $info[18];
$this -> output[$i]['goals_tegen'] = $info[20];
$this -> output[$i]['punten_mindering'] = $info[22];
$i++;
}
break;
case 'programma':
preg_match_all('#<tr( class="clubselectie")?>
include 'class.socket.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]['thuis_club'] = $info[5];
$this -> output[$i]['uit_club'] = $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">Programma</td>', $contents);
preg_match_all('#<tr(.*?)>(\s+)(\s+)<td align="left" class="scoretd">(\d+.)</td>(\s+)<td align="left" class="scoretd">(.*?)</td>(\s+)<td align="center" class="scoretd">(\d+)</td>(\s+)<td align="center" class="scoretd">(\d+)</td>(\s+)<td align="center" class="scoretd">(\d+)</td>(\s+)<td align="center" class="scoretd">(\d+)</td>(\s+)<td align="center" class="scoretd"><b>(\d+)</b></td>(\s+)<td align="center" class="scoretd">(\d+)</td>(\s+)<td align="center" class="scoretd">(\d+)</td>(\s+)<td align="center" class="scoretd">(.*?)</td>(\s+)</tr>#si', $contents, $matches, PREG_SET_ORDER);
$this -> output = array();
$i = 0;
foreach($matches as $info)
{
$this -> output[$i]['eigenclub'] = (($info[1]) ? '1' : '');
$this -> output[$i]['nummer'] = $info[4];
$this -> output[$i]['club'] = $info[6];
$this -> output[$i]['gespeeld'] = $info[8];
$this -> output[$i]['gewonnen'] = $info[10];
$this -> output[$i]['gelijk'] = $info[12];
$this -> output[$i]['verloren'] = $info[14];
$this -> output[$i]['punten'] = $info[16];
$this -> output[$i]['goals_voor'] = $info[18];
$this -> output[$i]['goals_tegen'] = $info[20];
$this -> output[$i]['punten_mindering'] = $info[22];
$i++;
}
break;
case 'programma':
preg_match_all('#<tr( class="clubselectie")?>
$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;
}
}
?>
class.socket.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
<?php
/*******************************************
* Socket Class Made By Lucas van Dijk
* * * * * * * * * * *
* This class can be used for ANYTHING related to socket
* programming.
*
* Includes some examples on how the socket class can be
* implented. (the HttpGetRequest and HttpPostRequest class)
* * * * * * * * * * *
* Revision 1.3
********************************************/
class Socket
{
/**
* @desc the main socket
* @scope protected
* @type resource
*/
var $socket;
/**
* @desc IP of the server
* @scope protected
* @type string
*/
var $ip;
/**
* @desc port of the server
* @scope protected
* @type int
*/
var $port;
/**
* @desc Timeout
* @scope protected
* @type int
*/
var $timeout;
/**
* @desc Contains an error message
* @scope protected
* @type string
*/
var $error;
/**
* @desc Contains the data returned
* @scope protected
* @type string
*/
var $contents;
/**
* @desc Constructor, inits some vars
* @scope
*/
function Socket()
{
$this -> reset();
}
/**
* @desc resets all vars
* @scope
*/
function reset()
{
$this -> timeout = 10;
$this -> ip = '';
$this -> port = 0;
$this -> contents = '';
}
/**
* @desc sets the IP and port
* @scope
* @param the IP
* @param the port
*/
function set_ip($ip, $port)
{
$this -> ip = (string) $ip;
$this -> port = (int) $port;
}
/**
* @desc sets the timeout
* @scope
* @param the timeout
*/
function set_timeout($timeout)
{
$this -> timeout = (int) $timeout;
}
/**
* @desc gets the error message
* @scope
* @return the error message
*/
function get_error()
{
return $this -> error;
}
/**
* @desc gets the data returned
* @scope
* @return the data
*/
function get_contents()
{
return $this -> contents;
}
/**
* @desc connects to the server
* @scope
* @return true on success else false
*/
function connect()
{
return $this -> socket = fsockopen($this -> ip, $this -> port, $errno, $this -> error, $this -> timeout);
}
/**
* @desc makes the actual request to the server
* @scope
* @param the request
* @return the contents returned by server, false on fail
*/
function request($request)
{
// Connect to IP and Port
$this -> connect();
// Check if connected
if(is_resource($this -> socket))
{
fwrite($this -> socket, $request);
// Get contents
$buffer = '';
while($buffer = fgets($this -> socket, 4096))
{
$this -> contents .= $buffer;
}
return $this -> contents;
}
else
{
// Error!
return false;
}
}
}
class HttpGetRequest extends Socket
{
/**
* @desc determines if we should include headers or not
* @scope protected
* @type boolean
*/
var $include_headers;
/**
* @desc determines if we should redirect, when a Location header was found
* @scope protected
* @type boolean
*/
var $redirect;
/**
* @desc an array with all the headers to be sent
* @scope protected
* @type array
*/
var $headers;
/**
* @desc the file to request
* @scope protected
* @type string
*/
var $file;
/**
* @desc an array with all cookies setted by the web page
* @scope protected
* @type array
*/
var $cookies;
/**
* @desc Cookies to set with the next request
* @scope protected
* @type array
*/
var $cookies_to_set;
/**
* @desc constructor, inits some vars
* @scope
*/
function HttpGetRequest()
{
$this -> reset();
}
/**
* @desc resets all vars
* @scope
*/
function reset()
{
$this -> timeout = 10;
$this -> include_headers = false;
$this -> redirect = true;
$this -> headers = array();
$this -> file = '';
$this -> cookies = array();
$this -> cookies_to_set = array();
$this -> redirect = true;
}
/**
* @desc sets if we include headers or not
* @scope
* @param true or false, should we include headers?
*/
function include_headers($yes_no = true)
{
$this -> include_headers = (bool) $yes_no;
}
/**
* @desc determines if we should redirect, when a Location header was found
* @scope
* @param true or false, should we redirect?
*/
function use_redirect($yes_no = true)
{
$this -> redirect = (bool) $yes_no;
}
/**
* @desc adds a header
* @scope
* @param the header
*/
function add_header($header)
{
$this -> headers[] = (string) $header."\r\n";
}
/**
* @desc set the file to request
* @scope
* @param the file
*/
function set_file($file)
{
$this -> file = (string) $file;
}
/**
* @desc gets the array woth cookies
* @scope
* @return array with all the cookies
*/
function get_cookies()
{
return $this -> cookies;
}
/**
* @desc send request to the webpage
* @scope
* @param the file
* @return the contents, or false on fail
*/
function request()
{
$contents = '';
// Connect to IP and Port
$this -> connect();
// Check if connected
if(is_resource($this -> socket))
{
// Build cookie header
$cookies = '';
foreach($this -> cookies_to_set as $name => $value)
{
$cookies .= $name."=".$value.";";
}
$this -> add_header("GET /".$this -> file." HTTP/1.1");
$this -> add_header("Host: ".$this -> ip);
$this -> add_header("Connection: Close");
$this -> add_header("User-Agent: Socket PHP class (incompatible; IE sucks)");
if(count($this -> cookies_to_set))
{
$this -> add_header("Cookie: ".$cookies);
}
$this -> add_header("");
$this -> contents = $this -> do_request();
$this -> headers = array();
$this -> grab_cookies();
return $this -> contents;
}
else
{
// Error!
return false;
}
}
/**
* @desc does the actual request, builds headers etc.
* @scope protected
* @return the content
*/
function do_request()
{
$contents = '';
// Build request to send
$request = '';
foreach($this -> headers as $header)
{
$request .= $header;
}
fwrite($this -> socket, $request);
if($this -> include_headers == false)
{
$line = '';
while(!($line == "\r\n"))
{
$line = fgets($this -> socket, 128);
if($this -> redirect)
{
if(preg_match("#Location\: (.*?)\\r\\n#si", $line, $matches))
{
$this -> set_file($matches[1]);
// Clear all headers
$this -> headers = array();
return $this -> request();
}
}
} // strip out the header
}
// Get contents
$buffer = '';
while($buffer = fgets($this -> socket, 4096))
{
$contents .= $buffer;
}
return $contents;
}
/**
* @desc gets the cookies setted by the webserver
* @scope protected
* @return array with the cookies
*/
function grab_cookies()
{
if($this -> include_headers)
{
preg_match_all("/Set-Cookie: (.*?)\r\n/si", $this -> contents, $matches, PREG_SET_ORDER);
foreach($matches as $match)
{
$cookie = explode(";", $match[1]);
list($cookie_name, $cookie_value) = explode("=", $cookie[0], 2);
$this -> cookies[urldecode($cookie_name)] = urldecode($cookie_value);
}
}
}
/**
* @desc sets a cookie
* @scope
* @param cookie name
* @param cookie value
*/
function set_cookie($cookie_name, $cookie_value)
{
$this -> cookies_to_set[$cookie_name] = $cookie_value;
}
/**
* @desc removes a cookie
* @scope
* @param cookie name
*/
function remove_cookie($cookie_name)
{
unset($this -> cookies_to_set[$cookie_name]);
}
/**
* @desc sets all cookies grabbed by grab_cookies();
* @scope
*/
function set_all_cookies()
{
foreach($this -> cookies as $name => $value)
{
$this -> set_cookie($name, $value);
}
}
}
class HttpPostRequest extends HttpGetRequest
{
/**
* @desc Post variables to send
* @scope protected
* @type array
*/
var $post_vars;
/**
* @desc Constructor, inits some vars
* @scope
*/
function HttpPostRequest()
{
$this -> reset();
}
/**
* @desc resets all vars
* @scope
*/
function reset()
{
$this -> post_vars = array();
$this -> timeout = 10;
$this -> include_headers = false;
$this -> redirect = true;
$this -> headers = array();
$this -> file = '';
$this -> cookies = array();
$this -> redirect = true;
}
/**
* @desc adds a post var
* @scope
* @param name of the var
* @param value of the var
*/
function add_var($name, $value)
{
$this -> post_vars[$name] = $value;
}
/**
* @desc makes the actual request to the webpage
* @scope
* @param the file
* @return the contents, or false on fail
*/
function request()
{
// Connect to IP and Port
$this -> connect();
// Check if connected
if(is_resource($this -> socket))
{
// Build post vars
$vars = '';
foreach($this -> post_vars as $name => $value)
{
$vars .= "&".$name."=".urlencode($value);
}
$vars = substr($vars, 1);
$this -> add_header("POST /".$this -> file." HTTP/1.1");
$this -> add_header("Host: ".$this -> ip);
$this -> add_header("Connection: Close");
$this -> add_header("User-Agent: Socket PHP class (incompatible; IE sucks)");
$this -> add_header("Content-type: application/x-www-form-urlencoded");
$this -> add_header("Content-Length: ".strlen($vars));
$this -> add_header('');
$this -> add_header($vars);
$this -> add_header('');
$this -> contents = $this -> do_request();
$this -> grab_cookies();
return $this -> contents;
}
else
{
// Error!
return false;
}
}
}
?>
/*******************************************
* Socket Class Made By Lucas van Dijk
* * * * * * * * * * *
* This class can be used for ANYTHING related to socket
* programming.
*
* Includes some examples on how the socket class can be
* implented. (the HttpGetRequest and HttpPostRequest class)
* * * * * * * * * * *
* Revision 1.3
********************************************/
class Socket
{
/**
* @desc the main socket
* @scope protected
* @type resource
*/
var $socket;
/**
* @desc IP of the server
* @scope protected
* @type string
*/
var $ip;
/**
* @desc port of the server
* @scope protected
* @type int
*/
var $port;
/**
* @desc Timeout
* @scope protected
* @type int
*/
var $timeout;
/**
* @desc Contains an error message
* @scope protected
* @type string
*/
var $error;
/**
* @desc Contains the data returned
* @scope protected
* @type string
*/
var $contents;
/**
* @desc Constructor, inits some vars
* @scope
*/
function Socket()
{
$this -> reset();
}
/**
* @desc resets all vars
* @scope
*/
function reset()
{
$this -> timeout = 10;
$this -> ip = '';
$this -> port = 0;
$this -> contents = '';
}
/**
* @desc sets the IP and port
* @scope
* @param the IP
* @param the port
*/
function set_ip($ip, $port)
{
$this -> ip = (string) $ip;
$this -> port = (int) $port;
}
/**
* @desc sets the timeout
* @scope
* @param the timeout
*/
function set_timeout($timeout)
{
$this -> timeout = (int) $timeout;
}
/**
* @desc gets the error message
* @scope
* @return the error message
*/
function get_error()
{
return $this -> error;
}
/**
* @desc gets the data returned
* @scope
* @return the data
*/
function get_contents()
{
return $this -> contents;
}
/**
* @desc connects to the server
* @scope
* @return true on success else false
*/
function connect()
{
return $this -> socket = fsockopen($this -> ip, $this -> port, $errno, $this -> error, $this -> timeout);
}
/**
* @desc makes the actual request to the server
* @scope
* @param the request
* @return the contents returned by server, false on fail
*/
function request($request)
{
// Connect to IP and Port
$this -> connect();
// Check if connected
if(is_resource($this -> socket))
{
fwrite($this -> socket, $request);
// Get contents
$buffer = '';
while($buffer = fgets($this -> socket, 4096))
{
$this -> contents .= $buffer;
}
return $this -> contents;
}
else
{
// Error!
return false;
}
}
}
class HttpGetRequest extends Socket
{
/**
* @desc determines if we should include headers or not
* @scope protected
* @type boolean
*/
var $include_headers;
/**
* @desc determines if we should redirect, when a Location header was found
* @scope protected
* @type boolean
*/
var $redirect;
/**
* @desc an array with all the headers to be sent
* @scope protected
* @type array
*/
var $headers;
/**
* @desc the file to request
* @scope protected
* @type string
*/
var $file;
/**
* @desc an array with all cookies setted by the web page
* @scope protected
* @type array
*/
var $cookies;
/**
* @desc Cookies to set with the next request
* @scope protected
* @type array
*/
var $cookies_to_set;
/**
* @desc constructor, inits some vars
* @scope
*/
function HttpGetRequest()
{
$this -> reset();
}
/**
* @desc resets all vars
* @scope
*/
function reset()
{
$this -> timeout = 10;
$this -> include_headers = false;
$this -> redirect = true;
$this -> headers = array();
$this -> file = '';
$this -> cookies = array();
$this -> cookies_to_set = array();
$this -> redirect = true;
}
/**
* @desc sets if we include headers or not
* @scope
* @param true or false, should we include headers?
*/
function include_headers($yes_no = true)
{
$this -> include_headers = (bool) $yes_no;
}
/**
* @desc determines if we should redirect, when a Location header was found
* @scope
* @param true or false, should we redirect?
*/
function use_redirect($yes_no = true)
{
$this -> redirect = (bool) $yes_no;
}
/**
* @desc adds a header
* @scope
* @param the header
*/
function add_header($header)
{
$this -> headers[] = (string) $header."\r\n";
}
/**
* @desc set the file to request
* @scope
* @param the file
*/
function set_file($file)
{
$this -> file = (string) $file;
}
/**
* @desc gets the array woth cookies
* @scope
* @return array with all the cookies
*/
function get_cookies()
{
return $this -> cookies;
}
/**
* @desc send request to the webpage
* @scope
* @param the file
* @return the contents, or false on fail
*/
function request()
{
$contents = '';
// Connect to IP and Port
$this -> connect();
// Check if connected
if(is_resource($this -> socket))
{
// Build cookie header
$cookies = '';
foreach($this -> cookies_to_set as $name => $value)
{
$cookies .= $name."=".$value.";";
}
$this -> add_header("GET /".$this -> file." HTTP/1.1");
$this -> add_header("Host: ".$this -> ip);
$this -> add_header("Connection: Close");
$this -> add_header("User-Agent: Socket PHP class (incompatible; IE sucks)");
if(count($this -> cookies_to_set))
{
$this -> add_header("Cookie: ".$cookies);
}
$this -> add_header("");
$this -> contents = $this -> do_request();
$this -> headers = array();
$this -> grab_cookies();
return $this -> contents;
}
else
{
// Error!
return false;
}
}
/**
* @desc does the actual request, builds headers etc.
* @scope protected
* @return the content
*/
function do_request()
{
$contents = '';
// Build request to send
$request = '';
foreach($this -> headers as $header)
{
$request .= $header;
}
fwrite($this -> socket, $request);
if($this -> include_headers == false)
{
$line = '';
while(!($line == "\r\n"))
{
$line = fgets($this -> socket, 128);
if($this -> redirect)
{
if(preg_match("#Location\: (.*?)\\r\\n#si", $line, $matches))
{
$this -> set_file($matches[1]);
// Clear all headers
$this -> headers = array();
return $this -> request();
}
}
} // strip out the header
}
// Get contents
$buffer = '';
while($buffer = fgets($this -> socket, 4096))
{
$contents .= $buffer;
}
return $contents;
}
/**
* @desc gets the cookies setted by the webserver
* @scope protected
* @return array with the cookies
*/
function grab_cookies()
{
if($this -> include_headers)
{
preg_match_all("/Set-Cookie: (.*?)\r\n/si", $this -> contents, $matches, PREG_SET_ORDER);
foreach($matches as $match)
{
$cookie = explode(";", $match[1]);
list($cookie_name, $cookie_value) = explode("=", $cookie[0], 2);
$this -> cookies[urldecode($cookie_name)] = urldecode($cookie_value);
}
}
}
/**
* @desc sets a cookie
* @scope
* @param cookie name
* @param cookie value
*/
function set_cookie($cookie_name, $cookie_value)
{
$this -> cookies_to_set[$cookie_name] = $cookie_value;
}
/**
* @desc removes a cookie
* @scope
* @param cookie name
*/
function remove_cookie($cookie_name)
{
unset($this -> cookies_to_set[$cookie_name]);
}
/**
* @desc sets all cookies grabbed by grab_cookies();
* @scope
*/
function set_all_cookies()
{
foreach($this -> cookies as $name => $value)
{
$this -> set_cookie($name, $value);
}
}
}
class HttpPostRequest extends HttpGetRequest
{
/**
* @desc Post variables to send
* @scope protected
* @type array
*/
var $post_vars;
/**
* @desc Constructor, inits some vars
* @scope
*/
function HttpPostRequest()
{
$this -> reset();
}
/**
* @desc resets all vars
* @scope
*/
function reset()
{
$this -> post_vars = array();
$this -> timeout = 10;
$this -> include_headers = false;
$this -> redirect = true;
$this -> headers = array();
$this -> file = '';
$this -> cookies = array();
$this -> redirect = true;
}
/**
* @desc adds a post var
* @scope
* @param name of the var
* @param value of the var
*/
function add_var($name, $value)
{
$this -> post_vars[$name] = $value;
}
/**
* @desc makes the actual request to the webpage
* @scope
* @param the file
* @return the contents, or false on fail
*/
function request()
{
// Connect to IP and Port
$this -> connect();
// Check if connected
if(is_resource($this -> socket))
{
// Build post vars
$vars = '';
foreach($this -> post_vars as $name => $value)
{
$vars .= "&".$name."=".urlencode($value);
}
$vars = substr($vars, 1);
$this -> add_header("POST /".$this -> file." HTTP/1.1");
$this -> add_header("Host: ".$this -> ip);
$this -> add_header("Connection: Close");
$this -> add_header("User-Agent: Socket PHP class (incompatible; IE sucks)");
$this -> add_header("Content-type: application/x-www-form-urlencoded");
$this -> add_header("Content-Length: ".strlen($vars));
$this -> add_header('');
$this -> add_header($vars);
$this -> add_header('');
$this -> contents = $this -> do_request();
$this -> grab_cookies();
return $this -> contents;
}
else
{
// Error!
return false;
}
}
}
?>
index.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
<?php
ob_start();
## Login gegevens voor KNVB.nl
$Email = '';
$Wachtwoord = '';
## Team gegevens
## URL: link naar de statistieken van een team, zonder http://www.knvb.nl/ ervoor.
## Naam: naam van het team.
## Titel: naam van het team zoals het in het menutje weergegeven moet worden.
## Clubnaam: : naam van het team zoals weergegeven op de knvb site.
$Team = array ( array ( 'URL' => 'clubs_comp/real_time?action=teamDetails&ClubName=Monnickendam&NotationDescription=0212%20Mannen%20%20Zaterdag%20standaard&LevelDescription=2e%20klasse%20A&CompetitionType=0212&ClassLevel=12&RegionCode=KNVB-DISTRICT-WEST1&Pool=A&TeamDescription=&CompNummer=W1-0212**-12-148881!',
'Naam' => 'Monnickendam, 0212 Mannen Zaterdag standaard , 2e klasse A ',
'Titel' => '',
'Clubnaam' => '' ),
array ( 'URL' => 'clubs_comp/team_standen?club_id=BBFW684&team_id=123328&comp_id=W1-0213**-12-148883!',
'Naam' => ' ',
'Titel' => '',
'Clubnaam' => '' ),
);
include( 'class.knvb.php' );
if ( !isset ( $_GET [ 'team' ] ) || !isset ( $Team [ $_GET [ 'team' ] ] ) )
$_GET [ 'team' ] = 0;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>VVMonnickendam<?php echo $Team [ $_GET [ 'team' ] ][ 'Titel' ]; ?></title>
<style type="text/css">
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 12pt;
text-align: center;
}
a {
color: #000;
text-decoration: none;
}
a:hover {
color: #390;
text-decoration: underline;
}
h2 {
margin: 15px 20px;
font-size: 16pt;
text-align: center;
}
table {
margin: 0 auto;
}
table.stand {
padding: 0px;
width: 600px;
}
table.stand th, table.uitslagen th, table.programma th {
background: #6297DA;
color: #fff;
font-family: Arial, Helvetica, sans-serif;
font-size:12px;
color:#000000;
}
table.stand th, table.stand td {
padding: 3px;
border-right: #000 1px solid;
border-bottom: #000 1px solid;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
font-size:12px;
color:#000000;
}
table.uitslagen {
padding: 0px;
width: 600px;
font-family: Arial, Helvetica, sans-serif;
font-size:12px;
color:#000000;
}
table.programma {
padding: 0px;
width: 700px;
font-family: Arial, Helvetica, sans-serif;
font-size:12px;
color:#000000;
}
table.uitslagen th, table.uitslagen td, table.programma th, table.programma td {
padding: 3px;
border-right: #000 1px solid;
border-bottom: #000 1px solid;
text-align: left;
}
</style>
</head>
<body>
<?php
if ( sizeof ( $Team ) > 1 ) {
foreach ( $Team as $Key => $Value ) {
if ( $Key > 0 )
echo " | \n";
if ( $Key == $_GET [ 'team' ] )
echo "\t\t<b>" . $Value [ 'Titel' ] . '</b>';
else
echo "\t\t<a href=\"?team=" . $Key . '">' . $Value [ 'Titel' ] . '</a>';
}
}
$ripper = new KnvbRipper ( $Email, $Wachtwoord, $Team [ $_GET [ 'team' ] ][ 'URL' ], 'programma' );
?>
<h2>Wedstrijden</h2>
<table align="center" cellpadding="0" cellspacing="1" class="programma">
<tr>
<th>Datum</th>
<th>Tijd</th>
<th>Thuis Club</th>
<th>Uit Club</th>
<th>Accomedatie</th>
</tr>
<?php
$Programma = $ripper -> rip ( );
foreach ( $Programma as $Programma ) {
if ( eregi ( $Team [ $_GET [ 'team' ] ][ 'Naam' ], $Programma [ 'thuis_club' ] ) || eregi ( $Team [ $_GET [ 'team' ] ][ 'Naam' ], $Programma [ 'uit_club' ] ) )
{
echo "\t\t\t<tr style=\"background: #eee; font-weight: bold;\">\n";
}
else
echo "\t\t\t<tr>\n";
?>
<td><?php echo $Programma [ 'datum' ]; ?></td>
<td><?php echo $Programma [ 'tijd' ]; ?></td>
<td><?php echo str_replace ( $Team [ $_GET [ 'team' ] ][ 'Naam' ], '<b>' . $Team [ $_GET [ 'team' ] ][ 'Naam' ] . '</b>', $Programma [ 'thuis_club' ] ); ?></td>
<td><?php echo str_replace ( $Team [ $_GET [ 'team' ] ][ 'Naam' ], '<b>' . $Team [ $_GET [ 'team' ] ][ 'Naam' ] . '</b>', $Programma [ 'uit_club' ] ); ?></td>
<td><?php echo $Programma [ 'accomedatie' ]; ?></td>
</tr>
<?php
}
if( sizeof( $Programma ) == 0 ) {
?>
<tr>
<td colspan="5" style="text-align: center;">Er is momenteel geen programma bekend!</td>
</tr>
<?php
}
?>
</table>
<h2>Uitslagen</h2>
<table cellpadding="0" cellspacing="1" class="uitslagen">
<tr>
<th>Datum</th>
<th>Thuis Club</th>
<th>Uit Club</th>
<th>Uitslag</th>
</tr>
<?php
$Uitslagen = $ripper -> rip ( 'uitslagen' );
foreach ( $Uitslagen as $Uitslag ) {
if ( eregi ( $Team [ $_GET [ 'team' ] ][ 'Naam' ], $Uitslag [ 'thuis_club' ] ) || eregi ( $Team [ $_GET [ 'team' ] ][ 'Naam' ], $Uitslag [ 'uit_club' ] ) )
echo "\t\t\t<tr style=\"background: #eee; font-weight: bold;\">\n";
else
echo "\t\t\t<tr>\n";
?>
<td><?php echo $Uitslag [ 'datum' ]; ?></td>
<td><?php echo $Uitslag [ 'thuis_club' ]; ?></td>
<td><?php echo $Uitslag [ 'uit_club' ]; ?></td>
<td><?php echo $Uitslag [ 'uitslag' ]; ?></td>
</tr>
<?php
}
if( sizeof( $Uitslagen ) == 0 ) {
?>
<tr>
<td colspan="4" style="text-align: center;">Er zijn momenteel geen uitslagen bekend!</td>
</tr>
<?php
}
?>
</table>
<h2>Stand</h2>
<table cellpadding="0" cellspacing="1" class="stand">
<tr>
<th>#</th>
<th style="text-align: left;">Club</th>
<th>G</th>
<th>W</th>
<th>GL</th>
<th>V</th>
<th>P</th>
<th>VP</th>
<th>DPV</th>
<th>DPT</th>
<th>DS</th>
<th>PM</th>
</tr>
<?php
$Stand = $ripper -> rip ( 'stand' );
foreach ( $Stand as $Stand ) {
if ( eregi ( $Team [ $_GET [ 'team' ] ][ 'Clubnaam' ], $Stand [ 'club' ] ) )
echo "\t\t\t<tr style=\"background: #cccccc; font-weight: bold;\">\n";
else
echo "\t\t\t<tr>\n";
?>
<td><?php echo $Stand [ 'nummer' ]; ?></td>
<td style="text-align: left;"><?php echo $Stand [ 'club' ]; ?></td>
<td><?php echo $Stand [ 'gespeeld' ]; ?></td>
<td><?php echo $Stand [ 'gewonnen' ]; ?></td>
<td><?php echo $Stand [ 'gelijk' ]; ?></td>
<td><?php echo $Stand [ 'verloren' ]; ?></td>
<td><?php echo $Stand [ 'punten' ]; ?></td>
<td><?php echo ( ( $Stand [ 'gelijk' ] * 2 ) + ( $Stand [ 'verloren' ] * 3 ) ); ?></td>
<td><?php echo $Stand [ 'goals_voor' ]; ?></td>
<td><?php echo $Stand [ 'goals_tegen' ]; ?></td>
<td><?php echo ( $Stand [ 'goals_voor' ] - $Stand [ 'goals_tegen' ] ); ?></td>
<td><?php echo $Stand [ 'punten_mindering' ]; ?></td>
</tr>
<?php
}
if( sizeof( $Stand ) == 0 ) {
header("location: index.php");
?>
<tr>
<td colspan="12" style=\"text-align: center;\">Er is momenteel geen stand bekend!</td>
</tr>
<?php
}
?>
<tr>
<td style="border: none;" colspan="12">
<b>G</b>: gespeeld | <b>W</b>: gewonnen | <b>GL</b>: gelijk | <b>V</b>: verloren | <b>P</b>: punten | <b>VP</b>: verlies punten<br />
<b>DPV</b>: doelpunten voor | <b>DPT</b>: doelpunten tegen | <b>DS</b>: doelsaldo | <b>PM</b>: punten in mindering
</td>
</tr>
</table>
</body>
</html>
<?php
ob_end_flush();
?>
ob_start();
## Login gegevens voor KNVB.nl
$Email = '';
$Wachtwoord = '';
## Team gegevens
## URL: link naar de statistieken van een team, zonder http://www.knvb.nl/ ervoor.
## Naam: naam van het team.
## Titel: naam van het team zoals het in het menutje weergegeven moet worden.
## Clubnaam: : naam van het team zoals weergegeven op de knvb site.
$Team = array ( array ( 'URL' => 'clubs_comp/real_time?action=teamDetails&ClubName=Monnickendam&NotationDescription=0212%20Mannen%20%20Zaterdag%20standaard&LevelDescription=2e%20klasse%20A&CompetitionType=0212&ClassLevel=12&RegionCode=KNVB-DISTRICT-WEST1&Pool=A&TeamDescription=&CompNummer=W1-0212**-12-148881!',
'Naam' => 'Monnickendam, 0212 Mannen Zaterdag standaard , 2e klasse A ',
'Titel' => '',
'Clubnaam' => '' ),
array ( 'URL' => 'clubs_comp/team_standen?club_id=BBFW684&team_id=123328&comp_id=W1-0213**-12-148883!',
'Naam' => ' ',
'Titel' => '',
'Clubnaam' => '' ),
);
include( 'class.knvb.php' );
if ( !isset ( $_GET [ 'team' ] ) || !isset ( $Team [ $_GET [ 'team' ] ] ) )
$_GET [ 'team' ] = 0;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>VVMonnickendam<?php echo $Team [ $_GET [ 'team' ] ][ 'Titel' ]; ?></title>
<style type="text/css">
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 12pt;
text-align: center;
}
a {
color: #000;
text-decoration: none;
}
a:hover {
color: #390;
text-decoration: underline;
}
h2 {
margin: 15px 20px;
font-size: 16pt;
text-align: center;
}
table {
margin: 0 auto;
}
table.stand {
padding: 0px;
width: 600px;
}
table.stand th, table.uitslagen th, table.programma th {
background: #6297DA;
color: #fff;
font-family: Arial, Helvetica, sans-serif;
font-size:12px;
color:#000000;
}
table.stand th, table.stand td {
padding: 3px;
border-right: #000 1px solid;
border-bottom: #000 1px solid;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
font-size:12px;
color:#000000;
}
table.uitslagen {
padding: 0px;
width: 600px;
font-family: Arial, Helvetica, sans-serif;
font-size:12px;
color:#000000;
}
table.programma {
padding: 0px;
width: 700px;
font-family: Arial, Helvetica, sans-serif;
font-size:12px;
color:#000000;
}
table.uitslagen th, table.uitslagen td, table.programma th, table.programma td {
padding: 3px;
border-right: #000 1px solid;
border-bottom: #000 1px solid;
text-align: left;
}
</style>
</head>
<body>
<?php
if ( sizeof ( $Team ) > 1 ) {
foreach ( $Team as $Key => $Value ) {
if ( $Key > 0 )
echo " | \n";
if ( $Key == $_GET [ 'team' ] )
echo "\t\t<b>" . $Value [ 'Titel' ] . '</b>';
else
echo "\t\t<a href=\"?team=" . $Key . '">' . $Value [ 'Titel' ] . '</a>';
}
}
$ripper = new KnvbRipper ( $Email, $Wachtwoord, $Team [ $_GET [ 'team' ] ][ 'URL' ], 'programma' );
?>
<h2>Wedstrijden</h2>
<table align="center" cellpadding="0" cellspacing="1" class="programma">
<tr>
<th>Datum</th>
<th>Tijd</th>
<th>Thuis Club</th>
<th>Uit Club</th>
<th>Accomedatie</th>
</tr>
<?php
$Programma = $ripper -> rip ( );
foreach ( $Programma as $Programma ) {
if ( eregi ( $Team [ $_GET [ 'team' ] ][ 'Naam' ], $Programma [ 'thuis_club' ] ) || eregi ( $Team [ $_GET [ 'team' ] ][ 'Naam' ], $Programma [ 'uit_club' ] ) )
{
echo "\t\t\t<tr style=\"background: #eee; font-weight: bold;\">\n";
}
else
echo "\t\t\t<tr>\n";
?>
<td><?php echo $Programma [ 'datum' ]; ?></td>
<td><?php echo $Programma [ 'tijd' ]; ?></td>
<td><?php echo str_replace ( $Team [ $_GET [ 'team' ] ][ 'Naam' ], '<b>' . $Team [ $_GET [ 'team' ] ][ 'Naam' ] . '</b>', $Programma [ 'thuis_club' ] ); ?></td>
<td><?php echo str_replace ( $Team [ $_GET [ 'team' ] ][ 'Naam' ], '<b>' . $Team [ $_GET [ 'team' ] ][ 'Naam' ] . '</b>', $Programma [ 'uit_club' ] ); ?></td>
<td><?php echo $Programma [ 'accomedatie' ]; ?></td>
</tr>
<?php
}
if( sizeof( $Programma ) == 0 ) {
?>
<tr>
<td colspan="5" style="text-align: center;">Er is momenteel geen programma bekend!</td>
</tr>
<?php
}
?>
</table>
<h2>Uitslagen</h2>
<table cellpadding="0" cellspacing="1" class="uitslagen">
<tr>
<th>Datum</th>
<th>Thuis Club</th>
<th>Uit Club</th>
<th>Uitslag</th>
</tr>
<?php
$Uitslagen = $ripper -> rip ( 'uitslagen' );
foreach ( $Uitslagen as $Uitslag ) {
if ( eregi ( $Team [ $_GET [ 'team' ] ][ 'Naam' ], $Uitslag [ 'thuis_club' ] ) || eregi ( $Team [ $_GET [ 'team' ] ][ 'Naam' ], $Uitslag [ 'uit_club' ] ) )
echo "\t\t\t<tr style=\"background: #eee; font-weight: bold;\">\n";
else
echo "\t\t\t<tr>\n";
?>
<td><?php echo $Uitslag [ 'datum' ]; ?></td>
<td><?php echo $Uitslag [ 'thuis_club' ]; ?></td>
<td><?php echo $Uitslag [ 'uit_club' ]; ?></td>
<td><?php echo $Uitslag [ 'uitslag' ]; ?></td>
</tr>
<?php
}
if( sizeof( $Uitslagen ) == 0 ) {
?>
<tr>
<td colspan="4" style="text-align: center;">Er zijn momenteel geen uitslagen bekend!</td>
</tr>
<?php
}
?>
</table>
<h2>Stand</h2>
<table cellpadding="0" cellspacing="1" class="stand">
<tr>
<th>#</th>
<th style="text-align: left;">Club</th>
<th>G</th>
<th>W</th>
<th>GL</th>
<th>V</th>
<th>P</th>
<th>VP</th>
<th>DPV</th>
<th>DPT</th>
<th>DS</th>
<th>PM</th>
</tr>
<?php
$Stand = $ripper -> rip ( 'stand' );
foreach ( $Stand as $Stand ) {
if ( eregi ( $Team [ $_GET [ 'team' ] ][ 'Clubnaam' ], $Stand [ 'club' ] ) )
echo "\t\t\t<tr style=\"background: #cccccc; font-weight: bold;\">\n";
else
echo "\t\t\t<tr>\n";
?>
<td><?php echo $Stand [ 'nummer' ]; ?></td>
<td style="text-align: left;"><?php echo $Stand [ 'club' ]; ?></td>
<td><?php echo $Stand [ 'gespeeld' ]; ?></td>
<td><?php echo $Stand [ 'gewonnen' ]; ?></td>
<td><?php echo $Stand [ 'gelijk' ]; ?></td>
<td><?php echo $Stand [ 'verloren' ]; ?></td>
<td><?php echo $Stand [ 'punten' ]; ?></td>
<td><?php echo ( ( $Stand [ 'gelijk' ] * 2 ) + ( $Stand [ 'verloren' ] * 3 ) ); ?></td>
<td><?php echo $Stand [ 'goals_voor' ]; ?></td>
<td><?php echo $Stand [ 'goals_tegen' ]; ?></td>
<td><?php echo ( $Stand [ 'goals_voor' ] - $Stand [ 'goals_tegen' ] ); ?></td>
<td><?php echo $Stand [ 'punten_mindering' ]; ?></td>
</tr>
<?php
}
if( sizeof( $Stand ) == 0 ) {
header("location: index.php");
?>
<tr>
<td colspan="12" style=\"text-align: center;\">Er is momenteel geen stand bekend!</td>
</tr>
<?php
}
?>
<tr>
<td style="border: none;" colspan="12">
<b>G</b>: gespeeld | <b>W</b>: gewonnen | <b>GL</b>: gelijk | <b>V</b>: verloren | <b>P</b>: punten | <b>VP</b>: verlies punten<br />
<b>DPV</b>: doelpunten voor | <b>DPT</b>: doelpunten tegen | <b>DS</b>: doelsaldo | <b>PM</b>: punten in mindering
</td>
</tr>
</table>
</body>
</html>
<?php
ob_end_flush();
?>