Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Even more code cleaning
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/trunk/unstable@790 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
jcleeland committed Nov 25, 2003
1 parent 6491b6e commit 6729dbc
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 50 deletions.
21 changes: 14 additions & 7 deletions group.php
Expand Up @@ -47,7 +47,7 @@
$postedfieldnames=explode("|", $_POST['fieldnames']);
foreach ($postedfieldnames as $pf)
{
$_SESSION[$pf] = $_POST[$pf];
if (isset($_POST[$pf])) {$_SESSION[$pf] = $_POST[$pf];}
}
}

Expand Down Expand Up @@ -84,7 +84,7 @@
if ($_SESSION[$cm] == "0" || $_SESSION[$cm])
{
}
elseif (!$_POST[$multiname])
elseif (!isset($_POST[$multiname]) || !$_POST[$multiname])
{
//One of the mandatory questions hasn't been answered
if ($_POST['move'] == " << "._PREV." ") {$_SESSION['step'] = $_POST['thisstep'];}
Expand Down Expand Up @@ -193,20 +193,27 @@
if (!isset($col_name)) {$col_name="";}
if (!isset($values)) {$values="";}
$col_name .= "`, `" . $value;
if (get_magic_quotes_gpc() == "0")
if (isset($_SESSION[$value]))
{
if (phpversion() >= "4.3.0")
if (get_magic_quotes_gpc() == "0")
{
$values .= ", '" . mysql_real_escape_string($_SESSION[$value]) . "'";
if (phpversion() >= "4.3.0")
{
$values .= ", '" . mysql_real_escape_string($_SESSION[$value]) . "'";
}
else
{
$values .= ", '" . mysql_escape_string($_SESSION[$value]) . "'";
}
}
else
{
$values .= ", '" . mysql_escape_string($_SESSION[$value]) . "'";
$values .= ", '" . $_SESSION[$value] . "'";
}
}
else
{
$values .= ", '" . $_SESSION[$value] . "'";
$values .= ", ''";
}
}
$col_name .= "`";
Expand Down
10 changes: 6 additions & 4 deletions qanda.php
Expand Up @@ -972,23 +972,25 @@
while ($ansrow = mysql_fetch_array($ansresult))
{
$myfname = $ia[1].$ansrow['code'];
if ($trbc == "array1" || !$trbc) {$trbc = "array2";} else {$trbc = "array1";}
if (isset($trbc) && ($trbc == "array1" || !$trbc) || !isset($trbc)) {$trbc = "array2";} else {$trbc = "array1";}
$answer .= "\t\t\t\t<tr class='$trbc'>\n"
. "\t\t\t\t\t<td align='right' width='$percwidth%'>{$ansrow['answer']}</td>\n";
foreach ($labelcode as $ld)
{
$answer .= "\t\t\t\t\t<td align='center' width='$otherwidth%'><input class='radio' type='radio' name='$myfname' value='$ld'";
if ($_SESSION[$myfname] == $ld['code']) {$answer .= " checked";}
if (isset($_SESSION[$myfname]) && $_SESSION[$myfname] == $ld['code']) {$answer .= " checked";}
$answer .= " onClick='checkconditions(this.value, this.name, this.type)' /></td>\n";
}
if ($ia[6] != "Y")
{
$answer .= "\t\t\t\t\t<td align='center' width='$otherwidth%'><input class='radio' type='radio' name='$myfname' value=''";
if ($_SESSION[$myfname] == "") {$answer .= " checked";}
if (!isset($_SESSION[$myfname]) || $_SESSION[$myfname] == "") {$answer .= " checked";}
$answer .= " onClick='checkconditions(this.value, this.name, this.type)' /></td>\n";
}
$answer .= "\t\t\t\t</tr>\n"
. "\t\t\t\t<input type='hidden' name='java$myfname' id='java$myfname' value='{$_SESSION[$myfname]}'>\n";
. "\t\t\t\t<input type='hidden' name='java$myfname' id='java$myfname' value='";
if (isset($_SESSION[$myfname])) {$answer .= $_SESSION[$myfname];}
$answer .= "'>\n";
$inputnames[]=$myfname;
$fn++;
if ($ia[6] == "Y" && $ia[7] != "Y") //Question is mandatory. Add to mandatory array
Expand Down
68 changes: 38 additions & 30 deletions question.php
Expand Up @@ -48,48 +48,49 @@
$postedfieldnames=explode("|", $_POST['fieldnames']);
foreach ($postedfieldnames as $pf)
{
$_SESSION[$pf] = $_POST[$pf];
if (isset($_POST[$pf])) {$_SESSION[$pf] = $_POST[$pf];}
}
}

