Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: [Resuelto:] No aparece captcha en el formulario de comentarios  (Read 7306 times)

0 Members and 1 Guest are viewing this topic.

launioncotahuasi

  • Coppermine newbie
  • Offline Offline
  • Posts: 16

Instale captcha 3.0 en mi galeria, pero solo aparece en los formularios para ingresar y registrarse; en el formulario de comentarios no aparece nada y los spam entran directamente. Para lo que mas queria el captcha era precisamente para el formulario de comentarios.
El archivo codebase.php no lo toque porque no domino lo de php, pero asi se supone que deberia aparecer en todos los formularios, como me ha pasado en otro album.


Mi album esta en http://limadeayer.comli.com/galeria/

Gracias
« Last Edit: August 20, 2009, 07:41:16 am by Fabricio Ferrero »
Logged

mipavluk

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Female
  • Posts: 51
    • Scrapping Whispers
Re: No aparece captcha en el formulario de comentarios
« Reply #1 on: August 18, 2009, 09:34:43 pm »

vos querés que personas que no se han registrado puedan escribir comentarios?
Logged

launioncotahuasi

  • Coppermine newbie
  • Offline Offline
  • Posts: 16
Re: No aparece captcha en el formulario de comentarios
« Reply #2 on: August 18, 2009, 09:47:24 pm »

Este es mi codebase.php

Code: [Select]
<?php
/**
 * Coppermine Photo Gallery
 *
 * Copyright (c) 2003-2006 Coppermine Dev Team
 * v1.1 originally written by Gregory DEMAR
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Coppermine version: 1.4.13
 * CAPTCHA Plugin
 * Based on Mod by Abbas ali(http://coppermine-gallery.net/forum/index.php?topic=29564.0)
 * Plugin Writen by bmossavari at gmail dot com
 */

if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');
// Add an install & configure & uninstall actions
$thisplugin->add_action('plugin_install''captcha_install');
$thisplugin->add_action('plugin_configure''captcha_configure');
$thisplugin->add_action('plugin_uninstall''captcha_uninstall');
// Add a filter for the gallery header
$thisplugin->add_filter('page_html''captcha_main');
// Add actions
$thisplugin->add_action('page_start''captcha_page_start');
// Install Plugin
function captcha_install()
{
    global 
$CONFIG$lang_plugin_captcha;
    require (
'plugins/captcha/include/init.inc.php');

    require 
'include/sql_parse.php';
    
// create table
    
$db_schema 'plugins/captcha/schema.sql';
    
$sql_query fread(fopen($db_schema'r'), filesize($db_schema));
    
$sql_query preg_replace('/CPG_/'$CONFIG['TABLE_PREFIX'], $sql_query);

    
$sql_query remove_remarks($sql_query);
    
$sql_query split_sql_file($sql_query';');

    foreach(
$sql_query as $q) {
        
cpg_db_query($q);
    }

    return 
true;
}
// Uninstall (ask admin about dropping table)
function captcha_uninstall()
{
    global 
$CONFIG;

    
cpg_db_query("DROP TABLE IF EXISTS {$CONFIG['TABLE_PREFIX']}plugin_captcha");
    return 
true;
}

/**
 * captcha_main()
 * Filter HTML and ADD Capthca image & confirmation
 *
 * @return HTML
 */
