aboutsummaryrefslogtreecommitdiff
path: root/Neutron-trunk/cms-special/admin-v2/stats/index.php
blob: 81b4b6989aa48aad33bc526a021c9a0d51354b2e (plain)
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
<?php require_once "../../../resources/private/relative.php"; getRelativeDetails("cms-special"); ?>
<?php $pageConfig = [ "domName" => "Statistiques", "headerName" => "Statistiques" ]; require_once $_SERVER['DOCUMENT_ROOT'] . "/cms-special/admin/\$resources/precontent.php"; ?>
<?php if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats")) { echo("<h2>" . $lang["admin-stats"]["new"] . "</h2><p>" . $lang["admin-stats"]["notice"] . "</p>"); } ?>
<?php

function gystat($year, $month, $showYear = false) {
    global $lang;

    if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/newstats/" . $year . "/" . $month)) {

        $files = scandir($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/newstats/" . $year . "/" . $month);
        $cmonth = 0;
        foreach ($files as $file) {
            if ($file != "." && $file != "..") {
                $count = count(explode("\n", trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/newstats/" . $year . "/" . $month . "/" . $file))));
                if ($count > 0) {
                    $cmonth = $cmonth + $count;
                }
            }
        }

        if ($cmonth > 0) {
            if ($cmonth > 1) {
                if ($showYear) {
                    echo("<tr><td><b>{$lang["admin-stats"]["months"][$month - 1]} {$year}{$lang["admin-stats"]["separator"]}</b></td><td> {$cmonth}</td><td> {$lang["admin-stats"]["visits2"]}</td></tr>");
                } else {
                    echo("<tr><td><b>{$lang["admin-stats"]["months"][$month - 1]}{$lang["admin-stats"]["separator"]}</b></td><td> {$cmonth}</td><td> {$lang["admin-stats"]["visits2"]}</td></tr>");
                }
            } else {
                if ($showYear) {
                    echo("<tr><td><b>{$lang["admin-stats"]["months"][$month - 1]} {$year}{$lang["admin-stats"]["separator"]}</b></td><td> {$cmonth}</td><td> {$lang["admin-stats"]["visit1"]}</td></tr>");
                } else {
                    echo("<tr><td><b>{$lang["admin-stats"]["months"][$month - 1]}{$lang["admin-stats"]["separator"]}</b></td><td> {$cmonth}</td><td> {$lang["admin-stats"]["visit1"]}</td></tr>");
                }
            }
        }
    }
}

?>
<h3><?= $lang["admin-stats"]["thisMonth"]?></h3>
<table>
    <tbody>
        <?php
        
        if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/newstats/" . date('Y') . "/" . date('m'))) {
            $mtxt = $lang["admin-stats"]["monthslc"][date('m') - 1];

            $files = scandir($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/newstats/" . date('Y') . "/" . date('m'));
            foreach ($files as $file) {
                if ($file != "." && $file != "..") {
                    $count = count(explode("\n", trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/newstats/" . date('Y') . "/" . date('m') . "/" . $file))));
                    if ($count > 0) {
                        $day = (int)trim($file);
                        if ($count > 1) {
                            echo("<tr><td><b>{$day} {$mtxt}{$lang["admin-stats"]["separator"]}</b></td><td> {$count}</td><td> {$lang["admin-stats"]["visits2"]}</td></tr>");
                        } else {
                            echo("<tr><td><b>{$day} {$mtxt}{$lang["admin-stats"]["separator"]}</b></td><td> {$count}</td><td> {$lang["admin-stats"]["visit1"]}</td></tr>");
                        }
                    }
                }
            }
        }

        ?>
    </tbody>
</table>

<h3><?= $lang["admin-stats"]["year"]?></h3>
<table>
    <tbody>
        <?php
        
        gystat(date('Y'), "01", false);
        gystat(date('Y'), "02", false);
        gystat(date('Y'), "03", false);
        gystat(date('Y'), "04", false);
        gystat(date('Y'), "05", false);
        gystat(date('Y'), "06", false);
        gystat(date('Y'), "07", false);
        gystat(date('Y'), "08", false);
        gystat(date('Y'), "09", false);
        gystat(date('Y'), "10", false);
        gystat(date('Y'), "11", false);
        gystat(date('Y'), "12", false);

        ?>
    </tbody>
</table>

<h3><?= $lang["admin-stats"]["last2"]?><?= date('Y') - 1 ?></h3>
<table>
    <tbody>
        <?php
        
        gystat(date('Y') - 1, "1", true);
        gystat(date('Y') - 1, "2", true);
        gystat(date('Y') - 1, "3", true);
        gystat(date('Y') - 1, "4", true);
        gystat(date('Y') - 1, "5", true);
        gystat(date('Y') - 1, "6", true);
        gystat(date('Y') - 1, "7", true);
        gystat(date('Y') - 1, "8", true);
        gystat(date('Y') - 1, "9", true);
        gystat(date('Y') - 1, "10", true);
        gystat(date('Y') - 1, "11", true);
        gystat(date('Y') - 1, "12", true);

        ?>
    </tbody>
</table>

<?php if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats")): ?> 
<hr style="border-top:none;">
<h2><?= $lang["admin-stats"]["old"] ?></h2>
<p><?= $lang["admin-stats"]["notice"] ?></p>
        <h3><?= $lang["admin-stats"]["thisMonth"]?></h3>
<table><tbody><?php

$dates = scandir($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats");
foreach ($dates as $date) {
    if ($date != "." && $date != "..") {
        if (startsWith($date, date("Y-m-"))) {
            $newdate = str_replace(date("Y-m-"), "", $date);
            $newdatestr = $newdate . date("/m/Y");
            echo("<tr><td><b>{$newdatestr}{$lang["admin-stats"]["separator"]}</b></td><td>" . file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $date) . "</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
        }
    }
}

?>
</tbody></table>
        <h3><?= $lang["admin-stats"]["year"] ?></h3>
        <table>
            <tbody>
                <?php

                $visits = [];
                $visits['01'] = 0;
                $visits['02'] = 0;
                $visits['03'] = 0;
                $visits['04'] = 0;
                $visits['05'] = 0;
                $visits['06'] = 0;
                $visits['07'] = 0;
                $visits['08'] = 0;
                $visits['09'] = 0;
                $visits['10'] = 0;
                $visits['11'] = 0;
                $visits['12'] = 0;
                $lists = scandir($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats");
                foreach ($lists as $list) {
                    if (startsWith($list, date("Y") . "-01")) {
                        $visits['01'] = $visits['01'] + (int)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $list);
                    }
                    if (startsWith($list, date("Y") . "-02")) {
                        $visits['02'] = $visits['02'] + (int)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $list);
                    }
                    if (startsWith($list, date("Y") . "-03")) {
                        $visits['03'] = $visits['03'] + (int)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $list);
                    }
                    if (startsWith($list, date("Y") . "-04")) {
                        $visits['04'] = $visits['04'] + (int)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $list);
                    }
                    if (startsWith($list, date("Y") . "-05")) {
                        $visits['05'] = $visits['05'] + (int)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $list);
                    }
                    if (startsWith($list, date("Y") . "-06")) {
                        $visits['06'] = $visits['06'] + (int)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $list);
                    }
                    if (startsWith($list, date("Y") . "-07")) {
                        $visits['07'] = $visits['07'] + (int)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $list);
                    }
                    if (startsWith($list, date("Y") . "-08")) {
                        $visits['08'] = $visits['08'] + (int)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $list);
                    }
                    if (startsWith($list, date("Y") . "-09")) {
                        $visits['09'] = $visits['09'] + (int)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $list);
                    }
                    if (startsWith($list, date("Y") . "-10")) {
                        $visits['10'] = $visits['10'] + (int)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $list);
                    }
                    if (startsWith($list, date("Y") . "-11")) {
                        $visits['11'] = $visits['11'] + (int)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $list);
                    }
                    if (startsWith($list, date("Y") . "-12")) {
                        $visits['12'] = $visits['12'] + (int)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $list);
                    }
                }

                echo("<tr><td><b>{$lang["admin-stats"]["months"][0]}{$lang["admin-stats"]["separator"]}</b></td><td>{$visits['01']}</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
                echo("<tr><td><b>{$lang["admin-stats"]["months"][1]}{$lang["admin-stats"]["separator"]}</b></td><td>{$visits['02']}</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
                echo("<tr><td><b>{$lang["admin-stats"]["months"][2]}{$lang["admin-stats"]["separator"]}</b></td><td>{$visits['03']}</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
                echo("<tr><td><b>{$lang["admin-stats"]["months"][3]}{$lang["admin-stats"]["separator"]}</b></td><td>{$visits['04']}</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
                echo("<tr><td><b>{$lang["admin-stats"]["months"][4]}{$lang["admin-stats"]["separator"]}</b></td><td>{$visits['05']}</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
                echo("<tr><td><b>{$lang["admin-stats"]["months"][5]}{$lang["admin-stats"]["separator"]}</b></td><td>{$visits['06']}</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
                echo("<tr><td><b>{$lang["admin-stats"]["months"][6]}{$lang["admin-stats"]["separator"]}</b></td><td>{$visits['07']}</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
                echo("<tr><td><b>{$lang["admin-stats"]["months"][7]}{$lang["admin-stats"]["separator"]}</b></td><td>{$visits['08']}</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
                echo("<tr><td><b>{$lang["admin-stats"]["months"][8]}{$lang["admin-stats"]["separator"]}</b></td><td>{$visits['09']}</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
                echo("<tr><td><b>{$lang["admin-stats"]["months"][9]}{$lang["admin-stats"]["separator"]}</b></td><td>{$visits['10']}</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
                echo("<tr><td><b>{$lang["admin-stats"]["months"][10]}{$lang["admin-stats"]["separator"]}</b></td><td>{$visits['11']}</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
                echo("<tr><td><b>{$lang["admin-stats"]["months"][11]}{$lang["admin-stats"]["separator"]}</b></td><td>{$visits['12']}</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
                ?>
            </tbody>
        </table>
        <h3><?= $lang["admin-stats"]["last"] ?></h3>
        <table>
            <tbody>
                <?php

                $visits = [];
                $visits['01'] = 0;
                $visits['02'] = 0;
                $visits['03'] = 0;
                $visits['04'] = 0;
                $visits['05'] = 0;
                $visits['06'] = 0;
                $visits['07'] = 0;
                $visits['08'] = 0;
                $visits['09'] = 0;
                $visits['10'] = 0;
                $visits['11'] = 0;
                $visits['12'] = 0;
                $lists = scandir($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats");
                foreach ($lists as $list) {
                    if (startsWith($list, ((int)date("Y") - 1) . "-01")) {
                        $visits['01'] = $visits['01'] + (int)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $list);
                    }
                    if (startsWith($list, ((int)date("Y") - 1) . "-02")) {
                        $visits['02'] = $visits['02'] + (int)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $list);
                    }
                    if (startsWith($list, ((int)date("Y") - 1) . "-03")) {
                        $visits['03'] = $visits['03'] + (int)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $list);
                    }
                    if (startsWith($list, ((int)date("Y") - 1) . "-04")) {
                        $visits['04'] = $visits['04'] + (int)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $list);
                    }
                    if (startsWith($list, ((int)date("Y") - 1) . "-05")) {
                        $visits['05'] = $visits['05'] + (int)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $list);
                    }
                    if (startsWith($list, ((int)date("Y") - 1) . "-06")) {
                        $visits['06'] = $visits['06'] + (int)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $list);
                    }
                    if (startsWith($list, ((int)date("Y") - 1) . "-07")) {
                        $visits['07'] = $visits['07'] + (int)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $list);
                    }
                    if (startsWith($list, ((int)date("Y") - 1) . "-08")) {
                        $visits['08'] = $visits['08'] + (int)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $list);
                    }
                    if (startsWith($list, ((int)date("Y") - 1) . "-09")) {
                        $visits['09'] = $visits['09'] + (int)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $list);
                    }
                    if (startsWith($list, ((int)date("Y") - 1) . "-10")) {
                        $visits['10'] = $visits['10'] + (int)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $list);
                    }
                    if (startsWith($list, ((int)date("Y") - 1) . "-11")) {
                        $visits['11'] = $visits['11'] + (int)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $list);
                    }
                    if (startsWith($list, ((int)date("Y") - 1) . "-12")) {
                        $visits['12'] = $visits['12'] + (int)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . $list);
                    }
                }

                echo("<tr><td><b>{$lang["admin-stats"]["months"][0]} " . ((int)date("Y") - 1) . "{$lang["admin-stats"]["separator"]}</b></td><td>{$visits['01']}</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
                echo("<tr><td><b>{$lang["admin-stats"]["months"][1]} " . ((int)date("Y") - 1) . "{$lang["admin-stats"]["separator"]}</b></td><td>{$visits['02']}</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
                echo("<tr><td><b>{$lang["admin-stats"]["months"][2]} " . ((int)date("Y") - 1) . "{$lang["admin-stats"]["separator"]}</b></td><td>{$visits['03']}</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
                echo("<tr><td><b>{$lang["admin-stats"]["months"][3]} " . ((int)date("Y") - 1) . "{$lang["admin-stats"]["separator"]}</b></td><td>{$visits['04']}</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
                echo("<tr><td><b>{$lang["admin-stats"]["months"][4]} " . ((int)date("Y") - 1) . "{$lang["admin-stats"]["separator"]}</b></td><td>{$visits['05']}</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
                echo("<tr><td><b>{$lang["admin-stats"]["months"][5]} " . ((int)date("Y") - 1) . "{$lang["admin-stats"]["separator"]}</b></td><td>{$visits['06']}</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
                echo("<tr><td><b>{$lang["admin-stats"]["months"][6]} " . ((int)date("Y") - 1) . "{$lang["admin-stats"]["separator"]}</b></td><td>{$visits['07']}</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
                echo("<tr><td><b>{$lang["admin-stats"]["months"][7]} " . ((int)date("Y") - 1) . "{$lang["admin-stats"]["separator"]}</b></td><td>{$visits['08']}</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
                echo("<tr><td><b>{$lang["admin-stats"]["months"][8]} " . ((int)date("Y") - 1) . "{$lang["admin-stats"]["separator"]}</b></td><td>{$visits['09']}</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
                echo("<tr><td><b>{$lang["admin-stats"]["months"][9]} " . ((int)date("Y") - 1) . "{$lang["admin-stats"]["separator"]}</b></td><td>{$visits['10']}</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
                echo("<tr><td><b>{$lang["admin-stats"]["months"][10]} " . ((int)date("Y") - 1) . "{$lang["admin-stats"]["separator"]}</b></td><td>{$visits['11']}</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
                echo("<tr><td><b>{$lang["admin-stats"]["months"][11]} " . ((int)date("Y") - 1) . "{$lang["admin-stats"]["separator"]}</b></td><td>{$visits['12']}</td><td> {$lang["admin-stats"]["visits"]}</td></tr>");
                ?>
            </tbody>
        </table>
        <?php endif; ?>
<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/cms-special/admin/\$resources/precontent.php"; ?>