Debian Codegraph @

etc/download_stats/eclipsestats-old.php

raw
1 <?php
2 $plugin = trim(isset($_GET["plugin"]) ? $_GET["plugin"] : "");
3 $version = trim(isset($_GET["version"]) ? $_GET["version"] : "");
4 if (strlen($plugin) > 0 && strlen($version) > 0) {
5 savestats($plugin, $version);
6 }
7 function savestats($plugin, $version) {
8 // File name/format:
9 // titan_eclipse_designer.txt titan_eclipse_logviewer.txt titan_eclipse_executor.txt
10 // version1 counter1
11 // version2 counter2
12 // ...
13 $filename = $plugin . ".txt";
14 $tmpfilename = $filename . ".tmp";
15 $tmp = fopen($tmpfilename, "w");
16 if (file_exists($filename)) {
17 $oldstats = file_get_contents($filename);
18 $lines = explode("\n", $oldstats);
19 foreach ($lines as $line) {
20 $data = explode(" ", $line);
21 if ($data[0] == $version) {
22 fputs($tmp, $version . " " . ((int)$data[1] + 1) . "\n");
23 } else {
24 fputs($tmp, $line);
25 }
26 }
27 } else {
28 fputs($version . "1\n");
29 }
30 fclose($tmp);
31 rename($tmpfilename, $filename);
32 }
33 ?>