Example #1
0
 $con = '';
 if ($data['consoleinfoid'] != '') {
     $c = new Console();
     $con = $c->getConsoleInfo($data['consoleinfoid']);
 }
 $AniDBAPIArray = '';
 if ($data["anidbid"] > 0) {
     $AniDB = new AniDB(['Settings' => $releases->pdo]);
     $AniDBAPIArray = $AniDB->getAnimeInfo($data["anidbid"]);
 }
 $predbQuery = '';
 if ($data["preid"] > 0) {
     $PreDB = new PreDB();
     $predbQuery = $PreDB->getByID($data["preid"]);
 }
 $prehash = new PreHash();
 $pre = $prehash->getForRelease($data["prehashid"]);
 $rf = new ReleaseFiles();
 $releasefiles = $rf->get($data["id"]);
 $page->smarty->assign('releasefiles', $releasefiles);
 $page->smarty->assign('release', $data);
 $page->smarty->assign('reVideo', $reVideo);
 $page->smarty->assign('reAudio', $reAudio);
 $page->smarty->assign('reSubs', $reSubs);
 $page->smarty->assign('nfo', $nfo);
 $page->smarty->assign('rage', $rage);
 $page->smarty->assign('movie', $mov);
 $page->smarty->assign('xxx', $xxx);
 $page->smarty->assign('episode', $episodeArray);
 $page->smarty->assign('anidb', $AniDBAPIArray);
 $page->smarty->assign('music', $mus);
