-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprc.php
More file actions
31 lines (28 loc) · 783 Bytes
/
prc.php
File metadata and controls
31 lines (28 loc) · 783 Bytes
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
<?php
// Project4Dimensions: pageRetrievalCounter (prc)
// https://github.com/Project4Dimensions/pageRetrievalCounter
function prc()
{
$filename = basename($_SERVER['SCRIPT_FILENAME'], ".php") . ".num";
if (file_exists($filename)) {
if (intval(file_get_contents($filename)) === 0) {
$num = 1;
} else {
$num = intval(file_get_contents($filename)) + 1;
}
} else {
$num = 1;
}
try {
error_reporting(0);
if (file_put_contents($filename, $num, LOCK_EX) === FALSE) {
throw new Exception("err");
} else {
file_put_contents($filename, $num, LOCK_EX);
echo strval($num);
}
} catch (Exception $e) {
echo $e->getMessage();
}
}
?>