diff options
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -65,6 +65,7 @@ require_once 'application/CachedPage.php'; | |||
65 | require_once 'application/config/ConfigPlugin.php'; | 65 | require_once 'application/config/ConfigPlugin.php'; |
66 | require_once 'application/FeedBuilder.php'; | 66 | require_once 'application/FeedBuilder.php'; |
67 | require_once 'application/FileUtils.php'; | 67 | require_once 'application/FileUtils.php'; |
68 | require_once 'application/History.php'; | ||
68 | require_once 'application/HttpUtils.php'; | 69 | require_once 'application/HttpUtils.php'; |
69 | require_once 'application/Languages.php'; | 70 | require_once 'application/Languages.php'; |
70 | require_once 'application/LinkDB.php'; | 71 | require_once 'application/LinkDB.php'; |
@@ -754,6 +755,12 @@ function renderPage($conf, $pluginManager, $LINKSDB) | |||
754 | die($e->getMessage()); | 755 | die($e->getMessage()); |
755 | } | 756 | } |
756 | 757 | ||
758 | try { | ||
759 | $history = new History($conf->get('resource.history')); | ||
760 | } catch(Exception $e) { | ||
761 | die($e->getMessage()); | ||
762 | } | ||
763 | |||
757 | $PAGE = new PageBuilder($conf); | 764 | $PAGE = new PageBuilder($conf); |
758 | $PAGE->assign('linkcount', count($LINKSDB)); | 765 | $PAGE->assign('linkcount', count($LINKSDB)); |
759 | $PAGE->assign('privateLinkcount', count_private($LINKSDB)); | 766 | $PAGE->assign('privateLinkcount', count_private($LINKSDB)); |
@@ -1146,6 +1153,7 @@ function renderPage($conf, $pluginManager, $LINKSDB) | |||
1146 | $conf->set('api.secret', escape($_POST['apiSecret'])); | 1153 | $conf->set('api.secret', escape($_POST['apiSecret'])); |
1147 | try { | 1154 | try { |
1148 | $conf->write(isLoggedIn()); | 1155 | $conf->write(isLoggedIn()); |
1156 | $history->updateSettings(); | ||
1149 | invalidateCaches($conf->get('resource.page_cache')); | 1157 | invalidateCaches($conf->get('resource.page_cache')); |
1150 | } | 1158 | } |
1151 | catch(Exception $e) { | 1159 | catch(Exception $e) { |
@@ -1177,6 +1185,7 @@ function renderPage($conf, $pluginManager, $LINKSDB) | |||
1177 | $PAGE->assign('hide_public_links', $conf->get('privacy.hide_public_links', false)); | 1185 | $PAGE->assign('hide_public_links', $conf->get('privacy.hide_public_links', false)); |
1178 | $PAGE->assign('api_enabled', $conf->get('api.enabled', true)); | 1186 | $PAGE->assign('api_enabled', $conf->get('api.enabled', true)); |
1179 | $PAGE->assign('api_secret', $conf->get('api.secret')); | 1187 | $PAGE->assign('api_secret', $conf->get('api.secret')); |
1188 | $history->updateSettings(); | ||
1180 | $PAGE->renderPage('configure'); | 1189 | $PAGE->renderPage('configure'); |
1181 | exit; | 1190 | exit; |
1182 | } | 1191 | } |
@@ -1206,6 +1215,7 @@ function renderPage($conf, $pluginManager, $LINKSDB) | |||
1206 | unset($tags[array_search($needle,$tags)]); // Remove tag. | 1215 | unset($tags[array_search($needle,$tags)]); // Remove tag. |
1207 | $value['tags']=trim(implode(' ',$tags)); | 1216 | $value['tags']=trim(implode(' ',$tags)); |
1208 | $LINKSDB[$key]=$value; | 1217 | $LINKSDB[$key]=$value; |
1218 | $history->updateLink($LINKSDB[$key]); | ||
1209 | } | 1219 | } |
1210 | $LINKSDB->save($conf->get('resource.page_cache')); | 1220 | $LINKSDB->save($conf->get('resource.page_cache')); |
1211 | echo '<script>alert("Tag was removed from '.count($linksToAlter).' links.");document.location=\'?do=changetag\';</script>'; | 1221 | echo '<script>alert("Tag was removed from '.count($linksToAlter).' links.");document.location=\'?do=changetag\';</script>'; |
@@ -1223,6 +1233,7 @@ function renderPage($conf, $pluginManager, $LINKSDB) | |||
1223 | $tags[array_search($needle, $tags)] = trim($_POST['totag']); | 1233 | $tags[array_search($needle, $tags)] = trim($_POST['totag']); |
1224 | $value['tags'] = implode(' ', array_unique($tags)); | 1234 | $value['tags'] = implode(' ', array_unique($tags)); |
1225 | $LINKSDB[$key] = $value; | 1235 | $LINKSDB[$key] = $value; |
1236 | $history->updateLink($LINKSDB[$key]); | ||
1226 | } | 1237 | } |
1227 | $LINKSDB->save($conf->get('resource.page_cache')); // Save to disk. | 1238 | $LINKSDB->save($conf->get('resource.page_cache')); // Save to disk. |
1228 | echo '<script>alert("Tag was renamed in '.count($linksToAlter).' links.");document.location=\'?searchtags='.urlencode(escape($_POST['totag'])).'\';</script>'; | 1239 | echo '<script>alert("Tag was renamed in '.count($linksToAlter).' links.");document.location=\'?searchtags='.urlencode(escape($_POST['totag'])).'\';</script>'; |
@@ -1257,11 +1268,13 @@ function renderPage($conf, $pluginManager, $LINKSDB) | |||
1257 | $created = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $linkdate); | 1268 | $created = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $linkdate); |
1258 | $updated = new DateTime(); | 1269 | $updated = new DateTime(); |
1259 | $shortUrl = $LINKSDB[$id]['shorturl']; | 1270 | $shortUrl = $LINKSDB[$id]['shorturl']; |
1271 | $new = false; | ||
1260 | } else { | 1272 | } else { |
1261 | // New link | 1273 | // New link |
1262 | $created = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $linkdate); | 1274 | $created = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $linkdate); |
1263 | $updated = null; | 1275 | $updated = null; |
1264 | $shortUrl = link_small_hash($created, $id); | 1276 | $shortUrl = link_small_hash($created, $id); |
1277 | $new = true; | ||
1265 | } | 1278 | } |
1266 | 1279 | ||
1267 | // Remove multiple spaces. | 1280 | // Remove multiple spaces. |
@@ -1300,6 +1313,11 @@ function renderPage($conf, $pluginManager, $LINKSDB) | |||
1300 | 1313 | ||
1301 | $LINKSDB[$id] = $link; | 1314 | $LINKSDB[$id] = $link; |
1302 | $LINKSDB->save($conf->get('resource.page_cache')); | 1315 | $LINKSDB->save($conf->get('resource.page_cache')); |
1316 | if ($new) { | ||
1317 | $history->addLink($link); | ||
1318 | } else { | ||
1319 | $history->updateLink($link); | ||
1320 | } | ||
1303 | 1321 | ||
1304 | // If we are called from the bookmarklet, we must close the popup: | 1322 | // If we are called from the bookmarklet, we must close the popup: |
1305 | if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { | 1323 | if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { |
@@ -1346,6 +1364,7 @@ function renderPage($conf, $pluginManager, $LINKSDB) | |||
1346 | $pluginManager->executeHooks('delete_link', $link); | 1364 | $pluginManager->executeHooks('delete_link', $link); |
1347 | unset($LINKSDB[$id]); | 1365 | unset($LINKSDB[$id]); |
1348 | $LINKSDB->save($conf->get('resource.page_cache')); // save to disk | 1366 | $LINKSDB->save($conf->get('resource.page_cache')); // save to disk |
1367 | $history->deleteLink($link); | ||
1349 | 1368 | ||
1350 | // If we are called from the bookmarklet, we must close the popup: | 1369 | // If we are called from the bookmarklet, we must close the popup: |
1351 | if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; } | 1370 | if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; } |
@@ -1528,7 +1547,8 @@ function renderPage($conf, $pluginManager, $LINKSDB) | |||
1528 | $_POST, | 1547 | $_POST, |
1529 | $_FILES, | 1548 | $_FILES, |
1530 | $LINKSDB, | 1549 | $LINKSDB, |
1531 | $conf | 1550 | $conf, |
1551 | $history | ||
1532 | ); | 1552 | ); |
1533 | echo '<script>alert("'.$status.'");document.location=\'?do=' | 1553 | echo '<script>alert("'.$status.'");document.location=\'?do=' |
1534 | .Router::$PAGE_IMPORT .'\';</script>'; | 1554 | .Router::$PAGE_IMPORT .'\';</script>'; |
@@ -1557,6 +1577,7 @@ function renderPage($conf, $pluginManager, $LINKSDB) | |||
1557 | 1577 | ||
1558 | // Plugin administration form action | 1578 | // Plugin administration form action |
1559 | if ($targetPage == Router::$PAGE_SAVE_PLUGINSADMIN) { | 1579 | if ($targetPage == Router::$PAGE_SAVE_PLUGINSADMIN) { |
1580 | $history->updateSettings(); | ||
1560 | try { | 1581 | try { |
1561 | if (isset($_POST['parameters_form'])) { | 1582 | if (isset($_POST['parameters_form'])) { |
1562 | unset($_POST['parameters_form']); | 1583 | unset($_POST['parameters_form']); |