Example #1
0
 /**
  * Method used to compress data and then send it to the user to download on the spot.
  *
  * @param string $sName Name of the archive
  * @param string $sExt File extension of the archive (zip, tar.gz, xml)
  * @param string $sFolder Folder to compress. Must be located within the "file/cache/" folder.
  * @return bool Only returns false if we were unable to compress the data
  */
 public function download($sName, $sExt, $sFolder, $iServerId = 0)
 {
     if (!($sNewFile = Phpfox::getLib('phpfox.archive', $sExt)->compress($sName, $sFolder))) {
         return false;
     }
     if (Phpfox::getParam('core.allow_cdn')) {
         Phpfox::getLib('cdn')->put($sNewFile);
     }
     if (is_dir(PHPFOX_DIR_CACHE . $sFolder . PHPFOX_DS)) {
         Phpfox_File::instance()->delete_directory(PHPFOX_DIR_CACHE . $sFolder . PHPFOX_DS);
     }
     ($sPlugin = Phpfox_Plugin::get('archive_export_download')) ? eval($sPlugin) : false;
     // Phpfox::getlib('phpfox.file')->forceDownload($sNewFile, $sName . '.' . $sExt);
     Phpfox::getlib('phpfox.file')->forceDownload($sNewFile, $sName . '.' . $sExt, '', '', $iServerId);
 }
Example #2
0
	/**
	 * Method used to compress data and then send it to the user to download on the spot.
	 *
	 * @param string $sName Name of the archive
	 * @param string $sExt File extension of the archive (zip, tar.gz, xml)
	 * @param string $sFolder Folder to compress. Must be located within the "file/cache/" folder.
	 * @return bool Only returns false if we were unable to compress the data
	 */
	public function download($sName, $sExt, $sFolder)
	{		
		if (!($sNewFile = Phpfox::getLib('phpfox.archive', $sExt)->compress($sName, $sFolder)))
		{
			return false;
		}				

		if (is_dir(PHPFOX_DIR_CACHE . $sFolder . PHPFOX_DS))
		{
			Phpfox::getLib('file')->delete_directory(PHPFOX_DIR_CACHE . $sFolder . PHPFOX_DS);
		}	
		
		(($sPlugin = Phpfox_Plugin::get('archive_export_download')) ? eval($sPlugin) : false);
		
		Phpfox::getlib('phpfox.file')->forceDownload($sNewFile, $sName . '.' . $sExt);		
	}