Skip to content

Commit

Permalink
Fixed bug with security question not working if gd- image library is …
Browse files Browse the repository at this point in the history
…not installed. Now that library is optional and the security question will just not show if the library is not installed.

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/phpsurveyor@2872 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed May 8, 2007
1 parent 21f5fe1 commit 484deea
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 43 deletions.
29 changes: 21 additions & 8 deletions common.php
Original file line number Diff line number Diff line change
Expand Up @@ -2029,9 +2029,12 @@ function templatereplace($line)
$saveform .= "'></td></tr>\n"
. "<tr><td align='right'>".$clang->gT("Your Email").":</td><td><input type='text' name='saveemail' value='";
if (isset($_POST['saveemail'])) {$saveform .= html_escape(auto_unescape($_POST['saveemail']));}
$saveform .= "'></td></tr>\n"
."<tr><td align='right'>".$clang->gT("Security Question").":</td><td><table><tr><td valign='center'><img src='verification.php'></td><td valign='center'><input type='text' size='5' maxlength='3' name='loadsecurity' value=''></td></tr></table></td></tr>\n"
. "<tr><td align='right'></td><td></td></tr>\n"
$saveform .= "'></td></tr>\n";
if (function_exists("ImageCreate"))
{
$saveform .="<tr><td align='right'>".$clang->gT("Security Question").":</td><td><table><tr><td valign='center'><img src='verification.php'></td><td valign='center'><input type='text' size='5' maxlength='3' name='loadsecurity' value=''></td></tr></table></td></tr>\n";
}
$saveform .= "<tr><td align='right'></td><td></td></tr>\n"
. "<tr><td></td><td><input type='submit' name='savesubmit' value='".$clang->gT("Save Now")."'></td></tr>\n"
. "</table>";
$line=str_replace("{SAVEFORM}", $saveform, $line);
Expand All @@ -2046,9 +2049,14 @@ function templatereplace($line)
$loadform .= "'></td></tr>\n"
. "<tr><td align='right'>".$clang->gT("Password").":</td><td><input type='password' name='loadpass' value='";
if (isset($_POST['loadpass'])) {$loadform .= html_escape(auto_unescape($_POST['loadpass']));}
$loadform .= "'></td></tr>\n"
. "<tr><td align='right'>".$clang->gT("Security Question").":</td><td><table><tr><td valign='center'><img src='verification.php'></td><td valign='center'><input type='text' size='5' maxlength='3' name='loadsecurity' value=''></td></tr></table></td></tr>\n"
. "<tr><td align='right'></td><td></td></tr>\n"
$loadform .= "'></td></tr>\n";
if (function_exists("ImageCreate"))
{
$loadform .="<tr><td align='right'>".$clang->gT("Security Question").":</td><td><table><tr><td valign='center'><img src='verification.php'></td><td valign='center'><input type='text' size='5' maxlength='3' name='loadsecurity' value=''></td></tr></table></td></tr>\n";
}


$loadform .="<tr><td align='right'></td><td></td></tr>\n"
. "<tr><td></td><td><input type='submit' value='".$clang->gT("Load Now")."'></td></tr></table>\n";
$line=str_replace("{LOADFORM}", $loadform, $line);
}
Expand Down Expand Up @@ -2086,8 +2094,13 @@ function templatereplace($line)
if (!isset($_GET['lang']) && !isset($_POST['lang'])) $reglang = GetBaseLanguageFromSurveyID($surveyid);
if (isset($_GET['lang'])) $reglang = $_GET['lang'];
if (isset($_POST['lang'])) $reglang = $_POST['lang'];
$registerform .= "<tr><td align='right'>".$clang->gT("Security Question").":</td><td><table><tr><td valign='center'><img src='verification.php'></td><td valign='center'><input type='text' size='5' maxlength='3' name='loadsecurity' value=''></td></tr></table></td></tr>\n"
. "<tr><td align='right'><input type='hidden' name='lang' value='".$reglang."'></td><td></td></tr>\n";

if (function_exists("ImageCreate"))
{
$registerform .="<tr><td align='right'>".$clang->gT("Security Question").":</td><td><table><tr><td valign='center'><img src='verification.php'></td><td valign='center'><input type='text' size='5' maxlength='3' name='loadsecurity' value=''></td></tr></table></td></tr>\n";
}

