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