Esempio n. 1
0
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;
}
Esempio n. 2
0
/**
 * 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';
}
Esempio n. 3
0
function phpquranOnline()
{
    global $SQL, $dbprefix, $config, $session;
    // get information ..
    $ip = get_ip();
    $agent = $SQL->escape($_SERVER['HTTP_USER_AGENT']);
    $timeout = 600;
    //seconds //10 min
    $time = time();
    $timeout2 = $time - $timeout;
    $username = '******';
    //---
    if (!empty($ip) && !empty($agent) && !empty($session)) {
        $rep_query = array('REPLACE' => 'ip, username, agent, time, session', 'INTO' => "{$dbprefix}online", 'VALUES' => "'{$ip}','{$username}','{$agent}','{$time}','{$session}'", 'UNIQUE' => "session='{$session}'");
        $SQL->build($rep_query);
    }
    $last_online_time_update = get_cache_value('last_online_time_update');
    //clean online table
    if (time() - $last_online_time_update >= 3600) {
        $query_del = array('DELETE' => "{$dbprefix}online", 'WHERE' => "time < '{$timeout2}'");
        $SQL->build($query_del);
        //update last_online_time_update
        update_cache('last_online_time_update', time());
    }
}
Esempio n. 4
0
File: rss.php Progetto: pyp22/aurweb
<?php

set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang');
include_once "aur.inc.php";
include_once "pkgfuncs.inc.php";
include_once "feedcreator.class.php";
#detect prefix
$protocol = isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on' ? "https" : "http";
$host = $_SERVER['HTTP_HOST'];
$feed_key = 'pkg-feed-' . $protocol;
$bool = false;
$ret = get_cache_value($feed_key, $bool);
if ($bool) {
    echo $ret;
    exit;
}
$rss = new RSSCreator20();
$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";