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


PHP Groups::getIDByName方法代码示例

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


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

示例1: search

 /**
  * Function for searching on the site (by subject, searchname or advanced).
  *
  * @param string $searchName
  * @param string $usenetName
  * @param string $posterName
  * @param string $groupName
  * @param int    $sizeFrom
  * @param int    $sizeTo
  * @param int    $hasNfo
  * @param int    $hasComments
  * @param int    $daysNew
  * @param int    $daysOld
  * @param int    $offset
  * @param int    $limit
  * @param string $orderBy
  * @param int    $maxAge
  * @param integer[] $excludedCats
  * @param string $type
  * @param array  $cat
  *
  * @return array
  */
 public function search($searchName, $usenetName, $posterName, $groupName, $sizeFrom, $sizeTo, $hasNfo, $hasComments, $daysNew, $daysOld, $offset = 0, $limit = 1000, $orderBy = '', $maxAge = -1, $excludedCats = [], $type = 'basic', $cat = [-1])
 {
     $sizeRange = [1 => 1, 2 => 2.5, 3 => 5, 4 => 10, 5 => 20, 6 => 30, 7 => 40, 8 => 80, 9 => 160, 10 => 320, 11 => 640];
     if ($orderBy == '') {
         $orderBy = [];
         $orderBy[0] = 'postdate ';
         $orderBy[1] = 'desc ';
     } else {
         $orderBy = $this->getBrowseOrder($orderBy);
     }
     $searchOptions = [];
     if ($searchName != -1) {
         $searchOptions['searchname'] = $searchName;
     }
     if ($usenetName != -1) {
         $searchOptions['name'] = $usenetName;
     }
     if ($posterName != -1) {
         $searchOptions['fromname'] = $posterName;
     }
     $whereSql = sprintf("%s\n\t\t\tWHERE r.passwordstatus %s AND r.nzbstatus = %d %s %s %s %s %s %s %s %s %s %s %s", $this->releaseSearch->getFullTextJoinString(), $this->showPasswords, Enzebe::NZB_ADDED, $maxAge > 0 ? sprintf(' AND r.postdate > (NOW() - INTERVAL %d DAY) ', $maxAge) : '', $groupName != -1 ? sprintf(' AND r.groupid = %d ', $this->groups->getIDByName($groupName)) : '', array_key_exists($sizeFrom, $sizeRange) ? ' AND r.size > ' . (string) (104857600 * (int) $sizeRange[$sizeFrom]) . ' ' : '', array_key_exists($sizeTo, $sizeRange) ? ' AND r.size < ' . (string) (104857600 * (int) $sizeRange[$sizeTo]) . ' ' : '', $hasNfo != 0 ? ' AND r.nfostatus = 1 ' : '', $hasComments != 0 ? ' AND r.comments > 0 ' : '', $type !== 'advanced' ? $this->categorySQL($cat) : ($cat[0] != '-1' ? sprintf(' AND (r.categoryid = %d) ', $cat[0]) : ''), $daysNew != -1 ? sprintf(' AND r.postdate < (NOW() - INTERVAL %d DAY) ', $daysNew) : '', $daysOld != -1 ? sprintf(' AND r.postdate > (NOW() - INTERVAL %d DAY) ', $daysOld) : '', count($excludedCats) > 0 ? ' AND r.categoryid NOT IN (' . implode(',', $excludedCats) . ')' : '', count($searchOptions) > 0 ? $this->releaseSearch->getSearchSQL($searchOptions) : '');
     $baseSql = sprintf("SELECT r.*,\n\t\t\t\tCONCAT(cp.title, ' > ', c.title) AS category_name,\n\t\t\t\tCONCAT(cp.id, ',', c.id) AS category_ids,\n\t\t\t\tgroups.name AS group_name,\n\t\t\t\trn.id AS nfoid,\n\t\t\t\tre.releaseid AS reid,\n\t\t\t\tcp.id AS categoryparentid\n\t\t\tFROM releases r\n\t\t\tLEFT OUTER JOIN releasevideo re ON re.releaseid = r.id\n\t\t\tLEFT OUTER JOIN releasenfo rn ON rn.releaseid = r.id\n\t\t\tINNER JOIN groups ON groups.id = r.groupid\n\t\t\tINNER JOIN category c ON c.id = r.categoryid\n\t\t\tINNER JOIN category cp ON cp.id = c.parentid\n\t\t\t%s", $whereSql);
     $sql = sprintf("SELECT * FROM (\n\t\t\t\t%s\n\t\t\t) r\n\t\t\tORDER BY r.%s %s\n\t\t\tLIMIT %d OFFSET %d", $baseSql, $orderBy[0], $orderBy[1], $limit, $offset);
     $releases = $this->pdo->query($sql);
     if ($releases && count($releases)) {
         $releases[0]['_totalrows'] = $this->getPagerCount($baseSql);
     }
     return $releases;
 }