Example #2
0
 /**
  * Create releases from complete binaries.
  *
  * @param int|string $groupID (optional)
  *
  * @return int
  * @access public
  */
 public function createReleases($groupID)
 {
     $startTime = time();
     $group = $this->groups->getCBPTableNames($this->tablePerGroup, $groupID);
     $page = new Page();
     $this->pdo->log->doEcho($this->pdo->log->primary('Creating releases from complete binaries'));
     $this->pdo->ping(true);
     //
     // Get out all distinct relname, group from binaries
     //
     $categorize = new \Categorize(['Settings' => $this->pdo]);
     $returnCount = $duplicate = 0;
     $result = $this->pdo->queryDirect(sprintf("SELECT %s.*, g.name AS group_name, count(%s.id) AS parts FROM %s INNER JOIN groups g ON g.id = %s.groupid WHERE %s procstat = %d AND relname IS NOT NULL GROUP BY relname, g.name, groupid, fromname ORDER BY COUNT(%s.id) DESC LIMIT %d", $group['bname'], $group['bname'], $group['bname'], $group['bname'], !empty($groupID) ? ' groupid = ' . $groupID . ' AND ' : ' ', Releases::PROCSTAT_READYTORELEASE, $group['bname'], $this->releaseCreationLimit));
     while ($row = $this->pdo->getAssocArray($result)) {
         $relguid = $this->createGUID();
         // Clean release name
         $releaseCleaning = new ReleaseCleaning();
         $cleanRelName = $this->cleanReleaseName($row['relname']);
         $cleanedName = $releaseCleaning->releaseCleaner($row['relname'], $row['fromname'], $row['group_name']);
         if (is_array($cleanedName)) {
             $properName = $cleanedName['properlynamed'];
             $prehashID = isset($cleanerName['predb']) ? $cleanerName['predb'] : false;
             $isReqID = isset($cleanerName['requestid']) ? $cleanerName['requestid'] : false;
             $cleanedName = $cleanedName['cleansubject'];
         } else {
             $properName = true;
             $isReqID = $prehashID = false;
         }
         if ($prehashID === false && $cleanedName !== '') {
             // try to match the cleaned searchname to predb title or filename here
             $preHash = new PreHash();
             $preMatch = $preHash->matchPre($cleanedName);
             if ($preMatch !== false) {
                 $cleanedName = $preMatch['title'];
                 $prehashID = $preMatch['prehashid'];
                 $properName = true;
             }
         }
         $relid = $this->insertRelease(['name' => $this->pdo->escapeString($cleanRelName), 'searchname' => $this->pdo->escapeString(utf8_encode($cleanedName)), 'totalpart' => $row["parts"], 'groupid' => $row["groupid"], 'guid' => $this->pdo->escapeString($relguid), 'categoryid' => $categorize->determineCategory($groupID, $cleanedName), 'regexid' => $row["regexid"], 'postdate' => $this->pdo->escapeString($row['date']), 'fromname' => $this->pdo->escapeString($row['fromname']), 'reqid' => $row["reqid"], 'passwordstatus' => $page->settings->getSetting('checkpasswordedrar') > 0 ? -1 : 0, 'nzbstatus' => \Enzebe::NZB_NONE, 'isrenamed' => $properName === true ? 1 : 0, 'reqidstatus' => $isReqID === true ? 1 : 0, 'prehashid' => $prehashID === false ? 0 : $prehashID]);
         //
         // Tag every binary for this release with its parent release id
         //
         $this->pdo->queryExec(sprintf("UPDATE %s SET procstat = %d, releaseid = %d WHERE relname = %s AND procstat = %d AND %s fromname=%s", $group['bname'], Releases::PROCSTAT_RELEASED, $relid, $this->pdo->escapeString($row["relname"]), Releases::PROCSTAT_READYTORELEASE, !empty($groupID) ? ' groupid = ' . $groupID . ' AND ' : ' ', $this->pdo->escapeString($row["fromname"])));
         $cat = new \Categorize(['Settings' => $this->pdo]);
         //
         // Write the nzb to disk
         //
         $catId = $cat->determineCategory($groupID, $cleanRelName);
         $nzbfile = $this->nzb->getNZBPath($relguid, $page->settings->getSetting('nzbpath'), true);
         $this->nzb->writeNZBforreleaseID($relid, $cleanRelName, $catId, $nzbfile, $groupID);
         //
         // Remove used binaries
         //
         $this->pdo->queryDelete(sprintf("DELETE %s, %s FROM %s JOIN %s ON %s.id = %s.binaryid WHERE releaseid = %d ", $group['pname'], $group['bname'], $group['pname'], $group['bname'], $group['bname'], $group['pname'], $relid));
         //
         // If nzb successfully written, then load it and get size completion from it
         //
         $nzbInfo = new NZBInfo();
         if (!$nzbInfo->loadFromFile($nzbfile)) {
             $this->pdo->log->doEcho($this->pdo->log->primary('Failed to write nzb file (bad perms?) ' . $nzbfile . ''));
             $this->delete($relid);
         } else {
             // Check if gid already exists
             $dupes = $this->pdo->queryOneRow(sprintf("SELECT EXISTS(SELECT 1 FROM releases WHERE gid = %s) AS total", $this->pdo->escapeString($nzbInfo->gid)));
             if ($dupes['total'] > 0) {
                 $this->pdo->log->doEcho($this->pdo->log->primary('Duplicate - ' . $cleanRelName . ''));
                 $this->delete($relid);
                 $duplicate++;
             } else {
                 $this->pdo->queryExec(sprintf("UPDATE releases SET totalpart = %d, size = %s, COMPLETION = %d, GID=%s , nzb_guid = %s WHERE id = %d", $nzbInfo->filecount, $nzbInfo->filesize, $nzbInfo->completion, $this->pdo->escapeString($nzbInfo->gid), $this->pdo->escapeString($nzbInfo->gid), $relid));
                 $this->pdo->log->doEcho($this->pdo->log->primary('Added release ' . $cleanRelName . ''));
                 $returnCount++;
                 if ($this->echoCLI) {
                     $this->pdo->log->doEcho($this->pdo->log->primary('Added ' . $returnCount . 'releases.'));
                 }
             }
         }
     }
     if ($this->echoCLI) {
         $this->pdo->log->doEcho($this->pdo->log->primary(PHP_EOL . number_format($returnCount) . ' Releases added and ' . number_format($duplicate) . ' duplicate releases deleted in ' . $this->consoleTools->convertTime(time() - $startTime)), true);
     }
     return ['added' => $returnCount, 'dupes' => $duplicate];
 }
