← phpBB

Ultimas no forum - PHPbb

Lida 3001 vezes

Offline

Bruno Mota 
Membro
Mensagens 1733 Gostos 3
Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

Alguem tem o script para aparcer as ultima do forum na pagina?
Offline

asturmas 
Administrador
Mensagens 19734 Gostos 49
Feedback +2

Troféus totais: 39
Trófeus: (Ver todos)
Mobile User Windows User Super Combination Combination Topic Starter 100 Poll Votes 50 Poll Votes 10 Poll Votes Poll Voter Poll Starter

tambem keria isso  :lol:
Offline

cenourinha 
Elite
Mensagens 4094 Gostos 21
Troféus totais: 34
Trófeus: (Ver todos)
Mobile User Apple User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4

Offline

asturmas 
Administrador
Mensagens 19734 Gostos 49
Feedback +2

Troféus totais: 39
Trófeus: (Ver todos)
Mobile User Windows User Super Combination Combination Topic Starter 100 Poll Votes 50 Poll Votes 10 Poll Votes Poll Voter Poll Starter

tks
o codigo ke la vem e pa por num ficheiro php?
cumps
Offline

cenourinha 
Elite
Mensagens 4094 Gostos 21
Troféus totais: 34
Trófeus: (Ver todos)
Mobile User Apple User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4

Diz ai o que vem la sff!
Offline

asturmas 
Administrador
Mensagens 19734 Gostos 49
Feedback +2

Troféus totais: 39
Trófeus: (Ver todos)
Mobile User Windows User Super Combination Combination Topic Starter 100 Poll Votes 50 Poll Votes 10 Poll Votes Poll Voter Poll Starter

Código: [Seleccione]
<?
/**
* Mod Title:   Latest posts/topics
* Mod Version: phpBB 2.0
* Author:      Pegas (pegas@ami.cz) (originally made by ?, previous version by LiLCoolboy (M@urice Cheung))
* Description: Shows latest posts or topics on any page, 2 optional parameters
* Release:     v3.0, 27.01.2003
***
* DeMo:                http://kocky-online.cz (Czech language)
* Installation Level:  Easy
* Installation Time:   5 minutes
* Files To Edit:       0
* Included Files:      (if necessary)
***
* Installation Notes:
* Put this code into new file, set $serverPath and $urlPath,
* upload this file onto server and include into your page and you are done!
*   -- OR --
* Put this code into your page, set $serverPath and $urlPath,
* and you are done!
***
* Parameters:
* There are 2 optional parameters when calling this code as standalone file via include!
* type - whether to show topics or posts
*   type=posts  - posts [default when missing]
*   type=topics - topics
* count - how much posts/topics show
*   count=# [default is 3]
***
* Examples (assume that your file with this code is hilites.php):
* hilites.php?type=topics&count=5
*  - shows latest 5 topics
* hilites.php?type=topics
*  - shows latest 3 topics
* hilites.php
*  - shows latest 3 posts
***
* Revision:
* v1.0
*  author: ?
* v2.0
*  author: LiLCoolboy (M@urice Cheung)
*  - not working without significant changes, mistypes
* v3.0
*  author: Petr Gasparik
*  + added parameters when called as standalone file
*  + posts/topics selection corrected
*  + corrected mistypes
*/
$urlPath = "ABSOLUTE_PATH_OF_YOUR_FORUM"; //example: if your forum URL looks like http://kocky-online.cz/forum, this should be "/forum"
$serverPath = "PATH_TO/config.php"; //example: when this file is in URL path /forum/mod, this should be ../config.php
if(empty($count))
$count = "3"; //default value of how many posts/topics to show
if(empty($type))
$type = "posts"; //default value of whether to show 'posts' or 'topics'
$titleLimit = 30; //this is max.length of 'title' of topic/post
$moreLimit = 20; //this is max.length of 'more' (used in posts)

//-----------------[ DO NOT EDIT BELOW HERE ]-------------------------
include_once("$serverPath");
$db = @mysql_connect("$dbhost", "$dbuser", "$dbpasswd") or die("here we die at connection");
@mysql_select_db("$dbname",$db) or die("here we die");

if($type == "posts")
{
$prefix = 'p';
   $sql = "SELECT x.post_subject as title, p.post_id as id, f.forum_id, t.topic_title as more "
    ."FROM ${table_prefix}topics t, ${table_prefix}forums f, ${table_prefix}posts p, ${table_prefix}posts_text x "
    ."WHERE t.topic_id = p.topic_id AND f.forum_id = t.forum_id AND p.post_id = x.post_id "
    ."ORDER BY p.post_id DESC "
    ."LIMIT $count";
}
else
{
$prefix = 't';
   $sql = "SELECT t.topic_title as title, t.topic_id as id, f.forum_id, '' as more "
    ."FROM ${table_prefix}topics t, ${table_prefix}forums f "
    ."WHERE f.forum_id = t.forum_id "
    ."ORDER BY topic_time DESC "
    ."LIMIT $count";
}