function captcha_main($html)
{
    global 
$lang_display_comments$lang_register_php$lang_plugin_captcha_conf $CAPTCHA_DISABLE;

    switch (
$_SERVER['PHP_SELF']) {
        case 
'login.php':
            
$valid_groups explode(','$CAPTCHA_DISABLE['login']);
            if (!
in_array(USER_GROUP$valid_groups) OR $CAPTCHA_DISABLE['login'] == '') {
                
$exper '(<input type="password".*</td>)';
                if (
preg_match($exper$html)) {
                    
$newcpch '<!-- CAPTCH PLUGIN 3 --><input type="password" class="textinput" name="password" style="width: 100%" tabindex="2" /></td></tr><tr><td class="tableb">' $lang_plugin_captcha_conf '</td><td class="tableb" colspan="2"><input type="text" name="confirmCode" id="confirmCode" size="20" class="textinput" style="width=50%" tabindex="3"><img src="captcha.php" align="middle"></td>';
                    
$html preg_replace($exper$newcpch$html);
                }
            }
            break;
        case 
'register.php':
            
$valid_groups explode(','$CAPTCHA_DISABLE['register']);
            if (!
in_array(USER_GROUP$valid_groups) OR $CAPTCHA_DISABLE['register'] == '') {
                
$exper '(<td colspan="2" align="center" class="tablef">.*
                 .*<input type="submit" name="submit" value="' 
$lang_register_php['submit'] . '" class="button" />.*
             .*</td>)'
;
                if (
preg_match($exper$html)) {
                    
$newcpch '<!-- CAPTCH PLUGIN 3 --><tr><td class="tableb" height="25" width="40%">' $lang_plugin_captcha_conf '</td><td class="tableb_compact" colspan="2"><input type="text" name="confirmCode" id="confirmCode" size="5" class="textinput"><img src="captcha.php" align="middle"></tr><tr><td colspan="2" align="center" class="tablef">
                    <input type="submit" name="submit" value="' 
$lang_register_php['submit'] . '" class="button" />
            </td></tr>'
;
                    
$html preg_replace($exper$newcpch$html);
                }
            }
            break;
        case 
'displayimage.php':
            
$valid_groups explode(','$CAPTCHA_DISABLE['comment']);
            if (!
in_array(USER_GROUP$valid_groups) OR $CAPTCHA_DISABLE['comment'] == '') {
                
$exper '(<input type="submit" class="comment_button" name="submit" value="' $lang_display_comments['OK'] . '" />)';
                if (
preg_match($exper$html)) {
                    if (
USER_ID) {
                        
$newcpch '<!-- CAPTCH PLUGIN 3 --><input type="submit" class="comment_button" name="submit" id="submit" value="' $lang_display_comments['OK'] . '" /></td></tr><tr><td class="tableb_compact" colspan="2">' $lang_plugin_captcha_conf '</td><td class="tableb_compact" colspan="2"><input type="text" name="confirmCode" id="confirmCode" size="5" class="textinput"><img src="captcha.php" align="middle">';
                    } else {
                        
$newcpch '<!-- CAPTCH PLUGIN 3 --><input type="submit" class="comment_button" name="submit" id="submit" value="' $lang_display_comments['OK'] . '" /></td></tr><tr><td class="tableb_compact" >' $lang_plugin_captcha_conf '</td><td class="tableb_compact" ><input type="text" name="confirmCode" id="confirmCode" size="5" class="textinput"><td class="tableb_compact"><img src="captcha.php" align="middle"></td><td class="tableb_compact" >&nbsp;</td><td class="tableb_compact" >&nbsp;</td>';
                    }
                    
$html preg_replace($exper$newcpch$html);
                }
            }
            break;
        case 
'report_file.php':
            
$valid_groups explode(','$CAPTCHA_DISABLE['report']);
            if (!
in_array(USER_GROUP$valid_groups) OR $CAPTCHA_DISABLE['report'] == '') {
                
$exper '(<textarea.*<br />)';
                if (
preg_match($exper$html)) {
                    
$newcpch = <<<EOT
            <textarea name="message" class="textinput" rows="8" cols="40" onselect="storeCaret_post(this);" onclick="storeCaret_post(this);" onkeyup="storeCaret_post(this);" style="width: 100%;">$message</textarea><br /><br />
        </td>
        <tr>
            <!-- CAPTCH PLUGIN 3 --><td class="tableh2" colspan="3"><b>
{$lang_plugin_captcha_conf}</b><img src="captcha.php" align="middle"></td>
        </tr>
        <tr>
            <td class="tableb" colspan="3">
                                                                                <input type="text" name="confirmCode" id="confirmCode" size="5" class="textinput" style="width: 100%;">
EOT;
                    
$html preg_replace($exper$newcpch$html);
                }
            }

            break;
        case 
'ecard.php':
            
$valid_groups explode(','$CAPTCHA_DISABLE['ecard']);
            if (!
in_array(USER_GROUP$valid_groups) OR $CAPTCHA_DISABLE['ecard'] == '') {
                
$exper '(<textarea.*<br />)';
                if (
preg_match($exper$html)) {
                    
$newcpch = <<<EOT
            <textarea name="message" class="textinput" rows="8" cols="40" onselect="storeCaret_post(this);" onclick="storeCaret_post(this);" onkeyup="storeCaret_post(this);" style="width: 100%;">$message</textarea><br /><br />
        </td>
        <tr>
            <!-- CAPTCH PLUGIN 3 --><td class="tableh2" colspan="3"><b>
{$lang_plugin_captcha_conf}</b><img src="captcha.php" align="middle"></td>
        </tr>
        <tr>
            <td class="tableb" colspan="3">
                                                                                <input type="text" name="confirmCode" id="confirmCode" size="5" class="textinput" style="width: 100%;">
EOT;
                    
$html preg_replace($exper$newcpch$html);
                }
            }

            break;
        default: ;
    } 
