<commit_before><?php

function getURLMetadata($url) {
	//allow only http(s) and (s)ftp
	$protocols = '/^[hs]{0,1}[tf]{0,1}tp[s]{0,1}\:\/\//i';
	//if not (allowed) protocol is given, assume http
	if(preg_match($protocols, $url) == 0) {
		$url = 'http://' . $url;
	} 
	$metadata['url'] = $url;

	$page = file_get_contents($url);
	@preg_match( "/<title>(.*)<\/title>/si", $page, $match );
	$metadata['title'] = htmlspecialchars_decode(@$match[1]); 

	$meta = get_meta_tags($url);

	if(array_key_exists('description', $meta)) {
		$metadata['description'] = $meta['description'];
	}
	
	return $metadata;
}<commit_msg>apps/bookmarks: use curl instead of file_get_contents<commit_after><?php

function getURLMetadata($url) {
	//allow only http(s) and (s)ftp
	$protocols = '/^[hs]{0,1}[tf]{0,1}tp[s]{0,1}\:\/\//i';
	//if not (allowed) protocol is given, assume http
	if(preg_match($protocols, $url) == 0) {
		$url = 'http://' . $url;
	} 
	$metadata['url'] = $url;

	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	$page = curl_exec($ch);
	curl_close($ch);

	@preg_match( "/<title>(.*)<\/title>/si", $page, $match );
	$metadata['title'] = htmlspecialchars_decode(@$match[1]); 

	$meta = get_meta_tags($url);

	if(array_key_exists('description', $meta)) {
		$metadata['description'] = $meta['description'];
	}
	
	return $metadata;
}
{'fraction_non_alphanumeric': 0.2351233671988389, 'fraction_numerical': 0.012336719883889695, 'mean_word_length': 5.15625, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, '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': '649991', 'n_tokens_mistral': 571, 'n_tokens_neox': 539, 'n_words': 98}