Ultime dal forum in home page...

Arieccomi qui ;D volevo chiedere se è possibile inserire gli ultimi post inseriti sul forum sulla home page del sito...

Una cosa del genere esiste per phpnuke collegato con phpBB2... io sul mio sito ho phpBB2 così mi sono scaricato il blocco per vedere le news in home page sui portali nuke: ecco qui il codice:

<?php

/************************************************************************************/
/*                                                                                  */
/* CENTER BLOCK: block-phpBB_Forums.php                                             */
/* For PHP-Nuke 6.5 +                                                               */
/* v1.5  06-04-2003                                                                 */
/*                                                                                  */
/* by: Guasila.com (info@guasila.com)                                              */
/* http://www.guasila.com                                                           */
/*                                                                                  */
/* This program is free software. You can redistribute it and/or modify             */
/* it under the terms of the GNU General Public License as published by             */
/* the Free Software Foundation; either version 2 of the License.                   */
/*                                                                                  */
/************************************************************************************/


if( eregi( "block-phpBB_Forums.php", $_SERVER['PHP_SELF'])) {
   Header("Location: index.php");
   die();
}

global $prefix, $user_prefix, $db, $sitename, $bgcolor1, $bgcolor2;


/**********************************/
/*                                */
/* Configuration parameters       */
/*                                */
/**********************************/
// When set to 1 then Forums permissions which View and/or Read are NOT set to 'ALL' will NOT be displayed in the center block
$HideViewReadOnly = 1;
// Show only 5 last new topics
$Last_New_Topics  = 5;                            
// Icon that is displayed in Center Block in front of Topic
$IconPath         = "modules/Forums/templates/subSilver/images/icon_mini_message.gif";

/**********************************/
/*                                */
/* Don't Edit Below !             */
/*                                */
/**********************************/
$border           = 0;
$cellspacing      = 0;
$cellstyle        = "style=\"border-left-width: 1; border-right-width: 1; border-top-width: 1; border-bottom-style: dotted; border-bottom-width: 1\"";

/* Total Amount of Topics */
$result = $db->sql_query( "SELECT * FROM ".$prefix."_bbtopics" );
$Amount_Of_Topics = $db->sql_numrows( $result );

/* Total Amount of Posts */
$result = $db->sql_query( "SELECT * FROM ".$prefix."_bbposts" );
$Amount_Of_Posts = $db->sql_numrows( $result );

/* Total Amount of Topic Views */
$Amount_Of_Topic_Views = 0;
$result = $db->sql_query( "SELECT topic_views FROM ".$prefix."_bbtopics" );
while( list( $topic_views ) = $db->sql_fetchrow( $result ) )
{
   $Amount_Of_Topic_Views = $Amount_Of_Topic_Views + $topic_views;
}

/* Total Amount of Topic Replies */
$Amount_Of_Topic_Replies = 0;
$result = $db->sql_query( "SELECT topic_replies FROM ".$prefix."_bbtopics" );
while( list( $topic_replies ) = $db->sql_fetchrow( $result ) )
{
   $Amount_Of_Topic_Replies = $Amount_Of_Topic_Replies + $topic_replies;
}

/* Total Amount of Members */
$result = $db->sql_query( "SELECT * FROM ".$user_prefix."_users" );
$Amount_Of_Members = $db->sql_numrows( $result ) - 1;