// switch
    
return $html;
}
/**
 * captcha_page_start()
 * check/validate captcha confirmation code [user input] for each page
 *
 * @return
 */
function captcha_page_start()
{
    global 
$lang_continue$lang_error$lang_plugin_captcha_conf$CONFIG$CAPTCHA_DISABLE$CAPTCHA_TIMEOUT;
    
/*                              Setting Options                                        */
    /**
     * Enable/Disable array
     *
     * Set which group should NOT see Captcha on each page
     * ''=> Captcha Enable for all users
     * COppermine Standard Group Name:
     * Administrators,Registered,Guests,Banned
     * You can add your custome group name too
     * Seprated by ','
     */

    
$CAPTCHA_DISABLE = array('login' => 'Administrators,Registered',
        
'register' => 'Administrators,Registered',
        
'comment' => 'Administrators,Registered',
        
'report' => 'Administrators',
        
'ecard' => 'Administrators',
        );
    
$CAPTCHA_TIMEOUT 300// How many sec should passed before we remove the code from database
    
require ('plugins/captcha/include/init.inc.php');
    require(
'plugins/captcha/include/captcha.class.php');

    switch (
$_SERVER['PHP_SELF']) {
        case 
'login.php':
            
$valid_groups explode(','$CAPTCHA_DISABLE['login']);
            if (!
in_array(USER_GROUP$valid_groups) OR $CAPTCHA_DISABLE['login'] == '') {
                if (isset(
$_POST['submitted']) AND !Validate($_POST['confirmCode'])) {
                    
load_template();
                    
pageheader($lang_error"<META http-equiv=\"refresh\" content=\"3;url=login.php\">");
                    
msg_box($lang_error"$lang_plugin_captcha_error"$lang_continue'login.php');
                    
pagefooter();
                    exit;
                }
            }
            break;
        case 
'register.php':
            
$valid_groups explode(','$CAPTCHA_DISABLE['register']);
            if (!
in_array(USER_GROUP$valid_groups) OR $CAPTCHA_DISABLE['register'] == '') {
                if (isset(
$_POST['submit']) AND !Validate($_POST['confirmCode'])) {
                    
load_template();
                    
pageheader($lang_error"<META http-equiv=\"refresh\" content=\"3;url=register.php\">");
                    
msg_box($lang_error"$lang_plugin_captcha_error"$lang_continue'register.php');
                    
pagefooter();
                    exit;
                }
            }
            break;
        case 
'db_input.php':
            
$valid_groups explode(','$CAPTCHA_DISABLE['comment']);
            if (!
in_array(USER_GROUP$valid_groups) OR $CAPTCHA_DISABLE['comment'] == '') {
                if (isset(
$_POST['msg_body']) AND !Validate($_POST['confirmCode'])) {
                    
load_template();
                    
pageheader($lang_error"<META http-equiv=\"refresh\" content=\"3;url=displayimage.php?pos=" . (- $_POST['pid']) . "\">");
                    
msg_box($lang_error"$lang_plugin_captcha_error"$lang_continue"displayimage.php?pos=" . (- $_POST['pid']));
                    
pagefooter();
                    exit;
                }
            }
            break;
        case 
'report_file.php':
            
$valid_groups explode(','$CAPTCHA_DISABLE['report']);
            if (!
in_array(USER_GROUP$valid_groups) OR $CAPTCHA_DISABLE['report'] == '') {
                if (
count($_POST) > AND !Validate($_POST['confirmCode'])) {
                    
load_template();
                    
pageheader($lang_error"<META http-equiv=\"refresh\" content=\"3;url=report_file.php?album={$_GET['album']}&pid={$_GET['pid']}&pos={$_GET['pos']}\">");
                    
msg_box($lang_error"$lang_plugin_captcha_error"$lang_continue"report_file.php?album={$_GET['album']}&pid={$_GET['pid']}&pos={$_GET['pos']}");
                    
pagefooter();
                    exit;
                }
            }
            break;
        case 
'ecard.php':
            
$valid_groups explode(','$CAPTCHA_DISABLE['ecard']);
            if (!
in_array(USER_GROUP$valid_groups) OR $CAPTCHA_DISABLE['ecard'] == '') {
                if (
count($_POST) > AND !Validate($_POST['confirmCode'])) {
                    
load_template();
                    
pageheader($lang_error"<META http-equiv=\"refresh\" content=\"3;url=ecard.php?album={$_GET['album']}&pid={$_GET['pid']}&pos={$_GET['pos']}\">");
                    
msg_box($lang_error"$lang_plugin_captcha_error"$lang_continue"ecard.php?album={$_GET['album']}&pid={$_GET['pid']}&pos={$_GET['pos']}");
                    
pagefooter();
                    exit;
                }
            }
            break;
        default: ;
    } 
// switch
}

