aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php47
1 files changed, 5 insertions, 42 deletions
diff --git a/index.php b/index.php
index 6189e0b8..1ab34193 100644
--- a/index.php
+++ b/index.php
@@ -1,5 +1,5 @@
1<?php 1<?php
2// Shaarli 0.0.43beta - Shaare your links... 2// Shaarli 0.0.44beta - Shaare your links...
3// The personal, minimalist, super-fast, no-database Delicious clone. By sebsauvage.net 3// The personal, minimalist, super-fast, no-database Delicious clone. By sebsauvage.net
4// http://sebsauvage.net/wiki/doku.php?id=php:shaarli 4// http://sebsauvage.net/wiki/doku.php?id=php:shaarli
5// Licence: http://www.opensource.org/licenses/zlib-license.php 5// Licence: http://www.opensource.org/licenses/zlib-license.php
@@ -39,7 +39,7 @@ $GLOBALS['config']['ENABLE_RSS_PERMALINKS'] = true; // Enable RSS permalinks by
39// Optional config file. 39// Optional config file.
40if (is_file($GLOBALS['config']['DATADIR'].'/options.php')) require($GLOBALS['config']['DATADIR'].'/options.php'); 40if (is_file($GLOBALS['config']['DATADIR'].'/options.php')) require($GLOBALS['config']['DATADIR'].'/options.php');
41 41
42define('shaarli_version','0.0.43beta'); 42define('shaarli_version','0.0.44beta');
43define('PHPPREFIX','<?php /* '); // Prefix to encapsulate data in PHP code. 43define('PHPPREFIX','<?php /* '); // Prefix to encapsulate data in PHP code.
44define('PHPSUFFIX',' */ ?>'); // Suffix to encapsulate data in PHP code. 44define('PHPSUFFIX',' */ ?>'); // Suffix to encapsulate data in PHP code.
45// http://server.com/x/shaarli --> /shaarli/ 45// http://server.com/x/shaarli --> /shaarli/
@@ -1490,6 +1490,7 @@ function renderPage()
1490 $PAGE = new pageBuilder; 1490 $PAGE = new pageBuilder;
1491 $PAGE->assign('linkcount',count($LINKSDB)); 1491 $PAGE->assign('linkcount',count($LINKSDB));
1492 $PAGE->assign('token',getToken()); 1492 $PAGE->assign('token',getToken());
1493 $PAGE->assign('tags', $LINKSDB->allTags());
1493 $PAGE->renderPage('changetag'); 1494 $PAGE->renderPage('changetag');
1494 exit; 1495 exit;
1495 } 1496 }
@@ -1633,6 +1634,7 @@ function renderPage()
1633 $PAGE->assign('link_is_new',false); 1634 $PAGE->assign('link_is_new',false);
1634 $PAGE->assign('token',getToken()); // XSRF protection. 1635 $PAGE->assign('token',getToken()); // XSRF protection.
1635 $PAGE->assign('http_referer',(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')); 1636 $PAGE->assign('http_referer',(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''));
1637 $PAGE->assign('tags', $LINKSDB->allTags());
1636 $PAGE->renderPage('editlink'); 1638 $PAGE->renderPage('editlink');
1637 exit; 1639 exit;
1638 } 1640 }
@@ -1704,6 +1706,7 @@ function renderPage()
1704 $PAGE->assign('link_is_new',$link_is_new); 1706 $PAGE->assign('link_is_new',$link_is_new);
1705 $PAGE->assign('token',getToken()); // XSRF protection. 1707 $PAGE->assign('token',getToken()); // XSRF protection.
1706 $PAGE->assign('http_referer',(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')); 1708 $PAGE->assign('http_referer',(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''));
1709 $PAGE->assign('tags', $LINKSDB->allTags());
1707 $PAGE->renderPage('editlink'); 1710 $PAGE->renderPage('editlink');
1708 exit; 1711 exit;
1709 } 1712 }
@@ -2308,45 +2311,6 @@ if (!function_exists('json_encode')) {
2308 } 2311 }
2309} 2312}
2310 2313
2311// Webservices (for use with jQuery/jQueryUI)
2312// e.g. index.php?ws=tags&term=minecr
2313function processWS()
2314{
2315 if (empty($_GET['ws']) || empty($_GET['term'])) return;
2316 $term = $_GET['term'];
2317 $LINKSDB=new linkdb(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); // Read links from database (and filter private links if used it not logged in).
2318 header('Content-Type: application/json; charset=utf-8');
2319
2320 // Search in tags (case insensitive, cumulative search)
2321 if ($_GET['ws']=='tags')
2322 {
2323 $tags=explode(' ',str_replace(',',' ',$term)); $last = array_pop($tags); // Get the last term ("a b c d" ==> "a b c", "d")
2324 $addtags=''; if ($tags) $addtags=implode(' ',$tags).' '; // We will pre-pend previous tags
2325 $suggested=array();
2326 /* To speed up things, we store list of tags in session */
2327 if (empty($_SESSION['tags'])) $_SESSION['tags'] = $LINKSDB->allTags();
2328 foreach($_SESSION['tags'] as $key=>$value)
2329 {
2330 if (startsWith($key,$last,$case=false) && !in_array($key,$tags)) $suggested[$addtags.$key.' ']=0;
2331 }
2332 echo json_encode(array_keys($suggested));
2333 exit;
2334 }
2335
2336 // Search a single tag (case sensitive, single tag search)
2337 if ($_GET['ws']=='singletag')
2338 {
2339 /* To speed up things, we store list of tags in session */
2340 if (empty($_SESSION['tags'])) $_SESSION['tags'] = $LINKSDB->allTags();
2341 foreach($_SESSION['tags'] as $key=>$value)
2342 {
2343 if (startsWith($key,$term,$case=true)) $suggested[$key]=0;
2344 }
2345 echo json_encode(array_keys($suggested));
2346 exit;
2347 }
2348}
2349
2350// Re-write configuration file according to globals. 2314// Re-write configuration file according to globals.
2351// Requires some $GLOBALS to be set (login,hash,salt,title). 2315// Requires some $GLOBALS to be set (login,hash,salt,title).
2352// If the config file cannot be saved, an error message is displayed and the user is redirected to "Tools" menu. 2316// If the config file cannot be saved, an error message is displayed and the user is redirected to "Tools" menu.
@@ -2603,7 +2567,6 @@ if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=r
2603if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=atom')) { showATOM(); exit; } 2567if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=atom')) { showATOM(); exit; }
2604if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=dailyrss')) { showDailyRSS(); exit; } 2568if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=dailyrss')) { showDailyRSS(); exit; }
2605if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=daily')) { showDaily(); exit; } 2569if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=daily')) { showDaily(); exit; }
2606if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'ws=')) { processWS(); exit; } // Webservices (for jQuery/jQueryUI)
2607if (!isset($_SESSION['LINKS_PER_PAGE'])) $_SESSION['LINKS_PER_PAGE']=$GLOBALS['config']['LINKS_PER_PAGE']; 2570if (!isset($_SESSION['LINKS_PER_PAGE'])) $_SESSION['LINKS_PER_PAGE']=$GLOBALS['config']['LINKS_PER_PAGE'];
2608renderPage(); 2571renderPage();
2609?> 2572?>