/* Last X New Topics */
$Count_Topics = 0;
$Topic_Buffer = "";
$result1 = $db->sql_query( "SELECT topic_id, forum_id, topic_last_post_id, topic_title, topic_poster, topic_views, topic_replies, topic_moved_id FROM ".$prefix."_bbtopics ORDER BY topic_last_post_id DESC" );
while( list( $topic_id, $forum_id, $topic_last_post_id, $topic_title, $topic_poster, $topic_views, $topic_replies, $topic_moved_id ) = sql_fetch_row( $result1, $dbi ) )
{
   $skip_display = 0;
   if( $HideViewReadOnly == 1 )
   {
      $result5 = $db->sql_query( "SELECT auth_view, auth_read FROM ".$prefix."_bbforums where forum_id = '$forum_id'" );
      list( $auth_view, $auth_read ) = $db->sql_fetchrow( $result5 );
      if( ( $auth_view != 0 ) or ( $auth_read != 0 ) ) { $skip_display = 1; }
   }
   
   if( $topic_moved_id != 0 )
   {
     // Shadow Topic !!
      $skip_display = 1;
   }
   
   if( $skip_display == 0 )
   {
     $Count_Topics += 1;
      $result2 = $db->sql_query( "SELECT topic_id, poster_id, FROM_UNIXTIME( post_time,'%b %d, %Y at %T') as post_time FROM ".$prefix."_bbposts where post_id = '$topic_last_post_id'" );
      list( $topic_id, $poster_id, $post_time ) = $db->sql_fetchrow( $result2 );

      $result3 = $db->sql_query( "SELECT username, user_id FROM ".$user_prefix."_users where user_id='$poster_id'" );
      list( $uname, $uid ) = $db->sql_fetchrow( $result3 );
      $LastPoster = "<A HREF=\"modules.php?name=Forums&file=profile&mode=viewprofile&u=$uid\"STYLE=\"text-decoration: none\"> $uname </a>";
      
      $result4 = $db->sql_query( "SELECT username, user_id FROM ".$user_prefix."_users where user_id='$topic_poster'" );
      list( $uname, $uid ) = $db->sql_fetchrow( $result4 );
      $OrigPoster = "<A HREF=\"modules.php?name=Forums&file=profile&mode=viewprofile&u=$uid\"STYLE=\"text-decoration: none\"> $uname </a>";
   
      $TopicImage = "<img src=\"$IconPath\" border=\"0\" alt=\"\">";
      $TopicTitleShow = "<a href=\"modules.php?name=Forums&amp;file=viewtopic&amp;p=$topic_last_post_id#$topic_last_post_id\"STYLE=\"text-decoration: none\">$topic_title</a>";
   
      $Topic_Buffer .= "<tr height=20 onmouseover=\"this.style.backgroundColor='#eeeeee'\" onmouseout=\"this.style.backgroundColor=''\"><td $cellstyle>$TopicImage&nbsp;&nbsp;</td><td $cellstyle>$TopicTitleShow</td><td $cellstyle><div align=\"center\">$OrigPoster</div></td><td $cellstyle><div align=\"center\"><b>$topic_views</b></div></td><td $cellstyle><div align=\"center\"><b>$topic_replies</b></div></td><td $cellstyle align=\"center\">$LastPoster<br><font size=\"-2\"><i>$post_time</i></font></td></tr>";
   }
   
   if( $Last_New_Topics == $Count_Topics ) { break 1; }
   
}

/* Write Table to Screen */
$content  = "<table width=\"100%\" border=\"$border\"  cellspacing=\"$cellspacing\" bordercolor=\"$bgcolor2\" bgcolor=\"$bgcolor1\">";
$content .= "<tr><td height=\"21\" align=\"center\" colspan=\"6\" bgcolor=\"$bgcolor2\"><b>$sitename</b></td></tr>";
$content .= "<tr><td>&nbsp;&nbsp;</td><td align=\"center\">Nuovi messaggi</td><td align=\"center\">Autori</td><td align=\"center\">Visti</td><td align=\"center\">Risposte</td><td align=\"center\">Ultimi posts</td></tr>";
$content .= "$Topic_Buffer";
$content .= "<tr><td align=\"center\" colspan=\"6\">Messaggi:<b>$Amount_Of_Topics</b>&nbsp;<b>|</b>&nbsp;Posts:<b>$Amount_Of_Posts</b>&nbsp;<b>|</b>&nbsp;Visti:<b>$Amount_Of_Topic_Views</b>&nbsp;<b>|</b>&nbsp;Risposte:<b>$Amount_Of_Topic_Replies</b>&nbsp;<b>|</b>&nbsp;<a href=\"modules.php?name=Members_List\">Utenti:</a>&nbsp;<b>$Amount_Of_Members</b></center></td></tr>";
$content .= "<tr><td align=\"center\" colspan=\"6\">[ <a href=\"modules.php?name=Forums\">Vai al forum</a> ]&nbsp;&nbsp;&nbsp;[ <a href=\"modules.php?op=modload&name=Forums&file=search\">Cerca</a> ]</center></td></tr>";
$content .= "</table>";

