Re: consulta mysql
Publicado: 04 Ene 2013, 21:25
Aja todo aclarado voy a probar...
phpBB España Oficial, Soporte Internacional Oficial del sistema de foros phpBB en Español, extensiones, estilos, traducciones, guías, tutoriales, videos, redes sociales, webmaster.
https://www.phpbb-es.com/foro/
Qué? es que después de todo, ni siquiera nos has mostrado que es lo que estas haciendo.rafaxplayer escribió:Probado, funciona correctamente... solo por rizar el rizo decir que se situa en la ultima pagina de post pero el scroll arriba y no al final XD , es esto mucho pedir?
Cierto, lo siento...Alorse escribió:Qué? es que después de todo, ni siquiera nos has mostrado que es lo que estas haciendo.rafaxplayer escribió:Probado, funciona correctamente... solo por rizar el rizo decir que se situa en la ultima pagina de post pero el scroll arriba y no al final XD , es esto mucho pedir?
Código: Seleccionar todo
<?php
header("Expires: Sun, 19 Nov 1978 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
include("config.php");
mysql_select_db($dbname,mysql_connect($dbhost,$dbuser,$dbpasswd));
$userdata = mysql_fetch_array(mysql_query("SELECT * FROM phpbb_users WHERE username_clean='".mysql_real_escape_string(strtolower($_GET['id']))."' LIMIT 1"));
if ($userdata!=false) {
$query = mysql_query("SELECT t.topic_id, t.topic_last_post_time, tt.mark_time as topic_mark_time, ft.mark_time as forum_mark_time
FROM (phpbb_topics t) LEFT JOIN phpbb_topics_track tt
ON (tt.user_id = " . $userdata['user_id'] . "
AND t.topic_id = tt.topic_id) LEFT JOIN phpbb_forums_track ft
ON (ft.user_id = " . $userdata['user_id'] . "
AND t.forum_id = ft.forum_id) WHERE t.topic_last_post_time > " . $userdata['user_lastvisit'] ."
AND(
(tt.mark_time IS NOT NULL AND t.topic_last_post_time > tt.mark_time) OR
(tt.mark_time IS NULL AND ft.mark_time IS NOT NULL AND t.topic_last_post_time > ft.mark_time) OR
(tt.mark_time IS NULL AND ft.mark_time IS NULL)
)
AND t.topic_moved_id = 0 ");
$fi=0;
while ($data=mysql_fetch_array($query)) {
$query2=mysql_query("SELECT post_id FROM phpbb_posts WHERE topic_id='".$data["topic_id"]."' AND post_time > '".$userdata['user_lastvisit']."'");
while ($data2=mysql_fetch_array($query2)) {
$fi++;
}
}
}else{
$fi=0;
}
echo $fi;
?>
Código: Seleccionar todo
<html><head><title>AMSSpecialist</title>
<style>
a:link {
color: #666;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #666;
}
a:hover {
text-decoration: none;
color: #666;
}
a:active {
text-decoration: none;
color: #666;
}
body,td,th {
font-family: Verdana, Geneva, sans-serif;
font-size: 10px;
}
</style>
</head>
<body style="background-color:#e9e9e9; margin:0px; padding:0px; font: Verdana 10px;">
<?php
include("config.php");
mysql_select_db($dbname,mysql_connect($dbhost,$dbuser,$dbpasswd));
$userdata = mysql_fetch_array(mysql_query("SELECT * FROM phpbb_users WHERE username_clean='".mysql_real_escape_string(strtolower($_GET['id']))."' LIMIT 1"));
if ($userdata!=false) {
$query = mysql_query("SELECT t.topic_title, t.topic_id, t.topic_last_poster_name, t.topic_last_post_id, t.topic_last_post_time, t.forum_id, tt.mark_time as topic_mark_time, ft.mark_time as forum_mark_time
FROM (phpbb_topics t) LEFT JOIN phpbb_topics_track tt
ON (tt.user_id = " . $userdata['user_id'] . "
AND t.topic_id = tt.topic_id) LEFT JOIN phpbb_forums_track ft
ON (ft.user_id = " . $userdata['user_id'] . "
AND t.forum_id = ft.forum_id) WHERE t.topic_last_post_time > " . $userdata['user_lastvisit'] ."
AND(
(tt.mark_time IS NOT NULL AND t.topic_last_post_time > tt.mark_time) OR
(tt.mark_time IS NULL AND ft.mark_time IS NOT NULL AND t.topic_last_post_time > ft.mark_time) OR
(tt.mark_time IS NULL AND ft.mark_time IS NULL)
)
AND t.topic_moved_id = 0 ");
while ($data=mysql_fetch_array($query)) {
$query2=mysql_query("SELECT post_id FROM phpbb_posts WHERE topic_id='".$data["topic_id"]."' AND post_time > '".$userdata['user_lastvisit']."'");
$fi=0;
while ($data2=mysql_fetch_array($query2)) {
$fi++;
}
echo "<div style='position:relative; width:500px; height:20px; overflow:hidden; background:url(bjk.png) no-repeat;'>";
echo "<div style='position:absolute; left:7px; top:3px; color:#fff; font-weight:bold;'>".$fi."</div>";
echo "<div style='position:absolute; left:24px; top:3px;'><a href='http://www.amsspecialist.com/viewtopic.php?f=".$data["forum_id"]."&t=".$data["topic_id"]."&p=".$data["topic_last_post_id"]."#p=".$data["topic_last_post_id"]."' target='_blank'><b>".$data["topic_title"]."</b></a></div>";
echo "<div style='position:absolute; left:410px; top:3px; color:#0b75e0;'>".$data["topic_last_poster_name"]."</div>";
echo "</div>";
}
} else{
echo 'No user data, use RSS';
}
?>
</body>
</html>
Si se sitúa en la pagina que es y al final tiene el #p, debería situarse exactamente en el mensaje que corresponde, no arriba ni al final, aunque si el mensaje es el primero pues si se situa al principio.rafaxplayer escribió:se situa en la ultima pagina de post pero el scroll arriba y no al final
Si claro, requiere la id del mensaje (post) para poder que lo ubique en el.rafaxplayer escribió:supongo que #p requiere la id del post, no?.
Pues no hace lo dichoAlorse escribió:Si claro, requiere la id del mensaje (post) para poder que lo ubique en el.rafaxplayer escribió:supongo que #p requiere la id del post, no?.
import
al archivo includes/functions.php del foro y llama la función get_unread_topics()
a la cual debes pasarle 4 parámetros, $userdata['user_id']
, $sql_extra
, $sql_sort
y $sql_limit
, estos últimos 3 ya los tienes, serian:
Código: Seleccionar todo
$sql_extra = 'AND t.topic_moved_id = 0';
$sql_sort = 'ORDER BY t.topic_last_post_time DESC';
$sql_limit = 10;
Código: Seleccionar todo
$fi = get_unread_topics($userdata['user_id'], $sql_extra, $sql_sort, $sql_limit);
Código: Seleccionar todo
var NEWPOST={color:[12,180,37,255]};
var NOPOST={color:[255, 0, 0, 255]};
chrome.browserAction.setBadgeBackgroundColor(NOPOST);
seticon();
function setbadge(num){
if (parseInt(num)>0){
chrome.browserAction.setBadgeBackgroundColor(NEWPOST);
}
else{
chrome.browserAction.setBadgeBackgroundColor(NOPOST);
}
chrome.browserAction.setBadgeText({text:num});
}
function seticon(){
nowDate = new Date();
if((nowDate.getMonth()== 0 && nowDate.getDate()<= 7) || (nowDate.getMonth()== 11 && nowDate.getDate() > 23 )){
chrome.browserAction.setIcon({"path":"images/amssp_navidad.png"});
localStorage.icon="images/amssp_navidad.png"
}else{chrome.browserAction.setIcon({"path":"images/amssp.png"});
localStorage.icon="images/amssp.png"}
}
function playSound(soundUrl){
var sound = new Audio(soundUrl);
if(sound && JSON.parse(localStorage.PlaySounds)){
sound.play();
}
}
var req = new XMLHttpRequest();
function getlastpost(){
if (req != null) {
req.open(
"GET",
"http://www.amsspecialist.com/unread_count.php?id=" + localStorage.user,
true);
req.onreadystatechange = show;
req.send(null);
}else{
localStorage.numpost = 0;
setbadge(localStorage.numpost);
}
window.setTimeout(function(){getlastpost();},5000);
}
function show(){
if (req.readyState == 4 ) {
if (req.status == 200) {
localStorage.numpost=(isNaN(parseInt(req.responseText)) || req.responseText =='undefined' ? 0 : parseInt(req.responseText));
setbadge(localStorage.numpost);
//chrome.browserAction.setBadgeText({text:localStorage.numpost});
Notifishow(localStorage.numpost);
localStorage.lastnumpost=localStorage.numpost;
}
}
}
function Notifishow(num) {
var post = (num-localStorage.lastnumpost);
var notification = window.webkitNotifications.createNotification(
'images/amssp.png',
chrome.i18n.getMessage('new_post'),
chrome.i18n.getMessage('new_post_public').replace('#',post)
);
if ( num > localStorage.lastnumpost){
if(JSON.parse(localStorage.Notify)){
notification.ondisplay = playSound('sounds/Mouth.mp3');
//notification.onclick = playSound('sounds/Boop.ogg');
notification.show();
if(JSON.parse(localStorage.NotifyHidde)){
window.setTimeout(function(){notification.close();},15000);
}
}
}
}
getlastpost();