Beispiel #1
0
 /**
  * Perform cleanup of all items in arrays.
  */
 private function doClean()
 {
     $this->numnuked += count($this->cleanup['nuke']);
     $this->nummiscd += count($this->cleanup['misc']);
     if (!$this->echoonly) {
         $releases = new \Releases(['Settings' => $this->pdo]);
         foreach (array_keys($this->cleanup['nuke']) as $id) {
             $releases->delete($id);
         }
         if (count($this->cleanup['misc'])) {
             $sql = 'update releases set categoryid = ' . Category::CAT_MISC_OTHER . ' where categoryid != ' . Category::CAT_MISC_OTHER . ' and id in (' . implode(array_keys($this->cleanup['misc']), ',') . ')';
             $this->pdo->queryExec($sql);
         }
     }
     $this->cleanup = array('nuke' => array(), 'misc' => array());
 }
 /**
  * Reset all stats about a group and delete all releases and binaries associated with that group.
  */
 public function purge($id)
 {
     require_once WWW_DIR . "/lib/binaries.php";
     $db = new DB();
     $releases = new Releases();
     $binaries = new Binaries();
     $this->reset($id);
     $rels = $db->query(sprintf("select ID from releases where groupID = %d", $id));
     foreach ($rels as $rel) {
         $releases->delete($rel["ID"]);
     }
     $bins = $db->query(sprintf("select ID from binaries where groupID = %d", $id));
     foreach ($bins as $bin) {
         $binaries->delete($bin["ID"]);
     }
 }
<?php