?>

Per farlo funzionare devo semplicemente eliminare le prime righe e inserire la connessione al database e modificare il nome delle tabelle?=

inviato 12 anni fa
z3ro
z3ro
1
X 0 X

Non credo sia così semplice, poiché questo script prevede la disponibilità di altre parti di codice disponibili in phpnuke ma che ovviamente tu non hai. Ad esempio il codice sfrutta l'oggetto $db per effettuare le query che però a te manca  :dunno:

 :bye:

risposto 12 anni fa
Gianni Tomasicchio
X 0 X

beh... però, voglio dire... non sono variabili così difficili

cioè:

global $prefix, $user_prefix, $db, $sitename, $bgcolor1, $bgcolor2;

$prefix basta metterla: phpbb_

$user_prefix  :(

$db basta creare una connessione al database no?

$sitename mi sembra facile

e per i colori si sparano a caso e si vede il risultato e poi si modificano... no?

risposto 12 anni fa
z3ro
z3ro
1
X 0 X
$db basta creare una connessione al database no?

No, è un oggetto di phpnuke. Dovresti cercarne il codice...

 :bye:

risposto 12 anni fa
Gianni Tomasicchio
X 0 X

acc... proverò a cercare altrimenti sono messo male e non potrò fare quello che volevo :'(

risposto 12 anni fa
z3ro
z3ro
1
X 0 X

se non lo trovi proviamo a fare delle modifiche, non ti preoccupare  ;)

 :bye:

risposto 12 anni fa
Gianni Tomasicchio
X 0 X

potrebbe essere:

$db = new sql_db($dbhost, $dbuname, $dbpass, $dbname, false);

?

risposto 12 anni fa
z3ro
z3ro
1
X 0 X

Non basta. sql_db è una classe, pertanto serve trovare la sua definizione (il codice).

 :bye:

risposto 12 anni fa
Gianni Tomasicchio
X 0 X
<?php
class sql_db

{



   var $db_connect_id;

   var $result;



   var $next_id;

   var $in_transaction = 0;



   var $row = array();

   var $rowset = array();

   var $limit_offset;

   var $query_limit_success;



   var $num_queries = 0;



   //

   // Constructor

   //

