Пример #1
0
function freshports_PortCommitPrint($commit, $category, $port, $VuXMLList)
{
    global $DateFormatDefault;
    global $TimeFormatDefault;
    global $freshports_CommitMsgMaxNumOfLinesToShow;
    global $User;
    $HTML = '';
    # print a single commit for a port
    $HTML .= "<tr><td valign='top' NOWRAP>";
    $HTML .= $commit->commit_date . '<br>';
    // indicate if this port needs refreshing from CVS
    if ($commit->{'needs_refresh'}) {
        $HTML .= " " . freshports_Refresh_Icon_Link() . "\n";
    }
    $HTML .= freshports_Email_Link($commit->message_id);
    #	$HTML .= '&nbsp;&nbsp;'. freshports_Commit_Link($commit->message_id);
    if ($commit->EncodingLosses()) {
        $HTML .= '&nbsp;' . freshports_Encoding_Errors_Link();
    }
    $HTML .= ' ';
    $HTML .= freshports_Commit_Link_Port($commit->message_id, $category, $port);
    # output the VERSION and REVISION
    $PackageVersion = freshports_PackageVersion($commit->{'port_version'}, $commit->{'port_revision'}, $commit->{'port_epoch'});
    if (strlen($PackageVersion) > 0) {
        $HTML .= '&nbsp;&nbsp;<big><b>' . $PackageVersion . '</b></big>';
    }
    $HTML .= '<br>';
    if (isset($commit->svn_revision)) {
        $HTML .= freshports_svnweb_ChangeSet_Link($commit->svn_revision, $commit->svn_hostname, $commit->path_to_repo);
    }
    if ($commit->stf_message != '') {
        $HTML .= '&nbsp; ' . freshports_SanityTestFailure_Link($commit->message_id);
    }
    if (isset($VuXMLList[$commit->id])) {
        $HTML .= '&nbsp;<a href="/vuxml.php?vid=' . $VuXMLList[$commit->id] . '">' . freshports_VuXML_Icon() . '</a>';
    }
    $HTML .= "</td>\n";
    $HTML .= '    <td valign="top">';
    $HTML .= freshports_CommitterEmailLink($commit->committer) . '&nbsp;' . freshports_Search_Committer($commit->committer);
    $HTML .= "</td>\n";
    $HTML .= '    <td valign="top" width="*">';
    $HTML .= freshports_CommitDescriptionPrint($commit->description, $commit->encoding_losses, $freshports_CommitMsgMaxNumOfLinesToShow, freshports_MoreCommitMsgToShow($commit->message_id, $freshports_CommitMsgMaxNumOfLinesToShow));
    $HTML .= "</td>\n";
    $HTML .= "</tr>\n";
    return $HTML;
}
Пример #2
0
 function Display()
 {
     $port = $this->port;
     $HTML = '';
     #		$HTML = $this->JavascriptInclude();
     $MarkedAsNew = "N";
     $HTML .= "<DL>\n";
     $HTML .= "<DT>";
     $HTML .= port_display_WATCH_LIST_ADD_REMOVE;
     $HTML .= '<BIG><B>';
     if ($this->LinkToPort) {
         $HTML .= $this->LinkToPort();
     } else {
         $HTML .= $port->port;
     }
     $HTML .= "</B></BIG>";
     // description
     if ($port->short_description && ($this->ShowShortDescription || $this->ShowEverything)) {
         $HTML .= ' <span class="fp_description_short">' . htmlify(_forDisplay($port->short_description)) . '</span>';
         $HTML .= "<br>\n";
     }
     $HTML .= "<b>";
     $PackageVersion = freshports_PackageVersion($port->{'version'}, $port->{'revision'}, $port->{'epoch'});
     if (strlen($PackageVersion) > 0) {
         $HTML .= ' ' . $PackageVersion;
     }
     if (isset($port->category_looking_at)) {
         if ($port->category_looking_at != $port->category) {
             $HTML .= '<sup>*</sup>';
         }
     }
     $HTML .= "</b>";
     if ($this->ShowEverything || $this->ShowCategory) {
         $HTML .= ' <A HREF="/' . $port->category . '/" TITLE="The category for this port">' . $port->category . '</A>';
     }
     // indicate if this port has been removed from cvs
     if ($port->IsDeleted()) {
         $HTML .= " " . freshports_Deleted_Icon_Link() . "\n";
     }
     // indicate if this port needs refreshing from CVS
     if ($port->{'needs_refresh'}) {
         $HTML .= " " . freshports_Refresh_Icon_Link() . "\n";
     }
     if ($port->{'date_added'} > Time() - 3600 * 24 * $this->DaysMarkedAsNew) {
         $MarkedAsNew = "Y";
         $HTML .= freshports_New_Icon() . "\n";
     }
     if ($this->ShowEverything || $this->ShowWatchListCount) {
         $HTML .= ' ' . freshPorts_WatchListCount_Icon_Link() . '=' . $port->WatchListCount();
     }
     $HTML .= ' ' . freshports_Search_Depends_All($port->category . '/' . $port->port);
     # if this port is, or every has been, vulnerable, display the right skull
     # and a link to the list of all such vulnerabilities
     if ($port->IsVulnerable() || $port->WasVulnerable()) {
         $HTML .= ' ' . freshports_VuXML_Link($port->package_name, $port->IsVulnerable());
     }
     # search for bugs related to this port
     $HTML .= ' ' . freshports_Search_For_Bugs($port->category . '/' . $port->port);
     # report a bug related to this port
     $HTML .= ' ' . freshports_Report_A_Bug($port->category . '/' . $port->port);
     $HTML .= "</DT>\n<DD>";
     # show forbidden and broken
     if ($port->forbidden) {
         $HTML .= freshports_Forbidden_Icon_Link($port->forbidden) . ' FORBIDDEN: ' . htmlify(_forDisplay($port->forbidden)) . "<br>";
     }
     if ($port->broken) {
         $HTML .= freshports_Broken_Icon_Link($port->broken) . ' BROKEN: ' . htmlify(_forDisplay($port->broken)) . "<br>";
     }
     if ($port->deprecated) {
         $HTML .= freshports_Deprecated_Icon_Link($port->deprecated) . ' DEPRECATED: ' . htmlify(_forDisplay($port->deprecated)) . "<br>";
     }
     if ($port->expiration_date) {
         if (date('Y-m-d') >= $port->expiration_date) {
             $HTML .= freshports_Expired_Icon_Link($port->expiration_date) . ' This port expired on: ' . $port->expiration_date . '<br>';
         } else {
             $HTML .= freshports_Expiration_Icon_Link($port->expiration_date) . ' EXPIRATION DATE: ' . $port->expiration_date . '<br>';
         }
     }
     if ($port->ignore) {
         $HTML .= freshports_Ignore_Icon_Link($port->ignore) . ' IGNORE: ' . htmlify(_forDisplay($port->ignore)) . "<br>";
     }
     if ($port->restricted) {
         $HTML .= freshports_Restricted_Icon_Link($port->restricted) . ' RESTRICTED: ' . htmlify(_forDisplay($port->restricted)) . '<br>';
     }
     if ($port->no_cdrom) {
         $HTML .= freshports_No_CDROM_Icon_Link($port->no_cdrom) . ' NO CDROM: ' . htmlify(_forDisplay($port->no_cdrom)) . '<br>';
     }
     if ($port->is_interactive) {
         $HTML .= freshports_Is_Interactive_Icon_Link($port->is_interactive) . ' IS INTERACTIVE: ' . htmlify(_forDisplay($port->is_interactive)) . '<br>';
     }
     // maintainer
     if ($port->maintainer && ($this->ShowMaintainedBy || $this->ShowEverything)) {
         if (strtolower($port->maintainer) == UNMAINTAINTED_ADDRESS) {
             $HTML .= '<br>There is no maintainer for this port.<br>';
             $HTML .= 'Any concerns regarding this port should be directed to the FreeBSD ' . 'Ports mailing list via ';
             $HTML .= '<A HREF="' . MAILTO . ':' . freshportsObscureHTML($port->maintainer);
             $HTML .= '?subject=FreeBSD%20Port:%20' . $port->category . '/' . $port->port . '" TITLE="email the FreeBSD Ports mailing list">';
             $HTML .= freshportsObscureHTML($port->maintainer) . '</A>';
         } else {
             $HTML .= '<b>';
             $HTML .= 'Maintainer:</b> <A HREF="' . MAILTO . ':' . freshportsObscureHTML($port->maintainer);
             $HTML .= '?subject=FreeBSD%20Port:%20' . $port->category . '/' . $port->port . '" TITLE="email the maintainer">';
             $HTML .= freshportsObscureHTML($port->maintainer) . '</A>';
         }
         $HTML .= ' ' . freshports_Search_Maintainer($port->maintainer) . '<br>';
     }
     // last commit date
     if (($this->ShowLastCommitDate || $this->ShowEverything) && $port->last_commit_date) {
         $HTML .= '<b>Last commit date:</b> ' . FormatTime($port->last_commit_date, 0, "Y-m-d H:i:s") . '<br>';
     }
     // there are only a few places we want to show the last change.
     // therefore, we do not check ShowEverything here
     if ($this->ShowLastChange) {
         if ($port->updated != 0) {
             $HTML .= 'last change committed by ' . freshports_CommitterEmailLink($port->committer);
             // separate lines in case committer is null
             $HTML .= ' ' . freshports_Search_Committer($port->committer);
             $HTML .= ' on <font size="-1">' . $port->updated . '</font>' . "\n";
             $HTML .= freshports_Email_Link($port->message_id);
             if ($port->EncodingLosses()) {
                 $HTML .= ' ' . freshports_Encoding_Errors_Link();
             }
             $HTML .= ' ' . freshports_Commit_Link($port->message_id);
             $HTML .= ' ' . freshports_Commit_Link_Port($port->message_id, $port->category, $port->port);
             global $freshports_CommitMsgMaxNumOfLinesToShow;
             $HTML .= freshports_PortDescriptionPrint($port->update_description, $port->encoding_losses, $freshports_CommitMsgMaxNumOfLinesToShow, freshports_MoreCommitMsgToShow($port->message_id, $freshports_CommitMsgMaxNumOfLinesToShow));
         } else {
             $HTML .= "no changes recorded in FreshPorts<br>\n";
         }
     }
     # show the date added, if asked
     if ($this->ShowDateAdded || $this->ShowEverything) {
         $HTML .= '<b>Port Added:</b> <font size="-1">';
         if ($port->date_added) {
             $HTML .= $port->date_added;
         } else {
             $HTML .= "unknown";
         }
         $HTML .= '</font><BR>' . "\n";
     }
     $HTML .= PeopleWatchingThisPortAlsoWatch($this->db, $port->element_id);
     if ($port->categories) {
         // remove the primary category and remove any double spaces or trailing/leading spaces
         // this ensures that explode gives us the right stuff
         if (isset($port->category_looking_at)) {
             $CategoryToRemove = $port->category_looking_at;
         } else {
             $CategoryToRemove = $port->category;
         }
         $Categories = str_replace($CategoryToRemove, '', $port->categories);
         $Categories = str_replace('  ', ' ', $Categories);
         $Categories = trim($Categories);
         if ($Categories) {
             $HTML .= "<b>Also Listed In:</b> ";
             $CategoriesArray = explode(" ", $Categories);
             $Count = count($CategoriesArray);
             for ($i = 0; $i < $Count; $i++) {
                 $Category = $CategoriesArray[$i];
                 #					$CategoryID = freshports_CategoryIDFromCategory($Category, $this->db);
                 #					if ($CategoryID) {
                 #						// this is a real category
                 $HTML .= '<a href="/' . $Category . '/">' . $Category . '</a>';
                 #					} else {
                 #						$HTML .= $Category;
                 #					}
                 if ($i < $Count - 1) {
                     $HTML .= " ";
                 }
             }
             $HTML .= "<br>\n";
         }
     }
     $HTML .= '<b>License:</b> ';
     if ($port->license) {
         $HTML .= htmlentities($port->license);
     } else {
         $HTML .= 'not specified in port';
     }
     $HTML .= "<br>\n";
     # The ad goes here
     if ($this->ShowAd || $this->ShowEverything) {
         $HTML .= port_display_AD;
     }
     if ($this->ShowDescriptionLong || $this->ShowEverything) {
         $HTML .= '<PRE CLASS="code">' . htmlify(_forDisplay($port->long_description)) . '</PRE>';
     }
     if ($this->ShowChangesLink || $this->ShowEverything) {
         # we want something like
         # http://svn.freebsd.org/ports/head/x11-wm/awesome/
         $HTML .= '<a href="http://' . $port->svn_hostname . $port->element_pathname . '/">SVNWeb</a>';
     }
     if ($port->PackageExists() && ($this->ShowPackageLink || $this->ShowEverything)) {
         // package
         $HTML .= ' <b>:</b> ';
         $HTML .= '<A HREF="' . FRESHPORTS_FREEBSD_FTP_URL . '/' . freshports_PackageVersion($port->version, $port->revision, $port->epoch);
         $HTML .= '.tgz">Package</A>';
     }
     if ($port->homepage && ($this->ShowHomepageLink || $this->ShowEverything)) {
         $HTML .= ' <b>:</b> ';
         $HTML .= '<a HREF="' . _forDisplay($port->homepage) . '" TITLE="Homepage for this port">Homepage</a>';
     }
     if (defined('DISTFILESSURVEYSHOW') && ($this->ShowDistfilesSurveyLink || $this->ShowEverything)) {
         $HTML .= ' <b>:</b> ' . freshports_DistFilesSurveyURL($port->category, $port->port);
     }
     if (defined('PORTSMONSHOW') && ($this->ShowPortsMonLink || $this->ShowEverything)) {
         $HTML .= ' <b>:</b> ' . freshports_PortsMonitorURL($port->category, $port->port);
     }
     if ($this->ShowEverything || $this->ShowMasterSlave) {
         #
         # Display our master port
         #
         $MasterSlave = new MasterSlave($port->dbh);
         $NumRows = $MasterSlave->FetchByMaster($port->category . '/' . $port->port);
         if ($port->IsSlavePort() || $NumRows > 0) {
             $HTML .= "\n<hr>\n";
         }
         if ($port->IsSlavePort()) {
             $HTML .= '<dl><dt><b>Master port:</b> ';
             list($MyCategory, $MyPort) = explode('/', $port->master_port);
             $HTML .= freshports_link_to_port($MyCategory, $MyPort);
             $HTML .= "</dt>\n";
             $HTML .= "</dl>\n";
         }
         #
         # Display our slave ports
         #
         if ($NumRows > 0) {
             $HTML .= '<span class="slaveports">Slave ports</span>' . "\n" . '<ol class="slaveports" id="slaveports">';
             for ($i = 0; $i < $NumRows; $i++) {
                 $MasterSlave->FetchNth($i);
                 $HTML .= '<li>' . freshports_link_to_port($MasterSlave->slave_category_name, $MasterSlave->slave_port_name) . '</li>';
             }
             $HTML .= "</ol>\n";
         }
     }
     if ($this->ShowDepends || $this->ShowEverything) {
         if ($port->depends_build || $port->depends_run || $port->depends_lib) {
             $HTML .= '<hr><p><big>NOTE: FreshPorts displays only information on required and default dependencies.  Optional dependencies are not covered.</big></p>';
         }
         if ($port->depends_build) {
             $HTML .= '<span class="required">Build dependencies:</span>' . "\n" . '<ol class="required" id="requiredtobuild">';
             $HTML .= freshports_depends_links($this->db, $port->depends_build);
             $HTML .= "\n</ol>\n";
         }
         if ($port->depends_run) {
             $HTML .= '<span class="required">Runtime dependencies:</span>' . "\n" . '<ol class="required" id="requiredtorun">';
             $HTML .= freshports_depends_links($this->db, $port->depends_run);
             $HTML .= "\n</ol>\n";
         }
         if ($port->depends_lib) {
             $HTML .= '<span class="required">Library dependencies:</span>' . "\n" . '<ol class="required" id="requiredlibraries">';
             $HTML .= freshports_depends_links($this->db, $port->depends_lib);
             $HTML .= "\n</ol>\n";
         }
         if ($port->fetch_depends) {
             $HTML .= '<span class="required">Fetch dependencies:</span>' . "\n" . '<ol class="required" id="requiredfetches">';
             $HTML .= freshports_depends_links($this->db, $port->fetch_depends);
             $HTML .= "\n</ol>\n";
         }
         if ($port->patch_depends) {
             $HTML .= '<span class="required">Patch dependencies:</span>' . "\n" . '<ol class="required" id="requiredpatches">';
             $HTML .= freshports_depends_links($this->db, $port->patch_depends);
             $HTML .= "\n</ol>\n";
         }
         if ($port->extract_depends) {
             $HTML .= '<span class="required">Extract dependencies:</span>' . "\n" . '<ol class="required" id="requiredextracts">';
             $HTML .= freshports_depends_links($this->db, $port->extract_depends);
             $HTML .= "\n</ol>\n";
         }
         # XXX when adding new depends above, be sure to update the array in ShowDependencies()
         $HTML .= $this->ShowDependencies($port);
     }
     # only show if we're meant to show, and if the port has not been deleted.
     if ($this->ShowPackageLink || $this->ShowEverything) {
         $HTML .= "\n<hr>\n";
         if ($port->IsDeleted()) {
             $HTML .= '<p>No installation instructions: this port has been deleted.</p>';
             $HTML .= '<p>The package name of this deleted port was: <code class="code">' . $port->latest_link . '</code></p>';
         } else {
             $HTML .= '<p><b>To install <a href="/faq.php#port" TITLE="what is a port?">the port</a>:</b> <code class="code">cd /usr/ports/' . $port->category . '/' . $port->port . '/ && make install clean</code><br>';
             if (isset($port->no_package) && $port->no_package != '') {
                 $HTML .= '<p><b>No <a href="/faq.php#package" TITLE="what is a package?">package</a> is available:</b> ' . $port->no_package . '</p>';
             } else {
                 if ($port->forbidden || $port->broken || $port->ignore || $port->restricted) {
                     $HTML .= '<p><b>A <a href="/faq.php#package" TITLE="what is a package?">package</a> is not available for ports marked as: Forbidden / Broken / Ignore / Restricted</b></p>';
                 } else {
                     $HTML .= '<b>To add the <a href="/faq.php#package" TITLE="what is a package?">package</a>:</b> <code class="code">pkg install ' . $port->category . '/' . $port->port . '</code></p>';
                 }
             }
         }
         $HTML .= "\n<hr>\n";
     }
     if ($this->ShowDescriptionShort && ($this->ShowDescriptionLink || $this->ShowEverything)) {
         // Long description
         $HTML .= '<A HREF="/' . $port->category . '/' . $port->port . '/">Description</a>';
         $HTML .= ' <b>:</b> ';
     }
     if ($this->ShowEverything) {
         $HTML .= "<b>Configuration Options</b>\n<pre>";
         if ($port->showconfig) {
             $HTML .= $port->showconfig;
         } else {
             $HTML .= '     No options to configure';
         }
         $HTML .= "</pre>\n<hr>\n";
     }
     if ($this->ShowEverything && $port->uses) {
         $HTML .= "<b>USES:</b>\n<pre>";
         $HTML .= $port->uses;
         $HTML .= "</pre>\n<hr>\n";
     }
     if ($this->ShowEverything || $this->ShowMasterSites) {
         $HTML .= '<b>Master Sites:</b>' . "\n" . '<ol class="mastersites" id="mastersites">' . "\n";
         $MasterSites = explode(' ', $port->master_sites);
         asort($MasterSites);
         foreach ($MasterSites as $Site) {
             $HTML .= '<li>' . htmlify(_forDisplay($Site)) . "</li>\n";
         }
         $HTML .= "</ol>\n";
         #			$HTML .= '<br>';
     }
     #		$HTML .= "\n<hr>\n";
     $HTML .= "\n</DD>\n";
     $HTML .= "</DL>\n";
     return $HTML;
 }
