Merge branch 'master' of git://github.com/sebsauvage/Shaarli

Conflicts:
	index.php
	tpl/includes.html
	tpl/linklist.html
	tpl/page.footer.html
This commit is contained in:
Knah Tsaeb 2013-03-04 14:03:46 +01:00
commit 9de40d272f
7 changed files with 121 additions and 84 deletions

171
index.php
View file

@ -96,6 +96,8 @@ require $GLOBALS['config']['CONFIG_FILE']; // Read login/password hash into $GL
if (empty($GLOBALS['title'])) $GLOBALS['title']='Shared links on '.htmlspecialchars(indexUrl());
if (empty($GLOBALS['timezone'])) $GLOBALS['timezone']=date_default_timezone_get();
if (empty($GLOBALS['disablesessionprotection'])) $GLOBALS['disablesessionprotection']=false;
if (empty($GLOBALS['disablejquery'])) $GLOBALS['disablejquery']=false;
// I really need to rewrite Shaarli with a proper configuation manager.
autoLocale(); // Sniff browser language and set date format accordingly.
header('Content-Type: text/html; charset=utf-8'); // We use UTF-8 for proper international characters handling.
@ -144,7 +146,7 @@ class pageCache
private $shouldBeCached; // boolean: Should this url be cached ?
private $filename; // Name of the cache file for this url
/*
/*
$url = url (typically the value returned by pageUrl())
$shouldBeCached = boolean. If false, the cache will be disabled.
*/
@ -153,7 +155,7 @@ class pageCache
$this->url = $url;
$this->filename = $GLOBALS['config']['PAGECACHE'].'/'.sha1($url).'.cache';
$this->shouldBeCached = $shouldBeCached;
}
}
// If the page should be cached and a cached version exists,
// returns the cached version (otherwise, return null).
@ -181,7 +183,7 @@ class pageCache
$handler = opendir($GLOBALS['config']['PAGECACHE']);
if ($handler!==false)
{
while (($filename = readdir($handler))!==false)
while (($filename = readdir($handler))!==false)
{
if (endsWith($filename,'.cache')) { unlink($GLOBALS['config']['PAGECACHE'].'/'.$filename); }
}
@ -238,7 +240,7 @@ function text2clickable($url)
function keepMultipleSpaces($text)
{
return str_replace(' ','  ',$text);
}
// ------------------------------------------------------------------------------------------
// Sniff browser language to display dates in the right format automatically.
@ -304,7 +306,7 @@ function check_auth($login,$password)
function isLoggedIn()
{
if ($GLOBALS['config']['OPEN_SHAARLI']) return true;
if (!isset($GLOBALS['login'])) return false; // Shaarli is not configured yet.
// If session does not exist on server side, or IP address has changed, or session has expired, logout.
@ -320,7 +322,7 @@ function isLoggedIn()
}
// Force logout.
function logout() { if (isset($_SESSION)) { unset($_SESSION['uid']); unset($_SESSION['ip']); unset($_SESSION['username']);} }
function logout() { if (isset($_SESSION)) { unset($_SESSION['uid']); unset($_SESSION['ip']); unset($_SESSION['username']); unset($_SESSION['privateonly']); } }
// ------------------------------------------------------------------------------------------
@ -408,7 +410,9 @@ if (isset($_POST['login']))
else
{
ban_loginFailed();
echo '<script language="JavaScript">alert("Wrong login/password.");document.location=\'?do=login\';</script>'; // Redirect to login screen.
$redir = '';
if (isset($_GET['post'])) { $redir = '&post='.urlencode($_GET['post']).(!empty($_GET['title'])?'&title='.urlencode($_GET['title']):'').(!empty($_GET['source'])?'&source='.urlencode($_GET['source']):''); }
echo '<script language="JavaScript">alert("Wrong login/password.");document.location=\'?do=login'.$redir.'\';</script>'; // Redirect to login screen.
exit;
}
}
@ -417,7 +421,7 @@ if (isset($_POST['login']))
// Misc utility functions:
// Try to get just domain for @via
// Try to get just domain for @via
function getJustDomain($url){
$parts = parse_url($url);
return trim($parts['host']);
@ -609,7 +613,7 @@ function tokenOk($token)
p = new pageBuilder;
p.assign('myfield','myvalue');
p.renderPage('mytemplate');
*/
class pageBuilder
{
@ -618,11 +622,11 @@ class pageBuilder
function __construct()
{
$this->tpl=false;
}
}
private function initialize()
{
$this->tpl = new RainTPL;
{
$this->tpl = new RainTPL;
$this->tpl->assign('newversion',checkUpdate());
$this->tpl->assign('feedurl',htmlspecialchars(indexUrl()));
$searchcrits=''; // Search criteria
@ -637,16 +641,16 @@ class pageBuilder
if (!empty($GLOBALS['title'])) $this->tpl->assign('pagetitle',$GLOBALS['title']);
if (!empty($GLOBALS['pagetitle'])) $this->tpl->assign('pagetitle',$GLOBALS['pagetitle']);
$this->tpl->assign('shaarlititle',empty($GLOBALS['title']) ? 'Shaarli': $GLOBALS['title'] );
return;
return;
}
// The following assign() method is basically the same as RainTPL (except that it's lazy)
public function assign($what,$where)
{
if ($this->tpl===false) $this->initialize(); // Lazy initialization
$this->tpl->assign($what,$where);
}
// Render a specific page (using a template).
// eg. pb.renderPage('picwall')
public function renderPage($page)
@ -664,14 +668,14 @@ class pageBuilder
echo $mylinks['20110826_161819']['title'];
foreach($mylinks as $link)
echo $link['title'].' at url '.$link['url'].' ; description:'.$link['description'];
Available keys:
title : Title of the link
url : URL of the link. Can be absolute or relative. Relative URLs are permalinks (eg.'?m-ukcw')
description : description of the entry
private : Is this link private ? 0=no, other value=yes
linkdate : date of the creation of this entry, in the form YYYYMMDD_HHMMSS (eg.'20110914_192317')
tags : tags attached to this entry (separated by spaces)
tags : tags attached to this entry (separated by spaces)
We implement 3 interfaces:
- ArrayAccess so that this object behaves like an associative array.
@ -852,7 +856,7 @@ class linkdb implements Iterator, Countable, ArrayAccess
arsort($tags); // Sort tags by usage (most used tag first)
return $tags;
}
// Returns the list of days containing articles (oldest first)
// Output: An array containing days (in format YYYYMMDD).
public function days()
@ -930,7 +934,7 @@ function showRSS()
echo '<description><![CDATA['.nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($link['description'])))).$descriptionlink.']]></description>'."\n</item>\n";
$i++;
}
echo '</channel></rss>';
echo '</channel></rss><!-- Cached version of '.pageUrl().' -->';
$cache->cache(ob_get_contents());
ob_end_flush();
@ -1010,9 +1014,9 @@ function showATOM()
$feed.='<author><name>'.htmlspecialchars($pageaddr).'</name><uri>'.htmlspecialchars($pageaddr).'</uri></author>';
$feed.='<id>'.htmlspecialchars($pageaddr).'</id>'."\n\n"; // Yes, I know I should use a real IRI (RFC3987), but the site URL will do.
$feed.=$entries;
$feed.='</feed>';
$feed.='</feed><!-- Cached version of '.pageUrl().' -->';
echo $feed;
$cache->cache(ob_get_contents());
ob_end_flush();
exit;
@ -1030,11 +1034,11 @@ function showDailyRSS()
$cached = $cache->cachedVersion(); if (!empty($cached)) { echo $cached; exit; }
// If cached was not found (or not usable), then read the database and build the response:
$LINKSDB=new linkdb(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); // Read links from database (and filter private links if used it not logged in).
/* Some Shaarlies may have very few links, so we need to look
back in time (rsort()) until we have enough days ($nb_of_days).
*/
$linkdates=array(); foreach($LINKSDB as $linkdate=>$value) { $linkdates[]=$linkdate; }
$linkdates=array(); foreach($LINKSDB as $linkdate=>$value) { $linkdates[]=$linkdate; }
rsort($linkdates);
$nb_of_days=7; // We take 7 days.
$today=Date('Ymd');
@ -1049,14 +1053,14 @@ function showDailyRSS()
}
if (count($days)>$nb_of_days) break; // Have we collected enough days ?
}
// Build the RSS feed.
header('Content-Type: application/rss+xml; charset=utf-8');
$pageaddr=htmlspecialchars(indexUrl());
echo '<?xml version="1.0" encoding="UTF-8"?><rss version="2.0">';
echo '<channel><title>Daily - '.htmlspecialchars($GLOBALS['title']).'</title><link>'.$pageaddr.'</link>';
echo '<description>Daily shared links</description><language>en-en</language><copyright>'.$pageaddr.'</copyright>'."\n";
foreach($days as $day=>$linkdates) // For each day.
{
$daydate = utf8_encode(strftime('%A %d, %B %Y',linkdate2timestamp($day.'_000000'))); // Full text date
@ -1064,7 +1068,7 @@ function showDailyRSS()
$absurl=htmlspecialchars(indexUrl().'?do=daily&day='.$day); // Absolute URL of the corresponding "Daily" page.
echo '<item><title>'.htmlspecialchars($GLOBALS['title'].' - '.$daydate).'</title><guid>'.$absurl.'</guid><link>'.$absurl.'</link>';
echo '<pubDate>'.htmlspecialchars($rfc822date)."</pubDate>";
// Build the HTML body of this RSS entry.
$html='';
$href='';
@ -1074,21 +1078,21 @@ function showDailyRSS()
{
$l = $LINKSDB[$linkdate];
$l['formatedDescription']=nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($l['description']))));
$l['thumbnail'] = thumbnail($l['url']);
$l['localdate']=linkdate2locale($l['linkdate']);
$l['thumbnail'] = thumbnail($l['url']);
$l['localdate']=linkdate2locale($l['linkdate']);
if (startsWith($l['url'],'?')) $l['url']=indexUrl().$l['url']; // make permalink URL absolute
$links[$linkdate]=$l;
$links[$linkdate]=$l;
}
// Then build the HTML for this day:
$tpl = new RainTPL;
$tpl = new RainTPL;
$tpl->assign('links',$links);
$html = $tpl->draw('dailyrss',$return_string=true);
echo "\n";
echo '<description><![CDATA['.$html.']]></description>'."\n</item>\n\n";
}
echo '</channel></rss>';
}
echo '</channel></rss><!-- Cached version of '.pageUrl().' -->';
$cache->cache(ob_get_contents());
ob_end_flush();
exit;
@ -1102,12 +1106,12 @@ function showDaily()
$day=Date('Ymd',strtotime('-1 day')); // Yesterday, in format YYYYMMDD.
if (isset($_GET['day'])) $day=$_GET['day'];
$days = $LINKSDB->days();
$i = array_search($day,$days);
if ($i==false) { $i=count($days)-1; $day=$days[$i]; }
$previousday='';
$nextday='';
$previousday='';
$nextday='';
if ($i!==false)
{
if ($i>1) $previousday=$days[$i-1];
@ -1118,14 +1122,16 @@ function showDaily()
// We pre-format some fields for proper output.
foreach($linksToDisplay as $key=>$link)
{
$linksToDisplay[$key]['taglist']=explode(' ',$link['tags']);
$taglist = explode(' ',$link['tags']);
uasort($taglist, 'strcasecmp');
$linksToDisplay[$key]['taglist']=$taglist;
$linksToDisplay[$key]['formatedDescription']=nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($link['description']))));
$linksToDisplay[$key]['thumbnail'] = thumbnail($link['url']);
$linksToDisplay[$key]['thumbnail'] = thumbnail($link['url']);
}
/* We need to spread the articles on 3 columns.
I did not want to use a javascript lib like http://masonry.desandro.com/
so I manually spread entries with a simple method: I roughly evaluate the
so I manually spread entries with a simple method: I roughly evaluate the
height of a div according to title and description length.
*/
$columns=array(array(),array(),array()); // Entries to display, for each column.
@ -1153,7 +1159,7 @@ function showDaily()
$PAGE->assign('col3',$columns[2]);
$PAGE->assign('day',utf8_encode(strftime('%A %d, %B %Y',linkdate2timestamp($day.'_000000'))));
$PAGE->assign('previousday',$previousday);
$PAGE->assign('nextday',$nextday);
$PAGE->assign('nextday',$nextday);
$PAGE->renderPage('daily');
exit;
}
@ -1232,7 +1238,7 @@ function renderPage()
$PAGE->assign('linkcount',count($LINKSDB));
$PAGE->assign('tags',$tagList);
$PAGE->renderPage('tagcloud');
exit;
exit;
}
// -------- User clicks on a tag in a link: The tag is added to the list of searched tags (searchtags=...)
@ -1268,10 +1274,14 @@ function renderPage()
if (isset($_GET['linksperpage']))
{
if (is_numeric($_GET['linksperpage'])) { $_SESSION['LINKS_PER_PAGE']=abs(intval($_GET['linksperpage'])); }
header('Location: '.(empty($_SERVER['HTTP_REFERER'])?'?':$_SERVER['HTTP_REFERER']));
// Make sure the referer is from Shaarli itself.
$referer = '?';
if (!empty($_SERVER['HTTP_REFERER']) && strcmp(parse_url($_SERVER['HTTP_REFERER'],PHP_URL_HOST),$_SERVER['SERVER_NAME'])==0)
$referer = $_SERVER['HTTP_REFERER'];
header('Location: '.$referer);
exit;
}
// -------- User wants to see only private links (toggle)
if (isset($_GET['privateonly']))
{
@ -1283,7 +1293,11 @@ function renderPage()
{
unset($_SESSION['privateonly']); // See all links
}
header('Location: '.(empty($_SERVER['HTTP_REFERER'])?'?':$_SERVER['HTTP_REFERER']));
// Make sure the referer is from Shaarli itself.
$referer = '?';
if (!empty($_SERVER['HTTP_REFERER']) && strcmp(parse_url($_SERVER['HTTP_REFERER'],PHP_URL_HOST),$_SERVER['SERVER_NAME'])==0)
$referer = $_SERVER['HTTP_REFERER'];
header('Location: '.$referer);
exit;
}
@ -1357,6 +1371,7 @@ function renderPage()
$GLOBALS['title']=$_POST['title'];
$GLOBALS['redirector']=$_POST['redirector'];
$GLOBALS['disablesessionprotection']=!empty($_POST['disablesessionprotection']);
$GLOBALS['disablejquery']=!empty($_POST['disablejquery']);
writeConfig();
echo '<script language="JavaScript">alert("Configuration was saved.");document.location=\'?do=tools\';</script>';
exit;
@ -1439,7 +1454,11 @@ function renderPage()
if (!tokenOk($_POST['token'])) die('Wrong token.'); // Go away !
$tags = trim(preg_replace('/\s\s+/',' ', $_POST['lf_tags'])); // Remove multiple spaces.
$linkdate=$_POST['lf_linkdate'];
$link = array('title'=>trim($_POST['lf_title']),'url'=>trim($_POST['lf_url']),'description'=>trim($_POST['lf_description']),'snippet'=>trim($_POST['lf_snippet']),'private'=>(isset($_POST['lf_private']) ? 1 : 0),'linkdate'=>$linkdate,'tags'=>str_replace(',',' ',$tags), 'via'=>trim($_POST['lf_via']));
$url = trim($_POST['lf_url']);
if (!startsWith($url,'http:') && !startsWith($url,'https:') && !startsWith($url,'ftp:') && !startsWith($url,'magnet:') && !startsWith($url,'?'))
$url = 'http://'.$url;
$link = array('title'=>trim($_POST['lf_title']),'url'=>$url,'description'=>trim($_POST['lf_description']),'private'=>(isset($_POST['lf_private']) ? 1 : 0),
'linkdate'=>$linkdate,'tags'=>str_replace(',',' ',$tags),'snippet'=>trim($_POST['lf_snippet']), 'via'=>trim($_POST['lf_via']));
if ($link['title']=='') $link['title']=$link['url']; // If title is empty, use the URL as title.
$LINKSDB[$linkdate] = $link;
$LINKSDB->savedb(); // save to disk
@ -1730,7 +1749,7 @@ function buildLinkList($PAGE,$LINKSDB)
}
else
$linksToDisplay = $LINKSDB; // otherwise, display without filtering.
// Option: Show only private links
if (!empty($_SESSION['privateonly']))
{
@ -1771,11 +1790,13 @@ function buildLinkList($PAGE,$LINKSDB)
$classLi = $i%2!=0 ? '' : 'publicLinkHightLight';
$link['class'] = ($link['private']==0 ? $classLi : 'private');
$link['localdate']=linkdate2locale($link['linkdate']);
$link['taglist']=explode(' ',$link['tags']);
$taglist = explode(' ',$link['tags']);
uasort($taglist, 'strcasecmp');
$link['taglist']=$taglist;
$linkDisp[$keys[$i]] = $link;
$i++;
}
// Compute paging navigation
$searchterm= ( empty($_GET['searchterm']) ? '' : '&searchterm='.$_GET['searchterm'] );
$searchtags= ( empty($_GET['searchtags']) ? '' : '&searchtags='.$_GET['searchtags'] );
@ -1783,8 +1804,8 @@ function buildLinkList($PAGE,$LINKSDB)
$previous_page_url=''; if ($i!=count($keys)) $previous_page_url='?page='.($page+1).$searchterm.$searchtags;
$next_page_url='';if ($page>1) $next_page_url='?page='.($page-1).$searchterm.$searchtags;
$token = ''; if (isLoggedIn()) $token=getToken();
$token = ''; if (isLoggedIn()) $token=getToken();
// Fill all template fields.
$PAGE->assign('linkcount',count($LINKSDB));
$PAGE->assign('previous_page_url',$previous_page_url);
@ -1793,7 +1814,7 @@ function buildLinkList($PAGE,$LINKSDB)
$PAGE->assign('page_max',$pagecount);
$PAGE->assign('result_count',count($linksToDisplay));
$PAGE->assign('search_type',$search_type);
$PAGE->assign('search_crits',$search_crits);
$PAGE->assign('search_crits',$search_crits);
$PAGE->assign('redirector',empty($GLOBALS['redirector']) ? '' : $GLOBALS['redirector']); // optional redirector URL
$PAGE->assign('token',$token);
$PAGE->assign('links',$linkDisp);
@ -1801,7 +1822,7 @@ function buildLinkList($PAGE,$LINKSDB)
}
// Compute the thumbnail for a link.
//
//
// with a link to the original URL.
// Understands various services (youtube.com...)
// Input: $url = url for which the thumbnail must be found.
@ -1828,15 +1849,15 @@ function computeThumbnail($url,$href=false)
{
$path = parse_url($url,PHP_URL_PATH);
return array('src'=>'http://img.youtube.com/vi'.$path.'/default.jpg',
'href'=>$href,'width'=>'120','height'=>'90','alt'=>'YouTube thumbnail');
'href'=>$href,'width'=>'120','height'=>'90','alt'=>'YouTube thumbnail');
}
if ($domain=='pix.toile-libre.org') // pix.toile-libre.org image hosting
{
parse_str(parse_url($url,PHP_URL_QUERY), $params); // Extract image filename.
if (!empty($params) && !empty($params['img'])) return array('src'=>'http://pix.toile-libre.org/upload/thumb/'.urlencode($params['img']),
'href'=>$href,'style'=>'max-width:120px; max-height:150px','alt'=>'pix.toile-libre.org thumbnail');
}
'href'=>$href,'style'=>'max-width:120px; max-height:150px','alt'=>'pix.toile-libre.org thumbnail');
}
if ($domain=='imgur.com')
{
$path = parse_url($url,PHP_URL_PATH);
@ -1915,7 +1936,7 @@ function computeThumbnail($url,$href=false)
{
$sign = hash_hmac('sha256', $url, $GLOBALS['salt']); // We use the salt to sign data (it's random, secret, and specific to each installation)
return array('src'=>indexUrl().'?do=genthumbnail&hmac='.htmlspecialchars($sign).'&url='.urlencode($url),
'href'=>$href,'width'=>'120','style'=>'height:auto;','alt'=>'thumbnail');
'href'=>$href,'width'=>'120','style'=>'height:auto;','alt'=>'thumbnail');
}
return array(); // No thumbnail.
@ -1932,7 +1953,7 @@ function thumbnail($url,$href=false)
{
$t = computeThumbnail($url,$href);
if (count($t)==0) return ''; // Empty array = no thumbnail for this URL.
$html='<a href="'.htmlspecialchars($t['href']).'"><img src="'.htmlspecialchars($t['src']).'"';
if (!empty($t['width'])) $html.=' width="'.htmlspecialchars($t['width']).'"';
if (!empty($t['height'])) $html.=' height="'.htmlspecialchars($t['height']).'"';
@ -1951,27 +1972,32 @@ function thumbnail($url,$href=false)
// Returns '' if no thumbnail available.
function lazyThumbnail($url,$href=false)
{
$t = computeThumbnail($url,$href);
$t = computeThumbnail($url,$href);
if (count($t)==0) return ''; // Empty array = no thumbnail for this URL.
$html='<a href="'.htmlspecialchars($t['href']).'">';
// Lazy image (only loaded by javascript when in the viewport).
if (!empty($GLOBALS['disablejquery'])) // (except if jQuery is disabled)
$html.='<img class="lazyimage" src="'.htmlspecialchars($t['src']).'"';
else
$html.='<img class="lazyimage" src="#" data-original="'.htmlspecialchars($t['src']).'"';
$html.='<img class="lazyimage" src="#" data-original="'.htmlspecialchars($t['src']).'"';
if (!empty($t['width'])) $html.=' width="'.htmlspecialchars($t['width']).'"';
if (!empty($t['height'])) $html.=' height="'.htmlspecialchars($t['height']).'"';
if (!empty($t['style'])) $html.=' style="'.htmlspecialchars($t['style']).'"';
if (!empty($t['alt'])) $html.=' alt="'.htmlspecialchars($t['alt']).'"';
$html.='>';
// No-javascript fallback:
// No-javascript fallback.
$html.='<noscript><img src="'.htmlspecialchars($t['src']).'"';
if (!empty($t['width'])) $html.=' width="'.htmlspecialchars($t['width']).'"';
if (!empty($t['height'])) $html.=' height="'.htmlspecialchars($t['height']).'"';
if (!empty($t['style'])) $html.=' style="'.htmlspecialchars($t['style']).'"';
if (!empty($t['alt'])) $html.=' alt="'.htmlspecialchars($t['alt']).'"';
$html.='></noscript></a>';
return $html;
}
@ -2026,7 +2052,7 @@ function install()
// Display config form:
list($timezone_form,$timezone_js) = templateTZform();
$timezone_html=''; if ($timezone_form!='') $timezone_html='<tr><td valign="top"><b>Timezone:</b></td><td>'.$timezone_form.'</td></tr>';
$PAGE = new pageBuilder;
$PAGE->assign('timezone_html',$timezone_html);
$PAGE->assign('timezone_js',$timezone_js);
@ -2071,8 +2097,8 @@ function templateTZform($ptz=false)
foreach($continents as $continent)
$continents_html.='<option value="'.$continent.'"'.($pcontinent==$continent?'selected':'').'>'.$continent.'</option>';
$cities_html = $cities[$pcontinent];
$timezone_form = "Continent: <select name=\"continent\" id=\"continent\" onChange=\"onChangecontinent();\">${continents_html}</select><br /><br />";
$timezone_form .= "City: <select name=\"city\" id=\"city\">${cities[$pcontinent]}</select><br /><br />";
$timezone_form = "Continent: <select name=\"continent\" id=\"continent\" onChange=\"onChangecontinent();\">${continents_html}</select>";
$timezone_form .= "&nbsp;&nbsp;&nbsp;&nbsp;City: <select name=\"city\" id=\"city\">${cities[$pcontinent]}</select><br />";
$timezone_js = "<script language=\"JavaScript\">";
$timezone_js .= "function onChangecontinent(){document.getElementById(\"city\").innerHTML = citiescontinent[document.getElementById(\"continent\").value];}";
$timezone_js .= "var citiescontinent = ".json_encode($cities).";" ;
@ -2143,12 +2169,11 @@ function processWS()
function writeConfig()
{
if (is_file($GLOBALS['config']['CONFIG_FILE']) && !isLoggedIn()) die('You are not authorized to alter config.'); // Only logged in user can alter config.
if (empty($GLOBALS['redirector'])) $GLOBALS['redirector']='';
if (empty($GLOBALS['disablesessionprotection'])) $GLOBALS['disablesessionprotection']=false;
$config='<?php $GLOBALS[\'login\']='.var_export($GLOBALS['login'],true).'; $GLOBALS[\'hash\']='.var_export($GLOBALS['hash'],true).'; $GLOBALS[\'salt\']='.var_export($GLOBALS['salt'],true).'; ';
$config .='$GLOBALS[\'timezone\']='.var_export($GLOBALS['timezone'],true).'; date_default_timezone_set('.var_export($GLOBALS['timezone'],true).'); $GLOBALS[\'title\']='.var_export($GLOBALS['title'],true).';';
$config .= '$GLOBALS[\'redirector\']='.var_export($GLOBALS['redirector'],true).'; ';
$config .= '$GLOBALS[\'disablesessionprotection\']='.var_export($GLOBALS['disablesessionprotection'],true).'; ';
$config .= '$GLOBALS[\'disablejquery\']='.var_export($GLOBALS['disablejquery'],true).'; ';
$config .= ' ?>';
if (!file_put_contents($GLOBALS['config']['CONFIG_FILE'],$config) || strcmp(file_get_contents($GLOBALS['config']['CONFIG_FILE']),$config)!=0)
{
@ -2265,7 +2290,7 @@ function genThumbnail()
// The thumbnail for TED talks is located in the <link rel="image_src" [...]> tag on that page
// http://www.ted.com/talks/mikko_hypponen_fighting_viruses_defending_the_net.html
// <link rel="image_src" href="http://images.ted.com/images/ted/28bced335898ba54d4441809c5b1112ffaf36781_389x292.jpg" />
list($httpstatus,$headers,$data) = getHTTP($url,5);
list($httpstatus,$headers,$data) = getHTTP($url,5);
if (strpos($httpstatus,'200 OK')!==false)
{
// Extract the link to the thumbnail
@ -2288,7 +2313,7 @@ function genThumbnail()
}
}
}
elseif ($domain=='xkcd.com' || endsWith($domain,'.xkcd.com'))
{
// There is no thumbnail available for xkcd comics, so download the whole image and resize it.
@ -2316,7 +2341,7 @@ function genThumbnail()
}
}
}
}
}
else
{
@ -2388,7 +2413,7 @@ if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=g
if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=rss')) { showRSS(); exit; }
if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=atom')) { showATOM(); exit; }
if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=dailyrss')) { showDailyRSS(); exit; }
if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=daily')) { showDaily(); exit; }
if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=daily')) { showDaily(); exit; }
if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'ws=')) { processWS(); exit; } // Webservices (for jQuery/jQueryUI)
if (!isset($_SESSION['LINKS_PER_PAGE'])) $_SESSION['LINKS_PER_PAGE']=$GLOBALS['config']['LINKS_PER_PAGE'];
renderPage();

