aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/functions.php
diff options
context:
space:
mode:
authornicosomb <nicolas@loeuillet.org>2013-04-16 11:52:25 +0200
committernicosomb <nicolas@loeuillet.org>2013-04-16 11:52:25 +0200
commit139769aa245fd58d032cb009303b0ea2cc4187cd (patch)
tree5a69fec8dedb380e034b318a4fb16e0c664c2545 /inc/functions.php
parent643e3037e6e63befb2cec20f7986f14480d4ae4b (diff)
downloadwallabag-139769aa245fd58d032cb009303b0ea2cc4187cd.tar.gz
wallabag-139769aa245fd58d032cb009303b0ea2cc4187cd.tar.zst
wallabag-139769aa245fd58d032cb009303b0ea2cc4187cd.zip
stockage de la vue et du tri en session
Diffstat (limited to 'inc/functions.php')
-rwxr-xr-xinc/functions.php49
1 files changed, 41 insertions, 8 deletions
diff --git a/inc/functions.php b/inc/functions.php
index 3ee238dd..a7430585 100755
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -46,9 +46,9 @@ function get_external_file($url, $timeout)
46 46
47 // create http context and add timeout and user-agent 47 // create http context and add timeout and user-agent
48 $context = stream_context_create(array('http'=>array('timeout' => $timeout, // Timeout : time until we stop waiting for the response. 48 $context = stream_context_create(array('http'=>array('timeout' => $timeout, // Timeout : time until we stop waiting for the response.
49 'header'=> "User-Agent: ".$useragent, // spoot Mozilla Firefox 49 'header'=> "User-Agent: ".$useragent, // spoot Mozilla Firefox
50 'follow_location' => true 50 'follow_location' => true
51 ))); 51 )));
52 52
53 // only download page lesser than 4MB 53 // only download page lesser than 4MB
54 $data = @file_get_contents($url, false, $context, -1, 4000000); // We download at most 4 MB from source. 54 $data = @file_get_contents($url, false, $context, -1, 4000000); // We download at most 4 MB from source.
@@ -146,6 +146,20 @@ function action_to_do($action, $id, $url, $token)
146 } 146 }
147 else die('CSRF problem'); 147 else die('CSRF problem');
148 break; 148 break;
149 case 'toggle_fav' :
150 if (verif_token($token)) {
151 $sql_action = "UPDATE entries SET is_fav=~is_fav WHERE id=?";
152 $params_action = array($id);
153 }
154 else die('CSRF problem');
155 break;
156 case 'toggle_archive' :
157 if (verif_token($token)) {
158 $sql_action = "UPDATE entries SET is_read=~is_read WHERE id=?";
159 $params_action = array($id);
160 }
161 else die('CSRF problem');
162 break;
149 default: 163 default:
150 break; 164 break;
151 } 165 }
@@ -168,22 +182,41 @@ function action_to_do($action, $id, $url, $token)
168/** 182/**
169 * Détermine quels liens afficher : home, fav ou archives 183 * Détermine quels liens afficher : home, fav ou archives
170 */ 184 */
171function display_view($view) 185function display_view()
172{ 186{
173 global $db; 187 global $db;
174 188
175 switch ($view) 189 switch ($_SESSION['sort'])
190 {
191 case 'ia':
192 $order = 'ORDER BY id';
193 break;
194 case 'id':
195 $order = 'ORDER BY id DESC';
196 break;
197 case 'ta':
198 $order = 'ORDER BY lower(title)';
199 break;
200 case 'td':
201 $order = 'ORDER BY lower(title) DESC';
202 break;
203 default:
204 $order = 'ORDER BY id';
205 break;
206 }
207
208 switch ($_SESSION['view'])
176 { 209 {
177 case 'archive': 210 case 'archive':
178 $sql = "SELECT * FROM entries WHERE is_read=? ORDER BY id desc"; 211 $sql = "SELECT * FROM entries WHERE is_read=? " . $order;
179 $params = array(-1); 212 $params = array(-1);
180 break; 213 break;
181 case 'fav' : 214 case 'fav' :
182 $sql = "SELECT * FROM entries WHERE is_fav=? ORDER BY id desc"; 215 $sql = "SELECT * FROM entries WHERE is_fav=? " . $order;
183 $params = array(-1); 216 $params = array(-1);
184 break; 217 break;
185 default: 218 default:
186 $sql = "SELECT * FROM entries WHERE is_read=? ORDER BY id desc"; 219 $sql = "SELECT * FROM entries WHERE is_read=? " . $order;
187 $params = array(0); 220 $params = array(0);
188 break; 221 break;
189 } 222 }