* Modified typo3/sysext/cms/tslib/class.tslib_content.php:
[Packages/TYPO3.CMS.git] / typo3 / tce_file.php
index 3e5e49f..5186696 100755 (executable)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *  
-*  (c) 1999-2003 Kasper Skaarhoj (kasper@typo3.com)
+*  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is 
  *
  *
  *
- *   77: class SC_tce_file 
- *   88:     function init()   
- *  103:     function initClipboard()  
- *  124:     function main()   
- *  157:     function finish() 
+ *   76: class SC_tce_file 
+ *   96:     function init()   
+ *  116:     function initClipboard()  
+ *  137:     function main()   
  *
- * TOTAL FUNCTIONS: 4
+ * TOTAL FUNCTIONS: 3
  * (This index is automatically created/updated by the extension "extdeveval")
  *
  */ 
@@ -69,27 +68,41 @@ require_once (PATH_t3lib.'class.t3lib_extfilefunc.php');
 
 /**
  * Script Class, handling the calling of methods in the file admin classes.
- * 
+ *
  * @author     Kasper Skaarhoj <kasper@typo3.com>
  * @package TYPO3
  * @subpackage core
  */
 class SC_tce_file {
-       var $include_once=array();
-       var $CB;
-       var $file;
-       var $redirect;
+
+               // Internal, static: GPvar:
+       var $file;                                              // Array of file-operations.
+       var $redirect;                                  // Redirect URL
+       var $CB;                                                // Clipboard operations array
+       var $overwriteExistingFiles;    // If existing files should be overridden.
+       var $vC;                                                // VeriCode - a hash of server specific value and other things which identifies if a submission is OK. (see $BE_USER->veriCode())
+
+               // Internal, dynamic:   
+       var $include_once=array();              // Used to set the classes to include after the init() function is called.
+
+
+
        
        /**
         * Registering Incoming data
-        * 
-        * @return      void            
+        *
+        * @return      void
         */
        function init() {
-               $this->file = t3lib_div::GPvar('file');
-               $this->redirect = t3lib_div::GPvar('redirect');
-
-               $this->CB = t3lib_div::GPvar('CB');
+       
+                       // GPvars:
+               $this->file = t3lib_div::_GP('file');
+               $this->redirect = t3lib_div::_GP('redirect');
+               $this->CB = t3lib_div::_GP('CB');
+               $this->overwriteExistingFiles = t3lib_div::_GP('overwriteExistingFiles');
+               $this->vC = t3lib_div::_GP('vC');
+               
+                       // If clipboard is set, then include the clipboard class:
                if (is_array($this->CB))        {
                        $this->include_once[]=PATH_t3lib.'class.t3lib_clipboard.php';
                }
@@ -97,8 +110,8 @@ class SC_tce_file {
 
        /**
         * Initialize the Clipboard. This will fetch the data about files to paste/delete if such an action has been sent.
-        * 
-        * @return      void            
+        *
+        * @return      void
         */
        function initClipboard()        {
                if (is_array($this->CB))        {
@@ -118,52 +131,29 @@ class SC_tce_file {
        /**
         * Performing the file admin action:
         * Initializes the objects, setting permissions, sending data to object.
-        * 
-        * @return      void            
+        *
+        * @return      void
         */
        function main() {
                global $FILEMOUNTS,$TYPO3_CONF_VARS,$BE_USER;
                
-               // *********************************
-               // Initializing
-               // *********************************
+                       // Initializing:
                $fileProcessor = t3lib_div::makeInstance('t3lib_extFileFunctions');
                $fileProcessor->init($FILEMOUNTS, $TYPO3_CONF_VARS['BE']['fileExtensions']);
                $fileProcessor->init_actionPerms($BE_USER->user['fileoper_perms']);
-               $fileProcessor->dontCheckForUnique = t3lib_div::GPvar('overwriteExistingFiles') ? 1 : 0;
+               $fileProcessor->dontCheckForUnique = $this->overwriteExistingFiles ? 1 : 0;
                
-               // ***************************
-               // Checking referer / executing
-               // ***************************
-               $refInfo=parse_url(t3lib_div::getIndpEnv('HTTP_REFERER'));
+                       // Checking referer / executing:
+               $refInfo = parse_url(t3lib_div::getIndpEnv('HTTP_REFERER'));
                $httpHost = t3lib_div::getIndpEnv('TYPO3_HOST_ONLY');
-               if ($httpHost!=$refInfo['host'] && t3lib_div::GPvar('vC')!=$BE_USER->veriCode() && !$TYPO3_CONF_VARS['SYS']['doNotCheckReferer'])       {
+               if ($httpHost!=$refInfo['host'] && $this->vC!=$BE_USER->veriCode() && !$TYPO3_CONF_VARS['SYS']['doNotCheckReferer'])    {
                        $fileProcessor->writeLog(0,2,1,'Referer host "%s" and server host "%s" did not match!',array($refInfo['host'],$httpHost));
                } else {
                        $fileProcessor->start($this->file);
                        $fileProcessor->processData();
                }
                
-               if (!$this->redirect)   {
-                       $this->redirect = 'status_file.php';
-               }
-       }
-
-       /**
-        * Redirecting to the status script for files.
-        * 
-        * @return      void            
-        */
-       function finish()       {
-               Header('Location: '.t3lib_div::locationHeaderUrl($this->redirect));
-
-               echo '
-               <script type="text/javascript">
-                               if (confirm(\'System Error:\n\n Some error happend in tce_file.php. Continue?\'))       {
-                                       document.location = \''.$this->redirect.'\';
-                               }
-               </script>
-               ';
+               $fileProcessor->printLogErrorMessages($this->redirect);
        }
 }
 
@@ -188,10 +178,8 @@ $SOBE = t3lib_div::makeInstance('SC_tce_file');
 $SOBE->init();
 
 // Include files?
-reset($SOBE->include_once);    
-while(list(,$INC_FILE)=each($SOBE->include_once))      {include_once($INC_FILE);}
+foreach($SOBE->include_once as $INC_FILE)      include_once($INC_FILE);
 
 $SOBE->initClipboard();
 $SOBE->main();
-$SOBE->finish();
-?>
\ No newline at end of file
+?>