Skip to content

Commit

Permalink
Put security question in for registration form.
Browse files Browse the repository at this point in the history
Fixed language support for registration form.

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/phpsurveyor@2476 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
David Olivier committed Mar 1, 2007
1 parent 896aae5 commit 8758df8
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 13 deletions.
6 changes: 5 additions & 1 deletion common.php
Expand Up @@ -1929,7 +1929,6 @@ function templatereplace($line)
. "<tr><td></td><td><input type='submit' value='".$clang->gT("Load Now")."'></td></tr></table>\n";
$line=str_replace("{LOADFORM}", $loadform, $line);
}

//REGISTER SURVEY DETAILS
if (strpos($line, "{REGISTERERROR}") !== false) $line=str_replace("{REGISTERERROR}", $register_errormsg, $line);
if (strpos($line, "{REGISTERMESSAGE1}") !== false) $line=str_replace("{REGISTERMESSAGE1}", $clang->gT("You must be registered to complete this survey"), $line);
Expand Down Expand Up @@ -1961,6 +1960,11 @@ function templatereplace($line)
$registerform .= " value='".returnglobal('register_email')."'";
}
$registerform .= " /></td></tr>\n";
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='images/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(isset($thissurvey['attribute1']) && $thissurvey['attribute1'])
{
$registerform .= "<tr><td align='right'>".$thissurvey['attribute1'].":</td>\n"
Expand Down
17 changes: 10 additions & 7 deletions index.php
Expand Up @@ -60,7 +60,6 @@
{
$_GET['lang'] = preg_replace("/[^a-zA-Z0-9_]/", "", $_GET['lang']);
if ($_GET['lang']) $clang = SetSurveyLanguage( $surveyid, $_GET['lang']);

}
else
if (isset($_SESSION['s_lang']))
Expand Down Expand Up @@ -1611,12 +1610,16 @@ function UpdateFieldArray()
{
global $surveyid;

reset($_SESSION['fieldarray']);
while ( list($key) = each($_SESSION['fieldarray']) ) {
$questionarray =& $myArray[$key];
$questionarray[2]=$row['title'];
$questionarray[3]=$row['question'];
unset($questionarray);
if (isset($_SESSION['fieldarray']))
{
reset($_SESSION['fieldarray']);
while ( list($key) = each($_SESSION['fieldarray']) )
{
$questionarray =& $myArray[$key];
$questionarray[2]=$row['title'];
$questionarray[3]=$row['question'];
unset($questionarray);
}
}

// This seems to only work in PHP 5 because of the referenced (&) array in the foreach construct
Expand Down
32 changes: 27 additions & 5 deletions register.php
Expand Up @@ -35,6 +35,7 @@
*/
//THESE WILL BEMOVED INTO THE LANGUAGE FILE ONCE COMPLETED
require_once(dirname(__FILE__).'/config.php');
require_once($rootdir.'/classes/core/language.php');

$surveyid=returnglobal('sid');

Expand All @@ -48,16 +49,37 @@
include "index.php";
exit;
}

session_start();
$thissurvey=getSurveyInfo($surveyid);
GetBaseLanguageFromSurveyID($surveyid);

// Get passed language from form, so that we dont loose this!
if (!isset($_POST['lang']) || $_POST['lang'] == "")
{
$baselang = GetBaseLanguageFromSurveyID($surveyid);
$clang = new phpsurveyor_lang($baselang);
} else {
$clang = new phpsurveyor_lang($_POST['lang']);
}


$register_errormsg = "";

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

//Check that the email is a valid style address
if (!validate_email(returnglobal('register_email')))
{
$register_errormsg=$clang->gT("The email you used is not valid. Please try again.");
include "index.php";
exit;
$register_errormsg .= $clang->gT("The email you used is not valid. Please try again.");
}

if ($register_errormsg != "")
{
include "index.php";
exit;
}

//Check if this email already exists in token database
Expand Down

0 comments on commit 8758df8

Please sign in to comment.