I'm trying to filter some logs like I need them and tried to it dynamic. I have some domains and I'm trying to filter some things from it, and it all works like I want it - but now I changed the domain name and now my code doesn't work anymore. It says one variable isn't defined.
$sp_bots = shell_exec("grep bot | awk '{print $12}' /var/www/laravel/logs/vhosts/zahnmedizinisches-fachzentrum-berlin.de.log");
$array_sp_bots = explode("
", $sp_bots);
$all_bots = array();
foreach($array_sp_bots as $bots){
if(strpos($bots, "bot")){
$all_bots[] = $bots;
}
}
# count values of strings in array
if (!empty( $all_bots )) {
$bots = array_count_values($all_bots);
arsort($bots);
$mostOccuring = max(array_count_values($all_bots));
$bot_keys = array_keys($bots);
#number of total bots
$count_bots = count($all_bots);
}
and in my returns:
return view('/domains/data', [
'count_bots' => $count_bots,
'bot_keys' => $bot_keys,
'mostOccuring' => $mostOccuring,
]);
but all three variables in my return are undefined.. anybody knows why?