forked from prachir1501/polarisv3dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
counter.php
43 lines (31 loc) · 1002 Bytes
/
counter.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
<?php
session_start();
function check_file($file_name , $def_val){
if(!file_exists($file_name))
{
$file = fopen($file_name , "w");
fwrite($file , $def_val);
fclose($file);
}
}
function incre_counter( $file_name){
$file = fopen($file_name , "r");
$counter = (int)fgets($file);;
$counter++;
fclose($file);
$file = fopen($file_name , "w");
fwrite($file , (string)$counter);
fclose($file);
}
check_file("/home/pramodh/counters/counter_uniq.txt" , "0");
check_file("/home/pramodh/counters/counter_visits.txt" , "0");
if(!isset($_SESSION['hasVisited']))
{
$_SESSION['hasVisited'] = "YES";
incre_counter("/home/pramodh/counters/counter_visits.txt");
incre_counter("/home/pramodh/counters/counter_uniq.txt");
}
else{
incre_counter("/home/pramodh/counters/counter_visits.txt");
}
?>