开发者ID:engine9-,项目名称:newznab-tmux,代码行数:52,代码来源:Releases.php

示例2: search

 /**
  * Function for searching on the site (by subject, searchname or advanced).
  *
  * @param string $searchName
  * @param string $usenetName
  * @param string $posterName
  * @param string $groupName
  * @param array  $cat
  * @param int    $sizeFrom
  * @param int    $sizeTo
  * @param int    $hasNfo
  * @param int    $hasComments
  * @param int    $daysNew
  * @param int    $daysOld
  * @param int    $offset
  * @param int    $limit
  * @param string $orderBy
  * @param int    $maxAge
  * @param array  $excludedCats
  * @param string $type
  *
  * @return array
  */
 public function search($searchName, $usenetName, $posterName, $groupName, $cat = [-1], $sizeFrom, $sizeTo, $hasNfo, $hasComments, $daysNew, $daysOld, $offset = 0, $limit = 1000, $orderBy = '', $maxAge = -1, $excludedCats = [], $type = 'basic')
 {
     $sizeRange = range(1, 11);
     if ($orderBy == '') {
         $orderBy = [];
         $orderBy[0] = 'postdate ';
         $orderBy[1] = 'desc ';
     } else {
         $orderBy = $this->getBrowseOrder($orderBy);
     }
     $searchOptions = [];
     if ($searchName != -1) {
         $searchOptions['searchname'] = $searchName;
     }
     if ($usenetName != -1) {
         $searchOptions['name'] = $usenetName;
     }
     if ($posterName != -1) {
         $searchOptions['fromname'] = $posterName;
     }
     $innerSql = sprintf("%s\n\t\t\tWHERE r.passwordstatus <= %d %s %s %s %s %s %s %s %s %s %s %s", $this->releaseSearch->getFullTextJoinString(), $this->showPasswords(), $maxAge > 0 ? sprintf(' AND r.postdate > (NOW() - INTERVAL %d DAY) ', $maxAge) : '', $groupName != -1 ? sprintf(' AND r.group_id = %d ', $this->groups->getIDByName($groupName)) : '', in_array($sizeFrom, $sizeRange) ? ' AND r.size > ' . (string) (104857600 * (int) $sizeFrom) . ' ' : '', in_array($sizeTo, $sizeRange) ? ' AND r.size < ' . (string) (104857600 * (int) $sizeTo) . ' ' : '', $hasNfo != 0 ? ' AND r.nfostatus = 1 ' : '', $hasComments != 0 ? ' AND r.comments > 0 ' : '', $type !== 'advanced' ? $this->categorySQL($cat) : ($cat[0] != '-1' ? sprintf(' AND (r.categoryid = %d) ', $cat[0]) : ''), $daysNew != -1 ? sprintf(' AND r.postdate < (NOW() - INTERVAL %d DAY) ', $daysNew) : '', $daysOld != -1 ? sprintf(' AND r.postdate > (NOW() - INTERVAL %d DAY) ', $daysOld) : '', count($excludedCats) > 0 ? ' AND r.categoryid NOT IN (' . implode(',', $excludedCats) . ')' : '', count($searchOptions) > 0 ? $this->releaseSearch->getSearchSQL($searchOptions) : '');
     $sql = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM (\n\t\t\t\tSELECT r.*, CONCAT(cp.title, ' > ', c.title) AS category_name,\n\t\t\t\tCONCAT(cp.id, ',', c.id) AS category_ids,\n\t\t\t\tgroups.name AS group_name, rn.id AS nfoid,\n\t\t\t\tre.releaseid AS reid, cp.id AS categoryparentid\n\t\t\t\tFROM releases r\n\t\t\t\tLEFT OUTER JOIN releasevideo re ON re.releaseid = r.id\n\t\t\t\tLEFT OUTER JOIN releasenfo rn ON rn.releaseid = r.id\n\t\t\t\tINNER JOIN groups ON groups.id = r.group_id\n\t\t\t\tINNER JOIN category c ON c.id = r.categoryid\n\t\t\t\tINNER JOIN category cp ON cp.id = c.parentid\n\t\t\t\t%s\n\t\t\t) r\n\t\t\tORDER BY r.%s %s\n\t\t\tLIMIT %d OFFSET %d", $innerSql, $orderBy[0], $orderBy[1], $limit, $offset);
     $releases = $this->pdo->query($sql);
     if ($releases && count($releases)) {
         $releases[0]['_totalrows'] = $this->pdo->get_Found_Rows();
     }
     return $releases;
 }
