<commit_before><?php
$type = $_GET['type'];
$timeout = $_GET['timeout'];
$viewport = $_GET['viewport'];
$js = $_GET['js'];
$resizewidth = $_GET['width'];
$cache = preg_replace("/[^A-Za-z0-9 ]/", '', $_GET['cache']);
$onfail = rawurldecode($_GET['onfail']);
if(!$onfail)
	$onfail = 'https://http2pic.haschek.at/img/failed.jpg';
$url = rawurldecode($_GET['url']);
if(isBase64($url))
	$url = base64_decode($url);

if(!$timeout || !is_numeric($timeout) || ($timeout>30 || $timeout<1))
	$timeout = 10;

if($viewport)
{
	$a=explode('x', $viewport);
	$w = $a[0];
	$h = $a[1];
	if($w)
		$vp = "--width $w ";
	if($h)
		$vp.= "--height $h ";

}	

if($js=='no')
	$jsp = '-n ';

switch ($type) {
	case 'png':
		$ft = $type;
		header('Content-Type: image/png');
	break;

	case 'jpg':
	case 'jpeg':
	default:
		$ft = 'jpg';
		header('Content-Type: image/jpeg');
}



if(!$cache)
	$cache = md5(time().rand(1,2000));
$hash = $cache.'-'.preg_replace("/[^A-Za-z0-9 ]/", '', $url).'.'.$ft;


$file = __DIR__.'/cache/'.$hash;
if(!file_exists($file))<commit_msg>Adding cache folder if nto exist<commit_after><?php
$type = $_GET['type'];
$timeout = $_GET['timeout'];
$viewport = $_GET['viewport'];
$js = $_GET['js'];
$resizewidth = $_GET['width'];
$cache = preg_replace("/[^A-Za-z0-9 ]/", '', $_GET['cache']);
$onfail = rawurldecode($_GET['onfail']);
if(!$onfail)
	$onfail = 'https://http2pic.haschek.at/img/failed.jpg';
$url = rawurldecode($_GET['url']);
if(isBase64($url))
	$url = base64_decode($url);

if(!$timeout || !is_numeric($timeout) || ($timeout>30 || $timeout<1))
	$timeout = 10;

if($viewport)
{
	$a=explode('x', $viewport);
	$w = $a[0];
	$h = $a[1];
	if($w)
		$vp = "--width $w ";
	if($h)
		$vp.= "--height $h ";

}	

if($js=='no')
	$jsp = '-n ';

switch ($type) {
	case 'png':
		$ft = $type;
		header('Content-Type: image/png');
	break;

	case 'jpg':
	case 'jpeg':
	default:
		$ft = 'jpg';
		header('Content-Type: image/jpeg');
}



if(!$cache)
	$cache = md5(time().rand(1,2000));
$hash = $cache.'-'.preg_replace("/[^A-Za-z0-9 ]/", '', $url).'.'.$ft;

if(!is_dir(__DIR__.'/cache/'))
	mkdir(__DIR__.'/cache/');
$file = __DIR__.'/cache/'.$hash;
if(!file_exists($file))
{'fraction_non_alphanumeric': 0.2919369786839666, 'fraction_numerical': 0.020389249304911955, 'mean_word_length': 4.622395833333333, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '2777209', 'n_tokens_mistral': 987, 'n_tokens_neox': 937, 'n_words': 156}