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


PHP Sites::getLicense方法代码示例

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


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

示例1: updateAllGroups

 /**
  * Process headers and store in database for all active groups.
  */
 function updateAllGroups()
 {
     $n = $this->n;
     $groups = new Groups();
     $res = $groups->getActive();
     $s = new Sites();
     echo $s->getLicense();
     if ($res) {
         shuffle($res);
         $alltime = microtime(true);
         echo 'Updating: ' . sizeof($res) . ' groups - Using compression? ' . ($this->compressedHeaders ? 'Yes' : 'No') . $n;
         $nntp = new Nntp();
         if ($nntp->doConnect()) {
             $pos = 0;
             foreach ($res as $groupArr) {
                 $pos++;
                 echo 'Group ' . $pos . ' of ' . sizeof($res) . $n;
                 $this->message = array();
                 $this->updateGroup($nntp, $groupArr);
             }
             $nntp->doQuit();
             echo 'Updating completed in ' . number_format(microtime(true) - $alltime, 2) . ' seconds' . $n;
         } else {
             echo "Failed to get NNTP connection.{$n}";
         }
     } else {
         echo "No groups specified. Ensure groups are added to newznab's database and activated before updating.{$n}";
     }
 }
开发者ID:scriptzteam,项目名称:newzNZB-premium-indexer,代码行数:32,代码来源:binaries.php

示例2: processReleases

 /**
  * @param int    $categorize
  * @param int    $postProcess
  * @param string $groupName (optional)
  * @param \NNTP   $nntp
  * @param bool   $echooutput
  *
  * @return int
  */
 public function processReleases($categorize, $postProcess, $groupName, &$nntp, $echooutput)
 {
     $this->echoCLI = $echooutput && NN_ECHOCLI;
     $page = new Page();
     $groupID = '';
     $s = new Sites();
     echo $s->getLicense();
     if (!empty($groupName)) {
         $groupInfo = $this->groups->getByName($groupName);
         $groupID = $groupInfo['id'];
     }
     $processReleases = microtime(true);
     if ($this->echoCLI) {
         $this->pdo->log->doEcho($this->pdo->log->header("Starting release update process (" . date('Y-m-d H:i:s') . ")"), true);
     }
     if (!file_exists($page->settings->getSetting('nzbpath'))) {
         $this->pdo->log->doEcho($this->pdo->log->primary('Bad or missing nzb directory - ' . $page->settings->getSetting('nzbpath')), true);
         return -1;
     }
     $this->checkRegexesUptoDate($page->settings->getSetting('latestregexurl'), $page->settings->getSetting('latestregexrevision'), $page->settings->getSetting('newznabID'));
     $this->applyRegex($groupID);
     $this->processIncompleteBinaries($groupID);
     $DIR = NN_MISC;
     $PYTHON = shell_exec('which python3 2>/dev/null');
     $PYTHON = empty($PYTHON) ? 'python -OOu' : 'python3 -OOu';
     $processRequestIDs = (int) $page->settings->getSetting('lookup_reqids');
     $consoleTools = new ConsoleTools(['ColorCLI' => $this->pdo->log]);
     $totalReleasesAdded = 0;
     do {
         $releasesCount = $this->createReleases($groupID);
         $totalReleasesAdded += $releasesCount['added'];
         if ($processRequestIDs === 0) {
             $this->processRequestIDs($groupID, 5000, true);
         } else {
             if ($processRequestIDs === 1) {
                 $this->processRequestIDs($groupID, 5000, true);
                 $this->processRequestIDs($groupID, 1000, false);
             } else {
                 if ($processRequestIDs === 2) {
                     $requestIDTime = time();
                     if ($this->echoCLI) {
                         $this->pdo->log->doEcho($this->pdo->log->header("Process Releases -> Request id Threaded lookup."));
                     }
                     passthru("{$PYTHON} {$DIR}update_scripts/nix_scripts/tmux/python/requestid_threaded.py");
                     if ($this->echoCLI) {
                         $this->pdo->log->doEcho($this->pdo->log->primary("\nReleases updated in " . $consoleTools->convertTime(time() - $requestIDTime)));
                     }
                 }
             }
         }
         $this->categorizeReleases($categorize, $groupID);
         $this->postProcessReleases($postProcess, $nntp);
         $this->deleteBinaries($groupID);
         // This loops as long as there were releases created or 3 loops, otherwise, you could loop indefinately
     } while ($releasesCount['added'] + $releasesCount['dupes'] >= $this->releaseCreationLimit);
     $this->deletedReleasesByGroup($groupID);
     $this->deleteReleases();
     //
     // User/Request housekeeping, should ideally move this to its own section, but it needs to be done automatically.
     //
     $users = new Users();
     $users->pruneRequestHistory($page->settings->getSetting('userdownloadpurgedays'));
     //Print amount of added releases and time it took.
     if ($this->echoCLI && $this->tablePerGroup === false) {
         $countID = $this->pdo->queryOneRow('SELECT COUNT(id) AS count FROM binaries ' . (!empty($groupID) ? ' WHERE groupid = ' . $groupID : ''));
         $this->pdo->log->doEcho($this->pdo->log->primary('Completed adding ' . number_format($totalReleasesAdded) . ' releases in ' . $this->consoleTools->convertTime(number_format(microtime(true) - $processReleases, 2)) . '. ' . number_format($countID === false ? 0 : $countID['count']) . ' binaries waiting to be converted (still incomplete or in queue for creation)'), true);
     }
     return $totalReleasesAdded;
 }
