Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $start_date = strtotime('2021-04-23 00:00:00');
- $end_date = strtotime('2021-12-31 00:00:00');
- $fp = fopen(dirname(__FILE__) . "/test_actions.log", 'r');
- $cnt_total = 0; $cnt_unknown=0; $cnt_goal=0;
- $unique_ips = array();
- while(!feof($fp)){
- $str = fgets($fp);
- $cnt_total ++;
- if(count(($p = explode("\t", $str))) < 5){
- $cnt_unknown++;
- continue;
- }
- list($date_time, $_, $remote_adr, $cmd) = $p;
- #echo $date_time . "\t" . date("Y-m-d H:i:s", strtotime($date_time)) . "\n";
- if($cnt_total > 100) #exit;
- if($cmd !== 'subscribe'){
- continue;
- }
- $date_time = strtotime($date_time);
- if($date_time < $start_date or $date_time > $end_date){
- continue;
- }
- $cnt_goal++;
- if(!isset($unique_ips[$remote_adr])){
- $unique_ips[$remote_adr] = 0;
- }
- $unique_ips[$remote_adr] ++;
- #print_r($p); exit;
- #var_dump($str);
- #break;
- }
- fclose($fp);
- echo "Total lines processed: $cnt_total\n";
- echo "Total lines goal: $cnt_goal\n";
- if($cnt_unknown > 1){
- echo " \t- unknown lines: $cnt_unknown\t!!!\n";
- }
- echo "\n";
- echo "Unique IPs: ". count(array_keys($unique_ips)) . "\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement