aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php27
1 files changed, 23 insertions, 4 deletions
diff --git a/index.php b/index.php
index c6f86c59..5bc13d49 100644
--- a/index.php
+++ b/index.php
@@ -1,6 +1,6 @@
1<?php 1<?php
2/** 2/**
3 * Shaarli v0.7.0 - Shaare your links... 3 * Shaarli v0.8.0 - Shaare your links...
4 * 4 *
5 * The personal, minimalist, super-fast, database free, bookmarking service. 5 * The personal, minimalist, super-fast, database free, bookmarking service.
6 * 6 *
@@ -25,7 +25,7 @@ if (date_default_timezone_get() == '') {
25/* 25/*
26 * PHP configuration 26 * PHP configuration
27 */ 27 */
28define('shaarli_version', '0.7.0'); 28define('shaarli_version', '0.8.0');
29 29
30// http://server.com/x/shaarli --> /shaarli/ 30// http://server.com/x/shaarli --> /shaarli/
31define('WEB_PATH', substr($_SERVER['REQUEST_URI'], 0, 1+strrpos($_SERVER['REQUEST_URI'], '/', 0))); 31define('WEB_PATH', substr($_SERVER['REQUEST_URI'], 0, 1+strrpos($_SERVER['REQUEST_URI'], '/', 0)));
@@ -332,8 +332,17 @@ include $conf->get('resource.ban_file', 'data/ipbans.php');
332function ban_loginFailed($conf) 332function ban_loginFailed($conf)
333{ 333{
334 $ip = $_SERVER['REMOTE_ADDR']; 334 $ip = $_SERVER['REMOTE_ADDR'];
335 $trusted = $conf->get('security.trusted_proxies', array());
336 if (in_array($ip, $trusted)) {
337 $ip = getIpAddressFromProxy($_SERVER, $trusted);
338 if (!$ip) {
339 return;
340 }
341 }
335 $gb = $GLOBALS['IPBANS']; 342 $gb = $GLOBALS['IPBANS'];
336 if (!isset($gb['FAILURES'][$ip])) $gb['FAILURES'][$ip]=0; 343 if (! isset($gb['FAILURES'][$ip])) {
344 $gb['FAILURES'][$ip]=0;
345 }
337 $gb['FAILURES'][$ip]++; 346 $gb['FAILURES'][$ip]++;
338 if ($gb['FAILURES'][$ip] > ($conf->get('security.ban_after') - 1)) 347 if ($gb['FAILURES'][$ip] > ($conf->get('security.ban_after') - 1))
339 { 348 {
@@ -1236,6 +1245,9 @@ function renderPage($conf, $pluginManager)
1236 // -------- User clicked the "Save" button when editing a link: Save link to database. 1245 // -------- User clicked the "Save" button when editing a link: Save link to database.
1237 if (isset($_POST['save_edit'])) 1246 if (isset($_POST['save_edit']))
1238 { 1247 {
1248 $linkdate = $_POST['lf_linkdate'];
1249 $updated = isset($LINKSDB[$linkdate]) ? strval(date('Ymd_His')) : false;
1250
1239 // Go away! 1251 // Go away!
1240 if (! tokenOk($_POST['token'])) { 1252 if (! tokenOk($_POST['token'])) {
1241 die('Wrong token.'); 1253 die('Wrong token.');
@@ -1246,7 +1258,7 @@ function renderPage($conf, $pluginManager)
1246 $tags = preg_replace('/(^| )\-/', '$1', $tags); 1258 $tags = preg_replace('/(^| )\-/', '$1', $tags);
1247 // Remove duplicates. 1259 // Remove duplicates.
1248 $tags = implode(' ', array_unique(explode(' ', $tags))); 1260 $tags = implode(' ', array_unique(explode(' ', $tags)));
1249 $linkdate = $_POST['lf_linkdate']; 1261
1250 $url = trim($_POST['lf_url']); 1262 $url = trim($_POST['lf_url']);
1251 if (! startsWith($url, 'http:') && ! startsWith($url, 'https:') 1263 if (! startsWith($url, 'http:') && ! startsWith($url, 'https:')
1252 && ! startsWith($url, 'ftp:') && ! startsWith($url, 'magnet:') 1264 && ! startsWith($url, 'ftp:') && ! startsWith($url, 'magnet:')
@@ -1261,6 +1273,7 @@ function renderPage($conf, $pluginManager)
1261 'description' => $_POST['lf_description'], 1273 'description' => $_POST['lf_description'],
1262 'private' => (isset($_POST['lf_private']) ? 1 : 0), 1274 'private' => (isset($_POST['lf_private']) ? 1 : 0),
1263 'linkdate' => $linkdate, 1275 'linkdate' => $linkdate,
1276 'updated' => $updated,
1264 'tags' => str_replace(',', ' ', $tags) 1277 'tags' => str_replace(',', ' ', $tags)
1265 ); 1278 );
1266 // If title is empty, use the URL as title. 1279 // If title is empty, use the URL as title.
@@ -1624,6 +1637,12 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
1624 $link['class'] = $link['private'] == 0 ? $classLi : 'private'; 1637 $link['class'] = $link['private'] == 0 ? $classLi : 'private';
1625 $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); 1638 $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']);
1626 $link['timestamp'] = $date->getTimestamp(); 1639 $link['timestamp'] = $date->getTimestamp();
1640 if (! empty($link['updated'])) {
1641 $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['updated']);
1642 $link['updated_timestamp'] = $date->getTimestamp();
1643 } else {
1644 $link['updated_timestamp'] = '';
1645 }
1627 $taglist = explode(' ', $link['tags']); 1646 $taglist = explode(' ', $link['tags']);
1628 uasort($taglist, 'strcasecmp'); 1647 uasort($taglist, 'strcasecmp');
1629 $link['taglist'] = $taglist; 1648 $link['taglist'] = $taglist;