$helper->addFormGroup('captcha_code', "Unser Spiel ist durch ein grafisches CAPTCHA gesichert. Du musst den angezeigten Code wiederholen, damit du unser Spiel nutzen kannst.");
$helper->addFieldText('captcha_code', "Bitte wiederhole den Code:");
$helper->addInputTextField('captcha_code');
+$helper->addInputHiddenField('captcha_hash', $this->readVariable('captcha_hash'));
$helper->flushContent();
// [EOF]
// Get crypto instance
$cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
+ // Hash the CAPTCHA code for later comparison
+ $this->hashedString = $cryptoInstance->hashString($captchaString);
+
// Encrypt the string for later usage
$this->encryptedString = $cryptoInstance->encryptString($captchaString);
-
- // Hash the encrypted string for later comparison
- $this->hashedString = $cryptoInstance->hashString($this->encryptedString);
}
/**
// Load a template for this CAPTCHA
$this->getTemplateInstance()->loadCodeTemplate("captch_graphic_code");
- // Assign variable
+ // Assign variables
$this->getTemplateInstance()->assignVariable('encrypted_code', urlencode(base64_encode($this->encryptedString)));
+ $this->getTemplateInstance()->assignVariable('captcha_hash', $this->hashedString);
// Compile the template
$this->getTemplateInstance()->compileTemplate();
* @param $var The variable we are looking for
* @param $value The value we want to store in the variable
* @return void
+ * @throws EmptyVariableException If the variable name is left empty
*/
public final function assignVariable ($var, $value) {
+ // Trim spaces of variable name
+ $var = trim($var);
+
+ // Empty variable found?
+ if (empty($var)) {
+ // Throw an exception
+ throw new EmptyVariableException(array($this, 'var'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ } // END - if
+
// First search for the variable if it was already added
$idx = $this->isVariableAlreadySet($var);
// Was it found?
if ($idx === false) {
// Add it to the stack
+ //* DEBUG: */ echo "ADD: ".$var."<br />\n";
$this->addVariable($var, $value);
} elseif (!empty($value)) {
// Modify the stack entry
+ //* DEBUG: */ echo "MOD: ".$var."<br />\n";
$this->modifyVariable($var, $value);
}
}
if ((is_array($variableMatches)) && (count($variableMatches) == 4) && (count($variableMatches[0]) > 0)) {
// Initialize all missing variables
foreach ($variableMatches[3] as $key=>$var) {
- // Try to assign it, empty strings are being ignored
- $this->assignTemplateVariable($variableMatches[1][$key], $var);
+ // Variable name
+ $varName = $variableMatches[1][$key];
+
+ // Workarround: Do not assign empty variables
+ if (!empty($var)) {
+ // Try to assign it, empty strings are being ignored
+ $this->assignTemplateVariable($varName, $var);
+ } // END - if
} // END - foreach
} // END - if
}
);
// Did something change?
- if (strlen($eval) != $eval) {
+ if (strlen($eval) != $evalLength) {
// Run the constructed command. This will "compile" all variables in
@eval($eval);
} // END - if