<commit_before><?php
if(file_exists("config.js") && file_exists("config.php") && file_exists("../.well-known/host-meta")) {
	die("Looks like the installation was already successfully completed");
}
if($_POST["install"] == "install") {
	$domain = $_POST["domain"];
	$protocol = $_POST["protocol"];
	$installationType = $_POST["installationType"];
	if($installationType == "hive") {
		@unlink("base64.js");
		@unlink("callback.html"); 
		@unlink("login.html");
		@unlink("register.html");
		@unlink("sjcl/sjcl.js");
		@rmdir("sjcl");
		@unlink("unhosted.js");
		@unlink("wallet.js");
		@unlink("webfinger.js");
		@file_put_contents("../index.html", "This the unhosted hive for $protocol://$domain. Please contact <EMAIL>@$domain for more info about your unhosted account.");
	}
	$scriptDir = dirname(__file__);
	$wwwDir = dirname($scriptDir);
	$virtualHostDir = dirname($wwwDir);
	file_put_contents("config.php", "<?php\n"
		."class UnhostedSettings {\n"
		."\tconst installationType = '$installationType';\n"
		."\tconst protocol = '$protocol';\n"
		."\tconst domain = '$domain';\n"
		."\tconst davDir = '$virtualHostDir/dav/';\n"
		."\tconst pwdDir = '$virtualHostDir/pwd/';\n"
		."\tconst walletDir = '$virtualHostDir/wallet/';\n"
		."}\n");
	file_put_contents("config.js", 
		"var appBaseUrl = '$protocol://$domain';\n"
		."var installationType = '$installationType';\n"
		."\n"
		."var config = {\n"
		."\tappUrl: appBaseUrl + '/',\n"
		."\tdoUrl: appBaseUrl + '/unhosted/do.php',\n"
		."\tloginUrl: appBaseUrl + '/unhosted/login.html',\n"
		."\tregisterUrl: appBaseUrl + '/unhosted/register.html',\n"
		."\tcallbackUrl: appBaseUrl + '/unhosted/callback.html',\n"
		."\tclientId: '$domain',\n"
		."\tdataScope: '$domain',\n"
		."\thomeDomain: '$domain'\n"
		."}\n");
	file_put_contents("../.well-known/host-meta", "<?xml version='1.0' encoding='UTF-8'?>\n"
		."<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0' \n"
 		."\t\txmlns:hm='http://host-meta.net/xrd/1.0'>\n"
 		."\t<hm:Host xmlns='http://host-meta.net/xrd/1.0'>$domain</hm:Host>\n"
 		."\t<Link rel='lrdd' \n"
 		."\t\ttemplate='http://$domain/unhosted/webfinger.php?q={uri}'>\n"
 		."\t\t<Title>Resource Descriptor</Title>\n"
 		."\t</Link>\n"
 		."\t<Link rel='register'\n" 
 		."\t\ttemplate='http://$domain/unhosted/register.html?user_name={uri}&amp;redirect_url={redirect_url}'>\n"
 		."\t\t<Title>Resource Descriptor</Title>\n"
 		."\t</Link>\n"<commit_msg>correcting protocol in host-meta when installed over https<commit_after><?php
if(file_exists("config.js") && file_exists("config.php") && file_exists("../.well-known/host-meta")) {
	die("Looks like the installation was already successfully completed");
}
if($_POST["install"] == "install") {
	$domain = $_POST["domain"];
	$protocol = $_POST["protocol"];
	$installationType = $_POST["installationType"];
	if($installationType == "hive") {
		@unlink("base64.js");
		@unlink("callback.html"); 
		@unlink("login.html");
		@unlink("register.html");
		@unlink("sjcl/sjcl.js");
		@rmdir("sjcl");
		@unlink("unhosted.js");
		@unlink("wallet.js");
		@unlink("webfinger.js");
		@file_put_contents("../index.html", "This the unhosted hive for $protocol://$domain. Please contact <EMAIL>@$domain for more info about your unhosted account.");
	}
	$scriptDir = dirname(__file__);
	$wwwDir = dirname($scriptDir);
	$virtualHostDir = dirname($wwwDir);
	file_put_contents("config.php", "<?php\n"
		."class UnhostedSettings {\n"
		."\tconst installationType = '$installationType';\n"
		."\tconst protocol = '$protocol';\n"
		."\tconst domain = '$domain';\n"
		."\tconst davDir = '$virtualHostDir/dav/';\n"
		."\tconst pwdDir = '$virtualHostDir/pwd/';\n"
		."\tconst walletDir = '$virtualHostDir/wallet/';\n"
		."}\n");
	file_put_contents("config.js", 
		"var appBaseUrl = '$protocol://$domain';\n"
		."var installationType = '$installationType';\n"
		."\n"
		."var config = {\n"
		."\tappUrl: appBaseUrl + '/',\n"
		."\tdoUrl: appBaseUrl + '/unhosted/do.php',\n"
		."\tloginUrl: appBaseUrl + '/unhosted/login.html',\n"
		."\tregisterUrl: appBaseUrl + '/unhosted/register.html',\n"
		."\tcallbackUrl: appBaseUrl + '/unhosted/callback.html',\n"
		."\tclientId: '$domain',\n"
		."\tdataScope: '$domain',\n"
		."\thomeDomain: '$domain'\n"
		."}\n");
	file_put_contents("../.well-known/host-meta", "<?xml version='1.0' encoding='UTF-8'?>\n"
		."<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0' \n"
 		."\t\txmlns:hm='http://host-meta.net/xrd/1.0'>\n"
 		."\t<hm:Host xmlns='http://host-meta.net/xrd/1.0'>$domain</hm:Host>\n"
 		."\t<Link rel='lrdd' \n"
 		."\t\ttemplate='$protocol://$domain/unhosted/webfinger.php?q={uri}'>\n"
 		."\t\t<Title>Resource Descriptor</Title>\n"
 		."\t</Link>\n"
 		."\t<Link rel='register'\n" 
 		."\t\ttemplate='$protocol://$domain/unhosted/register.html?user_name={uri}&amp;redirect_url={redirect_url}'>\n"
 		."\t\t<Title>Resource Descriptor</Title>\n"
 		."\t</Link>\n"
{'fraction_non_alphanumeric': 0.24547488305877568, 'fraction_numerical': 0.0044742729306487695, 'mean_word_length': 4.271168274383708, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 2, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 8}, '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': '6138108', 'n_tokens_mistral': 2051, 'n_tokens_neox': 1948, 'n_words': 274}