<commit_before><?php
//Utility to check if client IP matches requirements for a particular ebook
INCLUDE "sensitive.php";
require("config/config.php");

//expecting ebook PID as GET parameter
$clientIP = $_SERVER['REMOTE_ADDR']; 
$PID = $_GET['ItemID'];

//check security policy on etext object
$baseURL = "https://$FEDORA_USERNAME:$FEDORA_PASSWORD@silo.lib.wayne.edu/fedora/risearch?";
$queryOptions = "type=tuples&lang=itql&format=json&dt=on&stream=on&query=";
$baseQuery = "select \$object from <#ri> where <info:fedora/$PID> <http://$APP_HOST/fedora/objects/wayne:WSUDOR-Fedora-Relations/datastreams/RELATIONS/content/hasSecurityPolicy> \$object;";

$concatURL = $baseURL.$queryOptions.urlencode($baseQuery);
$results = file_get_contents($concatURL);
$decoded_results = json_decode($results);
// print_r($decoded_results);

if (count($decoded_results->results) === 0 ){		
	$proxyRequire = "true";
}

else{
	$exploded = explode("/", $decoded_results->results[0]->object);	

	if ($exploded[1] === "wayne:WSUDORSecurity-permit-apia-WSUComm"){
		$proxyRequire = "true";
	}
	if ($exploded[1] === "wayne:WSUDORSecurity-permit-apia-unrestricted"){
		$proxyRequire = "false";
	}
}

//if Proxy required<commit_msg>fix to redirect auth<commit_after><?php
//Utility to check if client IP matches requirements for a particular ebook
INCLUDE "sensitive.php";
require("config/config.php");

//expecting ebook PID as GET parameter
$clientIP = $_SERVER['REMOTE_ADDR']; 
$PID = $_GET['ItemID'];

//check security policy on etext object
$baseURL = "https://$FEDORA_USERNAME:$FEDORA_PASSWORD@silo.lib.wayne.edu/fedora/risearch?";
$queryOptions = "type=tuples&lang=itql&format=json&dt=on&stream=on&query=";
$baseQuery = "select \$object from <#ri> where <info:fedora/$PID> <http://digital.library.wayne.edu/fedora/objects/wayne:WSUDOR-Fedora-Relations/datastreams/RELATIONS/content/hasSecurityPolicy> \$object;";

$concatURL = $baseURL.$queryOptions.urlencode($baseQuery);
$results = file_get_contents($concatURL);
$decoded_results = json_decode($results);
// print_r($decoded_results);

if (count($decoded_results->results) === 0 ){		
	$proxyRequire = "true";
}

else{
	$exploded = explode("/", $decoded_results->results[0]->object);	

	if ($exploded[1] === "wayne:WSUDORSecurity-permit-apia-WSUComm"){
		$proxyRequire = "true";
	}
	if ($exploded[1] === "wayne:WSUDORSecurity-permit-apia-unrestricted"){
		$proxyRequire = "false";
	}
}

//if Proxy required
{'fraction_non_alphanumeric': 0.1753379762392462, 'fraction_numerical': 0.0032773453502662844, 'mean_word_length': 6.422492401215806, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '3720644', 'n_tokens_mistral': 909, 'n_tokens_neox': 865, 'n_words': 150}