<commit_before><!---
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 ---><cfif request.admintype EQ "web"><cflocation url="#request.self#" addtoken="no"></cfif>
<cfinclude template="ext.functions.cfm">

<cfparam name="url.action2" default="none">
<cfset error.message="">
<cfset error.detail="">

<cftry>
<cfswitch expression="#url.action2#">
	<cfcase value="settings">
    	<cfif not len(form.location)>
        	<cfset form.location=form.locationCustom>
        </cfif>

		<cfadmin
			action="UpdateUpdate"
			type="#request.adminType#"
			password="#session["password"&request.adminType]#"

			updateType="#form.type#"
			updateLocation="#form.location#"
			remoteClients="#request.getRemoteClients()#">
	</cfcase>
	<cfcase value="run">
		<cfsetting requesttimeout="10000">
		<cfadmin
			action="runUpdate"
			type="#request.adminType#"
			password="#session["password"&request.adminType]#"
			remoteClients="#request.getRemoteClients()#">
	</cfcase>

	<cfcase value="remove">
		<cfadmin
			action="removeUpdate"
            onlyLatest="#StructKeyExists(form,'latest')#"
			type="#request.adminType#"
			password="#session["password"&request.adminType]#"
			remoteClients="#request.getRemoteClients()#">
	</cfcase>

	<!---<cfcase value="downUp">
		<cfsetting requesttimeout="100000">
		<cfadmin
			action="changeVersionTo"
            version="#form.version#"
			type="#request.adminType#"
			password="#session["password"&request.adminType]#"
			remoteClients="#request.getRemoteClients()#">
	</cfcase>--->



</cfswitch>
	<cfcatch>
		<cfset error.message=cfcatch.message>
		<cfset error.detail=cfcatch.Detail>
		<cfset error.cfcatch=cfcatch>
	</cfcatch>
</cftry>

<!---
Redirtect to entry --->
<cfif url.action2 NEQ "none" and error.message EQ "">
	<cflocation url="#request.self#?action=#url.action#" addtoken="no">
</cfif>

<!---
Error Output --->
<cfset printError(error)>


<cfadmin
			action="listPatches"
			returnvariable="patches"
            type="#request.adminType#"
            password="#session["password"&request.adminType]#">

<cftry>
	<cfadmin
			action="getMinVersion"
			returnvariable="minVersion"
            type="#request.adminType#"
            password="#session["password"&request.adminType]#">
    <cfcatch>
    	<cfset minVersion=createObject('java','lucee.VersionInfo').getIntVersion().toString()>
    </cfcatch>
</cftry>
<!----
<cfadmin
			action="needNewJars"
			returnvariable="needNewJars"
            type="#request.adminType#"
            password="#session["password"&request.adminType]#">
because this is only about optional updates, we do this only in background from now
---->
<cfset needNewJars=false>

<cfscript>
include "services.update.functions.cfm";

// get info for the update location

	curr=server.lucee.version;
	updateData=getAvailableVersion();
try{
	if(isNull(updateData.code) || updateData.code==404)
		cfthrow(message="Could not reach update provider [#updateData.provider.location#].",detail=updateData.message);
	else if(updateData.code!=200)
		cfthrow(message="Invalid response from [#updateData.provider.location#].",detail=updateData.message);
	
	updateData.qryOtherVersions=queryNew('version,versionSortable');
	queryAddRow(updateData.qryOtherVersions,updateData.otherVersions.len());
	loop array=updateData.otherVersions item="v" index="i" {
		updateData.qryOtherVersions.version[i]=v;
		updateData.qryOtherVersions.versionSortable[i]=toVersionSortable(v);
	}
} catch (any e){ 
	error.message=cfcatch.message;
	error.detail=cfcatch.Detail;
	error.exception = cfcatch;
	error.cfcatch = cfcatch;
}
printError(error);
	if(structKeyExists(updateData,"qryOtherVersions"))querySort(updateData.qryOtherVersions,'versionSortable','desc');
	hasAccess=1;
	hasUpdate=structKeyExists(updateData,"available");
