phpDocumentor lodel-logic
[ class tree: lodel-logic ] [ index: lodel-logic ] [ all elements ]

Source for file class.filebrowser.php

Documentation is available at class.filebrowser.php

  1. <?php
  2. /**    
  3.  * Logique du navigateur de fichiers
  4.  *
  5.  * PHP versions 4 et 5
  6.  *
  7.  * LODEL - Logiciel d'Edition ELectronique.
  8.  *
  9.  * Home page: http://www.lodel.org
  10.  * E-Mail: lodel@lodel.org
  11.  *
  12.  * All Rights Reserved
  13.  *
  14.  * This program is free software; you can redistribute it and/or modify
  15.  * it under the terms of the GNU General Public License as published by
  16.  * the Free Software Foundation; either version 2 of the License, or
  17.  * (at your option) any later version.
  18.  *
  19.  * This program is distributed in the hope that it will be useful,
  20.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22.  * GNU General Public License for more details.
  23.  *
  24.  * You should have received a copy of the GNU General Public License
  25.  * along with this program; if not, write to the Free Software
  26.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  27.  *
  28.  * @package lodel/logic
  29.  * @author Ghislain Picard
  30.  * @author Jean Lamy
  31.  * @copyright 2001-2002, Ghislain Picard, Marin Dacos
  32.  * @copyright 2003, Ghislain Picard, Marin Dacos, Luc Santeramo, Nicolas Nutten, Anne Gentil-Beccot
  33.  * @copyright 2004, Ghislain Picard, Marin Dacos, Luc Santeramo, Anne Gentil-Beccot, Bruno Cénou
  34.  * @copyright 2005, Ghislain Picard, Marin Dacos, Luc Santeramo, Gautier Poupeau, Jean Lamy, Bruno Cénou
  35.  * @copyright 2006, Marin Dacos, Luc Santeramo, Bruno Cénou, Jean Lamy, Mikaël Cixous, Sophie Malafosse
  36.  * @copyright 2007, Marin Dacos, Bruno Cénou, Sophie Malafosse, Pierre-Alain Mignot
  37.  * @licence http://www.gnu.org/copyleft/gpl.html
  38.  * @since Fichier ajouté depuis la version 0.8
  39.  * @version CVS:$Id: class.filebrowser.php 4006 2007-10-05 11:53:41Z malafosse $
  40.  */
  41.  
  42.  
  43. define("UPLOADDIR",SITEROOT."upload");
  44.  
  45. $GLOBALS['nodesk']=true;
  46.  
  47.  
  48. /**
  49.  * Classe de logique du navigateur de fichier
  50.  * 
  51.  * @package lodel/logic
  52.  * @author Ghislain Picard
  53.  * @author Jean Lamy
  54.  * @copyright 2001-2002, Ghislain Picard, Marin Dacos
  55.  * @copyright 2003, Ghislain Picard, Marin Dacos, Luc Santeramo, Nicolas Nutten, Anne Gentil-Beccot
  56.  * @copyright 2004, Ghislain Picard, Marin Dacos, Luc Santeramo, Anne Gentil-Beccot, Bruno Cénou
  57.  * @copyright 2005, Ghislain Picard, Marin Dacos, Luc Santeramo, Gautier Poupeau, Jean Lamy, Bruno Cénou
  58.  * @copyright 2006, Marin Dacos, Luc Santeramo, Bruno Cénou, Jean Lamy, Mikaël Cixous, Sophie Malafosse
  59.  * @copyright 2007, Marin Dacos, Bruno Cénou, Sophie Malafosse, Pierre-Alain Mignot
  60.  * @licence http://www.gnu.org/copyleft/gpl.html
  61.  * @since Classe ajouté depuis la version 0.8
  62.  * @see logic.php
  63.  */
  64.  
  65.     /** Constructor
  66.     */
  67.     function FileBrowserLogic({
  68.         if (!$GLOBALS['lodeluser']['redactor']die("ERROR: you don't have the right to access this feature");
  69.     }
  70.  
  71.     /**
  72.      * Affichage d'un objet
  73.      *
  74.      * @param array &$context le contexte passé par référence
  75.      * @param array &$error le tableau des erreurs éventuelles passé par référence
  76.      */
  77.     function viewAction(&$context,&$error)
  78.  
  79.     {
  80.         return "filebrowser";
  81.     }
  82.  
  83.     /**
  84.         * dispatcher Action
  85.         */
  86.  
  87.     function submitAction(&$context,&$error)
  88.  
  89.     {
  90.         if ($_POST['checkmail']return $this->checkMailAction($context,$error);
  91.         if ($_POST['resize'&& $_POST['newsize']return $this->resizeAction($context,$error);
  92.         if ($_POST['delete']return $this->deleteAction($context,$error);
  93.     }
  94.  
  95.     /**
  96.         * check Mail and store files in attachments
  97.         */
  98.  
  99.     function checkMailAction(&$context,&$error)
  100.  
  101.     {
  102.         require_once("imapfunc.php");
  103.         $context['nbattachments']=checkmailforattachments();
  104.         update();
  105.         return "filebrowser";
  106.     }
  107.  
  108.     /**
  109.         * delete files
  110.         */
  111.  
  112.     function deleteAction(&$context,&$error)
  113.  
  114.     {
  115.         $selectedfiles=is_array($context['file']array_keys($context['file']false;
  116.         $dh=@opendir(UPLOADDIR);
  117.         if (!$dhdie("ERROR: can't open upload directory");
  118.  
  119.         while( ($file=readdir($dh))!==false {
  120.             if ($file[0]!="." || is_file(UPLOADDIR."/".$file)) {
  121.     if (in_array($file,$selectedfiles)) // quite safe way, not efficient !
  122.         @unlink(UPLOADDIR."/".$file);
  123.     }
  124.             }
  125.         }
  126.         update();
  127.         return "filebrowser";
  128.     }
  129.  
  130.     /**
  131.         * 
  132.         */
  133.  
  134.     function resizeAction(&$context,&$error)
  135.  
  136.     {
  137.         $selectedfiles=is_array($context['file']array_keys($context['file']false;
  138.         require_once("images.php");
  139.         $dh=@opendir(UPLOADDIR);
  140.         if (!$dhdie("ERROR: can't open upload directory");
  141.         while( ($file=readdir($dh))!==false {
  142.             if ($file[0]!="." || is_file(UPLOADDIR."/".$file)) {
  143.     if (in_array($file,$selectedfiles)) // quite safe way, not efficient !
  144.         $file=UPLOADDIR."/".$file;
  145.         resize_image($context['newsize'],$file,$file);
  146.     }
  147.             }
  148.         }
  149.         update();
  150.         return "filebrowser";
  151.     }
  152.  
  153. // logic FileBrowserLogic
  154.  
  155.  
  156. function loop_filelist($context,$funcname)
  157.  
  158. {
  159.     $dh=@opendir(UPLOADDIR);
  160.     if (!$dh// create the dir if needed
  161.         if (!@mkdir(UPLOADDIR,0777 octdec($GLOBALS['filemask']))) die("ERROR: unable to create the directory \"UPLOADDIR\"");
  162.         @chmod(UPLOADDIR,0777 octdec($GLOBALS['filemask']));
  163.         $dh=@opendir(UPLOADDIR);
  164.         if (!$dhdie("ERROR: can't open \"UPLOADDIR\" dir");
  165.     }
  166.  
  167.     while( ($file=readdir($dh))!==false {
  168.         if ($file[0]=="." || !is_file(UPLOADDIR."/".$file)) continue;
  169.         $localcontext=$context;
  170.         // is it an image ?
  171.         list($w,$h)=getimagesize(UPLOADDIR."/".$file);
  172.         if ($w && $h{
  173.             $localcontext['imagesize']="$w x $h";
  174.         }
  175.         //
  176.         $localcontext['name']=$file;
  177.         $localcontext['size']=nicefilesize(filesize(UPLOADDIR."/".$file));
  178.         $localcontext['checked']=$context['file'][$file"checked=\"checked\"" "";
  179.         call_user_func("code_do_$funcname",$localcontext);
  180.     }
  181. }
  182.  
  183. ?>

Documentation generated on Thu, 24 Jul 2008 05:07:45 +0200 by phpDocumentor 1.4.0a2