mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
Revert the changes
This commit is contained in:
+49
-42
@@ -371,7 +371,7 @@ class Binaries
|
||||
$groupNNTP = $this->_nntp->selectGroup($groupMySQL['name']);
|
||||
if ($this->_nntp->isError($groupNNTP)) {
|
||||
$groupNNTP = $this->_nntp->dataError($this->_nntp, $groupMySQL['name']);
|
||||
if ($groupNNTP->code === 411) {
|
||||
if ($groupNNTP->code == 411) {
|
||||
$this->_groups->disableIfNotExist($groupMySQL['id']);
|
||||
}
|
||||
if ($this->_nntp->isError($groupNNTP)) {
|
||||
@@ -384,7 +384,7 @@ class Binaries
|
||||
}
|
||||
|
||||
// Attempt to repair any missing parts before grabbing new ones.
|
||||
if ($groupMySQL['last_record'] !== 0) {
|
||||
if ($groupMySQL['last_record'] != 0) {
|
||||
if ($this->_partRepair) {
|
||||
if ($this->_echoCLI) {
|
||||
$this->_colorCLI->doEcho($this->_colorCLI->primary('Part repair enabled. Checking for missing parts.'), true);
|
||||
@@ -396,7 +396,7 @@ class Binaries
|
||||
}
|
||||
|
||||
// Generate postdate for first record, for those that upgraded.
|
||||
if ($groupMySQL['first_record_postdate'] === null && $groupMySQL['first_record'] !== 0) {
|
||||
if (is_null($groupMySQL['first_record_postdate']) && $groupMySQL['first_record'] != 0) {
|
||||
|
||||
$groupMySQL['first_record_postdate'] = $this->postdate($groupMySQL['first_record'], $groupNNTP);
|
||||
|
||||
@@ -412,7 +412,7 @@ class Binaries
|
||||
}
|
||||
|
||||
// Get first article we want aka the oldest.
|
||||
if ($groupMySQL['last_record'] === 0) {
|
||||
if ($groupMySQL['last_record'] == 0) {
|
||||
if ($this->_newGroupScanByDays) {
|
||||
// For new newsgroups - determine here how far we want to go back using date.
|
||||
$first = $this->daytopost($this->_newGroupDaysToScan, $groupNNTP);
|
||||
@@ -438,10 +438,10 @@ class Binaries
|
||||
// Check if the server has more articles than our loop limit x 2.
|
||||
if ($totalCount > ($this->messageBuffer * 2)) {
|
||||
// Get the remainder of $totalCount / $this->message buffer
|
||||
$leaveOver = round($totalCount % $this->messageBuffer, 0, PHP_ROUND_HALF_DOWN) + $this->messageBuffer;
|
||||
$leaveOver = round(($totalCount % $this->messageBuffer), 0, PHP_ROUND_HALF_DOWN) + $this->messageBuffer;
|
||||
} else {
|
||||
// Else get half of the available.
|
||||
$leaveOver = round($totalCount / 2, 0, PHP_ROUND_HALF_DOWN);
|
||||
$leaveOver = round(($totalCount / 2), 0, PHP_ROUND_HALF_DOWN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -472,7 +472,7 @@ class Binaries
|
||||
if ($this->_echoCLI) {
|
||||
$this->_colorCLI->doEcho(
|
||||
$this->_colorCLI->primary(
|
||||
($groupMySQL['last_record'] === 0
|
||||
($groupMySQL['last_record'] == 0
|
||||
? 'New group ' . $groupNNTP['group'] . ' starting with ' .
|
||||
($this->_newGroupScanByDays
|
||||
? $this->_newGroupDaysToScan . ' days'
|
||||
@@ -507,8 +507,8 @@ class Binaries
|
||||
$this->_colorCLI->doEcho(
|
||||
$this->_colorCLI->header(
|
||||
"\nGetting " . number_format($last - $first + 1) . ' articles (' . number_format($first) .
|
||||
' to ' . number_format($last) . ') from ' . $groupMySQL['name'] . ' - (' .
|
||||
number_format($groupLast - $last) . ' articles in queue).'
|
||||
' to ' . number_format($last) . ') from ' . $groupMySQL['name'] . " - (" .
|
||||
number_format($groupLast - $last) . " articles in queue)."
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -520,7 +520,7 @@ class Binaries
|
||||
if (!empty($scanSummary)) {
|
||||
|
||||
// If new group, update first record & postdate
|
||||
if ($groupMySQL['first_record_postdate'] === null && $groupMySQL['first_record'] === 0) {
|
||||
if (is_null($groupMySQL['first_record_postdate']) && $groupMySQL['first_record'] == 0) {
|
||||
$groupMySQL['first_record'] = $scanSummary['firstArticleNumber'];
|
||||
|
||||
if (isset($scanSummary['firstArticleDate'])) {
|
||||
@@ -569,7 +569,7 @@ class Binaries
|
||||
);
|
||||
}
|
||||
|
||||
if ($last === $groupLast) {
|
||||
if ($last == $groupLast) {
|
||||
$done = true;
|
||||
} else {
|
||||
$first = $last;
|
||||
@@ -638,13 +638,12 @@ class Binaries
|
||||
|
||||
// Increment if part repair and return false.
|
||||
if ($partRepair === true) {
|
||||
$fLast = $this->first === $this->last ? '= ' . $this->first : 'IN (' . implode(',', range($this->first, $this->last)) . ')';
|
||||
$this->_pdo->queryExec(
|
||||
sprintf(
|
||||
'UPDATE %s SET attempts = attempts + 1 WHERE groups_id = %d AND numberid %s',
|
||||
$this->tableNames['prname'],
|
||||
$this->groupMySQL['id'],
|
||||
$fLast
|
||||
($this->first == $this->last ? '= ' . $this->first : 'IN (' . implode(',', range($this->first, $this->last)) . ')')
|
||||
)
|
||||
);
|
||||
return $returnArray;
|
||||
@@ -663,7 +662,7 @@ class Binaries
|
||||
|
||||
// Check if the non-compression headers have an error.
|
||||
if ($this->_nntp->isError($headers)) {
|
||||
$message = ($headers->code === 0 ? 'Unknown error' : $headers->message);
|
||||
$message = ($headers->code == 0 ? 'Unknown error' : $headers->message);
|
||||
$this->log(
|
||||
"Code {$headers->code}: $message\nSkipping group: {$this->groupMySQL['name']}",
|
||||
__FUNCTION__,
|
||||
@@ -704,8 +703,8 @@ class Binaries
|
||||
}
|
||||
|
||||
// If set we are running in partRepair mode.
|
||||
if ($partRepair === true && $missingParts !== null) {
|
||||
if (!in_array($header['Number'], $missingParts, false)) {
|
||||
if ($partRepair === true && !is_null($missingParts)) {
|
||||
if (!in_array($header['Number'], $missingParts)) {
|
||||
// If article isn't one that is missing skip it.
|
||||
continue;
|
||||
} else {
|
||||
@@ -726,7 +725,7 @@ class Binaries
|
||||
*/
|
||||
if (preg_match('/^\s*(?!"Usenet Index Post)(.+)\s+\((\d+)\/(\d+)\)/', $header['Subject'], $header['matches'])) {
|
||||
// Add yEnc to subjects that do not have them, but have the part number at the end of the header.
|
||||
if (stripos($header['Subject'], 'yEnc') === false) {
|
||||
if (!stristr($header['Subject'], 'yEnc')) {
|
||||
$header['matches'][1] .= ' yEnc';
|
||||
}
|
||||
} else {
|
||||
@@ -751,7 +750,7 @@ class Binaries
|
||||
}
|
||||
$header['Bytes'] = (int)$header['Bytes'];
|
||||
|
||||
if (ProcessReleasesMultiGroup::isMultiGroup($header['From'])) {
|
||||
if(ProcessReleasesMultiGroup::isMultiGroup($header['From'])) {
|
||||
$mgrHeaders[] = $header;
|
||||
} else {
|
||||
$stdHeaders[] = $header;
|
||||
@@ -766,11 +765,11 @@ class Binaries
|
||||
$this->outputHeaderInitial();
|
||||
}
|
||||
|
||||
if (!empty($stdHeaders) && count($stdHeaders) > 0) {
|
||||
if (isset($stdHeaders) && count($stdHeaders) > 0) {
|
||||
$this->storeHeaders($stdHeaders, false);
|
||||
}
|
||||
if (!empty($mgrHeaders) && count($mgrHeaders) > 0) {
|
||||
$this->tableNames = ProcessReleasesMultiGroup::tableNames();
|
||||
if (isset($mgrHeaders) && count($mgrHeaders) > 0) {
|
||||
$this->tableNames = ProcessReleasesMultiGroup::returnTableNames();
|
||||
$this->storeHeaders($mgrHeaders, true);
|
||||
}
|
||||
|
||||
@@ -966,6 +965,8 @@ class Binaries
|
||||
$this->header['matches'][2] . ',' . $this->header['Bytes'] . '),';
|
||||
}
|
||||
|
||||
unset($headers); // Reclaim memory.
|
||||
|
||||
// Start of inserting into SQL.
|
||||
$this->startUpdate = microtime(true);
|
||||
|
||||
@@ -979,7 +980,7 @@ class Binaries
|
||||
$binariesQuery = rtrim($binariesQuery, ',') . $binariesEnd;
|
||||
|
||||
// Check if we got any binaries. If we did, try to insert them.
|
||||
if ((strlen($binariesCheck . $binariesEnd) === strlen($binariesQuery)) ? true : $this->_pdo->queryExec($binariesQuery)) {
|
||||
if (((strlen($binariesCheck . $binariesEnd) === strlen($binariesQuery)) ? true : $this->_pdo->queryExec($binariesQuery))) {
|
||||
if ($this->_debug) {
|
||||
$this->_colorCLI->doEcho(
|
||||
$this->_colorCLI->debug(
|
||||
@@ -988,7 +989,7 @@ class Binaries
|
||||
)
|
||||
);
|
||||
}
|
||||
if ((strlen($partsQuery) === strlen($partsCheck)) ? true : $this->_pdo->queryExec(rtrim($partsQuery, ','))) {
|
||||
if (((strlen($partsQuery) === strlen($partsCheck)) ? true : $this->_pdo->queryExec(rtrim($partsQuery, ',')))) {
|
||||
$this->_pdo->Commit();
|
||||
} else {
|
||||
if ($this->addToPartRepair) {
|
||||
@@ -1011,7 +1012,7 @@ class Binaries
|
||||
* @param array $headers
|
||||
* @param int $msgCount
|
||||
*/
|
||||
protected function getHighLowArticleInfo(array $returnArray, array $headers, int $msgCount)
|
||||
protected function getHighLowArticleInfo(array &$returnArray, array $headers, int $msgCount)
|
||||
{
|
||||
// Get highest and lowest article numbers/dates.
|
||||
$iterator1 = 0;
|
||||
@@ -1028,7 +1029,7 @@ class Binaries
|
||||
}
|
||||
|
||||
// Break if we found non empty articles.
|
||||
if (isset($returnArray['firstArticleNumber'], $returnArray['lastArticleNumber'])) {
|
||||
if (isset($returnArray['firstArticleNumber']) && isset($returnArray['lastArticleNumber'])) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1060,7 +1061,7 @@ class Binaries
|
||||
$this->_colorCLI->doEcho(
|
||||
$this->_colorCLI->primary(
|
||||
'Received ' . count($this->headersReceived) .
|
||||
' articles of ' . number_format($this->last - $this->first + 1) . ' requested, ' .
|
||||
' articles of ' . (number_format($this->last - $this->first + 1)) . ' requested, ' .
|
||||
$this->headersBlackListed . ' blacklisted, ' . $this->notYEnc . ' not yEnc.'
|
||||
)
|
||||
);
|
||||
@@ -1287,10 +1288,12 @@ class Binaries
|
||||
|
||||
// If we could not find it locally, try usenet.
|
||||
$header = $this->_nntp->getXOVER($currentPost);
|
||||
if (!$this->_nntp->isError($header) && isset($header[0]['Date']) && strlen($header[0]['Date']) > 0) {
|
||||
if (!$this->_nntp->isError($header)) {
|
||||
// Check if the date is set.
|
||||
$date = $header[0]['Date'];
|
||||
break;
|
||||
if (isset($header[0]['Date']) && strlen($header[0]['Date']) > 0) {
|
||||
$date = $header[0]['Date'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Try to get a different article number.
|
||||
@@ -1312,7 +1315,7 @@ class Binaries
|
||||
$currentPost = $tempPost;
|
||||
|
||||
if ($this->_debug) {
|
||||
$this->_colorCLI->doEcho($this->_colorCLI->debug('Postdate retried ' . $attempts . ' time(s).'));
|
||||
$this->_colorCLI->doEcho($this->_colorCLI->debug('Postdate retried ' . $attempts . " time(s)."));
|
||||
}
|
||||
} while ($attempts++ <= 20);
|
||||
|
||||
@@ -1333,7 +1336,7 @@ class Binaries
|
||||
$date .
|
||||
') (' .
|
||||
$this->daysOld($date) .
|
||||
' days old)',
|
||||
" days old)",
|
||||
Logger::LOG_INFO
|
||||
);
|
||||
}
|
||||
@@ -1416,14 +1419,14 @@ class Binaries
|
||||
if ($this->_echoCLI) {
|
||||
echo '+';
|
||||
}
|
||||
} else if ($articleTime === $goalTime) {
|
||||
} else if ($articleTime == $goalTime) {
|
||||
// Exact match. We did it! (this will likely never happen though)
|
||||
break;
|
||||
}
|
||||
|
||||
// We seem to be flip-flopping between 2 articles, assume we're out of articles to check.
|
||||
// End on an article more recent than our oldest so that we don't miss any releases.
|
||||
if ($reallyOldArticle === $wantedArticle && ($goalTime - $articleTime) <= 0) {
|
||||
if ($reallyOldArticle == $wantedArticle && ($goalTime - $articleTime) <= 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1468,7 +1471,7 @@ class Binaries
|
||||
foreach ($numbers as $number) {
|
||||
$insertStr .= '(' . $number . ',' . $groupID . '),';
|
||||
}
|
||||
return $this->_pdo->queryInsert(rtrim($insertStr, ',') . ' ON DUPLICATE KEY UPDATE attempts=attempts+1');
|
||||
return $this->_pdo->queryInsert((rtrim($insertStr, ',') . ' ON DUPLICATE KEY UPDATE attempts=attempts+1'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1486,7 +1489,7 @@ class Binaries
|
||||
foreach ($numbers as $number) {
|
||||
$sql .= $number . ',';
|
||||
}
|
||||
$this->_pdo->queryExec(rtrim($sql, ',') . ') AND groups_id = ' . $groupID);
|
||||
$this->_pdo->queryExec((rtrim($sql, ',') . ') AND groups_id = ' . $groupID));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1569,7 +1572,7 @@ class Binaries
|
||||
* Return all blacklists.
|
||||
*
|
||||
* @param bool $activeOnly Only display active blacklists ?
|
||||
* @param int|string $opType Optional, get white or black lists (use Binaries constants).
|
||||
* @param int $opType Optional, get white or black lists (use Binaries constants).
|
||||
* @param string $groupName Optional, group.
|
||||
* @param bool $groupRegex Optional Join groups / binaryblacklist using regexp for equals.
|
||||
*
|
||||
@@ -1633,19 +1636,21 @@ class Binaries
|
||||
/**
|
||||
* Updates a blacklist from binary blacklist edit admin web page.
|
||||
*
|
||||
* @param array $blacklistArray
|
||||
* @param Array $blacklistArray
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function updateBlacklist($blacklistArray)
|
||||
{
|
||||
$blArray = $blacklistArray['groupname'] === '' ? 'null' : $this->_pdo->escapeString(preg_replace('/a\.b\./i', 'alt.binaries.', $blacklistArray['groupname']));
|
||||
return $this->_pdo->queryExec(
|
||||
sprintf('
|
||||
UPDATE binaryblacklist
|
||||
SET groupname = %s, regex = %s, status = %d, description = %s, optype = %d, msgcol = %d
|
||||
WHERE id = %d ',
|
||||
$blArray,
|
||||
($blacklistArray['groupname'] == ''
|
||||
? 'null'
|
||||
: $this->_pdo->escapeString(preg_replace('/a\.b\./i', 'alt.binaries.', $blacklistArray['groupname']))
|
||||
),
|
||||
$this->_pdo->escapeString($blacklistArray['regex']), $blacklistArray['status'],
|
||||
$this->_pdo->escapeString($blacklistArray['description']),
|
||||
$blacklistArray['optype'],
|
||||
@@ -1658,18 +1663,20 @@ class Binaries
|
||||
/**
|
||||
* Adds a new blacklist from binary blacklist edit admin web page.
|
||||
*
|
||||
* @param array $blacklistArray
|
||||
* @param Array $blacklistArray
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function addBlacklist($blacklistArray)
|
||||
{
|
||||
$blArray = $blacklistArray['groupname'] === '' ? 'null' : $this->_pdo->escapeString(preg_replace('/a\.b\./i', 'alt.binaries.', $blacklistArray['groupname']));
|
||||
return $this->_pdo->queryInsert(
|
||||
sprintf('
|
||||
INSERT INTO binaryblacklist (groupname, regex, status, description, optype, msgcol)
|
||||
VALUES (%s, %s, %d, %s, %d, %d)',
|
||||
$blArray,
|
||||
($blacklistArray['groupname'] == ''
|
||||
? 'null'
|
||||
: $this->_pdo->escapeString(preg_replace('/a\.b\./i', 'alt.binaries.', $blacklistArray['groupname']))
|
||||
),
|
||||
$this->_pdo->escapeString($blacklistArray['regex']),
|
||||
$blacklistArray['status'],
|
||||
$this->_pdo->escapeString($blacklistArray['description']),
|
||||
|
||||
@@ -50,7 +50,7 @@ class ProcessReleasesMultiGroup extends ProcessReleases
|
||||
*/
|
||||
protected function initiateTableNames($groupID)
|
||||
{
|
||||
$this->tables = $this->tableNames();
|
||||
$this->tables = $this->returnTableNames();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,7 +58,7 @@ class ProcessReleasesMultiGroup extends ProcessReleases
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function tableNames()
|
||||
public static function returnTableNames()
|
||||
{
|
||||
return [
|
||||
'cname' => 'multigroup_collections',
|
||||
|
||||
Reference in New Issue
Block a user