コード例 #1
0
ファイル: jfuploader.php プロジェクト: xenten/swift-kanban
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;
	 }	 
}
コード例 #2
0
function showFlashComponent($id)
{
    $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;
        $user =& JFactory::getUser();
        // we check if we have a master profile!
        if ($row->master_profile == 'true') {
            if ($user->id != 0) {
                if ($row->master_profile_mode == 'id') {
                    $uploadfolder = $uploadfolder . '/' . $user->id;
                } else {
                    if ($row->master_profile_lowercase == 'true') {
                        $uploadfolder = $uploadfolder . '/' . strtolower($user->username);
                    } else {
                        $uploadfolder = $uploadfolder . '/' . $user->username;
                    }
                }
                // we check if the folder exists - if not it is created!
                if (!file_exists($uploadfolder) && $uploadfolder != "") {
                    mkdir($uploadfolder);
                    // if the copy directory exists we copy everything!
                    $extra_dir = "components/com_joomla_flash_uploader/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 = "./../../../..";
        } else {
            $folder = "./../../../../" . $uploadfolder;
        }
        JFUHelper::setJFUSession($row, $folder);
        $_SESSION["TFU_FILE_CHMOD"] = JFUHelper::getVariable($database, 'file_chmod');
        $_SESSION["TFU_DIR_CHMOD"] = JFUHelper::getVariable($database, 'dir_chmod');
        unset($_SESSION["IS_ADMIN"]);
        $_SESSION["IS_FRONTEND"] = "TRUE";
        if ($user->id != 0) {
            $_SESSION["TFU_USER"] = $user->username;
            $_SESSION["TFU_USER_ID"] = $user->id;
        } else {
            unset($_SESSION["TFU_USER"]);
            unset($_SESSION["TFU_USER_ID"]);
        }
        // we check if the flash should be included with js oder the object tag
        $use_js_include = JFUHelper::check_js_include($database);
        store_temp_session();
        JFUHelper::fixSession();
        HTML_joomla_flash_uploader::showFlash($row, $uploadfolder, $use_js_include, false);
    }
}
コード例 #3
0
ファイル: view.html.php プロジェクト: xenten/swift-kanban
 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);
         }
     }
 }