X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=inline;f=index.php;h=9783539a21b3eca3fbd4c5a72c43d12e33a699b4;hb=0b631e69d11e1860380deeeb684b82cab412518b;hp=957d8d9a4f428abbc0524b02f4e91bfd04e5b47e;hpb=c03c90a13e1356ca9cf40cc664547c49305cb24b;p=github%2Fshaarli%2FShaarli.git diff --git a/index.php b/index.php index 957d8d9a..9783539a 100644 --- a/index.php +++ b/index.php @@ -10,8 +10,6 @@ * - https://github.com/sebsauvage/Shaarli * * Licence: http://www.opensource.org/licenses/zlib-license.php - * - * Requires: PHP 5.5.x */ // Set 'UTC' as the default timezone if it is not defined in php.ini @@ -86,7 +84,7 @@ use \Shaarli\Updater\Updater; // Ensure the PHP version is supported try { - ApplicationUtils::checkPHPVersion('5.5', PHP_VERSION); + ApplicationUtils::checkPHPVersion('7.1', PHP_VERSION); } catch (Exception $exc) { header('Content-Type: text/plain; charset=utf-8'); echo $exc->getMessage(); @@ -465,7 +463,7 @@ function showDaily($pageBuilder, $LINKSDB, $conf, $pluginManager, $loginManager) // Description: 836 characters gives roughly 342 pixel height. // This is not perfect, but it's usually OK. $length = strlen($link['title']) + (342 * strlen($link['description'])) / 836; - if ($link['thumbnail']) { + if (! empty($link['thumbnail'])) { $length += 100; // 1 thumbnails roughly takes 100 pixels height. } // Then put in column which is the less filled: @@ -1126,22 +1124,24 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, // lf_id should only be present if the link exists. $id = isset($_POST['lf_id']) ? intval(escape($_POST['lf_id'])) : $LINKSDB->getNextId(); + $link['id'] = $id; // Linkdate is kept here to: // - use the same permalink for notes as they're displayed when creating them // - let users hack creation date of their posts // See: https://shaarli.readthedocs.io/en/master/guides/various-hacks/#changing-the-timestamp-for-a-shaare $linkdate = escape($_POST['lf_linkdate']); + $link['created'] = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $linkdate); if (isset($LINKSDB[$id])) { // Edit - $created = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $linkdate); - $updated = new DateTime(); - $shortUrl = $LINKSDB[$id]['shorturl']; + $link['updated'] = new DateTime(); + $link['shorturl'] = $LINKSDB[$id]['shorturl']; + $link['sticky'] = isset($LINKSDB[$id]['sticky']) ? $LINKSDB[$id]['sticky'] : false; $new = false; } else { // New link - $created = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $linkdate); - $updated = null; - $shortUrl = link_small_hash($created, $id); + $link['updated'] = null; + $link['shorturl'] = link_small_hash($link['created'], $id); + $link['sticky'] = false; $new = true; } @@ -1157,17 +1157,13 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, } $url = whitelist_protocols(trim($_POST['lf_url']), $conf->get('security.allowed_protocols')); - $link = array( - 'id' => $id, + $link = array_merge($link, [ 'title' => trim($_POST['lf_title']), 'url' => $url, 'description' => $_POST['lf_description'], 'private' => (isset($_POST['lf_private']) ? 1 : 0), - 'created' => $created, - 'updated' => $updated, 'tags' => str_replace(',', ' ', $tags), - 'shorturl' => $shortUrl, - ); + ]); // If title is empty, use the URL as title. if ($link['title'] == '') { @@ -1181,8 +1177,6 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, $link['thumbnail'] = $thumbnailer->get($url); } - $link['sticky'] = isset($link['sticky']) ? $link['sticky'] : false; - $pluginManager->executeHooks('save_link', $link); $LINKSDB[$id] = $link; @@ -1567,6 +1561,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, if ($targetPage == Router::$PAGE_SAVE_PLUGINSADMIN) { try { if (isset($_POST['parameters_form'])) { + $pluginManager->executeHooks('save_plugin_parameters', $_POST); unset($_POST['parameters_form']); foreach ($_POST as $param => $value) { $conf->set('plugins.'. $param, escape($value));