[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 |
---|
[3645] | 21 | $py_addext = array("gvideo", "dm", "ytube", "wideo", "vimeo"); |
---|
[3619] | 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 |
---|
[3647] | 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', 'ORDER BY category_id, rank '); |
---|
[3619] | 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']); |
---|
[3650] | 179 | $tag_images = array(); |
---|
| 180 | |
---|
| 181 | foreach ($page['tag_ids'] as $tag_id) |
---|
| 182 | { |
---|
| 183 | $query = ' |
---|
| 184 | SELECT image_id |
---|
| 185 | FROM '.IMAGE_TAG_TABLE.' |
---|
| 186 | WHERE tag_id = '.$tag_id.' |
---|
| 187 | ;'; |
---|
| 188 | $tag_images[$tag_id] = array_from_query($query, 'image_id'); |
---|
| 189 | } |
---|
| 190 | |
---|
| 191 | // then we calculate the intersection, the images that are associated to |
---|
| 192 | // every tags |
---|
| 193 | $items = array_shift($tag_images); |
---|
| 194 | foreach ($tag_images as $images) |
---|
| 195 | { |
---|
| 196 | $items = array_intersect($items, $images); |
---|
| 197 | } |
---|
| 198 | |
---|
[3619] | 199 | // $cat need to bo not null... |
---|
| 200 | array_push($cat, "1"); |
---|
[3650] | 201 | $query = 'SELECT img.id, img.file, img.date_available, img.date_creation, img.tn_ext, img.name, |
---|
[3619] | 202 | img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path, |
---|
| 203 | img.level , ic.category_id, cat.name AS catname, cat.comment AS catcomment, cat.rank, cat.status, |
---|
| 204 | cat.visible, cat.uppercats, cat.permalink, cat.dir ' |
---|
[3650] | 205 | .' FROM '.IMAGES_TABLE.' AS img ' |
---|
[3619] | 206 | .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id' |
---|
[3650] | 207 | .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id ' |
---|
| 208 | .' WHERE img.id IN ('.implode(',', $items).') ' |
---|
| 209 | .$forbidden |
---|
[3619] | 210 | .' '.$conf['order_by'].';'; |
---|
| 211 | } |
---|
| 212 | |
---|
| 213 | |
---|
| 214 | elseif (($page['section']) == 'categories') |
---|
| 215 | { |
---|
| 216 | // Accueil |
---|
| 217 | if(empty($page['category'])) |
---|
| 218 | { |
---|
| 219 | // Page accueil |
---|
| 220 | // Vérification d'activation du plugin (page administration) |
---|
| 221 | // ou flux pour piclenswall et configuration specifique |
---|
| 222 | if ($obj->my_config['piclens_gallerie_active'] || $piclenswallfeed) |
---|
| 223 | { |
---|
| 224 | // Categories de premier niveau |
---|
| 225 | $query = 'SELECT id,name,permalink FROM ' . CATEGORIES_TABLE |
---|
| 226 | .' WHERE id_uppercat is NULL'; |
---|
| 227 | |
---|
| 228 | $result = pwg_query($query); |
---|
| 229 | |
---|
| 230 | while ($row = mysql_fetch_assoc($result)) |
---|
| 231 | { |
---|
| 232 | if (!(in_array($row['id'], explode(',', $user['forbidden_categories'])))) |
---|
| 233 | { |
---|
| 234 | array_push($cat, $row['id']); |
---|
| 235 | |
---|
| 236 | } |
---|
| 237 | } |
---|
| 238 | // Type = avec recursiite |
---|
| 239 | // Si parametrage specifique pour le mur 3D, recursivite sur les categories |
---|
| 240 | if (($piclenswallfeed) || (( $obj->my_config['piclens_gallerie_type'])-1)) |
---|
| 241 | { |
---|
| 242 | // recuperation des sous-categories (tous niveaux) de la categorie en cours. |
---|
| 243 | $subcat= get_subcat_ids($cat); |
---|
| 244 | |
---|
| 245 | // Verification droits des sous-categories |
---|
| 246 | foreach($subcat as $sscat) |
---|
| 247 | { |
---|
| 248 | if (!(in_array($sscat, explode(',', $user['forbidden_categories'])))) |
---|
| 249 | array_push($cat, $sscat); |
---|
| 250 | } |
---|
| 251 | } |
---|
| 252 | |
---|
| 253 | // selection uniquement des categories a afficher (si flux pour le mur ET parametre mur = specifique) |
---|
| 254 | if ($piclenswallfeed) |
---|
| 255 | { |
---|
| 256 | foreach($cat as $i => $wcat) |
---|
| 257 | { |
---|
| 258 | if (!in_array($wcat, $piclenswall_cat)) |
---|
| 259 | unset($cat[$i]); |
---|
| 260 | } |
---|
| 261 | } |
---|
| 262 | |
---|
| 263 | $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name, |
---|
| 264 | img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path, |
---|
| 265 | img.level, ic.category_id, cat.name AS catname, cat.comment AS catcomment, cat.rank, cat.status, |
---|
| 266 | cat.visible, cat.uppercats, cat.permalink, cat.dir ' |
---|
| 267 | .' FROM ' . IMAGES_TABLE.' AS img' |
---|
| 268 | .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id' |
---|
| 269 | .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id' |
---|
| 270 | .' WHERE ic.category_id IN ('.implode(',', $cat).')' |
---|
| 271 | .(sizeof($obj->my_config['included_file_types']) ? ' AND (img.tn_ext IN ('.implode(',', $type_ext).')' : '') |
---|
| 272 | .($tn_ext_is_null ? ' OR img.tn_ext IS NULL)' : (sizeof($obj->my_config['included_file_types']) ? ')' : '')) |
---|
| 273 | // Verif droits (niveaux) de l'utilisateur sur les images |
---|
| 274 | .' AND img.level <='.$user['level'].' ' |
---|
| 275 | // Choix du critere de tri d'affichage |
---|
| 276 | .$order_list[ $obj->my_config['piclens_order'] ] |
---|
| 277 | .$order_sort[ $obj->my_config['piclens_sort'] ]; |
---|
| 278 | |
---|
| 279 | |
---|
| 280 | } |
---|
| 281 | } |
---|
| 282 | |
---|
| 283 | // Page category |
---|
| 284 | elseif (isset($page['category'])) |
---|
| 285 | { |
---|
| 286 | check_restrictions($page['category']['id']); |
---|
| 287 | |
---|
| 288 | // Flux pour le mur 3D et mur en mode "specifique" |
---|
| 289 | if ($piclenswallfeed) |
---|
| 290 | { |
---|
| 291 | $selectionID = $page['category']['id']; |
---|
| 292 | // categorie parametre pour etre affichee dans le mur |
---|
| 293 | if (in_array($selectionID, $piclenswall_cat)) |
---|
| 294 | array_push($cat, $selectionID); |
---|
| 295 | |
---|
| 296 | // recuperation des sous-categories (tous niveaux) de la categorie en cours. |
---|
| 297 | $subcat= get_subcat_ids(array($selectionID)); |
---|
| 298 | |
---|
| 299 | // Verification ajout des sous-categories qui peuvent être affichees (parametrees dans mur 3D) et des drois des sous categories |
---|
| 300 | foreach($subcat as $sscat) |
---|
| 301 | { |
---|
| 302 | if ((in_array($sscat, $piclenswall_cat)) && (!(in_array($sscat, explode(',', $user['forbidden_categories']))))) |
---|
| 303 | array_push($cat, $sscat); |
---|
| 304 | } |
---|
| 305 | |
---|
| 306 | } |
---|
| 307 | // Piclens (et mur 3D avec meme parametrage que piclens) : paramétrage "commun" |
---|
| 308 | else |
---|
| 309 | { |
---|
| 310 | // recherche de toutes les photos de la categorie (incluant les photos des sous-categories si necessaire) |
---|
| 311 | $selectionID = $page['category']['id']; |
---|
| 312 | |
---|
| 313 | array_push($cat, $selectionID); |
---|
| 314 | |
---|
| 315 | // Si recursivite activee |
---|
| 316 | if ($obj->my_config['piclens_recursive']) |
---|
| 317 | { |
---|
| 318 | // recuperation des sous-categories (tous niveaux) de la categorie en cours. |
---|
| 319 | $subcat= get_subcat_ids(array($selectionID)); |
---|
| 320 | |
---|
| 321 | // Verification droits des sous-categories |
---|
| 322 | foreach($subcat as $sscat) |
---|
| 323 | { |
---|
| 324 | if (!(in_array($sscat, explode(',', $user['forbidden_categories'])))) |
---|
| 325 | array_push($cat, $sscat); |
---|
| 326 | } |
---|
| 327 | |
---|
| 328 | } |
---|
| 329 | } |
---|
| 330 | |
---|
| 331 | $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name, |
---|
| 332 | img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path, |
---|
| 333 | img.level, ic.category_id, cat.name AS catname, cat.comment AS catcomment, cat.rank, cat.status, |
---|
| 334 | cat.visible, cat.uppercats, cat.permalink, cat.dir ' |
---|
| 335 | .' FROM ' . IMAGES_TABLE.' AS img' |
---|
| 336 | .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id' |
---|
| 337 | .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id' |
---|
| 338 | .' WHERE ic.category_id IN ('.implode(',', $cat).')' |
---|
| 339 | .(sizeof($obj->my_config['included_file_types']) ? ' AND (img.tn_ext IN ('.implode(',', $type_ext).')' : '') |
---|
| 340 | .($tn_ext_is_null ? ' OR img.tn_ext IS NULL)' : (sizeof($obj->my_config['included_file_types']) ? ')' : '')) |
---|
| 341 | // Verif droits (niveaux) de l'utilisateur sur les images |
---|
| 342 | .' AND img.level <='.$user['level'].' ' |
---|
| 343 | // Choix du critere de tri d'affichage |
---|
| 344 | .$order_list[ $obj->my_config['piclens_order_cat'] ] |
---|
| 345 | .$order_sort[ $obj->my_config['piclens_sort_cat'] ]; |
---|
| 346 | |
---|
| 347 | } |
---|
| 348 | } |
---|
| 349 | |
---|
| 350 | if ($debug) echo $query; |
---|
| 351 | |
---|
| 352 | // Si au moins une image récupérée (une catégorie ou une image présente) |
---|
| 353 | if (count($cat)!=0) |
---|
| 354 | { |
---|
| 355 | $result = pwg_query($query); |
---|
| 356 | |
---|
| 357 | while ($row = mysql_fetch_assoc($result)) |
---|
| 358 | { |
---|
| 359 | // Plugin Extended Description present et active |
---|
| 360 | // suppression des categories et images pour lesquelles un <!--hidden--> est present |
---|
| 361 | if (!$plugins_ExtendedDesc |
---|
| 362 | OR ($plugins_ExtendedDesc |
---|
| 363 | && !(substr_count($row['name'], $piclens_extdesc_hidden)) |
---|
| 364 | && ((isset($row['catname']) ? !(substr_count($row['catname'], $piclens_extdesc_hidden)) : true)) |
---|
| 365 | )) |
---|
| 366 | { |
---|
| 367 | // Suppression des doublons (même path) |
---|
| 368 | if ($obj->my_config['piclens_exclude_double']) |
---|
| 369 | { |
---|
| 370 | $double = false; |
---|
| 371 | foreach ($pictures as $key => $values) |
---|
| 372 | // même path |
---|
| 373 | if ($row['path'] == $values['path']) |
---|
| 374 | $double=true; |
---|
| 375 | |
---|
| 376 | // pas de double trouvé |
---|
| 377 | if (!$double) |
---|
| 378 | array_push($pictures, $row); |
---|
| 379 | } |
---|
| 380 | else |
---|
| 381 | array_push($pictures, $row); |
---|
| 382 | } |
---|
| 383 | } |
---|
| 384 | } |
---|
| 385 | // Fin requetes recherches photos |
---|
| 386 | |
---|
| 387 | |
---|
| 388 | // Creation du fichier xml (flux rss) |
---|
| 389 | // It's a rss file |
---|
| 390 | header("Content-Type: application/xml; charset=UTF-8"); |
---|
| 391 | echo '<?xml version="1.0" encoding="utf-8" standalone="yes"?>'; |
---|
| 392 | echo "\n"; |
---|
| 393 | echo '<rss version="2.0" '."\n" |
---|
| 394 | .'xmlns:media="http://search.yahoo.com/mrss/" '."\n" |
---|
| 395 | .'xmlns:atom="http://www.w3.org/2005/Atom">'; |
---|
| 396 | echo "\n"; |
---|
| 397 | echo '<channel>'; |
---|
| 398 | echo "\n"; |
---|
| 399 | |
---|
[3649] | 400 | |
---|
| 401 | |
---|
[3619] | 402 | // <!-- <title>test Page</title> --> |
---|
| 403 | echo '<link>'.$obj->root_site_piclens.'</link>'; |
---|
| 404 | echo "\n"; |
---|
| 405 | echo '<description>Flux RSS pour cooliris</description>'; |
---|
| 406 | echo "\n"; |
---|
| 407 | echo '<language>fr</language>'; |
---|
| 408 | echo "\n"; |
---|
| 409 | |
---|
| 410 | // Version du plugin Piclens |
---|
| 411 | $db_plugins = get_db_plugins('', 'piclens'); |
---|
| 412 | if (!empty($db_plugins)) |
---|
| 413 | $piclens_version = $db_plugins[0]['version']; |
---|
| 414 | else |
---|
| 415 | $piclens_version = 'N/A'; |
---|
| 416 | |
---|
| 417 | echo '<generator>Piwigo Cooliris Plugin v.'.$piclens_version.'</generator>'; |
---|
| 418 | echo "\n"; |
---|
| 419 | |
---|
| 420 | // Icone de la gallerie dans le flux RSS |
---|
| 421 | echo "\n"; |
---|
[3649] | 422 | echo '<atom:icon>' |
---|
| 423 | .(strlen($obj->my_config['piclens_rss_icon']) |
---|
| 424 | ? $obj->my_config['piclens_rss_icon'] |
---|
| 425 | : $obj->root_site_piclens.'template-common/favicon.ico') |
---|
| 426 | .'</atom:icon>'; |
---|
[3619] | 427 | echo "\n"; |
---|
| 428 | |
---|
[3649] | 429 | |
---|
[3619] | 430 | // Pour chacune des images, preparation du flux xml |
---|
| 431 | foreach ($pictures as $row) |
---|
| 432 | { |
---|
| 433 | // Mode de l'image parametre |
---|
| 434 | $piclens_normal = $obj->my_config['piclens_normal']; |
---|
| 435 | |
---|
| 436 | // si parametrage high et high absente ou utilisateur non habilite, affichage version normale |
---|
| 437 | if (($piclens_normal == 3) && (!($row['has_high']) || !$user['enabled_high'])) |
---|
| 438 | $piclens_normal = 2; // Normal uniquement pour l'image en cours |
---|
| 439 | |
---|
| 440 | // Get thumbnail url |
---|
| 441 | if ($plugins_SecureImage) // SecureImage installe et actif |
---|
| 442 | { |
---|
| 443 | $link_url = $obj->root_site_piclens.'plugins/secureImages/getFile.php?image_id='.$row['id']; |
---|
| 444 | |
---|
| 445 | $thumbnail_url = $obj->root_site_piclens.'plugins/secureImages/getFile.php?image_id='.$row['id'] |
---|
| 446 | .$thumb_secure[$obj->my_config['piclens_thumb'] ]; |
---|
| 447 | $content_url = $obj->root_site_piclens.'plugins/secureImages/getFile.php?image_id='.$row['id'] |
---|
| 448 | .$normal_secure[$piclens_normal ]; |
---|
| 449 | } |
---|
| 450 | else // SecureImage non installe ou non actif |
---|
| 451 | { |
---|
| 452 | $link_url = $obj->root_site_piclens.$row['path']; |
---|
| 453 | |
---|
| 454 | if ( ($obj->my_config['piclens_thumb']) == 2) // Normal |
---|
| 455 | $thumbnail_url = (url_is_remote($row['path']) ? $row['path']: embellish_url($obj->root_site_piclens.$row['path'])); |
---|
| 456 | else |
---|
| 457 | { |
---|
| 458 | if ($plugins_SecureImage_only) // Plugin secureimage active mais configuration compatibilite piclens-secureimage desactivee |
---|
| 459 | { |
---|
| 460 | $path=get_thumbnail_location($row); |
---|
| 461 | $thumbnail_url = ( url_is_remote($path) ? $path : embellish_url($obj->root_site_piclens.$path) ); |
---|
| 462 | } |
---|
| 463 | else // Plugin secureimage desactive |
---|
| 464 | { |
---|
| 465 | $thumbnail_url = embellish_url($obj->root_site_piclens.get_thumbnail_location($row)); |
---|
| 466 | } |
---|
| 467 | } |
---|
| 468 | |
---|
| 469 | switch ($piclens_normal) |
---|
| 470 | { |
---|
| 471 | case 1 : // miniature |
---|
| 472 | if ($plugins_SecureImage_only) // Plugin secureimage active mais configuration compatibilite piclens-secureimage desactivee |
---|
| 473 | { |
---|
| 474 | $path=get_thumbnail_location($row); |
---|
| 475 | $content_url = ( url_is_remote($path) ? $path : embellish_url($obj->root_site_piclens.$path) ); |
---|
| 476 | } |
---|
| 477 | else // Plugin secureimage desactive |
---|
| 478 | { |
---|
| 479 | $content_url = embellish_url($obj->root_site_piclens.get_thumbnail_location($row));; |
---|
| 480 | } |
---|
| 481 | break; |
---|
| 482 | case 2 : // normal |
---|
| 483 | $content_url = (url_is_remote($row['path']) ? $row['path']: embellish_url($obj->root_site_piclens.$row['path'])); |
---|
| 484 | break; |
---|
| 485 | case 3 : |
---|
| 486 | $content_url = (url_is_remote($row['path']) ? dirname($row['path']).'/pwg_high/'.basename($row['path']) |
---|
| 487 | : embellish_url( $obj->root_site_piclens. dirname($row['path']).'/pwg_high/'.basename($row['path'])) |
---|
| 488 | ); |
---|
| 489 | break; |
---|
| 490 | default : // normal |
---|
| 491 | $content_url = (url_is_remote($row['path']) ? $row['path'] : embellish_url($obj->root_site_piclens.$row['path'])); |
---|
| 492 | break; |
---|
| 493 | } |
---|
| 494 | } |
---|
| 495 | |
---|
| 496 | // link on picture.php page |
---|
| 497 | set_make_full_url(); |
---|
| 498 | if ( isset($row['category_id']) & isset($row['catname']) ) |
---|
| 499 | { |
---|
| 500 | $url = duplicate_picture_url( |
---|
| 501 | array( |
---|
| 502 | 'image_id' => $row['id'], |
---|
| 503 | 'image_file' => $row['file'], |
---|
| 504 | 'category' => array( |
---|
| 505 | 'id' => $row['category_id'], |
---|
| 506 | 'name' => $row['catname'], |
---|
| 507 | 'permalink' => '' |
---|
| 508 | ) |
---|
| 509 | ), |
---|
| 510 | array('start') |
---|
| 511 | ); |
---|
| 512 | } |
---|
| 513 | else |
---|
| 514 | { |
---|
| 515 | $url = duplicate_picture_url( |
---|
| 516 | array( |
---|
| 517 | 'image_id' => $row['id'], |
---|
| 518 | 'image_file' => $row['file'] |
---|
| 519 | ), |
---|
| 520 | array('start') |
---|
| 521 | ); |
---|
| 522 | } |
---|
| 523 | unset_make_full_url(); |
---|
| 524 | |
---|
| 525 | // HTTPS Patch : If needed NO_https can easily be set in your config_local thru LocalFiles Editor |
---|
| 526 | if (isset($conf['NO_https']) and $conf['NO_https'] and strncasecmp($url, 'https://', 8) == 0 ) |
---|
| 527 | $url = 'http://' . substr($url, 8); |
---|
| 528 | |
---|
| 529 | // Show rss item for a picture |
---|
| 530 | echo "<item>\n"; |
---|
| 531 | |
---|
| 532 | |
---|
| 533 | |
---|
| 534 | echo "<title><![CDATA[" |
---|
[3645] | 535 | .parse($obj->my_config['piclens_rss_name'], $row, $plugins_ExtendedDesc, $obj->my_config['piclens_maxcomment_nb']) |
---|
[3619] | 536 | ."]]></title>\n"; |
---|
| 537 | |
---|
[3649] | 538 | // not media:description for normal piclens to show description |
---|
| 539 | echo '<description><![CDATA[' |
---|
| 540 | .parse($obj->my_config['piclens_rss_desc'], $row, $plugins_ExtendedDesc, $obj->my_config['piclens_maxcomment_nb']) |
---|
| 541 | .']]> </description>'; |
---|
[3619] | 542 | |
---|
| 543 | echo '<media:description type="html"><![CDATA[' |
---|
[3645] | 544 | .parse($obj->my_config['piclens_rss_desc'], $row, $plugins_ExtendedDesc, $obj->my_config['piclens_maxcomment_nb']) |
---|
[3619] | 545 | .']]> </media:description>'; |
---|
[3649] | 546 | |
---|
| 547 | |
---|
[3619] | 548 | /* |
---|
| 549 | // Extended description for the comment and category name |
---|
| 550 | if ($plugins_ExtendedDesc) // Extended description compatibility |
---|
| 551 | { |
---|
| 552 | if (isset($row['catname'])) |
---|
| 553 | $row['catname'] = trigger_event('render_element_description',$row['catname']); |
---|
| 554 | if (isset($row['comment'])) |
---|
| 555 | $row['comment'] = trigger_event('render_element_description',$row['comment']); |
---|
| 556 | } |
---|
| 557 | |
---|
| 558 | |
---|
| 559 | // Titre de l'image dans Piclens |
---|
| 560 | switch($obj->my_config['piclens_name_image']) |
---|
| 561 | { |
---|
| 562 | case 2 : |
---|
| 563 | // format nom fichier |
---|
| 564 | echo "<title><![CDATA[" |
---|
| 565 | .(($obj->my_config['piclens_cat_view'] && isset ($row['catname'])) ? $row['catname']." - " : "") |
---|
| 566 | . $row['file'] . "]]></title>\n"; |
---|
| 567 | break; |
---|
| 568 | case 3 : |
---|
| 569 | // format nom de la photo |
---|
| 570 | if (isset($row['name'])) |
---|
| 571 | echo "<title><![CDATA[" |
---|
| 572 | .(($obj->my_config['piclens_cat_view'] && isset ($row['catname'])) ? $row['catname']." - " : "") |
---|
| 573 | .$row['name']."]]></title>\n"; |
---|
| 574 | else |
---|
| 575 | echo "<title><![CDATA[" |
---|
| 576 | .(($obj->my_config['piclens_cat_view'] && isset ($row['catname'])) ? $row['catname']." - " : "") |
---|
| 577 | . $row['file'] . "]]></title>\n"; |
---|
| 578 | break; |
---|
| 579 | default : |
---|
| 580 | // format nom fichier : taille |
---|
| 581 | echo "<title><![CDATA[" |
---|
| 582 | .(($obj->my_config['piclens_cat_view'] && isset ($row['catname'])) ? $row['catname']." - " : "") |
---|
| 583 | . get_thumbnail_title($row) . "]]></title>\n"; |
---|
| 584 | break; |
---|
| 585 | } |
---|
| 586 | |
---|
| 587 | // Description (nom de vignette) present |
---|
| 588 | switch($obj->my_config['piclens_name_desc']) |
---|
| 589 | { |
---|
| 590 | case 2 : |
---|
| 591 | if (isset($row['name'])) |
---|
| 592 | echo '<media:description type="html"><![CDATA['.$row['name'].']]> </media:description>'; |
---|
| 593 | break; |
---|
| 594 | case 3 : |
---|
| 595 | if (isset($row['comment'])) |
---|
[3647] | 596 | { |
---|
| 597 | if ($plugins_ExtendedDesc) // Extended description compatibility |
---|
| 598 | { |
---|
| 599 | $desc=trigger_event('render_element_description',$row['comment']); |
---|
| 600 | echo '<media:description type="html"><![CDATA['.$desc.']]> </media:description>'; |
---|
| 601 | } |
---|
| 602 | else |
---|
| 603 | echo '<media:description type="html"><![CDATA['.$row['comment'].']]> </media:description>'; |
---|
| 604 | } |
---|
| 605 | break; |
---|
[3619] | 606 | default : |
---|
| 607 | break; |
---|
| 608 | } |
---|
| 609 | */ |
---|
| 610 | echo "\n"; |
---|
| 611 | |
---|
| 612 | // link |
---|
| 613 | echo "<link>" . $url . "</link>\n"; |
---|
| 614 | |
---|
| 615 | echo "<guid isPermaLink=\"false\">\"" . $row['id'] . "\"</guid>\n"; |
---|
| 616 | |
---|
| 617 | |
---|
| 618 | echo "<media:thumbnail url=\"" . $thumbnail_url . "\" />\n"; |
---|
| 619 | |
---|
| 620 | $extension = explode(".", $row['file']); |
---|
| 621 | $extension = $extension[sizeof($extension)-1]; |
---|
| 622 | |
---|
| 623 | // Fichiers video (Charlies content) |
---|
| 624 | if ((in_array($extension, $video_ext_piclens))) |
---|
| 625 | { |
---|
| 626 | if ($obj->my_config['piclens_video']) // activation des videos |
---|
| 627 | { |
---|
| 628 | switch ($extension) |
---|
| 629 | { |
---|
| 630 | case "flv": |
---|
| 631 | echo "<media:content type=\"video/x-flv\" url=\"".$content_url."\"/>\n"; |
---|
| 632 | break; |
---|
| 633 | } |
---|
| 634 | } |
---|
| 635 | else |
---|
| 636 | { |
---|
| 637 | echo "<media:content url=\"" . $thumbnail_url . "\" />\n"; |
---|
| 638 | } |
---|
| 639 | } |
---|
| 640 | // Fichiers video (PY Gvideo) |
---|
| 641 | elseif ((in_array($extension, $py_addext))) |
---|
| 642 | { |
---|
| 643 | if ($obj->my_config['piclens_video']) // activation des videos |
---|
| 644 | { |
---|
| 645 | // Si impossibilite de lire le fichier! |
---|
| 646 | if( false == ($idvideo = file_get_contents(PHPWG_ROOT_PATH.$row['path']))) |
---|
| 647 | { |
---|
| 648 | echo "<media:content url=\"" . $thumbnail_url . "\" />\n"; |
---|
| 649 | } |
---|
| 650 | else |
---|
| 651 | { |
---|
| 652 | $sp = explode("/", $idvideo); |
---|
| 653 | switch ($extension) |
---|
| 654 | { |
---|
| 655 | case "dm" : |
---|
| 656 | echo "<enclosure url=\"http://www.dailymotion.com/swf/".$sp[0]."\" type=\"application/x-shockwave-flash\" />\n"; |
---|
| 657 | break; |
---|
| 658 | case "ytube": |
---|
| 659 | echo "<enclosure url=\"http://youtube.com/v/".$sp[0].".swf\" type=\"application/x-shockwave-flash\" />\n"; |
---|
| 660 | break; |
---|
| 661 | case "wideo": |
---|
| 662 | 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"; |
---|
| 663 | break; |
---|
| 664 | case "gvideo": |
---|
| 665 | echo "<enclosure url=\"http://video.google.com/googleplayer.swf?docid=".$sp[0]."\" type=\"application/x-shockwave-flash\" />\n"; |
---|
| 666 | break; |
---|
| 667 | case "vimeo": |
---|
| 668 | echo "<enclosure url=\"http://vimeo.com/moogaloop.swf?clip_id=".$sp[0]."\" type=\"application/x-shockwave-flash\" />\n"; |
---|
| 669 | break; |
---|
| 670 | } |
---|
| 671 | } |
---|
| 672 | } |
---|
| 673 | else |
---|
| 674 | { |
---|
| 675 | echo "<media:content url=\"" . $thumbnail_url . "\" />\n"; |
---|
| 676 | } |
---|
| 677 | } |
---|
| 678 | // Images (standard) |
---|
| 679 | else |
---|
| 680 | echo "<media:content url=\"" . $content_url . "\" />\n"; |
---|
| 681 | |
---|
| 682 | echo "</item>\n"; |
---|
| 683 | echo "\n"; |
---|
| 684 | } |
---|
| 685 | echo "</channel>\n"; |
---|
| 686 | echo "</rss>"; |
---|
| 687 | } |
---|
| 688 | |
---|
| 689 | } |
---|
| 690 | |
---|
[3645] | 691 | // parse the configuration to complete with the correct informations |
---|
| 692 | function parse($data, $row, $plugins_ExtendedDesc = false, $nb_comment = 0) |
---|
| 693 | { |
---|
[3619] | 694 | |
---|
[3645] | 695 | // Eviter de charger les commentaires (appels base) si ils ne sont pas affichés |
---|
| 696 | if (strpos($data, '%ID') === false) |
---|
| 697 | $nb_comment = 0; |
---|
| 698 | |
---|
[3619] | 699 | include (PICLENS_PATH.'include/config_param.inc.php'); |
---|
| 700 | |
---|
| 701 | $patterns = array(); |
---|
| 702 | $replacements = array(); |
---|
| 703 | foreach ($piclens_parse as $key => $value) |
---|
| 704 | { |
---|
| 705 | array_push($patterns, $key); |
---|
| 706 | array_push($replacements, $value); |
---|
| 707 | } |
---|
| 708 | |
---|
| 709 | return str_replace($patterns, $replacements, $data); |
---|
| 710 | } |
---|
| 711 | |
---|
[3645] | 712 | // Return the last comments of an image id |
---|
| 713 | function get_comment($img_id, $nb_comment = 0) |
---|
| 714 | { |
---|
| 715 | $commentstring = ''; |
---|
[3619] | 716 | |
---|
[3645] | 717 | if ($nb_comment != 0) |
---|
| 718 | { |
---|
| 719 | $query = ' |
---|
| 720 | SELECT id,author,date,image_id,content |
---|
| 721 | FROM '.COMMENTS_TABLE.' |
---|
| 722 | WHERE image_id = '.$img_id.' |
---|
| 723 | AND validated = \'true\' |
---|
| 724 | ORDER BY date ASC |
---|
| 725 | LIMIT 0,'.$nb_comment.' |
---|
| 726 | ;'; |
---|
| 727 | $result = pwg_query( $query ); |
---|
| 728 | $first = true; |
---|
[3619] | 729 | |
---|
[3645] | 730 | while ($row = mysql_fetch_array($result)) |
---|
| 731 | { |
---|
| 732 | |
---|
| 733 | // Format : "Commentaire (Utilisateur - Date)" |
---|
| 734 | $commentstring .= ($first ? '' : " / \n") |
---|
| 735 | .trigger_event('render_comment_content',$row['content']) |
---|
| 736 | .' ('. trigger_event('render_comment_author', |
---|
| 737 | empty($row['author']) |
---|
| 738 | ? l10n('guest') |
---|
| 739 | : $row['author']) |
---|
| 740 | .' - ' |
---|
| 741 | .format_date( $row['date'], false) |
---|
| 742 | .")"; |
---|
| 743 | |
---|
| 744 | $first = false; |
---|
| 745 | |
---|
| 746 | } |
---|
| 747 | } |
---|
| 748 | return $commentstring; |
---|
| 749 | } |
---|
| 750 | |
---|
[3410] | 751 | ?> |
---|