Ejemplo n.º 1
0
function setSessionVariables()
{
    global $folder, $enable_folder_browsing, $enable_folder_creation, $enable_folder_deletion, $sort_files_by_date;
    global $upload_notification_email, $upload_notification_email_from, $upload_notification_email_subject, $image_magic_path;
    global $upload_notification_email_text, $split_extension, $user, $hide_directory_in_title, $use_image_magic, $login;
    // this setting are needed in the other php files too!
    if ($login == "true") {
        $_SESSION["TFU_LOGIN"] = "******";
    }
    $_SESSION["TFU_ROOT_DIR"] = $_SESSION["TFU_DIR"] = $folder;
    $_SESSION["TFU_BROWSE_FOLDER"] = $enable_folder_browsing;
    $_SESSION["TFU_CREATE_FOLDER"] = $enable_folder_creation;
    $_SESSION["TFU_DELETE_FOLDER"] = $enable_folder_deletion;
    $_SESSION["TFU_SORT_FILES_BY_DATE"] = $sort_files_by_date;
    $_SESSION["TFU_NOT_EMAIL"] = $upload_notification_email;
    $_SESSION["TFU_NOT_EMAIL_FROM"] = $upload_notification_email_from;
    $_SESSION["TFU_NOT_EMAIL_SUBJECT"] = $upload_notification_email_subject;
    $_SESSION["TFU_NOT_EMAIL_TEXT"] = $upload_notification_email_text;
    $_SESSION["TFU_SPLIT_EXTENSION"] = $split_extension;
    $_SESSION["TFU_USER"] = $user;
    $_SESSION["TFU_HIDE_DIRECTORY_IN_TITLE"] = $hide_directory_in_title;
    $_SESSION["TFU_USE_IMAGE_MAGIC"] = $use_image_magic;
    $_SESSION["TFU_IMAGE_MAGIC_PATH"] = $image_magic_path;
    store_temp_session();
}
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);
    }
}
Ejemplo n.º 3
0
function setSessionVariables()
{
    global $folder, $user, $login;
    // this settings are needed in the other php files too!
    if ($login == 'true') {
        $_SESSION['TFU_LOGIN'] = '******';
    }
    $_SESSION['TFU_RN'] = parseInputParameter($_POST['twg_rn']);
    $_SESSION['TFU_ROOT_DIR'] = $_SESSION['TFU_DIR'] = $folder;
    if (!isset($_SESSION['TFU_USER']) || $user != '') {
        $_SESSION['TFU_USER'] = $user != '' ? $user : $_SERVER['REMOTE_ADDR'];
    }
    store_temp_session();
}
Ejemplo n.º 4
0
        $subject = $_SESSION["TFU_NOT_EMAIL_SUBJECT"];
        $filestr = "\n\n";
        foreach ($_SESSION["TFU_LAST_UPLOADS"] as $filename) {
            $filestr = $filestr . str_replace("./", "", str_replace("../", "", $filename)) . "\n";
        }
        if ($filestr == "\n\n") {
            $filestr .= "Please check your setup. No files where uploaded.";
        }
        $username = "******";
        if (isset($_SESSION["TFU_USER"])) {
            $username = $_SESSION["TFU_USER"];
        }
        $mailtext = sprintf($_SESSION["TFU_NOT_EMAIL_TEXT"], $username, $filestr);
        @mail($email, html_entity_decode($subject), html_entity_decode($mailtext), $submailheaders);
    }
    store_temp_session();
} else {
    if (isset($_GET['remaining'])) {
        // seems like the session is lost! therefore we create a temp dir that enables TFU session handling
        debug("It seems that the session handling of the server is not o.k. Therefore TFU simulates a basic session handling and uses the session_cache folder for that.");
        if (!mkdir(dirname(__FILE__) . "/session_cache")) {
            debug("Directory session_cache could no be created! Please create the sub directoy session_cache and set the permissions to 777.");
        } else {
            debug("Directory session_cache could be created! TFU does now an internal session handling.");
        }
    } else {
        echo "Not logged in!";
    }
}
echo " ";
// important - solves bug for Mac!
Ejemplo n.º 5
0
function setSessionVariables()
{
    global $folder, $user, $login;
    // this settings are needed in the other php files too!
    if ($login == 'true') {
        $_SESSION['TFU_LOGIN'] = '******';
        if (!isset($_SESSION['TFU_USER'])) {
            // can be set by the Joomla wrapper and we don't overwrite it with a dummy value!
            $_SESSION['TFU_USER'] = $user != '' && $user != '__empty__' ? $user : $_SERVER['REMOTE_ADDR'];
        }
    } else {
        unset($_SESSION['TFU_USER']);
    }
    $_SESSION['TFU_RN'] = parseInputParameter($_POST['twg_rn']);
    $_SESSION['TFU_ROOT_DIR'] = $_SESSION['TFU_DIR'] = $folder;
    store_temp_session();
}
Ejemplo n.º 6
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;
	 }	 
}
Ejemplo n.º 7
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);
         }
     }
 }