开发者ID:engine9-,项目名称:newznab-tmux,代码行数:78,代码来源:Releases.php

示例3: processReleases

 function processReleases()
 {
     require_once WWW_DIR . "/lib/binaries.php";
     $db = new DB();
     $currTime_ori = $db->queryOneRow("SELECT NOW() as now");
     $cat = new Category();
     $nzb = new Nzb();
     $s = new Sites();
     $releaseRegex = new ReleaseRegex();
     $page = new Page();
     $groups = new Groups();
     $retcount = 0;
     echo $s->getLicense();
     echo "\n\nStarting release update process (" . date("Y-m-d H:i:s") . ")\n";
     if (!file_exists($page->site->nzbpath)) {
         echo "Bad or missing nzb directory - " . $page->site->nzbpath;
         return -1;
     }
     //
     // Get all regexes for all groups which are to be applied to new binaries
     // in order of how they should be applied
     //
     $releaseRegex->get();
     echo "Stage 1 : Applying regex to binaries\n";
     $activeCategories = $cat->get();
     $catbasedsizes = $db->getLookupAsArray($activeCategories, "ID");
     $activeGroups = $groups->getActive(false);
     $groupbasedminsizes = $db->getLookupAsArray($groups->getAllNoReleases(), "ID");
     foreach ($activeGroups as $groupArr) {
         //check if regexes have already been applied during update binaries
         if ($groupArr['regexmatchonly'] == 1) {
             continue;
         }
         $groupRegexes = $releaseRegex->getForGroup($groupArr['name']);
         echo "Stage 1 : Applying " . sizeof($groupRegexes) . " regexes to group " . $groupArr['name'] . "\n";
         // Get out all binaries of STAGE0 for current group
         $newUnmatchedBinaries = array();
         $ressql = sprintf("SELECT binaries.ID, binaries.name, binaries.date, binaries.totalParts, binaries.procstat, binaries.fromname from binaries where groupID = %d and procstat IN (%d,%d) and regexID IS NULL order by binaries.date asc", $groupArr['ID'], Releases::PROCSTAT_NEW, Releases::PROCSTAT_TITLENOTMATCHED);
         $resbin = $db->queryDirect($ressql);
         $matchedbins = 0;
         while ($rowbin = $db->getAssocArray($resbin)) {
             $regexMatches = array();
             foreach ($groupRegexes as $groupRegex) {
                 $regexCheck = $releaseRegex->performMatch($groupRegex, $rowbin['name']);
                 if ($regexCheck !== false) {
                     $regexMatches = $regexCheck;
                     break;
                 }
             }
             if (!empty($regexMatches)) {
                 $matchedbins++;
                 $relparts = explode("/", $regexMatches['parts']);
                 $db->exec(sprintf("update binaries set relname = replace(%s, '_', ' '), relpart = %d, reltotalpart = %d, procstat=%d, categoryID=%s, regexID=%d, reqID=%s where ID = %d", $db->escapeString($regexMatches['name']), $relparts[0], $relparts[1], Releases::PROCSTAT_TITLEMATCHED, $regexMatches['regcatid'], $regexMatches['regexID'], $db->escapeString($regexMatches['reqID']), $rowbin["ID"]));
             } else {
                 if ($rowbin['procstat'] == Releases::PROCSTAT_NEW) {
                     $newUnmatchedBinaries[] = $rowbin['ID'];
                 }
             }
         }
         //mark as not matched
         if (!empty($newUnmatchedBinaries)) {
             $db->exec(sprintf("update binaries set procstat=%d where ID IN (%s)", Releases::PROCSTAT_TITLENOTMATCHED, implode(',', $newUnmatchedBinaries)));
         }
     }
     //
     // Move all binaries from releases which have the correct number of files on to the next stage.
     //
     echo "Stage 2 : Marking binaries where all parts are available";
     $result = $db->queryDirect(sprintf("SELECT relname, date, SUM(reltotalpart) AS reltotalpart, groupID, reqID, fromname, SUM(num) AS num, coalesce(g.minfilestoformrelease, s.minfilestoformrelease) as minfilestoformrelease FROM   ( SELECT relname, reltotalpart, groupID, reqID, fromname, max(date) as date, COUNT(ID) AS num FROM binaries     WHERE procstat = %s     GROUP BY relname, reltotalpart, groupID, reqID, fromname ORDER BY NULL ) x left outer join groups g on g.ID = x.groupID inner join ( select value as minfilestoformrelease from site where setting = 'minfilestoformrelease' ) s GROUP BY relname, groupID, reqID, fromname, minfilestoformrelease ORDER BY NULL", Releases::PROCSTAT_TITLEMATCHED));
     while ($row = $db->getAssocArray($result)) {
         $retcount++;
         //
         // Less than the site permitted number of files in a release. Dont discard it, as it may
         // be part of a set being uploaded.
         //
         if ($row["num"] < $row["minfilestoformrelease"]) {
             //echo "Number of files in release ".$row["relname"]." less than site/group setting (".$row['num']."/".$row["minfilestoformrelease"].")\n";
             //$db->exec(sprintf("update binaries set procattempts = procattempts + 1 where relname = %s and procstat = %d and groupID = %d and fromname = %s", $db->escapeString($row["relname"]), Releases::PROCSTAT_TITLEMATCHED, $row["groupID"], $db->escapeString($row["fromname"]) ));
         } elseif ($row["num"] >= $row["reltotalpart"]) {
             $incomplete = false;
             if ($row['reltotalpart'] == 0 && strtotime($currTime_ori['now']) - strtotime($row['date']) < 14400) {
                 $incomplete = true;
             } else {
                 // Check that the binary is complete
                 $binlist = $db->query(sprintf("SELECT binaries.ID, totalParts, date, COUNT(DISTINCT parts.messageID) AS num FROM binaries, parts WHERE binaries.ID=parts.binaryID AND binaries.relname = %s AND binaries.procstat = %d AND binaries.groupID = %d AND binaries.fromname = %s GROUP BY binaries.ID ORDER BY NULL", $db->escapeString($row["relname"]), Releases::PROCSTAT_TITLEMATCHED, $row["groupID"], $db->escapeString($row["fromname"])));
                 foreach ($binlist as $rowbin) {
                     if ($rowbin['num'] < $rowbin['totalParts']) {
                         // Allow to binary to release if posted to usenet longer than four hours ago and we still don't have all the parts
                         if (!(strtotime($currTime_ori['now']) - strtotime($rowbin['date']) > 14400)) {
                             $incomplete = true;
                             break;
                         }
                     }
                 }
             }
             if (!$incomplete) {
                 //
                 // Right number of files, but see if the binary is a allfilled/reqid post, in which case it needs its name looked up
                 //
                 if ($row['reqID'] != '' && $page->site->reqidurl != "") {
//.........这里部分代码省略.........
开发者ID:scriptzteam,项目名称:newzNZB-premium-indexer,代码行数:101,代码来源:releases.php

示例4: processReleases

 function processReleases()
 {
     $db = new DB();
     $cat = new Category();
     $bin = new Binaries();
     $nzb = new Nzb();
     $s = new Sites();
     $relreg = new ReleaseRegex();
     $page = new Page();
     $nfo = new Nfo(true);
     $retcount = 0;
     echo $s->getLicense();
     echo "\n\nStarting release update process (" . date("Y-m-d H:i:s") . ")\n";
     if (!file_exists($page->site->nzbpath)) {
         echo "Bad or missing nzb directory - " . $page->site->nzbpath;
         return;
     }
     $this->checkRegexesUptoDate($page->site->latestregexurl, $page->site->latestregexrevision, true);
     //
     // Get all regexes for all groups which are to be applied to new binaries
     // in order of how they should be applied
     //
     $regexrows = $relreg->get();
     foreach ($regexrows as $regexrow) {
         echo "Applying regex " . $regexrow["ID"] . " for group " . ($regexrow["groupname"] == "" ? "all" : $regexrow["groupname"]) . "\n";
         $groupmatch = "";
         //
         // Groups ending in * need to be like matched when getting out binaries for groups and children
         //
         if (preg_match("/\\*\$/i", $regexrow["groupname"])) {
             $groupname = substr($regexrow["groupname"], 0, -1);
             $resgrps = $db->query(sprintf("select ID from groups where name like %s ", $db->escapeString($groupname . "%")));
             foreach ($resgrps as $resgrp) {
                 $groupmatch .= " groupID = " . $resgrp["ID"] . " or ";
             }
             $groupmatch .= " 1=2 ";
         } elseif ($regexrow["groupname"] != "") {
             $resgrp = $db->queryOneRow(sprintf("select ID from groups where name = %s ", $db->escapeString($regexrow["groupname"])));
             //
             // if group not found, its a regex for a group we arent indexing.
             //
             if ($resgrp) {
                 $groupmatch = " groupID = " . $resgrp["ID"];
             } else {
                 $groupmatch = " 1=2 ";
             }
         } else {
             $groupmatch = " 1=1 ";
         }
         // Get current mysql time for date comparison checks in case php is in a different time zone
         $currTime = $db->queryOneRow("SELECT NOW() as now");
         // Get out all binaries of STAGE0 for current group
         $arrNoPartBinaries = array();
         $resbin = $db->queryDirect(sprintf("SELECT binaries.ID, binaries.name, binaries.date, binaries.totalParts from binaries where (%s) and procstat = %d order by binaries.date asc", $groupmatch, Releases::PROCSTAT_NEW));
         while ($rowbin = mysql_fetch_assoc($resbin)) {
             if (preg_match($regexrow["regex"], $rowbin["name"], $matches)) {
                 $matches = array_map("trim", $matches);
                 if (isset($matches['reqid']) && ctype_digit($matches['reqid']) && (!isset($matches['name']) || empty($matches['name']))) {
                     $matches['name'] = $matches['reqid'];
                 }
                 // Check that the regex provided the correct parameters
                 if (!isset($matches['name']) || empty($matches['name'])) {
                     echo "regex applied which didnt return right number of capture groups - " . $regexrow["regex"] . "\n";
                     print_r($matches);
                     continue;
                 }
                 // If theres no number of files data in the subject, put it into a release if it was posted to usenet longer than five hours ago.
                 if (!isset($matches['parts']) && strtotime($currTime['now']) - strtotime($rowbin['date']) > 18000 || isset($arrNoPartBinaries[$matches['name']])) {
                     //
                     // Take a copy of the name of this no-part release found. This can be used
                     // next time round the loop to find parts of this set, but which have not yet reached 3 hours.
                     //
                     $arrNoPartBinaries[$matches['name']] = "1";
                     $matches['parts'] = "01/01";
                 }
                 if (isset($matches['name']) && isset($matches['parts'])) {
                     if (strpos($matches['parts'], '/') === false) {
                         $matches['parts'] = str_replace(array('-', '~', ' of '), '/', $matches['parts']);
                     }
                     $regcatid = "null ";
                     if ($regexrow["categoryID"] != "") {
                         $regcatid = $regexrow["categoryID"];
                     }
                     $reqid = " null ";
                     if (isset($matches['reqid'])) {
                         $reqid = $matches['reqid'];
                     }
                     //check if post is repost
                     if (preg_match('/(repost\\d?|re\\-?up)/i', $rowbin['name'], $repost) && !preg_match('/repost|re\\-?up/i', $matches['name'])) {
                         $matches['name'] .= ' ' . $repost[1];
                     }
                     $relparts = explode("/", $matches['parts']);
                     $db->query(sprintf("update binaries set relname = replace(%s, '_', ' '), relpart = %d, reltotalpart = %d, procstat=%d, categoryID=%s, regexID=%d, reqID=%s where ID = %d", $db->escapeString($matches['name']), $relparts[0], $relparts[1], Releases::PROCSTAT_TITLEMATCHED, $regcatid, $regexrow["ID"], $reqid, $rowbin["ID"]));
                 }
             }
         }
     }
     //
     // Move all binaries from releases which have the correct number of files on to the next stage.
     //
//.........这里部分代码省略.........
开发者ID:priyavadan,项目名称:newznab,代码行数:101,代码来源:releases.php


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