diff --git a/admin/browse.php b/admin/browse.php index 5f231b365de..744a3ace3ac 100644 --- a/admin/browse.php +++ b/admin/browse.php @@ -124,7 +124,7 @@ { //SHOW HEADER echo "\t"._BROWSERESPONSES.": $surveyname\n"; - if (!$_POST['sql']) {echo "$surveyoptions";} // Don't show options if coming from tokens script + if (!isset($_POST['sql']) || !$_POST['sql']) {echo "$surveyoptions";} // Don't show options if coming from tokens script echo "\n" ."
\n"; @@ -196,7 +196,7 @@ $nfncount = count($fnames)-1; //SHOW INDIVIDUAL RECORD $idquery = "SELECT * FROM $surveytable WHERE "; - if ($_POST['sql']) + if (isset($_POST['sql']) && $_POST['sql']) { if (get_magic_quotes_gpc) {$idquery .= stripslashes($_POST['sql']);} else {$idquery .= "{$_POST['sql']}";} @@ -246,7 +246,7 @@ ."\n" ."\t\n" ."\t\t\n" ."\t\n" ."
\n"; - if ($_POST['sql']) {echo "\t\t\t\n";} + if (isset($_POST['sql']) && $_POST['sql']) {echo "\t\t\t\n";} echo "\t\t
\n"; diff --git a/admin/statistics.php b/admin/statistics.php index c3f19257140..efb80935455 100644 --- a/admin/statistics.php +++ b/admin/statistics.php @@ -80,6 +80,7 @@ $filters[]=array("$row[0]", "$row[1]", "$row[2]", "$row[3]", "$row[4]", strip_tags($row[5]), $row[6]); } // 2: Get answers for each question +if (!isset($currentgroup)) {$currentgroup="";} foreach ($filters as $flt) { if ($flt[1] != $currentgroup) @@ -96,7 +97,7 @@ $counter=0; } //echo $flt[2]; //debugging line - if ($counter == 4) {echo "\t\t\t\t\n\t\t\t\t"; $counter=0;} + if (isset($counter) && $counter == 4) {echo "\t\t\t\t\n\t\t\t\t"; $counter=0;} $myfield = "{$sid}X{$flt[1]}X{$flt[0]}"; $niceqtext = str_replace("\"", "`", $flt[5]); $niceqtext = str_replace("'", "`", $niceqtext); @@ -110,7 +111,7 @@ if ($flt[2] == "M" || $flt[2] == "P" || $flt[2] == "R") {$myfield = "M$myfield";} if ($flt[2] == "N") {$myfield = "N$myfield";} echo " " ."\"".str_replace("\""," ."
\n"; @@ -131,7 +132,9 @@ ." \"".str_replace("\""," ."
\n" ."\t\t\t\t\tResponses containing:
\n" - ."\t\t\t\t\t"; + ."\t\t\t\t\t"; $allfields[]=$myfield2; break; case "S": // Short free text @@ -140,51 +143,64 @@ ." \"".str_replace("\""," ."
\n" ."\t\t\t\t\tResponses containing:
\n" - ."\t\t\t\t\t"; + ."\t\t\t\t\t"; $allfields[]=$myfield2; break; case "N": // Numerical $myfield2="{$myfield}G"; $myfield3="{$myfield}L"; echo "\t\t\t\t\tNumber greater than:
\n" - ."\t\t\t\t\t
\n" + ."\t\t\t\t\t
\n" ."\t\t\t\t\tNumber less than:
\n" - ."\t\t\t\t\t
\n"; + ."\t\t\t\t\t
\n"; break; case "D": // Date $myfield2="D$myfield"; $myfield3="$myfield2="; $myfield4="$myfield2<"; $myfield5="$myfield2>"; echo "\t\t\t\t$setfont$flt[3]" - ." \"".str_replace("\""," + ." \"".str_replace("\""," ."
\n" ."\t\t\t\t\tDate (YYYY-MM-DD) equals:
\n" - ."\t\t\t\t\t
\n" + ."\t\t\t\t\t
\n" ."\t\t\t\t\t  OR between:
\n" - ."\t\t\t\t\t & \n"; + ."\t\t\t\t\t & \n"; break; case "5": // 5 point choice for ($i=1; $i<=5; $i++) { echo "\t\t\t\t\t\n"; } break; case "G": // Gender echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\n"; break; case "Y": // Yes\No echo "\t\t\t\t\t\n" ."\t\t\t\t\t\n"; break; // ARRAYS @@ -196,12 +212,14 @@ while ($row=mysql_fetch_row($result)) { $myfield2 = $myfield."$row[0]"; - echo "\n"; + echo "\n"; if ($counter2 == 4) {echo "\t\t\t\t\n\t\t\t\t\n"; $counter2=0;} echo "\t\t\t\t$setfont$flt[3] ($row[0])" ." " ."\"".str_replace("\""," ."
\n" @@ -209,7 +227,7 @@ for ($i=1; $i<=5; $i++) { echo "\t\t\t\t\t\n"; } @@ -228,21 +246,25 @@ while ($row=mysql_fetch_row($result)) { $myfield2 = $myfield . "$row[0]"; - echo "\n"; + echo "\n"; if ($counter2 == 4) {echo "\t\t\t\t\n\t\t\t\t\n"; $counter2=0;} echo "\t\t\t\t$setfont$flt[3] ($row[0])"; //heading echo " " - ."\"".str_replace("\""," + ."\"".str_replace("\""," ."
\n" ."\t\t\t\t\n\t\t\t\t\n"; @@ -260,23 +282,25 @@ while ($row=mysql_fetch_row($result)) { $myfield2 = $myfield . "$row[0]"; - echo "\n"; + echo "\n"; if ($counter2 == 4) {echo "\t\t\t\t\n\t\t\t\t\n"; $counter2=0;} echo "\t\t\t\t$setfont$flt[3] ($row[0])" ." " ."\"".str_replace("\""," ."
\n" ."\t\t\t\t\n\t\t\t\t\n"; $counter2++; @@ -293,23 +317,25 @@ while ($row=mysql_fetch_row($result)) { $myfield2 = $myfield . "$row[0]"; - echo "\n"; + echo "\n"; if ($counter2 == 4) {echo "\t\t\t\t\n\t\t\t\t\n"; $counter2=0;} echo "\t\t\t\t$setfont$flt[3] ($row[0])" ." " ."\"".str_replace("\""," ."
\n" ."\t\t\t\t\n\t\t\t\t\n"; $counter2++; @@ -326,11 +352,13 @@ while ($row=mysql_fetch_row($result)) { $myfield2 = $myfield . "$row[0]"; - echo "\n"; + echo "\n"; if ($counter2 == 4) {echo "\t\t\t\t\n\t\t\t\t\n"; $counter2=0;} echo "\t\t\t\t$setfont$flt[3] ($row[0])" ." " ."\"".str_replace("\""," ."
\n"; @@ -341,7 +369,7 @@ while ($frow = mysql_fetch_array($fresult)) { echo "\t\t\t\t\t\n"; } echo "\t\t\t\t\n\t\t\t\t\n"; @@ -366,10 +394,12 @@ if ($counter2 == 4) {echo "\t\t\t\t\n\t\t\t\t\n"; $counter=0;} $myfield2 = "R" . $myfield . $i . "-" . strlen($i); $myfield3 = $myfield . $i; - echo "\n" + echo "\n" ."\t\t\t\t$setfont$flt[3] ($i)" ." " ."\"".str_replace("\""," ."
\n" @@ -377,7 +407,7 @@ foreach ($answers as $ans) { echo "\t\t\t\t\t\n"; } echo "\t\t\t\t\n\t\t\t\t\n"; @@ -393,7 +423,7 @@ while ($row=mysql_fetch_row($result)) { echo "\t\t\t\t\t\t\n"; } break; @@ -403,6 +433,7 @@ echo "\n\t\t\t\t\n"; } $currentgroup=$flt[1]; + if (!isset($counter)) {$counter=0;} $counter++; } echo "\n\t\t\t\t\n"; @@ -416,7 +447,7 @@ ."\t\t\n" ."\t\t \n" ."\t\t\t\t$setfontView summary of all available fields\n" ."\t\t\n\t\t\t
\n" ."\t\t\t\n" @@ -431,7 +462,7 @@ // DISPLAY RESULTS -if ($_POST['display']) +if (isset($_POST['display']) && $_POST['display']) { // 1: Get list of questions with answers chosen for (reset($_POST); $key=key($_POST); next($_POST)) { $postvars[]=$key;} // creates array of post variable names @@ -508,7 +539,7 @@ $query = "SELECT count(*) FROM {$dbprefix}survey_$sid"; $result = mysql_query($query) or die ("Couldn't get total
$query
".mysql_error()); while ($row=mysql_fetch_row($result)) {$total=$row[0];} - if ($selects) + if (isset($selects) && $selects) { $query .= " WHERE "; $query .= implode(" AND ", $selects); @@ -531,8 +562,8 @@ echo "\n\t\t
\n" ."\t\tSQL: $query\n" ."\t\n"; - if ($selects) {$sql=implode(" AND ", $selects);} - if (!$sql) {$sql="NULL";} + if (isset ($selects) && $selects) {$sql=implode(" AND ", $selects);} + if (!isset($sql) || !$sql) {$sql="NULL";} if ($results > 0) { echo "\t" @@ -551,7 +582,7 @@ echo "\n"; } -if ($_POST['summary']) +if (isset($_POST['summary']) && $_POST['summary']) { $pipepos=strpos($_POST['summary'], "|"); if ($pipepos == 0) {$runthrough[]=$_POST['summary'];} @@ -879,7 +910,7 @@ //foreach ($fvalues as $fv) {echo "$fv | ";} //debugging line //2. Display results - if ($alist) //JUST IN CASE SOMETHING GOES WRONG + if (isset($alist) && $alist) //JUST IN CASE SOMETHING GOES WRONG { echo "
\n\n" ."\t\n"; foreach ($alist as $al) { - if ($al[2]) //picks out alist that come from the multiple list above + if (isset($al[2]) && $al[2]) //picks out alist that come from the multiple list above { if ($al[1] == _OTHER) {
$setfontField Summary for $qtitle:" @@ -891,7 +922,7 @@ ."\t