my_config['piclens_recursive'] = false; } // extensions video $py_addext = array("gvideo", "dm", "ytube", "wideo", "vimeo", "wat"); $video_ext_piclens = array("flv"); if (isset($conf['piclens_videoext_thumb'])) // Conf file contains extensions to show as thumbnail. Others files will not be display (except previous ext) $videos_ext_other = $conf['piclens_videoext_thumb']; else // Conf not present, by default, list of file to display as thumb $videos_ext_other = array('mpg','avi','mp4','mov','wmv','divx','xvid','mpeg','3pg'); // Vérification présence et activation plugin SecureImages ET si actif, vérification d'activation de compatibilité $plugins_SecureImage_only = (get_db_plugins('active','secureImages') ? true : false ); $plugins_SecureImage = ($plugins_SecureImage_only && ($obj->my_config['piclens_secureimage']) ? true : false ); // Verification presence et activation plugin ExtendedDescription $plugins_ExtendedDesc = (get_db_plugins('active','ExtendedDescription') && ($obj->my_config['piclens_extendeddesc']) ? true : false ); // Vérification d'activation du plugin (page administration) OU activation de piclensWall 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'))) { //-------------------------------------------------------------- initialization // Mode des miniatures et des images normales dans piclens (avec et sans plugin secureimage) $thumb_secure = array('', '&thumb=1', ''); // correspondant a 1-->'miniature' et 2-->'normal' $normal_secure = array('', '&thumb=1', '', '&highdef=1'); // correspondant a 1-->'miniature' et 2-->'normal' et 3 --> High $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 '); $order_sort = array('', '', ' ASC', ' DESC'); // Extensions a prendre en compte $tn_ext_is_null = false; $type_ext = $obj->my_config['included_file_types']; foreach($type_ext as $i => $value) { if ($value == '!NULL!') $tn_ext_is_null = true; $type_ext[$i] = '"'.($value == '!NULL!' ? 'NULL' : $value).'"'; } // Categories a prendre en compte pour le mur $piclenswall_cat = (isset($obj->my_config['piclens_wall_categories']) ? $obj->my_config['piclens_wall_categories'] : array()); // Seulement sur une page type 'categorie' if (isset($page['section'])) { $cat = array(); $pictures = array(); $forbidden = get_sql_condition_FandF( array ( 'forbidden_categories' => 'category_id', 'visible_categories' => 'category_id', 'visible_images' => 'id' ), 'AND' ); // Images recentes if (($page['section']) == 'recent_pics') { if ( !isset($page['super_order_by']) ) { $conf['order_by'] = str_replace( 'ORDER BY ', 'ORDER BY date_available DESC,', $conf['order_by'] ); } // $cat need to bo not null... array_push($cat, "1"); $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name, img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path, img.level ' .' FROM ' . IMAGES_TABLE.' AS img' .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id' .' WHERE img.date_available >= SUBDATE( CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY) ' .get_sql_condition_FandF ( array('visible_images' => 'id'), 'AND' ) .' '.$conf['order_by'].';'; } // Plus vues elseif ($page['section'] == 'recent_cats') { // $cat need to bo not null... array_push($cat, "1"); $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name, img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path, img.level, ic.category_id, cat.name AS catname, cat.comment AS catcomment, cat.rank, cat.status, cat.visible, cat.uppercats, cat.permalink, cat.dir ' .' FROM ' . IMAGES_TABLE.' AS img' .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id' .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id' .' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' ON cat.id = cat_id and user_id = '.$user['id'] .' WHERE date_last >= SUBDATE( CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY ) '.$forbidden .';'; } // Plus vues elseif ($page['section'] == 'most_visited') { // $cat need to bo not null... array_push($cat, "1"); $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name, img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path, img.level, ic.category_id, cat.name AS catname, cat.comment AS catcomment, cat.rank, cat.status, cat.visible, cat.uppercats, cat.permalink, cat.dir ' .' FROM ' . IMAGES_TABLE.' AS img' .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id' .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id' .' WHERE img.hit > 0 ' .$forbidden .' ORDER BY hit DESC, file ASC' .' LIMIT 0, '.$conf['top_number'].';'; } // mieux notees elseif ($page['section'] == 'best_rated') { // $cat need to bo not null... array_push($cat, "1"); $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name, img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path, img.level ' .' FROM ' . IMAGES_TABLE.' AS img' .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id' .' WHERE img.average_rate IS NOT NULL ' .get_sql_condition_FandF ( array('visible_images' => 'id'), 'AND' ) .' ORDER BY average_rate DESC, id ASC' .' LIMIT 0, '.$conf['top_number'].';'; } elseif ($page['section'] == 'favorites') { check_user_favorites(); // $cat need to bo not null... array_push($cat, "1"); $query = 'SELECT img.id, img.file, img.date_available, img.date_creation, img.tn_ext, img.name, img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path, img.level ' .' FROM '.FAVORITES_TABLE.' AS fav ' .' INNER JOIN '.IMAGES_TABLE.' AS img ON fav.image_id = img.id' .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id' .' WHERE user_id = '.$user['id'] .' '.get_sql_condition_FandF ( array('visible_images' => 'id'), 'AND' ) .' '.$conf['order_by'].';'; } // Gestion des tags elseif (($page['section']) == 'tags') { // $row = get_image_ids_for_tags($page['tags_id']); $tag_images = array(); foreach ($page['tag_ids'] as $tag_id) { $query = ' SELECT image_id FROM '.IMAGE_TAG_TABLE.' WHERE tag_id = '.$tag_id.' ;'; $tag_images[$tag_id] = array_from_query($query, 'image_id'); } // then we calculate the intersection, the images that are associated to // every tags $items = array_shift($tag_images); foreach ($tag_images as $images) { $items = array_intersect($items, $images); } $items = array_unique($items); // foreach ($items as $item) // echo "item=".implode(',', $items); // $cat need to bo not null... array_push($cat, "1"); $query = 'SELECT distinct(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name, img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path, img.level ' .' FROM '.IMAGES_TABLE.' AS img ' .' WHERE img.id IN ('.implode(',', $items).') ' .' '.get_sql_condition_FandF ( array('visible_images' => 'id'), 'AND' ) .' '.$conf['order_by'].';'; } elseif (($page['section']) == 'categories') { // Accueil if(empty($page['category'])) { // Page accueil // Vérification d'activation du plugin (page administration) // ou flux pour piclenswall et configuration specifique if ($obj->my_config['piclens_gallerie_active'] || $piclenswallfeed) { // Categories de premier niveau $query = 'SELECT id,name,permalink FROM ' . CATEGORIES_TABLE .' WHERE id_uppercat is NULL'; $result = pwg_query($query); while ($row = mysql_fetch_assoc($result)) { if (!(in_array($row['id'], explode(',', $user['forbidden_categories'])))) { array_push($cat, $row['id']); } } // Type = avec recursiite // Si parametrage specifique pour le mur 3D, recursivite sur les categories if (($piclenswallfeed) || (( $obj->my_config['piclens_gallerie_type'])-1)) { // recuperation des sous-categories (tous niveaux) de la categorie en cours. $subcat= get_subcat_ids($cat); // Verification droits des sous-categories foreach($subcat as $sscat) { if (!(in_array($sscat, explode(',', $user['forbidden_categories'])))) array_push($cat, $sscat); } } // selection uniquement des categories a afficher (si flux pour le mur ET parametre mur = specifique) if ($piclenswallfeed) { foreach($cat as $i => $wcat) { if (!in_array($wcat, $piclenswall_cat)) unset($cat[$i]); } } $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name, img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path, img.level, ic.category_id, cat.name AS catname, cat.comment AS catcomment, cat.rank, cat.status, cat.visible, cat.uppercats, cat.permalink, cat.dir ' .' FROM ' . IMAGES_TABLE.' AS img' .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id' .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id' .' WHERE ic.category_id IN ('.implode(',', $cat).')' .(sizeof($obj->my_config['included_file_types']) ? ' AND (img.tn_ext IN ('.implode(',', $type_ext).')' : '') .($tn_ext_is_null ? ' OR img.tn_ext IS NULL)' : (sizeof($obj->my_config['included_file_types']) ? ')' : '')) // Verif droits (niveaux) de l'utilisateur sur les images .' AND img.level <='.$user['level'].' ' // Choix du critere de tri d'affichage .$order_list[ $obj->my_config['piclens_order'] ] .$order_sort[ $obj->my_config['piclens_sort'] ]; } } // Page category elseif (isset($page['category'])) { check_restrictions($page['category']['id']); // Flux pour le mur 3D et mur en mode "specifique" if ($piclenswallfeed) { $selectionID = $page['category']['id']; // categorie parametre pour etre affichee dans le mur if (in_array($selectionID, $piclenswall_cat)) array_push($cat, $selectionID); // recuperation des sous-categories (tous niveaux) de la categorie en cours. $subcat= get_subcat_ids(array($selectionID)); // Verification ajout des sous-categories qui peuvent être affichees (parametrees dans mur 3D) et des drois des sous categories foreach($subcat as $sscat) { if ((in_array($sscat, $piclenswall_cat)) && (!(in_array($sscat, explode(',', $user['forbidden_categories']))))) array_push($cat, $sscat); } } // Piclens (et mur 3D avec meme parametrage que piclens) : paramétrage "commun" else { // recherche de toutes les photos de la categorie (incluant les photos des sous-categories si necessaire) $selectionID = $page['category']['id']; array_push($cat, $selectionID); // Si recursivite activee if ($obj->my_config['piclens_recursive']) { // recuperation des sous-categories (tous niveaux) de la categorie en cours. $subcat= get_subcat_ids(array($selectionID)); // Verification droits des sous-categories foreach($subcat as $sscat) { if (!(in_array($sscat, explode(',', $user['forbidden_categories'])))) array_push($cat, $sscat); } } } $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name, img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path, img.level, ic.category_id, cat.name AS catname, cat.comment AS catcomment, cat.rank, cat.status, cat.visible, cat.uppercats, cat.permalink, cat.dir ' .' FROM ' . IMAGES_TABLE.' AS img' .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id' .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id' .' WHERE ic.category_id IN ('.implode(',', $cat).')' .(sizeof($obj->my_config['included_file_types']) ? ' AND (img.tn_ext IN ('.implode(',', $type_ext).')' : '') .($tn_ext_is_null ? ' OR img.tn_ext IS NULL)' : (sizeof($obj->my_config['included_file_types']) ? ')' : '')) // Verif droits (niveaux) de l'utilisateur sur les images .' AND img.level <='.$user['level'].' ' // Choix du critere de tri d'affichage .$order_list[ $obj->my_config['piclens_order_cat'] ] .$order_sort[ $obj->my_config['piclens_sort_cat'] ]; } } if ($debug) echo $query; // Si au moins une image récupérée (une catégorie ou une image présente) if (count($cat)!=0) { $result = pwg_query($query); while ($row = mysql_fetch_assoc($result)) { // Plugin Extended Description present et active // suppression des categories et images pour lesquelles un est present if (!$plugins_ExtendedDesc OR ($plugins_ExtendedDesc && !(substr_count($row['name'], $piclens_extdesc_hidden)) && ((isset($row['catname']) ? !(substr_count($row['catname'], $piclens_extdesc_hidden)) : true)) )) { // Suppression des doublons (même path) if ($obj->my_config['piclens_exclude_double']) { $double = false; foreach ($pictures as $key => $values) // même path if ($row['path'] == $values['path']) $double=true; // pas de double trouvé if (!$double) array_push($pictures, $row); } else array_push($pictures, $row); } } } // Fin requetes recherches photos // Creation du fichier xml (flux rss) // It's a rss file header("Content-Type: application/xml; charset=UTF-8"); echo ''; echo "\n"; echo ''; echo "\n"; if (strlen($obj->my_config['piclens_rss_title'])) { echo ''.$obj->my_config['piclens_rss_title'].''; echo "\n"; } echo ''; echo "\n"; // echo ''.$obj->root_site_piclens.''; echo "\n"; echo 'Flux RSS pour cooliris'; echo "\n"; echo 'fr'; echo "\n"; // Version du plugin Piclens $db_plugins = get_db_plugins('', 'piclens'); if (!empty($db_plugins)) $piclens_version = $db_plugins[0]['version']; else $piclens_version = 'N/A'; echo 'Piwigo Cooliris Plugin v.'.$piclens_version.''; echo "\n"; // Icone de la gallerie dans le flux RSS echo "\n"; echo '' .(strlen($obj->my_config['piclens_rss_icon']) ? $obj->my_config['piclens_rss_icon'] : $obj->root_site_piclens.'template-common/favicon.ico') .''; echo "\n"; // Pour chacune des images, preparation du flux xml foreach ($pictures as $row) { // Mode de l'image parametre $piclens_normal = $obj->my_config['piclens_normal']; // si parametrage high et high absente ou utilisateur non habilite, affichage version normale if (($piclens_normal == 3) && (!($row['has_high']) || !$user['enabled_high'])) $piclens_normal = 2; // Normal uniquement pour l'image en cours // Get thumbnail url if ($plugins_SecureImage) // SecureImage installe et actif { $link_url = $obj->root_site_piclens.'plugins/secureImages/getFile.php?image_id='.$row['id']; $thumbnail_url = $obj->root_site_piclens.'plugins/secureImages/getFile.php?image_id='.$row['id'] .$thumb_secure[$obj->my_config['piclens_thumb'] ]; $content_url = $obj->root_site_piclens.'plugins/secureImages/getFile.php?image_id='.$row['id'] .$normal_secure[$piclens_normal ]; } else // SecureImage non installe ou non actif { $link_url = $obj->root_site_piclens.$row['path']; if ( ($obj->my_config['piclens_thumb']) == 2) // Normal $thumbnail_url = (url_is_remote($row['path']) ? $row['path']: embellish_url($obj->root_site_piclens.$row['path'])); else { $path=get_thumbnail_location($row); $thumbnail_url = ( url_is_remote($path) ? $path : embellish_url($obj->root_site_piclens.$path) ); } switch ($piclens_normal) { case 1 : // miniature $path=get_thumbnail_location($row); $content_url = ( url_is_remote($path) ? $path : embellish_url($obj->root_site_piclens.$path) ); break; case 2 : // normal $content_url = (url_is_remote($row['path']) ? $row['path']: embellish_url($obj->root_site_piclens.$row['path'])); break; case 3 : $content_url = (url_is_remote($row['path']) ? dirname($row['path']).'/pwg_high/'.basename($row['path']) : embellish_url( $obj->root_site_piclens. dirname($row['path']).'/pwg_high/'.basename($row['path'])) ); break; default : // normal $content_url = (url_is_remote($row['path']) ? $row['path'] : embellish_url($obj->root_site_piclens.$row['path'])); break; } } // link on picture.php page set_make_full_url(); if ( isset($row['category_id']) & isset($row['catname']) ) { $url = duplicate_picture_url( array( 'image_id' => $row['id'], 'image_file' => $row['file'], 'category' => array( 'id' => $row['category_id'], 'name' => $row['catname'], 'permalink' => '' ) ), array('start') ); } else { $url = duplicate_picture_url( array( 'image_id' => $row['id'], 'image_file' => $row['file'] ), array('start') ); } unset_make_full_url(); // HTTPS Patch : If needed NO_https can easily be set in your config_local thru LocalFiles Editor if (isset($conf['NO_https']) and $conf['NO_https'] and strncasecmp($url, 'https://', 8) == 0 ) $url = 'http://' . substr($url, 8); // Show rss item for a picture echo "\n"; echo "<![CDATA[" .parse($obj->my_config['piclens_rss_name'], $row, $plugins_ExtendedDesc, $obj->my_config['piclens_maxcomment_nb']) ."]]>\n"; // not media:description for normal piclens to show description echo 'my_config['piclens_rss_desc'], $row, $plugins_ExtendedDesc, $obj->my_config['piclens_maxcomment_nb']) .']]> '; echo 'my_config['piclens_rss_desc'], $row, $plugins_ExtendedDesc, $obj->my_config['piclens_maxcomment_nb']) .']]> '; /* // Extended description for the comment and category name if ($plugins_ExtendedDesc) // Extended description compatibility { if (isset($row['catname'])) $row['catname'] = trigger_event('render_element_description',$row['catname']); if (isset($row['comment'])) $row['comment'] = trigger_event('render_element_description',$row['comment']); } // Titre de l'image dans Piclens switch($obj->my_config['piclens_name_image']) { case 2 : // format nom fichier echo "<![CDATA[" .(($obj->my_config['piclens_cat_view'] && isset ($row['catname'])) ? $row['catname']." - " : "") . $row['file'] . "]]>\n"; break; case 3 : // format nom de la photo if (isset($row['name'])) echo "<![CDATA[" .(($obj->my_config['piclens_cat_view'] && isset ($row['catname'])) ? $row['catname']." - " : "") .$row['name']."]]>\n"; else echo "<![CDATA[" .(($obj->my_config['piclens_cat_view'] && isset ($row['catname'])) ? $row['catname']." - " : "") . $row['file'] . "]]>\n"; break; default : // format nom fichier : taille echo "<![CDATA[" .(($obj->my_config['piclens_cat_view'] && isset ($row['catname'])) ? $row['catname']." - " : "") . get_thumbnail_title($row) . "]]>\n"; break; } // Description (nom de vignette) present switch($obj->my_config['piclens_name_desc']) { case 2 : if (isset($row['name'])) echo ' '; break; case 3 : if (isset($row['comment'])) { if ($plugins_ExtendedDesc) // Extended description compatibility { $desc=trigger_event('render_element_description',$row['comment']); echo ' '; } else echo ' '; } break; default : break; } */ echo "\n"; // link echo "" . $url . "\n"; echo "\"" . $row['id'] . "\"\n"; echo "\n"; $extension = explode(".", $row['file']); $extension = $extension[sizeof($extension)-1]; // Fichiers video (Charlies content) if ((in_array($extension, array_merge($video_ext_piclens,$videos_ext_other) ))) { if ($obj->my_config['piclens_video']) // activation des videos { if ((in_array($extension, $video_ext_piclens))) { //video supported by cooliris echo "\n"; } else { //video not supported by cooliris: thumbnail is displayed echo "\n"; } } else // deactivation of videos { echo "\n"; } } // Fichiers video (PY Gvideo) elseif ((in_array($extension, $py_addext))) { if ($obj->my_config['piclens_video']) // activation des videos { // Si impossibilite de lire le fichier! if( false == ($idvideo = file_get_contents(PHPWG_ROOT_PATH.$row['path']))) { echo "\n"; } else { $sp = explode("/", $idvideo); switch ($extension) { case "dm" : echo "\n"; break; case "ytube": echo "\n"; break; case "wideo": echo "\n"; break; case "gvideo": echo "\n"; break; case "vimeo": echo "\n"; break; case "wat": echo "\n"; break; } } } else { echo "\n"; } } // Images (standard) else echo "\n"; echo "\n"; echo "\n"; } echo "\n"; echo ""; } } // parse the configuration to complete with the correct informations function parse($data, $row, $plugins_ExtendedDesc = false, $nb_comment = 0) { // Eviter de charger les commentaires (appels base) si ils ne sont pas affichés if (strpos($data, '%ID') === false) $nb_comment = 0; include (PICLENS_PATH.'include/config_param.inc.php'); $patterns = array(); $replacements = array(); foreach ($piclens_parse as $key => $value) { array_push($patterns, $key); array_push($replacements, $value); } return str_replace($patterns, $replacements, $data); } // Return the last comments of an image id function get_comment($img_id, $nb_comment = 0) { $commentstring = ''; if ($nb_comment != 0) { $query = ' SELECT id,author,date,image_id,content FROM '.COMMENTS_TABLE.' WHERE image_id = '.$img_id.' AND validated = \'true\' ORDER BY date ASC LIMIT 0,'.$nb_comment.' ;'; $result = pwg_query( $query ); $first = true; while ($row = mysql_fetch_array($result)) { // Format : "Commentaire (Utilisateur - Date)" $commentstring .= ($first ? '' : " / \n") // .trigger_event('render_comment_content',$row['content']) .empty($row['content']) ? '': $row['content'] // .' ('. trigger_event('render_comment_author', .(empty($row['author']) ? l10n('guest') : $row['author']) .' - ' .format_date( $row['date'], false) .")"; $first = false; } } return $commentstring; } ?>