//CHECK IF ALL MANDATORY QUESTIONS HAVE BEEN ANSWERED
if (isset($_POST['move']) && $allowmandatorybackwards==1 && $_POST['move'] == " << "._PREV." ") {$backok="Y";}
if (isset($_POST['mandatory']) && $_POST['mandatory'] && $backok != "Y")
if (isset($_POST['mandatory']) && $_POST['mandatory'] && (!isset($backok) || $backok != "Y"))
{
$chkmands=explode("|", $_POST['mandatory']);
$mfns=explode("|", $_POST['mandatoryfn']);
$mi=0;
foreach ($chkmands as $cm)
{
if ($multiname != "MULTI$mfns[$mi]") //multiname has not been set, or is different from the last one
if (!isset($multiname) || $multiname != "MULTI$mfns[$mi]") //multiname has not been set, or is different from the last one
{
if ($multiname && $_POST[$multiname]) //This isn't the first time (multiname exists, and is a posted variable)
if ((isset($multiname) && $multiname) && (isset($_POST[$multiname]) && $_POST[$multiname])) //This isn't the first time (multiname exists, and is a posted variable)
{
if ($$multiname == $$multiname2) //The number of questions not answered is equal to the number of questions
{
//The number of questions not answered is equal to the number of questions
if ($_POST['move'] == " << "._PREV." ") {$_SESSION['step'] = $_POST['thisstep'];}
if ($_POST['move'] == " "._NEXT." >> ") {$_SESSION['step'] = $_POST['thisstep'];}
if ($_POST['move'] == " "._LAST." ") {$_SESSION['step'] = $_POST['thisstep']; $_POST['move'] == " "._NEXT." >> ";}
if (isset($_POST['move']) && $_POST['move'] == " << "._PREV." ") {$_SESSION['step'] = $_POST['thisstep'];}
if (isset($_POST['move']) && $_POST['move'] == " "._NEXT." >> ") {$_SESSION['step'] = $_POST['thisstep'];}
if (isset($_POST['move']) && $_POST['move'] == " "._LAST." ") {$_SESSION['step'] = $_POST['thisstep']; $_POST['move'] == " "._NEXT." >> ";}
$notanswered[]=substr($multiname, 5, strlen($multiname));
$$multiname=0;
$$multiname2=0;
}
}
$multiname="MULTI$mfns[$mi]";
$multiname2=$multiname; //POSSIBLE CORRUPTION OF PROCESS - CHECK LATER
$$multiname=0;
$$multiname2=0;
}
else {$multiname="MULTI$mfns[$mi]";}
if ($_SESSION[$cm] == "0" || $_SESSION[$cm])
{
}
elseif (!$_POST[$multiname])
elseif (!isset($_POST[$multiname]) || !$_POST[$multiname])
{
//One of the mandatory questions hasn't been asnwered
if ($_POST['move'] == " << "._PREV." ") {$_SESSION['step'] = $_POST['thisstep'];}
if ($_POST['move'] == " "._NEXT." >> ") {$_SESSION['step'] = $_POST['thisstep'];}
if ($_POST['move'] == " "._LAST." ") {$_SESSION['step'] = $_POST['thisstep']; $_POST['move'] == " "._NEXT." >> ";}
if (isset($_POST['move']) && $_POST['move'] == " << "._PREV." ") {$_SESSION['step'] = $_POST['thisstep'];}
if (isset($_POST['move']) && $_POST['move'] == " "._NEXT." >> ") {$_SESSION['step'] = $_POST['thisstep'];}
if (isset($_POST['move']) && $_POST['move'] == " "._LAST." ") {$_SESSION['step'] = $_POST['thisstep']; $_POST['move'] == " "._NEXT." >> ";}
$notanswered[]=$mfns[$mi];
}
else
Expand All @@ -100,57 +101,57 @@
$$multiname2++;
$mi++;
}
if ($multiname && $_POST[$multiname])
if ((isset($multiname) && $multiname) && (isset($_POST[$multiname]) && $_POST[$multiname]))
{
if ($$multiname == $$multiname2) //so far all multiple choice options are unanswered
{
//The number of questions not answered is equal to the number of questions
if ($_POST['move'] == " << "._PREV." ") {$_SESSION['step'] = $_POST['thisstep'];}
if ($_POST['move'] == " "._NEXT." >> ") {$_SESSION['step'] = $_POST['thisstep'];}
if ($_POST['move'] == " "._LAST." ") {$_SESSION['step'] = $_POST['thisstep']; $_POST['move'] == " "._NEXT." >> ";}
if (isset($_POST['move']) && $_POST['move'] == " << "._PREV." ") {$_SESSION['step'] = $_POST['thisstep'];}
if (isset($_POST['move']) && $_POST['move'] == " "._NEXT." >> ") {$_SESSION['step'] = $_POST['thisstep'];}
if (isset($_POST['move']) && $_POST['move'] == " "._LAST." ") {$_SESSION['step'] = $_POST['thisstep']; $_POST['move'] == " "._NEXT." >> ";}
$notanswered[]=substr($multiname, 5, strlen($multiname));
$$multiname="";
$$multiname2="";
}
}
}
if (isset($_POST['conmandatory']) && $_POST['conmandatory'] && $backok != "Y")
if (isset($_POST['conmandatory']) && $_POST['conmandatory'] && (!isset($backok) || $backok != "Y"))
{
$chkcmands=explode("|", $_POST['conmandatory']);
$cmfns=explode("|", $_POST['conmandatoryfn']);
$mi=0;
foreach ($chkcmands as $ccm)
{
$multiname="MULTI$cmfns[$mi]";
if (!$_POST[$multiname])
if (!isset($_POST[$multiname]) || !$_POST[$multiname])
{
$dccm="display$ccm";
}
else
{
$dccm="display".$cmfns[0];
}
if ($_POST[$dccm] == "on" && (!$_SESSION[$ccm] && $_SESSION[$ccm] != "0") && !$_POST[$multiname])
if ($_POST[$dccm] == "on" && (!$_SESSION[$ccm] && $_SESSION[$ccm] != "0") && (!isset($_POST[$multiname]) || !$_POST[$multiname]))
{
//One of the conditional mandatory questions was on, but hasn't been answered
if ($_POST['move'] == " << "._PREV." ") {$_SESSION['step'] = $_POST['thisstep'];}
if ($_POST['move'] == " "._NEXT." >> ") {$_SESSION['step'] = $_POST['thisstep'];}
if ($_POST['move'] == " "._LAST." ") {$_SESSION['step'] = $_POST['thisstep']; $_POST['move'] == " "._NEXT." >> ";}
if (isset($_POST['move']) && $_POST['move'] == " << "._PREV." ") {$_SESSION['step'] = $_POST['thisstep'];}
if (isset($_POST['move']) && $_POST['move'] == " "._NEXT." >> ") {$_SESSION['step'] = $_POST['thisstep'];}
if (isset($_POST['move']) && $_POST['move'] == " "._LAST." ") {$_SESSION['step'] = $_POST['thisstep']; $_POST['move'] == " "._NEXT." >> ";}
$notanswered[]=$cmfns[$mi];
}
elseif ($_POST[$dccm] == "on" && !$_SESSION[$ccm] && $_POST[$multiname])
{
$notanswered[]=$cmfns[$mi];
}
}
if ($_POST[$multiname])
if (isset($_POST[$multiname]) && $_POST[$multiname])
{
if (count($notanswered) == count($chkcmands)) //
{
//The number of questions not answered is equal to the number of questions
if ($_POST['move'] == " << "._PREV." ") {$_SESSION['step'] = $_POST['thisstep'];}
if ($_POST['move'] == " "._NEXT." >> ") {$_SESSION['step'] = $_POST['thisstep'];}
if ($_POST['move'] == " "._LAST." ") {$_SESSION['step'] = $_POST['thisstep']; $_POST['move'] == " "._NEXT." >> ";}
if (isset($_POST['move']) && $_POST['move'] == " << "._PREV." ") {$_SESSION['step'] = $_POST['thisstep'];}
if (isset($_POST['move']) && $_POST['move'] == " "._NEXT." >> ") {$_SESSION['step'] = $_POST['thisstep'];}
if (isset($_POST['move']) && $_POST['move'] == " "._LAST." ") {$_SESSION['step'] = $_POST['thisstep']; $_POST['move'] == " "._NEXT." >> ";}
}
else
{
Expand Down Expand Up @@ -178,20 +179,27 @@
foreach ($_SESSION['insertarray'] as $value)
{
$col_name .= "`, `" . $value;
if (get_magic_quotes_gpc() == "0")
if (isset($_SESSION[$value]))
{
if (phpversion() >= "4.3.0")
if (get_magic_quotes_gpc() == "0")
{
$values .= ", '" . mysql_real_escape_string($_SESSION[$value]) . "'";
if (phpversion() >= "4.3.0")
{
$values .= ", '" . mysql_real_escape_string($_SESSION[$value]) . "'";
}
else
{
$values .= ", '" . mysql_escape_string($_SESSION[$value]) . "'";
}
}
else
{
$values .= ", '" . mysql_escape_string($_SESSION[$value]) . "'";
$values .= ", '" . $_SESSION[$value] . "'";
}
}
else
{
$values .= ", '" . $_SESSION[$value] . "'";
$values .= ", ''";
}
}
$col_name .= "`";
Expand Down
26 changes: 17 additions & 9 deletions survey.php
Expand Up @@ -45,7 +45,7 @@
$postedfieldnames=explode("|", $_POST['fieldnames']);
foreach ($postedfieldnames as $pf)
{
$_SESSION[$pf] = $_POST[$pf];
if (isset($_POST[$pf])) {$_SESSION[$pf] = $_POST[$pf];}
}
}

Expand All @@ -57,9 +57,9 @@
$mi=0;
foreach ($chkmands as $cm)
{
if ($multiname != "MULTI$mfns[$mi]")
if (!isset($multiname) || $multiname != "MULTI$mfns[$mi]")
{
if ($multiname && $_POST[$multiname])
if ((isset($multiname) && $multiname) && (isset($_POST[$multiname]) && $_POST[$multiname]))
{
if ($$multiname == $$multiname2) //so far all multiple choice options are unanswered
{
Expand All @@ -73,6 +73,7 @@
}
}
$multiname="MULTI$mfns[$mi]";
$multiname2=$multiname; //POSSIBLE CORRUPTION OF PROCESS - CHECK LATER
$$multiname=0;
$$multiname2=0;
}
Expand Down Expand Up @@ -158,7 +159,7 @@
$$multiname2++;
$mi++;
}
if ($multiname && $_POST[$multiname])
if (isset($multiname) && $multiname && isset($_POST[$multiname]) && $_POST[$multiname])
{
if ($$multiname == $$multiname2) //so far all multiple choice options are unanswered
{
Expand Down Expand Up @@ -198,20 +199,27 @@
if (!isset($col_name)) {$col_name="";}
if (!isset($values)) {$values="";}
$col_name .= "`, `" . $value;
if (get_magic_quotes_gpc() == "0")
if (isset($_SESSION[$value]))
{
if (phpversion() >= "4.3.0")
if (get_magic_quotes_gpc() == "0")
{
$values .= ", '" . mysql_real_escape_string($_SESSION[$value]) . "'";
if (phpversion() >= "4.3.0")
{
$values .= ", '" . mysql_real_escape_string($_SESSION[$value]) . "'";
}
else
{
$values .= ", '" . mysql_escape_string($_SESSION[$value]) . "'";
}
}
else
{
$values .= ", '" . mysql_escape_string($_SESSION[$value]) . "'";
$values .= ", '" . $_SESSION[$value] . "'";
}
}
else
{
$values .= ", '" . $_SESSION[$value] . "'";
$values .= ", ''";
}
}
$col_name .= "`";
Expand Down

0 comments on commit 6729dbc

Please sign in to comment.