$_l->sprintf(' %s: 0 of %s', $tRow['cat_name'], number_format($tRow['cnt'], 0)); } $_l->refresh(); foreach ($fields as $cat => $info) { $_r->println('Truncate table `cat_' . $cat . '`'); $_r->refresh(); F::$dbo->query('TRUNCATE `cat_' . $cat . '`'); $_r->println(' Collecting RAW data'); $_r->refresh(); $q = F::$dbo->query('SELECT id, remote_ip, datetime, data FROM raw_log WHERE cat_name = "' . strtoupper($cat) . '" ORDER BY id ASC'); $_r->println(' Processing'); $_r->refresh(); foreach ($q as $row) { $msgRaw = array(); foreach (explode("\n", $row['data']) as $value) { $value = explode('=', $value, 2); $msgRaw[$value[0]] = $value[1]; } cli::processCategory($cat, $info['fields'], $row['id'], $row['remote_ip'], $row['datetime'], $msgRaw); $fields[$cat]['processed']++; $_l->reset(); foreach ($totals as $tRow) { $_l->sprintf('%s%s: %s of %s', strtolower($tRow['cat_name']) == $cat ? '>' : ' ', $tRow['cat_name'], number_format($fields[strtolower($tRow['cat_name'])]['processed'], 0), number_format($tRow['cnt'], 0)); } $_l->refresh(); } } $_r->println('Processing completed. Press any key...'); $_r->refresh(); ncurses_getch(); F::close();
$data['mark'] = F::$dbo->escape($mark, true); $data['remote_ip'] = F::$dbo->escape($from, true); $data['remote_port'] = $port; $data['data'] = F::$dbo->escape(implode("\n", $msg), true); $query = sprintf('insert into raw_log (%s) values (%s)', implode(',', array_keys($data)), implode(',', array_values($data))); } if (false === F::$dbo->query($query)) { echo $dbo->error; break; } if (!array_key_exists('raw_log', $gc)) { $gc['raw_log'] = $curTime; } if ($catFields = cli::getCategoryFields($catName)) { $cat = strtolower($catName); cli::processCategory($cat, $catFields, F::$dbo->getInsertId(), $from, $fullDate, $msgRaw); if (!array_key_exists('cat_' . $cat, $gc)) { $gc['cat_' . $cat] = $curTime; } } $_wLeft->println(str_pad('=[GC Cooldown]', 23, '=')); foreach ($gc as $tbl => $date) { $_wLeft->println(' ' . $tbl . ': ' . (cli::GARBAGE_COLLECTING_INTERVAL - $curTime + $date)); } if (count($gcTimings) > 0) { $_wLeft->println(str_pad('=[GC Timings]', 23, '=')); foreach ($gcTimings as $tbl => $info) { $_wLeft->println(' ' . $tbl . ': ' . $info); } } $mem = number_format(memory_get_usage(), 0, '.', ',');