コード例 #1
0
ファイル: NZBGet.php プロジェクト: sebst3r/nZEDb
    /**
     * Send a NZB to NZBGet.
     *
     * @param string $guid Release identifier.
     *
     * @return bool|mixed
     *
     * @access public
     */
    public function sendNZBToNZBGet($guid)
    {
        $relData = $this->Releases->getByGuid($guid);
        $string = Utility::unzipGzipFile($this->NZB->getNZBPath($guid));
        $string = $string === false ? '' : $string;
        $encoded = base64_encode($string);
        $header = <<<NZBGet_NZB
<?xml version="1.0"?>
<methodCall>
\t<methodName>append</methodName>
\t<params>
\t\t<param>
\t\t\t<value><string>{$relData['searchname']}</string></value>
\t\t</param>
\t\t<param>
\t\t\t<value><string>{$relData['category_name']}</string></value>
\t\t</param>
\t\t<param>
\t\t\t<value><i4>0</i4></value>
\t\t</param>
\t\t<param>
\t\t\t<value><boolean>>False</boolean></value>
\t\t</param>
\t\t<param>
\t\t\t<value>
\t\t\t\t<string>
{$encoded}
\t\t\t\t</string>
\t\t\t</value>
\t\t</param>
\t</params>
</methodCall>
NZBGet_NZB;
        Utility::getUrl(['url' => $this->fullURL . 'append', 'method' => 'post', 'postdata' => $header, 'verifycert' => false]);
    }
