Foros del Web » Programando para Internet » PHP »

error en un .php

Estas en el tema de error en un .php en el foro de PHP en Foros del Web. Hola a todos! Es la primera vez que entro en el foro... a ver si alguien , por favor, me puede ayudar en este error ...
  #1 (permalink)  
Antiguo 07/09/2005, 04:57
 
Fecha de Ingreso: septiembre-2005
Mensajes: 9
Antigüedad: 18 años, 7 meses
Puntos: 0
error en un .php

Hola a todos!
Es la primera vez que entro en el foro... a ver si alguien , por favor, me puede ayudar en este error (soy novato en esto de PHP) .
Gracias de antemano!
Se trata de un contador de descargas y hay un archivo que me dá un error:

Archivo >> click.php

Error >> Invalid ID, numbers (0-9) only!



Código:
__________________________________________________
<?php
# PHP click counter (CCount)
# Version: 1.1
# File name: click.php
# Written 22nd January 2005 by Klemen Stirn ([email protected])
# http://www.PHPJunkYard.com

################################################## ############################
# COPYRIGHT NOTICE #
# Copyright 2004-2005 PHPJunkYard All Rights Reserved. #
# #
# The CCount may be used and modified free of charge by anyone so long as #
# this copyright notice and the comments above remain intact. By using this #
# code you agree to indemnify Klemen Stirn from any liability that might #
# arise from it's use. #
# #
# Selling the code for this program without prior written consent is #
# expressly forbidden. In other words, please ask first before you try and #
# make money off this program. #
# #
# Obtain permission before redistributing this software over the Internet or #
# in any other medium. In all cases copyright and header must remain intact. #
# This Copyright is in full effect in any country that has International #
# Trade Agreements with the United States of America or with #
# the European Union. #
################################################## ############################

#############################
# DO NOT EDIT BELOW #
#############################

error_reporting(E_ALL ^ E_NOTICE);

// Get settings from the settings.php file
require "settings.php";

// First check if the ID is set and if it is valid (contains nothing but numbers)
$id=$_GET['id'];
if(empty($id) || preg_match("/\D/",$id)) {die("Invalid ID, numbers (0-9) only!");}

// Different systems use different line endings
if($settings['system'] == 2) {$newline="\r\n";}
elseif($settings['system'] == 3) {$newline="\r";}
else {$newline="\n";}

// Get lines from file
$lines=file($settings['logfile']);

// Let's found the line that starts with our ID number
$found=0;
$i=0;
foreach ($lines as $thisline) {
if (preg_match("/^($id\%\%)/",$thisline)) {
$thisline=chop($thisline);
// We found the line, now we get URL and count from the line
list($id,$added,$url,$count,$name)=explode("%%",$t hisline);
// Increase count by 1 and update this line
$count++;
$lines[$i]=$id."%%".$added."%%".$url."%%".$count."%%".$name. $newline;
$found=1;
break;
}
// This line didn't start with ID, lets go to the next one
$i++;
}
if($found != 1) {die("This ID doesn't exist!");}

// Rewrite the log file with the updated line
$content = implode('', $lines);
$fp = fopen($settings['logfile'],"wb") or die("Can't write to log file! Please Change the file permissions (CHMOD to 666 on UNIX machines!)");
fputs($fp,$content);
fclose($fp);

// Redirect to the link URL
Header("Location: $url");
exit();
?>
  #2 (permalink)  
Antiguo 07/09/2005, 08:58
 
Fecha de Ingreso: septiembre-2005
Mensajes: 9
Antigüedad: 18 años, 7 meses
Puntos: 0
Bueno quizás he hecho mal la pregunta y el problema sea otro.
Como podeis ver en la imagen, los clicks están a "0".
El problema que tengo es que aunque haga el click en las "Web page" y estos enlaces se abran correctamente, el contador de los clicks no sube.
No lo pregunto en la web de donde bajé todo porque es en ingles y no entiendo nada.
Gracias!


Última edición por Santitg; 07/09/2005 a las 09:05
  #3 (permalink)  
Antiguo 07/09/2005, 12:18
 
Fecha de Ingreso: septiembre-2005
Mensajes: 9
Antigüedad: 18 años, 7 meses
Puntos: 0
Estos son todos los archivos de contador:
click.php
clicks.txt
display.php
settings.php
index.php
ids.txt

Creo que el problema (que no sé como solucionar ) está en la lectura del clicks.txt
Si cambio lo datos (manualmente) en este clicks.txt..entonces si sube el contador de Web page

Última edición por Santitg; 07/09/2005 a las 12:41
  #4 (permalink)  
Antiguo 07/09/2005, 14:44
 
Fecha de Ingreso: septiembre-2005
Mensajes: 9
Antigüedad: 18 años, 7 meses
Puntos: 0
Bueno..mientras alguien se decide a decirme algo, yo iré añadiendo las pistas que encuentre:

Estas líneas de abajo (del click.php) son las que deberían incrementar automáticamente el contador..¿poqué no lo hacen?...¿porqué no se reflejan en el clicks.txt ?
__________________________________________________ ___________

