exit; } $data = $nntp->getGroups(); if ($nntp->isError($data)) { exit($pdo->log->error("\nFailed to getGroups() from nntp server.\n")); } if (!isset($data['group'])) { exit($pdo->log->error("\nFailed to getGroups() from nntp server.\n")); } $nntp->doQuit(); $res = $pdo->query("SELECT name FROM groups"); $counter = 0; $minvalue = $argv[1]; foreach ($data as $newgroup) { if (isset($newgroup["group"])) { if (strstr($newgroup["group"], ".bin") != false && MyInArray($res, $newgroup["group"], "name") == false && $newgroup["last"] - $newgroup["first"] > 1000000) { $pdo->queryInsert(sprintf("INSERT INTO allgroups (name, first_record, last_record, updated) VALUES (%s, %d, %d, NOW())", $pdo->escapeString($newgroup["group"]), $newgroup["first"], $newgroup["last"])); } } } $grps = $pdo->query("SELECT DISTINCT name FROM allgroups WHERE name NOT IN (SELECT name FROM groups)"); foreach ($grps as $grp) { if (!myInArray($res, $grp, "name")) { $data = $pdo->queryOneRow(sprintf("SELECT (MAX(last_record) - MIN(first_record)) AS count, (MAX(last_record) - MIN(last_record))/(UNIX_TIMESTAMP(MAX(updated))-UNIX_TIMESTAMP(MIN(updated))) as per_second, (MAX(last_record) - MIN(last_record)) AS tracked, MIN(updated) AS firstchecked from allgroups WHERE name = %s", $pdo->escapeString($grp["name"]))); if (floor($data["per_second"] * 3600) >= $minvalue) { echo $pdo->log->header($grp["name"]); echo $pdo->log->primary("Available Post Count: " . number_format($data["count"]) . "\n" . "Date First Checked: " . $data["firstchecked"] . "\n" . "Posts Since First: " . number_format($data["tracked"]) . "\n" . "Average Per Hour: " . number_format(floor($data["per_second"] * 3600)) . "\n"); $counter++; } } }
use nzedb\db\Settings; $pdo = new Settings(); $nntp = new NNTP(['Settings' => $pdo]); if ($nntp->doConnect() !== true) { exit; } $data = $nntp->getGroups(); $res = $pdo->query("SELECT name FROM groups ORDER BY name"); foreach ($data as $newgroup) { if (strstr($newgroup["group"], ".bin") != false && !MyInArray($res, $newgroup["group"], "name") && $newgroup["last"] - $newgroup["first"] > 100000) { $pdo->queryInsert(sprintf("INSERT INTO allgroups (name, first_record, last_record, updated) VALUES (%s, %d, %d, NOW())", $pdo->escapeString($newgroup["group"]), $newgroup["first"], $newgroup["last"])); } } $grps = $pdo->query("SELECT DISTINCT name FROM allgroups"); foreach ($grps as $grp) { if (!MyInArray($res, $grp, "name")) { $data = $pdo->queryOneRow(sprintf("SELECT (MAX(last_record) - MIN(first_record)) AS count, (MAX(last_record) - MIN(first_record))/(MAX(updated)-MIN(updated)) as per_second from allgroups WHERE name = %s", $pdo->escapeString($grp["name"]))); if (floor($data["per_second"] * 3600) >= 100000) { echo $grp["name"] . " has " . number_format($data["count"]) . " headers available, averaging " . number_format(floor($data["per_second"] * 3600)) . " per hour\n"; } } } function myInArray($array, $value, $key) { //loop through the array foreach ($array as $val) { //if $val is an array cal myInArray again with $val as array input if (is_array($val)) { if (myInArray($val, $value, $key)) { return true; }