| 2 | 
           ddelon | 
           1 | 
           <?php
  | 
        
        
            | 
            | 
           2 | 
           /*
  | 
        
        
            | 
            | 
           3 | 
           attach.php
  | 
        
        
            | 
            | 
           4 | 
           Code original de ce fichier : Eric FELDSTEIN
  | 
        
        
            | 
            | 
           5 | 
           Copyright (c) 2002, Hendrik Mans <hendrik@mans.de>
  | 
        
        
            | 
            | 
           6 | 
           Copyright 2002, 2003 David DELON
  | 
        
        
            | 
            | 
           7 | 
           Copyright 2002, 2003 Charles NEPOTE
  | 
        
        
            | 
            | 
           8 | 
           Copyright  2003,2004  Eric FELDSTEIN
  | 
        
        
            | 
            | 
           9 | 
           Copyright  2003  Jean-Pascal MILCENT
  | 
        
        
            | 
            | 
           10 | 
           All rights reserved.
  | 
        
        
            | 
            | 
           11 | 
           Redistribution and use in source and binary forms, with or without
  | 
        
        
            | 
            | 
           12 | 
           modification, are permitted provided that the following conditions
  | 
        
        
            | 
            | 
           13 | 
           are met:
  | 
        
        
            | 
            | 
           14 | 
           1. Redistributions of source code must retain the above copyright
  | 
        
        
            | 
            | 
           15 | 
           notice, this list of conditions and the following disclaimer.
  | 
        
        
            | 
            | 
           16 | 
           2. Redistributions in binary form must reproduce the above copyright
  | 
        
        
            | 
            | 
           17 | 
           notice, this list of conditions and the following disclaimer in the
  | 
        
        
            | 
            | 
           18 | 
           documentation and/or other materials provided with the distribution.
  | 
        
        
            | 
            | 
           19 | 
           3. The name of the author may not be used to endorse or promote products
  | 
        
        
            | 
            | 
           20 | 
           derived from this software without specific prior written permission.
  | 
        
        
            | 
            | 
           21 | 
              | 
        
        
            | 
            | 
           22 | 
           THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  | 
        
        
            | 
            | 
           23 | 
           IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  | 
        
        
            | 
            | 
           24 | 
           OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  | 
        
        
            | 
            | 
           25 | 
           IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  | 
        
        
            | 
            | 
           26 | 
           INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  | 
        
        
            | 
            | 
           27 | 
           NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  | 
        
        
            | 
            | 
           28 | 
           DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  | 
        
        
            | 
            | 
           29 | 
           THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  | 
        
        
            | 
            | 
           30 | 
           (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  | 
        
        
            | 
            | 
           31 | 
           THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  | 
        
        
            | 
            | 
           32 | 
           */
  | 
        
        
            | 
            | 
           33 | 
           /******************************************************************************
  | 
        
        
            | 
            | 
           34 | 
           *			DOCUMENTATION
  | 
        
        
            | 
            | 
           35 | 
           *******************************************************************************
  | 
        
        
            | 
            | 
           36 | 
           	RESUME
  | 
        
        
            | 
            | 
           37 | 
           L'action {{attach}} permet de lier un fichier à une page, d'uploader ce fichier
  | 
        
        
            | 
            | 
           38 | 
           et de downloader ce fichier. Si le fichier est une image, elle est affichée
  | 
        
        
            | 
            | 
           39 | 
           dans la page. Lorsque le fichier est sur le serveur, il est possible de faire
  | 
        
        
            | 
            | 
           40 | 
           une mise à jour de celui-ci.
  | 
        
        
            | 
            | 
           41 | 
              | 
        
        
            | 
            | 
           42 | 
           	PARAMETRES DE L'ACTION
  | 
        
        
            | 
            | 
           43 | 
           L'action {{attach}} prend les paramètres suivants :
  | 
        
        
            | 
            | 
           44 | 
            - file ou attachfile: nom du fichier tel qu'il sera sur le serveur. Les
  | 
        
        
            | 
            | 
           45 | 
              espaces sont remplacé par des "_". (OBLIGATOIRE)
  | 
        
        
            | 
            | 
           46 | 
            - desc ou attachdesc: description du fichier. C'est le texte qui sera affiché
  | 
        
        
            | 
            | 
           47 | 
              comme lien vers le fichier ou dans l'attribut alt de la balise <img>. Ce
  | 
        
        
            | 
            | 
           48 | 
              paramètre est obligatoire pour les images pour être conforme au XHTML.
  | 
        
        
            | 
            | 
           49 | 
            - delete ou attachdelete: Si ce paramètre est non vide alors le fichier sera
  | 
        
        
            | 
            | 
           50 | 
              effacé sur le serveur.
  | 
        
        
            | 
            | 
           51 | 
            - link ou attachlink: URL de lien pour une image sensible. le lien peut être
  | 
        
        
            | 
            | 
           52 | 
              un nom de page WikiNi, un lien interwiki ou une adresse http
  | 
        
        
            | 
            | 
           53 | 
            - class: indique le nom de la ou les classes de style à utiliser pour afficher
  | 
        
        
            | 
            | 
           54 | 
              l'image. les noms des classes sont séparés par un espace.
  | 
        
        
            | 
            | 
           55 | 
              | 
        
        
            | 
            | 
           56 | 
           	EXEMPLES
  | 
        
        
            | 
            | 
           57 | 
            - Attacher un fichier archive:
  | 
        
        
            | 
            | 
           58 | 
            		{{attach file="archive.zip"}}
  | 
        
        
            | 
            | 
           59 | 
            - Attacher un fichier archive avec une description
  | 
        
        
            | 
            | 
           60 | 
            		{{attach file="archive.zip" desc="Code source de l'application"}}
  | 
        
        
            | 
            | 
           61 | 
            - Supprimer un fichier:
  | 
        
        
            | 
            | 
           62 | 
            		{{attach file="archive.zip" delete="y"}}
  | 
        
        
            | 
            | 
           63 | 
            - Afficher une image:
  | 
        
        
            | 
            | 
           64 | 
            		{{attach file="image.png" desc="voici une image"}}
  | 
        
        
            | 
            | 
           65 | 
            - Afficher une image sensible:
  | 
        
        
            | 
            | 
           66 | 
            		{{attach file="image.png" desc="voici une image" link="PagePrincipale"}}
  | 
        
        
            | 
            | 
           67 | 
            		{{attach file="image.png" desc="voici une image" link="WikiNi:PagePrincipale"}}
  | 
        
        
            | 
            | 
           68 | 
            		{{attach file="image.png" desc="voici une image" link="http://www.wikini.net"}}
  | 
        
        
            | 
            | 
           69 | 
            - Afficher une image collé sur le bord droit et sans contour:
  | 
        
        
            | 
            | 
           70 | 
            		{{attach file="image.png" desc="voici une image" class="right noborder"}}
  | 
        
        
            | 
            | 
           71 | 
              | 
        
        
            | 
            | 
           72 | 
           	INSTALLATION
  | 
        
        
            | 
            | 
           73 | 
           1) Copiez le fichier attach.php dans le répertoire des actions (/actions)
  | 
        
        
            | 
            | 
           74 | 
           2) Copiez le fichier attach.class.php dans le répertoire des actions (/actions)
  | 
        
        
            | 
            | 
           75 | 
           3) Copiez le fichier attachfm.php dans le repertoire des actions (/actions)
  | 
        
        
            | 
            | 
           76 | 
           4) Copiez le fichier filamanager.php dans le répertoire des handlers (/handlers/page)
  | 
        
        
            | 
            | 
           77 | 
           5) Copiez le fichier upload.php dans le répertoire des handlers (/handlers/page)
  | 
        
        
            | 
            | 
           78 | 
           6) Copiez le fichier download.php dans le répertoire des handlers (/handlers/page)
  | 
        
        
            | 
            | 
           79 | 
           7) Créez le répertoire racine des uploads sur le site du wiki. Si le SAFE_MODE
  | 
        
        
            | 
            | 
           80 | 
           	de PHP est activé, vous devez créer vous même ce répertoire et autoriser
  | 
        
        
            | 
            | 
           81 | 
           	l'écriture dans ce répertoire pour l'utilisateur et le groupe.
  | 
        
        
            | 
            | 
           82 | 
           8) Ouvrez le fichier wakka.config.php et ajoutez la configuration de l'action.
  | 
        
        
            | 
            | 
           83 | 
           	Tous les paramètres de configuration ont une valeur par défaut.
  | 
        
        
            | 
            | 
           84 | 
           	Le configuration par défaut est:
  | 
        
        
            | 
            | 
           85 | 
              | 
        
        
            | 
            | 
           86 | 
           	$wakkaConfig["attach_config"] = array(
  | 
        
        
            | 
            | 
           87 | 
           			"upload_path" => 'files',				//repertoire racine des uploads
  | 
        
        
            | 
            | 
           88 | 
           			"ext_images" => 'gif|jpeg|png|jpg',	//extension des fichiers images
  | 
        
        
            | 
            | 
           89 | 
           			"ext_script" => 'php|php3|asp|asx|vb|vbs|js',	//extension des script(non utilisé)
  | 
        
        
            | 
            | 
           90 | 
           			"update_symbole" => '*',				//symbole pour faire un update du fichier
  | 
        
        
            | 
            | 
           91 | 
           			"max_file_size" => 1024*100,			//taille maximum du fichier en octer (100Ko par défaut)
  | 
        
        
            | 
            | 
           92 | 
           			"fmDelete_symbole" => 'Supr',			//symbole a afficher pour le lien "supprimer" dans le gestionnaire de fichier
  | 
        
        
            | 
            | 
           93 | 
           			"fmRestore_symbole" => 'Rest',		//symbole a afficher pour le lien "restaurer" dans le gestionnaire de fichier
  | 
        
        
            | 
            | 
           94 | 
           			"fmTrash_symbole" => 'Poubelle')		//symbole a afficher pour le lien "Poubelle" dans le gestionnaire de fichier
  | 
        
        
            | 
            | 
           95 | 
              | 
        
        
            | 
            | 
           96 | 
           9) Ajoutez les classes de style au fichier wakka.css. Exemple de style :
  | 
        
        
            | 
            | 
           97 | 
           .attach_margin05em { margin: 0.5em;}
  | 
        
        
            | 
            | 
           98 | 
           .attach_margin1em { margin: 1em;}
  | 
        
        
            | 
            | 
           99 | 
           .attach_left {float: left;}
  | 
        
        
            | 
            | 
           100 | 
           .attach_right {float: right;}
  | 
        
        
            | 
            | 
           101 | 
           .attach_noborder {border-width: 0px;}
  | 
        
        
            | 
            | 
           102 | 
           .attach_vmiddle {vertical-align: text-bottom;}
  | 
        
        
            | 
            | 
           103 | 
              | 
        
        
            | 
            | 
           104 | 
           10)Pour configurer l'aspect du gestionnnaire de fichier utiliser les classes de style .tableFM
  | 
        
        
            | 
            | 
           105 | 
           tableFMCol1 et tableFMCol2
  | 
        
        
            | 
            | 
           106 | 
           Exemple :
  | 
        
        
            | 
            | 
           107 | 
           .tableFM {border: thin solid Black; width: 100%;  }
  | 
        
        
            | 
            | 
           108 | 
           .tableFM THEAD { background-color: Silver; font-weight: bold; text-align: center;   }
  | 
        
        
            | 
            | 
           109 | 
           .tableFM TFOOT { background-color: Silver; font-weight: bold; text-align: left;   }
  | 
        
        
            | 
            | 
           110 | 
           .tableFM TBODY TR { text-align: center;  }
  | 
        
        
            | 
            | 
           111 | 
           .tableFMCol1 { background-color: Aqua; }
  | 
        
        
            | 
            | 
           112 | 
           .tableFMCol2 { background-color: Yellow; }
  | 
        
        
            | 
            | 
           113 | 
           *******************************************************************************/
  | 
        
        
            | 
            | 
           114 | 
              | 
        
        
            | 
            | 
           115 | 
           if (!class_exists('attach')){
  | 
        
        
            | 
            | 
           116 | 
           	include($this->GetConfigValue('action_path').'/attach.class.php');
  | 
        
        
            | 
            | 
           117 | 
           }
  | 
        
        
            | 
            | 
           118 | 
           $att = new attach($this);
  | 
        
        
            | 
            | 
           119 | 
           $att->doAttach();
  | 
        
        
            | 
            | 
           120 | 
           unset($att);
  | 
        
        
            | 
            | 
           121 | 
           ?>
  |