Skip to content

Commit

Permalink
Dev Fixed default value for SSL enforcement not set proper on a new i…
Browse files Browse the repository at this point in the history
…nstallation

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev@9458 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Nov 9, 2010
1 parent eca187a commit c85fc12
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 28 deletions.
5 changes: 2 additions & 3 deletions admin/database.php
Expand Up @@ -1110,6 +1110,8 @@ function get_max_question_order($gid)
if ($usresult->RecordCount()==0)
{

$bplang = new limesurvey_lang($langname);
$aDefaultTexts=aTemplateDefaultTexts($bplang,'unescaped');
if (getEmailFormat($surveyid) == "html")
{
$ishtml=true;
Expand All @@ -1119,9 +1121,6 @@ function get_max_question_order($gid)
{
$ishtml=false;
}

$bplang = new limesurvey_lang($langname);
$aDefaultTexts=aTemplateDefaultTexts($bplang,'unescaped');
$languagedetails=getLanguageDetails($langname);
$usquery = "INSERT INTO ".db_table_name('surveys_languagesettings')
." (surveyls_survey_id, surveyls_language, surveyls_title, "
Expand Down
32 changes: 16 additions & 16 deletions admin/globalsettings.php
Expand Up @@ -92,7 +92,7 @@ function globalsettingssave()
$sessionlifetimetemp=(int)($_POST['sessionlifetime']);
if ($sessionlifetimetemp==0) $sessionlifetimetemp=3600;
setGlobalSetting('sessionlifetime',$sessionlifetimetemp);
setGlobalSetting('forcehttps',$_POST['forcehttps']);
setGlobalSetting('force_ssl',$_POST['force_ssl']);
setGlobalSetting('surveyPreview_require_Auth',strip_tags($_POST['surveyPreview_require_Auth']));
$savetime=trim(strip_tags((float) $_POST['timeadjust']).' hours'); //makes sure it is a number, at least 0
if ((substr($savetime,0,1)!='-') && (substr($savetime,0,1)!='+')) { $savetime = '+'.$savetime;}
Expand Down Expand Up @@ -395,37 +395,37 @@ function globalsettingsdisplay()
$editsurvey .= ">".$clang->gT("No")."</option>\n"
. "\t\t</select></li>\n";

$thisforcehttps = getGlobalSetting('forcehttps');
$opt_forcehttps_on = $opt_forcehttps_off = $opt_forcehttps_neither = '';
$warning_forcehttps = $clang->gT('Warning: Before turning on HTTPS, ')
$thisforce_ssl = getGlobalSetting('force_ssl');
$opt_force_ssl_on = $opt_force_ssl_off = $opt_force_ssl_neither = '';
$warning_force_ssl = $clang->gT('Warning: Before turning on HTTPS, ')
. '<a href="https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'"title="'
. $clang->gT('Test if your server has SSL enabled by clicking on this link.').'">'
. $clang->gT('check if this link works.').'</a><br/> '
. $clang->gT("If the link does not work and you turn on HTTPS, LimeSurvey will break and you won't be able to access it.");
// $warning_forcehttps = ' Do <strong>NOT</strong> force "On" if you\'re <strong>not completely certain</strong> your server has a SSL enabled. <br />'
// $warning_force_ssl = ' Do <strong>NOT</strong> force "On" if you\'re <strong>not completely certain</strong> your server has a SSL enabled. <br />'
// . 'Before turning on HTTPS, <a href="https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'">See if this link works</a><br />'
// . 'If not, <strong>LimeSurvey will break</strong> if SSL is forced on but your server does not have a valid secure certificate installed and enabled.<br />';
switch($thisforcehttps)
switch($thisforce_ssl)
{
case 'on':
$warning_forcehttps = '&nbsp;';
$warning_force_ssl = '&nbsp;';
break;
case 'off':
case 'neither':
break;
default:
$thisforcehttps = 'neither';
$thisforce_ssl = 'neither';
};
$this_opt = 'opt_forcehttps_'.$thisforcehttps;
$this_opt = 'opt_force_ssl_'.$thisforce_ssl;
$$this_opt = ' selected="selected"';
$editsurvey .= '<li><label for="forcehttps">'.$clang->gT('Force HTTPS:')."</label>\n"
. "<select name=\"forcehttps\" id=\"forcehttps\">\n\t"
. '<option value="on" '.$opt_forcehttps_on.'>'.$clang->gT('On')."</option>\n\t"
. '<option value="off" '.$opt_forcehttps_off.'>'.$clang->gT('Off')."</option>\n\t"
. '<option value="neither" '.$opt_forcehttps_neither.'>'.$clang->gT('Don\'t force on or off')."</option>\n\t"
$editsurvey .= '<li><label for="force_ssl">'.$clang->gT('Force HTTPS:')."</label>\n"
. "<select name=\"force_ssl\" id=\"force_ssl\">\n\t"
. '<option value="on" '.$opt_force_ssl_on.'>'.$clang->gT('On')."</option>\n\t"
. '<option value="off" '.$opt_force_ssl_off.'>'.$clang->gT('Off')."</option>\n\t"
. '<option value="neither" '.$opt_force_ssl_neither.'>'.$clang->gT('Don\'t force on or off')."</option>\n\t"
. "</select></li>\n"
. "<li><span style='font-size:0.7em;'>$warning_forcehttps\n</span></li>\n";
unset($thisforcehttps,$opt_forcehttps_on,$opt_forcehttps_off,$opt_forcehttps_neither,$warning_forcehttps,$this_opt);
. "<li><span style='font-size:0.7em;'>$warning_force_ssl\n</span></li>\n";
unset($thisforce_ssl,$opt_force_ssl_on,$opt_force_ssl_off,$opt_force_ssl_neither,$warning_force_ssl,$this_opt);


$editsurvey .= "\t</ul></div>\n";
Expand Down
14 changes: 7 additions & 7 deletions common_functions.php
Expand Up @@ -7757,8 +7757,8 @@ function redirect($ssl_mode)
};

/**
* SSL_mode() $forcehttps is on or off, it checks if the current
* request is to HTTPS (or not). If $forcehttps is on, and the
* SSL_mode() $force_ssl is on or off, it checks if the current
* request is to HTTPS (or not). If $force_ssl is on, and the
* request is not to HTTPS, it redirects the request to the HTTPS
* version of the URL, if the request is to HTTPS, it rewrites all
* the URL variables so they also point to HTTPS.
Expand All @@ -7772,19 +7772,19 @@ function SSL_mode()
$https = isset($_SERVER['HTTPS'])?$_SERVER['HTTPS']:'';
if($https_emergency_override !== true )
{
$forcehttps = strtolower(getGlobalSetting('forcehttps'));
$force_ssl = strtolower(getGlobalSetting('force_ssl'));
}
else
{
$forcehttps = 'off';
$force_ssl = 'off';
};
if( $forcehttps == 'on' && $https != 'on' )
if( $force_ssl == 'on' && $https == '' )
{
redirect('s');
}
if( $forcehttps == 'off' && $https == 'on')
if( $force_ssl == 'off' && $https != '')
{
redirect();
redirect('');
};
};

Expand Down
4 changes: 2 additions & 2 deletions config-defaults.php
Expand Up @@ -455,7 +455,7 @@


/**
* @var $forcehttps string - forces LimeSurvey to run through HTTPS or to block HTTPS
* @var $force_ssl string - forces LimeSurvey to run through HTTPS or to block HTTPS
* 'on' = force SSL/HTTPS to be on (This will cause LimeSurvey
* to fail in SSL is turned off)
* 'off' = block SSL/HTTPS (this prevents LimeSurvey from
Expand All @@ -470,7 +470,7 @@
* If LimeSurvey comes up as normal, then everything is fine. If you
* get a page not found error or permission denied error then
*/
$forcehttps = ''; // DO not turn on unless you are sure your server supports SSL/HTTPS
$force_ssl = ''; // DO not turn on unless you are sure your server supports SSL/HTTPS


/**
Expand Down

0 comments on commit c85fc12

Please sign in to comment.