Vincular comentarios...
- POSTEADO POR WAO - Es posible vincular los comentarios con el id de descarga en un pop up y ponerle un contador de comentarios para cada descarga? EJEMPLO: http://www.s*atelliweb.com/index.php?section=livef (sin el asterisco) Este es el sistema de comentarios que estoy utilizando en mi web y este es el script de descargas, esto es lo que he hecho, añadido... [B][COLOR="DarkRed"]form.php (script comentarios):[/COLOR][/B] [PHP]<input type="hidden" name="pageid" id="pageid" value="<?php echo (isset($download_id)) ? $download_id : '0' ?>" /> <?php if (isset($_GET['id']) && !empty($_GET['id'])) { $download_id = mysql_escape_string($_GET['id']); } ?>[/PHP] [B][COLOR="DarkRed"]index.php (script comentarios):[/COLOR][/B] [PHP]<?php /* Insert this for the admin header (optional) */ include_once "canny/admin_header.php"; /* Includes required configuration settings and functions */ include_once "canny/config.php"; include "canny/comments.class.php"; /* Set page id, otherwise leave as null */ $pageid = null; /* Displays comments */ $comments = new comments(); echo $comments->gather_comments(false, $pageid); /* Displays the comment form */ include_once "canny/form.php"; ?> [/PHP] [B][COLOR="DarkRed"]index.php (script descargas):[/COLOR][/B] [HTML]<a href="/comments/"><img src="comments.png" border="0"></a>[/HTML] El sistema de votaciones si he conseguido vincularlo, tengo que añadir codigo en el archivo .sql o en los archivos .php? |
- POSTEADO POR WAO - http://www.mediafire.com/download.php?ej5a87l8480g4cq Ni añadiendo este codigo me funciona en phpmyadmin... ALTER TABLE comments ADD pageid int(10) NOT NULL DEFAULT 0 |
los enlaces no funcionan o no existen los archivos...
de todas formas, en el script form.php, segun lo que has puesto, el valor del input, siempre sera 0...porque "$download_id" no esta definida todavia. Código PHP:
|
- POSTEADO POR WAO - Cita:
http://www.multiupload.com/?d=UOVFC85A http://www.easy-share.com/1912515655/0.rar http://depositfiles.com/es/files/kyy1v1f9i http://www.badongo.com/file/24266069 |
- POSTEADO POR WAO - Este codigo... comments.class.php: [PHP] /* / Relative Date / Time Strings / Credits: Zach Johnson - www.zachstronaut.com / Here we convert a the unix timestamp of when the comment was posted / to a relative time since that original date/time. (ei. xx hours ago) */ public function time_elapsed_string($ptime) { $etime = time() - $ptime; if ($etime < 1) { return '0 segundos'; } $a = array( 12 * 30 * 24 * 60 * 60 => 'año', 30 * 24 * 60 * 60 => 'mes', 24 * 60 * 60 => 'dia', 60 * 60 => 'hora', 60 => 'minuto', 1 => 'segundo' ); foreach ($a as $secs => $str) { $d = $etime / $secs; if ($d >= 1) { $r = round($d); return $r . ' '.$str . ($r > 1 ? 's' : '') . ' '; } } } } [/PHP] lo he traducido del ingles al español, se puede modificar para que en vez de "Posteado por ..... hace x horas..." sea "Posteado por.... el 3 Octubre 2010 @ 15:08 (GMT +2)"? |
yo lo haria asi...
[PHP]public function time_elapsed_string($ptime) { $diaE = Array('Mon'=>'Lunes', 'Tue'=>'Martes', 'Wed'=>'Miércoles', 'Thu'=>'Jueves', 'Fri'=>'Viernes', 'Sat'=>'Sábado', 'Sun'=>'Domingo'); $mesE = Array('Jan'=>'Enero', 'Feb'=>'Febrero', 'Mar'=>'Marzo', 'Apr'=>'Abril', 'May'=>'Mayo', 'Jun'=>'Junio', 'Jul'=>'Julio', 'Aug'=>'Agosto', 'Sep'=>'Septiembre', 'Oct'=>'Octubre', 'Nov'=>'Noviembre', 'Dec'=>'Diciembre'); $dia = date("D, j M Y @ G:i:s (\G\M\T O)", $ptime); $d = date('D', $ptime); $m = date('M', $ptime); $dia = str_replace($d, $diaE[$d], $dia); $dia = str_replace($m, $mesE[$m], $dia); return $dia; } [/PHP] Coke. |
- POSTEADO POR WAO - No funciona (pagina en blanco) e incluso ni añadiendo ni eliminando [B][COLOR="DarkRed"]{[/COLOR][/B]. [B] he cambiado esto...[/B] [PHP] /* / Relative Date / Time Strings / Credits: Zach Johnson - www.zachstronaut.com / Here we convert a the unix timestamp of when the comment was posted / to a relative time since that original date/time. (ei. xx hours ago) */ public function time_elapsed_string($ptime) { $etime = time() - $ptime; if ($etime < 1) { return '0 segundos'; } $a = array( 12 * 30 * 24 * 60 * 60 => 'año', 30 * 24 * 60 * 60 => 'mes', 24 * 60 * 60 => 'dia', 60 * 60 => 'hora', 60 => 'minuto', 1 => 'segundo' ); foreach ($a as $secs => $str) { $d = $etime / $secs; if ($d >= 1) { $r = round($d); return $r . ' '.$str . ($r > 1 ? 's' : '') . ' '; } } } } [/PHP] [B]por esto que me has posteado...[/B] [PHP]public function time_elapsed_string($ptime) { $diaE = Array('Mon'=>'Lunes', 'Tue'=>'Martes', 'Wed'=>'Miércoles', 'Thu'=>'Jueves', 'Fri'=>'Viernes', 'Sat'=>'Sábado', 'Sun'=>'Domingo'); $mesE = Array('Jan'=>'Enero', 'Feb'=>'Febrero', 'Mar'=>'Marzo', 'Apr'=>'Abril', 'May'=>'Mayo', 'Jun'=>'Junio', 'Jul'=>'Julio', 'Aug'=>'Agosto', 'Sep'=>'Septiembre', 'Oct'=>'Octubre', 'Nov'=>'Noviembre', 'Dec'=>'Diciembre'); $dia = date("D, j M Y @ G:i:s (\G\M\T O)", $ptime); $d = date('D', $ptime); $m = date('M', $ptime); $dia = str_replace($d, $diaE[$d], $dia); $dia = str_replace($m, $mesE[$m], $dia); return $dia; } [/PHP] |
el ultimo corchete, tienes que dejarlo.
Coke. |
- POSTEADO POR WAO - Por si sirve de ayuda, en comments.class.php, debajo de esta linea... Código PHP:
Código PHP:
|
por eso no es...puede ser por el corchete del final.
cambia esto... [PHP]public function time_elapsed_string($ptime) { $etime = time() - $ptime; if ($etime < 1) { return '0 segundos'; } $a = array( 12 * 30 * 24 * 60 * 60 => 'año', 30 * 24 * 60 * 60 => 'mes', 24 * 60 * 60 => 'dia', 60 * 60 => 'hora', 60 => 'minuto', 1 => 'segundo' ); foreach ($a as $secs => $str) { $d = $etime / $secs; if ($d >= 1) { $r = round($d); return $r . ' '.$str . ($r > 1 ? 's' : '') . ' '; } } } } [/PHP] por esto... [PHP] public function time_elapsed_string($ptime) { $diaE = array('Mon'=>'Lunes', 'Tue'=>'Martes', 'Wed'=>'Miércoles', 'Thu'=>'Jueves', 'Fri'=>'Viernes', 'Sat'=>'Sábado', 'Sun'=>'Domingo'); $mesE = array('Jan'=>'Enero', 'Feb'=>'Febrero', 'Mar'=>'Marzo', 'Apr'=>'Abril', 'May'=>'Mayo', 'Jun'=>'Junio', 'Jul'=>'Julio', 'Aug'=>'Agosto', 'Sep'=>'Septiembre', 'Oct'=>'Octubre', 'Nov'=>'Noviembre', 'Dec'=>'Diciembre'); $dia = date("D, j M Y @ G:i:s (\G\M\T O)", $ptime); $d = date('D', $ptime); $m = date('M', $ptime); $dia = str_replace($d, $diaE[$d], $dia); $dia = str_replace($m, $mesE[$m], $dia); return $dia; } } [/PHP] Coke. |
- POSTEADO POR WAO - Le he dado reputacion en el numero #6, en el #8 y ultimo mensaje no me ha dejado darle reputacion, he puesto "Creditos: Coke" debajo de "Credits: Zach Johnson - www.zachstronaut.com", ahora si me funciona, gracias a ti, esto es lo que tengo puesto en los archivos por si a alguien le sirve de ayuda, les he quitado los acentos en las palabras Miercoles y Sabado porque me los cambiaba por simbolos raros. comments.class.php: Código PHP:
Código PHP:
Script sexylighbox + demo: http://www.coders.me/ejemplos/sexy-lightbox-2 index.php (wcddl1): Código HTML:
<a href="/comentarios/?TB_iframe=true&height=390&width=773" rel="sexylightbox" class="tooltip" title="COMENTARIOS!"><img src="comentarios.png" border="0"></a> |
prueba esto con los acentos...
Código PHP:
Coke. |
- POSTEADO POR WAO - No te tenias que haber tomado la molestia, no era necesario, ya que no me deja darle mas reputacion (#8, #10 y #12) se la doy en este tema, "De nuevo, muchisimas gracias, por su gran ayuda!", he puesto el ultimo que me ha puesto, este... Código PHP:
|
- POSTEADO POR WAO - Se me olvido decir, ahora si se me ven los acentos en las palabras "Sabado" y "Miercoles". |
Cita:
Coke. |
- POSTEADO POR WAO - Cita:
Cita:
Cita:
* Added support for multiple pages (MySQL Table update required) Run this following query in your MySQL database manager: ALTER TABLE comments ADD pageid int(10) NOT NULL DEFAULT 0 Read the documentation for more on page defining |
pues eso, vete a tu base de datos y haz un query con este codigo...yo cambiaria el nombre del campo...
ALTER TABLE comments ADD downloadid int(10) NOT NULL DEFAULT 0 esto crea un campo nuevo en la tabla comments, es donde tienes que introducir la id de los download. luego busca... Código PHP:
Código PHP:
para recuperar los mensajes de cada descarga... $fecth = mysql_query("SELECT * FROM comments WHERE approval = 'Y' AND downloadid=[valor id de la descarga] ORDER BY IF(parentid = 0, id, parentid) $order, id ASC"); para saber el numero de mensajes de cada descarga... $numero = mysql_num_rows($fetch); resumiendo... index.php... Código PHP:
Código PHP:
[PHP]public function gather_comments($admin, $downId, $bol = false) //añadido $downId y $bol { global $config; $comment = ''; $order = $config['sort']; // check if we're displaying for the admin domain if ($admin) { $fetch = mysql_query("SELECT * FROM comments WHERE approval = 'P' ORDER BY IF(parentid = 0, id, parentid), id ASC"); if (mysql_num_rows($fetch) > 0) { $comment .= '<li><h4>These comments are awaiting your approval:</h4></li>'; } else { $comment .= '<li><h4>There are no pending comments.</h4></li>'; } } else { //------------------------------------- $fetch = mysql_query("SELECT * FROM comments WHERE approval = 'Y' AND downloadid=".$downId." ORDER BY IF(parentid = 0, id, parentid) $order, id ASC"); if($bol) return mysql_num_rows($fetch); //------------------------------------- if (mysql_num_rows($fetch) > 0) { while ($row = mysql_fetch_assoc($fetch)) { $comment .= $this->construct_html_comment($row, $admin); } } else { $comment .= '<li><h3>No comments</h3></li>'; } } return ' <div id="comments-container"> <ul> '.$comment.' </ul> </div> '; } [/PHP] submit.php... [PHP]//------------------------------------------------------------------------------------------ mysql_query("INSERT INTO comments(name,email,website,body,parentid,approval,hash,downloadid) VALUES ( '".$input['name']."', '".$input['email']."', '".$input['website']."', '".$input['body']."', '".$input['parentid']."', '$approval', '".mysql_escape_string($hash)."', '".$input['downloadid']."' )"); //---------------------------------------------------------------------------------------------- [/PHP] bueno, no se si ira bien o no...seguramente no...http://foros.zackyfiles.com/images/smilies/tongue.gif, pero bueno, es complicado sin poder ver en funcionamiento los script. Coke. |
- POSTEADO POR WAO - Dime si es correcto, quiero asegurarme para no meter la gamba hasta el fondo. phpMyAdmin: ALTER TABLE comments ADD downloadid int(10) NOT NULL DEFAULT 0 submit.php (script comentarios): Código PHP:
Código HTML:
<input type="hidden" name="downloadid" id="parentid" value="0" /> [PHP]public function gather_comments($admin, $downId, $bol = false) //añadido $downId y $bol { global $config; $comment = ''; $order = $config['sort']; // check if we're displaying for the admin domain if ($admin) { $fetch = mysql_query("SELECT * FROM comments WHERE approval = 'P' ORDER BY IF(parentid = 0, id, parentid), id ASC"); if (mysql_num_rows($fetch) > 0) { $comment .= '<li><h4>These comments are awaiting your approval:</h4></li>'; } else { $comment .= '<li><h4>There are no pending comments.</h4></li>'; } } else { //------------------------------------- $fetch = mysql_query("SELECT * FROM comments WHERE approval = 'Y' AND downloadid=".$downId." ORDER BY IF(parentid = 0, id, parentid) $order, id ASC"); if($bol) return mysql_num_rows($fetch); //------------------------------------- if (mysql_num_rows($fetch) > 0) { while ($row = mysql_fetch_assoc($fetch)) { $comment .= $this->construct_html_comment($row, $admin); } } else { $comment .= '<li><h3>No comments</h3></li>'; } } return ' <div id="comments-container"> <ul> '.$comment.' </ul> </div> '; } [/PHP] [B]ando perdido con esto que me ha posteado...[/B] [QUOTE]para recuperar los mensajes de cada descarga... $fecth = mysql_query("SELECT * FROM comments WHERE approval = 'Y' AND downloadid=[valor id de la descarga] ORDER BY IF(parentid = 0, id, parentid) $order, id ASC"); para saber el numero de mensajes de cada descarga... $numero = mysql_num_rows($fetch); resumiendo... index.php... [PHP]<?php $fetch_downloads = true; $fetch_order = "id DESC"; include "funcs.php"; //----------------------------------------------------- require "comments.class.php"; $mensajes = new comments(); //----------------------------------------------------- ?>[/PHP] [PHP]<?php foreach($downloads as $dl) { //--------------------------- $num_mens = $mensajes->gather_comments(false, $dl[id], true); //--------------------------- ?>[/PHP] [/QUOTE] |
- POSTEADO POR WAO - En el top del index.php del script wcddl1 o en el index.php del script comentarios? Código PHP:
Cita:
|
en el index del wcddl1, el de comentarios no tiene index, solo en la carpeta admin.
haz una copia de los archivos antes de modificarlos... todo correcto menos... form.php... Código PHP:
..../form.php?downloadid=xxxxx ahora en el form.php... Código PHP:
|
- POSTEADO POR WAO - Perdona, error por mi parte, con tanto codigo me habia hecho un lio, resulta que el fichero demo.php que contiene el script comentarios le cambie el nombre por index.php , en el index.php del script wcddl1 tengo que poner este codigo para que los comentarios se me abran en un pop up (sexylightbox)? Cita:
|
no...tienes que poner algo como esto...
Código PHP:
Coke. |
- POSTEADO POR WAO - Cita:
Cita:
|
- POSTEADO POR COKE - ese es el index de comentarios?... entoces para que quieres las variables "TB_iframe" "width" y "height"?...bueno. Código PHP:
Código PHP:
|
- POSTEADO POR WAO - Cita:
Cita:
Siguiendo todos los pasos que me ha posteado, me funcionara?, voy a bajarme todos los archivos y hacerme una copia de la base de datos, en cuanto lo ponga le comento, tanto si lo ha conseguido como si no, muchisimas gracias, me voy a poner a dar saltos de alegria como lo hallas conseguido, estoy ansioso por terminarla, despues de que halla conseguido vincular el sistema de votaciones espero y deseo que esto tambien se halla conseguido, me habra quedado la web de piiiiiiiiiiiiiiii madre, por cierto, el sistema de comentarios y el script wcddl1 no se parece en nada a mi web y al sistema de comentarios, le he añadido, eliminado, modificado... muchisimas cosas a los 2 scripts hace muchisimo tiempo. |
- POSTEADO POR WAO - Voy a resumirlo todo lo que debo de poner en un solo mensaje para no liarme, si me he equivocado en algo, dimelo porfavor. form.php (script comentarios): Código PHP:
Código PHP:
Cita:
Código PHP:
comment.class.php (script comentarios): [PHP]public function gather_comments($admin, $downId, $bol = false) //añadido $downId y $bol { global $config; $comment = ''; $order = $config['sort']; // check if we're displaying for the admin domain if ($admin) { $fetch = mysql_query("SELECT * FROM comments WHERE approval = 'P' ORDER BY IF(parentid = 0, id, parentid), id ASC"); if (mysql_num_rows($fetch) > 0) { $comment .= '<li><h4>These comments are awaiting your approval:</h4></li>'; } else { $comment .= '<li><h4>There are no pending comments.</h4></li>'; } } else { //------------------------------------- $fetch = mysql_query("SELECT * FROM comments WHERE approval = 'Y' AND downloadid=".$downId." ORDER BY IF(parentid = 0, id, parentid) $order, id ASC"); if($bol) return mysql_num_rows($fetch); //------------------------------------- if (mysql_num_rows($fetch) > 0) { while ($row = mysql_fetch_assoc($fetch)) { $comment .= $this->construct_html_comment($row, $admin); } } else { $comment .= '<li><h3>No comments</h3></li>'; } } return ' <div id="comments-container"> <ul> '.$comment.' </ul> </div> '; } [/PHP] [B]submit.php (script comentarios):[/B] [PHP]mysql_query("INSERT INTO comments(name,email,website,body,parentid,approval,hash,downloadid) VALUES ( '".$input['name']."', '".$input['email']."', '".$input['website']."', '".$input['body']."', '".$input['parentid']."', '$approval', '".mysql_escape_string($hash)."', '".$input['downloadid']."' )"); [/PHP] [B]phpMyAdmin:[/B] ALTER TABLE comments ADD downloadid int(10) NOT NULL DEFAULT 0 [B]comments.class.php (script comentarios):[/B] [PHP]<div style="color:000000;font-size:11px;font-family:verdana;position:relative;top:17px;left:90px;"><h5>Posteado por '.$begin_a.$row['name'].$end_a.' el '.$timestamp.' (GMT +2)</div> /* / Relative Date / Time Strings / Credits: Zach Johnson - www.zachstronaut.com / Creditos: Coke / Here we convert a the unix timestamp of when the comment was posted / to a relative time since that original date/time. (ei. xx hours ago) */ public function time_elapsed_string($ptime) { $diaE = array('Mon'=>'Lunes', 'Tue'=>'Martes', 'Wed'=>'Miércoles', 'Thu'=>'Jueves', 'Fri'=>'Viernes', 'Sat'=>'Sábado', 'Sun'=>'Domingo'); $mesE = array('Jan'=>'Enero', 'Feb'=>'Febrero', 'Mar'=>'Marzo', 'Apr'=>'Abril', 'May'=>'Mayo', 'Jun'=>'Junio', 'Jul'=>'Julio', 'Aug'=>'Agosto', 'Sep'=>'Septiembre', 'Oct'=>'Octubre', 'Nov'=>'Noviembre', 'Dec'=>'Diciembre'); $dia = date("D, j M Y @ G:i", $ptime); $d = date('D', $ptime); $m = date('M', $ptime); $fecha = str_replace(array($d, $m), array($diaE[$d], $mesE[$m]), $dia); return $fecha; } } [/PHP] |
no se si funcionara, no lo puedo probar...pero ten en cuenta una cosa, por ejemplo, esto...
Código PHP:
Coke. |
el index.php (script wcddl1) es...
Código PHP:
Código PHP:
Coke. |
Cita:
Código HTML:
<a href="/comentarios/?downloadid=<?php echo $dl[id];?>&TB_iframe=true&height=390&width=773" rel="sexylightbox" class="tooltip" title="COMENTARIOS!"><img Código PHP:
Código PHP:
DEMO: http://www.google.com/buzz/api/admin/configPostWidget |
este codigo..
Código PHP:
Código PHP:
lo unico que yo he añadido a ese bucle es... [PHP] //-------------------------- $num_mens = $mensajes->gather_comments(false, $dl[id], true); //-------------------------- [/PHP] lo demas es original. Coke. |
Gracias Coke, ahora si me ha quedado claro (el ultimo mensaje que me ha posteado), me he bajado todos los archivos por ftp y copia de la base de datos esta tarde, voy a cerrar mi web por si la cago, en cuanto lo halla puesto todo los codigos que me ha posteado, subido por ftp y probado, le comento en este tema.
|
Le doy las gracias por su grandisima ayuda, por todo lo que ha posteado, por aguantarme..., le felicito, eres un genio, ha conseguido lo que otros no han sido capaces de conseguir, enhorabuena, eres mi idolo.
Le explico, he estado probandolo, has conseguido vincular los comentarios con el id de descarga, ahora viene la mala noticia, no se me ve el contador y las descargas se me repiten en cada pagina, me voy a explicar para que se me entienda mejor, en la pagina 1 la descarga se me repite 5 veces, en la pagina 2 otra descarga se me repite 5 veces, etc... |
la duplicidad de las descargas puede ser por el bucle...
Código PHP:
Código PHP:
Código PHP:
|
Me salio una pagina en blanco, esto fue lo que puse al principio en index.php (wcddl1)...
Código PHP:
[PHP]<?php foreach($downloads as $dl) { //-------------------------- $num_mens = $mensajes->gather_comments(false, $dl[id], true); //-------------------------- } ?> [/PHP] lo tengo puesto asin... [PHP]<?php foreach($downloads as $dl) { //-------------------------- $num_mens = $mensajes->gather_comments(false, $dl[id], true); //-------------------------- } ?> <a href="/comentarios/?downloadid=<?php echo $dl[id];?>&TB_iframe=true&height=390&width=773" rel="sexylightbox" class="tooltip" title="COMENTARIOS!"><img src="comentarios.png" border="0"></a>[/php] |
Cita:
|
Otra buena noticia he de darle, ha conseguido que se me vea el contador, gracias Coke, una cosita (repeticion de descargas) nos falta por solucionar.
|
a ver...el bucle orignal es asi...
Código PHP:
no se como lo tendrias tu antes de modificarlo...lo que te digo, es que pongas el tuyo, el que tenias antes y la agregues Código PHP:
Coke. |
Gracias a su grandisima ayuda ha conseguido que mi web al fin todo funcione y se halla terminado, ha conseguido tambien que yo sea feliz, que la web halla quedado de piiiiiiiiiiii madre..., en cuanto ponga el gif (caja de color gris) de google buzz para el contador, la abro, si me necesitas, no dudes ni un segundo en pedirme ayuda, no sea timido, pidame toda la ayuda que necesite.
el bucle original no lo he tocado... Código PHP:
Código PHP:
Código PHP:
|
de nada...me alegro que todo funcione bien.
un saludo. Coke. |
Cita:
este es el resultado final de como lo tengo puesto en el index.php (script wcddl1)... Código PHP:
|
La franja horaria es GMT +2. Ahora son las 06:58. |
Powered por vBulletin™ Version 3.8.10
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.
Traducido por vBsoporte - vBulletin en español
ZackYFileS - Foros de Debate