gallery problem

Third Party Plugins to CMSimple - how to install, use and create plugins

Moderator: Tata

Post Reply
madar
Posts: 12
Joined: Wed Dec 31, 2008 1:32 pm
Location: Hungary

gallery problem

Post by madar » Fri Jan 30, 2009 4:35 pm

Hi, I have a gallery plugin with comments, I can add to this captcha code, bude not working :x
Please help me, now Can't post comments :o Where I have error?

function AddComment($dir,$pic){
global $plugin_cf,$plugin_tx,$sn,$su,$files,$title_array;
$page = getvariable('page');
$file = $files[$pic];
$size = GetImageSize ($dir."thumb/tn_".$file);
$w=$size[0];
$h=$size[1];
$t = "<fieldset class=\"gallery_fieldset\">";
$title = $title_array[$pic][0];
$t .= "<div class=\"addcomment\">";
$t .= "<div class=\"thumbnailitem\">";
if(eregi("true",$plugin_cf['gallery']['show_title']) and eregi("top",$plugin_cf['gallery']['title_placement']))$t .= $title;
$t .=tag('br')."<a href=\"$sn?$su\" class=\"thumb\">".tag('img src="'.$dir.'thumb/tn_'.rawurlencode($file).'" height="'.$h.'" width="'.$w.'" alt="'.$title.'"')."</a>".tag('br');
if(eregi("true",$plugin_cf['gallery']['show_title']) and eregi("bottom",$plugin_cf['gallery']['title_placement']))$t .= $title;
$t .= "</div>";
$t .= "<div class=\"addcommentform\">";
if (empty($_POST)) {
$t .= "<form method=\"post\" action=\"$sn?$su\">";
$t .= "<p>".tag('input type="hidden" name="pic" value="'.$pic.'"')."</p>";
$t .= "<p>".tag('input type="hidden" name="page" value="'.$page.'"')."</p>";
$t .= "<p>".tag('input type="hidden" name="action" value="writecomment"')."</p>";
$t .= "<p>".$plugin_tx['gallery']['form_name'].tag('br').tag('input type="text" name="comment_name" size="26" class="gallery_comment_form"')."</p>";
$t .= '<p><img src="http://www.example.hu/plugins/gallery/c ... w.php?sid=' . md5(uniqid(time())) . '" />' . tag('br') . '</p>';
$t .= "<p>".tag('input type="text" name="code" class="gallery_comment_form"')."</p>";
$t .= "<p>".$plugin_tx['gallery']['form_comment'].tag('br')."<textarea rows=\"3\" name=\"comment_text\" cols=\"21\" class=\"gallery_comment_form\"></textarea>"."</p>";
$t .= "<p>".tag('input type="submit" value="'.$plugin_tx['gallery']['add_comment'].'" class="gallery_submit"')."</p>";

$t .= "</form></div></div>";
$t .= "</fieldset>";

} else {
include './plugins/gallery/captcha/securimage.php';
$img = new Securimage();
$valid = $img->check($_POST['code']);

if($valid == true) {
return $t;
} else {
echo "<center>Sorry, the code you entered was invalid. <a href=\"javascript:history.go(-1)\">Go back</a> to try again.</center>";
}
}
}
cmsimpleforum.com best CMSimple community!

Holger
Site Admin
Posts: 3470
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

Re: gallery problem

Post by Holger » Fri Jan 30, 2009 11:02 pm

Hi madar,

I've integrated the securimage captcha into the gallery plugin.
Please be patient, the version will be available in the next days.
A little demo, without comments, is available at my playground:
http://www.HolgerIrmler.de/playground

Holger

madar
Posts: 12
Joined: Wed Dec 31, 2008 1:32 pm
Location: Hungary

Re: gallery problem

Post by madar » Sat Jan 31, 2009 1:09 pm

Ok, but what means "next days" please ? Because I've got only 5 days to do this. Thanks for reply
cmsimpleforum.com best CMSimple community!

Holger
Site Admin
Posts: 3470
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

Re: gallery problem

Post by Holger » Sat Jan 31, 2009 2:40 pm

