Пример #1
0
         $NumberOfCommits = $Commits->GetCountPortCommits();
     } else {
         $NumberOfCommits = $Commits->GetCountCommits();
     }
     if ($Debug) {
         echo 'number of commits = ' . $NumberOfCommits . "<br>\n";
     }
     $NumFound = $NumberOfCommits;
     $params = array('mode' => 'Sliding', 'perPage' => $PageSize, 'delta' => 5, 'totalItems' => $NumFound, 'urlVar' => 'page', 'currentPage' => $PageNumber, 'spacesBeforeSeparator' => 1, 'spacesAfterSeparator' => 1);
     $Pager =& Pager::factory($params);
     $offset = $Pager->getOffsetByPageId();
     $NumOnThisPage = $offset[1] - $offset[0] + 1;
     if ($PageNumber > 1) {
         $Commits->SetOffset($offset[0] - 1);
     }
     $Commits->SetLimit($PageSize);
     if (substr($query, 0, 7) == '/ports/') {
         $NumFetches = $Commits->FetchPortCommits();
     } else {
         $NumFetches = $Commits->Fetch();
     }
     break;
 default:
     $sqlSelectFields = "\n  select distinct\n         CL.commit_date - SystemTimeAdjust() AS last_commit_date, \n         P.id, \n         E.name as port,\n         C.name as category, \n         C.id as category_id, \n         P.version as version, \n         P.revision as revision, \n         P.portepoch as epoch, \n         P.maintainer, \n         P.short_description, \n         P.package_exists, \n         P.extract_suffix, \n         P.homepage, \n         E.status, \n         P.element_id, \n         P.broken, \n         P.deprecated, \n         P.ignore, \n         PV.current as vulnerable_current,\n         PV.past    as vulnerable_past,\n         P.forbidden,\n         P.master_port,\n         P.latest_link,\n         P.no_package,\n         P.package_name,\n         P.restricted,\n         P.no_cdrom,\n         P.expiration_date,\n         P.no_package,\n         P.license,\n         R.svn_hostname,\n         R.path_to_repo,\n         element_pathname(P.element_id) as element_pathname  ";
     $sqlSelectCount = "\n  SELECT count(*)";
     if ($User->id) {
         $sqlExtraFields .= ",\n         onwatchlist";
     }
     $sqlFrom = "\n  FROM ports P LEFT OUTER JOIN ports_vulnerable PV ON PV.port_id       = P.id \n               LEFT OUTER JOIN commit_log       CL ON P.last_commit_id = CL.id \n               LEFT OUTER JOIN repo             R  ON CL.repo_id       = R.id, \n       categories C, element E\n";
     #    from ports LEFT OUTER JOIN ports_vulnerable on ports_vulnerable.port_id = ports.id JOIN commit_log CL on ports.last_commit_id = CL.id JOIN repo R on CL.repo_id = R.id , categories, element  ";
     $sqlWatchListFrom = '';
