当前位置: 首页>>代码示例>>PHP>>正文


PHP Releases::deleteSingle方法代码示例

本文整理汇总了PHP中Releases::deleteSingle方法的典型用法代码示例。如果您正苦于以下问题:PHP Releases::deleteSingle方法的具体用法?PHP Releases::deleteSingle怎么用?PHP Releases::deleteSingle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Releases的用法示例。


在下文中一共展示了Releases::deleteSingle方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deleteReleases

 /**
  * Delete releases from the database.
  */
 protected function deleteReleases()
 {
     $deletedCount = 0;
     foreach ($this->result as $release) {
         if ($this->delete) {
             $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
             if ($this->echoCLI) {
                 echo $this->pdo->log->primary('Deleting: ' . $this->method . ': ' . $release['searchname']);
             }
         } elseif ($this->echoCLI) {
             echo $this->pdo->log->primary('Would be deleting: ' . $this->method . ': ' . $release['searchname']);
         }
         $deletedCount++;
     }
     $this->deletedCount += $deletedCount;
     return true;
 }
开发者ID:engine9-,项目名称:newznab-tmux,代码行数:20,代码来源:ReleaseRemover.php

示例2: create_guids

function create_guids($live, $delete = false)
{
    $pdo = new Settings();
    $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
    $timestart = TIME();
    $relcount = $deleted = $total = 0;
    $relrecs = false;
    if ($live == "true") {
        $relrecs = $pdo->queryDirect(sprintf("SELECT id, guid FROM releases WHERE nzbstatus = 1 AND nzb_guid IS NULL ORDER BY id DESC"));
    } else {
        if ($live == "limited") {
            $relrecs = $pdo->queryDirect(sprintf("SELECT id, guid FROM releases WHERE nzbstatus = 1 AND nzb_guid IS NULL ORDER BY id DESC LIMIT 10000"));
        }
    }
    if ($relrecs) {
        $total = $relrecs->rowCount();
    }
    if ($total > 0) {
        echo $pdo->log->header("Creating nzb_guids for " . number_format($total) . " releases.");
        $releases = new Releases(['Settings' => $pdo]);
        $nzb = new NZB($pdo);
        $releaseImage = new ReleaseImage($pdo);
        $reccnt = 0;
        if ($relrecs instanceof Traversable) {
            foreach ($relrecs as $relrec) {
                $reccnt++;
                $nzbpath = $nzb->NZBPath($relrec['guid']);
                if ($nzbpath !== false) {
                    $nzbfile = nzedb\utility\Utility::unzipGzipFile($nzbpath);
                    if ($nzbfile) {
                        $nzbfile = @simplexml_load_string($nzbfile);
                    }
                    if (!$nzbfile) {
                        if (isset($delete) && $delete == 'delete') {
                            //echo "\n".$nzb->NZBPath($relrec['guid'])." is not a valid xml, deleting release.\n";
                            $releases->deleteSingle(['g' => $relrec['guid'], 'i' => $relrec['id']], $nzb, $releaseImage);
                            $deleted++;
                        }
                        continue;
                    }
                    $binary_names = array();
                    foreach ($nzbfile->file as $file) {
                        $binary_names[] = $file["subject"];
                    }
                    if (count($binary_names) == 0) {
                        if (isset($delete) && $delete == 'delete') {
                            //echo "\n".$nzb->NZBPath($relrec['guid'])." has no binaries, deleting release.\n";
                            $releases->deleteSingle(['g' => $relrec['guid'], 'i' => $relrec['id']], $nzb, $releaseImage);
                            $deleted++;
                        }
                        continue;
                    }
                    asort($binary_names);
                    foreach ($nzbfile->file as $file) {
                        if ($file["subject"] == $binary_names[0]) {
                            $segment = $file->segments->segment;
                            $nzb_guid = md5($segment);
                            $pdo->queryExec("UPDATE releases set nzb_guid = " . $pdo->escapestring($nzb_guid) . " WHERE id = " . $relrec["id"]);
                            $relcount++;
                            $consoletools->overWritePrimary("Created: [" . $deleted . "] " . $consoletools->percentString($reccnt, $total) . " Time:" . $consoletools->convertTimer(TIME() - $timestart));
                            break;
                        }
                    }
                } else {
                    if (isset($delete) && $delete == 'delete') {
                        //echo $pdo->log->primary($nzb->NZBPath($relrec['guid']) . " does not have an nzb, deleting.");
                        $releases->deleteSingle(['g' => $relrec['guid'], 'i' => $relrec['id']], $nzb, $releaseImage);
                    }
                }
            }
        }
        if ($relcount > 0) {
            echo "\n";
        }
        echo $pdo->log->header("Updated " . $relcount . " release(s). This script ran for " . $consoletools->convertTime(TIME() - $timestart));
    } else {
        echo $pdo->log->info('Query time: ' . $consoletools->convertTime(TIME() - $timestart));
        exit($pdo->log->info("No releases are missing the guid."));
    }
}
开发者ID:Jay204,项目名称:nZEDb,代码行数:80,代码来源:populate_nzb_guid.php

