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
 /**
  * Try to match a single release to a PreDB title when the release is created.
  *
  * @param string $cleanerName
  *
  * @return array|bool Array with title/ID from PreDB if found, bool False if not found.
  */
 public function matchPre($cleanerName)
 {
     if ($cleanerName == '') {
         return false;
     }
     $titleCheck = $this->pdo->queryOneRow(sprintf('SELECT id FROM predb WHERE title = %s LIMIT 1', $this->pdo->escapeString($cleanerName)));
     if ($titleCheck !== false) {
         return array('title' => $cleanerName, 'preid' => $titleCheck['id']);
     }
     // Check if clean name matches a PreDB filename.
     $fileCheck = $this->pdo->queryOneRow(sprintf('SELECT id, title FROM predb WHERE filename = %s LIMIT 1', $this->pdo->escapeString($cleanerName)));
     if ($fileCheck !== false) {
         return array('title' => $fileCheck['title'], 'preid' => $fileCheck['id']);
     }
     return false;
 }
Example #4
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 #5
0
    }
} 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) {
        foreach ($preData as $data) {
            echo '<request', ' reqid="' . (!empty($data['requestid']) ? $data['requestid'] : '') . '"', ' md5="' . (!empty($data['md5']) ? $data['md5'] : '') . '"', ' sha1="' . (!empty($data['sha1']) ? $data['sha1'] : '') . '"', ' nuked="' . (!empty($data['nuked']) ? $data['nuked'] : '') . '"', ' category="' . (!empty($data['category']) ? $data['category'] : '') . '"', ' source="' . (!empty($data['source']) ? $data['source'] : '') . '"', ' nukereason="' . (!empty($data['nukereason']) ? $data['nukereason'] : '') . '"', ' files="' . (!empty($data['files']) ? $data['files'] : '') . '"', ' name="' . (!empty($data['title']) ? sanitize($data['title']) : '') . '"', ' date="' . (!empty($data['predate']) ? strtotime($data['predate']) : '') . '"', ' size="' . (!empty($data['size']) && $data['size'] != 'NULL' ? $data['size'] : '') . '"', ' group="' . (isset($data['groupname']) && !empty($data['groupname']) ? $data['groupname'] : '') . '"', ' ident="' . (isset($data['ident']) && !empty($data['ident']) ? $data['ident'] : '') . '"', '/>';
        }
Example #6
0
<?php

if (!isset($argv[1])) {
    exit('This script will set where backfill starts based on your oldest release in a group or groups,' . ' so you do not have to re-download and process all the headers you already downloaded.' . PHP_EOL . 'This is good if you imported NZBs or reset a group for example.' . PHP_EOL . 'To start the script, type in a group name or all for all the backfill enabled groups.' . PHP_EOL);
}
require_once dirname(__FILE__) . '/../../../www/config.php';
$pdo = new nzedb\db\DB();
if ($argv[1] === 'all') {
    $groups = $pdo->query('SELECT * FROM groups WHERE backfill = 1');
} else {
    $groups = $pdo->query(sprintf('SELECT * FROM groups WHERE name = %s', $pdo->escapeString($argv[1])));
}
if (count($groups) === 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;
Example #7
0
            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";
    }
}
echo '</requests>';
Example #8
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'];
Example #9
0
 protected function _updateString($sqlKey, &$oldValue, &$newValue, $escape = true)
 {
     return empty($oldValue) && !empty($newValue) ? $sqlKey . ' = ' . ($escape ? $this->_db->escapeString($newValue) : $newValue) . ', ' : '';
 }