-
Notifications
You must be signed in to change notification settings - Fork 0
/
memberRefresh.php
58 lines (42 loc) · 1.42 KB
/
memberRefresh.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
/*
* Copyright (C) 2011 Ryan Holmes
* <http://www.gnu.org/licenses/agpl.html>
*/
$cfg = parse_ini_file('../inc/config.ini');
function __autoload($name) {
include '../classes/'.$name.'.class.php'; }
try {
$DB = new DB(parse_ini_file($cfg['secret_file']));
}
catch ( PDOException $e ) {
echo 'Database connection failed. PDOException:';
echo $e->getMessage();
die('=/');
}
$apiDetails = parse_ini_file($cfg['api_file']);
$memberURL = "http://api.eve-online.com/corp/MemberTracking.xml.aspx?keyID=$apiDetails[keyID]&vCode=$apiDetails[vCode]&extended=1";
unset($apiDeatils);
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$data = get_data($memberURL);
if (!$data) { exit; } // if failed (server is offline or whatever), just stop. Otherwise, Member List would be deleted and replaced with nothing.
$members = new SimpleXMLElement($data);
$membersNew = array();
$DB->query('TRUNCATE TABLE `memberList`');
foreach($members->result->rowset->row AS $member) {
$name = (string)$member['name'];
$id = (string)$member['characterID'];
$roles = (string)$member['roles'];
$DB->ea("INSERT INTO `memberList` (`charID`, `name`, `roles`) VALUES (?, ?, ?)", array($id, $name, $roles));
}
echo 'Member list refreshed.';
?>