/**
 * Validate()
 * Retrieve Captcha code from database based on ip address and user input
 *
 * @param string $sUserCode
 * @return boolian
 */
function Validate($sUserCode)
{
    global 
$CONFIG$CAPTCHA_TIMEOUT;
    
$timeout = (time() - $CAPTCHA_TIMEOUT); // set timeout for removing old enteries
    
$query "DELETE FROM {$CONFIG['TABLE_PREFIX']}plugin_captcha where UNIX_TIMESTAMP(time) < $timeout ";
    
cpg_db_query($query);
    
$ip $_SERVER['REMOTE_ADDR'];
    
$code md5(strtoupper($sUserCode));
    
$query "SELECT COUNT(*) AS ccount FROM {$CONFIG['TABLE_PREFIX']}plugin_captcha WHERE ((ip_addr = '$ip') AND (code ='$code')) LIMIT 1";
    
$results cpg_db_query($query);
    
$result mysql_fetch_assoc($results);
    if (
$result['ccount']) {
        return 
true;
    }
    return 
false;
}

?>
Logged

mipavluk

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Female
  • Posts: 51
    • Scrapping Whispers
Re: No aparece captcha en el formulario de comentarios
« Reply #3 on: August 18, 2009, 09:51:43 pm »

un minuto

hasta donde yo se... y no se demasiado... jajaja.... en el captcha vos podes seleccionar qué grupos de usuarios querés que tengan el captcha... nada más...

pero en la configuración de la galería... como seguridad....

1) tenés que poner que todas las cuentas se verifiquen por e-mail, entonces, se reduce el número de spam, porque solo entran aquellos que ponen un e-mail válido

2) tenés que marcar que los invitados no puedan colocar nada, ni comentarios, ni subir imágenes, si quieren algo de ello deben registrarse...
Logged

launioncotahuasi

  • Coppermine newbie
  • Offline Offline
  • Posts: 16
Re: No aparece captcha en el formulario de comentarios
« Reply #4 on: August 19, 2009, 12:33:38 am »

Ya esta solucionado, el problema era que no le habia dado permiso de comentarios a los usuarios anonimos. Gracias
Logged

mipavluk

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Female
  • Posts: 51
    • Scrapping Whispers
Re: No aparece captcha en el formulario de comentarios
« Reply #5 on: August 19, 2009, 05:33:05 pm »

q bueno!  ;)
Logged

Fabricio Ferrero

  • Moderator
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 1996
  • From San Juan, Argentina, to the World!
    • http://fabricioferrero.com/
Re: No aparece captcha en el formulario de comentarios
« Reply #6 on: August 19, 2009, 05:59:08 pm »

Muchas Gracias por volver y dar por solucionado el tema!


P.D: Gracias mipavluk por la ayuda ;)

Saludos,
Logged
Read Docs and Search the Forum before posting. - Soporte en español
--*--
Fabricio Ferrero's Website

Catching up! :)
Pages: [1]   Go Up
 

Page created in 0.024 seconds with 22 queries.