Пример #2
0
function freshports_NonPortDescription($db, $element_record)
{
    global $TableWidth;
    global $FreshPortsTitle;
    $Debug = 1;
    freshports_ConditionalGet(freshports_LastModified());
    header("HTTP/1.1 200 OK");
    $Title = preg_replace('|^/?ports/|', '', $element_record->element_pathname);
    $FileName = preg_replace('|^/?ports/|', '', $element_record->element_pathname);
    require_once $_SERVER['DOCUMENT_ROOT'] . '/../include/getvalues.php';
    freshports_Start($Title, "{$FreshPortsTitle} - new ports, applications", "FreeBSD, index, applications, ports");
    ?>

	<?php 
    echo freshports_MainTable();
    ?>

	<tr><td valign="top" width="100%">

	<?php 
    echo freshports_MainContentTable();
    ?>
<TR>
<?php 
    echo freshports_PageBannerText('non port: ' . $Title);
    ?>
</TR>
<tr><td>
<a HREF="<?php 
    echo FRESHPORTS_FREEBSD_SVN_URL . $element_record->element_pathname;
    ?>
?view=log">SVNWeb</a>
</td></tr>

<?php 
    global $User;
    # these two options must be the last on the line.  And as such are mutually exclusive
    define('BYPASSCACHE', 'bypasscache=1');
    # do not read the cache for display
    define('REFRESHCACHE', 'refreshcache=1');
    # refresh the cache
    $BypassCache = substr($_SERVER["REQUEST_URI"], strlen($_SERVER["REQUEST_URI"]) - strlen(BYPASSCACHE)) == BYPASSCACHE;
    $RefreshCache = substr($_SERVER["REQUEST_URI"], strlen($_SERVER["REQUEST_URI"]) - strlen(REFRESHCACHE)) == REFRESHCACHE;
    $PageNumber = 1;
    if (isset($_SERVER['REDIRECT_QUERY_STRING'])) {
        parse_str($_SERVER['REDIRECT_QUERY_STRING'], $query_parts);
        if (isset($query_parts['page']) && Is_Numeric($query_parts['page'])) {
            $PageNumber = intval($query_parts['page']);
            if ($PageNumber != $query_parts['page'] || $PageNumber < 1) {
                $PageNumber = 1;
            }
        }
    }
    $NumCommitsPerPage = $User->page_size;
    $Cache = new CacheFile();
    $Cache->PageSize = $User->page_size;
    $result = $Cache->Retrieve($FileName, $PageNumber);
    if (!$result && !$BypassCache && !$RefreshCache) {
        if ($Debug) {
            echo "found something from the cache<br>\n";
        }
        $HTML = $Cache->CacheDataGet();
        #
        # we need to know the element_id of this port
        # and the whether or not it is on the person's watch list
        # let's create a special function for that!
        #
        $EndOfFirstLine = strpos($HTML, "\n");
        if ($EndOfFirstLine == false) {
            die('Internal error: I was expecting an ElementID and found nothing');
        }
        # extract the ElementID from the cache
        $ElementID = intval(substr($HTML, 0, $EndOfFirstLine));
        if ($ElementID == 0) {
            syslog(LOG_ERR, "Extract of ElementID from cache failed.  Is cache corrupt/deprecated? port was {$category}/{$port}");
            die('sorry, I encountered a problem with the cache.  Please send the URL and this message to the webmaster.');
        }
        if ($User->id) {
            $OnWatchList = freshports_OnWatchList($db, $User->id, $ElementID);
        } else {
            $OnWatchList = 0;
        }
        $HTML = substr($HTML, $EndOfFirstLine + 1);
    } else {
        if ($Debug) {
            echo "found NOTHING in cache<br>\n";
        }
        $HTML = '';
        $Commits = new CommitsByTreeLocation($db);
        $Commits->SetLimit($Cache->PageSize);
        $Commits->Debug = $Debug;
        $Commits->UserIDSet($User->id);
        $Commits->TreePathConditionSet("= '" . $element_record->element_pathname . "'");
        #
        # get the count without excuting the whole query
        # we don't want to pull back all the data.
        #
        $NumCommits = $Commits->GetCountCommits();
        $params = array('mode' => 'Sliding', 'perPage' => $NumCommitsPerPage, 'delta' => 5, 'totalItems' => $NumCommits, 'urlVar' => 'page', 'currentPage' => $PageNumber, 'spacesBeforeSeparator' => 1, 'spacesAfterSeparator' => 1, 'append' => false, 'path' => '/' . preg_replace('|^/?ports/|', '', $element_record->element_pathname), 'fileName' => '?page=%d', 'altFirst' => 'First Page', 'firstPageText' => 'First Page', 'altLast' => 'Last Page', 'lastPageText' => 'Last Page');
        $Pager =& Pager::factory($params);
        $links = $Pager->GetLinks();
        $NumCommitsHTML = '<tr><td><p align="left">Number of commits found: ' . $NumCommits;
        $Offset = 0;
        $PageLinks = $links['all'];
        $PageLinksHTML = str_replace('/?page=1"', '"', $PageLinks);
        $PageLinksHTML = str_replace('/?page=', '?page=', $PageLinksHTML);
        if ($PageLinksHTML != '') {
            $offset = $Pager->getOffsetByPageId();
            $NumOnThisPage = $offset[1] - $offset[0] + 1;
            $Offset = $offset[0] - 1;
            $NumCommitsHTML .= " (showing only {$NumOnThisPage} on this page)";
            unset($offset);
        }
        if ($PageNumber > 1) {
            $Commits->SetOffset($Offset);
        }
        $NumCommitsHTML .= '</p>';
        if ($PageLinksHTML != '') {
            $PageLinksHTML = '<p align="center">' . $PageLinksHTML . '</p>';
        }
        $NumCommitsHTML .= $PageLinksHTML . '</td></tr>';
        $HTML = $NumCommitsHTML;
        if ($Commits->Debug) {
            echo "PageNumber='{$PageNumber}'<br>Offset='{$Offset}'<br>";
        }
        $NumFetches = $Commits->Fetch();
        $DisplayCommit = new DisplayCommit($db, $Commits->LocalResult);
        $HTML .= $DisplayCommit->CreateHTML();
        $HTML .= $NumCommitsHTML;
        # If we are not reading
        if (!$BypassCache || $RefreshCache) {
            $Cache->CacheDataSet($element_record->{'id'} . "\n" . $HTML);
            $Cache->Add($FileName, $PageNumber);
        }
    }
    echo $HTML;
    echo "</table>\n";
    ?>

</TD>
  <TD VALIGN="top" WIDTH="*" ALIGN="center">
  <?php 
    echo freshports_SideBar();
    ?>
  </td>
</TR>

</TABLE>

<?php 
    echo freshports_ShowFooter();
    ?>

</body>
</html>

<?php 
}