corrade-http-templates – Rev 80
?pathlinks?
<?php
###########################################################################
## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ##
###########################################################################
## This is a script that reads a visitors log and generates a json ##
## object from the number of males and females that Corrade detected. ##
###########################################################################
###########################################################################
## CONFIGURATION ##
###########################################################################
# Visitors file.
$VISITOR_FILE = "visitors.log";
###########################################################################
## INTERNALS ##
###########################################################################
require_once('vendor/was/utilities/src/formats/csv/csv.php');
require_once('vendor/was/utilities/src/IO/IO.php');
$f = 0;
$m = 0;
array_walk(
explode(
PHP_EOL,
atomized_get_contents(
$VISITOR_FILE
)
),
function($e, $k) use(&$f, &$m) {
switch(wasCSVToArray($e)[1]) {
case 'female':
++$f;
break;
default:
++$m;
break;
}
}
);
header('content-type: application/json; charset=utf-8');
echo json_encode(
array(
"Male" => $m,
"Female" => $f
)
);