require_once "config.php";
$page = new AdminPage();
if (isset($_GET['id'])) {
    $releases = new Releases();
    $releases->delete($_GET['id']);
}
if (isset($_GET['from'])) {
    $referrer = $_GET['from'];
} else {
    $referrer = $_SERVER['HTTP_REFERER'];
}
header("Location: " . $referrer);
     # regular expression entry abort futher checks
     $strerr = str_pad((int) $errcnt, 2, " ", STR_PAD_LEFT);
     if (isset($bl["ID"])) {
         echo "{$strerr}. id=" . $bl["ID"] . ", ";
     }
     echo " name=" . $header["name"] . "\n";
     echo "\t regex={$regex}\n";
     echo "\t error=" . $e->getMessage() . "\n\n";
     exit(1);
 }
 if ($blacklist_check) {
     $errcnt++;
     echo 'BL: /' . $bl['regex'] . '/i matched ' . $header['ID'] . '/' . $header['name'] . " (" . $header['groupname'] . ")\n";
     if ($purgeMatched && isset($header['ID']) && $header['ID'] > 0) {
         // Support purging if enabled
         $release->delete($header['ID']);
     }
     # ensure whitelist flags are off to avoid extra processing
     # at the end of this loop (Below)
     $whitelist = array();
     break;
 }
 if ($use_CategorySizeRestrictions == true && $header['categoryID']) {
     $sizes = null;
     if ($use_NNCategorySizeRestrictions) {
         $sizes = $category->getSizeRangeById($header['categoryID']);
     } else {
         if (array_key_exists($header['categoryID'], $categoryRestrictions)) {
             $sizes = $categoryRestrictions[$header['categoryID']];
         }
     }
//
//$sql = "select ID from releases where fromname = 'PowerBUS@gmail.com (PowerBUS)'";
//
// [5] delete all under a certain amount of completion
//
//$sql = "select ID from releases where completion != 0 and completion != 100 and completion < 99";
//
// [6] all audio which contains a file with .exe in
//
//$sql = "select distinct r.ID from releasefiles rf inner join releases r on r.id = rf.releaseID and r.categoryID like '3%' where rf.name like '%.exe'";
//
// [7] delete all releases for a name
//
//$sql = "select ID from releases where searchname like '%Friday The 13th The Series S03 -enjoy-%'";
//
// [8] delete all releases for a regex
//
//$sql = "select ID from releases where regexID = 1307";
//
// [9] delete all releases under a certain size (100MB) for a category
//
//$sql = "select ID from releases where categoryID like '2%' and size < 104857600";
if ($sql == "") {
    echo "You must uncomment one of the sql selects above to determine which releases are to be deleted.";
} else {
    $rel = $db->query($sql);
    echo "about to delete " . count($rel) . " release(s)";
    foreach ($rel as $r) {
        $releases->delete($r['ID']);
    }
}
Beispiel #6
0
 public function processUnwanted()
 {
     $r = new Releases();
     $currTime_ori = $this->pdo->queryOneRow("SELECT NOW() as now");
     //
     // Delete any passworded releases
     //
     if ($this->pdo->getSetting('deletepasswordedrelease') == 1) {
         echo "PostPrc : Removing unwanted releases\n";
         $result = $this->pdo->query("select id from releases where passwordstatus > 0");
         foreach ($result as $row) {
             $r->delete($row["id"]);
         }
     }
     //
     // Delete any releases which are older than site's release retention days
     //
     if ($this->pdo->getSetting('releaseretentiondays') != 0) {
         echo "PostPrc : Deleting releases older than " . $this->pdo->getSetting('releaseretentiondays') . " days\n";
         $result = $this->pdo->query(sprintf("select id from releases where postdate < %s - interval %d day", $this->pdo->escapeString($currTime_ori["now"]), $this->pdo->getSetting('releaseretentiondays')));
         foreach ($result as $row) {
             $r->delete($row["id"]);
         }
     }
     //
     // Delete any audiopreviews older than site->audiopreviewprune days
     //
     if ($this->pdo->getSetting('audiopreviewprune') > 0) {
         $result = $this->pdo->query(sprintf("select guid from releases where categoryid in (select id from category where parentid = " . Category::CAT_PARENT_MUSIC . ") and haspreview = 2 and adddate < %s - interval %d day", $this->pdo->escapeString($currTime_ori["now"]), $this->pdo->getSetting('audiopreviewprune')));
         if (sizeof($result) > 0) {
             echo "PostPrc : Deleting " . count($result) . " audio previews older than " . $this->pdo->getSetting('audiopreviewprune') . " days\n";
             foreach ($result as $row) {
                 $r->updateHasPreview($row["guid"], 0);
                 $this->deleteAudioSample($row["guid"]);
             }
         }
     }
     //
     // Delete any releases suspected of being spam/virus
     //
     if ($this->pdo->getSetting('removespam') != 0) {
         $spamIDs = array();
         //
         // all releases where the only file inside the rars is *.exe and they are not in the PC category
         //
         $sql = "select releasefiles.releaseid as id from releasefiles inner join  ( select releaseid, count(*) as totnum from  releasefiles group by releaseid ) x on x.releaseid = releasefiles.releaseid and x.totnum = 1 inner join releases on releases.id = releasefiles.releaseid left join releasenfo on releasenfo.releaseid = releases.id where (releasefiles.name like '%.exe' or releasefiles.name like '%.scr') and (releases.categoryid not in (select id from category where parentid = " . Category::CAT_PARENT_PC . ") or (releases.categoryid in (select id from category where parentid = " . Category::CAT_PARENT_PC . ") and releasenfo.id is null)) group by releasefiles.releaseid";
         $result = $this->pdo->query($sql);
         $spamIDs = array_merge($result, $spamIDs);
         //
         // all releases containing exe not in permitted categories
         //
         if ($this->pdo->getSetting('exepermittedcategories') != '') {
             $sql = sprintf("select releasefiles.releaseid as id from releasefiles  inner join releases on releases.id = releasefiles.releaseid  left join releasenfo on releasenfo.releaseid = releases.id  where releasefiles.name like '%%.exe'  and releases.categoryid not in (%s)  group by releasefiles.releaseid", $this->pdo->getSetting('exepermittedcategories'));
             $result = $this->pdo->query($sql);
             $spamIDs = array_merge($result, $spamIDs);
         }
         //
         // delete all releases which contain a file with password.url in it
         //
         $sql = "select distinct releasefiles.releaseid as id from releasefiles where name = 'password.url'";
         $result = $this->pdo->query($sql);
         $spamIDs = array_merge($result, $spamIDs);
         //
         // all releases where the only file inside the rars is *.rar
         //
         $sql = "select releasefiles.releaseid as id from releasefiles  inner join  ( select releaseid, count(*) as totnum from releasefiles group by releaseid ) x on x.releaseid = releasefiles.releaseid and x.totnum = 1 inner join releases on releases.id = releasefiles.releaseid where releasefiles.name like '%.rar' group by releasefiles.releaseid";
         $result = $this->pdo->query($sql);
         $spamIDs = array_merge($result, $spamIDs);
         //
         // all audio which contains a file with .exe in
         //
         $sql = "select distinct r.id from releasefiles rf inner join releases r on r.id = rf.releaseid and r.categoryid in (select id from category where parentid = " . Category::CAT_PARENT_MUSIC . ") where (rf.name like '%.exe' or rf.name like '%.bin')";
         $result = $this->pdo->query($sql);
         $spamIDs = array_merge($result, $spamIDs);
         if (count($spamIDs) > 0) {
             echo "PostPrc : Deleting " . count($spamIDs) . " spam releases\n";
             foreach ($spamIDs as $row) {
                 $r->delete($row["id"]);
             }
         }
     }
 }
Beispiel #7
0
             }
             if (!file_exists($importedpath . basename($nzbFile))) {
                 rename($nzbFile, $importedpath . basename($nzbFile));
             }
         }
     } else {
         echo sprintf("%0" . $digits . "d %.2f%% Error : Failed to write file to disk %s\n", $items - $num, $num / $items * 100, $nzbfilename);
         if ($movefiles) {
             if (!file_exists($errorpath)) {
                 mkdir($errorpath);
             }
             if (!file_exists($errorpath . basename($nzbFile))) {
                 rename($nzbFile, $errorpath . basename($nzbFile));
             }
         }
         $releases->delete($relid);
     }
 } else {
     $numbins = 0;
     $numparts = 0;
     $binaryId = 0;
     $groupRegexes = $releaseRegex->getForGroup($groupName);
     foreach ($nzbInfo->nzb as $postFile) {
         $regexMatches = [];
         foreach ($groupRegexes as $groupRegex) {
             $regexCheck = $releaseRegex->performMatch($groupRegex, $postFile["subject"]);
             if ($regexCheck !== false) {
                 $regexMatches = $regexCheck;
                 break;
             }
         }
$releases = new Releases();
$category = new Category();
// set the current action
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
$id = isset($_REQUEST['id']) && is_array($_REQUEST['id']) ? $_REQUEST['id'] : '';
$page->smarty->assign('action', $action);
$page->smarty->assign('idArr', $id);
switch ($action) {
    case 'doedit':
    case 'edit':
        $success = false;
        if ($action == 'doedit') {
            $upd = $releases->updatemulti($_REQUEST["id"], $_REQUEST["category"], $_REQUEST["grabs"], $_REQUEST["tvinfoID"], $_REQUEST["season"], $_REQUEST['imdbID']);
            if ($upd !== false) {
                $success = true;
            } else {
            }
        }
        $page->smarty->assign('success', $success);
        $page->smarty->assign('from', isset($_REQUEST['from']) ? $_REQUEST['from'] : '');
        $page->smarty->assign('catlist', $category->getForSelect());
        $page->content = $page->smarty->fetch('ajax_release-edit.tpl');
        echo $page->content;
        break;
    case 'dodelete':
        $releases->delete($_REQUEST["id"], true);
        break;
    default:
        $page->show404();
        break;
}
 public function processGID($limit = 500, $batch = 5000, $delete_broken_releases = false)
 {
     // Process until someone presses cntrl-c
     $db = new DB();
     $nzb = new NZB();
     $processed = 0;
     // We need an offset for tracking unhandled issues
     $offset = 0;
     $fsql = 'SELECT ID, name, guid FROM releases ' . 'WHERE GID IS NULL ORDER BY adddate DESC LIMIT %d,%d';
     $usql = "UPDATE releases SET GID = '%s' WHERE ID = %d";
     while (1) {
         // finish
         if ($limit > 0 && $processed >= $limit) {
             break;
         }
         $batch = $limit > 0 && $batch > $limit ? $limit : $batch;
         $res = $db->query(sprintf($fsql, $offset, $batch));
         if (!$res) {
             break;
         }
         if (count($res) <= 0) {
             break;
         }
         $offset += $batch;
         foreach ($res as $r) {
             $nzbfile = $nzb->getNZBPath($r["guid"]);
             if ($nzbfile === Null) {
                 continue;
             }
             $nzbInfo = new NzbInfo();
             if (!$nzbInfo->loadFromFile($nzbfile)) {
                 if ($delete_broken_releases) {
                     $release = new Releases();
                     $release->delete($r['ID']);
                     // Free the variable in an attempt to recover memory
                     unset($release);
                     echo '-';
                 } else {
                     // Skip over this one for future fetches
                     $offset++;
                 }
                 continue;
             }
             $gid = false;
             if (!empty($nzbInfo->gid)) {
                 $gid = $nzbInfo->gid;
             }
             // Free the variable in an attempt to recover memory
             unset($nzbInfo);
             if (!$gid) {
                 if ($delete_broken_releases) {
                     $release = new Releases();
                     $release->delete($r['ID']);
                     unset($release);
                     echo '-';
                 } else {
                     // Skip over this one for future fetches
                     $offset++;
                 }
                 continue;
             }
             // Update DB With Global Identifer
             $ures = $db->exec(sprintf($usql, $gid, $r['ID']));
             if ($ures < 0) {
                 printf("\nPostPrc : Failed to update: %s\n", $r['name']);
             }
             // make noise...
             echo '.';
             $processed += 1;
         }
     }
     # Batch update for comment table
     $usql = 'UPDATE releasecomment, releases ' . 'SET releasecomment.GID = releases.GID ' . 'WHERE releases.ID = releasecomment.releaseID ' . 'AND releasecomment.GID IS NULL ' . 'AND releases.GID IS NOT NULL ';
     $affected = $db->exec(sprintf($usql));
     if ($affected > 0) {
         $processed += $affected;
     }
     return $processed;
 }