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