⌈⌋ ⎇ branch:  freshcode


Check-in [08ed5cd6ea]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add CloudFlare and DB statistics to frontpage (replacing no-ads whitebox).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 08ed5cd6ea5bc4351daf44a41a5ffaa5d0de4713
User & Date: mario 2014-11-03 02:15:11
Context
2014-11-03
02:17
Add github-releases to RewriteRule dispatcher, config: set default user-agent string for cURL *and* PHP streams. check-in: b4b26d77c4 user: mario tags: trunk
02:15
Add CloudFlare and DB statistics to frontpage (replacing no-ads whitebox). check-in: 08ed5cd6ea user: mario tags: trunk
02:12
For absent results, allow singular ->property_row access to silently return NULL. check-in: 44a53a1581 user: mario tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to cron.daily/autoupdate.php.

22
23
24
25
26
27
28


29
30


// run in cron context
chdir(dirname(__DIR__));
include("config.php");

// go
$run = new Autoupdate();
$run->all();


#print_r($run->test("github", "youtube-dl"));










>
>
|
|
>
>
22
23
24
25
26
27
28
29
30
31
32
33
34
// run in cron context
chdir(dirname(__DIR__));
include("config.php");

// go
$run = new Autoupdate();
$run->all();
#print_r($run->test("changelog", "uselessd"));
#print_r($run->test("regex", "linux"));
#print_r($run->test("regex", "php"));
#print_r($p = $run->test("regex", "limesurvey"));
#var_dump(input::words($p["version"]));
#var_dump($run->version_exists('limesurvey', $p['version']));

Added cron.daily/header_stats.php.







































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
 * title: statistics
 * description: generate statistics, visitors, projects, autoupdate, etc. for header
 *
 * Approximate weekly numbers by multiplication.
 *
 */

chdir(dirname(__DIR__)); 
include("config.php");


// get CloudFlare visitor stats
$json = curl()
   ->url("https://www.cloudflare.com/api_json.html")
   ->postfields([
       "a" => "stats",
       "tkn" => CLOUDFLARE_TKN,
       "email" => CLOUDFLARE_EMAIL,
       "z" => "freshcode.club",
       "interval" => 40,
    ])
   ->exec();
$stats = json_decode($json);
#print_r($stats);
$s_visitors = intval($stats->response->result->objs[0]->trafficBreakdown->uniques->regular * 4.1);
$s_pageviews = intval($stats->response->result->objs[0]->trafficBreakdown->pageviews->regular * 8.9);

// number of projects
$s_num_proj = db("SELECT COUNT(name) AS cnt FROM (SELECT name FROM release GROUP BY name)")->cnt;

// releases
$s_num_vers = db("SELECT COUNT(name) AS cnt FROM (SELECT DISTINCT name, version FROM release WHERE version != ?)", "")->cnt;

// autoupdating entries
$s_num_auto = db("SELECT COUNT(name) AS cnt FROM (SELECT name FROM release WHERE autoupdate_module != ? GROUP BY name)", "none")->cnt;
$s_num_auto = round($s_num_auto / $s_num_proj * 100, 1);


file_put_contents("template/stats.htm",
<<<HTML
   <ul id=stats>
      <li> <var>$s_num_proj</var> projects
      <li> <var>$s_num_vers</var> releases
      <li> <var>$s_num_auto%</var> auto updating
      <li> <var>$s_visitors</var> visitors/wk
      <li> <var>$s_pageviews</var> recent pageviews
   </ul>
HTML
);

Changes to template/header.php.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
/**
 * api: freshcode
 * type: template
 * title: HTML page header
 * description: Starts <html> and <head>, outputs top bar / menus etc.
 * version: 0.7.3
 *
 * Optionally injects a `$header_add` list, or allows to override the
 * page $title.
 *
 */
?>
<!DOCTYPE html>
<html>
<head> 
    <title><?= isset($title) ? $title : "freshcode.club" ?></title>
    <meta name=version content=0.7.3>
    <meta charset=UTF-8>
    <link rel=stylesheet href="/freshcode.css?0.7.3">
    <link rel="shortcut icon" href="/img/changes.png">
    <base href="/index">
    <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <!--[if lt IE 9]><script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"></script><![endif]-->
    <script src="/gimmicks.js?2"></script>
    <?php if (isset($header_add)) { print $header_add . "\n"; } ?>
</head>
<body>

<nav id=topbar>
Open source software release tracking.
<?= is_int(strpos(HTTP_HOST, ".")) ? '<small style="color:#9c7" class=version>[0.7.3 alpha]</small>' : '<b style="color:#c54">[local dev]</b>'; ?>
<span style=float:right>
<a href="//freshmeat.club/">freshmeat.club</a> |
<a href="//freecode.club/">freecode.club</a> |
<b><a href="//freshcode.club/">freshcode.club</a></b>
</span>
</nav>







|










|













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
/**
 * api: freshcode
 * type: template
 * title: HTML page header
 * description: Starts <html> and <head>, outputs top bar / menus etc.
 * version: 0.7.4
 *
 * Optionally injects a `$header_add` list, or allows to override the
 * page $title.
 *
 */
?>
<!DOCTYPE html>
<html>
<head> 
    <title><?= isset($title) ? $title : "freshcode.club" ?></title>
    <meta name=version content=0.7.4>
    <meta charset=UTF-8>
    <link rel=stylesheet href="/freshcode.css?0.7.3">
    <link rel="shortcut icon" href="/img/changes.png">
    <base href="/index">
    <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <!--[if lt IE 9]><script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"></script><![endif]-->
    <script src="/gimmicks.js?2"></script>
    <?php if (isset($header_add)) { print $header_add . "\n"; } ?>
</head>
<body>

<nav id=topbar>
Open source software release tracking.
<?= is_int(strpos(HTTP_HOST, ".")) ? '<small style="color:#9c7" class=version>[0.7.4 alpha]</small>' : '<b style="color:#c54">[local dev]</b>'; ?>
<span style=float:right>
<a href="//freshmeat.club/">freshmeat.club</a> |
<a href="//freecode.club/">freecode.club</a> |
<b><a href="//freshcode.club/">freshcode.club</a></b>
</span>
</nav>