<commit_before><?php
/**
 * @package Core
 * @subpackage externalWidgets
 */
class thumbnailAction extends sfAction
{
	const DEFAULT_DIMENSION = -1;
	static private $extensions = array(
		'jpg',
		'gif',
		'png',
	);

	/* (non-PHPdoc)
	 * @see /symfony/action/sfComponent#getRequestParameter()
	 *
	 * Needed because some partners add .jpg at the end of the url, it might be added to a real attribute.
	 */
	public function getRequestParameter($name, $default = null)
	{
		$exts = implode('|', self::$extensions);
	
		$val = parent::getRequestParameter($name, $default);
		if(!$val)
			return $val;
			
		return preg_replace("/^(.*)\.($exts)$/", '$1', $val);
	}

	public function getIntRequestParameter($name, $default, $min, $max)
	{
		return min($max, max($min, intval($this->getRequestParameter($name, $default))));
	}

	public function getFloatRequestParameter($name, $default, $min, $max = null)
	{
		$val = max($min, floatval($this->getRequestParameter($name, $default)));
		if(is_null($max))
			return $val;
			
		return min($max, $val);
	}
  
  
	/**
	 * Will forward to the regular swf player according to the widget_id
	 */
	public function execute()
	{
		KExternalErrors::setResponseErrorCode(KExternalErrors::HTTP_STATUS_NOT_FOUND);
		
		myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2;
		
		requestUtils::handleConditionalGet();
		
		ignore_user_abort();
		
		$entry_id = $this->getRequestParameter("entry_id", null , "/\d_[A-Za-z0-9]{8}/");
		$widget_id = $this->getRequestParameter("widget_id", 0);
		$upload_token_id = $this->getRequestParameter("upload_token_id");
		$version = $this->getIntRequestParameter("version", null, 0, 10000000);
		$type = $this->getIntRequestParameter("type", 1, 1, 5);
		//Hack: if KMS sends thumbnail request containing "!" char, the type should be treated as 5.
		
		$width = $this->getRequestParameter("width", self::DEFAULT_DIMENSION);
		$height = $this->getRequestParameter("height", self::DEFAULT_DIMENSION);
		if(strpos($width, "!") || strpos($height, "!"))
			$type = 5;

		list($width, $height) = $this->getDimensions();
		
		$nearest_aspect_ratio = $this->getIntRequestParameter("nearest_aspect_ratio", 0, 0, 1);
		$imageFilePath = null;

		$crop_provider = $this->getRequestParameter("crop_provider", null);
		$quality = $this->getIntRequestParameter("quality", 0, 0, 100);
		$src_x = $this->getFloatRequestParameter("src_x", 0, 0, 10000);
		$src_y = $this->getFloatRequestParameter("src_y", 0, 0, 10000);
		$src_w = $this->getFloatRequestParameter("src_w", 0, 0, 10000);
		$src_h = $this->getFloatRequestParameter("src_h", 0, 0, 10000);
		$vid_sec = $this->getFloatRequestParameter("vid_sec", -1, -1);
		$vid_slice = $this->getRequestParameter("vid_slice", -1);
		$vid_slices = $this->getRequestParameter("vid_slices", -1);
		$density = $this->getFloatRequestParameter("density", 0, 0);
		$stripProfiles = $this->getRequestParameter("strip", null);
		$flavor_id = $this->getRequestParameter("flavor_id", null);
		$file_name = $this->getRequestParameter("file_name", null);
		$file_name = basename($file_name);
		<commit_msg>PLAT-9543 - validate entry should be in other dc before dumping api<commit_after><?php
/**
 * @package Core
 * @subpackage externalWidgets
 */
class thumbnailAction extends sfAction
{
	const DEFAULT_DIMENSION = -1;
	static private $extensions = array(
		'jpg',
		'gif',
		'png',
	);

	/* (non-PHPdoc)
	 * @see /symfony/action/sfComponent#getRequestParameter()
	 *
	 * Needed because some partners add .jpg at the end of the url, it might be added to a real attribute.
	 */
	public function getRequestParameter($name, $default = null)
	{
		$exts = implode('|', self::$extensions);
	
		$val = parent::getRequestParameter($name, $default);
		if(!$val)
			return $val;
			
		return preg_replace("/^(.*)\.($exts)$/", '$1', $val);
	}

	public function getIntRequestParameter($name, $default, $min, $max)
	{
		return min($max, max($min, intval($this->getRequestParameter($name, $default))));
	}

	public function getFloatRequestParameter($name, $default, $min, $max = null)
	{
		$val = max($min, floatval($this->getRequestParameter($name, $default)));
		if(is_null($max))
			return $val;
			
		return min($max, $val);
	}
  
  
	/**
	 * Will forward to the regular swf player according to the widget_id
	 */
	public function execute()
	{
		KExternalErrors::setResponseErrorCode(KExternalErrors::HTTP_STATUS_NOT_FOUND);
		
		myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2;
		
		requestUtils::handleConditionalGet();
		
		ignore_user_abort();
		
		$entry_id = $this->getRequestParameter("entry_id");
		$widget_id = $this->getRequestParameter("widget_id", 0);
		$upload_token_id = $this->getRequestParameter("upload_token_id");
		$version = $this->getIntRequestParameter("version", null, 0, 10000000);
		$type = $this->getIntRequestParameter("type", 1, 1, 5);
		//Hack: if KMS sends thumbnail request containing "!" char, the type should be treated as 5.
		
		$width = $this->getRequestParameter("width", self::DEFAULT_DIMENSION);
		$height = $this->getRequestParameter("height", self::DEFAULT_DIMENSION);
		if(strpos($width, "!") || strpos($height, "!"))
			$type = 5;

		list($width, $height) = $this->getDimensions();
		
		$nearest_aspect_ratio = $this->getIntRequestParameter("nearest_aspect_ratio", 0, 0, 1);
		$imageFilePath = null;

		$crop_provider = $this->getRequestParameter("crop_provider", null);
		$quality = $this->getIntRequestParameter("quality", 0, 0, 100);
		$src_x = $this->getFloatRequestParameter("src_x", 0, 0, 10000);
		$src_y = $this->getFloatRequestParameter("src_y", 0, 0, 10000);
		$src_w = $this->getFloatRequestParameter("src_w", 0, 0, 10000);
		$src_h = $this->getFloatRequestParameter("src_h", 0, 0, 10000);
		$vid_sec = $this->getFloatRequestParameter("vid_sec", -1, -1);
		$vid_slice = $this->getRequestParameter("vid_slice", -1);
		$vid_slices = $this->getRequestParameter("vid_slices", -1);
		$density = $this->getFloatRequestParameter("density", 0, 0);
		$stripProfiles = $this->getRequestParameter("strip", null);
		$flavor_id = $this->getRequestParameter("flavor_id", null);
		$file_name = $this->getRequestParameter("file_name", null);
		$file_name = basename($file_name);
		
{'fraction_non_alphanumeric': 0.16950240770465488, 'fraction_numerical': 0.020385232744783308, 'mean_word_length': 5.313069908814589, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2016279', 'n_tokens_mistral': 2362, 'n_tokens_neox': 2088, 'n_words': 436}