<commit_before><?php
/* 
 * This file will handle the download prodecure based on user agent.
 *
 * @author ran
 */
// Include configuration: ( will include LocalSettings.php )
require_once( realpath( '../../' ) . '/includes/DefaultSettings.php' );

$download = new downloadEntry();
$download->redirectDownload();

class downloadEntry {
	var $resultObject = null; // lazy init
	/**
	 * The result object grabber, caches a local result object for easy access
	 * to result object properties. 
	 */
	function getResultObject(){
		global $wgMwEmbedVersion;
		if( ! $this->resultObject ){
			require_once( dirname( __FILE__ ) .  '/KalturaResultObject.php' );
			try {
				$this->resultObject = new KalturaResultObject( 'html5download:' . $wgMwEmbedVersion );
			} catch ( Exception $e ){
				die( $e->getMessage() );
			}
		}
		return $this->resultObject;
	}
	// Errors set special X-Kaltura and X-Kaltura-App: header and then deliver the no sources video
	private function fatalError( $errorMsg ) {
		header( "X-Kaltura: error-6" );
		header( "X-Kaltura-App: exiting on error 6 - requested flavor was not found" );
		header( "X-Kaltura-Error: " . htmlspecialchar( $errorMsg ) );
		// Then redirect to no-sources video: 
		$sources = $this->getResultObject()->getErrorVideoSources();		
		$flavorUrl = $this->getResultObject()->getSourceForUserAgent( $sources );
		header( "location: " . $flavorUrl );
		exit(1);
	}
	
	function redirectDownload() {
		$sources =  $this->getResultObject()->getSources();
		$flavorUrl = $this->getResultObject()->getSourceForUserAgent( $sources );
		// Redirect to flavor
		header( "location: " . $flavorUrl );
	}
}<commit_msg>No caching headers for download script<commit_after><?php
/* 
 * This file will handle the download prodecure based on user agent.
 *
 * @author ran
 */
// Include configuration: ( will include LocalSettings.php )
require_once( realpath( '../../' ) . '/includes/DefaultSettings.php' );

$download = new downloadEntry();
$download->redirectDownload();

class downloadEntry {
	var $resultObject = null; // lazy init
	/**
	 * The result object grabber, caches a local result object for easy access
	 * to result object properties. 
	 */
	function getResultObject(){
		global $wgMwEmbedVersion;
		if( ! $this->resultObject ){
			require_once( dirname( __FILE__ ) .  '/KalturaResultObject.php' );
			try {
				$this->resultObject = new KalturaResultObject( 'html5download:' . $wgMwEmbedVersion );
			} catch ( Exception $e ){
				die( $e->getMessage() );
			}
		}
		return $this->resultObject;
	}
	// Errors set special X-Kaltura and X-Kaltura-App: header and then deliver the no sources video
	private function fatalError( $errorMsg ) {
		header( "X-Kaltura: error-6" );
		header( "X-Kaltura-App: exiting on error 6 - requested flavor was not found" );
		header( "X-Kaltura-Error: " . htmlspecialchar( $errorMsg ) );
		// Then redirect to no-sources video: 
		$sources = $this->getResultObject()->getErrorVideoSources();		
		$flavorUrl = $this->getResultObject()->getSourceForUserAgent( $sources );
		header( "location: " . $flavorUrl );
		exit(1);
	}
	
	function redirectDownload() {
		$sources =  $this->getResultObject()->getSources();
		$flavorUrl = $this->getResultObject()->getSourceForUserAgent( $sources );
		// Redirect to flavor
		header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
		header("Pragma: no-cache");
		header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
		header( "location: " . $flavorUrl );
	}
}
{'fraction_non_alphanumeric': 0.14632752214918548, 'fraction_numerical': 0.006287510717347814, 'mean_word_length': 3.881450488145049, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 17, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5983223', 'n_tokens_mistral': 1187, 'n_tokens_neox': 1084, 'n_words': 292}