Add exams from exam58 to exam98
This commit is contained in:
36
exam92/FileBasedUniqueHC/count.php
Executable file
36
exam92/FileBasedUniqueHC/count.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
function hit_count(){
|
||||
|
||||
$ip_address = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
$ip_file = file('ip.txt');
|
||||
foreach($ip_file as $ip){
|
||||
$ip_single = trim($ip);
|
||||
if ($ip_address == $ip_single){
|
||||
$found = true;
|
||||
break;
|
||||
} else {
|
||||
$found = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if($found == true){
|
||||
$filename = 'count.txt';
|
||||
$handle = fopen($filename, 'r');
|
||||
$current = fread($handle, filesize($filename));
|
||||
fclose($handle);
|
||||
$current_inc = $current + 1;
|
||||
|
||||
$handle = fopen($filename, 'w');
|
||||
fwrite($handle,$current_inc);
|
||||
fclose($handle);
|
||||
|
||||
$handle = fopen('ip.txt', 'a');
|
||||
fwrite($handle, $ip_address."\n");
|
||||
fclose($handle);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
1
exam92/FileBasedUniqueHC/count.txt
Executable file
1
exam92/FileBasedUniqueHC/count.txt
Executable file
@@ -0,0 +1 @@
|
||||
7
|
||||
7
exam92/FileBasedUniqueHC/index.php
Executable file
7
exam92/FileBasedUniqueHC/index.php
Executable file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
include 'count.php';
|
||||
|
||||
hit_count();
|
||||
|
||||
?>
|
||||
7
exam92/FileBasedUniqueHC/ip.txt
Executable file
7
exam92/FileBasedUniqueHC/ip.txt
Executable file
@@ -0,0 +1,7 @@
|
||||
127.0.0.1
|
||||
127.0.0.1
|
||||
127.0.0.1
|
||||
127.0.0.1
|
||||
127.0.0.1
|
||||
127.0.0.1
|
||||
127.0.0.1
|
||||
Reference in New Issue
Block a user