diff options
author | Seb Sauvage <sebsauvage@sebsauvage.net> | 2011-09-27 13:35:00 +0200 |
---|---|---|
committer | Emilien Klein <emilien@klein.st> | 2011-09-27 13:35:00 +0200 |
commit | 8e92abac218a7419b4a4f0826b32daba46cfa926 (patch) | |
tree | f4955d83cd60779a85d64ea1d2dcaf94a5109b1b | |
parent | ba0718dcd43ecb44e80d65307ed4d2dfda24c0b9 (diff) | |
download | Shaarli-8e92abac218a7419b4a4f0826b32daba46cfa926.tar.gz Shaarli-8e92abac218a7419b4a4f0826b32daba46cfa926.tar.zst Shaarli-8e92abac218a7419b4a4f0826b32daba46cfa926.zip |
Version 0.0.19 beta:
- Corrected: Patch by Emilien to remove the update notification after the update.
- New: ATOM fee
-rw-r--r-- | index.php | 58 |
1 files changed, 53 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | <?php | 1 | <?php |
2 | // Shaarli 0.0.18 beta - Shaare your links... | 2 | // Shaarli 0.0.19 beta - 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 |
@@ -47,7 +47,7 @@ header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); | |||
47 | header("Cache-Control: no-store, no-cache, must-revalidate"); | 47 | header("Cache-Control: no-store, no-cache, must-revalidate"); |
48 | header("Cache-Control: post-check=0, pre-check=0", false); | 48 | header("Cache-Control: post-check=0, pre-check=0", false); |
49 | header("Pragma: no-cache"); | 49 | header("Pragma: no-cache"); |
50 | define('shaarli_version','0.0.18 beta'); | 50 | define('shaarli_version','0.0.19 beta'); |
51 | if (!is_dir(DATADIR)) { mkdir(DATADIR,0705); chmod(DATADIR,0705); } | 51 | if (!is_dir(DATADIR)) { mkdir(DATADIR,0705); chmod(DATADIR,0705); } |
52 | if (!is_file(DATADIR.'/.htaccess')) { file_put_contents(DATADIR.'/.htaccess',"Allow from none\nDeny from all\n"); } // Protect data files. | 52 | if (!is_file(DATADIR.'/.htaccess')) { file_put_contents(DATADIR.'/.htaccess',"Allow from none\nDeny from all\n"); } // Protect data files. |
53 | if (!is_file(CONFIG_FILE)) install(); | 53 | if (!is_file(CONFIG_FILE)) install(); |
@@ -89,7 +89,7 @@ function checkUpdate() | |||
89 | } | 89 | } |
90 | // Compare versions: | 90 | // Compare versions: |
91 | $newestversion=file_get_contents(UPDATECHECK_FILENAME); | 91 | $newestversion=file_get_contents(UPDATECHECK_FILENAME); |
92 | if ($newestversion!=shaarli_version) return $newestversion; | 92 | if (version_compare($newestversion,shaarli_version)==1) return $newestversion; |
93 | return ''; | 93 | return ''; |
94 | } | 94 | } |
95 | 95 | ||
@@ -310,6 +310,13 @@ function linkdate2rfc822($linkdate) | |||
310 | return date('r',linkdate2timestamp($linkdate)); // 'r' is for RFC822 date format. | 310 | return date('r',linkdate2timestamp($linkdate)); // 'r' is for RFC822 date format. |
311 | } | 311 | } |
312 | 312 | ||
313 | /* Converts a linkdate time (YYYYMMDD_HHMMSS) of an article to a ISO 8601 date. | ||
314 | (used to build the updated tags in ATOM feed.) */ | ||
315 | function linkdate2iso8601($linkdate) | ||
316 | { | ||
317 | return date('c',linkdate2timestamp($linkdate)); // 'c' is for ISO 8601 date format. | ||
318 | } | ||
319 | |||
313 | /* Converts a linkdate time (YYYYMMDD_HHMMSS) of an article to a localized date format. | 320 | /* Converts a linkdate time (YYYYMMDD_HHMMSS) of an article to a localized date format. |
314 | (used to display link date on screen) | 321 | (used to display link date on screen) |
315 | The date format is automatically chosen according to locale/languages sniffed from browser headers (see autoLocale()). */ | 322 | The date format is automatically chosen according to locale/languages sniffed from browser headers (see autoLocale()). */ |
@@ -588,6 +595,46 @@ function showRSS() | |||
588 | } | 595 | } |
589 | 596 | ||
590 | // ------------------------------------------------------------------------------------------ | 597 | // ------------------------------------------------------------------------------------------ |
598 | // Ouput the last 50 links in ATOM format. | ||
599 | function showATOM() | ||
600 | { | ||
601 | global $LINKSDB; | ||
602 | |||
603 | // Optionnaly filter the results: | ||
604 | $linksToDisplay=array(); | ||
605 | if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']); | ||
606 | elseif (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); | ||
607 | else $linksToDisplay = $LINKSDB; | ||
608 | |||
609 | header('Content-Type: application/xhtml+xml; charset=utf-8'); | ||
610 | $pageaddr=htmlspecialchars(serverUrl().$_SERVER["SCRIPT_NAME"]); | ||
611 | $latestDate = ''; | ||
612 | $entries=''; | ||
613 | $i=0; | ||
614 | $keys=array(); foreach($linksToDisplay as $key=>$value) { $keys[]=$key; } // No, I can't use array_keys(). | ||
615 | while ($i<50 && $i<count($keys)) | ||
616 | { | ||
617 | $link = $linksToDisplay[$keys[$i]]; | ||
618 | $iso8601date = linkdate2iso8601($link['linkdate']); | ||
619 | $latestDate = max($latestDate,$iso8601date); | ||
620 | $entries.='<entry><title>'.htmlspecialchars($link['title']).'</title><link href="'.htmlspecialchars($link['url']).'"/><id>'.htmlspecialchars($link['url']).'</id>'; | ||
621 | if (!HIDE_TIMESTAMPS || isLoggedIn()) $entries.='<updated>'.htmlspecialchars($iso8601date).'</updated>'; | ||
622 | $entries.='<summary>'.nl2br(htmlspecialchars($link['description'])).'</summary></entry>'."\n"; | ||
623 | $i++; | ||
624 | } | ||
625 | $feed='<?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom">'; | ||
626 | $feed.='<title>'.htmlspecialchars($GLOBALS['title']).'</title>'; | ||
627 | if (!HIDE_TIMESTAMPS || isLoggedIn()) $feed.='<updated>'.htmlspecialchars($latestDate).'</updated>'; | ||
628 | $feed.='<link href="'.htmlspecialchars($pageaddr).'" />'; | ||
629 | $feed.='<author><uri>'.htmlspecialchars($pageaddr).'</uri></author>'; | ||
630 | $feed.='<id>'.htmlspecialchars($pageaddr).'</id>'."\n\n"; // Yes, I know I should use a real IRI (RFC3987), but the site URL will do. | ||
631 | $feed.=$entries; | ||
632 | $feed.='</feed>'; | ||
633 | echo $feed; | ||
634 | exit; | ||
635 | } | ||
636 | |||
637 | // ------------------------------------------------------------------------------------------ | ||
591 | // Render HTML page: | 638 | // Render HTML page: |
592 | function renderPage() | 639 | function renderPage() |
593 | { | 640 | { |
@@ -1284,7 +1331,7 @@ $(document).ready(function() | |||
1284 | </script> | 1331 | </script> |
1285 | JS; | 1332 | JS; |
1286 | } | 1333 | } |
1287 | $feedurl=htmlspecialchars(serverUrl().$_SERVER['SCRIPT_NAME'].'?do=rss'); | 1334 | $feedurl=htmlspecialchars(serverUrl().$_SERVER['SCRIPT_NAME']); |
1288 | if (!empty($_GET['searchtags'])) $feedurl.='&searchtags='.$_GET['searchtags']; | 1335 | if (!empty($_GET['searchtags'])) $feedurl.='&searchtags='.$_GET['searchtags']; |
1289 | elseif (!empty($_GET['searchterm'])) $feedurl.='&searchterm='.$_GET['searchterm']; | 1336 | elseif (!empty($_GET['searchterm'])) $feedurl.='&searchterm='.$_GET['searchterm']; |
1290 | 1337 | ||
@@ -1299,7 +1346,7 @@ JS; | |||
1299 | </head> | 1346 | </head> |
1300 | <body {$data['onload']}>{$newversion} | 1347 | <body {$data['onload']}>{$newversion} |
1301 | <div id="pageheader"><div style="float:right; font-style:italic; color:#bbb; text-align:right; padding:0 5 0 0;">Shaare your links...<br>{$linkcount} links</div> | 1348 | <div id="pageheader"><div style="float:right; font-style:italic; color:#bbb; text-align:right; padding:0 5 0 0;">Shaare your links...<br>{$linkcount} links</div> |
1302 | <b><i>{$title}</i></b> - <a href="?">Home</a> {$menu} <a href="{$feedurl}" style="padding-left:30px;">RSS Feed</a> | 1349 | <b><i>{$title}</i></b> - <a href="?">Home</a> {$menu} <a href="{$feedurl}?do=rss" style="padding-left:30px;">RSS Feed</a> <a href="{$feedurl}?do=atom" style="padding-left:10px;">ATOM Feed</a> |
1303 | <a href="?do=tagcloud">Tag cloud</a> | 1350 | <a href="?do=tagcloud">Tag cloud</a> |
1304 | {$data['pageheader']} | 1351 | {$data['pageheader']} |
1305 | </div> | 1352 | </div> |
@@ -1486,5 +1533,6 @@ $LINKSDB=new linkdb(isLoggedIn() || OPEN_SHAARLI); // Read links from database | |||
1486 | if (startswith($_SERVER["QUERY_STRING"],'ws=')) { processWS(); exit; } // Webservices (for jQuery/jQueryUI) | 1533 | if (startswith($_SERVER["QUERY_STRING"],'ws=')) { processWS(); exit; } // Webservices (for jQuery/jQueryUI) |
1487 | if (!isset($_SESSION['LINKS_PER_PAGE'])) $_SESSION['LINKS_PER_PAGE']=LINKS_PER_PAGE; | 1534 | if (!isset($_SESSION['LINKS_PER_PAGE'])) $_SESSION['LINKS_PER_PAGE']=LINKS_PER_PAGE; |
1488 | if (startswith($_SERVER["QUERY_STRING"],'do=rss')) { showRSS(); exit; } | 1535 | if (startswith($_SERVER["QUERY_STRING"],'do=rss')) { showRSS(); exit; } |
1536 | if (startswith($_SERVER["QUERY_STRING"],'do=atom')) { showATOM(); exit; } | ||
1489 | renderPage(); | 1537 | renderPage(); |
1490 | ?> \ No newline at end of file | 1538 | ?> \ No newline at end of file |