示例3: sprintf

} 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");
            }
        }
    }
    $all += $count;
    $count = 0;
    echo "\n\n";
} while ($total > 0);
echo $pdo->log->header("\nDeleted " . number_format($all) . " Duplicate Releases");
开发者ID:Jay204,项目名称:nZEDb,代码行数:31,代码来源:remove_exact_dupes.php

示例4: processGID

    public function processGID($limit = 500, $batch = 5000, $delete_broken_releases = false)
    {
        // Process until someone presses cntrl-c
        $db = new Settings();
        $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->deleteSingle(['g' => $r['guid'], 'i' => $r['id']], $this->nzb, $this->releaseImage);
                        // 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->{$release}->deleteSingle(['g' => $r['guid'], 'i' => $r['id']], $this->nzb, $this->releaseImage);
                        unset($release);
                        echo '-';
                    } else {
                        // Skip over this one for future fetches
                        $offset++;
                    }
                    continue;
                }
                // Update DB With Global Identifer
                $ures = $db->queryExec(sprintf("UPDATE releases SET gid = %s WHERE id = %d", $db->escapeString($gid), $r['id']));
                if ($ures->rowCount() == 0) {
                    printf("\nPostPrc : Failed to update: %s\n", $r['name']);
                }
                // make noise...
                echo '.';
                $processed += 1;
            }
        }
        # Batch update for comment table
        /*$usql = 'UPDATE release_comments, releases '
        		.'SET release_comments.gid = releases.gid, '
        		.'release_comments.nzb_guid = releases.nzb_guid '
        		.'WHERE releases.id = release_comments.releaseid '
        		.'AND release_comments.gid IS NULL '
        		.'AND release_comments.nzb_guid = "" '
        		.'AND releases.nzb_guid IS NOT NULL '
        		.'AND releases.gid IS NOT NULL ';*/
        $affected = $db->queryExec(sprintf('UPDATE release_comments, releases SET release_comments.gid = releases.gid,
											release_comments.nzb_guid = releases.nzb_guid
											WHERE releases.id = release_comments.releaseid
											AND release_comments.gid IS NULL
											AND release_comments.nzb_guid = ""
											AND releases.nzb_guid IS NOT NULL
											AND releases.gid IS NOT NULL '));
        $rows = $affected->rowCount();
        if ($rows > 0) {
            $processed += $rows;
        }
        return $processed;
    }
开发者ID:RickDB,项目名称:newznab-tmux,代码行数:93,代码来源:SpotNab.php

示例5: purge

 /**
  * Purge a single group or all groups.
  *
  * @param int|string|bool $id The group ID. If false, purge all groups.
  */
 public function purge($id = false)
 {
     if ($id === false) {
         $this->resetall();
     } else {
         $this->reset($id);
     }
     $releaseArray = $this->pdo->queryDirect(sprintf("SELECT id, guid FROM releases %s", $id === false ? '' : 'WHERE group_id = ' . $id));
     if ($releaseArray instanceof Traversable) {
         $releases = new Releases(['Settings' => $this->pdo, 'Groups' => $this]);
         $nzb = new NZB($this->pdo);
         $releaseImage = new ReleaseImage($this->pdo);
         foreach ($releaseArray as $release) {
             $releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $nzb, $releaseImage);
         }
     }
 }
