• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

PHP problem-Mybb gesior news system

widnet

Banned User
Joined
Apr 11, 2009
Messages
920
Reaction score
3
Location
Poland/Cracow
Witam mam problem z php chodzi o to aby zamienic nastepujace tagi na tagi
News system test
PHP:
[b]Grube[/b]
[i]pochylone[/i]
[u]podkreslenie[/u]
[align=left]do lewej[/align]
[align=center]do srodka[/align]
[align=right]do prawej[/align]
[IMG]http://layouts.4za.pl/button.png[/IMG]
[url=http://layouts.4za.pl/]Url[/url]
[[email protected]]MAail[/email]
[quote]Cytat[/quote]
[code]KOD[/code]
[php]php
Kolor
[size=x-large]Rozmiar[/size]
czcionka
[/PHP]
html

Problem mam z skryptem bo nie dziala nie mmogl by ktos moj skrypt dokonczyc??
PHP:
<?php
/*------------------------------*/
define("IN_MYBB", 1);
define("KILL_GLOBALS", 1);
define("NO_ONLINE", 1);
/*------------------------------*/
include("forum/inc/init.php");
/*------------------------------*/
$forumpath = $mybb->settings['bburl'];
require_once MYBB_ROOT."/inc/class_parser.php";
$parser = new postParser();

/*------------------------------*/
$connect = @mysql_connect("localhost", "adrian", "noe interesoj sie") or die ("Brak łączności z serwerem.");
mysql_query('SET CHARSET utf8');
mysql_select_db("adrian_forum") or die ("Brak łączności z Bazą Danych.");

$show_news = ("SELECT tid, replyto, fid, subject, uid, username, dateline, message, visible FROM posts WHERE (fid = '3') AND (replyto = '0') ORDER BY tid DESC LIMIT 0,4");
$show_news_query = mysql_query($show_news) or die("Błąd w zapytaniu nr 1");

while($news = mysql_fetch_array($show_news_query))
{
$subjectOLD = $news[subject];
$subiect = str_replace('[align=center]', '<center>', $subjectOLD);
$subject = $news[subject];
str_replace('[align=center]', '<center>', $subject);
$message = $news[message];
str_replace('[align=center]', '<center>', $message);


$date_day = date("j", $news[dateline]);
$date_mounth = date("m", $news[dateline]);
$date_year = date("Y", $news[dateline]);
$time = date("H:i", $news['dateline']);
   switch ($date_mounth) {
         case '01': $date_mounth = 'Stycznia'; break;
         case '02': $date_mounth = 'Lutego'; break;
         case '03': $date_mounth = 'Marca'; break;
         case '04': $date_mounth = 'Kwietnia'; break;
         case '05': $date_mounth = 'Maja'; break;
         case '06': $date_mounth = 'Czerwca'; break;
         case '07': $date_mounth = 'Lipca'; break;
         case '08': $date_mounth = 'Sierpnia'; break;
         case '09': $date_mounth = 'Września'; break;
         case '10': $date_mounth = 'Października'; break;
         case '11': $date_mounth = 'Listopada'; break;
         case '12': $date_mounth = 'Grudnia'; break;
           default: $date_mounth = 'Błąd!!!'; break;
       }
$main_content .= "<div class='post'>";
$main_content .= "<strong><img border='0' src='<?PHP echo $layout_name; ?>/images/newscomer.png' width='100' height='30' ALIGN=right hspace='6' vspace='7'><a href='forum/showthread.php?tid=$news[tid]'><h3>".$parser->parse_message($subject)."</h3></a></strong>";
$main_content .= "<p>".$parser->parse_message($message)."</p>";
$main_content .= "<p style='text-align:right'><small>Napisane ".$date_day." ".$date_mounth." ".$date_year." r. o godz. ".$time.", przez <a href='forum/member.php?action=profile&amp;uid=$news[uid]'><b>".$news[username]."</b></a>.</small></p>";
$main_content .= "</div>";

}
?>
Jak bys chcial szybszy kontakt prosze pisac na gg 867803
 
ale problem mam taki ze mi nie wyświetla HTML

ots.4za.pl
Patrz
$subjectOLD = $news[subject]; -> pobiera z bazy temat newsa i zapisujesz do zmiennej subiectOLD, a następnie:
$subject = str_replace('[align=center]', '<center>', $subjectOLD); w zmiennej subject zapamiętujesz efekt działania funkcji, dzięki czemu bedziesz mógł wyświetlić (właściwie przekazać, ale to nie istotne) zmienna tutaj $parser->parse_message($subject)

I dalej nie wiem co robić
 
Gesior używa zmiennej $main_content (Juz użyłeś)

Spróbuj to zrobić na czystym PHP i sprawdź czy wogule działa.
 
Wiec opisz w czym masz problem? Nie działaja ci te tagi?

Użyj funkcji do której dałem ci link wyżej.
 
doszedlem do
<?php
/*------------------------------*/
define("IN_MYBB", 1);
define("KILL_GLOBALS", 1);
define("NO_ONLINE", 1);
/*------------------------------*/
include("forum/inc/init.php");
/*------------------------------*/
$forumpath = $mybb->settings['bburl'];
require_once MYBB_ROOT."/inc/class_parser.php";
$parser = new postParser();

/*------------------------------*/
$connect = @mysql_connect("localhost", "adrian", "") or die ("Brak łączności z serwerem.");
mysql_query('SET CHARSET utf8');
mysql_select_db("adrian_forum") or die ("Brak łączności z Bazą Danych.");

$show_news = ("SELECT tid, replyto, fid, subject, uid, username, dateline, message, visible FROM posts WHERE (fid = '3') AND (replyto = '0') ORDER BY tid DESC LIMIT 0,4");
$show_news_query = mysql_query($show_news) or die("Błąd w zapytaniu nr 1");

while($news = mysql_fetch_array($show_news_query))
{

$subject = $news[subject];
$subject = str_replace('[align=center]', '<div style="text-align: center;">', $subject);
$subject = str_replace('[/align]', '</div>', $subject);
$message = $news[message];
$message = str_replace('[align=center]', '<div style="text-align: center;">', $message);
$message = str_replace('[/align]', '</div>', $message);


$date_day = date("j", $news[dateline]);
$date_mounth = date("m", $news[dateline]);
$date_year = date("Y", $news[dateline]);
$time = date("H:i", $news['dateline']);
switch ($date_mounth) {
case '01': $date_mounth = 'Stycznia'; break;
case '02': $date_mounth = 'Lutego'; break;
case '03': $date_mounth = 'Marca'; break;
case '04': $date_mounth = 'Kwietnia'; break;
case '05': $date_mounth = 'Maja'; break;
case '06': $date_mounth = 'Czerwca'; break;
case '07': $date_mounth = 'Lipca'; break;
case '08': $date_mounth = 'Sierpnia'; break;
case '09': $date_mounth = 'Września'; break;
case '10': $date_mounth = 'Października'; break;
case '11': $date_mounth = 'Listopada'; break;
case '12': $date_mounth = 'Grudnia'; break;
default: $date_mounth = 'Błąd!!!'; break;
}
$main_content .= "<div class='post'>";
$main_content .= "<strong><img border='0' src='<?PHP echo $layout_name; ?>/images/newscomer.png' width='100' height='30' ALIGN=right hspace='6' vspace='7'><a href='forum/showthread.php?tid=$news[tid]'><h3>".$parser->parse_message($subject)."</h3></a></strong>";
$main_content .= "<p>".$parser->parse_message($message)."</p>";
$main_content .= "<p style='text-align:right'><small>Napisane ".$date_day." ".$date_mounth." ".$date_year." r. o godz. ".$time.", przez <a href='forum/member.php?action=profile&amp;uid=$news[uid]'><b>".$news[username]."</b></a>.</small></p>";
$main_content .= "</div>";

}
?>

ale wyswietla to tak
<div style="text-align: center;"> Hello

Demonica OTS get started

Rates
Exp = 25
Skill = 10
Loot = 3
Magic = 7
Spawn = 1

Map: Repigera

Towns: 4

IP: 4za.pl

Port: 7171

UP/Down: 1GB/ps

Powerfull dedicaded server

</div>
 

Ciekawe po co sie meczyc z tym zlomem jesli mozna tak:
PHP:
<?
	$BB = array(
		'/\[b\](.*?)\[\/b\]/is' => '<strong>$1</strong>',
		'/\[u\](.*?)\[\/u\]/is' => '<u>$1</u>',
		'/\[i\](.*?)\[\/i\]/is' => '<i>$1</i>',
		'/\[url\=(.*?)\](.*?)\[\/url\]/is' => '<a href=$1>$2</a>',
		'/\[color\=(.*?)\](.*?)\[\/color\]/is' => '<span style="color: $1;">$2</span>',
		'/\[img\](.*?)\[\/img\]/is' => '<img src=$1 alt=$1 />',
	);
	
	$message = '[b]Text[/b] [color=#A1B2C3][u]Text[/u][/color], [i][url=http://www.otland.net/forum.php]OtLand.[/url][/i][img]http://otland.net/customavatars/avatar37084_2.gif[/img]';
	$message = preg_replace(array_keys($BB), array_values($BB), $message);
	
	echo $message;
?>

"<_<"
 
Ciekawe po co sie meczyc z tym zlomem jesli mozna tak:
PHP:
<?
	$BB = array(
		'/\[b\](.*?)\[\/b\]/is' => '<strong>$1</strong>',
		'/\[u\](.*?)\[\/u\]/is' => '<u>$1</u>',
		'/\[i\](.*?)\[\/i\]/is' => '<i>$1</i>',
		'/\[url\=(.*?)\](.*?)\[\/url\]/is' => '<a href=$1>$2</a>',
		'/\[color\=(.*?)\](.*?)\[\/color\]/is' => '<span style="color: $1;">$2</span>',
		'/\[img\](.*?)\[\/img\]/is' => '<img src=$1 alt=$1 />',
	);
	
	$message = '[b]Text[/b] [color=#A1B2C3][u]Text[/u][/color], [i][url=http://www.otland.net/forum.php]OtLand.[/url][/i][img]http://otland.net/customavatars/avatar37084_2.gif[/img]';
	$message = preg_replace(array_keys($BB), array_values($BB), $message);
	
	echo $message;
?>

"<_<"
Uzyje Twojego systemu
 
Back
Top