Quote:
@Tobias Can you post your hacks for CBB please 'cus I'm just updating a site that will use it.
Sure, the problem being that I implemented the thing before DuGris came up with his new version for PhP 5+. So I haven't tested whether it actually works this way, but I wouldn't see why not. The code to be dropped into the files is from the hack for the contact module DuGris has posted a few days back.
It's two steps: Generate the image and display it in the form, and verify the user has entered the correct code. In CBB3, at least when you're admitting quick reply, you'll have two different places at which to display security images. For quick reply, it's in viewtopic.php, for full reply in include/forumform.inc.php. Both times, you will want to put the code for the security image before the "submit" button. Verification in post.php. Makes three files to hack.
In viewtopic.php, around line 608:
$forum_form->addElement(new XoopsFormHidden('notify', -1));
[color=CC0000]// Hack SecurityImage by DuGris
if (defined('SECURITYIMAGE_INCLUDED')) {
$security_image = new SecurityImage( _SECURITYIMAGE_GETCODE );
if ($security_image->render()) {
$forum_form->addElement($security_image, true);
}
}
// Hack SecurityImage by DuGris[/color]
$forum_form->addElement(new XoopsFormHidden('contents_submit', 1));
$submit_button = new XoopsFormButton('', 'quick_submit', _SUBMIT, "submit");
In include/forumform.inc.php, around line 262:
$forum_form->addElement(new XoopsFormHidden('op', $op));
[color=CC0000]// Hack SecurityImage by DuGris
if (defined('SECURITYIMAGE_INCLUDED')) {
$security_image = new SecurityImage( _SECURITYIMAGE_GETCODE );
if ($security_image->render()) {
$forum_form->addElement($security_image, true);
}
}
// Hack SecurityImage by DuGris[/color]
$button_tray = new XoopsFormElementTray('');
$submit_button = new XoopsFormButton('', 'contents_submit', _SUBMIT, "submit");
And to check whether the user has entered the correct code, in post.php, around line 135:
if(empty($message)){
redirect_header("javascript:history.go(-1);", 1);
exit();
}
[color=CC0000] // Hack SecurityImage by DuGris
include_once(XOOPS_ROOT_PATH ."/class/xoopsformloader.php");
if ( defined('SECURITYIMAGE_INCLUDED') && !SecurityImage::CheckSecurityImage() ) {
redirect_header( 'javascript:history.go(-1)' , 1, _SECURITYIMAGE_ERROR ) ;
}
// Hack SecurityImage by DuGris[/color]
if ( !empty($isedit) && $post_id>0) {
$uid = is_object($xoopsUser)? $xoopsUser->getVar('uid'):0;
There're, in fact, various parts inside post.php where I imagine the securityimage code would make sense. Depending on the order of the several verification steps to be performed. I'm not claiming that this is the most appropriate point to drop in the code, but it's working fine for me. It's here after it's established there's some content in the post at all. If anyone has a better idea or knows a reason why my method is not good, please let me know.
Oops: "tamairanslip" in the code above, I take, stands for j a v a s c r i p t : and is sanitized by this XOOPS here. Please substitute, without the spaces of course.