开发者ID:Jay204,项目名称:nZEDb,代码行数:51,代码来源:Releases.php

示例3: postdate

    /**
     * Returns unix time for an article number.
     *
     * @param int    $post      The article number to get the time from.
     * @param array  $groupData Usenet group info from NNTP selectGroup method.
     *
     * @return bool|int
     */
    public function postdate($post, array $groupData)
    {
        // Set table names
        $groupID = $this->_groups->getIDByName($groupData['group']);
        $group = [];
        if ($groupID !== '') {
            $group = $this->_groups->getCBPTableNames($this->_tablePerGroup, $groupID);
        }
        $currentPost = $post;
        $attempts = $date = 0;
        do {
            // Try to get the article date locally first.
            if ($groupID !== '') {
                // Try to get locally.
                $local = $this->_pdo->queryOneRow(sprintf('
						SELECT b.date AS date
						FROM %s b, %s p
						WHERE b.id = p.binaryid
						AND b.groupid = %s
						AND p.number = %s LIMIT 1', $group['bname'], $group['pname'], $groupID, $currentPost));
                if ($local !== false) {
                    $date = $local['date'];
                    break;
                }
            }
            // If we could not find it locally, try usenet.
            $header = $this->_nntp->getXOVER($currentPost);
            if (!$this->_nntp->isError($header)) {
                // Check if the date is set.
                if (isset($header[0]['Date']) && strlen($header[0]['Date']) > 0) {
                    $date = $header[0]['Date'];
                    break;
                }
            }
            // Try to get a different article number.
            if (abs($currentPost - $groupData['first']) > abs($groupData['last'] - $currentPost)) {
                $tempPost = round($currentPost / (mt_rand(1005, 1012) / 1000), 0, PHP_ROUND_HALF_UP);
                if ($tempPost < $groupData['first']) {
                    $tempPost = $groupData['first'];
                }
            } else {
                $tempPost = round(mt_rand(1005, 1012) / 1000 * $currentPost, 0, PHP_ROUND_HALF_UP);
                if ($tempPost > $groupData['last']) {
                    $tempPost = $groupData['last'];
                }
            }
            // If we got the same article number as last time, give up.
            if ($tempPost === $currentPost) {
                break;
            }
            $currentPost = $tempPost;
            if ($this->_debug) {
                $this->_colorCLI->doEcho($this->_colorCLI->debug('Postdate retried ' . $attempts . " time(s)."));
            }
        } while ($attempts++ <= 20);
        // If we didn't get a date, set it to now.
        if (!$date) {
            $date = time();
        } else {
            $date = strtotime($date);
        }
        if ($this->_debug) {
            $this->_debugging->log('Binaries', "postdate", 'Article (' . $post . "'s) date is (" . $date . ') (' . $this->daysOld($date) . " days old)", \Logger::LOG_INFO);
        }
        return $date;
    }
开发者ID:RickDB,项目名称:newznab-tmux,代码行数:74,代码来源:Binaries.php


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