aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
authorSeb Sauvage <sebsauvage@sebsauvage.net>2011-10-18 09:51:02 +0200
committerEmilien Klein <emilien@klein.st>2011-10-18 09:51:02 +0200
commit2732de7c9ef82cee6b8eb8116e376c4be06425c3 (patch)
treedfcd29611ebe48c74b91d57b6f13183af7646ca7 /index.php
parent03cd3750fd26d2667ccdadb55fd4807be34e1d1c (diff)
downloadShaarli-2732de7c9ef82cee6b8eb8116e376c4be06425c3.tar.gz
Shaarli-2732de7c9ef82cee6b8eb8116e376c4be06425c3.tar.zst
Shaarli-2732de7c9ef82cee6b8eb8116e376c4be06425c3.zip
Version 0.0.27 beta:
- Added: Picture wall (which can be filtered too: It will use the same filters (tags,text search) as current page when clicked.)
Diffstat (limited to 'index.php')
-rw-r--r--index.php66
1 files changed, 46 insertions, 20 deletions
diff --git a/index.php b/index.php
index f182ad29..801108b8 100644
--- a/index.php
+++ b/index.php
@@ -1,5 +1,5 @@
1<?php 1<?php
2// Shaarli 0.0.26 beta - Shaare your links... 2// Shaarli 0.0.27 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
@@ -53,7 +53,7 @@ header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
53header("Cache-Control: no-store, no-cache, must-revalidate"); 53header("Cache-Control: no-store, no-cache, must-revalidate");
54header("Cache-Control: post-check=0, pre-check=0", false); 54header("Cache-Control: post-check=0, pre-check=0", false);
55header("Pragma: no-cache"); 55header("Pragma: no-cache");
56define('shaarli_version','0.0.26 beta'); 56define('shaarli_version','0.0.27 beta');
57if (!is_dir($GLOBALS['config']['DATADIR'])) { mkdir($GLOBALS['config']['DATADIR'],0705); chmod($GLOBALS['config']['DATADIR'],0705); } 57if (!is_dir($GLOBALS['config']['DATADIR'])) { mkdir($GLOBALS['config']['DATADIR'],0705); chmod($GLOBALS['config']['DATADIR'],0705); }
58if (!is_file($GLOBALS['config']['DATADIR'].'/.htaccess')) { file_put_contents($GLOBALS['config']['DATADIR'].'/.htaccess',"Allow from none\nDeny from all\n"); } // Protect data files. 58if (!is_file($GLOBALS['config']['DATADIR'].'/.htaccess')) { file_put_contents($GLOBALS['config']['DATADIR'].'/.htaccess',"Allow from none\nDeny from all\n"); } // Protect data files.
59if ($GLOBALS['config']['ENABLE_LOCALCACHE']) 59if ($GLOBALS['config']['ENABLE_LOCALCACHE'])
@@ -738,6 +738,32 @@ function renderPage()
738 exit; 738 exit;
739 } 739 }
740 740
741 // -------- Picture wall
742 if (startswith($_SERVER["QUERY_STRING"],'do=picwall'))
743 {
744 // Optionnaly filter the results:
745 $linksToDisplay=array();
746 if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']);
747 elseif (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags']));
748 else $linksToDisplay = $LINKSDB;
749 $body='';
750 foreach($linksToDisplay as $link)
751 {
752 $thumb=thumbnail($link['url']);
753 if ($thumb!='')
754 {
755 $url=htmlspecialchars($link['url'],ENT_QUOTES);
756 $body.='<div class="picwall_pictureframe">'.$thumb.'<a href="'.$url.'"><span class="info">'.htmlspecialchars($link['title']).'</span></a></div>';
757
758 }
759 }
760 $body = '<center><div id="picwall_container">'.$body.'<hr style="width:0;height:0;clear:both;"></div></center>';
761 $data = array('pageheader'=>'<br>&nbsp;','body'=>$body,'onload'=>'');
762 templatePage($data);
763 exit;
764
765 }
766
741 // -------- Tag cloud 767 // -------- Tag cloud
742 if (startswith($_SERVER["QUERY_STRING"],'do=tagcloud')) 768 if (startswith($_SERVER["QUERY_STRING"],'do=tagcloud'))
743 { 769 {
@@ -1344,7 +1370,7 @@ function templateLinkList()
1344 foreach(explode(' ',$link['tags']) as $tag) { $tags.='<span class="linktag" title="Add tag"><a href="?addtag='.htmlspecialchars($tag).'">'.htmlspecialchars($tag).'</a></span> '; } 1370 foreach(explode(' ',$link['tags']) as $tag) { $tags.='<span class="linktag" title="Add tag"><a href="?addtag='.htmlspecialchars($tag).'">'.htmlspecialchars($tag).'</a></span> '; }
1345 $tags='<div class="linktaglist">'.$tags.'</div>'; 1371 $tags='<div class="linktaglist">'.$tags.'</div>';
1346 } 1372 }
1347 $linklist.='<li '.$classprivate.'>'.thumbnail($link['url']); 1373 $linklist.='<li '.$classprivate.'><div class="thumbnail">'.thumbnail($link['url']).'</div>';
1348 $linklist.='<div class="linkcontainer"><span class="linktitle"><a href="'.$redir.htmlspecialchars($link['url']).'">'.htmlspecialchars($title).'</a></span>'.$actions.'<br>'; 1374 $linklist.='<div class="linkcontainer"><span class="linktitle"><a href="'.$redir.htmlspecialchars($link['url']).'">'.htmlspecialchars($title).'</a></span>'.$actions.'<br>';
1349 if ($description!='') $linklist.='<div class="linkdescription">'.nl2br($description).'</div><br>'; 1375 if ($description!='') $linklist.='<div class="linkdescription">'.nl2br($description).'</div><br>';
1350 if (!$GLOBALS['config']['HIDE_TIMESTAMPS'] || isLoggedIn()) $linklist.='<span class="linkdate" title="Permalink"><a href="?'.smallHash($link['linkdate']).'">'.htmlspecialchars(linkdate2locale($link['linkdate'])).' - permalink</a> - </span>'; 1376 if (!$GLOBALS['config']['HIDE_TIMESTAMPS'] || isLoggedIn()) $linklist.='<span class="linkdate" title="Permalink"><a href="?'.smallHash($link['linkdate']).'">'.htmlspecialchars(linkdate2locale($link['linkdate'])).' - permalink</a> - </span>';
@@ -1383,26 +1409,26 @@ function thumbnail($url)
1383 if ($domain=='youtube.com' || $domain=='www.youtube.com') 1409 if ($domain=='youtube.com' || $domain=='www.youtube.com')
1384 { 1410 {
1385 parse_str(parse_url($url,PHP_URL_QUERY), $params); // Extract video ID and get thumbnail 1411 parse_str(parse_url($url,PHP_URL_QUERY), $params); // Extract video ID and get thumbnail
1386 if (!empty($params['v'])) return '<div class="thumbnail"><a href="'.htmlspecialchars($url).'"><img src="http://img.youtube.com/vi/'.htmlspecialchars($params['v']).'/default.jpg" width="120" height="90"></a></div>'; 1412 if (!empty($params['v'])) return '<a href="'.htmlspecialchars($url).'"><img src="http://img.youtube.com/vi/'.htmlspecialchars($params['v']).'/default.jpg" width="120" height="90"></a>';
1387 } 1413 }
1388 if ($domain=='imgur.com') 1414 if ($domain=='imgur.com')
1389 { 1415 {
1390 $path = parse_url($url,PHP_URL_PATH); 1416 $path = parse_url($url,PHP_URL_PATH);
1391 if (strpos($path,'/r/')==0) return '<div class="thumbnail"><a href="'.htmlspecialchars($url).'"><img src="http://i.imgur.com/'.htmlspecialchars(basename($path)).'s.jpg" width="90" height="90"></a></div>'; 1417 if (strpos($path,'/r/')==0) return '<a href="'.htmlspecialchars($url).'"><img src="http://i.imgur.com/'.htmlspecialchars(basename($path)).'s.jpg" width="90" height="90"></a>';
1392 if (strpos($path,'/gallery/')==0) return '<div class="thumbnail"><a href="'.htmlspecialchars($url).'"><img src="http://i.imgur.com'.htmlspecialchars(substr($path,8)).'s.jpg" width="90" height="90"></a></div>'; 1418 if (strpos($path,'/gallery/')==0) return '<a href="'.htmlspecialchars($url).'"><img src="http://i.imgur.com'.htmlspecialchars(substr($path,8)).'s.jpg" width="90" height="90"></a>';
1393 if (substr_count($path,'/')==1) return '<div class="thumbnail"><a href="'.htmlspecialchars($url).'"><img src="http://i.imgur.com/'.htmlspecialchars(substr($path,1)).'s.jpg" width="90" height="90"></a></div>'; 1419 if (substr_count($path,'/')==1) return '<a href="'.htmlspecialchars($url).'"><img src="http://i.imgur.com/'.htmlspecialchars(substr($path,1)).'s.jpg" width="90" height="90"></a>';
1394 } 1420 }
1395 if ($domain=='i.imgur.com') 1421 if ($domain=='i.imgur.com')
1396 { 1422 {
1397 $pi = pathinfo(parse_url($url,PHP_URL_PATH)); 1423 $pi = pathinfo(parse_url($url,PHP_URL_PATH));
1398 if (!empty($pi['filename'])) return '<div class="thumbnail"><a href="'.htmlspecialchars($url).'"><img src="http://i.imgur.com/'.htmlspecialchars($pi['filename']).'s.jpg" width="90" height="90"></a></div>'; 1424 if (!empty($pi['filename'])) return '<a href="'.htmlspecialchars($url).'"><img src="http://i.imgur.com/'.htmlspecialchars($pi['filename']).'s.jpg" width="90" height="90"></a>';
1399 } 1425 }
1400 if ($domain=='dailymotion.com' || $domain=='www.dailymotion.com') 1426 if ($domain=='dailymotion.com' || $domain=='www.dailymotion.com')
1401 { 1427 {
1402 if (strpos($url,'dailymotion.com/video/')) 1428 if (strpos($url,'dailymotion.com/video/'))
1403 { 1429 {
1404 $thumburl=str_replace('dailymotion.com/video/','dailymotion.com/thumbnail/video/',$url); 1430 $thumburl=str_replace('dailymotion.com/video/','dailymotion.com/thumbnail/video/',$url);
1405 return '<div class="thumbnail"><a href="'.htmlspecialchars($url).'"><img src="'.htmlspecialchars($thumburl).'" width="120" style="height:auto;"></a></div>'; 1431 return '<a href="'.htmlspecialchars($url).'"><img src="'.htmlspecialchars($thumburl).'" width="120" style="height:auto;"></a>';
1406 } 1432 }
1407 } 1433 }
1408 if (endsWith($domain,'.imageshack.us')) 1434 if (endsWith($domain,'.imageshack.us'))
@@ -1411,7 +1437,7 @@ function thumbnail($url)
1411 if ($ext=='jpg' || $ext=='jpeg' || $ext=='png' || $ext=='gif') 1437 if ($ext=='jpg' || $ext=='jpeg' || $ext=='png' || $ext=='gif')
1412 { 1438 {
1413 $thumburl = substr($url,0,strlen($url)-strlen($ext)).'th.'.$ext; 1439 $thumburl = substr($url,0,strlen($url)-strlen($ext)).'th.'.$ext;
1414 return '<div class="thumbnail"><a href="'.htmlspecialchars($url).'"><img src="'.htmlspecialchars($thumburl).'" width="120" style="height:auto;"></a></div>'; 1440 return '<a href="'.htmlspecialchars($url).'"><img src="'.htmlspecialchars($thumburl).'" width="120" style="height:auto;"></a>';
1415 } 1441 }
1416 } 1442 }
1417 1443
@@ -1425,7 +1451,7 @@ function thumbnail($url)
1425 if ($domain=='flickr.com' || endsWith($domain,'.flickr.com') || $domain=='vimeo.com') 1451 if ($domain=='flickr.com' || endsWith($domain,'.flickr.com') || $domain=='vimeo.com')
1426 { 1452 {
1427 $sign = hash_hmac('sha256', $url, $GLOBALS['salt']); // We use the salt to sign data (it's random, secret, and specific to each installation) 1453 $sign = hash_hmac('sha256', $url, $GLOBALS['salt']); // We use the salt to sign data (it's random, secret, and specific to each installation)
1428 return '<div class="thumbnail"><a href="'.htmlspecialchars($url).'"><img src="?do=genthumbnail&hmac='.htmlspecialchars($sign).'&url='.urlencode($url).'" width="120" style="height:auto;"></a></div>'; 1454 return '<a href="'.htmlspecialchars($url).'"><img src="?do=genthumbnail&hmac='.htmlspecialchars($sign).'&url='.urlencode($url).'" width="120" style="height:auto;"></a>';
1429 } 1455 }
1430 1456
1431 // For all other, we try to make a thumbnail of links ending with .jpg/jpeg/png/gif 1457 // For all other, we try to make a thumbnail of links ending with .jpg/jpeg/png/gif
@@ -1435,7 +1461,7 @@ function thumbnail($url)
1435 if ($ext=='jpg' || $ext=='jpeg' || $ext=='png' || $ext=='gif') 1461 if ($ext=='jpg' || $ext=='jpeg' || $ext=='png' || $ext=='gif')
1436 { 1462 {
1437 $sign = hash_hmac('sha256', $url, $GLOBALS['salt']); // We use the salt to sign data (it's random, secret, and specific to each installation) 1463 $sign = hash_hmac('sha256', $url, $GLOBALS['salt']); // We use the salt to sign data (it's random, secret, and specific to each installation)
1438 return '<div class="thumbnail"><a href="'.htmlspecialchars($url).'"><img src="?do=genthumbnail&hmac='.htmlspecialchars($sign).'&url='.urlencode($url).'" width="120" style="height:auto;"></a></div>'; 1464 return '<a href="'.htmlspecialchars($url).'"><img src="?do=genthumbnail&hmac='.htmlspecialchars($sign).'&url='.urlencode($url).'" width="120" style="height:auto;"></a>';
1439 } 1465 }
1440 return ''; // No thumbnail. 1466 return ''; // No thumbnail.
1441 1467
@@ -1487,10 +1513,10 @@ $(document).ready(function()
1487JS; 1513JS;
1488 } 1514 }
1489 $feedurl=htmlspecialchars(serverUrl().$_SERVER['SCRIPT_NAME']); 1515 $feedurl=htmlspecialchars(serverUrl().$_SERVER['SCRIPT_NAME']);
1490 $feedsearch=''; 1516 $searchcrits=''; // Search criteria
1491 if (!empty($_GET['searchtags'])) $feedsearch.='&searchtags='.$_GET['searchtags']; 1517 if (!empty($_GET['searchtags'])) $searchcrits.='&searchtags='.$_GET['searchtags'];
1492 elseif (!empty($_GET['searchterm'])) $feedsearch.='&searchterm='.$_GET['searchterm']; 1518 elseif (!empty($_GET['searchterm'])) $searchcrits.='&searchterm='.$_GET['searchterm'];
1493 $filtered_feed= ($feedsearch=='' ? '' : 'Filtered '); 1519 $filtered_feed= ($searchcrits=='' ? '' : 'Filtered ');
1494 $version=shaarli_version; 1520 $version=shaarli_version;
1495 1521
1496 $title = htmlspecialchars( $GLOBALS['title'] ); 1522 $title = htmlspecialchars( $GLOBALS['title'] );
@@ -1499,15 +1525,15 @@ JS;
1499<html> 1525<html>
1500<head> 1526<head>
1501<title>{$pagetitle}</title> 1527<title>{$pagetitle}</title>
1502<link rel="alternate" type="application/rss+xml" href="{$feedurl}?do=rss{$feedsearch}" title="{$filtered_feed}RSS Feed" /> 1528<link rel="alternate" type="application/rss+xml" href="{$feedurl}?do=rss{$searchcrits}" title="{$filtered_feed}RSS Feed" />
1503<link rel="alternate" type="application/atom+xml" href="{$feedurl}?do=atom{$feedsearch}" title="{$filtered_feed}ATOM Feed" /> 1529<link rel="alternate" type="application/atom+xml" href="{$feedurl}?do=atom{$searchcrits}" title="{$filtered_feed}ATOM Feed" />
1504<link type="text/css" rel="stylesheet" href="shaarli.css?version={$version}" /> 1530<link type="text/css" rel="stylesheet" href="shaarli.css?version={$version}" />
1505{$jsincludes} 1531{$jsincludes}
1506</head> 1532</head>
1507<body {$data['onload']}>{$newversion} 1533<body {$data['onload']}>{$newversion}
1508<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> 1534<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>
1509 <span id="shaarli_title"><a href="?">{$title}</a></span> - <a href="?">Home</a>&nbsp;{$menu}&nbsp;<a href="{$feedurl}?do=rss{$feedsearch}" style="padding-left:30px;">RSS Feed</a> <a href="{$feedurl}?do=atom{$feedsearch}" style="padding-left:10px;">ATOM Feed</a> 1535 <span id="shaarli_title"><a href="?">{$title}</a></span> - <a href="?">Home</a>&nbsp;{$menu}&nbsp;<a href="{$feedurl}?do=rss{$searchcrits}" style="padding-left:30px;">RSS Feed</a> <a href="{$feedurl}?do=atom{$searchcrits}" style="padding-left:10px;">ATOM Feed</a>
1510&nbsp;&nbsp; <a href="?do=tagcloud">Tag cloud</a> 1536&nbsp;&nbsp; <a href="?do=tagcloud">Tag cloud</a>&nbsp;&nbsp; <a href="?do=picwall{$searchcrits}">Picture wall</a>
1511{$data['pageheader']} 1537{$data['pageheader']}
1512</div> 1538</div>
1513{$data['body']} 1539{$data['body']}