X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=index.php;h=f7e73bde956c161d043d627361b92d7ca6eed519;hb=918bd5b9122f929268e0979063c4844e85090858;hp=f9f248953eb1d09281b548a7c01e465f553bc31e;hpb=fdf88d194874a533cf3a8de3d317d70018aa8a62;p=github%2Fshaarli%2FShaarli.git diff --git a/index.php b/index.php index f9f24895..f7e73bde 100644 --- a/index.php +++ b/index.php @@ -332,8 +332,17 @@ include $conf->get('resource.ban_file', 'data/ipbans.php'); function ban_loginFailed($conf) { $ip = $_SERVER['REMOTE_ADDR']; + $trusted = $conf->get('security.trusted_proxies', array()); + if (in_array($ip, $trusted)) { + $ip = getIpAddressFromProxy($_SERVER, $trusted); + if (!$ip) { + return; + } + } $gb = $GLOBALS['IPBANS']; - if (!isset($gb['FAILURES'][$ip])) $gb['FAILURES'][$ip]=0; + if (! isset($gb['FAILURES'][$ip])) { + $gb['FAILURES'][$ip]=0; + } $gb['FAILURES'][$ip]++; if ($gb['FAILURES'][$ip] > ($conf->get('security.ban_after') - 1)) { @@ -769,6 +778,7 @@ function renderPage($conf, $pluginManager) $PAGE = new PageBuilder($conf); $PAGE->assign('linkcount', count($LINKSDB)); $PAGE->assign('privateLinkcount', count_private($LINKSDB)); + $PAGE->assign('plugin_errors', $pluginManager->getErrors()); // Determine which page will be rendered. $query = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : ''; @@ -1236,6 +1246,9 @@ function renderPage($conf, $pluginManager) // -------- User clicked the "Save" button when editing a link: Save link to database. if (isset($_POST['save_edit'])) { + $linkdate = $_POST['lf_linkdate']; + $updated = isset($LINKSDB[$linkdate]) ? strval(date('Ymd_His')) : false; + // Go away! if (! tokenOk($_POST['token'])) { die('Wrong token.'); @@ -1246,7 +1259,7 @@ function renderPage($conf, $pluginManager) $tags = preg_replace('/(^| )\-/', '$1', $tags); // Remove duplicates. $tags = implode(' ', array_unique(explode(' ', $tags))); - $linkdate = $_POST['lf_linkdate']; + $url = trim($_POST['lf_url']); if (! startsWith($url, 'http:') && ! startsWith($url, 'https:') && ! startsWith($url, 'ftp:') && ! startsWith($url, 'magnet:') @@ -1261,6 +1274,7 @@ function renderPage($conf, $pluginManager) 'description' => $_POST['lf_description'], 'private' => (isset($_POST['lf_private']) ? 1 : 0), 'linkdate' => $linkdate, + 'updated' => $updated, 'tags' => str_replace(',', ' ', $tags) ); // If title is empty, use the URL as title. @@ -1624,6 +1638,12 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager) $link['class'] = $link['private'] == 0 ? $classLi : 'private'; $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); $link['timestamp'] = $date->getTimestamp(); + if (! empty($link['updated'])) { + $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['updated']); + $link['updated_timestamp'] = $date->getTimestamp(); + } else { + $link['updated_timestamp'] = ''; + } $taglist = explode(' ', $link['tags']); uasort($taglist, 'strcasecmp'); $link['taglist'] = $taglist;