aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php25
1 files changed, 11 insertions, 14 deletions
diff --git a/index.php b/index.php
index 957d8d9a..9e473936 100644
--- a/index.php
+++ b/index.php
@@ -1126,22 +1126,24 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
1126 1126
1127 // lf_id should only be present if the link exists. 1127 // lf_id should only be present if the link exists.
1128 $id = isset($_POST['lf_id']) ? intval(escape($_POST['lf_id'])) : $LINKSDB->getNextId(); 1128 $id = isset($_POST['lf_id']) ? intval(escape($_POST['lf_id'])) : $LINKSDB->getNextId();
1129 $link['id'] = $id;
1129 // Linkdate is kept here to: 1130 // Linkdate is kept here to:
1130 // - use the same permalink for notes as they're displayed when creating them 1131 // - use the same permalink for notes as they're displayed when creating them
1131 // - let users hack creation date of their posts 1132 // - let users hack creation date of their posts
1132 // See: https://shaarli.readthedocs.io/en/master/guides/various-hacks/#changing-the-timestamp-for-a-shaare 1133 // See: https://shaarli.readthedocs.io/en/master/guides/various-hacks/#changing-the-timestamp-for-a-shaare
1133 $linkdate = escape($_POST['lf_linkdate']); 1134 $linkdate = escape($_POST['lf_linkdate']);
1135 $link['created'] = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $linkdate);
1134 if (isset($LINKSDB[$id])) { 1136 if (isset($LINKSDB[$id])) {
1135 // Edit 1137 // Edit
1136 $created = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $linkdate); 1138 $link['updated'] = new DateTime();
1137 $updated = new DateTime(); 1139 $link['shorturl'] = $LINKSDB[$id]['shorturl'];
1138 $shortUrl = $LINKSDB[$id]['shorturl']; 1140 $link['sticky'] = isset($LINKSDB[$id]['sticky']) ? $LINKSDB[$id]['sticky'] : false;
1139 $new = false; 1141 $new = false;
1140 } else { 1142 } else {
1141 // New link 1143 // New link
1142 $created = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $linkdate); 1144 $link['updated'] = null;
1143 $updated = null; 1145 $link['shorturl'] = link_small_hash($link['created'], $id);
1144 $shortUrl = link_small_hash($created, $id); 1146 $link['sticky'] = false;
1145 $new = true; 1147 $new = true;
1146 } 1148 }
1147 1149
@@ -1157,17 +1159,13 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
1157 } 1159 }
1158 $url = whitelist_protocols(trim($_POST['lf_url']), $conf->get('security.allowed_protocols')); 1160 $url = whitelist_protocols(trim($_POST['lf_url']), $conf->get('security.allowed_protocols'));
1159 1161
1160 $link = array( 1162 $link = array_merge($link, [
1161 'id' => $id,
1162 'title' => trim($_POST['lf_title']), 1163 'title' => trim($_POST['lf_title']),
1163 'url' => $url, 1164 'url' => $url,
1164 'description' => $_POST['lf_description'], 1165 'description' => $_POST['lf_description'],
1165 'private' => (isset($_POST['lf_private']) ? 1 : 0), 1166 'private' => (isset($_POST['lf_private']) ? 1 : 0),
1166 'created' => $created,
1167 'updated' => $updated,
1168 'tags' => str_replace(',', ' ', $tags), 1167 'tags' => str_replace(',', ' ', $tags),
1169 'shorturl' => $shortUrl, 1168 ]);
1170 );
1171 1169
1172 // If title is empty, use the URL as title. 1170 // If title is empty, use the URL as title.
1173 if ($link['title'] == '') { 1171 if ($link['title'] == '') {
@@ -1181,8 +1179,6 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
1181 $link['thumbnail'] = $thumbnailer->get($url); 1179 $link['thumbnail'] = $thumbnailer->get($url);
1182 } 1180 }
1183 1181
1184 $link['sticky'] = isset($link['sticky']) ? $link['sticky'] : false;
1185
1186 $pluginManager->executeHooks('save_link', $link); 1182 $pluginManager->executeHooks('save_link', $link);
1187 1183
1188 $LINKSDB[$id] = $link; 1184 $LINKSDB[$id] = $link;
@@ -1567,6 +1563,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
1567 if ($targetPage == Router::$PAGE_SAVE_PLUGINSADMIN) { 1563 if ($targetPage == Router::$PAGE_SAVE_PLUGINSADMIN) {
1568 try { 1564 try {
1569 if (isset($_POST['parameters_form'])) { 1565 if (isset($_POST['parameters_form'])) {
1566 $pluginManager->executeHooks('save_plugin_parameters', $_POST);
1570 unset($_POST['parameters_form']); 1567 unset($_POST['parameters_form']);
1571 foreach ($_POST as $param => $value) { 1568 foreach ($_POST as $param => $value) {
1572 $conf->set('plugins.'. $param, escape($value)); 1569 $conf->set('plugins.'. $param, escape($value));