Example #3
0
<?php

if (!$page->users->isLoggedIn()) {
    $page->show403();
}
if (!isset($_REQUEST["id"])) {
    $page->show404();
}
$pre = new PreHash();
$predata = $pre->getOne($_REQUEST["id"]);
if (!$predata) {
    print "No pre info";
} else {
    print "<table>\n";
    if (isset($predata['nuked'])) {
        $nuked = '';
        switch ($predata['nuked']) {
            case PreHash::PRE_NUKED:
                $nuked = 'NUKED';
                break;
            case PreHash::PRE_MODNUKE:
                $nuked = 'MODNUKED';
                break;
            case PreHash::PRE_OLDNUKE:
                $nuked = 'OLDNUKE';
                break;
            case PreHash::PRE_RENUKED:
                $nuked = 'RENUKE';
                break;
            case PreHash::PRE_UNNUKED:
                $nuked = 'UNNUKED';
Example #4
0
<?php

/*
 * This script attemps to clean release names using the NFO, file name and release name, Par2 file.
 * A good way to use this script is to use it in this order: php fixReleaseNames.php 3 true other yes
 * php fixReleaseNames.php 5 true other yes
 * If you used the 4th argument yes, but you want to reset the status,
 * there is another script called resetRelnameStatus.php
 */
require_once dirname(__FILE__) . "/../bin/config.php";
use newznab\db\Settings;
$n = "\n";
$pdo = new Settings();
$namefixer = new \NameFixer(['Settings' => $pdo]);
$predb = new \PreHash(['Echo' => true, 'Settings' => $pdo]);
if (isset($argv[1]) && isset($argv[2]) && isset($argv[3]) && isset($argv[4])) {
    $update = $argv[2] == "true" ? 1 : 2;
    $other = 1;
    if ($argv[3] === 'all') {
        $other = 2;
    } else {
        if ($argv[3] === 'preid') {
            $other = 3;
        }
    }
    $setStatus = $argv[4] == "yes" ? 1 : 2;
    $show = 2;
    if (isset($argv[5]) && $argv[5] === 'show') {
        $show = 1;
    }
    $nntp = null;
Example #5
0
<?php

if (!$page->users->isLoggedIn()) {
    $page->show403();
}
$predb = new PreHash();
$offset = isset($_REQUEST["offset"]) && ctype_digit($_REQUEST['offset']) ? $_REQUEST["offset"] : 0;
if (isset($_REQUEST['prehashsearch'])) {
    $lastSearch = $_REQUEST['prehashsearch'];
    $parr = $predb->getAll($offset, ITEMS_PER_PAGE, $_REQUEST['prehashsearch']);
} else {
    $lastSearch = '';
    $parr = $predb->getAll($offset, ITEMS_PER_PAGE);
}
$page->smarty->assign('pagertotalitems', $parr['count']);
$page->smarty->assign('pageroffset', $offset);
$page->smarty->assign('pageritemsperpage', ITEMS_PER_PAGE);
$page->smarty->assign('pagerquerybase', WWW_TOP . "/prehash/&amp;offset=");
$page->smarty->assign('pagerquerysuffix', "#results");
$pager = $page->smarty->fetch("pager.tpl");
$page->smarty->assign('pager', $pager);
$page->smarty->assign('results', $parr['arr']);
$page->title = "Browse Prehash";
$page->meta_title = "View Prehash info";
$page->meta_keywords = "view,prehash,info,description,details";
$page->meta_description = "View Prehash info";
$page->content = $page->smarty->fetch('prehash.tpl');
$page->render();