%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/var/lib/rrd/
Upload File :
Create Path :
Current File : //proc/self/root/var/lib/rrd/routerstats.php

<?php
include "/www/varak.net/practiscore.varak.net/lib/dibi.phar";
dibi::connect([
		'driver'   => 'sqlite3',
    	'charset'  => 'utf8',
		'database' => '/var/lib/rrd/routerstats-vladka2024.sqlite3',
	]);
header("Content-type: text/plain");

$data = json_decode(file_get_contents("/var/lib/rrd/routerstats.json"));
$cutoff = time() - 3600 * 24 * 60;

foreach($data as $iname => $ifc)
{
	$keysToUnset = array();
	foreach($ifc as $key => $date)
    {
        if(!strstr($key, "2016-") && !strstr($key, "2017-") && !strstr($key, "2018-") && !strstr($key, "2019-") && !strstr($key, "2020-") && !strstr($key, "2021-") && !strstr($key, "2022-") && !strstr($key, "2023-") && !strstr($key, "2024-") && !strstr($key, "2025-") && !strstr($key, "2026-")) continue;
        if(strtotime($key) > $cutoff) continue;

        $ins = array(
        	"interface" => $iname,
        	"date" => $key,
        	"transmit" => $date->transmit,
        	"receive" => $date->receive,
        );
        $keysToUnset[] = $key;

        dibi::query("INSERT INTO [traffic]", $ins);
        echo "$iname ==> $key \n";
    }
    foreach ($keysToUnset as $key) 
    {
    	unset($data->{$iname}->{$key});
    }
}

file_put_contents("/var/lib/rrd/routerstats.json", json_encode($data, JSON_PRETTY_PRINT));

Zerion Mini Shell 1.0