Skip to content

Commit

Permalink
Fixed issue #9441: refurl does not catch external referrer url
Browse files Browse the repository at this point in the history
  • Loading branch information
Aestu authored and alfredo committed Jan 12, 2015
1 parent 20533db commit c07ce02
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
9 changes: 8 additions & 1 deletion application/helpers/expressions/em_manager_helper.php
Expand Up @@ -5209,7 +5209,14 @@ private function _UpdateValuesInDatabase($updatedValues, $finished=false)
}
if ($this->surveyOptions['refurl'] == true)
{
$sdata['refurl'] = getenv("HTTP_REFERER");
if (isset($_SESSION[$this->sessid]['refurl']))
{
$sdata['refurl'] = $_SESSION[$this->sessid]['refurl'];
}
else
{
$sdata['refurl'] = getenv("HTTP_REFERER");
}
}

$sdata = array_filter($sdata);
Expand Down
16 changes: 5 additions & 11 deletions application/helpers/frontend_helper.php
Expand Up @@ -78,6 +78,7 @@ function loadanswers()
$_SESSION['survey_'.$surveyid]['step'] = ($oSavedSurvey->saved_thisstep>1)?$oSavedSurvey->saved_thisstep:1;
$thisstep=$_SESSION['survey_'.$surveyid]['step']-1;// deprecated ?
$_SESSION['survey_'.$surveyid]['srid'] = $oSavedSurvey->srid;// Seems OK without
$_SESSION['survey_'.$surveyid]['refurl'] = $oSavedSurvey->refurl;
}

// Get if survey is been answered
Expand Down Expand Up @@ -2097,21 +2098,14 @@ function GetReferringUrl()
// read it from server variable
if(isset($_SERVER["HTTP_REFERER"]))
{
if(!preg_match('/'.$_SERVER["SERVER_NAME"].'/', $_SERVER["HTTP_REFERER"]))
if (!Yii::app()->getConfig('strip_query_from_referer_url'))
{
if (!Yii::app()->getConfig('strip_query_from_referer_url'))
{
return $_SERVER["HTTP_REFERER"];
}
else
{
$aRefurl = explode("?",$_SERVER["HTTP_REFERER"]);
return $aRefurl[0];
}
return $_SERVER["HTTP_REFERER"];
}
else
{
return '-';
$aRefurl = explode("?",$_SERVER["HTTP_REFERER"]);
return $aRefurl[0];
}
}
else
Expand Down
11 changes: 9 additions & 2 deletions application/libraries/Save.php
Expand Up @@ -151,7 +151,7 @@ function savedcontrol()
"datestamp" => $today,
"ipaddr" => getIPAddress(),
"startlanguage" => $_SESSION['survey_'.$surveyid]['s_lang'],
"refurl" => getenv("HTTP_REFERER")
"refurl" => ((isset($_SESSION['survey_'.$surveyid]['refurl'])) ? $_SESSION['survey_'.$surveyid]['refurl'] : getenv('HTTP_REFERER'))
);
if (SurveyDynamic::model($thissurvey['sid'])->insert($sdata)) // Checked
{
Expand All @@ -175,7 +175,14 @@ function savedcontrol()
$saved_control->saved_thisstep = $thisstep;
$saved_control->status = 'S';
$saved_control->saved_date = $today;
$saved_control->refurl = getenv('HTTP_REFERER');
if (isset($_SESSION['survey_'.$surveyid]['refurl']))
{
$saved_control->refurl = $_SESSION['survey_'.$surveyid]['refurl'];
}
else
{
$saved_control->refurl = getenv("HTTP_REFERER");
}

if ($saved_control->save())
{
Expand Down

0 comments on commit c07ce02

Please sign in to comment.