| // | Mod description : | // | Ce module est base sur le module existant pour le telechargement, | // | cette version permet le telechargement sur plusieurs pages. | // +-----------------------------------------------------------------------+ // | This program is free software; you can redistribute it and/or modify | // | it under the terms of the GNU General Public License as published by | // | the Free Software Foundation | // | | // | This program is distributed in the hope that it will be useful, but | // | WITHOUT ANY WARRANTY; without even the implied warranty of | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | // | General Public License for more details. | // | | // | You should have received a copy of the GNU General Public License | // | along with this program; if not, write to the Free Software | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | // | USA. ' | // +-----------------------------------------------------------------------+ class DownloadMulti { var $plugin_name, $plugin_path, $plugin_url; var $my_config; function DownloadMulti($plugin_name, $plugin_path, $plugin_url) { // Args $this->plugin_name = $plugin_name; $this->plugin_path = $plugin_path; $this->plugin_url = $plugin_url; // handler $this->initialize_event_handler($plugin_name, $plugin_path, $plugin_url); } function initialize_event_handler() { global $user; $this->load_config(); // Chargement de la configuration $this->load_lang(); // Chargement des langues if ($user['status'] != 'guest' AND !empty($this->my_config['group_id'])) { // Récupération du groupe utilisateur autorisé à télécharger les images $query = ' SELECT group_id FROM '.USER_GROUP_TABLE.' WHERE user_id = '.$user['id'].' ;'; $result = pwg_query($query); // Parcours la requête SQL while($row = mysql_fetch_array($result)) { if(in_array($row['group_id'], $this->my_config['group_id'])) { // Mise à jour du panier add_event_handler('loc_begin_index', array(&$this, 'DmCart')); // Ajout d'élements dans le header // Ne pas inclure dans les pages d'administration add_event_handler('loc_end_page_header', array(&$this, 'DmHeader')); // Ajout une entrée dans le menubar add_event_handler('blockmanager_apply', array(&$this, 'DmMenubar')); add_event_handler('blockmanager_register_blocks', array(&$this, 'register_dm_menubar_blocks')); // ---- Thumbnail // Entrée HTML du formulaire pour la sélection des images add_event_handler('loc_begin_index_thumbnails', array(&$this, 'DmFormThumbnail')); // Affichage des cases à cocher sous les vignettes add_event_handler('loc_end_index_thumbnails', array($this, 'DmCategoryThumbnail'), 50, 2); // Affichage du cadre en bas de thumbnail.tpl add_event_handler('loc_begin_index_thumbnails', array(&$this, 'DmCategoryDefault')); if (script_basename() == 'popuphelp') { // ---- Aide add_event_handler('get_popup_help_content', array(&$this, 'get_popup_help_content'), EVENT_HANDLER_PRIORITY_NEUTRAL, 2); } } } } if (is_admin()) { // ---- Administration add_event_handler('get_admin_plugin_menu_links', array(&$this, 'plugin_admin_menu')); // Menu d'administration } } /* this function initialize var $my_config with default values */ function init_config() { $this->my_config = array(); } //Chargement de la configuration function load_config() { $this->init_config(); $query = ' SELECT value FROM '.CONFIG_TABLE.' WHERE param = \'downloadmulti_config\' ;'; $result = pwg_query($query); if($result) { $row = mysql_fetch_row($result); if(is_string($row[0])) { $config = unserialize($row[0]); reset($config); while (list($key, $val) = each($config)) { $this->my_config[$key] = $val; } } } } // Sauvegarde de la configuration function save_config() { $query = ' REPLACE INTO '.CONFIG_TABLE.' VALUES( \'downloadmulti_config\', \''.serialize($this->my_config).'\', \'Configuration de Download Multi\') ;'; $result = pwg_query($query); if($result) { return true; } else { return false; } } // Affichage du lien dans la barre // menu administrateur function plugin_admin_menu($menu) { array_push($menu, array( 'NAME' => 'Download Multi', 'URL' => get_admin_plugin_menu_link($this->plugin_path.'admin/admin.php') ) ); return $menu; } // Chargement des fichiers langues function load_lang() { load_language('plugin.lang', $this->plugin_path); } // Gestion de l'aide pour le plugin function get_popup_help_content($popup_help_content, $page) { if (in_array($page, array($this->plugin_name, 'DownloadMulti'))) { $help_content = load_language('help/'.$page.'.html', $this->plugin_path, array('return'=>true)); } else { $help_content = false; } if ($help_content == false) { return $popup_help_content; } else { return $popup_help_content.$help_content; } } // Enregistrement du menu pour la gestion dans l'administration function register_dm_menubar_blocks($menu_ref_arr) { $menu = & $menu_ref_arr[0]; if ($menu->get_id() != 'menubar') return; $menu->register_block(new RegisteredBlock('mbDownloadMulti', 'Download Multi', 'DM')); } // Chargement de fichier dans l'entête du template function DmHeader() { global $template; $DmUrlJs = get_root_url().'plugins/'.$this->plugin_name.'/include/DownloadMulti.js'; $DmUrlCss = get_root_url().'plugins/'.$this->plugin_name.'/include/DownloadMulti.css'; $template->append( 'head_elements', ''."\n". ''."\n" ); } // Gestion de l'affichage dans le menubar function DmMenuBar($menu_ref_arr) { global $template; $menu = & $menu_ref_arr[0]; $template->assign('NBIMAGES', $this->DmCountCart()); if (($block = $menu->get_block( 'mbDownloadMulti' )) != null) { $block->set_title('Download Multi'); $block->template = $this->plugin_path.'template/DmMenu.tpl'; } } // Compte le nombre d'images selectionné // dans le panier du visiteur function DmCountCart() { global $prefixeTable, $user, $lang; $query = ' SELECT COUNT(*) AS nb_line FROM '.$prefixeTable.'download_multi WHERE id_user = '.$user['id'].' ;'; $row = mysql_fetch_array(pwg_query($query)); // Si le nombre de lignes est supérieur à 0 // alors on affiche le message d'avertissement // utilisateur if ($row['nb_line'] > 0) { $nbImages = sprintf($lang['dl_message_cart'], $row['nb_line']); } else { $nbImages = $lang['dl_empty_cart']; } return $nbImages; } // Mise à jour du panier function DmCart() { if (isset($_POST['action'])) { $this->DmControle(); } } // Affiche l'entrée HTML du formulaire function DmFormThumbnail() { global $template; $template->concat('PLUGIN_INDEX_CONTENT_BEGIN', '
'); } // Affiche les cases à cocher derrière le nom de l'image function DmCategoryThumbnail($tpl_var) { foreach($tpl_var as $cle=>$valeur) { $tpl_var[$cle]['NAME'] = $tpl_var[$cle]['NAME'].' '; } return $tpl_var; } // Affichage du formulaire sous les vignettes function DmCategoryDefault() { global $user, $template, $lang; // Intégration du formulaire sous les images $template->set_filenames( array('DownloadMulti_category' => $this->plugin_path.'template/DmCategory.tpl') ); $list_dl = array('thumbnail' => $lang['dl_thumbnail'], 'normal' => $lang['dl_normal']); // Si l'utilisateur n'a pas le droit aux hautes définitions // alors la ligne de téléchargement des hautes définitions // ne s'affiche pas. if($user['enabled_high'] == 1) { $list_dl['high'] = $lang['dl_high']; } $template->assign('type', $list_dl); $template->assign('select', $this->my_config['select_dl']); // Gestion du template $dm_html = $template->parse('DownloadMulti_category', true); $template->concat('PLUGIN_INDEX_CONTENT_END', $dm_html); } // Controle les valeurs envoyés par le formulaire // Crée les répertoires zip_archive et celui de l'utilisateur // si ils n'existent pas function DmControle() { global $template, $lang, $user, $errors; $errors = array(); if(isset($_POST['id_images'])) { $id_images = $_POST['id_images']; } if(isset($_POST['mode'])) { $mode = $_POST['mode']; } // Test si au moins une image à été // sélectionné if(count($id_images) == 1) { array_push($errors, $lang['dl_choice_image']); } // Test le répertoire zip_archive // Si il n'existe pas le script le créé // Action nécessaire pour résoudre le problème de droit chez certains hébergeurs $dir = $this->plugin_path; if(!is_dir($dir.'zip_archive/')) { umask(0000); if(!mkdir($dir.'zip_archive/', 0755)) { array_push($errors, $lang['dl_dir_zip']); } } // Création du répertoire de l'utilisateur avec sont id user if(!is_dir($dir.'zip_archive/'.$user['id'])) { umask(0000); if(!mkdir($dir.'zip_archive/'.$user['id'], 0755)) { array_push($errors, $lang['dl_dir_zip']); } } clearstatcache(); // Si il n'y a aucunes erreurs // on continue l'ajout dans la panier if(count($errors) == 0) { $this->DmAddPicture($id_images, $mode); $this->DmCountCart(); } } /* Ajoute les images dans le panier * $id_images --> Liste des images sélectionnés * $mode --> Type d'images ajouter (thumbnail, normal, high) */ function DmAddPicture($id_images, $mode) { global $user, $prefixeTable, $template, $lang, $errors; switch($mode) { case 'thumbnail': // Insertion des vignettes dans la base de données for($i=0;$iassign('errors', $errors); } break; case 'normal': // Pas propre mais nécessaire pour get_image_path include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php'); // Insertion des photos normal dans la base de données for($i=0;$iassign('errors', $errors); } break; case 'high': // Pas propre mais nécessaire pour get_image_path include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php'); // Insertion des hautes définitions dans la base de données for($i=0;$iassign('prefix', array( 'VALUE' => $this->my_config['prefix'], 'F_ACTION' => 'DmPanier.php?DmAction=genfic', ) ); } /* Si la page est rechargé par le bouton "Supprimer" * du formulaire il ne faut pas recréer les fichiers */ function DmPanierGenZip($prefix) { global $prefixeTable, $user, $template, $lang, $counter, $conf; $errors = array(); if(preg_match('/[^a-z0-9\-_]/', $prefix)) { array_push($errors, $lang['dl_no_prefix']); } else { if($this->my_config['create_category']) { // Sélection des photos par rapport à l'id utilisateur // Récupération de la structure des catégories $query = ' SELECT '.$prefixeTable.'download_multi.id_image, '.$prefixeTable.'download_multi.filesize, '.$prefixeTable.'download_multi.type, t_images.file, t_images.path, t_images.tn_ext, t_images.has_high, t_images.id, t_images.name, t_category.category_id FROM '.$prefixeTable.'download_multi INNER JOIN '.IMAGES_TABLE.' t_images ON t_images.id = '.$prefixeTable.'download_multi.id_image INNER JOIN '.IMAGE_CATEGORY_TABLE.' t_category ON t_images.id = t_category.image_id WHERE id_user = '.$user['id'].' ;'; } else { $query = ' SELECT '.$prefixeTable.'download_multi.id_image, '.$prefixeTable.'download_multi.filesize, '.$prefixeTable.'download_multi.type, '.IMAGES_TABLE.'.file, '.IMAGES_TABLE.'.path, '.IMAGES_TABLE.'.tn_ext, '.IMAGES_TABLE.'.has_high, '.IMAGES_TABLE.'.id FROM '.$prefixeTable.'download_multi INNER JOIN '.IMAGES_TABLE.' ON '.IMAGES_TABLE.'.id = '.$prefixeTable.'download_multi.id_image WHERE id_user = '.$user['id'].' ;'; } $result = pwg_query($query); $nbresult = mysql_num_rows($result); // Si le nombre d'enregistrement est inférieur à // alors il n'y a pas de fichier proposé au téléchargement if ($nbresult == 0) { array_push($errors, $lang['dl_no_file']); } else { // Découpage pour la création // de la barre de progression $indice = floor(100 / $nbresult); $indices = 0; $template->set_filenames( array('DownloadMulti_waiting' => $this->plugin_path.'/template/DmWaiting.tpl') ); $template->assign('waiting', $indices); $i = 0; $fichiers = array(); $counter = 0; while ($row = mysql_fetch_array($result)) { $cat_info = ''; $cat_name = ''; $c = 0; if ($row['type'] == 't') { $fichiers[$i]['path'] = get_thumbnail_path($row); $fichiers[$i]['poids'] = $row['filesize']; // Récupération du fichier originel ou alors du nom // de fichier créé par pLoader // ToDo : A MODIFIER LORSQUE LE NOM DU VRAI FICHIER SERA STOCKE PAR Piwigo if (empty($row['name'])) { $fichiers[$i]['name'] = $conf['prefix_thumbnail'].$row['file']; } else { $fichiers[$i]['name'] = $conf['prefix_thumbnail'].$row['name']; } if($this->my_config['create_category']) { // Recréation de la structure des catégories $cat_info = get_cat_info($row['category_id']); if (!empty($cat_info['uppercats'])) { $nb_cat = count(explode(',', $cat_info['uppercats'])); while ($c < $nb_cat) { $cat_name = $cat_name.$cat_info['upper_names'][$c]['name'].'/'; $c++; } $fichiers[$i]['cat_name'] = $cat_name.'thumbnails/'; } } else { $fichiers[$i]['cat_name'] = $fichiers[$i]['path']; } $i++; } if ($row['type'] == 'n') { include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php'); $fichiers[$i]['path'] = get_image_path($row); $fichiers[$i]['poids'] = $row['filesize']; // Récupération du fichier original ou alors du nom // de fichier créé par pLoader // ToDo : A MODIFIER LORSQUE LE NOM DU VRAI FICHIER SERA STOCKE PAR Piwigo if (empty($row['name'])) { $fichiers[$i]['name'] = $row['file']; } else { $fichiers[$i]['name'] = $row['name']; } if($this->my_config['create_category']) { // Recréation de la structure des catégories $cat_info = get_cat_info($row['category_id']); if (!empty($cat_info['uppercats'])) { $nb_cat = count(explode(',', $cat_info['uppercats'])); while ($c < $nb_cat) { $cat_name = $cat_name.$cat_info['upper_names'][$c]['name'].'/'; $c++; } $fichiers[$i]['cat_name'] = $cat_name; } } else { $fichiers[$i]['cat_name'] = $fichiers[$i]['path']; } $i++; } if ($row['type'] == 'h') { include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php'); $fichiers[$i]['path'] = get_high_path($row); $fichiers[$i]['poids'] = $row['filesize']; // Récupération du fichier originel ou alors du nom // de fichier créé par pLoader // ToDo : A MODIFIER LORSQUE LE NOM DU VRAI FICHIER SERA STOCKE PAR Piwigo if (empty($row['name'])) { $fichiers[$i]['name'] = $row['file']; } else { $fichiers[$i]['name'] = $row['name']; } if($this->my_config['create_category']) { // Recréation de la structure des catégories $cat_info = get_cat_info($row['category_id']); if (!empty($cat_info['uppercats'])) { $nb_cat = count(explode(',', $cat_info['uppercats'])); while ($c < $nb_cat) { $cat_name = $cat_name.$cat_info['upper_names'][$c]['name'].'/'; $c++; } $fichiers[$i]['cat_name'] = $cat_name.'pwg_high/'; } } else { $fichiers[$i]['cat_name'] = $fichiers[$i]['path']; } $i++; } } $fic_size = 0; if(class_exists('zipArchive')) { // Création de la 1ere archive $this->DmCreateZip($prefix); foreach($fichiers as $cle => $file) { $indices = $indice + $indices; // Contrôle la taille de l'archive // si elle est inférieur à la configuration // la boucle continue d'ajouter des fichiers if ($file['poids'] >= $this->my_config['archive_size']) { $this->DmAddZip($file['path'], $file['cat_name'].$file['name']); $this->DmCloseZip(); $counter = $counter + 1; $this->DmCreateZip($prefix); $fic_size = 0; } else if($fic_size <= $this->my_config['archive_size']) { $this->DmAddZip($file['path'], $file['cat_name'].$file['name']); } else { // si la taille est supérieur à la configuration // alors l'archive précédente est fermé // et une nouvelle est créé $this->DmCloseZip(); $this->DmCreateZip($prefix); $this->DmAddZip($file['path'], $file['cat_name'].$file['name']); $fic_size = 0; } $fic_size = $file['poids'] + $fic_size; // Force l'affichage de la barre de progression if(function_exists('ob_flush')) { $template->assign('waiting', $indices); $dm_html = $template->pparse('DownloadMulti_waiting'); $template->concat('PLUGIN_INDEX_PANIER_BEFORE', $dm_html); echo ' '; @ob_flush(); flush(); @ob_flush(); flush(); } } $this->DmCloseZip(); } // ANNULE : http://fr.piwigo.org/forum/viewtopic.php?pid=118210#p118210 /*else { require_once $this->plugin_path.'include/pclzip.lib.php'; $fic_size = 0; $create_zip_archive = 1; $i = 0; foreach($fichiers as $cle => $file) { $indices = $indice + $indices; if ($file['poids'] >= $this->my_config['archive_size']) { $this->DmPclZipCreateZip($prefix, $file['path']); } else if ($fic_size <= $this->my_config['archive_size']) { $this->DmPclZipAddZip($prefix, $file['path'], $create_zip_archive); $fic_size = $file['poids'] + $fic_size; } /*else { $create_zip_archive = 1; $this->DmPclZipAddZip($prefix, $file['path'], $create_zip_archive); $fic_size = 0; } // Force l'affichage de la barre de progression if(function_exists('ob_flush')) { $template->assign('waiting', $indices); $dm_html = $template->pparse('DownloadMulti_waiting'); $template->concat('PLUGIN_INDEX_PANIER_BEFORE', $dm_html); echo ' '; @ob_flush(); flush(); @ob_flush(); flush(); } } }*/ } } // Liste le répertoire de l'utlilisateur $this->DmPanierListeDir(); if(count($errors) != 0) { $template->assign('errors', $errors); $this->DmPanierPrefixZip(); } } // Créé l'archive avec son nom // avec la lib PclZip // ANNULE : http://fr.piwigo.org/forum/viewtopic.php?pid=118210#p118210 /*function DmPclZipCreateZip($prefix, $path) { global $template, $lang, $errors; $fichier_zip = $this->DmCreateNameZip($prefix); $archive = new PclZip($fichier_zip); if ($this->my_config['active_comment']) { $action = $archive->create($path, PCLZIP_OPT_REMOVE_PATH, PHPWG_ROOT_PATH.'upload', PCLZIP_OPT_ADD_PATH, $this->my_config['prefix_dir'], PCLZIP_OPT_COMMENT, $this->my_config['comment'], PCLZIP_OPT_NO_COMPRESSION ); } else { $action = $archive->create($path, PCLZIP_OPT_REMOVE_PATH, PHPWG_ROOT_PATH.'upload', PCLZIP_OPT_ADD_PATH, $this->my_config['prefix_dir'], PCLZIP_OPT_NO_COMPRESSION ); } if ($action == 0) { array_push($errors, $lang['dl_no_file']); $template->assign('errors', $errors); } }*/ // ANNULE : http://fr.piwigo.org/forum/viewtopic.php?pid=118210#p118210 // Ajout des fichiers dans l'archive // avec la lib PclZip /*function DmPclZipAddZip($prefix, $path, $create_zip_archive) { global $errors, $template, $lang, $create_zip_archive, $user; if ($create_zip_archive == 1) { $fichier_zip = $this->DmCreateNameZip($prefix); $create_zip_archive = 0; } else { $fichier_zip = get_class_vars(get_class($action)); $fichier_zip = $fichier_zip['zipname']; } $archive = new PclZip($fichier_zip); if ($this->my_config['active_comment']) { $action = $archive->add($path, PCLZIP_OPT_REMOVE_PATH, PHPWG_ROOT_PATH.'upload', PCLZIP_OPT_ADD_PATH, $this->my_config['prefix_dir'], PCLZIP_OPT_COMMENT, $this->my_config['comment'], PCLZIP_OPT_NO_COMPRESSION ); } else { $action = $archive->add($path, PCLZIP_OPT_REMOVE_PATH, PHPWG_ROOT_PATH.'upload', PCLZIP_OPT_ADD_PATH, $this->my_config['prefix_dir'], PCLZIP_OPT_NO_COMPRESSION ); var_dump($action); } if ($action == 0) { array_push($errors, $lang['dl_no_file'].'
'.$archive->errorInfo(true)); $template->assign('errors', $errors); } }*/ // Génération du nom de fichier zip function DmCreateNameZip($prefix) { global $user, $counter; $dir_zip = $this->plugin_path.'zip_archive/'.$user['id'].'/'; // nom du fichier zip $nom_fichier = str_replace('[date]', date('Ymd'), $this->my_config['pattern_name']); $nom_fichier = str_replace('[rand]', rand(1, 2000), $nom_fichier); $nom_fichier = $prefix.$nom_fichier.'_'.$counter; $fichier_zip = $dir_zip.$nom_fichier.'.zip'; // chemin d'accès au fichier zip return $fichier_zip; } // Création de l'instance zip // et création de l'archive avec la class zipArchive function DmCreateZip($prefix) { global $zip; $fichier_zip = $this->DmCreateNameZip($prefix); $zip = new ZipArchive(); $zip->open($fichier_zip, ZIPARCHIVE::CREATE); } // Ajout des fichiers dans l'archive // avec la class zipArchive function DmAddZip($path, $file_name) { global $zip; if(!$this->my_config['create_category']) { $file_name = str_replace(PHPWG_ROOT_PATH.'./galleries/', '', $file_name); $file_name = str_replace(PHPWG_ROOT_PATH.'./upload/', '', $file_name); } $zip->addFile($path, $this->my_config['prefix_dir'].'/'.$file_name); if($this->my_config['active_comment']) { $zip->setArchiveComment($this->my_config['comment']); } } // Fermeture de l'archive // avec la class zipArchive function DmCloseZip() { global $zip; $zip->close(); } /* Liste le répertoire utilisateur */ function DmPanierListeDir() { global $user, $template, $lang, $errors; $dir_zip = $this->plugin_path.'zip_archive/'.$user['id'].'/'; $errors = array(); $dir = opendir($dir_zip); while($file = readdir($dir)) { if(!is_file($file) && $file != '.' && $file != '..') { $tab_file[] = array('file' => $file, 'date' => filemtime($dir_zip.$file)); } } closedir($dir); clearstatcache(); if (isset($tab_file)) { $template->assign( array( 'F_ACTION' => 'DmPanier.php?DmAction=del' ) ); // Obtient une liste de colonnes foreach ($tab_file as $key => $row) { $file[$key] = $row['file']; $date[$key] = $row['date']; } // Tri les données par volume décroissant, edition croissant // Ajoute $data en tant que dernier paramêtre, pour trier par la clé commune array_multisort($file, SORT_ASC, $date, SORT_DESC, $tab_file); foreach($tab_file as $elem) { $tpl_var = array( 'FIC_CHEMIN' => $this->plugin_url.'plugins/'.$this->plugin_name.'/zip_archive/'.$user['id'].'/', 'FIC_NAME' => $elem['file'], 'FIC_DATE' => $this->DmPanierDd($elem['date']) ); $template->append('telechargements', $tpl_var); } } else { array_push($errors, $lang['dl_no_file']); $template->assign('errors', $errors); } } // Vide le panier en cours function DmPanierDelete() { global $user, $prefixeTable; // Suppression des images sélectionné dans une précédente session $query = ' DELETE FROM '.$prefixeTable.'download_multi WHERE id_user = \''.$user['id'].'\' ;'; $result = pwg_query($query); // Optimisation de la table pour éviter la fragmentation // après suppression d'enregistrements $query = ' OPTIMIZE TABLE '.$prefixeTable.'download_multi ;'; $result = pwg_query($query); redirect(duplicate_index_url()); } /* Suppression des fichiers dans le * répertoire utilisateur * $fic --> liste des fichiers */ function DmPanierDelUserDir($fic) { global $user, $prefixeTable; if (isset($fic)) { $dir_zip = $this->plugin_path.'zip_archive/'.$user['id'].'/'; foreach($fic as $file) { unlink($dir_zip.$file); } clearstatcache(); } } /* Renvoie la date */ function DmPanierDd($date) { return date("d/m/Y H:i:s", $date); } /* ------- Fin de la page DmPanier.php ------ */ /* ------- Section pour le fichier DmPreview.php ------ */ /* Affiche la liste des images */ function DmPreviewList() { global $prefixeTable, $user, $template, $lang, $errors; $errors = array(); $query = ' SELECT * FROM '.$prefixeTable.'download_multi INNER JOIN '.IMAGES_TABLE.' ON '.IMAGES_TABLE.'.id = '.$prefixeTable.'download_multi.id_image WHERE id_user = '.$user['id'].' ORDER BY file ;'; $result = pwg_query($query); // Si il n'y a pas d'enregistrement // Affiche le message 'panier vide' if (mysql_num_rows($result) == 0) { array_push($errors, $lang['dl_empty_cart']); $template->assign('errors', $errors); } else { while ($row = mysql_fetch_array($result)) { $type = $row['type']; switch ($type) { case 't': $txt_type = $lang['dl_type_thumbnail']; $img_type = 'page_white_world.png'; break; case 'n': $txt_type = $lang['dl_type_normal']; $img_type = 'page_white_picture.png'; break; case 'h': $txt_type = $lang['dl_type_high']; $img_type = 'page_white_camera.png'; break; } $url = duplicate_picture_url( array( 'image_id' => $row['id'], 'image_file' => $row['file'] ), array('start') ); $thumbnail_url = get_thumbnail_url($row); $tpl_var = array( 'F_ID_IMAGE' => $row['id_image'], 'F_TYPE' => $type, 'NAME' => get_thumbnail_title($row), 'TYPE' => $txt_type, 'IMG' => $img_type, 'URL' => $url, 'TN_SRC' => $thumbnail_url ); $template->append('thumbnails', $tpl_var); } } } /* Supprime une image * id_image -> identifiant de l'image * type -> type de l'image */ function DmPreviewDel($id_image, $type) { global $prefixeTable; // Suppression d'une image par rapport à sont id $query = ' DELETE FROM '.$prefixeTable.'download_multi WHERE id_image = \''.$id_image.'\' AND type = \''.$type.'\' ;'; $result = pwg_query($query); // Optimisation de la table pour éviter la fragmentation // après suppression d'enregistrements $query = ' OPTIMIZE TABLE '.$prefixeTable.'download_multi ;'; $result = pwg_query($query); } /* ------- Fin de la page DmPreview.php ------ */ /* ------- Administration ------- */ function DmServeurConfiguration() { global $template; if(class_exists('zipArchive')) { $template->assign( 'DmServeurConfiguration', array( 'ZIP' => 'zipArchive', 'PHP_VERSION' => PHP_VERSION, ) ); } else { $template->assign( 'DmServeurConfiguration', array( 'ZIP' => 'PclZip', 'PHP_VERSION' => PHP_VERSION, ) ); } } } ?>