You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by jf...@apache.org on 2016/08/26 18:04:02 UTC

svn commit: r1757902 - in /vcl/trunk/web/.ht-inc: authentication.php states.php utils.php

Author: jfthomps
Date: Fri Aug 26 18:04:01 2016
New Revision: 1757902

URL: http://svn.apache.org/viewvc?rev=1757902&view=rev
Log:
VCL-985 - login page and change locale form use continuations when user is logged out

authentication.php: modified printLoginPage: removed hidden input for continuation, added 2 hidden inputs - mode and authtype

states.php: added changeLocale to $actions['entry']

utils.php:
-modified getDojoHTML: added $filename for oneclick section
-modified changeLocale: split into 2 sections, depending on the value of $authed, set $newlocale, $oldmode, and $authtype from continuation if $authed is true, set them from form input variables if $authed is false
-modified getSelectLanguagePulldown: split into 2 sections, depending on the value of $authed, print a select form element based on continuations if $authed is true, print it based on input variables if $authed is false

Modified:
    vcl/trunk/web/.ht-inc/authentication.php
    vcl/trunk/web/.ht-inc/states.php
    vcl/trunk/web/.ht-inc/utils.php

Modified: vcl/trunk/web/.ht-inc/authentication.php
URL: http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/authentication.php?rev=1757902&r1=1757901&r2=1757902&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/authentication.php (original)
+++ vcl/trunk/web/.ht-inc/authentication.php Fri Aug 26 18:04:01 2016
@@ -230,7 +230,7 @@ function printLoginPage($servertimeout=0
 	if($userid == i('Proceed to Login'))
 		$userid = '';
 	if(! array_key_exists($authtype, $authMechs)) {
-		// FIXME - hackish
+		header("Location: " . BASEURL . SCRIPT);
 		dbDisconnect();
 		exit;
 	}
@@ -300,9 +300,8 @@ function printLoginPage($servertimeout=0
 	print "    <TD colspan=2 align=right><INPUT type=submit value=\"" . i("Login") . "\"></TD>\n";
 	print "  </TR>\n";
 	print "</TABLE>\n";
-	$cdata = array('authtype' => $authtype);
-	$cont = addContinuationsEntry('submitLogin', $cdata);
-	print "<INPUT type=hidden name=continuation value=\"$cont\">\n";
+	print "<input type=\"hidden\" name=\"mode\" value=\"submitLogin\">\n";
+	print "<input type=\"hidden\" name=\"authtype\" value=\"$authtype\">\n";
 	print "</FORM>\n";
 	print "$text2<br>\n";
 	print "</div>\n";

Modified: vcl/trunk/web/.ht-inc/states.php
URL: http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/states.php?rev=1757902&r1=1757901&r2=1757902&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/states.php (original)
+++ vcl/trunk/web/.ht-inc/states.php Fri Aug 26 18:04:01 2016
@@ -62,6 +62,7 @@ $actions["entry"] = array('main',
                           'siteconfig',
                           'newOneClick',
                           'AJsetTZoffset',
+                          'changeLocale',
 );
 
 $noHTMLwrappers = array('sendRDPfile',

Modified: vcl/trunk/web/.ht-inc/utils.php
URL: http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/utils.php?rev=1757902&r1=1757901&r2=1757902&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/utils.php (original)
+++ vcl/trunk/web/.ht-inc/utils.php Fri Aug 26 18:04:01 2016
@@ -13092,6 +13092,7 @@ function getDojoHTML($refresh) {
 		case 'submitOneClick':
 		case 'submitEditOneClick':
 		case 'deleteOneClick':
+			$filename = 'oneclick.js';
 			$dojoRequires = array('dojo.parser',
 			                      'dijit.layout.ContentPane',
 			                      'dijit.form.ValidationTextBox',
@@ -13564,10 +13565,27 @@ function printHTMLFooter() {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function changeLocale() {
-	global $locale;
-	$newlocale = getContinuationVar('locale');
-	$oldmode = getContinuationVar('oldmode');
-	$authtype = getContinuationVar('authtype', '');
+	global $locale, $authed, $authMechs;
+	if($authed) {
+		$newlocale = getContinuationVar('locale');
+		$oldmode = getContinuationVar('oldmode');
+		$authtype = getContinuationVar('authtype', '');
+	}
+	else {
+		$newlocale = processInputVar('locale', ARG_STRING);
+		$oldmode = processInputVar('oldmode', ARG_STRING);
+		$authtype = processInputVar('authtype', ARG_STRING);
+		if($oldmode != 'selectauth')
+			$oldmode = '';
+		if(! array_key_exists($authtype, $authMechs))
+			$authtype = '';
+		$locales = getFSlocales();
+		if(! array_key_exists($newlocale, $locales)) {
+			header("Location: " . BASEURL . SCRIPT);
+			dbDisconnect();
+			exit;
+		}
+	}
 	$locale = $newlocale;
 	setcookie("VCLLOCALE", $locale, (time() + (86400 * 31)), "/", COOKIEDOMAIN);
 	$extra = '';
@@ -13637,7 +13655,7 @@ function setVCLLocale() {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function getSelectLanguagePulldown() {
-	global $locale, $user, $remoteIP, $mode, $authMechs;
+	global $locale, $user, $remoteIP, $mode, $authMechs, $authed;
 	$tmp = explode('/', $_SERVER['SCRIPT_FILENAME']);
 	array_pop($tmp);
 	array_push($tmp, 'locale');
@@ -13651,24 +13669,46 @@ function getSelectLanguagePulldown() {
 		$user['id'] = 0;
 
 	$rt  = "<form name=\"localeform\" class=\"localeform\" action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
-	$rt .= "<select name=\"continuation\" onChange=\"this.form.submit();\" autocomplete=\"off\">\n";
-	$cdata = array('IP' => $remoteIP, 'oldmode' => $mode);
-	if($mode == 'selectauth') {
-		$type = processInputVar('authtype', ARG_STRING);
-		if(! empty($type) && array_key_exists($type, $authMechs))
-			$cdata['authtype'] = $type;
+	if($authed) {
+		$rt .= "<select name=\"continuation\" onChange=\"this.form.submit();\" autocomplete=\"off\">\n";
+		$cdata = array('IP' => $remoteIP, 'oldmode' => $mode);
+		if($mode == 'selectauth') {
+			$type = processInputVar('authtype', ARG_STRING);
+			if(! empty($type) && array_key_exists($type, $authMechs))
+				$cdata['authtype'] = $type;
+		}
+		foreach($locales as $dir => $lang) {
+			$cdata['locale'] = $dir;
+			$tmp = explode('/', $dir);
+			$testlocale = array_pop($tmp);
+			$cont = addContinuationsEntry('changeLocale', $cdata, 86400);
+			if($locale == $testlocale)
+				$rt .= "<option value=\"$cont\" selected>{$lang}</option>\n";
+			else
+				$rt .= "<option value=\"$cont\">{$lang}</option>\n";
+		}
+		$rt .= "</select>\n";
 	}
-	foreach($locales as $dir => $lang) {
-		$cdata['locale'] = $dir;
-		$tmp = explode('/', $dir);
-		$testlocale = array_pop($tmp);
-		$cont = addContinuationsEntry('changeLocale', $cdata, 86400);
-		if($locale == $testlocale)
-			$rt .= "<option value=\"$cont\" selected>{$lang}</option>\n";
-		else
-			$rt .= "<option value=\"$cont\">{$lang}</option>\n";
+	else {
+		$rt .= "<select name=\"locale\" onChange=\"this.form.submit();\" autocomplete=\"off\">\n";
+		foreach($locales as $dir => $lang) {
+			$tmp = explode('/', $dir);
+			$testlocale = array_pop($tmp);
+			if($locale == $testlocale)
+				$rt .= "<option value=\"$dir\" selected>{$lang}</option>\n";
+			else
+				$rt .= "<option value=\"$dir\">{$lang}</option>\n";
+		}
+		$rt .= "</select>\n";
+		if($mode == 'selectauth') {
+			$type = processInputVar('authtype', ARG_STRING);
+			if(! empty($type) && array_key_exists($type, $authMechs)) {
+				$rt .= "<input type=\"hidden\" name=\"authtype\" value=\"$type\">\n";
+				$rt .= "<input type=\"hidden\" name=\"oldmode\" value=\"selectauth\">\n";
+			}
+		}
+		$rt .= "<input type=\"hidden\" name=\"mode\" value=\"changeLocale\">\n";
 	}
-	$rt .= "</select>\n";
 	$rt .= "</form> \n";
 	return $rt;
 }