コード例 #1
0
ファイル: cachefuncs.inc.php プロジェクト: pyp22/aurweb
function db_cache_value($dbq, $key, $ttl = 600)
{
    $dbh = DB::connect();
    $status = false;
    $value = get_cache_value($key, $status);
    if (!$status) {
        $result = $dbh->query($dbq);
        $row = $result->fetch(PDO::FETCH_NUM);
        $value = $row[0];
        set_cache_value($key, $value, $ttl);
    }
    return $value;
}
コード例 #2
0
ファイル: stats.inc.php プロジェクト: pyp22/aurweb
/**
 * Display the most recent 10 packages
 *
 * @return void
 */
function updates_table()
{
    $dbh = DB::connect();
    $key = 'recent_updates';
    if (!($newest_packages = get_cache_value($key))) {
        $q = 'SELECT Packages.Name, Version, ModifiedTS, SubmittedTS ';
        $q .= 'FROM Packages INNER JOIN PackageBases ON ';
        $q .= 'Packages.PackageBaseID = PackageBases.ID ';
        $q .= 'WHERE PackageBases.PackagerUID IS NOT NULL ';
        $q .= 'ORDER BY ModifiedTS DESC LIMIT 15';
        $result = $dbh->query($q);
        $newest_packages = new ArrayObject();
        while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
            $newest_packages->append($row);
        }
        set_cache_value($key, $newest_packages);
    }
    include 'stats/updates_table.php';
}
コード例 #3
0
ファイル: rss.php プロジェクト: pyp22/aurweb
$rss->cssStyleSheet = false;
$rss->xslStyleSheet = false;
# Use UTF-8 (fixes FS#10706).
$rss->encoding = "UTF-8";
#All the general RSS setup
$rss->title = "AUR Newest Packages";
$rss->description = "The latest and greatest packages in the AUR";
$rss->link = "{$protocol}://{$host}";
$rss->syndicationURL = "{$protocol}://{$host}" . get_uri('/rss/');
$image = new FeedImage();
$image->title = "AUR";
$image->url = "{$protocol}://{$host}/images/AUR-logo-80.png";
$image->link = $rss->link;
$image->description = "AUR Newest Packages Feed";
$rss->image = $image;
#Get the latest packages and add items for them
$packages = latest_pkgs(20);
while (list($indx, $row) = each($packages)) {
    $item = new FeedItem();
    $item->title = $row["Name"];
    $item->link = "{$protocol}://{$host}" . get_pkg_uri($row["Name"]);
    $item->description = $row["Description"];
    $item->date = intval($row["SubmittedTS"]);
    $item->source = "{$protocol}://{$host}";
    $item->author = username_from_id($row["MaintainerUID"]);
    $rss->addItem($item);
}
#save it so that useCached() can find it
$feedContent = $rss->createFeed();
set_cache_value($feed_key, $feedContent, 1800);
echo $feedContent;