开发者ID:Jay204,项目名称:nZEDb,代码行数:22,代码来源:Groups.php

示例6: RecursiveDirectoryIterator

 $couldbe = $argv[1] === "true" ? $couldbe = "could be " : "were ";
 echo $pdo->log->header('Getting List of nzbs to check against db.');
 $dirItr = new RecursiveDirectoryIterator($pdo->getSetting('nzbpath'));
 $itr = new RecursiveIteratorIterator($dirItr, RecursiveIteratorIterator::LEAVES_ONLY);
 foreach ($itr as $filePath) {
     if (is_file($filePath) && preg_match('/([a-f-0-9]+)\\.nzb\\.gz/', $filePath, $guid)) {
         $nzbfile = nzedb\utility\Utility::unzipGzipFile($filePath);
         if ($nzbfile) {
             $nzbfile = @simplexml_load_string($nzbfile);
         }
         if ($nzbfile) {
             $res = $pdo->queryOneRow(sprintf("SELECT id, guid FROM releases WHERE guid = %s", $pdo->escapeString(stristr($filePath->getFilename(), '.nzb.gz', true))));
             if ($res === false) {
                 if ($argv[1] === "delete") {
                     @copy($filePath, nZEDb_ROOT . "pooped/" . $guid[1] . ".nzb.gz");
                     $releases->deleteSingle(['g' => $guid[1], 'i' => false], $nzb, $releaseImage);
                     $deleted++;
                 }
             } else {
                 if (isset($res)) {
                     $pdo->queryExec(sprintf("UPDATE releases SET nzbstatus = 1 WHERE id = %s", $res['id']));
                 }
             }
         } else {
             if ($argv[1] === "delete") {
                 @copy($filePath, nZEDb_ROOT . "pooped/" . $guid[1] . ".nzb.gz");
                 unlink($filePath);
                 $deleted++;
             }
         }
         $time = $consoletools->convertTime(time() - $timestart);
开发者ID:Jay204,项目名称:nZEDb,代码行数:31,代码来源:clean_nzbs.php

示例7: deleteReleases

    /**
     * Delete releases using admin settings.
     * This deletes releases, regardless of group.
     *
     * @void
     * @access public
     */
    public function deleteReleases()
    {
        $startTime = time();
        $category = new \Category(['Settings' => $this->pdo]);
        $genres = new \Genres(['Settings' => $this->pdo]);
        $passwordDeleted = $duplicateDeleted = $retentionDeleted = $completionDeleted = $disabledCategoryDeleted = 0;
        $disabledGenreDeleted = $miscRetentionDeleted = $miscHashedDeleted = $categoryMinSizeDeleted = 0;
        // Delete old releases and finished collections.
        if ($this->echoCLI) {
            $this->pdo->log->doEcho($this->pdo->log->header("Process Releases -> Delete old releases and passworded releases."));
        }
        // Releases past retention.
        if ($this->pdo->getSetting('releaseretentiondays') != 0) {
            $releases = $this->pdo->queryDirect(sprintf('SELECT id, guid FROM releases WHERE postdate < (NOW() - INTERVAL %d DAY)', $this->pdo->getSetting('releaseretentiondays')));
            if ($releases instanceof \Traversable) {
                foreach ($releases as $release) {
                    $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                    $retentionDeleted++;
                }
            }
        }
        // Passworded releases.
        if ($this->pdo->getSetting('deletepasswordedrelease') == 1) {
            $releases = $this->pdo->queryDirect(sprintf('SELECT id, guid FROM releases WHERE passwordstatus = %d', \Releases::PASSWD_RAR));
            if ($releases instanceof \Traversable) {
                foreach ($releases as $release) {
                    $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                    $passwordDeleted++;
                }
            }
        }
        // Possibly passworded releases.
        if ($this->pdo->getSetting('deletepossiblerelease') == 1) {
            $releases = $this->pdo->queryDirect(sprintf('SELECT id, guid FROM releases WHERE passwordstatus = %d', \Releases::PASSWD_POTENTIAL));
            if ($releases instanceof \Traversable) {
                foreach ($releases as $release) {
                    $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                    $passwordDeleted++;
                }
            }
        }
        if ($this->crossPostTime != 0) {
            // Crossposted releases.
            do {
                $releases = $this->pdo->queryDirect(sprintf('SELECT id, guid FROM releases WHERE adddate > (NOW() - INTERVAL %d HOUR) GROUP BY name HAVING COUNT(name) > 1', $this->crossPostTime));
                $total = 0;
                if ($releases && $releases->rowCount()) {
                    $total = $releases->rowCount();
                    foreach ($releases as $release) {
                        $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                        $duplicateDeleted++;
                    }
                }
            } while ($total > 0);
        }
        if ($this->completion > 0) {
            $releases = $this->pdo->queryDirect(sprintf('SELECT id, guid FROM releases WHERE completion < %d AND completion > 0', $this->completion));
            if ($releases instanceof \Traversable) {
                foreach ($releases as $release) {
                    $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                    $completionDeleted++;
                }
            }
        }
        // Disabled categories.
        $disabledCategories = $category->getDisabledIDs();
        if (count($disabledCategories) > 0) {
            foreach ($disabledCategories as $disabledCategory) {
                $releases = $this->pdo->queryDirect(sprintf('SELECT id, guid FROM releases WHERE categoryid = %d', $disabledCategory['id']));
                if ($releases instanceof \Traversable) {
                    foreach ($releases as $release) {
                        $disabledCategoryDeleted++;
                        $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                    }
                }
            }
        }
        // Delete smaller than category minimum sizes.
        $categories = $this->pdo->queryDirect('
			SELECT c.id AS id,
			CASE WHEN c.minsize = 0 THEN cp.minsize ELSE c.minsize END AS minsize
			FROM category c
			INNER JOIN category cp ON cp.id = c.parentid
			WHERE c.parentid IS NOT NULL');
        if ($categories instanceof \Traversable) {
            foreach ($categories as $category) {
                if ($category['minsize'] > 0) {
                    $releases = $this->pdo->queryDirect(sprintf('
							SELECT r.id, r.guid
							FROM releases r
							WHERE r.categoryid = %d
							AND r.size < %d', $category['id'], $category['minsize']));
                    if ($releases instanceof \Traversable) {
//.........这里部分代码省略.........
开发者ID:Jay204,项目名称:nZEDb,代码行数:101,代码来源:ProcessReleases.php

示例8: dirname

require dirname(__FILE__) . '/../../../www/config.php';
use nzedb\db\Settings;
$pdo = new Settings();
if (isset($argv[1]) && $argv[1] == "true") {
    $timestart = TIME();
    $releases = new Releases(['Settings' => $pdo]);
    $category = new Category(['Settings' => $pdo]);
    $nzb = new NZB($pdo);
    $releaseImage = new ReleaseImage($pdo);
    $catlist = $category->getDisabledIDs();
    $relsdeleted = 0;
    if (count($catlist > 0)) {
        foreach ($catlist as $cat) {
            $rels = $pdo->query(sprintf("SELECT id, guid FROM releases WHERE categoryid = %d", $cat['id']));
            if (count($rels)) {
                foreach ($rels as $rel) {
                    $relsdeleted++;
                    $releases->deleteSingle(['g' => $rel['guid'], 'i' => $rel['id']], $nzb, $releaseImage);
                }
            }
        }
    }
    $time = TIME() - $timestart;
    if ($relsdeleted > 0) {
        echo $pdo->log->header($relsdeleted . " releases deleted in " . $time . " seconds.");
    } else {
        exit($pdo->log->info("No releases to delete."));
    }
} else {
    exit($pdo->log->error("\nDeletes releases in categories you have disabled here : http://localhost/admin/category-list.php\n" . "php {$argv['0']} true    ...: run this script.\n"));
}
开发者ID:Jay204,项目名称:nZEDb,代码行数:31,代码来源:delete_disabled_category_releases.php

示例9: rename

             }
             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->deleteSingle(['g' => $relguid, 'i' => $relid], $nzb, $releaseImage);
     }
 } 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;
             }
         }
开发者ID:RickDB,项目名称:newznab-tmux,代码行数:31,代码来源:import.php


注:本文中的Releases::deleteSingle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。