   function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)

   {

      $this->persistency = $persistency;

      $this->user = $sqluser;

      $this->password = $sqlpassword;

      $this->server = $sqlserver;

      $this->dbname = $database;



      $this->db_connect_id = ( $this->persistency ) ? mssql_pconnect($this->server, $this->user, $this->password) : mssql_connect($this->server, $this->user, $this->password);



      if( $this->db_connect_id && $this->dbname != "" )

      {

         if( !mssql_select_db($this->dbname, $this->db_connect_id) )

         {

            mssql_close($this->db_connect_id);

            return false;

         }

      }



      return $this->db_connect_id;

   }



   //

   // Other base methods

   //

   function sql_close()

   {

      if($this->db_connect_id)

      {

         //

         // Commit any remaining transactions

         //

         if( $this->in_transaction )

         {

            @mssql_query("COMMIT", $this->db_connect_id);

         }



         return @mssql_close($this->db_connect_id);

      }

      else

      {

         return false;

      }

   }





   //

   // Query method

   //

   function sql_query($query = "", $transaction = FALSE)

   {

      //

      // Remove any pre-existing queries

      //

      unset($this->result);

      unset($this->row);



      if ( $query != "" )

      {

         $this->num_queries++;



         if ( $transaction == BEGIN_TRANSACTION && !$this->in_transaction )

         {

            if ( !mssql_query("BEGIN TRANSACTION", $this->db_connect_id) )

            {

               return false;

            }

            $this->in_transaction = TRUE;

         }



         //

         // Does query contain any LIMIT code? If so pull out relevant start and num_results

         // This isn't terribly easy with MSSQL, whatever you do will potentially impact

         // performance compared to an 'in-built' limit

         //

         // Another issue is the 'lack' of a returned true value when a query is valid but has

         // no result set (as with all the other DB interfaces). It seems though that it's

         // 'fair' to say that if a query returns a false result (ie. no resource id) then the

         // SQL was valid but had no result set. If the query returns nothing but the rowcount

         // returns something then there's a problem. This may well be a false assumption though

         // ... needs checking under Windows itself.

         //

         if( preg_match("/^SELECT(.*?)(LIMIT ([0-9]+)[, ]*([0-9]+)*)?$/s", $query, $limits) )

         {

            $query = $limits[1];



            if( !empty($limits[2]) )

            {

               $row_offset = ( $limits[4] ) ? $limits[3] : "";

               $num_rows = ( $limits[4] ) ? $limits[4] : $limits[3];



               $query = "TOP " . ( $row_offset + $num_rows ) . $query;

            }



            $this->result = mssql_query("SELECT $query", $this->db_connect_id); 



            if( $this->result )

            {

               $this->limit_offset[$this->result] = ( !empty($row_offset) ) ? $row_offset : 0;



               if( $row_offset > 0 )

               {

                  mssql_data_seek($this->result, $row_offset);

               }

            }

         }

         else if( eregi("^INSERT ", $query) )

         {

            if( mssql_query($query, $this->db_connect_id) )

            {

               $this->result = time() + microtime();



               $result_id = mssql_query("SELECT @@IDENTITY AS id, @@ROWCOUNT as affected", $this->db_connect_id);

               if( $result_id )

               {

                  if( $row = mssql_fetch_array($result_id) )

                  {

                     $this->next_id[$this->db_connect_id] = $row['id'];   

                     $this->affected_rows[$this->db_connect_id] = $row['affected'];

                  }

               }

            }

         }

         else

         {

            if( mssql_query($query, $this->db_connect_id) )

            {

               $this->result = time() + microtime();



               $result_id = mssql_query("SELECT @@ROWCOUNT as affected", $this->db_connect_id);

               if( $result_id )

               {

                  if( $row = mssql_fetch_array($result_id) )

                  {

                     $this->affected_rows[$this->db_connect_id] = $row['affected'];

                  }

               }

            }

         }



         if( !$this->result )

         {

            if( $this->in_transaction )

            {

               mssql_query("ROLLBACK", $this->db_connect_id);

               $this->in_transaction = FALSE;

            }



            return false;

         }



         if( $transaction == END_TRANSACTION && $this->in_transaction )

         {

            $this->in_transaction = FALSE;



            if( !@mssql_query("COMMIT", $this->db_connect_id) )

            {

               @mssql_query("ROLLBACK", $this->db_connect_id);

               return false;

            }

         }



         return $this->result;

      }

      else

      {

         if( $transaction == END_TRANSACTION && $this->in_transaction  )

         {

            $this->in_transaction = FALSE;



            if( !@mssql_query("COMMIT", $this->db_connect_id) )

            {

               @mssql_query("ROLLBACK", $this->db_connect_id);

               return false;

            }

         }



         return true;

      }

   }



   //

   // Other query methods

   //

   function sql_numrows($query_id = 0)

   {

      if( !$query_id )

      {

         $query_id = $this->result;

      }



      if( $query_id )

      {

         return ( !empty($this->limit_offset[$query_id]) ) ? mssql_num_rows($query_id) - $this->limit_offset[$query_id] : @mssql_num_rows($query_id);

      }

      else

      {

         return false;

      }

   }



   function sql_numfields($query_id = 0)

   {

      if( !$query_id )

      {

         $query_id = $this->result;

      }



      return ( $query_id ) ? mssql_num_fields($query_id) : false;

   }



   function sql_fieldname($offset, $query_id = 0)

   {

      if( !$query_id )

      {

         $query_id = $this->result;

      }



      return ( $query_id ) ? mssql_field_name($query_id, $offset) : false;

   }



   function sql_fieldtype($offset, $query_id = 0)

   {

      if(!$query_id)

      {

         $query_id = $this->result;

      }



      return ( $query_id ) ? mssql_field_type($query_id, $offset) : false;

   }



   function sql_fetchrow($query_id = 0)

   {

      if( !$query_id )

      {

         $query_id = $this->result;

      }



      if( $query_id )

      {

         empty($row);



         $row = mssql_fetch_array($query_id);



         while( list($key, $value) = @each($row) )

         {

            $row[$key] = stripslashes($value);

         }

         @reset($row);



         return $row;

      }

      else

      {

         return false;

      }

   }



   function sql_fetchrowset($query_id = 0)

   {

      if( !$query_id )

      {

         $query_id = $this->result;

      }



      if( $query_id )

      {

         $i = 0;

         empty($rowset);



         while( $row = mssql_fetch_array($query_id))

         {

            while( list($key, $value) = @each($row) )

            {

               $rowset[$i][$key] = stripslashes($value);

            }

            $i++;

         }

         @reset($rowset);



         return $rowset;

      }

      else

      {

         return false;

      }

   }



   function sql_fetchfield($field, $row = -1, $query_id)

   {

      if( !$query_id )

      {

         $query_id = $this->result;

      }



      if( $query_id )

      {

         if( $row != -1 )

         {

            if( $this->limit_offset[$query_id] > 0 )

            {

               $result = ( !empty($this->limit_offset[$query_id]) ) ? mssql_result($this->result, ($this->limit_offset[$query_id] + $row), $field) : false;

            }

            else

            {

               $result = mssql_result($this->result, $row, $field);

            }

         }

         else

         {

            if( empty($this->row[$query_id]) )

            {

               $this->row[$query_id] = mssql_fetch_array($query_id);

               $result = stripslashes($this->row[$query_id][$field]);

            }

         }



         return $result;

      }

      else

      {

         return false;

      }

   }



   function sql_rowseek($rownum, $query_id = 0)

   {

      if( !$query_id )

      {

         $query_id = $this->result;

      }



      if( $query_id )

      {

         return ( !empty($this->limit_offset[$query_id]) ) ? mssql_data_seek($query_id, ($this->limit_offset[$query_id] + $rownum)) : mssql_data_seek($query_id, $rownum);

      }

      else

      {

         return false;

      }

   }



   function sql_nextid()

   {

      return ( $this->next_id[$this->db_connect_id] ) ? $this->next_id[$this->db_connect_id] : false;

   }



   function sql_affectedrows()

   {

      return ( $this->affected_rows[$this->db_connect_id] ) ? $this->affected_rows[$this->db_connect_id] : false;

   }



   function sql_freeresult($query_id = 0)

   {

      if( !$query_id )

      {

         $query_id = $this->result;

      }



      return ( $query_id ) ? mssql_free_result($query_id) : false;

   }



   function sql_error($query_id = 0)

   {

      $result['message'] = @mssql_get_last_message();

      return $result;

   }



} // class sql_db
?>
risposto 12 anni fa
z3ro
z3ro
1
X 0 X