</cfscript>



<cfoutput>

<cfhtmlbody>
<script type="text/javascript">
	var submitted = false;
	function changeVersion(field) {
		field.disabled = true;
		submitted = true;
		var versionField=field.form.version;
		var value = versionField.options[versionField.selectedIndex].value;
		//alert(value);
		url='changeto.cfm?#session.urltoken#&adminType=#request.admintype#&version='+value;
		$(document).ready(function(){
			$('##updateInfoDesc').html('<img src="../res/img/spinner16.gif.cfm">');
			disableBlockUI=true;


	 		$.get(url, function(response) {
	      		field.disabled = false;

	 			if((response+"").trim()=="")
					window.location=('#request.self#?action=#url.action#'); //$('##updateInfoDesc').html("<p>#stText.services.update.restartOKDesc#</p>");
				else
					$('##updateInfoDesc').html('<div class="error">'+response+'</div>');
					//window.location=('#request.self#?action=#url.action#'); //$('##updateInfoDesc').html(response);

	 		});
		});
	}
	</script>
</cfhtmlbody>


	<div class="pageintro">#stText.services.update.desc#</div>

	<!--- Settings --->
	<h2>#stText.services.update.setTitle#</h2>
	<div class="itemintro">#stText.services.update.setDesc#</div>
	<cfformClassic onerror="customError" action="#go(url.action,"settings")#" method="post">
		<table class="maintbl">
			<tbody>
				<tr>
					<th scope="row">#stText.services.update.provider#</th><commit_msg>Fix for LDEV-1686<commit_after><!---
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 ---><cfif request.admintype EQ "web"><cflocation url="#request.self#" addtoken="no"></cfif>
<cfinclude template="ext.functions.cfm">

<cfparam name="url.action2" default="none">
<cfset error.message="">
<cfset error.detail="">

<cftry>
<cfswitch expression="#url.action2#">
	<cfcase value="settings">
    	<cfif not len(form.location)>
        	<cfset form.location=form.locationCustom>
        </cfif>

		<cfadmin
			action="UpdateUpdate"
			type="#request.adminType#"
			password="#session["password"&request.adminType]#"

			updateType="#form.type#"
			updateLocation="#form.location#"
			remoteClients="#request.getRemoteClients()#">
	</cfcase>
	<cfcase value="run">
		<cfsetting requesttimeout="10000">
		<cfadmin
			action="runUpdate"
			type="#request.adminType#"
			password="#session["password"&request.adminType]#"
			remoteClients="#request.getRemoteClients()#">
	</cfcase>

	<cfcase value="remove">
		<cfadmin
			action="removeUpdate"
            onlyLatest="#StructKeyExists(form,'latest')#"
			type="#request.adminType#"
			password="#session["password"&request.adminType]#"
			remoteClients="#request.getRemoteClients()#">
	</cfcase>

	<!---<cfcase value="downUp">
		<cfsetting requesttimeout="100000">
		<cfadmin
			action="changeVersionTo"
            version="#form.version#"
			type="#request.adminType#"
			password="#session["password"&request.adminType]#"
			remoteClients="#request.getRemoteClients()#">
	</cfcase>--->



</cfswitch>
	<cfcatch>
		<cfset error.message=cfcatch.message>
		<cfset error.detail=cfcatch.Detail>
		<cfset error.cfcatch=cfcatch>
	</cfcatch>
</cftry>

<!---
Redirtect to entry --->
<cfif url.action2 NEQ "none" and error.message EQ "">
	<cflocation url="#request.self#?action=#url.action#" addtoken="no">
</cfif>

<!---
Error Output --->
<cfset printError(error)>


<cfadmin
			action="listPatches"
			returnvariable="patches"
            type="#request.adminType#"
            password="#session["password"&request.adminType]#">