// Let's found the line that starts with our ID number
$found=0;
$i=0;
foreach ($lines as $thisline) {
if (preg_match("/^($id\%\%)/",$thisline)) {
$thisline=chop($thisline);
// We found the line, now we get URL and count from the line
list($id,$added,$url,$count,$name)=explode("%%",$t hisline);
// Increase count by 1 and update this line
$count++;
$lines[$i]=$id."%%".$added."%%".$url."%%".$count."%%".$name. $newline;
$found=1;
break;
_______________________________________

Este es el contenido del clicks.txt:
__________________________________________________ ___________

1%%2005/09/07%%http://www.tutorialgames.net/hacha.zip%%0%%
2%%2005/09/07%%http://www.tutorialgames.net%%1%%TutorialGames
3%%2005/09/07%%http://www.tutorialgames.net%%0%%
__________________________________________________ ___________

El %%1%% lo he puesto manualmente (esto sería trampa ).
Creo que el clicks.txt está solo de escritura y no de lectura...?
  #5 (permalink)  
Antiguo 07/09/2005, 18:35
 
Fecha de Ingreso: septiembre-2005
Mensajes: 9
Antigüedad: 18 años, 7 meses
Puntos: 0
Bueno, no he podido solucionar el problema. Dejo aquí el "readme" que tengo para la instalación.
Si alguien sabe inglés y me puede ayudar, le estaré muy agradecido.
Yo uso WindowXP home.

readme.htm

Última edición por Santitg; 07/09/2005 a las 18:45
  #6 (permalink)  
Antiguo 07/09/2005, 18:44
 
Fecha de Ingreso: mayo-2005
Mensajes: 38
Antigüedad: 18 años, 11 meses
Puntos: 0
Hola Santitg bueno parece que el problema no es el codigo, sino es que tu no le estas pasando a "id" un valor ya que en esta linea

// First check if the ID is set and if it is valid (contains nothing but numbers)
$id=$_GET['id'];
if(empty($id) || preg_match("/\D/",$id)) {die("Invalid ID, numbers (0-9) only!");}

verifica si "id" esta vacia, y cuando lo esta te lanza el error que decias tu Invalid ID, numbers (0-9) only!".
para pasarle el valor creo que deberia ser asi a travez de un link

www.tupagina.com/click.php?id=y aki le das un valor osea un numero entonces quedaria asi por ejemplo
www.tupagina.com/click.php?id=1

espero haberte ayudado de algo.
Saludos.
  #7 (permalink)  
Antiguo 07/09/2005, 18:54
 
Fecha de Ingreso: septiembre-2005
Mensajes: 9
Antigüedad: 18 años, 7 meses
Puntos: 0
Gracias por la respuesta Clo , voy a probar lo que me dices.
Un saludo
  #8 (permalink)  
Antiguo 07/09/2005, 19:14
 
Fecha de Ingreso: septiembre-2005
Mensajes: 9
Antigüedad: 18 años, 7 meses
Puntos: 0
He puesto esta línea:
http://www.tutorialgames.net/ccount/click.php['id']==1

__________________________________________________ __________________
// First check if the ID is set and if it is valid (contains nothing but numbers)
$id=$_GET['id'];
http://www.tutorialgames.net/ccount/click.php['id']==1
if(empty($id) || preg_match("/\D/",$id)) {die("Invalid ID, numbers (0-9) only!");}
__________________________________________________ ____________________

La he escrito ya de varias formas pero siempre me dá el siguiente error:

Parse error: parse error, unexpected T_STRING in /data/members/paid/t/u/tutorialgames.net/htdocs/www/ccount/click.php on line 3
  #9 (permalink)  
Antiguo 07/09/2005, 19:29
Avatar de luistar  
Fecha de Ingreso: marzo-2005
Ubicación: Argentina
Mensajes: 939
Antigüedad: 19 años, 1 mes
Puntos: 0
if(empty($id) || preg_match("/\D/",$id)) {die("Invalid ID, numbers (0-9) only!");}
con esta linea compruebas que $id existe y no esta vacío y que sólo contiene números?
puedes usar ereg para verificar...
intenta reemplazando ese xodigo con este:
if(empty($id) || ereg("^[0-9]",$id)) {die("Invalid ID, numbers (0-9) only!");}
  #10 (permalink)  
Antiguo 07/09/2005, 19:40
 
Fecha de Ingreso: septiembre-2005
Mensajes: 9
Antigüedad: 18 años, 7 meses
Puntos: 0
He hecho esto:

// First check if the ID is set and if it is valid (contains nothing but numbers)
$id=$_GET['id'];
if(empty($id) || ereg("^[0-9]",$id)) {die("Invalid ID, numbers (0-9) only!");}

//if(empty($id) || preg_match("/\D/",$id)) {die("Invalid ID, numbers (0-9) only!");}


Pero me sigue dando el mismo error:

Parse error: parse error, unexpected T_STRING in /data/members/paid/t/u/tutorialgames.net/htdocs/www/ccount/click.php on line 3


readme.htm


Puede ser algún espacio o caracter mal puesto ??

Última edición por Santitg; 07/09/2005 a las 19:52
  #11 (permalink)  
Antiguo 09/09/2005, 01:40
 
Fecha de Ingreso: septiembre-2005
Mensajes: 9
Antigüedad: 18 años, 7 meses
Puntos: 0
Aporto un nuevo dato:

Si pongo esta URL en el navegador:
http://www.tutorialgames.net/ccount/display.php

El resultado es :
var ccount_link = new Array(); ccount_link[]=; function ccount_display(id) { document.write(ccount_link[id]); }

Saludos y gracias !
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 01:32.