<commit_before><?php

function spliturl( $request ) {
	#split the path by '/'
	$params = explode( '/', $request );

	//echo $_SERVER['REQUEST_URI'].'<br>'.$request;
	//print_r($params);

	$family = $params[0];
	$subfamily = '';
	if ( strpos( $family, '-' ) !== FALSE ) {
		$newfamily = explode( '-', $family );
		//print_r($newfamily);
		$family    = $newfamily[0];
		$subfamily = $newfamily[1];
	}
	$aggregator = $params[1];
	$parameters = array();
	if ( isset( $params[2] ) ) { $parameters[] = $params[2]; }
	if ( isset( $params[3] ) ) { $parameters[] = $params[3]; }
	if ( isset( $params[4] ) ) { $parameters[] = $params[4]; }
	
	return array( $family, $subfamily, $aggregator, $parameters );
}

function html_escape($var) {
	if (is_array($var)) {
		return array_map('html_escape', $var);
	} else {
		return htmlspecialchars($var, ENT_QUOTES, 'UTF-8');
	}
}

/*
 * Functions that clean string so they can be used in a URL
 */
function url_title($str, $separator = '-', $lowercase = TRUE) {
	if ($separator == 'dash') {
	    $separator = '-';
	} else if ($separator == 'underscore') {
	    $separator = '_';
	}
	
	$q_separator = preg_quote($separator);

	$trans = array(
		'&.+?;'                 => '',
		'[^a-z0-9 _-]'          => '',
		'\s+'                   => $separator,
		'('.$q_separator.')+'   => $separator
	);

	$str = strip_tags($str);

	foreach ($trans as $key => $val) {
		$str = preg_replace("#".$key."#i", $val, $str);
	}

	if ($lowercase === TRUE) {
		$str = strtolower($str);
	}

	return trim($str, $separator);
}

// functions per immagini

function generate_user_img_url($user_id, $user_filename) {
	$user_file_url = BASEPATH.'uploads/clients/group1/client'.$user_id;
	$user_file_path = realpath('uploads/clients/group1/client'.$user_id);
		
	if($user_filename != '' && file_exists($user_file_path) && file_exists($user_file_path.'/'.$user_filename)) {
		$out = $user_file_url.'/'.$user_filename;
	} else {
		$out = BASEPATH.'assets/images/avatar_default.jpg'; 
	}
    return $out;
}

function get_activity_img_path($acfoldername, $prid) {
    return 'uploads/activities/group1/'.$acfoldername.'/main/';
}

function generate_activity_logo_url($activity_folder, $filename) {<commit_msg>adding function for makingg url<commit_after><?php

function spliturl( $request ) {
	#split the path by '/'
	$params = explode( '/', $request );

	//echo $_SERVER['REQUEST_URI'].'<br>'.$request;
	//print_r($params);

	$family = $params[0];
	$subfamily = '';
	if ( strpos( $family, '-' ) !== FALSE ) {
		$newfamily = explode( '-', $family );
		//print_r($newfamily);
		$family    = $newfamily[0];
		$subfamily = $newfamily[1];
	}
	$aggregator = $params[1];
	$parameters = array();
	if ( isset( $params[2] ) ) { $parameters[] = $params[2]; }
	if ( isset( $params[3] ) ) { $parameters[] = $params[3]; }
	if ( isset( $params[4] ) ) { $parameters[] = $params[4]; }
	
	return array( $family, $subfamily, $aggregator, $parameters );
}

function html_escape($var) {
	if (is_array($var)) {
		return array_map('html_escape', $var);
	} else {
		return htmlspecialchars($var, ENT_QUOTES, 'UTF-8');
	}
}

/*
 * Functions that clean string so they can be used in a URL
 */
function url_title($str, $separator = '-', $lowercase = TRUE) {
	if ($separator == 'dash') {
	    $separator = '-';
	} else if ($separator == 'underscore') {
	    $separator = '_';
	}
	
	$q_separator = preg_quote($separator);

	$trans = array(
		'&.+?;'                 => '',
		'[^a-z0-9 _-]'          => '',
		'\s+'                   => $separator,
		'('.$q_separator.')+'   => $separator
	);

	$str = strip_tags($str);

	foreach ($trans as $key => $val) {
		$str = preg_replace("#".$key."#i", $val, $str);
	}

	if ($lowercase === TRUE) {
		$str = strtolower($str);
	}

	return trim($str, $separator);
}

/**
 * It creates a URL appenting the content of variable $_SESSION['usr_type'] to BASEPATH
 *
 * Result is: BASEPATH . $_SESSION['usr_type'] . $final_part
 *
 * @param        string     Group
 * @param        string     Action
 * @param        string     Parameters: string separated with '/'
 * @param        string     Extection:  .html by default
 *
 * @return       string     The url well formed
 */
function make_url( $group = 'main', $action = '', $parameters = '', $extection = '.html' ) {
    if ( $group == 'main' ) {
        return BASEPATH.$_SESSION['usr_type'].'/'.$action.'/'.$parameters.$extection;
    } else {
        return BASEPATH.$_SESSION['usr_type'].'-'.$group.'/'.$action.'/'.$parameters.$extection;
    }
}

// functions per immagini

function generate_user_img_url($user_id, $user_filename) {
	$user_file_url = BASEPATH.'uploads/clients/group1/client'.$user_id;
	$user_file_path = realpath('uploads/clients/group1/client'.$user_id);
		
	if($user_filename != '' && file_exists($user_file_path) && file_exists($user_file_path.'/'.$user_filename)) {
		$out = $user_file_url.'/'.$user_filename;
	} else {
		$out = BASEPATH.'assets/images/avatar_default.jpg'; 
	}
    return $out;
}

function get_activity_img_path($acfoldername, $prid) {
    return 'uploads/activities/group1/'.$acfoldername.'/main/';
}

function generate_activity_logo_url($activity_folder, $filename) {
{'fraction_non_alphanumeric': 0.20336687306501547, 'fraction_numerical': 0.006191950464396285, 'mean_word_length': 3.5743362831858407, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '3264986', 'n_tokens_mistral': 1939, 'n_tokens_neox': 1860, 'n_words': 357}