} } if (!$ok) { // Merging the new value in the old vcard. $collectedNames[$fn]->add(clone $newProp); $ok = true; $stats['Merged values']++; } } } if (!$ok) { // echo $newProp->serialize() . " does not appear in earlier vcard!\n"; $stats['Error']++; if ($debug) { fwrite($debug, "Missing '" . $newProp->name . "' property in duplicate. Earlier vcard:\n" . $collectedNames[$fn]->serialize() . "\n\nLater:\n" . $vcard->serialize() . "\n\n"); } $vcard->destroy(); continue 2; } } } $vcard->destroy(); $stats['Ignored duplicates']++; } foreach ($collectedNames as $vcard) { // Overwriting any old PRODID $vcard->PRODID = '-//Sabre//Sabre VObject ' . Version::VERSION . '//EN'; write($vcard); writeStats(); } echo str_repeat("\n", count($stats)), "\nDone.\n";
exit; } // Create a new set of stats snapshot files if (isset($_GET['new'])) { $packets = array(); $bytes = array(); // Create variables to let us later quickly access this data if (is_array($data)) { foreach ($data as $row) { $packets[$row['srcip']][$row['srcport']][$row['dstip']][$row['dstport']][$row['protocol']] = $row['packets']; $bytes[$row['srcip']][$row['srcport']][$row['dstip']][$row['dstport']][$row['protocol']] = $row['bytes']; } } // Write the files out writeStats("packets", $packets); writeStats("bytes", $bytes); // If we're in view mode, pass that on. if (isset($_GET['view'])) { $filterPassThru .= "&view=1"; } // Redirect so we don't hit "new" every time we refresh the screen. header("Location: diag_new_states.php?&order=bytes&sort=des" . $filterPassThru); exit; } // View the delta from the last snapshot against the current data. if (isset($_GET['view'])) { // Read the stats data files readStats("packets", $packets); readStats("bytes", $bytes); if (is_array($data)) { foreach ($data as $key => $row) {