$registerform .= "<tr><td align='right'><input type='hidden' name='lang' value='".$reglang."'></td><td></td></tr>\n";
if(isset($thissurvey['attribute1']) && $thissurvey['attribute1'])
{
$registerform .= "<tr><td align='right'>".$thissurvey['attribute1'].":</td>\n"
Expand Down
59 changes: 30 additions & 29 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
if (!isset($token)) {$token=trim(returnglobal('token'));}

// If token was submitted from token form
if (isset($_GET['tokenSEC']) && $_GET['tokenSEC'] == 1)
if (isset($_GET['tokenSEC']) && $_GET['tokenSEC'] == 1 && function_exists("ImageCreate"))
{
if (!isset($_GET['loadsecurity']) || $_GET['loadsecurity'] != $_SESSION['secanswer'])
{
Expand Down Expand Up @@ -242,10 +242,13 @@
}

// if security question asnwer is incorrect
if ((!isset($_POST['loadsecurity']) || $_POST['loadsecurity'] != $_SESSION['secanswer']) && !isset($_GET['scid']))
{
$errormsg .= $clang->gT("The answer to the security question is incorrect")."<br />\n";
}
if (function_exists("ImageCreate"))
{
if ((!isset($_POST['loadsecurity']) || $_POST['loadsecurity'] != $_SESSION['secanswer']) && !isset($_GET['scid']))
{
$errormsg .= $clang->gT("The answer to the security question is incorrect")."<br />\n";
}
}

// Load session before loading the values from the saved data
if (isset($_GET['loadall']))
Expand Down Expand Up @@ -1077,30 +1080,28 @@ function buildsurveysession()
}
else
{
?>
<center><br />
<?php if (isset($secerror)) echo "<font color='#FF0000'>".$secerror."</font><br />"; ?>
<?php echo $clang->gT("This is a controlled survey. You need a valid token to participate.") ?><br /><br />
<?php echo $clang->gT("If you have been issued with a token, please enter it in the box below and click continue.") ?><br />&nbsp;
<form method='get' action='<?php echo $_SERVER['PHP_SELF'] ?>'>
<table align='center'>
<tr>
<td align='right' valign='middle'>
<input type='hidden' name='sid' value='<?php echo $surveyid ?>' id='sid' />
<input type='hidden' name='tokenSEC' value='1' id='sid' />
<?php echo $clang->gT("Token") ?>:</td><td align='left' valign='middle'><input class='text' type='text' name='token'>
</td>
</tr>
<tr>
<td align='center' valign='middle'>
<?php echo $clang->gT("Security Question"); ?>:</td><td align='left' valign='middle'><table><tr><td valign='center'><img src='verification.php'></td><td valign='center'><input type='text' size='5' maxlength='3' name='loadsecurity' value=''></td></tr></table>
</td>
</tr>
<tr><td colspan="2" align="center"><input class='submit' type='submit' value='<?php echo $clang->gT("Continue") ?>' /></td></tr>
</table>
</form>
<br />&nbsp;</center>
<?php
echo " <center><br />";
if (isset($secerror)) echo "<font color='#FF0000'>".$secerror."</font><br />";
echo $clang->gT("This is a controlled survey. You need a valid token to participate.")."<br /><br />";
echo $clang->gT("If you have been issued with a token, please enter it in the box below and click continue.")."<br />&nbsp;
<form method='get' action='".$_SERVER['PHP_SELF']."'>
<table align='center'>
<tr>
<td align='right' valign='middle'>
<input type='hidden' name='sid' value='".$surveyid."' id='sid' />
<input type='hidden' name='tokenSEC' value='1' id='sid' />"
.$clang->gT("Token")."</td><td align='left' valign='middle'><input class='text' type='text' name='token'>
</td>
</tr>";
if (function_exists("ImageCreate"))
{ echo "<tr>
<td align='center' valign='middle'>".$clang->gT("Security Question")."</td><td align='left' valign='middle'><table><tr><td valign='center'><img src='verification.php'></td><td valign='center'><input type='text' size='5' maxlength='3' name='loadsecurity' value=''></td></tr></table>
</td>
</tr>";}
echo "<tr><td colspan='2' align='center'><input class='submit' type='submit' value='".$clang->gT("Continue")."' /></td></tr>
</table>
</form>
<br />&nbsp;</center>";
}

echo templatereplace(file_get_contents("$thistpl/endpage.pstpl"));
Expand Down
7 changes: 5 additions & 2 deletions register.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@
$register_errormsg = "";

// Check the security question's answer
if (!isset($_POST['loadsecurity']) || $_POST['loadsecurity'] != $_SESSION['secanswer'])
if (function_exists("ImageCreate"))
{
$register_errormsg .= $clang->gT("The answer to the security question is incorrect")."<br />\n";
if (!isset($_POST['loadsecurity']) || $_POST['loadsecurity'] != $_SESSION['secanswer'])
{
$register_errormsg .= $clang->gT("The answer to the security question is incorrect")."<br />\n";
}
}

//Check that the email is a valid style address
Expand Down
11 changes: 7 additions & 4 deletions save.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,13 @@ function savedcontrol()
if ((isset($_POST['savepass']) && !isset($_POST['savepass2'])) || $_POST['savepass'] != $_POST['savepass2'])
{$errormsg.=$clang->gT("Your passwords do not match.")."<br />\n";}
// if security question asnwer is incorrect
if (!isset($_POST['loadsecurity']) || $_POST['loadsecurity'] != $_SESSION['secanswer'])
{
$errormsg .= $clang->gT("The answer to the security question is incorrect")."<br />\n";
}
if (function_exists("ImageCreate"))
{
if (!isset($_POST['loadsecurity']) || $_POST['loadsecurity'] != $_SESSION['secanswer'])
{
$errormsg .= $clang->gT("The answer to the security question is incorrect")."<br />\n";
}
}

if ($errormsg)
{
Expand Down
1 change: 1 addition & 0 deletions verification.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

// make sure you include this file only if the ImageCreate function does exist since it is an optional library
// Lets get into the session
session_start();

Expand Down

0 comments on commit 484deea

Please sign in to comment.