コード例 #2
0
ファイル: remove_exact_dupes.php プロジェクト: sebst3r/nZEDb
$size = ' size ';
if ($argv[2] === 'near') {
    $size = ' size between (size *.99) AND (size * 1.01) ';
}
if ($crosspostt != 0) {
    $query = sprintf('SELECT max(id) AS id, id AS idx, guid FROM releases WHERE adddate > (NOW() - INTERVAL %d HOUR) GROUP BY name, fromname, group_id,' . $size . 'HAVING COUNT(*) > 1', $crosspostt);
} else {
    $query = sprintf('SELECT max(id) AS id, id AS idx, guid FROM releases GROUP BY name, fromname, group_id,' . $size . 'HAVING COUNT(*) > 1');
}
do {
    $resrel = $pdo->queryDirect($query);
    if ($resrel instanceof \Traversable) {
        $total = $resrel->rowCount();
        echo $pdo->log->header(number_format($total) . " Releases have Duplicates");
        foreach ($resrel as $rowrel) {
            $nzbpath = $nzb->getNZBPath($rowrel['guid']);
            if (isset($argv[3]) && is_dir($argv[3])) {
                $path = $argv[3];
                if (substr($path, strlen($path) - 1) != '/') {
                    $path = $path . "/";
                }
                if (!file_exists($path . $rowrel['guid'] . ".nzb.gz") && file_exists($nzbpath)) {
                    if (@copy($nzbpath, $path . $rowrel['guid'] . ".nzb.gz") !== true) {
                        exit("\n" . $pdo->log->error("\nUnable to write " . $path . $rowrel['guid'] . ".nzb.gz"));
                    }
                }
            }
            if ($releases->deleteSingle(['g' => $rowrel['guid'], 'i' => $rowrel['idx']], $nzb, $ri) !== false) {
                $consoleTools->overWritePrimary('Deleted: ' . number_format(++$count) . " Duplicate Releases");
            }
        }
コード例 #3
0
ファイル: filelist.php プロジェクト: sebst3r/nZEDb
<?php

use nzedb\NZB;
use nzedb\Releases;
use nzedb\utility\Utility;
if (!$page->users->isLoggedIn()) {
    $page->show403();
}
if (isset($_GET["id"])) {
    $releases = new Releases(['Settings' => $page->settings]);
    $rel = $releases->getByGuid($_GET["id"]);
    if (!$rel) {
        $page->show404();
    }
    $nzb = new NZB($page->settings);
    $nzbpath = $nzb->getNZBPath($_GET["id"]);
    if (!file_exists($nzbpath)) {
        $page->show404();
    }
    $nzbfile = Utility::unzipGzipFile($nzbpath);
    $ret = $nzb->nzbFileList($nzbfile);
    $offset = isset($_REQUEST["offset"]) && ctype_digit($_REQUEST['offset']) ? $_REQUEST["offset"] : 0;
    $page->smarty->assign('pagertotalitems', sizeof($ret));
    $page->smarty->assign('pageroffset', $offset);
    $page->smarty->assign('pageritemsperpage', ITEMS_PER_PAGE);
    $page->smarty->assign('pagerquerybase', WWW_TOP . "/filelist/" . $_GET["id"] . "/&amp;offset=");
    $page->smarty->assign('pagerquerysuffix', "#results");
    $pager = $page->smarty->fetch("pager.tpl");
    $page->smarty->assign('pager', $pager);
    $page->smarty->assign('rel', $rel);
    $page->smarty->assign('files', array_slice($ret, $offset, ITEMS_PER_PAGE));
コード例 #4
0
ファイル: nzb-reorg.php プロジェクト: kaibosh/nZEDb
$pdo = new Settings();
$nzb = new NZB($pdo);
$consoleTools = new ConsoleTools();
$newLevel = $argv[1];
$sourcePath = $argv[2];
$objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($sourcePath));
$filestoprocess = [];
$iFilesProcessed = $iFilesCounted = 0;
$time = TIME();
echo "\nReorganizing files to Level {$newLevel} from: {$sourcePath} This could take a while...\n";
//$consoleTools = new \ConsoleTools();
foreach ($objects as $filestoprocess => $nzbFile) {
    if ($nzbFile->getExtension() != "gz") {
        continue;
    }
    $newFileName = $nzb->getNZBPath(str_replace(".nzb.gz", "", $nzbFile->getBasename()), $newLevel, true);
    if ($newFileName != $nzbFile) {
        rename($nzbFile, $newFileName);
        chmod($newFileName, 0777);
    }
    $iFilesProcessed++;
    if ($iFilesProcessed % 100 == 0) {
        $consoleTools->overWrite("Reorganized {$iFilesProcessed}");
    }
}
$pdo->ping(true);
$pdo->queryExec(sprintf("UPDATE settings SET value = %s WHERE setting = 'nzbsplitlevel'", $argv[1]));
$consoleTools->overWrite("Processed {$iFilesProcessed} nzbs in " . relativeTime($time) . "\n");
function relativeTime($_time)
{
    $d = array();
コード例 #5
0
ファイル: nzb-import.php プロジェクト: sebst3r/nZEDb
/**
 * Compress an imported NZB and store it inside the nzbfiles folder.
 *
 * @param string $relguid    The guid of the release.
 * @param string $nzb        String containing the imported NZB.
 * @param NZB    $NZB
 * @param object $pdo
 *
 * @return bool
 *
 */
function copyNZBforImport($relguid, $nzb, $NZB, $pdo)
{
    $path = $NZB->getNZBPath($relguid, 0, true);
    $fp = gzopen($path, 'w5');
    if ($fp && $nzb) {
        $date1 = htmlspecialchars(date('F j, Y, g:i a O'), ENT_QUOTES, 'utf-8');
        $article = preg_replace('/dtd">\\s*<nzb xmlns=/', "dtd\">\n<!-- NZB Generated by: nZEDb " . $pdo->version() . ' ' . $date1 . " -->\n<nzb xmlns=", $nzb);
        gzwrite($fp, preg_replace('/<\\/file>\\s*(<!--.+)?\\s*<\\/nzb>\\s*/si', "</file>\n  <!--GrabNZBs-->\n</nzb>", $article));
        gzclose($fp);
        // Chmod to fix issues some users have with file permissions.
        chmod($path, 0777);
        return true;
    } else {
        echo "ERROR: NZB already exists?\n";
        return false;
    }
}
コード例 #6
0
ファイル: NZBImport.php プロジェクト: sebst3r/nZEDb
 /**
  * @param array $filesToProcess List of NZB files to import.
  * @param bool|string $useNzbName Use the NZB file name as release name?
  * @param bool $delete Delete the NZB when done?
  * @param bool $deleteFailed Delete the NZB if failed importing?
  *
  * @return string|bool
  *
  * @access public
  */
 public function beginImport($filesToProcess, $useNzbName = false, $delete = true, $deleteFailed = true)
 {
     // Get all the groups in the DB.
     if (!$this->getAllGroups()) {
         if ($this->browser) {
             return $this->retVal;
         } else {
             return false;
         }
     }
     $start = date('Y-m-d H:i:s');
     $nzbsImported = $nzbsSkipped = 0;
     // Loop over the file names.
     foreach ($filesToProcess as $nzbFile) {
         // Check if the file is really there.
         if (is_file($nzbFile)) {
             // Get the contents of the NZB file as a string.
             if (strtolower(substr($nzbFile, -7)) === '.nzb.gz') {
                 $nzbString = Utility::unzipGzipFile($nzbFile);
             } else {
                 $nzbString = file_get_contents($nzbFile);
             }
             if ($nzbString === false) {
                 $this->echoOut('ERROR: Unable to read: ' . $nzbFile);
                 if ($deleteFailed) {
                     @unlink($nzbFile);
                 }
                 $nzbsSkipped++;
                 continue;
             }
             // Load it as a XML object.
             $nzbXML = @simplexml_load_string($nzbString);
             if ($nzbXML === false || strtolower($nzbXML->getName()) != 'nzb') {
                 $this->echoOut('ERROR: Unable to load NZB XML data: ' . $nzbFile);
                 if ($deleteFailed) {
                     @unlink($nzbFile);
                 }
                 $nzbsSkipped++;
                 continue;
             }
             // Try to insert the NZB details into the DB.
             $inserted = $this->scanNZBFile($nzbXML, $useNzbName ? str_ireplace('.nzb', '', basename($nzbFile)) : false);
             if ($inserted) {
                 // Try to copy the NZB to the NZB folder.
                 $path = $this->nzb->getNZBPath($this->relGuid, 0, true);
                 // Try to compress the NZB file in the NZB folder.
                 $fp = gzopen($path, 'w5');
                 gzwrite($fp, $nzbString);
                 gzclose($fp);
                 if (!is_file($path)) {
                     $this->echoOut('ERROR: Problem compressing NZB file to: ' . $path);
                     // Remove the release.
                     $this->pdo->queryExec(sprintf("DELETE FROM releases WHERE guid = %s", $this->pdo->escapeString($this->relGuid)));
                     if ($deleteFailed) {
                         @unlink($nzbFile);
                     }
                     $nzbsSkipped++;
                     continue;
                 } else {
                     if ($delete) {
                         // Remove the nzb file.
                         @unlink($nzbFile);
                     }
                     $nzbsImported++;
                     continue;
                 }
             } else {
                 if ($deleteFailed) {
                     @unlink($nzbFile);
                 }
                 $nzbsSkipped++;
                 continue;
             }
         } else {
             $this->echoOut('ERROR: Unable to fetch: ' . $nzbFile);
             $nzbsSkipped++;
             continue;
         }
     }
     $this->echoOut('Proccessed ' . $nzbsImported . ' NZBs in ' . (strtotime(date('Y-m-d H:i:s')) - strtotime($start)) . ' seconds, ' . $nzbsSkipped . ' NZBs were skipped.');
     if ($this->browser) {
         return $this->retVal;
     } else {
         return true;
     }
 }
コード例 #7
0
ファイル: release-files.php プロジェクト: kaibosh/nZEDb
require_once './config.php';
use nzedb\Releases;
use nzedb\NZB;
use nzedb\utility\Misc;
$page = new AdminPage();
if (!$page->users->isLoggedIn()) {
    $page->show403();
}
if (isset($_GET['id'])) {
    $releases = new Releases(['Settings' => $page->settings]);
    $release = $releases->getByGuid($_GET['id']);
    if ($release === false) {
        $page->show404();
    }
    $nzb = new NZB($page->settings);
    $nzbPath = $nzb->getNZBPath($_GET['id']);
    if (!file_exists($nzbPath)) {
        $page->show404();
    }
    $nzbFile = Misc::unzipGzipFile($nzbPath);
    $files = $nzb->nzbFileList($nzbFile);
    $page->smarty->assign('release', $release);
    $page->smarty->assign('files', $files);
    $page->title = "File List";
    $page->meta_title = "View Nzb file list";
    $page->meta_keywords = "view,nzb,file,list,description,details";
    $page->meta_description = "View Nzb File List";
    $page->content = $page->smarty->fetch('release-files.tpl');
    $page->render();
}