function rename_dir(&$dir, $enable_folder_rename, $fix_utf8)
{
    global $normalise_directory_names;
    if ($enable_folder_rename != 'true') {
        echo 'This action is not enabled!';
        exit(0);
    }
    $upperdir = substr($dir, 0, strrpos($dir, "/"));
    $newdir = parseInputParameterFile(trim(my_basename(' ' . $_GET['newdir'])));
    $newdir = fix_decoding($newdir, $fix_utf8);
    if ($normalise_directory_names) {
        $newdir = normalizeFileNames($newdir);
    }
    if ($dir == $_SESSION["TFU_ROOT_DIR"]) {
        $status = "&rename_dir=main";
    } else {
        $createdir = $upperdir . "/" . $newdir;
        if (file_exists($createdir)) {
            $status = "&rename_dir=exists";
        } else {
            $result = rename($dir, $upperdir . "/" . $newdir);
            if ($result) {
                $dir = $createdir;
                $_SESSION["TFU_DIR"] = $dir;
                $status = "&rename_dir=true";
            } else {
                $status = "&rename_dir=false";
            }
        }
    }
    return $status;
}
 }
 // end JFU
 if (@move_uploaded_file($file['tmp_name'], $filename)) {
     // This is only needed for JFU - ignore this small part if you use TFU standalone:
     if ($workaround_dir) {
         copy($filename, $dir . "/" . $image);
         unlink($filename);
         $filename = $dir . "/" . $image;
     }
     // end JFU
     $uploaded = file_exists($filename);
 }
 // Retry - bad file name - I try to fix this and save it anyway!
 if (!$uploaded) {
     // we normalize even if not selected because saving with the default name failed!
     $filename = $dir . '/' . str_replace("\\'", "'", iconv('UTF-8', '', normalizeFileNames($base_filename)));
     if (@move_uploaded_file($file['tmp_name'], $filename)) {
         $uploaded = file_exists($filename);
     }
 }
 if ($uploaded) {
     // we check the filesize later because of basedir restrictions in the the tmp dir!
     check_valid_filesize($filename);
     if ($file_chmod != 0) {
         @chmod($filename, $file_chmod);
     }
     if ($store == 2) {
         // we resize after the move because before it was not possible on this server
         // no fallback right now because the file is already uploaded.
         resize_file($filename, $size, 80, $base_filename);
     }
Beispiel #3
0
function showFlashPlugin($id, $twgpath) {
   global $prefix_path;

     $database = JFactory::getDBO();
	 $row = new joomla_flash_uploader($database);
	 $row->load($id);
	 if (!$row->resize_show) { // no profile found or no id!
	    return HTML_joomla_flash_uploader::wrongId($id, true);
	 } else {
	   $uploadfolder = $row->folder;
	   $uploadfolder_base = $uploadfolder;

	   $user = JFactory::getUser();
        // we check if we have a master profile!
       if ($row->master_profile == 'true') {
	      if ($user->id != 0 || $row->master_profile_mode == 'ip') {
               if ($row->master_profile_mode == 'id') {
                    $_SESSION["s_user"] = $user->id;
                    $uploadfolder = $uploadfolder . '/' . $user->id;
                } else if ($row->master_profile_mode == 'ip') {
                    $uploadfolder = $uploadfolder . '/' . $_SERVER['REMOTE_ADDR'];
                } else if ($row->master_profile_mode == 'group') {
                    $group = JFUHelper::getHighestGroupName($database, $user->groups);
                    
                    if ($row->master_profile_lowercase == 'true') {
                        $normalizeSpaces=true;
                        $group = normalizeFileNames($group);      
                    } 
                     $uploadfolder = $uploadfolder . '/' . $group;
                 } else {
                    if ($row->master_profile_mode == 'login') {
                        $uname = $user->username;
                    } else {
                        $uname = $user->name;
                    }
                    $_SESSION["s_user"] = $uname;
                    if ($row->master_profile_lowercase == 'true') {
                        $normalizeSpaces=true;
                        $uname = normalizeFileNames($uname);
                    }
                    $uploadfolder = $uploadfolder . '/' . $uname;  
                }
              // we check if the folder exists - if not it is created!
              if (!file_exists($uploadfolder) && $uploadfolder != "") {
                 $dir_chmod = JFUHelper::getVariable($database, 'dir_chmod'); 
                 $ftp_enable = $row->ftp_enable;  
                 if (isset($ftp_enable) && $ftp_enable == 'true') {
                        $ftp_host = $row->ftp_host; 
                        $ftp_port = $row->ftp_port; 
                        $ftp_user = $row->ftp_user; 
                        $ftp_pass = $row->ftp_pass; 
                        $ftp_root = $row->ftp_root;                                  
                        $ftp_createdir = $uploadfolder;
                        $conn_id = ftp_connect($ftp_host, $ftp_port); 
                        $login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);                         
                        ftp_chdir($conn_id, $ftp_root); 
                        $result = ftp_mkdir ($conn_id , $ftp_createdir);
                        if ($result && $dir_chmod != 0) {
                          @ftp_chmod($conn_id, $dir_chmod, $ftp_createdir);
                        }
                        ftp_close($conn_id);
                  } else {
                      $result = mkdir($uploadfolder);  
                      if ($result && $dir_chmod != 0) {
                        @chmod($uploadfolder, $dir_chmod);
                      }
                 }
                // if the copy directory exists we copy everything!
                $extra_dir = "components/com_jfuploader/default";
                if (file_exists($extra_dir)) {
                  JFUHelper::dir_copy($extra_dir, $uploadfolder);
                } 
              }
          } else {
              return HTML_joomla_flash_uploader::noUser($id,true);          
          }
       }
       
       if (file_exists("components/com_jfuploader/tfu/tfu_helper.php")) {
         $prefix_path = '';
         $prefix_dir_path = '';
       } else {
         $prefix_path = 'administrator/';
         $prefix_dir_path = '../';
       }      
	     // we go back to the main folder!
       if ($uploadfolder == "") {
         $folder =  './'.$prefix_dir_path.'../../..';
       } else {
         $folder =  './'.$prefix_dir_path.'../../../' . $uploadfolder;
       }
       JFUHelper::setJFUSession($row, $folder, $database); 
       unset($_SESSION["IS_ADMIN"]);
       $_SESSION["IS_FRONTEND"] = "TRUE";
       if ($user->id != 0) {
         $_SESSION["TFU_USER"] = $user->username;
         $_SESSION["TFU_USER_ID"] = $user->id;
         $_SESSION["TFU_USER_NAME"] = $user->name;
         $_SESSION["TFU_USER_EMAIL"] = $user->email;
         JFUHelper::setContactDetailsToSession($user->id);
       } else {
         unset($_SESSION['TFU_USER']);
         unset($_SESSION['TFU_USER_ID']);
         unset($_SESSION['TFU_USER_NAME']);
         unset($_SESSION['TFU_USER_EMAIL']);
         unset($_SESSION['TFU_USER_CONTACT']);
       }
       
        // we check if the flash should be included with js oder the object tag
       $use_js_include = JFUHelper::check_js_include($database);
       $jfu_config['idn_url']= JFUHelper::getVariable($database, 'idn_url');     
             
       store_temp_session();
       JFUHelper::fixSession();
       
       $thumbnailflash = '';
       if ($twgpath != '') {
         $thumbnailflash = $this->getFlashContent($twgpath, $uploadfolder,$use_js_include);
       }
       return  HTML_joomla_flash_uploader::showFlash( $row, $uploadfolder, $use_js_include, $jfu_config, true ) . $thumbnailflash;
	 }	 
}
Beispiel #4
0
     // This is only needed for JFU - ignore this small part if you use TFU standalone:
     if ($workaround_dir) {
         copy($filename, $dir . "/" . $image);
         unlink($filename);
         $filename = $dir . "/" . $image;
     }
     // end JFU
     $uploaded = file_exists($filename);
 }
 if ($enable_upload_debug) {
     tfu_debug('5a. After move_uploaded_file.');
 }
 // Retry - bad file name - I try to fix this and save it anyway!
 if (!$uploaded) {
     // we normalize even if not selected because saving with the default name failed!
     $filename = $dir . '/' . fix_decoding(normalizeFileNames($base_filename), $fix_utf8);
     if ($enable_upload_debug) {
         tfu_debug('5b. Retry move_uploaded_file : ' . $file['tmp_name'] . ' -> ' . $filename);
         // I try to enable the display error and set the error reporting higher
         // if the move fails here I want to know the reason!
         @ini_set('display_errors', 'On');
         $old_error = error_reporting(E_ALL);
     }
     if (move_uploaded_file($file['tmp_name'], $filename)) {
         $uploaded = file_exists($filename);
     }
     if ($enable_upload_debug) {
         error_reporting($old_error);
     }
 }
 if ($uploaded) {
Beispiel #5
0
 function showFlashComponent($id, $user, $editor_plugin, $block_type, $jfu_params)
 {
     global $prefix_dir_path, $prefix_path;
     $database =& JFactory::getDBO();
     $row = new joomla_flash_uploader($database);
     $row->load($id);
     if (!$row->resize_show) {
         // no profile found or no id!
         HTML_joomla_flash_uploader::wrongId($id);
     } else {
         $uploadfolder = $row->folder;
         $uploadfolder_base = $uploadfolder;
         // we check if we have a master profile!
         if ($row->master_profile == 'true') {
             if ($user->id != 0 || $row->master_profile_mode == 'ip') {
                 if ($row->master_profile_mode == 'id') {
                     $_SESSION["s_user"] = $user->id;
                     $uploadfolder = $uploadfolder . '/' . $user->id;
                 } else {
                     if ($row->master_profile_mode == 'ip') {
                         $uploadfolder = $uploadfolder . '/' . $_SERVER['REMOTE_ADDR'];
                     } else {
                         if ($row->master_profile_mode == 'group') {
                             $group = JFUHelper::getHighestGroupName($database, $user->groups);
                             if ($row->master_profile_lowercase == 'true') {
                                 $normalizeSpaces = true;
                                 $group = normalizeFileNames($group);
                             }
                             $uploadfolder = $uploadfolder . '/' . $group;
                         } else {
                             if ($row->master_profile_mode == 'login') {
                                 $uname = $user->username;
                             } else {
                                 $uname = $user->name;
                             }
                             $_SESSION["s_user"] = $uname;
                             if ($row->master_profile_lowercase == 'true') {
                                 $normalizeSpaces = true;
                                 $uname = normalizeFileNames($uname);
                             }
                             $uploadfolder = $uploadfolder . '/' . $uname;
                         }
                     }
                 }
                 // we check if the folder exists - if not it is created!
                 if (!file_exists($uploadfolder) && $uploadfolder != "") {
                     $dir_chmod = JFUHelper::getVariable($database, 'dir_chmod');
                     $ftp_enable = $row->ftp_enable;
                     if (isset($ftp_enable) && $ftp_enable == 'true') {
                         $ftp_host = $row->ftp_host;
                         $ftp_port = $row->ftp_port;
                         $ftp_user = $row->ftp_user;
                         $ftp_pass = $row->ftp_pass;
                         $ftp_root = $row->ftp_root;
                         $ftp_createdir = $uploadfolder;
                         $conn_id = ftp_connect($ftp_host, $ftp_port);
                         $login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);
                         ftp_chdir($conn_id, $ftp_root);
                         $result = ftp_mkdir($conn_id, $ftp_createdir);
                         if ($result && $dir_chmod != 0) {
                             @ftp_chmod($conn_id, $dir_chmod, $ftp_createdir);
                         }
                         ftp_close($conn_id);
                     } else {
                         $result = mkdir($uploadfolder);
                         if ($result && $dir_chmod != 0) {
                             @chmod($uploadfolder, $dir_chmod);
                         }
                     }
                     // if the copy directory exists we copy everything!
                     $extra_dir = "components/com_jfuploader/default";
                     if (file_exists($extra_dir)) {
                         JFUHelper::dir_copy($extra_dir, $uploadfolder);
                     }
                 }
             } else {
                 HTML_joomla_flash_uploader::noUser($id);
                 return;
             }
         }
         // we go back to the main folder! path has to be relativ to the tfu upload folder!
         if ($uploadfolder == "") {
             $folder = './' . $prefix_dir_path . '../../..';
         } else {
             $folder = './' . $prefix_dir_path . '../../../' . $uploadfolder;
         }
         JFUHelper::setJFUSession($row, $folder, $database);
         unset($_SESSION["IS_ADMIN"]);
         $_SESSION["IS_FRONTEND"] = "TRUE";
         if ($user->id != 0) {
             $_SESSION["TFU_USER"] = $user->name;
             $_SESSION["TFU_USER_ID"] = $user->id;
             $_SESSION["TFU_USER_NAME"] = $user->username;
             $_SESSION["TFU_USER_EMAIL"] = $user->email;
             JFUHelper::setContactDetailsToSession($user->id);
         } else {
             unset($_SESSION['TFU_USER']);
             unset($_SESSION['TFU_USER_ID']);
             unset($_SESSION['TFU_USER_NAME']);
             unset($_SESSION['TFU_USER_EMAIL']);
             unset($_SESSION['TFU_USER_CONTACT']);
         }
         // we check if the flash should be included with js oder the object tag
         $use_js_include = JFUHelper::check_js_include($database);
         $jfu_config['idn_url'] = JFUHelper::getVariable($database, 'idn_url');
         if (!$editor_plugin) {
             JFUHelper::fixSession();
             store_temp_session();
             HTML_joomla_flash_uploader::showFlash($row, $uploadfolder, $use_js_include, $jfu_config, false);
         } else {
             $_SESSION['TFU']['IS_JFU_PLUGIN'] = true;
             JFUHelper::fixSession();
             store_temp_session();
             // I have to set the javascript setting to update the data!
             $flash = HTML_joomla_flash_uploader::showFlash($row, $uploadfolder, $use_js_include, $jfu_config, true);
             echo '
      <style type="text/css">
        body.contentpane { background-color:#ffffff; margin-top:15px; margin-left:15px; margin-bottom:0px; overflow-y: hidden; overflow-x: hidden; line-height: 1.4;} 
        #main { padding: 0px;} 
      </style>';
             echo $flash;
             $base_path = JURI::base();
             HTML_joomla_flash_uploader::showImageSelector($base_path, $block_type, $jfu_params);
         }
     }
 }