1 | <?php |
---|
2 | /* |
---|
3 | * Plugin Name: CoolIris-Piclens |
---|
4 | * File : generate_rss.php |
---|
5 | */ |
---|
6 | |
---|
7 | $debug = false; |
---|
8 | |
---|
9 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
10 | |
---|
11 | include (PICLENS_INC_PATH.'config_extendeddesc.inc.php'); // Parametres pour extended description. |
---|
12 | |
---|
13 | // recuperation du parametre pour le mode no recursif (forçage de la non recursivite) |
---|
14 | if (isset($_GET['norecurs'])) |
---|
15 | { |
---|
16 | $obj->my_config['piclens_recursive'] = false; |
---|
17 | } |
---|
18 | |
---|
19 | |
---|
20 | // extensions video |
---|
21 | $py_addext = array("gvideo", "dm", "ytube", "wideo", "vimeo"); |
---|
22 | $video_ext_piclens = array("flv"); |
---|
23 | |
---|
24 | // Vérification présence et activation plugin SecureImages ET si actif, vérification d'activation de compatibilité |
---|
25 | $plugins_SecureImage_only = (get_db_plugins('active','secureImages') ? true : false ); |
---|
26 | $plugins_SecureImage = ($plugins_SecureImage_only && ($obj->my_config['piclens_secureimage']) ? true : false ); |
---|
27 | // Verification presence et activation plugin ExtendedDescription |
---|
28 | $plugins_ExtendedDesc = (get_db_plugins('active','ExtendedDescription') && ($obj->my_config['piclens_extendeddesc']) ? true : false ); |
---|
29 | |
---|
30 | |
---|
31 | // Vérification d'activation du plugin (page administration) OU activation de piclensWall |
---|
32 | if ($obj->my_config['piclens_active'] OR $obj->my_config['piclens_wall'] OR (!$obj->my_config['piclens_wall'] AND get_db_plugins('active','PWG_Stuffs'))) |
---|
33 | { |
---|
34 | //-------------------------------------------------------------- initialization |
---|
35 | |
---|
36 | // Mode des miniatures et des images normales dans piclens (avec et sans plugin secureimage) |
---|
37 | $thumb_secure = array('', '&thumb=1', ''); // correspondant a 1-->'miniature' et 2-->'normal' |
---|
38 | $normal_secure = array('', '&thumb=1', '', '&highdef=1'); // correspondant a 1-->'miniature' et 2-->'normal' et 3 --> High |
---|
39 | $order_list = array('', $conf['order_by_inside_category'], 'ORDER BY date_creation', 'ORDER BY date_available', 'ORDER BY average_rate', 'ORDER BY hit', 'ORDER BY file', 'ORDER BY id', 'ORDER BY RAND()', 'ORDER BY category_id'); |
---|
40 | $order_sort = array('', '', ' ASC', ' DESC'); |
---|
41 | |
---|
42 | // Extensions a prendre en compte |
---|
43 | $tn_ext_is_null = false; |
---|
44 | $type_ext = $obj->my_config['included_file_types']; |
---|
45 | foreach($type_ext as $i => $value) |
---|
46 | { |
---|
47 | if ($value == '!NULL!') $tn_ext_is_null = true; |
---|
48 | $type_ext[$i] = '"'.($value == '!NULL!' ? 'NULL' : $value).'"'; |
---|
49 | } |
---|
50 | |
---|
51 | // Categories a prendre en compte pour le mur |
---|
52 | $piclenswall_cat = (isset($obj->my_config['piclens_wall_categories']) ? $obj->my_config['piclens_wall_categories'] : array()); |
---|
53 | |
---|
54 | // Seulement sur une page type 'categorie' |
---|
55 | if (isset($page['section'])) |
---|
56 | { |
---|
57 | $cat = array(); |
---|
58 | $pictures = array(); |
---|
59 | |
---|
60 | $forbidden = get_sql_condition_FandF( |
---|
61 | array |
---|
62 | ( |
---|
63 | 'forbidden_categories' => 'category_id', |
---|
64 | 'visible_categories' => 'category_id', |
---|
65 | 'visible_images' => 'id' |
---|
66 | ), |
---|
67 | 'AND' |
---|
68 | ); |
---|
69 | |
---|
70 | // Images recentes |
---|
71 | if (($page['section']) == 'recent_pics') |
---|
72 | { |
---|
73 | if ( !isset($page['super_order_by']) ) |
---|
74 | { |
---|
75 | $conf['order_by'] = str_replace( |
---|
76 | 'ORDER BY ', |
---|
77 | 'ORDER BY date_available DESC,', |
---|
78 | $conf['order_by'] |
---|
79 | ); |
---|
80 | } |
---|
81 | // $cat need to bo not null... |
---|
82 | array_push($cat, "1"); |
---|
83 | |
---|
84 | $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name, |
---|
85 | img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path, |
---|
86 | img.level ' |
---|
87 | .' FROM ' . IMAGES_TABLE.' AS img' |
---|
88 | .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id' |
---|
89 | .' WHERE |
---|
90 | img.date_available >= SUBDATE( |
---|
91 | CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY) ' |
---|
92 | .$forbidden |
---|
93 | .' '.$conf['order_by'].';'; |
---|
94 | } |
---|
95 | // Plus vues |
---|
96 | elseif ($page['section'] == 'recent_cats') |
---|
97 | { |
---|
98 | // $cat need to bo not null... |
---|
99 | array_push($cat, "1"); |
---|
100 | |
---|
101 | $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name, |
---|
102 | img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path, |
---|
103 | img.level, ic.category_id, cat.name AS catname, cat.comment AS catcomment, cat.rank, cat.status, |
---|
104 | cat.visible, cat.uppercats, cat.permalink, cat.dir ' |
---|
105 | .' FROM ' . IMAGES_TABLE.' AS img' |
---|
106 | .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id' |
---|
107 | .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id' |
---|
108 | .' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' ON cat.id = cat_id and user_id = '.$user['id'] |
---|
109 | .' WHERE date_last >= SUBDATE( |
---|
110 | CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY |
---|
111 | ) |
---|
112 | '.get_sql_condition_FandF |
---|
113 | ( |
---|
114 | array('visible_categories' => 'id',), |
---|
115 | 'AND' |
---|
116 | ).' |
---|
117 | ;'; |
---|
118 | } |
---|
119 | |
---|
120 | // Plus vues |
---|
121 | elseif ($page['section'] == 'most_visited') |
---|
122 | { |
---|
123 | // $cat need to bo not null... |
---|
124 | array_push($cat, "1"); |
---|
125 | $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name, |
---|
126 | img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path, |
---|
127 | img.level, ic.category_id, cat.name AS catname, cat.comment AS catcomment, cat.rank, cat.status, |
---|
128 | cat.visible, cat.uppercats, cat.permalink, cat.dir ' |
---|
129 | .' FROM ' . IMAGES_TABLE.' AS img' |
---|
130 | .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id' |
---|
131 | .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id' |
---|
132 | .' WHERE img.hit > 0 ' |
---|
133 | .$forbidden |
---|
134 | .' ORDER BY hit DESC, file ASC' |
---|
135 | .' LIMIT 0, '.$conf['top_number'].';'; |
---|
136 | |
---|
137 | } |
---|
138 | // mieux notees |
---|
139 | elseif ($page['section'] == 'best_rated') |
---|
140 | { |
---|
141 | // $cat need to bo not null... |
---|
142 | array_push($cat, "1"); |
---|
143 | |
---|
144 | $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name, |
---|
145 | img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path, |
---|
146 | img.level ' |
---|
147 | .' FROM ' . IMAGES_TABLE.' AS img' |
---|
148 | .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id' |
---|
149 | .' WHERE img.average_rate IS NOT NULL ' |
---|
150 | .$forbidden |
---|
151 | .' ORDER BY average_rate DESC, id ASC' |
---|
152 | .' LIMIT 0, '.$conf['top_number'].';'; |
---|
153 | } |
---|
154 | elseif ($page['section'] == 'favorites') |
---|
155 | { |
---|
156 | check_user_favorites(); |
---|
157 | // $cat need to bo not null... |
---|
158 | array_push($cat, "1"); |
---|
159 | |
---|
160 | $query = 'SELECT img.id, img.file, img.date_available, img.date_creation, img.tn_ext, img.name, |
---|
161 | img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path, |
---|
162 | img.level, ' |
---|
163 | .' FROM '.FAVORITES_TABLE.' AS fav ' |
---|
164 | .' INNER JOIN '.IMAGES_TABLE.' AS img ON fav.image_id = img.id' |
---|
165 | .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id' |
---|
166 | .' WHERE user_id = '.$user['id'] |
---|
167 | .' '.get_sql_condition_FandF |
---|
168 | ( |
---|
169 | array('visible_images' => 'id'), |
---|
170 | 'AND' |
---|
171 | ) |
---|
172 | .' '.$conf['order_by'].';'; |
---|
173 | } |
---|
174 | |
---|
175 | // Gestion des tags |
---|
176 | elseif (($page['section']) == 'tags') |
---|
177 | { |
---|
178 | // $row = get_image_ids_for_tags($page['tags_id']); |
---|
179 | // $cat need to bo not null... |
---|
180 | array_push($cat, "1"); |
---|
181 | $query = 'SELECT DISTINCT(tag.image_id) , img.id, img.file, img.date_available, img.date_creation, img.tn_ext, img.name, |
---|
182 | img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path, |
---|
183 | img.level , ic.category_id, cat.name AS catname, cat.comment AS catcomment, cat.rank, cat.status, |
---|
184 | cat.visible, cat.uppercats, cat.permalink, cat.dir ' |
---|
185 | .' FROM '.IMAGE_TAG_TABLE.' AS tag '."\n" |
---|
186 | .' INNER JOIN '.IMAGES_TABLE.' AS img ON tag.image_id = img.id' |
---|
187 | .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id' |
---|
188 | .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id' |
---|
189 | .' WHERE tag.tag_id IN ('.implode(',', $page['tag_ids']).') ' |
---|
190 | .$forbidden |
---|
191 | .' '.$conf['order_by'].';'; |
---|
192 | } |
---|
193 | |
---|
194 | |
---|
195 | elseif (($page['section']) == 'categories') |
---|
196 | { |
---|
197 | // Accueil |
---|
198 | if(empty($page['category'])) |
---|
199 | { |
---|
200 | // Page accueil |
---|
201 | // Vérification d'activation du plugin (page administration) |
---|
202 | // ou flux pour piclenswall et configuration specifique |
---|
203 | if ($obj->my_config['piclens_gallerie_active'] || $piclenswallfeed) |
---|
204 | { |
---|
205 | // Categories de premier niveau |
---|
206 | $query = 'SELECT id,name,permalink FROM ' . CATEGORIES_TABLE |
---|
207 | .' WHERE id_uppercat is NULL'; |
---|
208 | |
---|
209 | $result = pwg_query($query); |
---|
210 | |
---|
211 | while ($row = mysql_fetch_assoc($result)) |
---|
212 | { |
---|
213 | if (!(in_array($row['id'], explode(',', $user['forbidden_categories'])))) |
---|
214 | { |
---|
215 | array_push($cat, $row['id']); |
---|
216 | |
---|
217 | } |
---|
218 | } |
---|
219 | // Type = avec recursiite |
---|
220 | // Si parametrage specifique pour le mur 3D, recursivite sur les categories |
---|
221 | if (($piclenswallfeed) || (( $obj->my_config['piclens_gallerie_type'])-1)) |
---|
222 | { |
---|
223 | // recuperation des sous-categories (tous niveaux) de la categorie en cours. |
---|
224 | $subcat= get_subcat_ids($cat); |
---|
225 | |
---|
226 | // Verification droits des sous-categories |
---|
227 | foreach($subcat as $sscat) |
---|
228 | { |
---|
229 | if (!(in_array($sscat, explode(',', $user['forbidden_categories'])))) |
---|
230 | array_push($cat, $sscat); |
---|
231 | } |
---|
232 | } |
---|
233 | |
---|
234 | // selection uniquement des categories a afficher (si flux pour le mur ET parametre mur = specifique) |
---|
235 | if ($piclenswallfeed) |
---|
236 | { |
---|
237 | foreach($cat as $i => $wcat) |
---|
238 | { |
---|
239 | if (!in_array($wcat, $piclenswall_cat)) |
---|
240 | unset($cat[$i]); |
---|
241 | } |
---|
242 | } |
---|
243 | |
---|
244 | $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name, |
---|
245 | img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path, |
---|
246 | img.level, ic.category_id, cat.name AS catname, cat.comment AS catcomment, cat.rank, cat.status, |
---|
247 | cat.visible, cat.uppercats, cat.permalink, cat.dir ' |
---|
248 | .' FROM ' . IMAGES_TABLE.' AS img' |
---|
249 | .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id' |
---|
250 | .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id' |
---|
251 | .' WHERE ic.category_id IN ('.implode(',', $cat).')' |
---|
252 | .(sizeof($obj->my_config['included_file_types']) ? ' AND (img.tn_ext IN ('.implode(',', $type_ext).')' : '') |
---|
253 | .($tn_ext_is_null ? ' OR img.tn_ext IS NULL)' : (sizeof($obj->my_config['included_file_types']) ? ')' : '')) |
---|
254 | // Verif droits (niveaux) de l'utilisateur sur les images |
---|
255 | .' AND img.level <='.$user['level'].' ' |
---|
256 | // Choix du critere de tri d'affichage |
---|
257 | .$order_list[ $obj->my_config['piclens_order'] ] |
---|
258 | .$order_sort[ $obj->my_config['piclens_sort'] ]; |
---|
259 | |
---|
260 | |
---|
261 | } |
---|
262 | } |
---|
263 | |
---|
264 | // Page category |
---|
265 | elseif (isset($page['category'])) |
---|
266 | { |
---|
267 | check_restrictions($page['category']['id']); |
---|
268 | |
---|
269 | // Flux pour le mur 3D et mur en mode "specifique" |
---|
270 | if ($piclenswallfeed) |
---|
271 | { |
---|
272 | $selectionID = $page['category']['id']; |
---|
273 | // categorie parametre pour etre affichee dans le mur |
---|
274 | if (in_array($selectionID, $piclenswall_cat)) |
---|
275 | array_push($cat, $selectionID); |
---|
276 | |
---|
277 | // recuperation des sous-categories (tous niveaux) de la categorie en cours. |
---|
278 | $subcat= get_subcat_ids(array($selectionID)); |
---|
279 | |
---|
280 | // Verification ajout des sous-categories qui peuvent être affichees (parametrees dans mur 3D) et des drois des sous categories |
---|
281 | foreach($subcat as $sscat) |
---|
282 | { |
---|
283 | if ((in_array($sscat, $piclenswall_cat)) && (!(in_array($sscat, explode(',', $user['forbidden_categories']))))) |
---|
284 | array_push($cat, $sscat); |
---|
285 | } |
---|
286 | |
---|
287 | } |
---|
288 | // Piclens (et mur 3D avec meme parametrage que piclens) : paramétrage "commun" |
---|
289 | else |
---|
290 | { |
---|
291 | // recherche de toutes les photos de la categorie (incluant les photos des sous-categories si necessaire) |
---|
292 | $selectionID = $page['category']['id']; |
---|
293 | |
---|
294 | array_push($cat, $selectionID); |
---|
295 | |
---|
296 | // Si recursivite activee |
---|
297 | if ($obj->my_config['piclens_recursive']) |
---|
298 | { |
---|
299 | // recuperation des sous-categories (tous niveaux) de la categorie en cours. |
---|
300 | $subcat= get_subcat_ids(array($selectionID)); |
---|
301 | |
---|
302 | // Verification droits des sous-categories |
---|
303 | foreach($subcat as $sscat) |
---|
304 | { |
---|
305 | if (!(in_array($sscat, explode(',', $user['forbidden_categories'])))) |
---|
306 | array_push($cat, $sscat); |
---|
307 | } |
---|
308 | |
---|
309 | } |
---|
310 | } |
---|
311 | |
---|
312 | $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name, |
---|
313 | img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path, |
---|
314 | img.level, ic.category_id, cat.name AS catname, cat.comment AS catcomment, cat.rank, cat.status, |
---|
315 | cat.visible, cat.uppercats, cat.permalink, cat.dir ' |
---|
316 | .' FROM ' . IMAGES_TABLE.' AS img' |
---|
317 | .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id' |
---|
318 | .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id' |
---|
319 | .' WHERE ic.category_id IN ('.implode(',', $cat).')' |
---|
320 | .(sizeof($obj->my_config['included_file_types']) ? ' AND (img.tn_ext IN ('.implode(',', $type_ext).')' : '') |
---|
321 | .($tn_ext_is_null ? ' OR img.tn_ext IS NULL)' : (sizeof($obj->my_config['included_file_types']) ? ')' : '')) |
---|
322 | // Verif droits (niveaux) de l'utilisateur sur les images |
---|
323 | .' AND img.level <='.$user['level'].' ' |
---|
324 | // Choix du critere de tri d'affichage |
---|
325 | .$order_list[ $obj->my_config['piclens_order_cat'] ] |
---|
326 | .$order_sort[ $obj->my_config['piclens_sort_cat'] ]; |
---|
327 | |
---|
328 | } |
---|
329 | } |
---|
330 | |
---|
331 | if ($debug) echo $query; |
---|
332 | |
---|
333 | // Si au moins une image récupérée (une catégorie ou une image présente) |
---|
334 | if (count($cat)!=0) |
---|
335 | { |
---|
336 | $result = pwg_query($query); |
---|
337 | |
---|
338 | while ($row = mysql_fetch_assoc($result)) |
---|
339 | { |
---|
340 | // Plugin Extended Description present et active |
---|
341 | // suppression des categories et images pour lesquelles un <!--hidden--> est present |
---|
342 | if (!$plugins_ExtendedDesc |
---|
343 | OR ($plugins_ExtendedDesc |
---|
344 | && !(substr_count($row['name'], $piclens_extdesc_hidden)) |
---|
345 | && ((isset($row['catname']) ? !(substr_count($row['catname'], $piclens_extdesc_hidden)) : true)) |
---|
346 | )) |
---|
347 | { |
---|
348 | // Suppression des doublons (même path) |
---|
349 | if ($obj->my_config['piclens_exclude_double']) |
---|
350 | { |
---|
351 | $double = false; |
---|
352 | foreach ($pictures as $key => $values) |
---|
353 | // même path |
---|
354 | if ($row['path'] == $values['path']) |
---|
355 | $double=true; |
---|
356 | |
---|
357 | // pas de double trouvé |
---|
358 | if (!$double) |
---|
359 | array_push($pictures, $row); |
---|
360 | } |
---|
361 | else |
---|
362 | array_push($pictures, $row); |
---|
363 | } |
---|
364 | } |
---|
365 | } |
---|
366 | // Fin requetes recherches photos |
---|
367 | |
---|
368 | |
---|
369 | // Creation du fichier xml (flux rss) |
---|
370 | // It's a rss file |
---|
371 | header("Content-Type: application/xml; charset=UTF-8"); |
---|
372 | echo '<?xml version="1.0" encoding="utf-8" standalone="yes"?>'; |
---|
373 | echo "\n"; |
---|
374 | echo '<rss version="2.0" '."\n" |
---|
375 | .'xmlns:media="http://search.yahoo.com/mrss/" '."\n" |
---|
376 | .'xmlns:atom="http://www.w3.org/2005/Atom">'; |
---|
377 | echo "\n"; |
---|
378 | echo '<channel>'; |
---|
379 | echo "\n"; |
---|
380 | |
---|
381 | // <!-- <title>test Page</title> --> |
---|
382 | echo '<link>'.$obj->root_site_piclens.'</link>'; |
---|
383 | echo "\n"; |
---|
384 | echo '<description>Flux RSS pour cooliris</description>'; |
---|
385 | echo "\n"; |
---|
386 | echo '<language>fr</language>'; |
---|
387 | echo "\n"; |
---|
388 | |
---|
389 | // Version du plugin Piclens |
---|
390 | $db_plugins = get_db_plugins('', 'piclens'); |
---|
391 | if (!empty($db_plugins)) |
---|
392 | $piclens_version = $db_plugins[0]['version']; |
---|
393 | else |
---|
394 | $piclens_version = 'N/A'; |
---|
395 | |
---|
396 | echo '<generator>Piwigo Cooliris Plugin v.'.$piclens_version.'</generator>'; |
---|
397 | echo "\n"; |
---|
398 | |
---|
399 | // Icone de la gallerie dans le flux RSS |
---|
400 | echo "\n"; |
---|
401 | echo '<atom:icon>'.$obj->root_site_piclens.'template-common/favicon.ico</atom:icon>'; |
---|
402 | echo "\n"; |
---|
403 | |
---|
404 | // Pour chacune des images, preparation du flux xml |
---|
405 | foreach ($pictures as $row) |
---|
406 | { |
---|
407 | // Mode de l'image parametre |
---|
408 | $piclens_normal = $obj->my_config['piclens_normal']; |
---|
409 | |
---|
410 | // si parametrage high et high absente ou utilisateur non habilite, affichage version normale |
---|
411 | if (($piclens_normal == 3) && (!($row['has_high']) || !$user['enabled_high'])) |
---|
412 | $piclens_normal = 2; // Normal uniquement pour l'image en cours |
---|
413 | |
---|
414 | // Get thumbnail url |
---|
415 | if ($plugins_SecureImage) // SecureImage installe et actif |
---|
416 | { |
---|
417 | $link_url = $obj->root_site_piclens.'plugins/secureImages/getFile.php?image_id='.$row['id']; |
---|
418 | |
---|
419 | $thumbnail_url = $obj->root_site_piclens.'plugins/secureImages/getFile.php?image_id='.$row['id'] |
---|
420 | .$thumb_secure[$obj->my_config['piclens_thumb'] ]; |
---|
421 | $content_url = $obj->root_site_piclens.'plugins/secureImages/getFile.php?image_id='.$row['id'] |
---|
422 | .$normal_secure[$piclens_normal ]; |
---|
423 | } |
---|
424 | else // SecureImage non installe ou non actif |
---|
425 | { |
---|
426 | $link_url = $obj->root_site_piclens.$row['path']; |
---|
427 | |
---|
428 | if ( ($obj->my_config['piclens_thumb']) == 2) // Normal |
---|
429 | $thumbnail_url = (url_is_remote($row['path']) ? $row['path']: embellish_url($obj->root_site_piclens.$row['path'])); |
---|
430 | else |
---|
431 | { |
---|
432 | if ($plugins_SecureImage_only) // Plugin secureimage active mais configuration compatibilite piclens-secureimage desactivee |
---|
433 | { |
---|
434 | $path=get_thumbnail_location($row); |
---|
435 | $thumbnail_url = ( url_is_remote($path) ? $path : embellish_url($obj->root_site_piclens.$path) ); |
---|
436 | } |
---|
437 | else // Plugin secureimage desactive |
---|
438 | { |
---|
439 | $thumbnail_url = embellish_url($obj->root_site_piclens.get_thumbnail_location($row)); |
---|
440 | } |
---|
441 | } |
---|
442 | |
---|
443 | switch ($piclens_normal) |
---|
444 | { |
---|
445 | case 1 : // miniature |
---|
446 | if ($plugins_SecureImage_only) // Plugin secureimage active mais configuration compatibilite piclens-secureimage desactivee |
---|
447 | { |
---|
448 | $path=get_thumbnail_location($row); |
---|
449 | $content_url = ( url_is_remote($path) ? $path : embellish_url($obj->root_site_piclens.$path) ); |
---|
450 | } |
---|
451 | else // Plugin secureimage desactive |
---|
452 | { |
---|
453 | $content_url = embellish_url($obj->root_site_piclens.get_thumbnail_location($row));; |
---|
454 | } |
---|
455 | break; |
---|
456 | case 2 : // normal |
---|
457 | $content_url = (url_is_remote($row['path']) ? $row['path']: embellish_url($obj->root_site_piclens.$row['path'])); |
---|
458 | break; |
---|
459 | case 3 : |
---|
460 | $content_url = (url_is_remote($row['path']) ? dirname($row['path']).'/pwg_high/'.basename($row['path']) |
---|
461 | : embellish_url( $obj->root_site_piclens. dirname($row['path']).'/pwg_high/'.basename($row['path'])) |
---|
462 | ); |
---|
463 | break; |
---|
464 | default : // normal |
---|
465 | $content_url = (url_is_remote($row['path']) ? $row['path'] : embellish_url($obj->root_site_piclens.$row['path'])); |
---|
466 | break; |
---|
467 | } |
---|
468 | } |
---|
469 | |
---|
470 | // link on picture.php page |
---|
471 | set_make_full_url(); |
---|
472 | if ( isset($row['category_id']) & isset($row['catname']) ) |
---|
473 | { |
---|
474 | $url = duplicate_picture_url( |
---|
475 | array( |
---|
476 | 'image_id' => $row['id'], |
---|
477 | 'image_file' => $row['file'], |
---|
478 | 'category' => array( |
---|
479 | 'id' => $row['category_id'], |
---|
480 | 'name' => $row['catname'], |
---|
481 | 'permalink' => '' |
---|
482 | ) |
---|
483 | ), |
---|
484 | array('start') |
---|
485 | ); |
---|
486 | } |
---|
487 | else |
---|
488 | { |
---|
489 | $url = duplicate_picture_url( |
---|
490 | array( |
---|
491 | 'image_id' => $row['id'], |
---|
492 | 'image_file' => $row['file'] |
---|
493 | ), |
---|
494 | array('start') |
---|
495 | ); |
---|
496 | } |
---|
497 | unset_make_full_url(); |
---|
498 | |
---|
499 | // HTTPS Patch : If needed NO_https can easily be set in your config_local thru LocalFiles Editor |
---|
500 | if (isset($conf['NO_https']) and $conf['NO_https'] and strncasecmp($url, 'https://', 8) == 0 ) |
---|
501 | $url = 'http://' . substr($url, 8); |
---|
502 | |
---|
503 | // Show rss item for a picture |
---|
504 | echo "<item>\n"; |
---|
505 | |
---|
506 | |
---|
507 | |
---|
508 | echo "<title><![CDATA[" |
---|
509 | .parse($obj->my_config['piclens_rss_name'], $row, $plugins_ExtendedDesc, $obj->my_config['piclens_maxcomment_nb']) |
---|
510 | ."]]></title>\n"; |
---|
511 | |
---|
512 | |
---|
513 | echo '<media:description type="html"><![CDATA[' |
---|
514 | .parse($obj->my_config['piclens_rss_desc'], $row, $plugins_ExtendedDesc, $obj->my_config['piclens_maxcomment_nb']) |
---|
515 | .']]> </media:description>'; |
---|
516 | |
---|
517 | /* |
---|
518 | // Extended description for the comment and category name |
---|
519 | if ($plugins_ExtendedDesc) // Extended description compatibility |
---|
520 | { |
---|
521 | if (isset($row['catname'])) |
---|
522 | $row['catname'] = trigger_event('render_element_description',$row['catname']); |
---|
523 | if (isset($row['comment'])) |
---|
524 | $row['comment'] = trigger_event('render_element_description',$row['comment']); |
---|
525 | } |
---|
526 | |
---|
527 | |
---|
528 | // Titre de l'image dans Piclens |
---|
529 | switch($obj->my_config['piclens_name_image']) |
---|
530 | { |
---|
531 | case 2 : |
---|
532 | // format nom fichier |
---|
533 | echo "<title><![CDATA[" |
---|
534 | .(($obj->my_config['piclens_cat_view'] && isset ($row['catname'])) ? $row['catname']." - " : "") |
---|
535 | . $row['file'] . "]]></title>\n"; |
---|
536 | break; |
---|
537 | case 3 : |
---|
538 | // format nom de la photo |
---|
539 | if (isset($row['name'])) |
---|
540 | echo "<title><![CDATA[" |
---|
541 | .(($obj->my_config['piclens_cat_view'] && isset ($row['catname'])) ? $row['catname']." - " : "") |
---|
542 | .$row['name']."]]></title>\n"; |
---|
543 | else |
---|
544 | echo "<title><![CDATA[" |
---|
545 | .(($obj->my_config['piclens_cat_view'] && isset ($row['catname'])) ? $row['catname']." - " : "") |
---|
546 | . $row['file'] . "]]></title>\n"; |
---|
547 | break; |
---|
548 | default : |
---|
549 | // format nom fichier : taille |
---|
550 | echo "<title><![CDATA[" |
---|
551 | .(($obj->my_config['piclens_cat_view'] && isset ($row['catname'])) ? $row['catname']." - " : "") |
---|
552 | . get_thumbnail_title($row) . "]]></title>\n"; |
---|
553 | break; |
---|
554 | } |
---|
555 | |
---|
556 | // Description (nom de vignette) present |
---|
557 | switch($obj->my_config['piclens_name_desc']) |
---|
558 | { |
---|
559 | case 2 : |
---|
560 | if (isset($row['name'])) |
---|
561 | echo '<media:description type="html"><![CDATA['.$row['name'].']]> </media:description>'; |
---|
562 | break; |
---|
563 | case 3 : |
---|
564 | if (isset($row['comment'])) |
---|
565 | echo '<media:description type="html"><![CDATA['.$row['comment'].']]> </media:description>'; |
---|
566 | break; |
---|
567 | default : |
---|
568 | break; |
---|
569 | } |
---|
570 | */ |
---|
571 | echo "\n"; |
---|
572 | |
---|
573 | // link |
---|
574 | echo "<link>" . $url . "</link>\n"; |
---|
575 | |
---|
576 | echo "<guid isPermaLink=\"false\">\"" . $row['id'] . "\"</guid>\n"; |
---|
577 | |
---|
578 | |
---|
579 | echo "<media:thumbnail url=\"" . $thumbnail_url . "\" />\n"; |
---|
580 | |
---|
581 | $extension = explode(".", $row['file']); |
---|
582 | $extension = $extension[sizeof($extension)-1]; |
---|
583 | |
---|
584 | // Fichiers video (Charlies content) |
---|
585 | if ((in_array($extension, $video_ext_piclens))) |
---|
586 | { |
---|
587 | if ($obj->my_config['piclens_video']) // activation des videos |
---|
588 | { |
---|
589 | switch ($extension) |
---|
590 | { |
---|
591 | case "flv": |
---|
592 | echo "<media:content type=\"video/x-flv\" url=\"".$content_url."\"/>\n"; |
---|
593 | break; |
---|
594 | } |
---|
595 | } |
---|
596 | else |
---|
597 | { |
---|
598 | echo "<media:content url=\"" . $thumbnail_url . "\" />\n"; |
---|
599 | } |
---|
600 | } |
---|
601 | // Fichiers video (PY Gvideo) |
---|
602 | elseif ((in_array($extension, $py_addext))) |
---|
603 | { |
---|
604 | if ($obj->my_config['piclens_video']) // activation des videos |
---|
605 | { |
---|
606 | // Si impossibilite de lire le fichier! |
---|
607 | if( false == ($idvideo = file_get_contents(PHPWG_ROOT_PATH.$row['path']))) |
---|
608 | { |
---|
609 | echo "<media:content url=\"" . $thumbnail_url . "\" />\n"; |
---|
610 | } |
---|
611 | else |
---|
612 | { |
---|
613 | $sp = explode("/", $idvideo); |
---|
614 | switch ($extension) |
---|
615 | { |
---|
616 | case "dm" : |
---|
617 | echo "<enclosure url=\"http://www.dailymotion.com/swf/".$sp[0]."\" type=\"application/x-shockwave-flash\" />\n"; |
---|
618 | break; |
---|
619 | case "ytube": |
---|
620 | echo "<enclosure url=\"http://youtube.com/v/".$sp[0].".swf\" type=\"application/x-shockwave-flash\" />\n"; |
---|
621 | break; |
---|
622 | case "wideo": |
---|
623 | echo "<enclosure url=\"http://www.kewego.com/swf/p3/epix.swf?language_code=fr&playerKey=0df9b773a15b&skinKey=7109c4112f57&sig=".$sp[0]."\" type=\"application/x-shockwave-flash\" />\n"; |
---|
624 | break; |
---|
625 | case "gvideo": |
---|
626 | echo "<enclosure url=\"http://video.google.com/googleplayer.swf?docid=".$sp[0]."\" type=\"application/x-shockwave-flash\" />\n"; |
---|
627 | break; |
---|
628 | case "vimeo": |
---|
629 | echo "<enclosure url=\"http://vimeo.com/moogaloop.swf?clip_id=".$sp[0]."\" type=\"application/x-shockwave-flash\" />\n"; |
---|
630 | break; |
---|
631 | } |
---|
632 | } |
---|
633 | } |
---|
634 | else |
---|
635 | { |
---|
636 | echo "<media:content url=\"" . $thumbnail_url . "\" />\n"; |
---|
637 | } |
---|
638 | } |
---|
639 | // Images (standard) |
---|
640 | else |
---|
641 | echo "<media:content url=\"" . $content_url . "\" />\n"; |
---|
642 | |
---|
643 | echo "</item>\n"; |
---|
644 | echo "\n"; |
---|
645 | } |
---|
646 | echo "</channel>\n"; |
---|
647 | echo "</rss>"; |
---|
648 | } |
---|
649 | |
---|
650 | } |
---|
651 | |
---|
652 | // parse the configuration to complete with the correct informations |
---|
653 | function parse($data, $row, $plugins_ExtendedDesc = false, $nb_comment = 0) |
---|
654 | { |
---|
655 | |
---|
656 | // Eviter de charger les commentaires (appels base) si ils ne sont pas affichés |
---|
657 | if (strpos($data, '%ID') === false) |
---|
658 | $nb_comment = 0; |
---|
659 | |
---|
660 | include (PICLENS_PATH.'include/config_param.inc.php'); |
---|
661 | |
---|
662 | $patterns = array(); |
---|
663 | $replacements = array(); |
---|
664 | foreach ($piclens_parse as $key => $value) |
---|
665 | { |
---|
666 | array_push($patterns, $key); |
---|
667 | array_push($replacements, $value); |
---|
668 | } |
---|
669 | |
---|
670 | return str_replace($patterns, $replacements, $data); |
---|
671 | } |
---|
672 | |
---|
673 | // Return the last comments of an image id |
---|
674 | function get_comment($img_id, $nb_comment = 0) |
---|
675 | { |
---|
676 | $commentstring = ''; |
---|
677 | |
---|
678 | if ($nb_comment != 0) |
---|
679 | { |
---|
680 | $query = ' |
---|
681 | SELECT id,author,date,image_id,content |
---|
682 | FROM '.COMMENTS_TABLE.' |
---|
683 | WHERE image_id = '.$img_id.' |
---|
684 | AND validated = \'true\' |
---|
685 | ORDER BY date ASC |
---|
686 | LIMIT 0,'.$nb_comment.' |
---|
687 | ;'; |
---|
688 | $result = pwg_query( $query ); |
---|
689 | $first = true; |
---|
690 | |
---|
691 | while ($row = mysql_fetch_array($result)) |
---|
692 | { |
---|
693 | |
---|
694 | // Format : "Commentaire (Utilisateur - Date)" |
---|
695 | $commentstring .= ($first ? '' : " / \n") |
---|
696 | .trigger_event('render_comment_content',$row['content']) |
---|
697 | .' ('. trigger_event('render_comment_author', |
---|
698 | empty($row['author']) |
---|
699 | ? l10n('guest') |
---|
700 | : $row['author']) |
---|
701 | .' - ' |
---|
702 | .format_date( $row['date'], false) |
---|
703 | .")"; |
---|
704 | |
---|
705 | $first = false; |
---|
706 | |
---|
707 | } |
---|
708 | } |
---|
709 | return $commentstring; |
---|
710 | } |
---|
711 | |
---|
712 | ?> |
---|