aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rwxr-xr-xindex.php34
1 files changed, 21 insertions, 13 deletions
diff --git a/index.php b/index.php
index a27f1993..4fdc5736 100755
--- a/index.php
+++ b/index.php
@@ -22,6 +22,9 @@
22 * afficher liens mis en favoris et archivés 22 * afficher liens mis en favoris et archivés
23 * tri des liens 23 * tri des liens
24 */ 24 */
25require_once dirname(__FILE__).'/inc/Readability.php';
26require_once dirname(__FILE__).'/inc/Encoding.php';
27include dirname(__FILE__).'/inc/functions.php';
25 28
26try 29try
27{ 30{
@@ -39,8 +42,21 @@ $id = (isset ($_GET['id'])) ? htmlspecialchars($_GET['id']) : '';
39 42
40switch ($action) { 43switch ($action) {
41 case 'add': 44 case 'add':
42 $url = (isset ($_GET['url'])) ? htmlspecialchars($_GET['url']) : ''; 45 $url = (isset ($_GET['url'])) ? $_GET['url'] : '';
46 $url = html_entity_decode(trim($url));
43 $title = $url; 47 $title = $url;
48 // if url use https protocol change it to http
49 if (!preg_match('!^https?://!i', $url)) $url = 'http://'.$url;
50 // convert page to utf-8
51 $html = Encoding::toUTF8(get_external_file($url,15));
52 if(isset($html) and strlen($html) > 0) {
53 // send result to readability library
54 $r = new Readability($html, $url);
55 if($r->init()) {
56 $title = $r->articleTitle->innerHTML;
57 }
58 }
59
44 $query = $db_handle->prepare('INSERT INTO entries ( url, title ) VALUES (?, ?)'); 60 $query = $db_handle->prepare('INSERT INTO entries ( url, title ) VALUES (?, ?)');
45 $query->execute(array($url, $title)); 61 $query->execute(array($url, $title));
46 break; 62 break;
@@ -53,6 +69,8 @@ switch ($action) {
53 $params_action = array($id); 69 $params_action = array($id);
54 break; 70 break;
55 case 'delete': 71 case 'delete':
72 $sql_action = "DELETE FROM entries WHERE id=?";
73 $params_action = array($id);
56 break; 74 break;
57 default: 75 default:
58 break; 76 break;
@@ -98,16 +116,6 @@ catch (Exception $e)
98 die('query error : '.$e->getMessage()); 116 die('query error : '.$e->getMessage());
99} 117}
100 118
101function url() {
102 $protocol = "http";
103 if(isset($_SERVER['HTTPS'])) {
104 if($_SERVER['HTTPS'] != "off") {
105 $protocol = "https";
106 }
107 }
108
109 return $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
110}
111?> 119?>
112<!DOCTYPE html> 120<!DOCTYPE html>
113<!--[if lte IE 6]> <html class="no-js ie6 ie67 ie678" lang="en"> <![endif]--> 121<!--[if lte IE 6]> <html class="no-js ie6 ie67 ie678" lang="en"> <![endif]-->
@@ -137,13 +145,13 @@ function url() {
137 <ul id="entries"> 145 <ul id="entries">
138 <?php 146 <?php
139 foreach ($entries as $entry) { 147 foreach ($entries as $entry) {
140 echo '<li><a href="readityourself.php?url='.urlencode($entry['url']).'">' . $entry['title'] . '</a> <a href="?action=toggle_archive&id='.$entry['id'].'" title="toggle mark as read" class="tool">&#10003;</a> <a href="?action=toggle_fav&id='.$entry['id'].'" title="toggle favorite" class="tool">'.(($entry['is_fav'] == 0) ? '&#9734;' : '&#9733;' ).'</a> <a href="#" title="toggle delete" class="tool">&#10799;</a></li>'; 148 echo '<li><a href="readityourself.php?url='.urlencode($entry['url']).'">' . $entry['title'] . '</a> <a href="?action=toggle_archive&id='.$entry['id'].'" title="toggle mark as read" class="tool">&#10003;</a> <a href="?action=toggle_fav&id='.$entry['id'].'" title="toggle favorite" class="tool">'.(($entry['is_fav'] == 0) ? '&#9734;' : '&#9733;' ).'</a> <a href="?action=delete&id='.$entry['id'].'" title="toggle delete" class="tool">&#10799;</a></li>';
141 } 149 }
142 ?> 150 ?>
143 </ul> 151 </ul>
144 </div> 152 </div>
145 <footer class="mr2 mt3"> 153 <footer class="mr2 mt3">
146 <p class="smaller"><a href="http://github.com/nicosomb/poche">poche</a> is a read it later open source system, based on <a href="http://www.memiks.fr/readityourself/">ReadItYourself</a>. poche is developed by <a href="http://nicolas.loeuillet.org">Nicolas Lœuillet</a> under the <a href="http://www.wtfpl.net/">Do What the Fuck You Want to Public License</a></p> 154 <p class="smaller"><a href="http://github.com/nicosomb/poche">poche</a> is a read it later open source system, based on <a href="http://www.memiks.fr/readityourself/">ReadItYourself</a>. poche is developed by <a href="http://nicolas.loeuillet.org">Nicolas Lœuillet</a> under the <a href="http://www.wtfpl.net/">WTFPL</a>.</p>
147 </footer> 155 </footer>
148 </body> 156 </body>
149</html> \ No newline at end of file 157</html> \ No newline at end of file