Пример #3
0
function DisplayNewsFeed($db, $token)
{
    $Debug = 0;
    global $FreshPortsSlogan;
    global $FreshPortsName;
    $wlid = freshports_WatchListVerifyToken($db, $token);
    if ($wlid == '') {
        syslog(LOG_ERR, __FILE__ . '::' . __LINE__ . ' watch list token requested by ' . $_SERVER['REMOTE_ADDR'] . ' not found ' . $token);
        header('HTTP/1.1 404 NOT FOUND');
        exit;
    }
    $ServerName = str_replace('freshports', 'FreshPorts', $_SERVER['SERVER_NAME']);
    header('Content-type: application/rss+xml');
    $HTML = '<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN"' . "\n";
    $HTML .= '        "http://my.netscape.com/publish/formats/rss-0.91.dtd">' . "\n";
    $HTML .= '<rss version="0.91">' . "\n";
    $HTML .= "\n";
    $HTML .= '<channel>' . "\n";
    $HTML .= '  <title>' . "{$FreshPortsName} -- {$FreshPortsSlogan}" . '</title>' . "\n";
    $HTML .= '  <link>http://' . $ServerName . '/</link>' . "\n";
    $HTML .= '  <description>The easiest place to find ports</description>' . "\n";
    $HTML .= '  <language>en-us</language>' . "\n";
    $HTML .= '  <copyright>Copyright ' . COPYRIGHTYEARS . ', DVL Software Limited.</copyright>' . "\n";
    $HTML .= "\n";
    $HTML .= '  <image>' . "\n";
    $HTML .= '    <title>FreshPorts - The place for ports</title>' . "\n";
    $HTML .= '    <url>http://' . $ServerName . '/images/freshports_mini.jpg</url>' . "\n";
    $HTML .= '    <link>http://' . $ServerName . '/</link>' . "\n";
    $HTML .= '    <width>128</width>' . "\n";
    $HTML .= '    <height>28</height>' . "\n";
    $HTML .= '    <description>FreshPorts - The place for ports</description>' . "\n";
    $HTML .= '  </image>' . "\n";
    $sort = "commit_date_sort DESC, CL.id ASC, E.name, category, version";
    $MaxArticles = MAX_PORTS;
    $date = 1;
    $committer = 1;
    $time = 1;
    #	if (IsSet($_REQUEST['MaxArticles'])) $MaxArticles = AddSlashes($_REQUEST['MaxArticles']);
    #	if (IsSet($_REQUEST['date']))        $date        = AddSlashes($_REQUEST['date']);
    #	if (IsSet($_REQUEST['committer']))   $committer   = AddSlashes($_REQUEST['committer']);
    #	if (IsSet($_REQUEST['time']))        $time        = AddSlashes($_REQUEST['time']);
    #	phpinfo();
    #	exit;
    if (!$MaxArticles || $MaxArticles < 1 || $MaxArticles > MAX_PORTS) {
        $MaxArticles = MAX_PORTS;
    }
    $MaxNumberOfPorts = $MaxArticles;
    $NewsAddenda = $_SERVER['DOCUMENT_ROOT'] . "/news.addenda";
    if (file_exists($NewsAddenda)) {
        # include any highlights here
        $fp = fopen($NewsAddenda, "r");
        if ($fp) {
            $NewsAddendaContents = fread($fp, filesize($NewsAddenda));
            fclose($fp);
        }
        $HTML .= $NewsAddendaContents;
        $MaxNumberOfPorts--;
    }
    $sql = "\n\tselect E.name \t\t\tas port, \n\t\t   P.id \t\t\t\tas id, \n\t       C.name \t\tas category, \n\t       C.id \t\tas category_id, \n\t       P.version \t\tas version, \n\t       P.revision \t\tas revision, \n\t       E.id \t\t\tas element_id,\n           to_char(CL.commit_date - SystemTimeAdjust(), 'DD Mon')  AS commit_date,\n           to_char(CL.commit_date - SystemTimeAdjust(), 'HH24:MI') AS commit_time,\n           CL.description       AS commit_description,\n           CLP.port_epoch as epoch,\n           CL.committer,\n           CL.commit_date as commit_date_sort\n\t  FROM watch_list_element WLE, element E, categories C, ports P,\n           commit_log CL, commit_log_ports CLP\n\t WHERE CLP.commit_log_id = CL.id\n       AND CLP.port_id       = P.id\n       AND P.element_id      = WLE.element_id\n\t   AND P.element_id      = E.id\n\t   AND P.category_id     = C.id \n\t   AND WLE.watch_list_id = {$wlid}";
    $sql .= " order by {$sort} ";
    $sql .= " LIMIT 100 ";
    #	syslog (LOG_NOTICE, $wlid . ' ' . $sort);
    if ($Debug) {
        echo "<pre>{$sql}</pre>";
    }
    $result = pg_exec($db, $sql);
    if (!$result) {
        echo pg_errormessage();
    }
    if ($Debug) {
        echo $sql;
    }
    $result = pg_exec($db, $sql);
    if (!$result) {
        echo '<pre>' . $sql . '</pre>error = ' . pg_errormessage();
        exit;
    }
    $numrows = pg_numrows($result);
    for ($i = 0; $i < $numrows; $i++) {
        $myrow = pg_fetch_array($result, $i);
        $HTML .= "\n";
        $HTML .= '  <item>' . "\n";
        $HTML .= '    <title>';
        if ($date == 1) {
            $HTML .= '[' . $myrow['commit_date'] . '] ';
        }
        if ($time == 1) {
            $HTML .= '[' . $myrow['commit_time'];
        }
        if ($committer == 1) {
            if ($time != 1) {
                $HTML .= '[';
            } else {
                $HTML .= ' ';
            }
            $HTML .= $myrow['committer'];
        }
        if ($time == 1 || $committer == 1) {
            $HTML .= '] ';
        }
        $HTML .= $myrow["category"] . '/' . $myrow["port"] . ' - ' . freshports_PackageVersion($myrow["version"], $myrow["revision"], $myrow["epoch"]);
        $HTML .= '</title>' . "\n";
        $HTML .= '    <link>http://' . $ServerName . '/' . $myrow["category"] . '/' . $myrow["port"] . '/</link>' . "\n";
        $HTML .= '    <description>' . htmlspecialchars(trim($myrow["commit_description"])) . '</description>' . "\n";
        $HTML .= '  </item>' . "\n";
    }
    $HTML .= '</channel>' . "\n";
    $HTML .= '</rss>' . "\n";
    echo '<?xml version="1.0"?>', "\n";
    echo $HTML;
}
Пример #4
0
    $myrow = pg_fetch_array($result, $i);
    $HTML .= "\n";
    $HTML .= '  <item>' . "\n";
    $HTML .= '    <title>';
    if ($date == 1) {
        $HTML .= '[' . htmlentities($myrow['commit_date']) . '] ';
    }
    if ($time == 1) {
        $HTML .= '[' . htmlentities($myrow['commit_time']);
    }
    if ($committer == 1) {
        if ($time != 1) {
            $HTML .= '[';
        } else {
            $HTML .= ' ';
        }
        $HTML .= htmlentities($myrow['committer']);
    }
    if ($time == 1 || $committer == 1) {
        $HTML .= '] ';
    }
    $HTML .= htmlentities($myrow["category"]) . '/' . htmlentities($myrow["port"]) . ' - ' . htmlentities(freshports_PackageVersion($myrow["version"], $myrow["revision"], $myrow["epoch"]));
    $HTML .= '</title>' . "\n";
    $HTML .= '    <link>http://' . $ServerName . '/' . htmlentities($myrow["category"] . '/' . $myrow["port"]) . '/</link>' . "\n";
    $HTML .= '    <description>' . htmlspecialchars(trim($myrow["commit_description"])) . '</description>' . "\n";
    $HTML .= '  </item>' . "\n";
}
$HTML .= '</channel>' . "\n";
$HTML .= '</rss>' . "\n";
echo '<?xml version="1.0"?>', "\n";
echo $HTML;
Пример #5
0
    $HTML .= "\n";
    $HTML .= '  <item>' . "\n";
    $HTML .= '    <title>';
    if ($date == 1) {
        $HTML .= '[' . $myrow['date_added_date'] . '] ';
    }
    if ($time == 1) {
        $HTML .= '[' . $myrow['date_added_time'];
    }
    if ($committer == 1) {
        if ($time != 1) {
            $HTML .= '[';
        } else {
            $HTML .= ' ';
        }
        $HTML .= $myrow['maintainer'];
    }
    if ($time == 1 || $committer == 1) {
        $HTML .= '] ';
    }
    $HTML .= $myrow["category"] . '/' . $myrow["port"] . ' - ' . freshports_PackageVersion($myrow["version"], $myrow["revision"], $myrow["epoch"]);
    $HTML .= '</title>' . "\n";
    $HTML .= '    <link>http://' . $ServerName . '/' . $myrow["category"] . '/' . $myrow["port"] . '/</link>' . "\n";
    $HTML .= '    <description>' . htmlspecialchars(trim($myrow["short_description"])) . '</description>' . "\n";
    $HTML .= '  </item>' . "\n";
}
$HTML .= '</channel>' . "\n";
$HTML .= '</rss>' . "\n";
header('Content-type: text/xml');
echo '<?xml version="1.0"?>', "\n";
echo $HTML;
Пример #6
0
function newsfeed($db, $Format)
{
    $PHP_SELF = $_SERVER['PHP_SELF'];
    # potential for exploitation here, with $Format
    define('NEWSFEEDCACHE', $_SERVER['DOCUMENT_ROOT'] . '/../dynamic/caching/news/news.' . $Format . '.xml');
    $MaxNumberOfPorts = MAX_PORTS;
    $rss = new UniversalFeedCreator();
    # this next call may wind up using the cached and the
    # rest of the function may never be use executed.
    #
    $rss->useCached($Format, NEWSFEEDCACHE, time());
    $rss->title = 'FreshPorts news';
    $rss->description = 'The place for ports';
    $rss->syndicationURL = $_SERVER['HTTP_HOST'] . '/' . $PHP_SELF;
    $rss->editor = 'editor@freshports.org (The Editor)';
    $rss->webmaster = 'webmaster@freshports.org (The Webmaster)';
    $rss->language = 'en-us';
    $rss->copyright = 'Copyright 1998-2013 DVL Software Limited';
    //optional
    //$rss->descriptionTruncSize = 500;
    //$rss->descriptionHtmlSyndicated = true;
    //$rss->xslStyleSheet = 'http://feedster.com/rss20.xsl';
    $rss->link = 'http://' . $_SERVER['HTTP_HOST'];
    $rss->feedURL = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $PHP_SELF;
    $image = new FeedImage();
    $image->title = 'FreshPorts news';
    $image->url = 'http://' . $_SERVER['HTTP_HOST'] . '/images/freshports_mini.jpg';
    $image->link = 'http://' . $_SERVER['HTTP_HOST'];
    $image->description = 'Feed provided by FreshPorts. Click to visit.';
    //optional
    $image->descriptionTruncSize = 500;
    $image->descriptionHtmlSyndicated = true;
    $rss->image = $image;
    $MyMaxArticles = 10;
    if (!isset($MaxArticles) || !$MaxArticles || $MaxArticles < 1 || $MaxArticles > $MyMaxArticles) {
        $MaxArticles = $MyMaxArticles;
    }
    $sql = "\nSELECT PORTELEMENT.*,\n       categories.name AS category\nFROM (\nSELECT LCPPORTS.*,\n       element.name    AS port,\n       element.status  AS status\n\nFROM (\nSELECT LCPCLLCP.*,\n       ports.forbidden,\n       ports.broken,\n       ports.deprecated,\n       ports.element_id                     AS element_id,\n       CASE when clp_version  IS NULL then ports.version  else clp_version  END as version,\n       CASE when clp_revision IS NULL then ports.revision else clp_revision END AS revision,\n       ports.version                        AS ports_version,\n       ports.revision                       AS ports_revision,\n       ports.portepoch                      AS epoch,\n       date_part('epoch', ports.date_added) AS date_added,\n       ports.short_description              AS short_description,\n       ports.category_id\nFROM (\n SELECT LCPCL.*, \n         port_id,\n         commit_log_ports.port_version  AS clp_version,\n         commit_log_ports.port_revision AS clp_revision,\n         commit_log_ports.needs_refresh AS needs_refresh\n    FROM \n   (SELECT commit_log.id     AS commit_log_id, \n           commit_date       AS commit_date_raw,\n           message_subject,\n           message_id,\n           committer,\n           description       AS commit_description,\n           to_char(commit_log.commit_date - SystemTimeAdjust(), 'DD Mon')  AS commit_date,\n           to_char(commit_log.commit_date - SystemTimeAdjust(), 'HH24:MI') AS commit_time,\n           encoding_losses\n     FROM commit_log JOIN\n               (SELECT latest_commits_ports.commit_log_id\n                   FROM latest_commits_ports\n               ORDER BY latest_commits_ports.commit_date DESC\n                 LIMIT {$MaxNumberOfPorts}) AS LCP\n           ON commit_log.id = LCP.commit_log_id) AS LCPCL JOIN commit_log_ports\n                         ON commit_log_ports.commit_log_id = LCPCL.commit_log_id\n                         AND commit_log_ports.commit_log_id > latest_commits_ports_anchor()) AS LCPCLLCP JOIN ports\nON LCPCLLCP.port_id = ports.id) AS LCPPORTS JOIN element\nON LCPPORTS.element_id = element.id) AS PORTELEMENT JOIN categories\nON PORTELEMENT.category_id = categories.id\nORDER BY commit_date_raw desc, category, port \nLIMIT 30";
    $ServerName = str_replace('freshports', 'FreshPorts', $_SERVER['SERVER_NAME']);
    $result = pg_query($db, $sql);
    while ($myrow = pg_fetch_array($result)) {
        $item = new FeedItem();
        $CommitURL = freshports_Commit_Link_Port_URL($myrow['message_id'], $myrow['category'], $myrow['port']);
        $item->title = $myrow["category"] . '/' . $myrow["port"] . ' - ' . freshports_PackageVersion($myrow["version"], $myrow["revision"], $myrow["epoch"]);
        $item->link = $CommitURL;
        if ($Format == 'rss0.91') {
            $item->description = trim($myrow["commit_description"]);
        } else {
            $item->description = htmlentities(trim($myrow["commit_description"]));
        }
        //optional
        //item->descriptionTruncSize = 500;
        $item->descriptionHtmlSyndicated = true;
        $item->date = strtotime($myrow['commit_date_raw']);
        $item->source = $_SERVER['HTTP_HOST'];
        $item->author = $myrow['committer'] . '@FreeBSD.org (' . $myrow['committer'] . ')';
        $item->guid = $CommitURL;
        $rss->addItem($item);
    }
    // valid format strings are: RSS0.91, RSS1.0, RSS2.0, PIE0.1, MBOX, OPML, ATOM0.3, HTML, JS
    return $rss->saveFeed($Format, NEWSFEEDCACHE);
}
Пример #7
-1
 function CreateHTML()
 {
     global $freshports_CommitMsgMaxNumOfLinesToShow;
     $Debug = 0;
     if (!$this->result) {
         syslog(LOG_ERR, __FILE__ . '::' . __LINE__ . ': no result set supplied');
         die("read from database failed");
         exit;
     }
     $NumRows = pg_numrows($this->result);
     if ($this->Debug) {
         echo __FILE__ . ':' . __LINE__ . " Number of rows = {$NumRows}<br>\n";
     }
     if (!$NumRows) {
         $this->HTML = "<TR><TD>\n<P>Sorry, nothing found in the database....</P>\n</td></tr>\n";
         return $this->HTML;
     }
     # if we have a UserID, but no flagged commits, grab them
     #
     if ($this->UserID && !isset($this->FlaggedCommits)) {
         require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/commit_flag.php';
         $FlaggedCommits = new CommitFlag($this->dbh);
         $NumFlaggedCommits = $FlaggedCommits->Fetch($this->UserID);
         for ($i = 0; $i < $NumFlaggedCommits; $i++) {
             $FlaggedCommits->FetchNth($i);
             $this->FlaggedCommits[$FlaggedCommits->commit_log_id] = $FlaggedCommits->commit_log_id;
             if ($this->Debug) {
                 echo "fetching record # {$i} -> {$FlaggedCommits->commit_log_id}<br>";
             }
         }
     }
     $GlobalHideLastChange = "N";
     $this->HTML = "";
     # leave it all empty as a comparison point
     $PreviousCommit = new CommitRecord();
     $NumberOfPortsInThisCommit = 0;
     $MaxNumberPortsToShow = 10;
     $TooManyPorts = false;
     # we might not show all of a commit, just for the really big ones.
     for ($i = 0; $i < $NumRows; $i++) {
         $myrow = pg_fetch_array($this->result, $i);
         if ($Debug) {
             echo 'processing row ' . $i . ' ' . $myrow['commit_log_id'] . ' ' . $myrow['message_id'] . "<br>\n";
         }
         unset($mycommit);
         $mycommit = new CommitRecord();
         $mycommit->PopulateValues($myrow);
         // OK, while we have the log change log, let's put the port details here.
         if ($mycommit->commit_log_id != $PreviousCommit->commit_log_id) {
             if ($NumberOfPortsInThisCommit > $MaxNumberPortsToShow && !$this->ShowAllPorts) {
                 $this->HTML .= '<BR>' . freshports_MorePortsToShow($PreviousCommit->message_id, $NumberOfPortsInThisCommit, $MaxNumberPortsToShow);
             }
             $TooManyPorts = false;
             if ($i > 0) {
                 $this->HTML .= "\n<BLOCKQUOTE>";
                 $this->HTML .= freshports_CommitDescriptionPrint($PreviousCommit->commit_description, $PreviousCommit->encoding_losses, $Lines, freshports_MoreCommitMsgToShow($PreviousCommit->message_id, $Lines));
                 # close off the previous commit first
                 $this->HTML .= "\n</BLOCKQUOTE>\n</TD></TR>\n\n\n";
             }
             # count the number of ports in this commit.
             # first time into the loop, this will be executed.
             $NumberOfPortsInThisCommit = 0;
             $MaxNumberPortsToShow = 10;
             if ($mycommit->commit_date != $PreviousCommit->commit_date) {
                 $this->HTML .= '<TR><TD COLSPAN="3" BGCOLOR="' . BACKGROUND_COLOUR . '" HEIGHT="0">' . "\n";
                 $this->HTML .= '   <FONT COLOR="#FFFFFF"><BIG>' . FormatTime($mycommit->commit_date, 0, "D, j M Y") . '</BIG></FONT>' . "\n";
                 $this->HTML .= '</TD></TR>' . "\n\n";
             }
             global $freshports_mail_archive;
             $this->HTML .= "<TR><TD>\n";
             $this->HTML .= '<SMALL>';
             $this->HTML .= '[ ' . $mycommit->commit_time . ' ' . freshports_CommitterEmailLink($mycommit->committer) . ' ]';
             $this->HTML .= '</SMALL>';
             $this->HTML .= '&nbsp;';
             $this->HTML .= freshports_Email_Link($mycommit->message_id);
             $this->HTML .= '&nbsp;';
             if ($this->UserID) {
                 if (isset($this->FlaggedCommits[$mycommit->commit_log_id])) {
                     $this->HTML .= freshports_Commit_Flagged_Link($mycommit->message_id);
                 } else {
                     $this->HTML .= freshports_Commit_Flagged_Not_Link($mycommit->message_id);
                 }
             }
             if ($mycommit->EncodingLosses()) {
                 $this->HTML .= '&nbsp;' . freshports_Encoding_Errors();
             }
             if ($mycommit->stf_message != '') {
                 $this->HTML .= '&nbsp; ' . freshports_SanityTestFailure_Link($mycommit->message_id);
             }
             #        			echo '<pre>' . print_r($mycommit, true) . '</pre>';
             if ($mycommit->svn_revision != '') {
                 $this->HTML .= '&nbsp; ' . freshports_svnweb_ChangeSet_Link($mycommit->svn_revision, $mycommit->svn_hostname, $mycommit->path_to_repo);
             }
             $this->HTML .= "<br>\n";
         }
         $NumberOfPortsInThisCommit++;
         if ($NumberOfPortsInThisCommit > $MaxNumberPortsToShow && !$this->ShowAllPorts) {
             $TooManyPorts = true;
         }
         if (!$TooManyPorts) {
             if (isset($mycommit->category) && $mycommit->category != '') {
                 if ($this->UserID) {
                     if ($mycommit->watch) {
                         $this->HTML .= ' ' . freshports_Watch_Link_Remove($this->WatchListAsk, $mycommit->watch, $mycommit->element_id) . ' ';
                     } else {
                         $this->HTML .= ' ' . freshports_Watch_Link_Add($this->WatchListAsk, $mycommit->watch, $mycommit->element_id) . ' ';
                     }
                 }
                 $this->HTML .= '<BIG><B>';
                 $this->HTML .= '<A HREF="/' . $mycommit->category . '/' . $mycommit->port . '/">';
                 $this->HTML .= $mycommit->port;
                 $this->HTML .= '</A>';
                 $PackageVersion = freshports_PackageVersion($mycommit->version, $mycommit->revision, $mycommit->epoch);
                 if (strlen($PackageVersion) > 0) {
                     $this->HTML .= ' ' . $PackageVersion;
                 }
                 $this->HTML .= "</B></BIG>\n";
                 $this->HTML .= '<A HREF="/' . $mycommit->category . '/">';
                 $this->HTML .= $mycommit->category . "</A>";
                 $this->HTML .= '&nbsp;';
                 // indicate if this port has been removed from cvs
                 if ($mycommit->status == "D") {
                     $this->HTML .= " " . freshports_Deleted_Icon_Link() . "\n";
                 }
                 // indicate if this port needs refreshing from CVS
                 if ($mycommit->needs_refresh) {
                     $this->HTML .= " " . freshports_Refresh_Icon_Link() . "\n";
                 }
                 if ($mycommit->date_added > Time() - 3600 * 24 * $this->DaysMarkedAsNew) {
                     $MarkedAsNew = "Y";
                     $this->HTML .= freshports_New_Icon() . "\n";
                 }
                 if ($mycommit->forbidden) {
                     $this->HTML .= ' ' . freshports_Forbidden_Icon_Link() . "\n";
                 }
                 if ($mycommit->broken) {
                     $this->HTML .= ' ' . freshports_Broken_Icon_Link() . "\n";
                 }
                 if ($mycommit->deprecated) {
                     $this->HTML .= ' ' . freshports_Deprecated_Icon_Link() . "\n";
                 }
                 if ($mycommit->expiration_date) {
                     if (date('Y-m-d') >= $mycommit->expiration_date) {
                         $this->HTML .= freshports_Expired_Icon_Link($mycommit->expiration_date) . "\n";
                     } else {
                         $this->HTML .= freshports_Expiration_Icon_Link($mycommit->expiration_date) . "\n";
                     }
                 }
                 if ($mycommit->ignore) {
                     $this->HTML .= ' ' . freshports_Ignore_Icon_Link() . "\n";
                 }
                 $this->HTML .= freshports_Commit_Link_Port($mycommit->message_id, $mycommit->category, $mycommit->port);
                 $this->HTML .= "&nbsp;";
                 if ($mycommit->vulnerable_current) {
                     $this->HTML .= '&nbsp;' . freshports_VuXML_Icon() . '&nbsp;';
                 } else {
                     if ($mycommit->vulnerable_past) {
                         $this->HTML .= '&nbsp;' . freshports_VuXML_Icon_Faded() . '&nbsp;';
                     }
                 }
                 if ($mycommit->restricted) {
                     $this->HTML .= freshports_Restricted_Icon_Link($mycommit->restricted) . '&nbsp;';
                 }
                 if ($mycommit->no_cdrom) {
                     $this->HTML .= freshports_No_CDROM_Icon_Link($mycommit->no_cdrom) . '&nbsp;';
                 }
                 if ($mycommit->is_interactive) {
                     $this->HTML .= freshports_Is_Interactive_Icon_Link($mycommit->is_interactive) . '&nbsp;';
                 }
             } else {
                 # This is a non-port element...
                 $this->HTML .= $mycommit->revision . ' ';
                 $this->HTML .= '<big><B>';
                 $PathName = preg_replace('|^/?ports/|', '', $mycommit->element_pathname);
                 #				echo "'$PathName' " . "'" . $mycommit->repo_name . "'";
                 switch ($mycommit->repo_name) {
                     case 'ports':
                         $PathName = preg_replace('|^head/|', '', $PathName);
                         break;
                 }
                 if ($PathName != $mycommit->element_pathname) {
                     $this->HTML .= '<a href="/' . str_replace('%2F', '/', urlencode($PathName)) . '">' . $PathName . '</a>';
                     $this->HTML .= "</B></BIG>\n";
                 } else {
                     $this->HTML .= '<a href="' . FRESHPORTS_FREEBSD_CVS_URL . $PathName . '#rev' . $mycommit->revision . '">' . $PathName . '</a>';
                     $this->HTML .= "</B></BIG>\n";
                 }
             }
             $this->HTML .= htmlify(_forDisplay($mycommit->short_description)) . "\n";
             $this->HTML .= "<BR>\n";
             global $freshports_CommitMsgMaxNumOfLinesToShow;
             if ($this->ShowEntireCommit) {
                 $Lines = 0;
             } else {
                 $Lines = $freshports_CommitMsgMaxNumOfLinesToShow;
             }
         }
         # !$TooManyPorts
         $PreviousCommit = $mycommit;
     }
     if ($NumberOfPortsInThisCommit > $MaxNumberPortsToShow && !$this->ShowAllPorts) {
         $this->HTML .= '<BR>' . freshports_MorePortsToShow($PreviousCommit->message_id, $NumberOfPortsInThisCommit, $MaxNumberPortsToShow);
     }
     $this->HTML .= "\n<BLOCKQUOTE>";
     $this->HTML .= freshports_CommitDescriptionPrint($PreviousCommit->commit_description, $PreviousCommit->encoding_losses, $Lines, freshports_MoreCommitMsgToShow($PreviousCommit->message_id, $Lines));
     # close off the last commit
     $this->HTML .= "\n</BLOCKQUOTE>\n</TD></TR>\n\n\n";
     unset($mycommit);
     return $this->HTML;
 }