aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php23
1 files changed, 22 insertions, 1 deletions
diff --git a/index.php b/index.php
index e392e501..76aa1ae0 100644
--- a/index.php
+++ b/index.php
@@ -62,6 +62,7 @@ require_once 'application/CachedPage.php';
62require_once 'application/config/ConfigPlugin.php'; 62require_once 'application/config/ConfigPlugin.php';
63require_once 'application/FeedBuilder.php'; 63require_once 'application/FeedBuilder.php';
64require_once 'application/FileUtils.php'; 64require_once 'application/FileUtils.php';
65require_once 'application/History.php';
65require_once 'application/HttpUtils.php'; 66require_once 'application/HttpUtils.php';
66require_once 'application/Languages.php'; 67require_once 'application/Languages.php';
67require_once 'application/LinkDB.php'; 68require_once 'application/LinkDB.php';
@@ -727,6 +728,12 @@ function renderPage($conf, $pluginManager, $LINKSDB)
727 die($e->getMessage()); 728 die($e->getMessage());
728 } 729 }
729 730
731 try {
732 $history = new History($conf->get('resource.history'));
733 } catch(Exception $e) {
734 die($e->getMessage());
735 }
736
730 $PAGE = new PageBuilder($conf); 737 $PAGE = new PageBuilder($conf);
731 $PAGE->assign('linkcount', count($LINKSDB)); 738 $PAGE->assign('linkcount', count($LINKSDB));
732 $PAGE->assign('privateLinkcount', count_private($LINKSDB)); 739 $PAGE->assign('privateLinkcount', count_private($LINKSDB));
@@ -1125,6 +1132,7 @@ function renderPage($conf, $pluginManager, $LINKSDB)
1125 $conf->set('api.secret', escape($_POST['apiSecret'])); 1132 $conf->set('api.secret', escape($_POST['apiSecret']));
1126 try { 1133 try {
1127 $conf->write(isLoggedIn()); 1134 $conf->write(isLoggedIn());
1135 $history->updateSettings();
1128 invalidateCaches($conf->get('resource.page_cache')); 1136 invalidateCaches($conf->get('resource.page_cache'));
1129 } 1137 }
1130 catch(Exception $e) { 1138 catch(Exception $e) {
@@ -1159,6 +1167,7 @@ function renderPage($conf, $pluginManager, $LINKSDB)
1159 $PAGE->assign('hide_public_links', $conf->get('privacy.hide_public_links', false)); 1167 $PAGE->assign('hide_public_links', $conf->get('privacy.hide_public_links', false));
1160 $PAGE->assign('api_enabled', $conf->get('api.enabled', true)); 1168 $PAGE->assign('api_enabled', $conf->get('api.enabled', true));
1161 $PAGE->assign('api_secret', $conf->get('api.secret')); 1169 $PAGE->assign('api_secret', $conf->get('api.secret'));
1170 $history->updateSettings();
1162 $PAGE->renderPage('configure'); 1171 $PAGE->renderPage('configure');
1163 exit; 1172 exit;
1164 } 1173 }
@@ -1188,6 +1197,7 @@ function renderPage($conf, $pluginManager, $LINKSDB)
1188 unset($tags[array_search($needle,$tags)]); // Remove tag. 1197 unset($tags[array_search($needle,$tags)]); // Remove tag.
1189 $value['tags']=trim(implode(' ',$tags)); 1198 $value['tags']=trim(implode(' ',$tags));
1190 $LINKSDB[$key]=$value; 1199 $LINKSDB[$key]=$value;
1200 $history->updateLink($LINKSDB[$key]);
1191 } 1201 }
1192 $LINKSDB->save($conf->get('resource.page_cache')); 1202 $LINKSDB->save($conf->get('resource.page_cache'));
1193 echo '<script>alert("Tag was removed from '.count($linksToAlter).' links.");document.location=\'?do=changetag\';</script>'; 1203 echo '<script>alert("Tag was removed from '.count($linksToAlter).' links.");document.location=\'?do=changetag\';</script>';
@@ -1205,6 +1215,7 @@ function renderPage($conf, $pluginManager, $LINKSDB)
1205 $tags[array_search($needle, $tags)] = trim($_POST['totag']); 1215 $tags[array_search($needle, $tags)] = trim($_POST['totag']);
1206 $value['tags'] = implode(' ', array_unique($tags)); 1216 $value['tags'] = implode(' ', array_unique($tags));
1207 $LINKSDB[$key] = $value; 1217 $LINKSDB[$key] = $value;
1218 $history->updateLink($LINKSDB[$key]);
1208 } 1219 }
1209 $LINKSDB->save($conf->get('resource.page_cache')); // Save to disk. 1220 $LINKSDB->save($conf->get('resource.page_cache')); // Save to disk.
1210 echo '<script>alert("Tag was renamed in '.count($linksToAlter).' links.");document.location=\'?searchtags='.urlencode(escape($_POST['totag'])).'\';</script>'; 1221 echo '<script>alert("Tag was renamed in '.count($linksToAlter).' links.");document.location=\'?searchtags='.urlencode(escape($_POST['totag'])).'\';</script>';
@@ -1239,11 +1250,13 @@ function renderPage($conf, $pluginManager, $LINKSDB)
1239 $created = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $linkdate); 1250 $created = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $linkdate);
1240 $updated = new DateTime(); 1251 $updated = new DateTime();
1241 $shortUrl = $LINKSDB[$id]['shorturl']; 1252 $shortUrl = $LINKSDB[$id]['shorturl'];
1253 $new = false;
1242 } else { 1254 } else {
1243 // New link 1255 // New link
1244 $created = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $linkdate); 1256 $created = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $linkdate);
1245 $updated = null; 1257 $updated = null;
1246 $shortUrl = link_small_hash($created, $id); 1258 $shortUrl = link_small_hash($created, $id);
1259 $new = true;
1247 } 1260 }
1248 1261
1249 // Remove multiple spaces. 1262 // Remove multiple spaces.
@@ -1282,6 +1295,11 @@ function renderPage($conf, $pluginManager, $LINKSDB)
1282 1295
1283 $LINKSDB[$id] = $link; 1296 $LINKSDB[$id] = $link;
1284 $LINKSDB->save($conf->get('resource.page_cache')); 1297 $LINKSDB->save($conf->get('resource.page_cache'));
1298 if ($new) {
1299 $history->addLink($link);
1300 } else {
1301 $history->updateLink($link);
1302 }
1285 1303
1286 // If we are called from the bookmarklet, we must close the popup: 1304 // If we are called from the bookmarklet, we must close the popup:
1287 if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { 1305 if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) {
@@ -1332,6 +1350,7 @@ function renderPage($conf, $pluginManager, $LINKSDB)
1332 $pluginManager->executeHooks('delete_link', $link); 1350 $pluginManager->executeHooks('delete_link', $link);
1333 unset($LINKSDB[$id]); 1351 unset($LINKSDB[$id]);
1334 $LINKSDB->save($conf->get('resource.page_cache')); // save to disk 1352 $LINKSDB->save($conf->get('resource.page_cache')); // save to disk
1353 $history->deleteLink($link);
1335 1354
1336 // If we are called from the bookmarklet, we must close the popup: 1355 // If we are called from the bookmarklet, we must close the popup:
1337 if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; } 1356 if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; }
@@ -1529,7 +1548,8 @@ function renderPage($conf, $pluginManager, $LINKSDB)
1529 $_POST, 1548 $_POST,
1530 $_FILES, 1549 $_FILES,
1531 $LINKSDB, 1550 $LINKSDB,
1532 $conf 1551 $conf,
1552 $history
1533 ); 1553 );
1534 echo '<script>alert("'.$status.'");document.location=\'?do=' 1554 echo '<script>alert("'.$status.'");document.location=\'?do='
1535 .Router::$PAGE_IMPORT .'\';</script>'; 1555 .Router::$PAGE_IMPORT .'\';</script>';
@@ -1558,6 +1578,7 @@ function renderPage($conf, $pluginManager, $LINKSDB)
1558 1578
1559 // Plugin administration form action 1579 // Plugin administration form action
1560 if ($targetPage == Router::$PAGE_SAVE_PLUGINSADMIN) { 1580 if ($targetPage == Router::$PAGE_SAVE_PLUGINSADMIN) {
1581 $history->updateSettings();
1561 try { 1582 try {
1562 if (isset($_POST['parameters_form'])) { 1583 if (isset($_POST['parameters_form'])) {
1563 unset($_POST['parameters_form']); 1584 unset($_POST['parameters_form']);