Ejemplo n.º 8
0
function showUpload()
{
    global $mybasedir;
    $mainframe = JFactory::getApplication();
    $database = JFactory::getDBO();
    $my = JFactory::getUser();
    // print_r(JAccess::getGroups());
    if (checkAccess($database, 'core.manage')) {
        $jfu_config['idn_url'] = JFUHelper::getVariable($database, 'idn_url');
        $row = new joomla_flash_uploader($database);
        $b_prof = selectBackendProfile($database, $my->groups);
        $row->load($b_prof);
        $uploadfolder = $row->folder;
        $pathfix = '';
        if ($mybasedir == '') {
            $pathfix = '../';
        }
        // we go back to the main folder!
        if ($uploadfolder == "") {
            $folder = "./" . $pathfix . "../../..";
            $filefolder = '';
            // this setting make the folder check always true
        } else {
            $folder = "./" . $pathfix . "../../../" . $uploadfolder;
            $filefolder = "./../" . $uploadfolder;
        }
        // settings for the flash
        JFUHelper::setJFUSession($row, $folder, $database);
        $_SESSION["IS_ADMIN"] = "TRUE";
        unset($_SESSION["IS_FRONTEND"]);
        $my = JFactory::getUser();
        $_SESSION["TFU_USER"] = $my->username . " (backend)";
        $_SESSION["TFU_USER_ID"] = $my->id;
        $_SESSION["TFU_USER_NAME"] = $my->name;
        $_SESSION["TFU_USER_EMAIL"] = $my->email;
        JFUHelper::setContactDetailsToSession($my->id);
        JFUHelper::fixSession();
        store_temp_session();
        HTML_joomla_flash_uploader::showUpload($row, $uploadfolder, $filefolder, $jfu_config);
    } else {
        HTML_joomla_flash_uploader::errorRights();
    }
}
function showUpload()
{
    global $mainframe;
    $database =& JFactory::getDBO();
    $my =& JFactory::getUser();
    if (checkAccess($database, $my->usertype, 'backend_access_upload')) {
        $row = new joomla_flash_uploader($database);
        $row->load(1);
        $uploadfolder = $row->folder;
        // we go back to the main folder!
        if ($uploadfolder == "") {
            $folder = "./../../../..";
            $filefolder = "";
        } else {
            $folder = "./../../../../" . $uploadfolder;
            $filefolder = "./../" . $uploadfolder;
        }
        // settings for the flash
        JFUHelper::setJFUSession($row, $folder);
        $_SESSION["TFU_FILE_CHMOD"] = JFUHelper::getVariable($database, 'file_chmod');
        $_SESSION["TFU_DIR_CHMOD"] = JFUHelper::getVariable($database, 'dir_chmod');
        $_SESSION["IS_ADMIN"] = "TRUE";
        unset($_SESSION["IS_FRONTEND"]);
        $my = $mainframe->getUser();
        $_SESSION["TFU_USER"] = $my->username . " (backend)";
        $_SESSION["TFU_USER_ID"] = $my->id;
        store_temp_session();
        JFUHelper::fixSession();
        HTML_joomla_flash_uploader::showUpload($row, $uploadfolder, $filefolder);
    } else {
        HTML_joomla_flash_uploader::errorRights();
    }
}