diff --git a/common.php b/common.php
index 2a1c590ce85..bf1814688b1 100644
--- a/common.php
+++ b/common.php
@@ -4303,46 +4303,10 @@ function FlattenText($texttoflatten)
{
$nicetext = strip_javascript($texttoflatten);
$nicetext = strip_tags($nicetext);
- $nicetext = str_replace("\r", "", $nicetext);
- $nicetext = trim(str_replace("\n", "", $nicetext));
+ $nicetext = str_replace(array("\n","\r"),array('',''), $nicetext);
+ $nicetext = trim($nicetext);
return $nicetext;
}
-/**
-* getreferringurl() returns the reffering URL
-*/
-function getreferringurl()
-{
- global $clang,$stripQueryFromRefurl;
- if (isset($_SESSION['refurl']))
- {
- return; // do not overwrite refurl
- }
-
- // refurl is not set in session, read it from server variable
- if(isset($_SERVER["HTTP_REFERER"]))
- {
- if(!preg_match('/'.$_SERVER["SERVER_NAME"].'/', $_SERVER["HTTP_REFERER"]))
- {
- if (!isset($stripQueryFromRefurl) || !$stripQueryFromRefurl)
- {
- $_SESSION['refurl'] = $_SERVER["HTTP_REFERER"];
- }
- else
- {
- $aRefurl = explode("?",$_SERVER["HTTP_REFERER"]);
- $_SESSION['refurl'] = $aRefurl[0];
- }
- }
- else
- {
- $_SESSION['refurl'] = '-';
- }
- }
- else
- {
- $_SESSION['refurl'] = null;
- }
-}
function getRandomID()
{ // Create a random survey ID - based on code from Ken Lyle
diff --git a/index.php b/index.php
index 6c00f7bdfe3..819cbf3db0e 100644
--- a/index.php
+++ b/index.php
@@ -701,7 +701,7 @@
}
//Check to see if a refering URL has been captured.
-getreferringurl();
+GetReferringUrl();
// Let's do this only if
// - a saved answer record hasn't been loaded through the saved feature
// - the survey is not anonymous
@@ -1653,7 +1653,7 @@ function sendsubmitnotification($sendnotification)
if ($prevquestion!=$qaarray[0])
{
$prevquestion=$qaarray[0];
- $questiontitle=strip_tags(html_entity_decode($prevquestion, ENT_QUOTES, $emailcharset));
+ $questiontitle=FlattenText(html_entity_decode($prevquestion, ENT_QUOTES, $emailcharset));
$results .= "\n$questiontitle: ";
if ($qaarray[1]!='')
{
@@ -1662,7 +1662,7 @@ function sendsubmitnotification($sendnotification)
}
if ($qaarray[1]!='')
{
- $answeroption=strip_tags(html_entity_decode($qaarray[1], ENT_QUOTES, $emailcharset));
+ $answeroption=FlattenText(html_entity_decode($qaarray[1], ENT_QUOTES, $emailcharset));
$results .= "[$answeroption]: ";
}
$details = arraySearchByKey($value, createFieldMap($surveyid),"fieldname", 1);
@@ -1673,14 +1673,14 @@ function sendsubmitnotification($sendnotification)
{
foreach (explode("\n",getextendedanswer($value,$_SESSION[$value])) as $line)
{
- $results .= "\t" . strip_tags(html_entity_decode($line, ENT_QUOTES, $emailcharset));
+ $results .= "\t" . FlattenText(html_entity_decode($line, ENT_QUOTES, $emailcharset));
$results .= "\n";
}
}
}
elseif (isset($_SESSION[$value]))
{
- $results .= strip_tags(html_entity_decode(getextendedanswer($value, $_SESSION[$value]),ENT_QUOTES, $emailcharset));
+ $results .= FlattenText(html_entity_decode(getextendedanswer($value, $_SESSION[$value]),ENT_QUOTES, $emailcharset));
$results .= "\n";
}
}
@@ -1720,7 +1720,7 @@ function sendsubmitnotification($sendnotification)
if(!SendEmailMessage($ertmessage, $ertsubject, $ert, $from, $sitename, false, getBounceEmail($surveyid)))
{
if ($debug>0) {echo '
Email could not be sent to EmailReponseTo field. Reason: '.$maildebug.'
';}
-}
+ }
}
}
}
@@ -2962,43 +2962,77 @@ function check_quota($checkaction,$surveyid)
}
-
- function encodeEmail($mail, $text="", $class="", $params=array())
- {
- $encmail ="";
- for($i=0; $i$val)
- {
- if($querystring){
- $querystring .= "&$key=".rawurlencode($val);
- } else {
- $querystring = "?$key=".rawurlencode($val);
- }
- }
- return "$text"; */
- return $text;
+ if(!$text)
+ {
+ $text = $encmail;
}
+ return $text;
+}
+
-?>
+/**
+* GetReferringUrl() returns the reffering URL
+*/
+function GetReferringUrl()
+{
+ global $clang,$stripQueryFromRefurl;
+ if (isset($_SESSION['refurl']))
+ {
+ return; // do not overwrite refurl
+ }
+
+ // refurl is not set in session, read it from server variable
+ if(isset($_SERVER["HTTP_REFERER"]))
+ {
+ if(!preg_match('/'.$_SERVER["SERVER_NAME"].'/', $_SERVER["HTTP_REFERER"]))
+ {
+ if (!isset($stripQueryFromRefurl) || !$stripQueryFromRefurl)
+ {
+ $_SESSION['refurl'] = $_SERVER["HTTP_REFERER"];
+ }
+ else
+ {
+ $aRefurl = explode("?",$_SERVER["HTTP_REFERER"]);
+ $_SESSION['refurl'] = $aRefurl[0];
+ }
+ }
+ else
+ {
+ $_SESSION['refurl'] = '-';
+ }
+ }
+ else
+ {
+ $_SESSION['refurl'] = null;
+ }
+}
+
+// Closing PHP tag intentionally left out - yes, it is okay
\ No newline at end of file