Wi-Fi
0
Вклад в тег
public function getUserTrafByThisDay(&$totalDay, &$totalIP) {
$thisdate = date('Y-m-d');
$handle1 = fopen($this->world.$thisdate, "r");
$handle2 = fopen($this->city.$thisdate, "r");
$sum['win'] = '0';
$sum['wout'] = '0';
$sum['cin'] = '0';
$sum['cout'] = '0';
while ($userinfo = fscanf($handle1, "%s\t%s\t%s\n")) {
$userByIp[$userinfo[0]]['win'] = $userinfo[1];
$userByIp[$userinfo[0]]['wout'] = $userinfo[2];
$sum['win'] = bcadd($sum['win'], $userinfo[1]);
$sum['wout'] = bcadd($sum['wout'], $userinfo[2]);
if (isset($totalIP[$userinfo[0]])) {
$totalIP[$userinfo[0]]['win'] = bcadd($totalIP[$userinfo[0]]['win'], $userinfo[1]);
$totalIP[$userinfo[0]]['wout'] = bcadd($totalIP[$userinfo[0]]['wout'], $userinfo[2]);
}
else {
$totalIP[$userinfo[0]]['win'] = $userinfo[1];
$totalIP[$userinfo[0]]['wout'] = $userinfo[2];
$totalIP[$userinfo[0]]['cin'] = '0';
$totalIP[$userinfo[0]]['cout'] = '0';
}
}
while ($userinfo = fscanf($handle2, "%s\t%s\t%s\n")) {
$userByIp[$userinfo[0]]['cin'] = $userinfo[1];
$userByIp[$userinfo[0]]['cout'] = $userinfo[2];
$sum['cin'] = bcadd($sum['cin'], $userinfo[1]);
$sum['cout'] = bcadd($sum['cout'], $userinfo[2]);
if (isset($totalIP[$userinfo[0]])) {
$totalIP[$userinfo[0]]['cin'] = bcadd($totalIP[$userinfo[0]]['cin'], $userinfo[1]);
$totalIP[$userinfo[0]]['cout'] = bcadd($totalIP[$userinfo[0]]['cout'], $userinfo[2]);
}
else {
$totalIP[$userinfo[0]]['cin'] = $userinfo[1];
$totalIP[$userinfo[0]]['cout'] = $userinfo[2];
}
}
fclose($handle1);
fclose($handle2);
$trafByDay[$thisdate] = $userByIp;
$totalDay[$thisdate] = $sum;
unset ($userByIp);
unset ($sum);
return $trafByDay;
}