Integracja MyBB z Portalem

Założony przez  cados19.

wersja skryptu MyBB:1.6.x
adres forum:http://cados12.blue-host.wroclaw.pl/forum/
na czym polega problem (screen, opis, komunikaty, nazwa i wersja wtyczki):

Witam Serdecznie próbuję zintegrować moje forum z portalem (skrypt php)
Dokładniej chodzi o ostatnie atki lub tematy z forum na portalu głównym
portal jest w katalogu public_html a forum w public_html/forum/

Za każdym skryptem którego używam wywala mi błąd

Typ błędu:
    
Ostrzeżenie (2)
Treść błędu:
    
Cannot modify header information headers already sent by (output started at /home/cados12/domains/cados12.blue-host.wroclaw.pl/public_html/index.php:8)
Lokalizacja:
    
Plikinc/functions.php
    Linia
1688
Kod
:
    
1685.     
    1686.     $mybb
->cookies[$name] = $value;
    
1687. 
    1688.     header
($cookiefalse);
    
1689. }
    
1690. 
    1691. 
/** 
Podam także screen:
[Obrazek: bladmybb.png]
Klasa:

<?php
/**
* This class can display latest threads or posts
* formated in unordered list (<ul/>)
* It doesn't depend on place where script is being run
* just initialize class and execute proper method

* @author Mariusz "marines" Kujawski <marinespl@gmail.com>
* @link http://marines.jogger.pl/
* @version 0.1
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
class MyBBLatest {
   
// mysql db handler
   
private $db;
   
// tables prefix
   
private $prefix;
   
// url to mybb
   
private $url;
   
/**
   * constructor
   *
   * @param string $mybb path to MyBB instalation
   * @param string $url URL of MyBB instalation
   * @return boolean
   */
   
public function __construct($mybb ''$url) {
      
// include mybb config file
      
@include('./' $mybb 'inc/config.php');
      
// db connect
      
$this->db = @mysql_connect($config['database']['hostname'], $config['database']['username'], $config['database']['password']);
      
// db choose
      
@mysql_select_db($config['database']['database'], $this->db);
      
// stop executing if db connection isn't availible
      
if (!$this->db) return false;
      
// set db prefix
      
$this->prefix $config['database']['table_prefix'];
      
// set base url of mybb
      
$this->url $url;
      
// return
      
return true;
   }
   
/**
   * display latest threads
   *
   * @param integer $many indicates how many threads have to be retrieved from database
   * @param boolean $lastpost indicates whether link has to direct to last post in thread
   * @param integer $fid ID of forum which threads have to be retrieved from
   * @return string list of threads
   */
   
public function threads($many 10$lastpost false$fid false) {
      
// forum id select
      
if ($fid) {
         
$where 'WHERE `fid` = ' $fid;
      }
      if (
$lastpost) {
         
$last '&action=lastpost';
      }
      
// initialize temporary var
      
$tmp '<ul class="last-threads">';
      
// select data
      
$query = @mysql_query('SELECT `tid`, `subject` FROM `' $this->prefix 'threads` ' $where ' ORDER BY `dateline` DESC LIMIT ' $many);
      
// check if query has result
      
if (!$query) return false;
      
// collect data into list
      
while ($row mysql_fetch_array($query)) {
         
$tmp .= '<li><a href="' $this->url 'showthread.php?tid=' $row[0] . $last '">' $row[1] . '</a></li>';
      }
      
$tmp .= '</ul>';
      
// return list of threads
      
return $tmp;
   }
   
/**
   * display latest posts
   *
   * @param integer $many indicates how many posts have to be retrieved from database
   * @param integer $fid ID of forum which posts have to be retrieved from
   * @return string list of posts
   */
   
public function posts($many 10$fid false) {
      
// forum id select
      
if ($fid) {
         
$where 'WHERE `fid` = ' $fid;
      }
      
// initialize temporary array
      
$tmp '<ul class="last-threads">';
      
// select db data
      
$query = @mysql_query('SELECT `pid`, `tid`, `subject` FROM `' $this->prefix 'posts` ' $where ' ORDER BY `dateline` DESC LIMIT ' $many);
      
// check if query has result
      
if (!$query) return false;
      
// collect data into list
      
while ($row mysql_fetch_array($query)) {
         
$tmp .= '<li><a href="' $this->url 'showthread.php?tid=' $row[1] . '&pid=' $row[0] . '#pid' $row[0] . '">' $row[2] . '</a></li>';
      }
      
$tmp .= '</ul>';
      
// return posts
      
return $tmp;
   }
// MyBBLatest end
?>
W Pliku posiadam
<?php
require_once('MyBBLatest.class.php');
$mybb = new MyBBLatest('forum''http://adres.pl/forum');
echo 
$mybb->threads();
echo 
$mybb->posts();
?>
O co chodzi i jak go mogę rozwiązać.
Matslom napisał 01.03.2013, 19:20:
Przenoszę do działu z tworzeniem pluginów
Jak mamy powiedzieć co jest źle, skoro nie podałeś kodu jakiego używasz?
Przepraszam z góry. W Pierwszym poście podałem wszystko
Po stronie na której to występuje widzę, że coś jest na stronie wyświetlane, a dopiero potem, w trakcie jest to używane. Coś idzie więc wcześniej.

W kodzie swojego portalu umieść to przed innymi rzeczami.
Jeżeli masz tam wymieszany html i php to np. tak:

<?php
ob_start
();
require_once(
'MyBBLatest.class.php');
$mybb = new MyBBLatest('forum''http://adres.pl/forum');
echo 
$mybb->threads();
echo 
$mybb->posts();
$mybb_latest ob_get_clean();

// tutaj twój kod

echo $mybb_latest;

// reszta twojego kodu 
Up powiem tak nie działa, dalej to samo lecz po przetrząsaniu tego forum napotkałem się na post jednego z użytkowników który wstawił takowy skrypt

                <?php

$db 
mysql_connect('localhost''user''Haslo') or die("Unable to connect with the database.");
@
mysql_select_db('baza',$db) or die("Unable to select the database <b>".$db['name']."</b>.");

$query mysql_query('SELECT `tid`, `subject` FROM `mybb_posts` ORDER BY `dateline` DESC LIMIT 10');
$www 'http://cados12.blue-host.wroclaw.pl/forum/';
while(
$topic mysql_fetch_array($query)){
  
$temat mysql_query("SELECT * FROM `mybb_threads` WHERE `tid` = '$topic[tid]' ORDER BY `dateline` DESC LIMIT 10");
  while(
$thread mysql_fetch_array($temat)){
  
$show '<a href="'.$www.'showthread.php?tid='.$topic['tid'].'&action=lastpost">'.$topic['subject'].'</a> ('.$thread['replies'].' Odpowiedzi)';
  }
}
echo 
$show;
?>

Sęk w tym że wyświetla tylko 1 temat a nie 10. Dlaczego ?
Dlatego że wszystkie wątki ładujesz do zmiennej $show i następnie poza pętlą robisz echo i ją wyświetlasz.
W tym twoim skrypcie echo powinno być w pętli while inaczej zawsze będzie wyświetlało Ci jeden ostatni wynik z pętli.
Siemka może mi ktoś pomóc z tym skryptem co dodał cados19 żeby wyświetlało mi 5 ostatnich tematów a nie muszę wybierać z którego bo to coś mi nie działa :) pokazuje mi tylko 1 z jakiej chcę tabeli mam nadzieje że ktoś mi pomoże :)



Użytkownicy przeglądający ten wątek:

1 gości