View file

@ -8,10 +8,19 @@
<form method="POST" action="" name="configform" id="configform">
<input type="hidden" name="token" value="{$token}">
<table border="0" cellpadding="20">
<tr><td><b>Page title:</b></td><td><input type="text" name="title" id="title" size="50" value="{$title}"></td></tr>
<tr><td valign="top"><b>Timezone:</b></td><td>{$timezone_form}</td></tr>
<tr><td valign="top"><b>Redirector</b></td><td><input type="text" name="redirector" id="redirector" size="50" value="{$redirector}"><br>(e.g. <i>http://anonym.to/?</i> will mask the HTTP_REFERER)</td></tr>
<tr> <td valign="top">Security:</td> <td><input type="checkbox" name="disablesessionprotection" id="disablesessionprotection" {if="!empty($GLOBALS['disablesessionprotection'])"}checked{/if}><label for="disablesessionprotection">&nbsp;Disable session cookie hijacking protection (Check this if you get disconnected often or if your IP address changes often.)</label></td></tr>
<tr><td><b>Page title:</b></td><td><input type="text" name="title" id="title" size="50" value="{$title}"></td></tr>
<tr><td valign="top"><b>Timezone:</b></td><td valign="top">{$timezone_form}</td></tr>
<tr><td valign="top"><b>Redirector</b></td><td><input type="text" name="redirector" id="redirector" size="50" value="{$redirector}"><br>(e.g. <i>http://anonym.to/?</i> will mask the HTTP_REFERER)</td></tr>
<tr><td valign="top"><b>Security:</b></td><td><input type="checkbox" name="disablesessionprotection" id="disablesessionprotection" {if="!empty($GLOBALS['disablesessionprotection'])"}checked{/if}><label for="disablesessionprotection">&nbsp;Disable session cookie hijacking protection (Check this if you get disconnected often or if your IP address changes often.)</label></td></tr>
<tr><td valign="top"><b>Features:</b></td><td>
<input type="checkbox" name="disablejquery" id="disablejquery" {if="!empty($GLOBALS['disablejquery'])"}checked{/if}><label for="disablejquery">&nbsp;Disable jQuery and all heavy javascript (for example: Autocomplete in tags. Useful for slow computers.)</label>
</tr>
<tr><td></td><td align="right"><input type="submit" name="Save" value="Save config" class="bigbutton"></td></tr>
</table>
</form>

View file

@ -8,5 +8,4 @@
<link type="text/css" rel="stylesheet" href="inc/shaarli.css?version={$version|urlencode}#" />
<link type="text/css" rel="stylesheet" href="../inc/highlight.js/styles/default.css" />
{if condition="is_file('inc/user.css')"}<link type="text/css" rel="stylesheet" href="inc/user.css?version={$version}#" />{/if}
<script src="inc/jquery.min.js#"></script><script src="inc/jquery-ui.min.js#"></script>
<script src="../inc/highlight.js/highlight.pack.js"></script>
{if="empty($GLOBALS['disablejquery'])"}<script src="inc/jquery.min.js#"></script><script src="inc/jquery-ui.min.js#"><script src="../inc/highlight.js/highlight.pack.js"></script></script>{/if}

View file

@ -60,7 +60,7 @@
{/if}
</div>
<div class="linkcontainer">
<span class="linktitle"><a href="{$redirector}{$value.url}" name="{$value.linkdate|smallHash}" id="{$value.linkdate|smallHash}">{$value.title|htmlspecialchars}</a></span>
<span class="linktitle"><a href="{$redirector}{$value.url|htmlspecialchars}" name="{$value.linkdate|smallHash}" id="{$value.linkdate|smallHash}">{$value.title|htmlspecialchars}</a></span>
{if="isLoggedIn()"}
<form method="GET" class="buttoneditform">
<input type="hidden" name="edit_link" value="{$value.linkdate}">

View file

@ -9,8 +9,8 @@ Other change as made by <a href="http://forge.leslibres.org/projects/myonsni">Kn
<script>function confirmDeleteLink() { var agree=confirm("Are you sure you want to delete this link ?"); if (agree) return true ; else return false ; }</script>
{/if}
{if="$GLOBALS['config']['OPEN_SHAARLI'] || isLoggedIn()"}
<script>
{if="($GLOBALS['config']['OPEN_SHAARLI'] || isLoggedIn()) && empty($GLOBALS['disablejquery'])"}
<script language="JavaScript">
$(document).ready(function()
{
$('#lf_tags').autocomplete({source:'{$source}?ws=tags',minLength:1});

View file

@ -2,7 +2,7 @@
<div id="logo" title="Share your links !" onclick="document.location='?';"></div>
<div style="float:right; font-style:italic; color:#bbb; text-align:right; padding:0 5 0 0;" class="nomobile">Shaare your links...<br>
{if="!empty($linkcount)"}{$linkcount} links{/if}</div>
<span id="shaarli_title"><a href="?">{$shaarlititle}</a></span>
<span id="shaarli_title"><a href="?">{$shaarlititle|htmlspecialchars}</a></span>
{if="!empty($_GET['source']) && $_GET['source']=='bookmarklet'"}
{ignore} When called as a popup from bookmarklet, do not display menu. {/ignore}

View file

@ -1,7 +1,9 @@
<!DOCTYPE html>
<html>
<head>{include="includes"}
<script src="inc/jquery.lazyload.min.js#"></script>
{if="empty($GLOBALS['disablejquery'])"}
<script src="inc/jquery.lazyload.min.js#"></script>
{/if}
</head>
<body>
<div id="pageheader">{include="page.header"}</div>
@ -16,9 +18,11 @@
</center>
{include="page.footer"}
</body>
{if="empty($GLOBALS['disablejquery'])"}
<script>
$(document).ready(function() {
$("img.lazyimage").show().lazyload();
});
</script>
{/if}
</html>