-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.php
69 lines (57 loc) · 1.29 KB
/
config.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
<?
$config = array(
'base' => '/Users/lweber/Sites/armor',
'users' => array()
);
// Get da datas
if(file_exists($config['base'].'/model/data.csv'))
{
$file = fopen($config['base'].'/model/data.csv', 'r');
$tries = 1;
while(!$file && $tries<5)
{
$file = fopen($config['base'].'/model/data.csv', 'r');
$tries++;
}
if($tries == 5)
{
die("Unable to open file: {$logFile}");
}
if($file)
{
$count = -2;
while(($row = fgetcsv($file)) !== false)
{
$count++;
if($count === -1 || $row[0] == "") continue;
$config['users'][$count]['name'] = $row[0];
$config['users'][$count]['serve_accuracy'] = $row[1];
$config['users'][$count]['serve_spin'] = $row[2];
$config['users'][$count]['return_skill'] = $row[3];
$config['users'][$count]['return_accuracy'] = $row[4];
$config['users'][$count]['return_spin'] = $row[5];
$config['users'][$count]['notes'] = $row[6];
}
fclose($file);
}
}
else
{
die("Datas Not Found");
}
$file = fopen($config['base'].'/model/users.json', 'w');
$tries = 1;
while(!$file && $tries<5)
{
$file = fopen($config['base'].'/model/users.json', 'w');
$tries++;
}
if($tries == 5)
{
die("Unable to open file: {$logFile}");
}
$contents = json_encode($config['users']);
fwrite($file,$contents);
fflush($file);
fclose($file)
?>