Using com securityimages in your code
From Walter Cedric Wiki
Contents |
[edit] Usage (for developer)
Using this framework is very simple....
[edit] For securityimages version < 4.0.0
[edit] in PHP <form>
In the page your code send to the user... 3 lines only are required
1. include my library in page scope <?php include ($mosConfig_absolute_path.'/administrator/components/com_securityimages/client.php'); ?>
2. this insert the captcha generated image <?php echo insertSecurityImage("security_refid"); ?>
3. this insert the help text and an input box <?php echo getSecurityImageText("security_try"); ?>
OR this line can be, in some case replace with (depending how much space You have in the presentation HTML layer)
<?php echo getSecurityImageTextHeader(); ?> 3' will be replace at run time, depending on user locale with "Please Enter what You see:"
<?php echo getSecurityImageTextHelp(); ?> 3 will be replace at run time, depending on user locale with "If You do not see ...Hit reload"
<?php echo getSecurityImageField("security_try"); ?> 3 will be replace at run time witht the input box
The code above insert the image, and the text, You page normally submit information to the server for processing. Most of the time, the last 2 lines are inserted in a <form>
[edit] in PHP code checking the <form>
In the server code where you process the data...
Only 2 lines are required...(in joomla because $security_refid, $security_try are posted variable value to the php scripts)
include ($mosConfig_absolute_path.'/administrator/components/com_securityimages/server.php');
$checkSecurity = checkSecurityImage($security_refid, $security_try);
if $checkSecurity = true //then the user has entered the right text.
[edit] For securityimages version >= 4.0.0
[edit] in PHP <form>
include($mosConfig_absolute_path.'/administrator/components/com_securityimages/client.php'); $packageName = 'securityimage_newpass';
echo "<tr><td>".getSecurityImageTextHeader()." *</td><td>".insertSecurityImage($packageName)."
".getSecurityImageTextHelp()."".getSecurityImageField($packageName)."</td></tr>";
[edit] in PHP code checking the <form>
$securityimage_newpass_refid = mosGetParam( $_POST, 'securityimage_newpass_refid', ); $securityimage_newpass_try = mosGetParam( $_POST, 'securityimage_newpass_try', ); $securityimage_newpass_reload = mosGetParam( $_POST, 'securityimage_newpass_reload', ); include_once ($mosConfig_absolute_path.'/administrator/components/com_securityimages/server.php'); $checkSecurity &= checkSecurityImage($securityimage_newpass_refid, $securityimage_newpass_try, $securityimage_newpass_reload);
<<added quotes in $POST statements, jwr011106>>
For me, the line $checkSecurity &= checkSecurityImage($securityimage_newpass_refid, $securityimage_newpass_try, $securityimage_newpass_reload);
only worked like this: $checkSecurity = checkSecurityImage($securityimage_newpass_refid, $securityimage_newpass_try, $securityimage_newpass_reload);

