$ git clone https://thingshare.ion.nu/thingshare.git
commit fba155cfc143cd7cb1438586e5cd914f256ba0d0
Author: Alicia <...>
Date: Mon Mar 16 22:37:59 2020 +0100
Added a start page.
diff --git a/.htaccess b/.htaccess
index e208db5..d320a6c 100644
--- a/.htaccess
+++ b/.htaccess
@@ -1,6 +1,8 @@
# Keep mod_negotiation from getting in the way
Options -Multiviews
# Redirect requests to paths that don't exist to index.php
-RewriteEngine On
-RewriteCond %{REQUEST_FILENAME} !-f
-RewriteRule .* index.php
+<IfModule mod_rewrite.c>
+ RewriteEngine On
+ RewriteCond %{REQUEST_FILENAME} !-f
+ RewriteRule .* index.php
+</IfModule>
diff --git a/index.php b/index.php
index b31bd78..70517ff 100644
--- a/index.php
+++ b/index.php
@@ -73,6 +73,7 @@ switch($path[1])
header('HTTP/1.1 404 Not found');
die('{"httpresponse":404,"error":"Not found"}');
break;
+ case '': include('start.php'); break;
default:
include_once('head.php');
header('HTTP/1.1 404 Not found');
diff --git a/start.php b/start.php
new file mode 100644
index 0000000..307b5b6
--- /dev/null
+++ b/start.php
@@ -0,0 +1,45 @@
+<...>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+*/
+include_once('head.php');
+include_once('rpc.php');
+// Gather the 10 most recent local things
+$things='';
+$res=rpc_get(DOMAIN, 'search//newest/10/0');
+foreach($res as $thing)
+{
+ $things.='<div class="thing"><div class="boxtop">By <a href="'.BASEURL.'/user/'.$thing['by']['name'].'@'.DOMAIN.'" title="'.$thing['by']['name'].'@'.DOMAIN.'">'.$thing['by']['displayname'].'</a></div><...><div class="boxbottom">'.htmlentities($thing['name']).'</div><img src="https://'.DOMAIN.$thing['preview'].'" /></a></div>';
+}
+// Get statistics
+function getcount($table)
+{
+ global $db;
+ $res=mysqli_query($db, 'select count(*) from '.$table);
+ $res=mysqli_fetch_row($res);
+ return $res[0];
+}
+$numusers=getcount('users where status!='.ACCOUNT_BANNED);
+$numthings=getcount('things where latest and !removed');
+$numpeers=getcount('peers where !blacklist');
+?>
+<h1><?=sprintf(_('Latest designs on %s'), DOMAIN)?></h1>
+<?=$things?>
+
+<h1><?=_('Statistics')?></h1>
+<?=sprintf(_('%d users, %d things on %s. Federating with %d peers'), $numusers, $numthings, DOMAIN, $numpeers)?>
diff --git a/style.css b/style.css
index 45b62ce..bbd97be 100644
--- a/style.css
+++ b/style.css
@@ -33,6 +33,7 @@ body {
}
#search input {
vertical-align:top;
+ height:calc(1em + 20px);
}
#search button {
padding:0px;