aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php47
1 files changed, 34 insertions, 13 deletions
diff --git a/index.php b/index.php
index d88f4346..5de60425 100644
--- a/index.php
+++ b/index.php
@@ -1552,21 +1552,40 @@ function renderPage()
1552 // -------- User clicked the "Save" button when editing a link: Save link to database. 1552 // -------- User clicked the "Save" button when editing a link: Save link to database.
1553 if (isset($_POST['save_edit'])) 1553 if (isset($_POST['save_edit']))
1554 { 1554 {
1555 if (!tokenOk($_POST['token'])) die('Wrong token.'); // Go away! 1555 // Go away!
1556 $tags = trim(preg_replace('/\s\s+/',' ', $_POST['lf_tags'])); // Remove multiple spaces. 1556 if (! tokenOk($_POST['token'])) {
1557 $tags = implode(' ', array_unique(explode(' ', $tags))); // Remove duplicates. 1557 die('Wrong token.');
1558 $linkdate=$_POST['lf_linkdate']; 1558 }
1559 // Remove multiple spaces.
1560 $tags = trim(preg_replace('/\s\s+/', ' ', $_POST['lf_tags']));
1561 // Remove duplicates.
1562 $tags = implode(' ', array_unique(explode(' ', $tags)));
1563 $linkdate = $_POST['lf_linkdate'];
1559 $url = trim($_POST['lf_url']); 1564 $url = trim($_POST['lf_url']);
1560 if (!startsWith($url,'http:') && !startsWith($url,'https:') && !startsWith($url,'ftp:') && !startsWith($url,'magnet:') && !startsWith($url,'?') && !startsWith($url,'javascript:')) 1565 if (! startsWith($url, 'http:') && ! startsWith($url, 'https:')
1561 $url = 'http://'.$url; 1566 && ! startsWith($url, 'ftp:') && ! startsWith($url, 'magnet:')
1562 $link = array('title'=>trim($_POST['lf_title']),'url'=>$url,'description'=>trim($_POST['lf_description']),'private'=>(isset($_POST['lf_private']) ? 1 : 0), 1567 && ! startsWith($url, '?') && ! startsWith($url, 'javascript:')
1563 'linkdate'=>$linkdate,'tags'=>str_replace(',',' ',$tags)); 1568 ) {
1564 if ($link['title']=='') $link['title']=$link['url']; // If title is empty, use the URL as title. 1569 $url = 'http://' . $url;
1570 }
1571
1572 $link = array(
1573 'title' => trim($_POST['lf_title']),
1574 'url' => $url,
1575 'description' => trim($_POST['lf_description']),
1576 'private' => (isset($_POST['lf_private']) ? 1 : 0),
1577 'linkdate' => $linkdate,
1578 'tags' => str_replace(',', ' ', $tags)
1579 );
1580 // If title is empty, use the URL as title.
1581 if ($link['title'] == '') {
1582 $link['title'] = $link['url'];
1583 }
1565 1584
1566 $pluginManager->executeHooks('save_link', $link); 1585 $pluginManager->executeHooks('save_link', $link);
1567 1586
1568 $LINKSDB[$linkdate] = $link; 1587 $LINKSDB[$linkdate] = $link;
1569 $LINKSDB->savedb($GLOBALS['config']['PAGECACHE']); // Save to disk. 1588 $LINKSDB->savedb($GLOBALS['config']['PAGECACHE']);
1570 pubsubhub(); 1589 pubsubhub();
1571 1590
1572 // If we are called from the bookmarklet, we must close the popup: 1591 // If we are called from the bookmarklet, we must close the popup:
@@ -1575,10 +1594,12 @@ function renderPage()
1575 exit; 1594 exit;
1576 } 1595 }
1577 1596
1578 $returnurl = !empty($_POST['returnurl']) ? escape($_POST['returnurl']): '?'; 1597 $returnurl = !empty($_POST['returnurl']) ? $_POST['returnurl'] : '?';
1579 $location = generateLocation($returnurl, $_SERVER['HTTP_HOST'], array('addlink', 'post', 'edit_link')); 1598 $location = generateLocation($returnurl, $_SERVER['HTTP_HOST'], array('addlink', 'post', 'edit_link'));
1580 $location .= '#'.smallHash($_POST['lf_linkdate']); // Scroll to the link which has been edited. 1599 // Scroll to the link which has been edited.
1581 header('Location: '. $location); // After saving the link, redirect to the page the user was on. 1600 $location .= '#' . smallHash($_POST['lf_linkdate']);
1601 // After saving the link, redirect to the page the user was on.
1602 header('Location: '. $location);
1582 exit; 1603 exit;
1583 } 1604 }
1584 1605