//echo $sql;

if($r = mysql_query($sql, $db)) {
while($m = mysql_fetch_array($r)) {
$j = stripslashes($m[title]);
$k = substr($j, 0, $titleLimit) . "...";
if(!empty($m[more]))
$m[more] = '('.substr($m[more], 0, $moreLimit) . '...)';
if ($type == 'posts') {
$anchor = '#'.$m[id];
}
//-------------------[ THIS IS ONLY LINE YOU COULD CHANGE ]--------------------------
echo "<a title=\"$m[title]\" href=\"$urlPath/viewtopic.php?${prefix}=$m[id]&sid=$m[forum_id]${anchor}\">$k</a> $m[more]<br>";
}
}
/
//-------------------[ DO NOT EDIT UP HERE ]--------------------------
?>



E isso
Offline

cenourinha 
Elite
Mensagens 4094 Gostos 21
Troféus totais: 34
Trófeus: (Ver todos)
Mobile User Apple User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4

<?php
$urlPath = "ABSOLUTE_PATH_OF_YOUR_FORUM";   //example: if your forum URL looks like http://kocky-online.cz/forum, this should be "/forum"
$serverPath = "PATH_TO/config.php";         //example: when this file is in URL path /forum/mod, this should be ../config.php
if(empty($count))
   $count = "3";                           //default value of how many posts/topics to show
if(empty($type))
   $type = "posts";      //default value of whether to show 'posts' or 'topics'
$titleLimit = 30;         //this is max.length of 'title' of topic/post
$moreLimit = 20;         //this is max.length of 'more' (used in posts)

//-----------------[ DO NOT EDIT BELOW HERE ]-------------------------
include_once("$serverPath");
$db = @mysql_connect("$dbhost", "$dbuser", "$dbpasswd") or die("here we die at connection");
@mysql_select_db("$dbname",$db) or die("here we die");

if($type == "posts")
{
   $prefix = 'p';
   $sql = "SELECT x.post_subject as title, p.post_id as id, f.forum_id, t.topic_title as more "
         ."FROM ${table_prefix}topics t, ${table_prefix}forums f, ${table_prefix}posts p, ${table_prefix}posts_text x "
         ."WHERE t.topic_id = p.topic_id AND f.forum_id = t.forum_id AND p.post_id = x.post_id "
         ."ORDER BY p.post_id DESC "
         ."LIMIT $count";
}
else
{
   $prefix = 't';
   $sql = "SELECT t.topic_title as title, t.topic_id as id, f.forum_id, '' as more "
         ."FROM ${table_prefix}topics t, ${table_prefix}forums f "
         ."WHERE f.forum_id = t.forum_id "
         ."ORDER BY topic_time DESC "
         ."LIMIT $count";
}

//echo $sql;

if($r = mysql_query($sql, $db)) {
   while($m = mysql_fetch_array($r)) {
      $j = stripslashes($m[title]);
      $k = substr($j, 0, $titleLimit) . "...";
      if(!empty($m[more]))
         $m[more] = '('.substr($m[more], 0, $moreLimit) . '...)';
      if ($type == 'posts') {
         $anchor = '#'.$m[id];
      }
      //-------------------[ THIS IS ONLY LINE YOU COULD CHANGE ]--------------------------
      echo "<a title=\"$m[title]\" href=\"$urlPath/viewtopic.php?${prefix}=$m[id]&sid=$m[forum_id]${anchor}\">$k</a> $m[more]<br>";
   }
}
/
//-------------------[ DO NOT EDIT UP HERE ]--------------------------
?>







Só tens de por isso!
Offline

raugusto 
Elite
Mensagens 3145 Gostos 33
Feedback +13

Troféus totais: 31
Trófeus: (Ver todos)
Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

eu usei um script destes durante algum tempo. Depois retirei porque como o meu site tinha muitos acessos isso esgotava a tabela de sessoes. Depois retirei e fiz uma alteração no codigo e nunca mais tive esse problema. Mas se notarem alguma coisa vejam se não será isso.
Offline

Flash005 
Membro
Mensagens 1360 Gostos 0
Troféus totais: 33
Trófeus: (Ver todos)
Quick Poster Windows User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4

Citação de: "raugusto"
eu usei um script destes durante algum tempo. Depois retirei porque como o meu site tinha muitos acessos isso esgotava a tabela de sessoes. Depois retirei e fiz uma alteração no codigo e nunca mais tive esse problema. Mas se notarem alguma coisa vejam se não será isso.

O servidor tinha limite de queries?

Como tens no footer as estatisticas da BD tem em atenção ao aumento de "Pedidos SQL" pois se houver um limite para nº de SQL queries vais ter o site empenado com a treta do limite de SQL queries ultrapassado, se bem que também tenho solução para isso  8)  :P

ps: isto já para não falar que terás o fórum extremamente mais lento  :roll: