コード例 #1
0
ファイル: populate_rt_indexes.php プロジェクト: zetas/nZEDb
function populate_rt($table, $max)
{
    $pdo = new DB();
    switch ($table) {
        case 'releases_rt':
            $pdo->queryDirect('SET SESSION group_concat_max_len=8192');
            $query = 'SELECT r.id, r.name, r.searchname, r.fromname, IFNULL(GROUP_CONCAT(rf.name SEPARATOR " "),"") filename
				FROM releases r
				LEFT JOIN release_files rf ON(r.id=rf.releaseid)
				WHERE r.id > %d
				GROUP BY r.id
				ORDER BY r.id ASC
				LIMIT %d';
            $rtvalues = '(id, name, searchname, fromname, filename)';
            $totals = $pdo->queryOneRow("SELECT COUNT(id) AS c, MIN(id) AS min FROM releases");
            if (!$totals) {
                exit("Could not get database information for releases table.\n");
            }
            $total = $totals["c"];
            $minId = $totals["min"];
            break;
        default:
            exit;
    }
    $sphinx = new SphinxSearch();
    $string = sprintf('REPLACE INTO %s %s VALUES ', $table, $rtvalues);
    $lastId = $minId - 1;
    echo "[Starting to populate sphinx RT index {$table} with {$total} releases.]\n";
    for ($i = $minId; $i <= $total + $max; $i += $max) {
        $rows = $pdo->queryDirect(sprintf($query, $lastId, $max));
        if (!$rows) {
            continue;
        }
        $tempString = '';
        foreach ($rows as $row) {
            if ($row["id"] > $lastId) {
                $lastId = $row["id"];
            }
            switch ($table) {
                case 'releases_rt':
                    $tempString .= sprintf('(%d,%s,%s,%s,%s),', $row['id'], $sphinx->sphinxQL->escapeString($row['name']), $sphinx->sphinxQL->escapeString($row['searchname']), $sphinx->sphinxQL->escapeString($row['fromname']), $sphinx->sphinxQL->escapeString($row['filename']));
                    break;
            }
        }
        if (!$tempString) {
            continue;
        }
        $sphinx->sphinxQL->queryExec($string . rtrim($tempString, ','));
        echo ".";
    }
    echo "\n[Done]\n";
}
コード例 #2
0
ファイル: PreDb.php プロジェクト: zetas/nZEDb
 /**
  * Matches the hashes within the predb table to release files and subjects (names) which are hashed.
  *
  * @param $time
  * @param $echo
  * @param $cats
  * @param $namestatus
  * @param $show
  *
  * @return int
  */
 public function parseTitles($time, $echo, $cats, $namestatus, $show)
 {
     $namefixer = new NameFixer(['Echo' => $this->echooutput, 'ConsoleTools' => $this->pdo->log, 'Settings' => $this->pdo]);
     $consoletools = new ConsoleTools(['ColorCLI' => $this->pdo->log]);
     $othercats = Category::getCategoryOthersGroup();
     $updated = $checked = 0;
     $tq = '';
     if ($time == 1) {
         $tq = 'AND r.adddate > (NOW() - INTERVAL 3 HOUR) ORDER BY rf.releaseid, rf.size DESC';
     }
     $ct = '';
     if ($cats == 1) {
         $ct = sprintf('AND r.categoryid IN (%s)', $othercats);
     }
     if ($this->echooutput) {
         $te = '';
         if ($time == 1) {
             $te = ' in the past 3 hours';
         }
         echo $this->pdo->log->header('Fixing search names' . $te . " using the predb hash.");
     }
     $regex = "AND (r.ishashed = 1 OR rf.ishashed = 1)";
     if ($cats === 3) {
         $query = sprintf('SELECT r.id AS releaseid, r.name, r.searchname, r.categoryid, r.group_id, ' . 'dehashstatus, rf.name AS filename FROM releases r ' . 'LEFT OUTER JOIN release_files rf ON r.id = rf.releaseid ' . 'WHERE nzbstatus = 1 AND dehashstatus BETWEEN -6 AND 0 AND preid = 0 %s', $regex);
     } else {
         $query = sprintf('SELECT r.id AS releaseid, r.name, r.searchname, r.categoryid, r.group_id, ' . 'dehashstatus, rf.name AS filename FROM releases r ' . 'LEFT OUTER JOIN release_files rf ON r.id = rf.releaseid ' . 'WHERE nzbstatus = 1 AND isrenamed = 0 AND dehashstatus BETWEEN -6 AND 0 %s %s %s', $regex, $ct, $tq);
     }
     $res = $this->pdo->queryDirect($query);
     $total = $res->rowCount();
     echo $this->pdo->log->primary(number_format($total) . " releases to process.");
     if ($res instanceof \Traversable) {
         foreach ($res as $row) {
             if (preg_match('/[a-fA-F0-9]{32,40}/i', $row['name'], $matches)) {
                 $updated = $updated + $namefixer->matchPredbHash($matches[0], $row, $echo, $namestatus, $this->echooutput, $show);
             } else {
                 if (preg_match('/[a-fA-F0-9]{32,40}/i', $row['filename'], $matches)) {
                     $updated = $updated + $namefixer->matchPredbHash($matches[0], $row, $echo, $namestatus, $this->echooutput, $show);
                 }
             }
             if ($show === 2) {
                 $consoletools->overWritePrimary("Renamed Releases: [" . number_format($updated) . "] " . $consoletools->percentString(++$checked, $total));
             }
         }
     }
     if ($echo == 1) {
         echo $this->pdo->log->header("\n" . $updated . " releases have had their names changed out of: " . number_format($checked) . " files.");
     } else {
         echo $this->pdo->log->header("\n" . $updated . " releases could have their names changed. " . number_format($checked) . " files were checked.");
     }
     return $updated;
 }
