-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlog.php
More file actions
112 lines (88 loc) · 2.05 KB
/
log.php
File metadata and controls
112 lines (88 loc) · 2.05 KB
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
<?php
include 'functions.php';
$json = file_get_contents('data.json');
$data = json_decode($json,1);
if(is_array($data))
{
krsort($data);
}
switch ($_GET['mode']) {
case "new":
$time = time();
$data[$time]['id'] = $time;
$data[$time]['name'] = $_GET['name'];
$data[$time]['date_start'] = $time;
$data[$time]['date_end'] = '';
$data[$time]['status'] = 1;
save($data);
break;
case "stop":
$id = $_GET['id'];
$data[$id]['date_end']=time();
save($data);
break;
case "remove":
$id = $_GET['id'];
$data[$id]['status']=2;
save($data);
break;
case "tally":
$total = 0;
if(is_array($data))
{
foreach ($data as $task) {
if($task['status']==1)
{
if($task['date_end']=="")
{
$total+=(time() - $task['date_start']);
}
else
{
$total+=($task['date_end'] - $task['date_start']);
}
}
}
}
echo timeNice($total);
break;
case "build":
if(is_array($data))
{
foreach ($data as $task) {
if($task['status']==1) {?>
<tr>
<td><?php echo $task['name']; ?></td>
<td>
<?php echo dateNice($task['date_start']); ?>
</td>
<td>
<?php
if($task['date_end']!="")
{
echo dateNice($task['date_end']);
}
?>
</td>
<td>
<?php
if($task['date_end']=="")
{
echo timeNice(time()-$task['date_start']);
}
else
{
echo timeNice($task['date_end'] - $task['date_start']);
}
?>
</td>
<td class="btn-col"><button data-id="<?php echo $task['id']; ?>" class="btn btn-primary btn-stop" <?php echo ($task['date_end'] == '')?:'disabled',''; ?> >Stop</button></td>
<td class="btn-col"><button data-id="<?php echo $task['id']; ?>" class="btn btn-danger btn-remove">X</button></td>
</tr>
<?php }}}
break;
default:
# code...
break;
}
?>