-
Notifications
You must be signed in to change notification settings - Fork 2
/
oldarchive.php
58 lines (44 loc) · 1.49 KB
/
oldarchive.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
<?php
// Output as text/plain
header('HTTP/1.1 200 OK');
header('Content-Type: text/plain; charset=utf-8');
require_once("../../../wp-config.php");
global $wpdb;
global $WTuser;
// Requires oldoutputclass
require_once( sprintf("%s/oldoutputclass.php",dirname(__FILE__)) );
$args = (object)$_REQUEST;
if ( ! property_exists($args,"date") | ! property_exists($args,"city") ) {
die("Input arguments missing, stop.");
}
$allcityObj = $WTuser->get_all_cityObj();
$cityObj = NULL; # Default, not yet found
foreach ( $allcityObj as $rec ) {
if ( strcmp($args->city,strtolower(substr($rec->get("hash"),0,1))) == 0 ) {
$cityObj = $rec; break;
}
}
// City not found?
if ( is_null($cityObj) ) {
die("Sorry, city could not have been found.");
}
if ( ! preg_match("/^[0-9]{6}$/",$args->date) ) {
die("Sorry, could not understand date input.");
}
# Convert date if possible
try {
$tdate = DateTime::createFromFormat('ymd', $args->date)->format("U");
$tdate = (int)floor($tdate / 86400);
} catch ( Expection $e ) {
die("Problems converting the input date to oldoutputObject. Stop.");
}
// Check if tdate was a tournament
$res = $wpdb->get_row(sprintf("SELECT status FROM %swetterturnier_dates WHERE tdate = %d",
$wpdb->prefix,$tdate));
if ( $wpdb->num_rows == 0 ) { exit("Sorry, no official tournament date."); }
if ( ! $res->status == 1 ) { exit("Sorry, no tournament date."); }
// Create new object
$obj = new wetterturnier_oldoutputObject( $cityObj, $tdate );
// Show archive table
$obj->show();
?>