コード例 #3
0
ファイル: populate_rt_indexes.php プロジェクト: kaibosh/nZEDb
function populate_rt($table = '')
{
    $pdo = new DB();
    $rows = false;
    switch ($table) {
        case 'releases_rt':
            $pdo->queryDirect('SET SESSION group_concat_max_len=8192');
            $rows = $pdo->queryExec('SELECT r.id, r.name, r.searchname, r.fromname, IFNULL(GROUP_CONCAT(rf.name SEPARATOR " "),"") filename
				FROM releases r LEFT JOIN release_files rf ON(r.id=rf.releaseid) GROUP BY r.id');
            $rtvalues = '(id, name, searchname, fromname, filename)';
            break;
    }
    if ($rows !== false && ($total = $rows->rowCount())) {
        $sphinx = new SphinxSearch();
        $string = sprintf('REPLACE INTO %s %s VALUES ', $table, $rtvalues);
        $tempString = '';
        $i = 0;
        echo '[Starting to populate sphinx RT index ' . $table . ' with ' . $total . ' releases.] ';
        foreach ($rows as $row) {
            $i++;
            switch ($table) {
                case 'releases_rt':
                    $tempString .= sprintf('(%d, %s, %s, %s, %s),', $row['id'], $sphinx->sphinxQL->escapeString($row['name']), $sphinx->sphinxQL->escapeString($row['searchname']), $sphinx->sphinxQL->escapeString($row['fromname']), $sphinx->sphinxQL->escapeString($row['filename']));
                    break;
            }
            if ($i === 1000 || $i >= $total) {
                $sphinx->sphinxQL->queryExec($string . rtrim($tempString, ','));
                $tempString = '';
                $total -= $i;
                $i = 0;
                echo '.';
            }
        }
        echo ' [Done.]' . PHP_EOL;
    } else {
        echo 'No releases in your DB or an error occurred. This will need to be resolved before you can use the search.' . PHP_EOL;
    }
}
コード例 #4
0
ファイル: test-nntp-debug.php プロジェクト: sebst3r/nZEDb
    {
        if (PEAR_LOG_DEBUG) {
            echo $this->color->info($message);
        }
    }
}
$nntp = new NNTPTest(new NNTPDebug(isset($argv[1]) ? true : false));
if ($nntp->doConnect() !== true) {
    exit('Error connecting to usenet!' . PHP_EOL);
}
$n = PHP_EOL;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////// Put your test code under here. ////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$db = new DB();
$groups = $db->query('SELECT name FROM groups WHERE name NOT like \'alt.binaries.%\' AND active = 1');
$groupList = [];
foreach ($groups as $group) {
    $groupList += $nntp->getGroups($group['name']);
}
$groupList += $nntp->getGroups('alt.binaries.*');
$groups = $db->queryDirect('SELECT name FROM groups WHERE active = 1');
$activeGroups = [];
if ($groups instanceof \Traversable) {
    foreach ($groups as $group) {
        if (isset($groupList[$group['name']])) {
            $activeGroups[$group['name']] = $groupList[$group['name']];
        }
    }
}
var_dump($activeGroups);