-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathleague_remote.php
59 lines (58 loc) · 2.03 KB
/
league_remote.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
<?php include("functions.php"); ?>
<?php include("func_update.php"); ?>
<?php
if($_SESSION['defaultSeason'])
{
$mysqli = new mysqli('DATABASE SERVER','DATABASE USERNAME','DATABASE PASSWORD','DATABASE NAME');
$mysqli->set_charset("utf8");
if ($_POST['forced']==1)
{
$query =
"SELECT
lpd.timestamp
FROM
latest_posting lpd
WHERE
type='league'
AND lpd.id='".addslashes($league_id)."'
";
$items = $mysqli->query($query) or die("Database Query Failed!");
$lpd = mysqli_fetch_array($items);
$difference = date('U') - $lpd['timestamp'];
//only accept a forced update every minute
if ($difference > 600)
{
if($_SESSION['id']==38596) echo "Accepting forced update<br>";
$session_update="now";
}
else
{
$fail = array("somearray" => array(6 => 5, 13 => 9, "a" => 42));
echo json_encode("fail".(10-(round($difference/60,2)))." minutes.</center>");
}
}
else
{
$query =
"SELECT
lpd.timestamp
FROM
latest_posting lpd
WHERE
type='league'
AND lpd.id='".addslashes($league_id)."'
";
$items = $mysqli->query($query) or die("Database Query Failed!");
$lpd = mysqli_fetch_array($items);
$difference = date('U') - $lpd['timestamp'];
if ($difference > $_SESSION['refreshTime'])
{
$session_update="now"; // greater than 24 hours then refresh
if($_SESSION['id']==38596) echo "LEAGUE: Longer than 24 hours so updating..<br>";
}
else $session_update="later";
}
$mysqli->close();
updateLeagueStats($league_id,$season_id,$session_update,$session_id,$session_username,$session_key,$_SESSION['buzzWebsite']); // update if logged in
}
?>