aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--index.php23
1 files changed, 16 insertions, 7 deletions
diff --git a/index.php b/index.php
index 6732083c..a9491ed3 100644
--- a/index.php
+++ b/index.php
@@ -1,5 +1,5 @@
1<?php 1<?php
2// Shaarli 0.0.22 beta - Shaare your links... 2// Shaarli 0.0.23 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
@@ -49,7 +49,7 @@ header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
49header("Cache-Control: no-store, no-cache, must-revalidate"); 49header("Cache-Control: no-store, no-cache, must-revalidate");
50header("Cache-Control: post-check=0, pre-check=0", false); 50header("Cache-Control: post-check=0, pre-check=0", false);
51header("Pragma: no-cache"); 51header("Pragma: no-cache");
52define('shaarli_version','0.0.22 beta'); 52define('shaarli_version','0.0.23 beta');
53if (!is_dir(DATADIR)) { mkdir(DATADIR,0705); chmod(DATADIR,0705); } 53if (!is_dir(DATADIR)) { mkdir(DATADIR,0705); chmod(DATADIR,0705); }
54if (!is_dir(CACHEDIR)) { mkdir(CACHEDIR,0705); chmod(CACHEDIR,0705); } 54if (!is_dir(CACHEDIR)) { mkdir(CACHEDIR,0705); chmod(CACHEDIR,0705); }
55if (!is_file(DATADIR.'/.htaccess')) { file_put_contents(DATADIR.'/.htaccess',"Allow from none\nDeny from all\n"); } // Protect data files. 55if (!is_file(DATADIR.'/.htaccess')) { file_put_contents(DATADIR.'/.htaccess',"Allow from none\nDeny from all\n"); } // Protect data files.
@@ -676,7 +676,7 @@ function renderPage()
676 } 676 }
677 $returnurl_html = (isset($_SERVER['HTTP_REFERER']) ? '<input type="hidden" name="returnurl" value="'.htmlspecialchars($_SERVER['HTTP_REFERER']).'">' : ''); 677 $returnurl_html = (isset($_SERVER['HTTP_REFERER']) ? '<input type="hidden" name="returnurl" value="'.htmlspecialchars($_SERVER['HTTP_REFERER']).'">' : '');
678 $loginform='<div id="headerform"><form method="post" name="loginform">Login: <input type="text" name="login">&nbsp;&nbsp;&nbsp;Password : <input type="password" name="password"> <input type="submit" value="Login" class="bigbutton"><br>'; 678 $loginform='<div id="headerform"><form method="post" name="loginform">Login: <input type="text" name="login">&nbsp;&nbsp;&nbsp;Password : <input type="password" name="password"> <input type="submit" value="Login" class="bigbutton"><br>';
679 $loginform.='<input style="margin:10 0 0 40;" type="checkbox" name="longlastingsession">&nbsp;Stay signed in (Do not check on public computers)<input type="hidden" name="token" value="'.getToken().'">'.$returnurl_html.'</form></div>'; 679 $loginform.='<input style="margin:10 0 0 40;" type="checkbox" name="longlastingsession" id="longlastingsession"><label for="longlastingsession">&nbsp;Stay signed in (Do not check on public computers)</label><input type="hidden" name="token" value="'.getToken().'">'.$returnurl_html.'</form></div>';
680 $onload = 'onload="document.loginform.login.focus();"'; 680 $onload = 'onload="document.loginform.login.focus();"';
681 $data = array('pageheader'=>$loginform,'body'=>'','onload'=>$onload); 681 $data = array('pageheader'=>$loginform,'body'=>'','onload'=>$onload);
682 templatePage($data); 682 templatePage($data);
@@ -941,7 +941,7 @@ HTML;
941 $tags = trim(preg_replace('/\s\s+/',' ', $_POST['lf_tags'])); // Remove multiple spaces. 941 $tags = trim(preg_replace('/\s\s+/',' ', $_POST['lf_tags'])); // Remove multiple spaces.
942 $linkdate=$_POST['lf_linkdate']; 942 $linkdate=$_POST['lf_linkdate'];
943 $link = array('title'=>trim($_POST['lf_title']),'url'=>trim($_POST['lf_url']),'description'=>trim($_POST['lf_description']),'private'=>(isset($_POST['lf_private']) ? 1 : 0), 943 $link = array('title'=>trim($_POST['lf_title']),'url'=>trim($_POST['lf_url']),'description'=>trim($_POST['lf_description']),'private'=>(isset($_POST['lf_private']) ? 1 : 0),
944 'linkdate'=>$linkdate,'tags'=>$tags); 944 'linkdate'=>$linkdate,'tags'=>str_replace(',',' ',$tags));
945 if ($link['title']=='') $link['title']=$link['url']; // If title is empty, use the URL as title. 945 if ($link['title']=='') $link['title']=$link['url']; // If title is empty, use the URL as title.
946 $LINKSDB[$linkdate] = $link; 946 $LINKSDB[$linkdate] = $link;
947 $LINKSDB->savedb(); // save to disk 947 $LINKSDB->savedb(); // save to disk
@@ -1337,7 +1337,16 @@ function thumbnail($url)
1337 return '<div class="thumbnail"><a href="'.htmlspecialchars($url).'"><img src="'.htmlspecialchars($thumburl).'" width="120" style="height:auto;"></a></div>'; 1337 return '<div class="thumbnail"><a href="'.htmlspecialchars($url).'"><img src="'.htmlspecialchars($thumburl).'" width="120" style="height:auto;"></a></div>';
1338 } 1338 }
1339 } 1339 }
1340 1340 if (endsWith($domain,'.imageshack.us'))
1341 {
1342 $ext=strtolower(pathinfo($url,PATHINFO_EXTENSION));
1343 if ($ext=='jpg' || $ext=='jpeg' || $ext=='png' || $ext=='gif')
1344 {
1345 $thumburl = substr($url,0,strlen($url)-strlen($ext)).'th.'.$ext;
1346 return '<div class="thumbnail"><a href="'.htmlspecialchars($url).'"><img src="'.htmlspecialchars($thumburl).'" width="120" style="height:auto;"></a></div>';
1347 }
1348 }
1349
1341 // Some other hosts are SLOW AS HELL and usually require an extra HTTP request to get the thumbnail URL. 1350 // Some other hosts are SLOW AS HELL and usually require an extra HTTP request to get the thumbnail URL.
1342 // So we deport the thumbnail generation in order not to slow down page generation 1351 // So we deport the thumbnail generation in order not to slow down page generation
1343 // (and we also cache the thumbnail) 1352 // (and we also cache the thumbnail)
@@ -1544,14 +1553,14 @@ function processWS()
1544 // Search in tags (case insentitive, cumulative search) 1553 // Search in tags (case insentitive, cumulative search)
1545 if ($_GET['ws']=='tags') 1554 if ($_GET['ws']=='tags')
1546 { 1555 {
1547 $tags=explode(' ',$term); $last = array_pop($tags); // Get the last term ("a b c d" ==> "a b c", "d") 1556 $tags=explode(' ',str_replace(',',' ',$term)); $last = array_pop($tags); // Get the last term ("a b c d" ==> "a b c", "d")
1548 $addtags=''; if ($tags) $addtags=implode(' ',$tags).' '; // We will pre-pend previous tags 1557 $addtags=''; if ($tags) $addtags=implode(' ',$tags).' '; // We will pre-pend previous tags
1549 $suggested=array(); 1558 $suggested=array();
1550 /* To speed up things, we store list of tags in session */ 1559 /* To speed up things, we store list of tags in session */
1551 if (empty($_SESSION['tags'])) $_SESSION['tags'] = $LINKSDB->allTags(); 1560 if (empty($_SESSION['tags'])) $_SESSION['tags'] = $LINKSDB->allTags();
1552 foreach($_SESSION['tags'] as $key=>$value) 1561 foreach($_SESSION['tags'] as $key=>$value)
1553 { 1562 {
1554 if (startsWith($key,$last,$case=false)) $suggested[$addtags.$key.' ']=0; 1563 if (startsWith($key,$last,$case=false) && !in_array($key,$tags)) $suggested[$addtags.$key.' ']=0;//FIXME
1555 } 1564 }
1556 echo json_encode(array_keys($suggested)); 1565 echo json_encode(array_keys($suggested));
1557 exit; 1566 exit;