non c'era bisogno di riportare il codice... >:(

metti tutto insieme e vedi se funziona

risposto 12 anni fa
Gianni Tomasicchio
X 0 X

non sembra funzionare... ma se io provassi a ricreare il blocco da 0?

cioè richiamando tutte le varie tabelle e variabili prendendo spunto da quello già fatto?

risposto 12 anni fa
z3ro
z3ro
1
X 0 X

non sembra funzionare... ma se io provassi a ricreare il blocco da 0?

cioè richiamando tutte le varie tabelle e variabili prendendo spunto da quello già fatto?

La cosa non è difficile, anche se dipende da quanta dimestichezza hai con il PHP. Impareresti comunque molto  ;)

Magari inizia a smanettarci sopra e se hai problemi ne discutiamo.

 :bye:

risposto 12 anni fa
Gianni Tomasicchio
X 0 X

ok... sto provando a vedere se ci riesco... ma pongo subito un dubbio... quel $content alla fine... che differenza c'è tra quando è $content = e $content .= ?

e soprattuto per riceve l'output del contenuto mi basta fare un echo "$content" ?

risposto 12 anni fa
z3ro
z3ro
1
X 0 X
ok... sto provando a vedere se ci riesco... ma pongo subito un dubbio... quel $content alla fine... che differenza c'è tra quando è $content = e $content .= ?

vedi la fine di questa lezione:

http://www.phpnews.it/content/view/243/107/

e soprattuto per riceve l'output del contenuto mi basta fare un echo "$content" ?

Meglio:

echo $content

 :bye:

risposto 12 anni fa
Gianni Tomasicchio
X 0 X

Dunque dunque dunque... ho sistemato tutte le query.. ho controllato tutto il codice più di 2 volte... ho provato ad eseguire le query da phpmyadmin e lì funzionano però non si vedono gli ultimi post nell'echo (anche se la tabella che li deve contenere viene visualizzata)...

ecco qui il codice:

<?php

/* Database */
$dbhost = "localhost";
$dbuname = "";
$dbpass = "";
$db_name = "";

/* Tables */

$prefix = "phpbb_";
$user_prefix = "phpbb_";

$db = mysql_connect($dbhost, $dbuname, $dbpass, $dbname);

$sitename = "Al di là dello specchio";
$bgcolor1 = "#FF00FF";
$bgcolor2 = "#FF0000";


/**********************************/
/*                                */
/* Configuration parameters       */
/*                                */
/**********************************/
// When set to 1 then Forums permissions which View and/or Read are NOT set to 'ALL' will NOT be displayed in the center block
$HideViewReadOnly = 1;
// Show only 5 last new topics
$Last_New_Topics  = 5;                            
// Icon that is displayed in Center Block in front of Topic
$IconPath         = "phpBB2/templates/subSilver/images/icon_mini_message.gif";

/**********************************/
/*                                */
/* Don't Edit Below !             */
/*                                */
/**********************************/
$border           = 0;
$cellspacing      = 0;
$cellstyle        = "style=\"border-left-width: 1; border-right-width: 1; border-top-width: 1; border-bottom-style: dotted; border-bottom-width: 1\"";

/* Total Amount of Topics */
$query    = "SELECT * FROM ".$prefix."topics";
$result = mysql_query($query,$db);
$Amount_Of_Topics = mysql_numrows($result);

/* Total Amount of Posts */
$query    = "SELECT * FROM ".$prefix."posts";
$result = mysql_query($query,$db);
$Amount_Of_Posts = mysql_numrows($result);

/* Total Amount of Topic Views */
$Amount_Of_Topic_Views = 0;
$query = "SELECT topic_views FROM ".$prefix."topics";
$result = mysql_query($query,$db);
$row = mysql_fetch_row($result);
while(list($topic_views) = $row);
{
   $Amount_Of_Topic_Views = $Amount_Of_Topic_Views + $topic_views;
}

/* Total Amount of Topic Replies */
$Amount_Of_Topic_Replies = 0;
$query    = "SELECT topic_replies FROM ".$prefix."topics";
$result = mysql_query($query,$db);
$row    = mysql_fetch_row($result);
while(list($topic_replies) = $row)
{
   $Amount_Of_Topic_Replies = $Amount_Of_Topic_Replies + $topic_replies;
}

/* Total Amount of Members */
$query    = "SELECT * FROM ".$prefix."users";
$result = mysql_query($query,$db);
$Amount_Of_Members = mysql_numrows($result) - 1;

