• User

    Codice php da modificare ?

    Ragazzi poiché non mastico php qualcuno mi aiutare per modificare questo blocco per nuke per visualizzare i post del forum in homepage, questo che allego é per il forum interno ma io vorrei modificarlo
    perché il mio forum risiede su database esterno.

    Ho provato a smanettare per aggiungere il codice di connessione e le query ma non riesco proprio, ormai mi sono arreso ma ci terrei
    a ottenere un risultato.

    CODICE BLOCCO:

    <?php

    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</td><td $cellstyle>$TopicTitleShow</td><td $cellstyle><div align=\"center\">$OrigPoster</div></td><td $cellstyle><div align=\"center\">**$topic_views**</div></td><td $cellstyle><div align=\"center\">**$topic_replies**</div></td><td $cellstyle align=\"center\">$LastPoster
    

    <font size="-2">$post_time</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">$sitename</td></tr>";
    $content .= "<tr><td></td><td align="center">"._BBFORUM_NEWTOPICS."</td><td align="center">"._BBFORUM_POSTER."</td><td align="center">"._BBFORUM_VIEWS."</td><td align="center">"._BBFORUM_REPLIES."</td><td align="center">"._BBFORUM_LASTPOSTER."</td></tr>";
    $content .= "$Topic_Buffer";
    $content .= "<tr><td align="center" colspan="6">"._BBFORUM_TOTTOPICS."$Amount_Of_Topics
    ***|"._BBFORUM_TOTPOSTS."$Amount_Of_Posts****|"._BBFORUM_TOTVIEWS."$Amount_Of_Topic_Views****|"._BBFORUM_TOTREPLIES."$Amount_Of_Topic_Replies****|<a href="modules.php?name=Members_List">"._BBFORUM_TOTMEMBERS."</a>$Amount_Of_Members</center></td></tr>";
    $content .= "<tr><td align="center" colspan="6">[ <a href="modules.php?name=Forums">"._BBFORUM_FORUM."</a> ][ <a href="modules.php?op=modload&name=Forums&file=search">"._BBFORUM_SEARCH."</a> ]</center></td></tr>";
    $content .= "</table>";

    ?>



  • Super User

    non mi son messo a leggere tutto il codice.

    Ti faccio vedere quello che uso io con PhpBB2

    <?php
    
                $querystrForum = "SELECT * FROM phpbb_topics ORDER BY topic_id DESC";
                $resultForum = mysql_query&#40;$querystrForum,$dbForum&#41;;
                if &#40;$frowForum = mysql_fetch_array&#40;$resultForum&#41;&#41; &#123;
                   $foundForum = true;
                   &#125;
               $iForum=0;
                   do &#123;
            $iForum=$iForum + 1;
            $topic_title=$frowForum&#91;"topic_title"&#93;;
            $topic_id=$frowForum&#91;"topic_id"&#93;;
          echo "<a  href=/video/viewtopic.php?t=" . $topic_id . " title = \" Video $topic_title\">" . $topic_title . "</a>
    ";
    
                   &#125; while &#40;$frowForum = mysql_fetch_array&#40;$resultForum&#41; and $iForum<20&#41;;
    
            &#125;
    
      ?>
    

    Con questo tiro fuori gli ultimi 20 topic scritti nel forum...

    Spero possa esserti utile

    Ciao!


  • User

    Ti ringrazio tuono ma non funziona da me, boh non so più cosa fare.


  • Super User

    Ovviamente non va perchè avrai le tabelle che si chiameranno in modo diverso...

    Dovresti dirmi i nomi delle tabelle e dei campi dove memorizzi i post.

    CIAO!


  • User

    Allora tuono premetto che io uso phpnuke, le tabelle in questione del forum esterno dovrebbero essere:

    phpbb_posts e phpbb_posts_text

    Io vorrei avere un codice dove nella stesso file ci sia il codice di connessione al database esterno e poco sotto la query per i post e poi pero' tutto questo codice non saprei dove inserirlo.

    Avevo provato alla lettere tutto quello scritto da Giorgio Tave ma non ha funzionato, cioé dopo avere inserito tutti i parametri alla fine in home page non viene fuori assolutamente niente.

    Piu sopra ho allegato il codice blocco bisognerebbe aggiungere il codice per la connessione e modificare le query che ci sono sotto ma io non riesco, perché non so dove intervenire.

    Se puoi aiutarmi mi faresti un grande favore.