<cftry>
	<cfadmin
			action="getMinVersion"
			returnvariable="minVersion"
            type="#request.adminType#"
            password="#session["password"&request.adminType]#">
    <cfcatch>
    	<cfset minVersion=createObject('java','lucee.VersionInfo').getIntVersion().toString()>
    </cfcatch>
</cftry>
<!----
<cfadmin
			action="needNewJars"
			returnvariable="needNewJars"
            type="#request.adminType#"
            password="#session["password"&request.adminType]#">
because this is only about optional updates, we do this only in background from now
---->
<cfset needNewJars=false>

<cfscript>
include "services.update.functions.cfm";

// get info for the update location

	curr=server.lucee.version;
	updateData=getAvailableVersion();
try{
	if(isNull(updateData.code) || updateData.code==404)
		cfthrow(message="Could not reach update provider [#updateData.provider.location#].",detail=updateData.message);
	else if(updateData.code!=200)
		cfthrow(message="Invalid response from [#updateData.provider.location#].",detail=updateData.message);
	
	updateData.qryOtherVersions=queryNew('version,versionSortable');
	queryAddRow(updateData.qryOtherVersions,updateData.otherVersions.len());
	loop array=updateData.otherVersions item="v" index="i" {
		updateData.qryOtherVersions.version[i]=v;
		updateData.qryOtherVersions.versionSortable[i]=toVersionSortable(v);
	}
} catch (any e){ 
	error.message=cfcatch.message;
	error.detail=cfcatch.Detail;
	error.exception = cfcatch;
	error.cfcatch = cfcatch;
}
printError(error);
	if(structKeyExists(updateData,"qryOtherVersions"))querySort(updateData.qryOtherVersions,'versionSortable','desc');
	hasAccess=1;
	hasUpdate=structKeyExists(updateData,"available");
</cfscript>



<cfoutput>

<cfhtmlbody>
<script type="text/javascript">
	var submitted = false;
	function changeVersion(field) {
		field.disabled = true;
		submitted = true;
		var versionField=field.form.version;
		var value = versionField.options[versionField.selectedIndex].value;
		//alert(value);
		url='changeto.cfm?#session.urltoken#&adminType=#request.admintype#&version='+value;
		$(document).ready(function(){
			$('##updateInfoDesc').html('<img src="../res/img/spinner16.gif.cfm">');
			disableBlockUI=true;

			$.ajax({
				method: 'get',
				url: url,
				success: function(response, status) {
					if((response+"").trim()=="")
					window.location=('#request.self#?action=#url.action#'); //$('##updateInfoDesc').html("<p>#stText.services.update.restartOKDesc#</p>");
					else
					$('##updateInfoDesc').html('<div class="error">'+response+'</div>');
					//window.location=('#request.self#?action=#url.action#'); //$('##updateInfoDesc').html(response);
				},
				error: function(e) {
					$('##updateInfoDesc').html('<div class="error">Update Failed Please Try again</div>');
				}
			});
		});
	}
	</script>
</cfhtmlbody>


	<div class="pageintro">#stText.services.update.desc#</div>

	<!--- Settings --->
	<h2>#stText.services.update.setTitle#</h2>
	<div class="itemintro">#stText.services.update.setDesc#</div>
	<cfformClassic onerror="customError" action="#go(url.action,"settings")#" method="post">
		<table class="maintbl">
			<tbody>
				<tr>
					<th scope="row">#stText.services.update.provider#</th>
{'fraction_non_alphanumeric': 0.16921369418594723, 'fraction_numerical': 0.004951762998377871, 'mean_word_length': 4.9311392405063295, 'pattern_counts': {'":': 0, '<': 159, '<?xml version=': 0, '>': 159, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5320190', 'n_tokens_mistral': 4127, 'n_tokens_neox': 3767, 'n_words': 683}