diff options
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 47 |
1 files changed, 5 insertions, 42 deletions
@@ -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. |
40 | if (is_file($GLOBALS['config']['DATADIR'].'/options.php')) require($GLOBALS['config']['DATADIR'].'/options.php'); | 40 | if (is_file($GLOBALS['config']['DATADIR'].'/options.php')) require($GLOBALS['config']['DATADIR'].'/options.php'); |
41 | 41 | ||
42 | define('shaarli_version','0.0.43beta'); | 42 | define('shaarli_version','0.0.44beta'); |
43 | define('PHPPREFIX','<?php /* '); // Prefix to encapsulate data in PHP code. | 43 | define('PHPPREFIX','<?php /* '); // Prefix to encapsulate data in PHP code. |
44 | define('PHPSUFFIX',' */ ?>'); // Suffix to encapsulate data in PHP code. | 44 | define('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 | ||
2313 | function 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 | |||
2603 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=atom')) { showATOM(); exit; } | 2567 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=atom')) { showATOM(); exit; } |
2604 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=dailyrss')) { showDailyRSS(); exit; } | 2568 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=dailyrss')) { showDailyRSS(); exit; } |
2605 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=daily')) { showDaily(); exit; } | 2569 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=daily')) { showDaily(); exit; } |
2606 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'ws=')) { processWS(); exit; } // Webservices (for jQuery/jQueryUI) | ||
2607 | if (!isset($_SESSION['LINKS_PER_PAGE'])) $_SESSION['LINKS_PER_PAGE']=$GLOBALS['config']['LINKS_PER_PAGE']; | 2570 | if (!isset($_SESSION['LINKS_PER_PAGE'])) $_SESSION['LINKS_PER_PAGE']=$GLOBALS['config']['LINKS_PER_PAGE']; |
2608 | renderPage(); | 2571 | renderPage(); |
2609 | ?> | 2572 | ?> |