/* Last X New Topics */
$Count_Topics = 0;
$Topic_Buffer = "";
$query = "SELECT topic_id, forum_id, topic_last_post_id, topic_title, topic_poster, topic_views, topic_replies, topic_moved_id FROM ".$prefix."topics ORDER BY topic_last_post_id DESC";
$result1 = mysql_query($query,$db);
while( list( $topic_id, $forum_id, $topic_last_post_id, $topic_title, $topic_poster, $topic_views, $topic_replies, $topic_moved_id ) = mysql_fetch_row( $result1, $db ) )
{
   $skip_display = 0;
   if( $HideViewReadOnly == 1 )
   {
      $query = "SELECT auth_view, auth_read FROM ".$prefix."forums where forum_id = '$forum_id'";
      $result5 = mysql_query($query,$db);
      $row = mysql_fetch_row($result5);
      list( $auth_view, $auth_read ) = $row;
      if( ( $auth_view != 0 ) or ( $auth_read != 0 ) ) { $skip_display = 1; }
   }
   
   if( $topic_moved_id != 0 )
   {
     // Shadow Topic !!
      $skip_display = 1;
   }
   
   if( $skip_display == 0 )
   {
     $Count_Topics += 1;
     $query = "SELECT topic_id, poster_id, FROM_UNIXTIME( post_time,'%b %d, %Y at %T') as post_time FROM ".$prefix."posts where post_id = '$topic_last_post_id'";
     $result2 = mysql_query($query,$db);
     $row = mysql_fetch_row($result2);
      list( $topic_id, $poster_id, $post_time ) = $row;
     
     $query = "SELECT username, user_id FROM ".$prefix."users where user_id='$poster_id'";
     $result3 = mysql_query($query,$db);
     $row = mysql_fetch_row($result3);
      list( $uname, $uid ) = $row ;
      $LastPoster = "<A HREF=\"modules.php?name=Forums&file=profile&mode=viewprofile&u=$uid\"STYLE=\"text-decoration: none\"> $uname </a>";
      
      $query = "SELECT username, user_id FROM ".$prefix."users where user_id='$topic_poster'";
     $result4 = mysql_query($query,$db);
     $row = mysql_fetch_row($result4);
      list( $uname, $uid ) = $row ;
      $OrigPoster = "<A HREF=\"modules.php?name=Forums&file=profile&mode=viewprofile&u=$uid\"STYLE=\"text-decoration: none\"> $uname </a>";
   
      $TopicImage = "<img src=\"$IconPath\" border=\"0\" alt=\"\">";
      $TopicTitleShow = "<a href=\"modules.php?name=Forums&amp;file=viewtopic&amp;p=$topic_last_post_id#$topic_last_post_id\"STYLE=\"text-decoration: none\">$topic_title</a>";
   
      $Topic_Buffer .= "<tr height=20 onmouseover=\"this.style.backgroundColor='#eeeeee'\" onmouseout=\"this.style.backgroundColor=''\"><td $cellstyle>$TopicImage&nbsp;&nbsp;</td><td $cellstyle>$TopicTitleShow</td><td $cellstyle><div align=\"center\">$OrigPoster</div></td><td $cellstyle><div align=\"center\"><b>$topic_views</b></div></td><td $cellstyle><div align=\"center\"><b>$topic_replies</b></div></td><td $cellstyle align=\"center\">$LastPoster<br><font size=\"-2\"><i>$post_time</i></font></td></tr>";
   }
   
   if( $Last_New_Topics == $Count_Topics ) { break 1; }
   
}

/* Write Table to Screen */
$content  = "<table width=\"100%\" border=\"$border\"  cellspacing=\"$cellspacing\" bordercolor=\"$bgcolor2\" bgcolor=\"$bgcolor1\">";
$content .= "<tr><td height=\"21\" align=\"center\" colspan=\"6\" bgcolor=\"$bgcolor2\"><b>$sitename</b></td></tr>";
$content .= "<tr><td>&nbsp;&nbsp;</td><td align=\"center\">Nuovi messaggi</td><td align=\"center\">Autori</td><td align=\"center\">Visti</td><td align=\"center\">Risposte</td><td align=\"center\">Ultimi posts</td></tr>";
$content .= "$Topic_Buffer";
$content .= "<tr><td align=\"center\" colspan=\"6\">Messaggi:<b>$Amount_Of_Topics</b>&nbsp;<b>|</b>&nbsp;Posts:<b>$Amount_Of_Posts</b>&nbsp;<b>|</b>&nbsp;Visti:<b>$Amount_Of_Topic_Views</b>&nbsp;<b>|</b>&nbsp;Risposte:<b>$Amount_Of_Topic_Replies</b>&nbsp;<b>|</b>&nbsp;<a href=\"modules.php?name=Members_List\">Utenti:</a>&nbsp;<b>$Amount_Of_Members</b></center></td></tr>";
$content .= "<tr><td align=\"center\" colspan=\"6\">[ <a href=\"modules.php?name=Forums\">Vai al forum</a> ]&nbsp;&nbsp;&nbsp;[ <a href=\"modules.php?op=modload&name=Forums&file=search\">Cerca</a> ]</center></td></tr>";
$content .= "</table>";
echo "$content";
?>
risposto 12 anni fa
z3ro
z3ro
1
X 0 X