madar wrote:Ok, but what means "next days" please ? Because I've got only 5 days to do this. Thanks for reply
I'm not sure ;) .
So here's my code for the integration of securimage captcha:

In idex.php:

Code: Select all

//Add comment
            if ($pic <> '' and $action == 'writecomment') {
            	//HI Validate input & captcha and return to form on errors 
            	$gallery_comment = true;
            	include_once $pth['folder']['plugins'].$plugin.'/securimage/securimage.php';
            	$securimage = new Securimage();
            	
            	if ($securimage->check($_POST['captcha_code']) == false) {
            	    $t .= '<div class="gallery_comment_error">&bull; '.$plugin_tx['gallery']['captcha_error'].'</div>';
            	    $gallery_comment = false;
            	}    
            	if ($_POST['comment_name'] == '') {
            	    $t .= '<div class="gallery_comment_error">&bull; '.$plugin_tx['gallery']['comment_name_error'].'</div>';
            	    $gallery_comment = false;	
            	}
            	if ($_POST['comment_text'] == '') {
            	    $t .= '<div class="gallery_comment_error">&bull; '.$plugin_tx['gallery']['comment_text_error'].'</div>';
            	    $gallery_comment = false;
            	}
            	if ($gallery_comment == false) {
            	    $t .= tag('br');
            	    $t .= AddComment($dir,$pic);	
        	    return $t;
        	}  //HI End captcha and input validation  
        	else
in thumbcreate.php,
function AddComment($dir, $pic):

Code: Select all

...

$t .= "<form method=\"post\" action=\"$sn?$su\">";
        $t .= tag('input type="hidden" name="pic" value="'.$pic.'"');
        $t .= tag('input type="hidden" name="page" value="'.$page.'"');
        $t .= tag('input type="hidden" name="action" value="writecomment"');
        $t .= "<p>".$plugin_tx['gallery']['form_name'].tag('br').tag('input type="text" name="comment_name" size="26" class="gallery_comment_form"')."</p>";
        $t .= "<p>".$plugin_tx['gallery']['form_comment'].tag('br')."<textarea rows=\"8\" name=\"comment_text\" cols=\"21\" class=\"gallery_comment_form\"></textarea>"."</p>";
        //HI Start Captcha Code
        $t .= "<p>".$plugin_tx['gallery']['captcha_heading'].tag('br').tag('img id="captcha" src="'.$pth['folder']['plugins'].'gallery/securimage/securimage_show.php." alt="CAPTCHA Image" class="gallery_captcha"')."&nbsp;&nbsp;"."</p>";
        $t .= "<p>";
        $t .= $plugin_tx['gallery']['captcha_verify_code']."&nbsp;&nbsp;".tag('input type="text" name="captcha_code" size="10" maxlength="4" class="gallery_comment_form"')."&nbsp;&nbsp;";
        $t .= "<a class=\"gallery_comment_form\" href=\"#\" onclick=\"document.getElementById('captcha').src = '".$pth['folder']['plugins']."gallery/securimage/securimage_show.php?' + Math.random(); return false\">".$plugin_tx['gallery']['captcha_reload']."</a>";
        $t .= "</p>";
        //HI End Captcha Code
        $t .= "<p>".tag('input type="submit" value="'.$plugin_tx['gallery']['add_comment'].'" class="gallery_submit"')."</p>";

... </form>
You have to edit your languagefile with my code.
New variables are:
  • $plugin_tx['gallery']['captcha_verify_code']
  • $plugin_tx['gallery']['captcha_reload']
  • $plugin_tx['gallery']['captcha_error']
Hope you get it now,

Holger

madar
Posts: 12
Joined: Wed Dec 31, 2008 1:32 pm
Location: Hungary

Re: gallery problem

Post by madar » Sun Feb 01, 2009 1:24 pm

Now it works perfetc, thanks Holger !
cmsimpleforum.com best CMSimple community!

madar
Posts: 12
Joined: Wed Dec 31, 2008 1:32 pm
Location: Hungary

Re: gallery problem

Post by madar » Mon Feb 02, 2009 6:49 pm

Done all, you can close this topic, thanks for help
cmsimpleforum.com best CMSimple community!

Post Reply