Foros del Web » Programando para Internet » PHP »

Problema sistema de puntos!

Estas en el tema de Problema sistema de puntos! en el foro de PHP en Foros del Web. Hola :D bueno tengo una duda :D quiero qe cuando ya manden el comentario se le agreguen 4 creditos, osea cuando le picken: "Add My ...
  #1 (permalink)  
Antiguo 12/06/2009, 12:28
 
Fecha de Ingreso: junio-2009
Mensajes: 9
Antigüedad: 14 años, 10 meses
Puntos: 0
Problema sistema de puntos!

Hola :D bueno tengo una duda :D

quiero qe cuando ya manden el comentario se le agreguen 4 creditos, osea cuando le picken:
"Add My Comment"

con este codigo

Código PHP:
<?php


mysql_query
("UPDATE usuarios SET puntos = puntos+1 WHERE nick='{$_COOKIE["nick"]}'");
?>
espero sus respuestas :D


aa por sierto este es el codigo del cute news



Código PHP:
<?PHP

error_reporting 
(E_ALL E_NOTICE);



// If we are showing RSS, include some need variables.
if($template == 'rss'){
  
}

//----------------------------------
// Check if we are included by PATH
//----------------------------------
if($_SERVER["HTTP_ACCEPT"] or $_SERVER["HTTP_ACCEPT_CHARSET"] or $_SERVER["HTTP_ACCEPT_ENCODING"] or $_SERVER["HTTP_CONNECTION"]){ /* do nothing */ }
elseif(
eregi("show_news. php"$PHP_SELF)){
die(
"<h4>CuteNews has detected that you are including show_news. php using the URL to this file. <br>
This is incorrect and you must include it using the PATH to show_news. php</h4><br>Example:<br>
this is <font color=red>WRONG</font> :&nbsp;&nbsp; &lt;?PHP include(\"hxxp: yoursite. com/cutenews/show_news. php\"); ?&gt;<br>
this is <font color=green>CORRECT</font>:&nbsp;&nbsp; &lt;?PHP include(\"cutenews/show_news. php\"); ?&gt;<br>
<br><BR>// <font size=2>if you think this message shouldn't be shown, open show_news. php and delete it from there</font>"
);
}
//----------------------------------
// End of the check
//----------------------------------

if(!isset($subaction) or $subaction == ""){ $subaction $POST["subaction"]; }

if(!isset(
$template) or $template == "" or strtolower($template) == "default"){ require_once("$cutepath/data/Default. tpl"); }
else{
        if(
file_exists("$cutepath/data/${template}. tpl")){ require("$cutepath/data/${template}. tpl"); }
    else{ die(
"Error!<br>the template <b>"htmlspecialchars($template). "</b> does not exists, note that templates are case sensetive and you must write the name exactly as it is"); }
}

// Prepare requested categories
if(eregi("[a-z]"$category)){
        die(
"<b>Error</b>!<br>CuteNews has detected that you use \$category = \""htmlspecialchars($category). "\"; but you can call the categories only with their <b>ID</b> numbers and not with names<br>
    example:<br><blockquote>&lt;?PHP<br>\$category = \"1\";<br>include(\"path/to/show_news. php\");<br>?&gt;</blockquote>"
);
}
$category preg_replace("/ /"""$category);
$tmp_cats_arr explode(","$category);
foreach(
$tmp_cats_arr as $key=>$value){
    if(
$value != ""){ $requested_cats[$value] = TRUE; }
}

if(
$archive == ""){
        
$news_file "$cutepath/data/news. txt";
        
$comm_file "$cutepath/data/comments. txt";
}else{
        
$news_file "$cutepath/data/archives/$archive. news. arch";
        
$comm_file "$cutepath/data/archives/$archive. comments. arch";
}

$allow_add_comment                        FALSE;
$allow_full_story                        FALSE;
$allow_active_news                         FALSE;
$allow_comments                         FALSE;



//<<<------------ Detarime what user want to do
if( $CN_HALT != TRUE and $static != TRUE and ($subaction == "showcomments" or $subaction == "showfull" or $subaction == "addcomment") and ((!isset($category) or $category == "") or ($requested_cats[$ucat] == TRUE )  ) ){
    if(
$subaction == "addcomment"){  $allow_add_comment        TRUE$allow_comments TRUE; }
    if(
$subaction == "showcomments"){ $allow_comments TRUE; }
    if((
$subaction == "showcomments" or $allow_comments == TRUE) and $config_show_full_with_comments == "yes"){$allow_full_story TRUE; }
    if(
$subaction == "showfull"$allow_full_story TRUE;
    if(
$subaction == "showfull" and $config_show_comments_with_full == "yes"$allow_comments TRUE;

}
else{
    if(
$config_reverse_active == "yes"){ $reverse TRUE; }
        
$allow_active_news TRUE;
}
//----------->>> Detarime what user want to do

require("$cutepath/inc/shows. inc. php");
    if(
$_GET['archive'] and $_GET['archive'] != ''){ $archive $_GET['archive']; } // stupid fix ?
unset($static$template$requested_cats$category$catid$cat,$reverse$in_use$archives_arr$number$no_prev$no_next$i$showed$prev$used_archives);
?>
  #2 (permalink)  
Antiguo 12/06/2009, 13:07
Avatar de Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: Problema sistema de puntos!

Actualmente estas agregando 1 "credito" y todo lo que tienes que hacer es modificar tu consulta para que en vez de puntos = puntos+1 diga puntos = puntos+4
__________________
- León, Guanajuato
- GV-Foto
  #3 (permalink)  
Antiguo 12/06/2009, 22:21
 
Fecha de Ingreso: junio-2009
Mensajes: 9
Antigüedad: 14 años, 10 meses
Puntos: 0
Respuesta: Problema sistema de puntos!

Cita:
Iniciado por Triby Ver Mensaje
Actualmente estas agregando 1 "credito" y todo lo que tienes que hacer es modificar tu consulta para que en vez de puntos = puntos+1 diga puntos = puntos+4
see eso lo se, pero como le ago qe juato cuando le den a "Add My Comment" se les añadan, no solo al ver la pagina??
  #4 (permalink)  
Antiguo 12/06/2009, 23:34
Avatar de Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: Problema sistema de puntos!

Ok, solo copia esa linea y pegala debajo de donde se agrega el comentario que, por cierto, no aparece y podria estar en show.inc.php
__________________
- León, Guanajuato
- GV-Foto
  #5 (permalink)  
Antiguo 13/06/2009, 00:02
 
Fecha de Ingreso: junio-2009
Mensajes: 9
Antigüedad: 14 años, 10 meses
Puntos: 0
Respuesta: Problema sistema de puntos!

triby gracias por ayudarme :D

aqui esta el show.inc.php

yo creo qe es aqui:

Código PHP:
//####################################################################################################################
//                         Add Comment
//####################################################################################################################
if($allow_add_comment){

        
$name trim($name);
        
$mail trim($mail);
    
$id = (int) $id;  // Yes it's stupid how I didn't thought about this :/

    //----------------------------------
    // Check the lenght of comment, include name + mail
    //----------------------------------

        
if( strlen($name) > 50 ){
               echo
"<div style=\"text-align: center;\">Your name is too long!</div>";
                
$CN_HALT TRUE;
                break 
1;
        }
        if( 
strlen($mail) > 50){
               echo
"<div style=\"text-align: center;\">Your e-mail is too long!</div>";
                
$CN_HALT TRUE;
                break 
1;
        }
        if( 
strlen($comments) > $config_comment_max_long and $config_comment_max_long != "" and $config_comment_max_long != "0"){
               echo
"<div style=\"text-align: center;\">Your comment is too long!</div>";
                
$CN_HALT TRUE;
                break 
1;
        }

    
//----------------------------------
    // Get the IP
    //----------------------------------
        
$foundip TRUE;
        if (
getenv("HTTP_CLIENT_IP")) $ip getenv("HTTP_CLIENT_IP");
        else if(
getenv("REMOTE_ADDR")) $ip getenv("REMOTE_ADDR");
        else if(
getenv("HTTP_X_FORWARDED_FOR")) $ip getenv("HTTP_X_FORWARDED_FOR");
        else {
$ip "not detected"$foundip FALSE;}

        if( !
$foundip or !preg_match("/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/""$ip") ){ $ip "not detected"$foundip FALSE;}    //ensure that what we have is a real IP
    //----------------------------------
    // Flood Protection
    //----------------------------------
    
if($config_flood_time != and $config_flood_time != "" ){
        if(
flooder($ip$id) == TRUE ){
                echo(
"<div style=\"text-align: center;\">Flood protection activated !!!<br />you have to wait $config_flood_time seconds after your last comment before posting again at this article.</div>");
                         
$CN_HALT TRUE;
             break 
1;
                }
    }

    
//----------------------------------
    // Check if IP is blocked
    //----------------------------------
    
$blockip FALSE;
    
$old_ips file("$cutepath/data/ipban.db.php");
    
$new_ips fopen("$cutepath/data/ipban.db.php""w");
    @
flock ($new_ips,2);
    foreach(
$old_ips as $old_ip_line){
            
$ip_arr explode("|"$old_ip_line);

        
//implemented wildcard match
            
$ip_check_matches 0;
            
$db_ip_split explode("."$ip_arr[0]);
            
$this_ip_split explode("."$ip);

            for(
$i_i=0;$i_i<4;$i_i++){
//            echo"IF $this_ip_split[$i_i] == $db_ip_split[$i_i] or $db_ip_split[$i_i] == '*'<br>";
                
if ($this_ip_split[$i_i] == $db_ip_split[$i_i] or $db_ip_split[$i_i] == '*') {
                    
$ip_check_matches += 1;
                }

            }

            if (
$ip_check_matches == 4) {
                        
$countblocks $ip_arr[1] = $ip_arr[1] + 1;
                        
fwrite($new_ips"$ip_arr[0]|$countblocks||\n"); $blockip TRUE;
            } else {
                        
fwrite($new_ips$old_ip_line);
            }

    }
    @
flock ($new_ips,3);
    
fclose($new_ips);
    if(
$blockip){
            echo(
"<div style=\"text-align: center;\">Sorry but you have been blocked from posting comments</div>");
         
$CN_HALT TRUE;
     break 
1;
    }

    
//----------------------------------
    // Check if the name is protected
    //----------------------------------
    
$is_member FALSE;
    foreach(
$all_users as $member_db_line)
    {
        if(!
eregi("<\?",$member_db_line) and $member_db_line != ""){
                        
$user_arr explode("|",$member_db_line);

            
//if the name is protected
            
if((strtolower($user_arr[2]) == strtolower($name) or strtolower($user_arr[4]) == strtolower($name)) and    ($user_arr[3] != $CNpass and $user_arr[3] != md5($password))    and $name != "")
                {
                                
//$comments         = replace_comment("add", $comments); //commented because will mess up the <br />
                                
$comments        preg_replace(array("'\"'""'\''""''"), array("&quot;""'"""), $comments);
                            
$name                replace_comment("add"preg_replace("/\n/""",$name));
                                
$mail                 replace_comment("add"preg_replace("/\n/""",$mail));


             echo
"<div style=\"text-align: center;\">This name is owned by a registered user and you must enter password to use it<br />
             <form name=passwordForm id=passwordForm method=\"post\" action=\"\">
             Password: <input type=\"password\" name=\"password\" />
             <input type=\"hidden\" name=\"name\" value=\"$name\" />
             <input type=\"hidden\" name=\"comments\" value=\"$comments\" />
             <input type=\"hidden\" name=\"mail\" value=\"$mail\" />
             <input type=\"hidden\" name=\"ip\" value=\"$ip\" />
             <input type=\"hidden\" name=\"subaction\" value=\"addcomment\" />
             <input type=\"hidden\" name=\"show\" value=\"$show\" />
             <input type=\"hidden\" name=\"ucat\" value=\"$ucat\" />
             $user_post_query
             <input type=\"submit\" /> \n <br>
             <input type=\"checkbox\" name=\"CNrememberPass\" value=1 /> Remember password in cookie (md5 format)
             </form>
              </div>"
;
                         
$CN_HALT TRUE;
             break 
2;

                }

            if(
strtolower($user_arr[2]) == strtolower($name)) $is_member TRUE;

                
//----------------------------------
                // Member wants to save his pass in cookie ?
                //----------------------------------
                    
if($CNrememberPass == 1){
                                if(
file_exists("$cutepath/remember.js")){
                                    echo
"<script type=\"text/javascript\" src=\"$config_http_script_dir/remember.js\"></script>";
                                    echo
"<script>CNRememberPass('".md5($password)."')</script>";
                                }
                                }

        }
        }

    
//----------------------------------
    // Check if only members can comment
    //----------------------------------
        
if($config_only_registered_comment == "yes" and !$is_member){
            echo
"<div style=\"text-align: center;\">Sorry but only registered users can post comments, and '".htmlspecialchars($name)."' is not recognized as valid member.</div>";
                         
$CN_HALT TRUE;
             break 
1;
    }

    
//----------------------------------
    // Wrap the long words
    //----------------------------------
    
if($config_auto_wrap 1){
        
$comments_arr explode("\n"$comments);
        foreach(
$comments_arr as $line){
                
$wraped_comm .= ereg_replace("([^ \/\/]{".$config_auto_wrap."})","\\1\n"$line) ."\n";
        }
            if(
strlen($name) > $config_auto_wrap){ $name substr($name0$config_auto_wrap)." ..."; }
    
$comments $wraped_comm;
    }



    
//----------------------------------
    // Do some validation check 4 name, mail..
    //----------------------------------
    
$comments         replace_comment("add"$comments);
    
$name                replace_comment("add"preg_replace("/\n/""",$name));
        
$mail                 replace_comment("add"preg_replace("/\n/""",$mail));

    if(
$name == " " or $name == ""){
            echo(
"<div style=\"text-align: center;\">You must enter name.<br /><a href=\"javascript:history.go(-1)\">go back</a></div>");
                
$CN_HALT TRUE;
                break 
1;
        }
    if(
$mail == " " or $mail == ""){ $mail "none"; }
    else{ 
$ok FALSE;
          if(
preg_match("/^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/"$mail)) $ok TRUE;
        elseif(
$config_allow_url_instead_mail == "yes" and preg_match("/((http(s?):\/\/)|(www\.))([\w\.]+)([\/\w+\.-?]+)/"$mail)) $ok TRUE;
        elseif(
$config_allow_url_instead_mail != "yes"){
                echo(
"<div style=\"text-align: center;\">This is not a valid e-mail<br /><a href=\"javascript:history.go(-1)\">go back</a></div>");
                        
$CN_HALT TRUE;
                        break 
1;
        }
                else{
                echo(
"<div style=\"text-align: center;\">This is not a valid e-mail or site URL<br /><a href=\"javascript:history.go(-1)\">go back</a></div>");
                        
$CN_HALT TRUE;
                        break 
1;
        }
    }

    if(
$comments == ""){
            echo(
"<div style=\"text-align: center;\">Sorry but the comment can not be blank<br /><a href=\"javascript:history.go(-1)\">go back</a></div>");
                        
$CN_HALT TRUE;
                        break 
1;
    }

    
$time time()+($config_date_adjust*60); 
  #6 (permalink)  
Antiguo 13/06/2009, 00:03
 
Fecha de Ingreso: junio-2009
Mensajes: 9
Antigüedad: 14 años, 10 meses
Puntos: 0
Respuesta: Problema sistema de puntos!

Código PHP:
    //----------------------------------
    // Add The Comment ... Go Go GO!
    //----------------------------------

    
$old_comments file("$comm_file");
    
$new_comments fopen("$comm_file""w");
    @
flock ($new_comments,2);
    
$found FALSE;
    foreach(
$old_comments as $old_comments_line)
    {
     
$old_comments_arr explode("|>|"$old_comments_line);
     if(
$old_comments_arr[0] == $id)
     {
        
$old_comments_arr[1] = trim($old_comments_arr[1]);
        
fwrite($new_comments"$old_comments_arr[0]|>|$old_comments_arr[1]$time|$name|$mail|$ip|$comments||\n");
        
$found TRUE;
     }else{
        
fwrite($new_comments$old_comments_line);
        
//if we do not have the news ID in the comments.txt we are not doing anything (see comment below) (must make sure the news ID is valid)
     
}
    }
    if(!
$found){
            
/* // do not add comment if News ID is not found \\ fwrite($new_comments, "$id|>|$time|$name|$mail|$ip|$comments||\n");*/

                
echo("<div style=\"text-align: center;\">CuteNews did not added your comment because there is some problem with the comments database.<br /><a href=\"javascript:history.go(-1)\">go back</a></div>");
                        
$CN_HALT TRUE;
                        break 
1;
    }
    @
flock ($new_comments,3);
    
fclose($new_comments); 
donde sera exactamente??

no lo leas es demaciado, lo podre en distintos lugares aver donde funciona gracias por tu ayuda :D
  #7 (permalink)  
Antiguo 13/06/2009, 03:57
Avatar de Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: Problema sistema de puntos!

Sin leer demasiado, hay un fwrite(...); debajo un $found = TRUE; ... justo debajo de esa linea, antes de }else{... aunque espero que para cuando veas esto ya lo hayas encontrado.
__________________
- León, Guanajuato
- GV-Foto
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 03:00.