non ho notato nulla di strano (a parte la qualità dello script che è veramente scadente :death:   )

ti consiglio di mettere diverse istruzioni echo all'interno del codice per vedere il valore delle variabili durante l'esecuzione. Usa print_r per vedere il valore degli array.

 :bye:

risposto 12 anni fa
Gianni Tomasicchio
X 0 X

non ho notato nulla di strano (a parte la qualità dello script che è veramente scadente :death:   )

ti consiglio di mettere diverse istruzioni echo all'interno del codice per vedere il valore delle variabili durante l'esecuzione. Usa print_r per vedere il valore degli array.

 :bye:

ehm... per la qualità non è che abbia modificato molto rispetto allo script originale... intanto mi interesserebbe il fatto che funzioni... poi si passa alla sistemazione del codice...

Domani provo a mettere qualche echo qua e là per vedere se ho sbagliato qualcosa nelle query  ;)

risposto 12 anni fa
z3ro
z3ro
1
X 0 X
ehm... per la qualità non è che abbia modificato molto rispetto allo script originale...

infatti non stavo criticando te  :-[

 :bye:

risposto 12 anni fa
Gianni Tomasicchio
X 0 X

non riesco a capire... tutti gli echo restituiscono parametri corretti  :-[ :-\

risposto 12 anni fa
z3ro
z3ro
1
X 0 X

ho spulciato un pò le tabelle nel MySQL fino ad ottenere questo risultato:

<?php
/* Database */
$db_name = "";
$db_host = "";
$db_user = "";
$db_pass = "";

/* Tables */
$prefix = "phpbb_";

/* Domain */
$host = "";

/* Database connection */
$db = mysql_connect($db_host, $db_user, $db_pass);
if ($db == FALSE)
die ("Errore nella connessione.");
mysql_select_db($db_name, $db)
or die ("Errore nella selezione del database.");

/* Query Topics */

$query    = "SELECT * FROM ".$prefix."topics ORDER BY topic_id DESC LIMIT 0,5";
$result = mysql_query($query, $db);
while ($row = mysql_fetch_array($result))
{
   $query2 = "SELECT username FROM ".$prefix."users WHERE user_id = '$row[topic_poster]'";
   $result2 = mysql_query($query2, $db);
   $row2   = mysql_fetch_array($result2);
   echo "<a href=\"http://www.atene77.altervista.org/phpBB2/viewtopic.php?t=$row[topic_id]\">$row[topic_title] - Postato da $row2[username]<br>";
}

mysql_close($db);
?>

Il risultato è parzialmente ottenuto... resta il fatto che non si vedono gli ultimi reply ma gli ultimi post inseriti "ex-novo"... Ora spulcerò ancora per capire dove si trova esattamente la voce dei reply in modo da riuscire a sistemare... intanto ci sono problemi nel codice? qualcosa scritto "male" o fin'ora ho fatto tutto bene?

Qualche consiglio? ;)

risposto 12 anni fa
z3ro
z3ro
1
X 0 X

Il problema che hai è causato dalla prima query. Infatti gli stai chiedendo le ultime 5 discussioni (topics) e non gli ultimi 5 messaggi. Per ovviare dovresti effettuare tale query sulla tabella che contiene i messaggi.

 :bye:

risposto 12 anni fa
Gianni Tomasicchio
X 0 X

guardando meglio c'era la voce: topic_last_post_id

ordinandoli in quel modo ottengo il risultato ottenuto ;D ora devo solo sistemare la parte grafica (inserendo il tutto in una tabella, magari) e poi direi che sono riuscito a fare quello di cui avevo bisogno... e sono molto felice! ;)

risposto 12 anni fa
z3ro
z3ro
1
X 0 X

 O0  :bye:

risposto 12 anni fa
Gianni Tomasicchio
X 0 X

ecco il risultato finale:

Link

 O0 O0 :bye: :bye: :bye: :bye:

risposto 12 anni fa
z3ro
z3ro
1
X 0 X
Effettua l'accesso o registrati per rispondere a questa domanda

Domande simili