From cc381753a82125de0d08379dc7c4d58cbdb66dad Mon Sep 17 00:00:00 2001 From: litemotiv Date: Wed, 5 Feb 2025 11:47:34 +0100 Subject: [PATCH] Colorize user home pages based on modified age --- index.php | 64 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/index.php b/index.php index a5de5d1..409ea7e 100644 --- a/index.php +++ b/index.php @@ -11,7 +11,7 @@ if (isset($_GET['notice'])) { } } ?> -

welcome to tilde.club

+

welcome to Tilde.club

Questions? See the official FAQ.

@@ -119,7 +119,7 @@ if (isset($_GET['notice'])) {

- tilde.club is not a social network it is one tiny totally + Tilde.club is not a social network it is one tiny totally standard unix computer that people respectfully use together in their shared quest to build awesome web pages

@@ -129,12 +129,12 @@ if (isset($_GET['notice'])) { RECENTLY CHANGED PAGES you can see that too

- Or Check out the tilde.club gallery created by ~tweska + Or Check out the Tilde.club gallery created by ~tweska


-

tilde.club gold star supporters

-

Tilde.Club is supported by a global community of +

Tilde.club gold star supporters

+

Tilde.club is supported by a global community of good people. We don't rank people by the amount they give, only by the fact that they gave. Here's who has donated! When you're on the @@ -165,11 +165,11 @@ if (isset($_GET['notice'])) {

-

here are the home pages of our users

-

this list does not include people who haven't changed their page yet.

-

if you're not seeing yourself listed here, change your page from the default.

-

users with recently updated pages within the last month are highlighted in a lighter color.

-

list all users

+

Here are the home pages of our users

+

This list does not include people who haven't changed their page yet.

+

If you're not seeing yourself listed here, change your page from the default.

+

Users with recently updated pages are highlighted in a lighter color.

+

List all users

'; + $homepagesOutput = '
'; + $now = time(); - foreach (glob("/home/*") as $user) { + foreach (glob("/home/*") as $user) + { // Look for index files with common extensions $indexFiles = glob("$user/public_html/index.{html,htm,php}", GLOB_BRACE); $index = count($indexFiles) > 0 ? $indexFiles[0] : null; if (!$index || in_array(sha1_file($index), $page_shas)) continue; - // Check if the index pages were updated in the last month - $recentChange = false; + // determine the most recently updated file + $age = 0; - foreach ($indexFiles as $file) { - if (filemtime($file) > $oneMonthAgo) { - $recentChange = true; - break; - } + foreach ($indexFiles as $file) + { + $access = filemtime($file); + + if ($access > $age) + $age = $access; } $user = basename($user); + + // For simplicity, we use a maximum of 50 months old + $monthsOld = floor(($now - $age) / 2592000); + if ($monthsOld > 50) $monthsOld = 50; - $homepages_list .= ''.(($recentChange) ? '~'.$user.'' : '~'.$user).''; + // Minimum is 15% opacity + $opacity = 100 - 2 * $monthsOld; + if ($opacity < 15) $opacity = 15; + + $homepagesOutput .= '~'.$user.''; } - $homepages_list .= '
'; + $homepagesOutput .= '
'; // Save cache file - $save_cache = file_put_contents($cache_file, $homepages_list); + $save_cache = file_put_contents($cache_file, $homepagesOutput); } - echo $homepages_list; + echo $homepagesOutput; ?>