Example #1
0
 /**
  * Update the search name of a release.
  *
  * @param int $releaseID
  * @param string $searchName
  */
 public function updateReleaseSearchName($releaseID, $searchName)
 {
     if (!is_null($this->sphinxQL)) {
         $old = $this->sphinxQL->queryOneRow(sprintf('SELECT * FROM releases_rt WHERE id = %s', $releaseID));
         if ($old !== false) {
             $this->insertRelease(['id' => $releaseID, 'guid' => $this->sphinxQL->escapeString($old['guid']), 'name' => $this->sphinxQL->escapeString($old['name']), 'searchname' => $searchName, 'fromname' => $this->sphinxQL->escapeString($old['fromname'])]);
         }
     }
 }
Example #2
0
 /**
  * Get a group ID for a group name.
  *
  * @param string $groupName
  *
  * @return mixed
  *
  * @access protected
  */
 protected function _getGroupID($groupName)
 {
     if (!isset($this->_groupList[$groupName])) {
         $group = $this->_pdo->queryOneRow(sprintf('SELECT id FROM groups WHERE name = %s', $this->_pdo->escapeString($groupName)));
         $this->_groupList[$groupName] = $group['id'];
     }
     return $this->_groupList[$groupName];
 }
Example #3
0
    /**
     * Safe backfill using posts. Going back to a date specified by the user on the site settings.
     * This does 1 group for x amount of parts until it reaches the date.
     *
     * @param string $articles
     *
     * @return void
     */
    public function safeBackfill($articles = '')
    {
        $groupname = $this->pdo->queryOneRow(sprintf('
				SELECT name FROM groups
				WHERE first_record_postdate BETWEEN %s AND NOW()
				AND backfill = 1
				ORDER BY name ASC', $this->pdo->escapeString($this->_safeBackFillDate)));
        if (!$groupname) {
            $dMessage = 'No groups to backfill, they are all at the target date ' . $this->_safeBackFillDate . ", or you have not enabled them to be backfilled in the groups page.\n";
            if ($this->_debug) {
                $this->_debugging->log('Backfill', "safeBackfill", $dMessage, Logger::LOG_FATAL);
            }
            exit($dMessage);
        } else {
            $this->backfillAllGroups($groupname['name'], $articles);
        }
    }
Example #4
0
    protected function _verifyPreData(&$matches)
    {
        // If the title is too short, don't bother.
        if (strlen($matches['title']) < 15) {
            return;
        }
        $matches['title'] = str_replace(array("\r", "\n"), '', $matches['title']);
        $duplicateCheck = $this->_db->queryOneRow(sprintf('SELECT * FROM predb WHERE title = %s', $this->_db->escapeString($matches['title'])));
        if (!is_numeric($matches['date']) || $matches['date'] < time() - 31536000) {
            return;
        }
        if ($duplicateCheck === false) {
            $this->_db->queryExec(sprintf('
					INSERT INTO predb (title, size, category, predate, source, requestid, groupid, files, filename, nuked, nukereason, shared)
					VALUES (%s, %s, %s, %s, %s, %d, %d, %s, %s, %d, %s, -1)', $this->_db->escapeString($matches['title']), isset($matches['size']) && !empty($matches['size']) ? $this->_db->escapeString($matches['size']) : 'NULL', isset($matches['category']) && !empty($matches['category']) ? $this->_db->escapeString($matches['category']) : 'NULL', $this->_db->from_unixtime($matches['date']), $this->_db->escapeString($matches['source']), isset($matches['requestid']) && is_numeric($matches['requestid']) ? $matches['requestid'] : 0, isset($matches['groupid']) && is_numeric($matches['groupid']) ? $matches['groupid'] : 0, isset($matches['files']) && !empty($matches['files']) ? $this->_db->escapeString($matches['files']) : 'NULL', isset($matches['filename']) ? $this->_db->escapeString($matches['filename']) : $this->_db->escapeString(''), isset($matches['nuked']) && is_numeric($matches['nuked']) ? $matches['nuked'] : 0, isset($matches['reason']) && !empty($matches['nukereason']) ? $this->_db->escapeString($matches['nukereason']) : 'NULL'));
            $this->_done++;
        } else {
            $query = 'UPDATE predb SET ';
            $query .= $this->_updateString('size', $duplicateCheck['size'], $matches['size']);
            $query .= $this->_updateString('files', $duplicateCheck['files'], $matches['files']);
            $query .= $this->_updateString('nukereason', $duplicateCheck['nukereason'], $matches['reason']);
            $query .= $this->_updateString('requestid', $duplicateCheck['requestid'], $matches['requestid'], false);
            $query .= $this->_updateString('groupid', $duplicateCheck['groupid'], $matches['groupid'], false);
            $query .= $this->_updateString('nuked', $duplicateCheck['nuked'], $matches['nuked'], false);
            $query .= $this->_updateString('filename', $duplicateCheck['filename'], $matches['filename']);
            $query .= $this->_updateString('category', $duplicateCheck['category'], $matches['category']);
            if ($query === 'UPDATE predb SET ') {
                return;
            }
            $this->_done++;
            $query .= 'predate = ' . $this->_db->from_unixtime($matches['date']) . ', ';
            $query .= 'source = ' . $this->_db->escapeString($matches['source']) . ', ';
            $query .= 'title = ' . $this->_db->escapeString($matches['title']);
            $query .= ', shared = -1';
            $query .= ' WHERE title = ' . $this->_db->escapeString($matches['title']);
            $this->_db->queryExec($query);
        }
    }
Example #5
0
 /**
  * Return a single PRE for a release.
  *
  * @param int $preID
  *
  * @return array
  */
 public function getOne($preID)
 {
     return $this->pdo->queryOneRow(sprintf('SELECT * FROM predb WHERE id = %d', $preID));
 }
Example #6
0
        case 'all':
            $pdo = new nzedb\db\DB();
            $preData = $pdo->query(sprintf('SELECT * FROM predb p WHERE 1=1 %s %s %s ORDER BY p.predate DESC LIMIT %d OFFSET %d', $newer, $older, $nuked, $limit, $offset));
            break;
    }
} else {
    if (isset($_POST['data'])) {
        $reqData = @unserialize($_POST['data']);
        if ($reqData !== false && is_array($reqData) && isset($reqData[0]['ident'])) {
            $pdo = new nzedb\db\DB();
            $preData = array();
            foreach ($reqData as $request) {
                $result = $pdo->queryOneRow(sprintf('
					SELECT p.*,
					g.name AS groupname
					FROM predb p
					INNER JOIN groups g ON g.id = p.group_id
					WHERE requestid = %d
					AND g.name = %s
					LIMIT 1', $request['reqid'], $pdo->escapeString($request['group'])));
                if ($result !== false) {
                    $result['ident'] = $request['ident'];
                    $preData[] = $result;
                }
            }
        }
    }
}
if ($json === false) {
    header('Content-type: text/xml');
    echo '<?xml version="1.0" encoding="UTF-8"?>', PHP_EOL, '<requests>', PHP_EOL;
    if (count($preData) > 0) {
Example #7
0
    if ($argv[1] === 'all') {
        exit('ERROR! No groups were found with backfill enabled!' . PHP_EOL);
    } else {
        exit('ERROR! Group (' . $argv[1] . ') not found!' . PHP_EOL);
    }
}
$nntp = new NNTP(['Settings' => $pdo]);
$nntp->doConnect() or exit('Could not connect to Usenet!' . PHP_EOL);
$binaries = new Binaries(['NNTP' => $nntp, 'Settings' => $pdo]);
foreach ($groups as $group) {
    $groupNNTP = $nntp->selectGroup($group['name']);
    if ($nntp->isError($groupNNTP)) {
        echo 'ERROR! Could not fetch information from NNTP for group (' . $group['name'] . ')' . PHP_EOL;
        continue;
    }
    $postDate = $pdo->queryOneRow(sprintf('SELECT UNIX_TIMESTAMP(postdate) AS postdate FROM releases WHERE group_id = %d ORDER BY postdate ASC LIMIT 1', $group['id']));
    if ($postDate === false) {
        echo 'ERROR! Could not find any existing releases for group (' . $group['name'] . ')' . PHP_EOL;
        continue;
    }
    $articleNumber = (int) $binaries->daytopost(round((time() - $postDate['postdate']) / 86400), $groupNNTP);
    if ($group['last_record'] != 0 && $articleNumber >= $group['last_record']) {
        echo 'ERROR! Could not determine the article number for this date: (' . $postDate['postdate'] . ') on group (' . $group['name'] . ')' . PHP_EOL;
        continue;
    }
    $articleDate = $binaries->postdate($articleNumber, $groupNNTP);
    $pdo->queryExec(sprintf('
			UPDATE groups
			SET first_record = %d, first_record_postdate = %s
			WHERE id = %d', $articleNumber, $pdo->from_unixtime($articleDate), $group['id']));
    echo 'SUCCESS! Updated group (' . $group['name'] . ')\'s first article number to (' . $articleNumber . ') dated (' . date('r', $articleDate) . ').' . PHP_EOL . 'The previous first article number was: (' . $group['first_record'] . ')' . (empty($group['first_record_postdate']) ? '.' : ' dated (' . date('r', strtotime($group['first_record_postdate'])) . ').') . PHP_EOL;
Example #8
0
					AND groupname = %s
					LIMIT 1', $request['reqid'], $db->escapeString($request['group'])));
            if ($result !== false) {
                $result['ident'] = $request['ident'];
                $preData[] = $result;
            }
        }
    }
} else {
    if (isset($_GET['reqid']) && isset($_GET['group']) && is_numeric($_GET['reqid'])) {
        require dirname(__FILE__) . '/../settings.php';
        require dirname(__FILE__) . '/../Classes/DB.php';
        $db = new nzedb\db\DB();
        $preData = $db->queryOneRow(sprintf('
			SELECT title, groupname, reqid
			FROM predb
			WHERE reqid = %d
			AND groupname = %s
			LIMIT 1', $_GET['reqid'], $db->escapeString(trim($_GET['group']))));
        if ($preData !== false) {
            $preData['ident'] = 0;
            $preData = array($preData);
        }
    }
}
header('Content-type: text/xml');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<requests>\n";
if ($preData !== false) {
    foreach ($preData as $pre) {
        echo '    <request name="' . preg_replace('/[^\\x{0009}\\x{000a}\\x{000d}\\x{0020}-\\x{D7FF}\\x{E000}-\\x{FFFD}]+/u', '.', $pre['title']) . '" group="' . $pre['groupname'] . '" reqid="' . $pre['reqid'] . '" ident="' . $pre['ident'] . "\"/>\n";
    }
}
Example #9
0
     sleep_printout(M2V_SLEEP_TIME);
     continue;
 }
 $rss_data = @simplexml_load_string($rss_data);
 if (!$rss_data) {
     echo "Error parsing XML data from M2V RSS.\n";
     sleep_printout(M2V_SLEEP_TIME);
     continue;
 }
 echo "Downloaded RSS data from M2V.\n";
 $items = 0;
 foreach ($rss_data->channel->item as $item) {
     if ($item->title == "m2v.ru") {
         continue;
     }
     if ($db->queryOneRow("SELECT id FROM predb WHERE filename != '' AND title = " . $db->escapeString($item->title))) {
         continue;
     }
     $item_data = getUrl($item->link);
     if (!$item_data) {
         echo "Error downloading page: '{$item->title}'\nSkipping.\n";
         usleep(M2VRU_THROTTLE_USLEEP);
         continue;
     }
     $fileName = $alternateFileName = '';
     if (preg_match_all('#<DIV\\s+class=links>(.+?)</DIV>#is', $item_data, $matches)) {
         foreach ($matches[1] as $match) {
             // <b>b8zkcy01.zip, <font color="silver">size: <font color="white">4,77 MB</font>
             if (preg_match('#<b>\\s*(?P<filename>.+?)\\s*,#is', $match, $matches2)) {
                 if (preg_match('#\\.(nfo|sfv|mu3|txt|jpe?g|png|gif)$#', $matches2['filename'])) {
                     $alternateFileName = $matches2['filename'];