Jump to content
MakeWebGames

Recommended Posts

Posted

Hello guys! It's been long since I have been here. (I've been to Bangladesh for a month.)

I need your help guys! I got a problem which I do not know why it is not working?

 

[ATTACH=CONFIG]1674[/ATTACH]

 

As you can see here. When ever I put a enter gap it does not work? So the in the BBCode Engine it's not doing the <br/>

My BBCodes Engine -

 

<?php


class bbcode
{
   function bbcode_parse($text)
   {
       global $ir, $db, $userid, $set;
       $text = htmlspecialchars($text);
       // Following removed due to security issues regarding session hijacking
       // $text = preg_replace("/\[img=(.+?)\]/", "<img src='$1' alt='Broken or invalid image' />", $text);
       // $text = preg_replace("/\[img\](.+?)\[\/img\]/", "<img src='$1' alt='Broken or invalid image' />", $text);
       // $text = preg_replace("/\[email=(.+?)\](.+?)\[\/email\]/", "<a href='mailto:$1'>$2</a>", $text);
       // $text = preg_replace("/\[email\](.+?)\[\/email\]/", "<a href='mailto:$1'>$1</a>", $text);
       // $text = preg_replace("/\[url=(.+?)\](.+?)\[\/url\]/", "<a href='$1'>$2</a>", $text);
       // End
       $text = preg_replace("/\[b\]/", "<strong>", $text);
       $text = preg_replace("/\[\/b\]/", "</strong>", $text);
       $text = preg_replace("/\[i\]/", "<em>", $text);
       $text = preg_replace("/\[\/i\]/", "</em>", $text);
       $text = preg_replace("/\[u\]/", "<span style='text-decoration:underline;'>", $text);
       $text = preg_replace("/\[\/u\]/", "</span>", $text);
       $text = preg_replace("/\[s\]/", "<s>", $text);
       $text = preg_replace("/\[\/s\]/", "</s>", $text);
       $text = preg_replace("/\[sub\](.+?)\[\/sub\]/", "<sub>$1</sub>", $text);
       $text = preg_replace("/\[sup\](.+?)\[\/sup\]/", "<sup>$1</sup>", $text);
       $text = preg_replace("/\[big\](.+?)\[\/big\]/", "<big>$1</big>", $text);
       $text = preg_replace("/\[small\](.+?)\[\/small\]/", "<small>$1</small>", $text);
       $text = preg_replace("/\[list\](.+?)\[\/list\]/", "<ul>$1</ul>", $text);
       $text = preg_replace("/\[olist\](.+?)\[\/olist\]/", "<ol>$1</ol>", $text);
       $text = preg_replace("/\[li\](.+?)\[\/li\]/", "<li>$1</li>", $text);
       $text = preg_replace("/\[font=(.+?)\](.+?)\[\/font\]/", "<span style='font-family:$1'>$2</span>", $text);
       $text = preg_replace("/\[size=(.+?)\](.+?)\[\/size\]/", "<font size='$1'>$2</font>", $text);
       $text = preg_replace("/\[img[=]?(left|right)?\](([^<> \n]+?)\.(gif|jpg|jpeg|png|bmp))\[\/img\]/i", '<img class="mainimage" src="\\2" border="0" align="\\1"  max-width: 5px  alt="">', $text);
       $text = preg_replace("/\n/", "&nbrlb;", $text);
       $text = preg_replace("/\[left\](.+?)\[\/left\]/", "<div style='text-align: left;'>$1</div>", $text);
       $text = preg_replace("/\[center\](.+?)\[\/center\]/", "<div style='text-align: center;'>$1</div>", $text);
       $text = preg_replace("/\[right\](.+?)\[\/right\]/", "<div style='text-align: right;'>$1</div>", $text);
       $text = preg_replace("/\[quote name='(.+?)\'](.+?)\[\/quote\]/", "<div class='quotetop'>Quote($1)</div><div class='quotemain'>$2</div>", $text);
       $text = preg_replace("/\[quote\](.+?)\[\/quote\]/", "<div class='quotetop'>Quote</div><div class='quotemain'>$1</div>", $text);
       $text = preg_replace("/\[style=(.+?)\](.+?)\[\/style\]/", "<div style='$1'>$2</div>", $text);
       $text = preg_replace("/\[quote\](.+?)\[\/quote\]/", "<div class='quotetop'>Quote</div><div class='quotemain'>$1</div>", $text);
       $text = preg_replace("/\[code\](.+?)\[\/code\]/", "<div class='codetop'>Code</div><div class='codemain'><code>$1</code></div>", $text);
       $text = preg_replace("/\[codebox\](.+?)\[\/codebox\]/", "<div class='codetop'>Code</div><div class='codemain'><code>$1</code></div>", $text);
       $text = preg_replace("/&nbrlb;/", "\n", $text);
       $text = preg_replace("/\[colour=(.+?)\]/", "<span style='color:$1;'>", $text);
       $text = preg_replace("/\[\/colour\]/", "</span>", $text);
       $text = preg_replace("/\[color=(.+?)\]/", "<span style='color:$1;'>", $text);
       $text = preg_replace("/\[\/color\]/", "</span>", $text);
       $text = preg_replace("/\[br \/]/", "", $text);
       $text = preg_replace("/\[br]/", "", $text);
       $text = preg_replace("/\[hr \/]/", "<hr />", $text);
       $text = preg_replace("/\[hr]/", "<hr />", $text);
       $text = preg_replace("/\[list\]/", "<ul>", $text);
       $text = preg_replace("/\[\/list\]/", "</ul>", $text);
       $text = preg_replace("/\[olist\]/", "<ol>", $text);
       $text = preg_replace("/\[\/olist\]/", "</ol>", $text);
       $text = preg_replace("/\[li\]/", "<li>", $text);
       $text = preg_replace("/\[\/li\]/", "</li>", $text);
       return $text;
   }
}
$bbc = new BBCode;
?>

 

Staff posting an announcement file -

 

function announcements()
{
   global $db, $ir, $c, $h, $userid, $set;
   if ($ir['user_level'] != 2)
   {
       echo 'You cannot access this area.<br />
       > <a href="staff.php">Go Back</a>';
       die($h->endpage());
   }



   $_POST['TITLE'] =
           (isset($_POST['TITLE']))
                   ? $db->escape(
                           strip_tags(
                                   stripslashes($_POST['TITLE'])))
                   : '';


if($_POST['TITLE'])
{
	if(strlen($_POST['TITLE']) < 5)
	{
	error('Sorry, the annoucement title is too short.');
               die($h->endpage());
	}
               $text = $_POST['TEXT'];
	$db->query("INSERT INTO announcements (`announce_NAME`, `announce_TEXT`, `announce_TIME`, `announce_URGENCY`, `announce_TOPIC`, `announce_POSTED`) VALUES ('{$_POST['TITLE']}', '{$text}', unix_timestamp(), '{$_POST['URGENCY']}', '{$_POST['TOPIC']}', '{$_POST['POSTED']}')");


	$db->query("UPDATE users SET `new_announcements` = `new_announcements` + 1");

	confirmation('Announcement added!');
	stafflog_add('Posted A New Annoucement');
	$h->endpage();
	exit;
}
else
{
	echo 'Adding an announcement - <br />
	Please try to make sure the announcement is concise and covers everything you want it to.
	<form action="staff.php?action=announce" method="post">

	Announcement Title:<input type="text" name="TITLE">
	<br /><br />

	Announcement Text:<br />
	<textarea name="TEXT" rows="10" cols="60">[font=Impact][color=orange][size=3][u]TITLE[/u][/size][/font][/color]</textarea>
	<br /><br />

	Announcement Urgency:
	<select name="URGENCY" type="dropdown">
	<option value="No Urgency">No Urgency</option>
	<option value="Low">Low</option>
	<option value="Medium">Medium</option>
	<option value="High">High</option>
	<option value="Urgent">Urgent</option>
	</select>
	<br /><br />

	Announcement Topic:
	<select name="TOPIC" type="dropdown">
	<option value="Updates">Updates</option>
	<option value="General News">General News</option>
	<option value="Fun">Fun</option>
	<option value="Warnings!">Warnings!</option>
	<option value="Design Info">Design Info</option>
	<option value="Edits">Edits</option>
	</select>
	<br /><br />

	<input type="hidden" name="POSTED" value="'.$ir['username'].'">
	<input type="submit" value="Add Announcement!" />
	</form>';
}

}

1823811362_ScreenShot2014-09-13at11_57_431.png.9390447c73646129181a7093724d0025.png

Posted
Hello guys! It's been long since I have been here. (I've been to Bangladesh for a month.)

I need your help guys! I got a problem which I do not know why it is not working?

 

[ATTACH=CONFIG]1674[/ATTACH]

 

As you can see here. When ever I put a enter gap it does not work? So the in the BBCode Engine it's not doing the <br/>

My BBCodes Engine -

 

<?php


class bbcode
{
   function bbcode_parse($text)
   {
       global $ir, $db, $userid, $set;
       $text = htmlspecialchars($text);
       // Following removed due to security issues regarding session hijacking
       // $text = preg_replace("/\[img=(.+?)\]/", "<img src='$1' alt='Broken or invalid image' />", $text);
       // $text = preg_replace("/\[img\](.+?)\[\/img\]/", "<img src='$1' alt='Broken or invalid image' />", $text);
       // $text = preg_replace("/\[email=(.+?)\](.+?)\[\/email\]/", "<a href='mailto:$1'>$2</a>", $text);
       // $text = preg_replace("/\[email\](.+?)\[\/email\]/", "<a href='mailto:$1'>$1</a>", $text);
       // $text = preg_replace("/\[url=(.+?)\](.+?)\[\/url\]/", "<a href='$1'>$2</a>", $text);
       // End
       $text = preg_replace("/\[b\]/", "<strong>", $text);
       $text = preg_replace("/\[\/b\]/", "</strong>", $text);
       $text = preg_replace("/\[i\]/", "<em>", $text);
       $text = preg_replace("/\[\/i\]/", "</em>", $text);
       $text = preg_replace("/\[u\]/", "<span style='text-decoration:underline;'>", $text);
       $text = preg_replace("/\[\/u\]/", "</span>", $text);
       $text = preg_replace("/\[s\]/", "<s>", $text);
       $text = preg_replace("/\[\/s\]/", "</s>", $text);
       $text = preg_replace("/\[sub\](.+?)\[\/sub\]/", "<sub>$1</sub>", $text);
       $text = preg_replace("/\[sup\](.+?)\[\/sup\]/", "<sup>$1</sup>", $text);
       $text = preg_replace("/\[big\](.+?)\[\/big\]/", "<big>$1</big>", $text);
       $text = preg_replace("/\[small\](.+?)\[\/small\]/", "<small>$1</small>", $text);
       $text = preg_replace("/\[list\](.+?)\[\/list\]/", "<ul>$1</ul>", $text);
       $text = preg_replace("/\[olist\](.+?)\[\/olist\]/", "<ol>$1</ol>", $text);
       $text = preg_replace("/\[li\](.+?)\[\/li\]/", "<li>$1</li>", $text);
       $text = preg_replace("/\[font=(.+?)\](.+?)\[\/font\]/", "<span style='font-family:$1'>$2</span>", $text);
       $text = preg_replace("/\[size=(.+?)\](.+?)\[\/size\]/", "<font size='$1'>$2</font>", $text);
       $text = preg_replace("/\[img[=]?(left|right)?\](([^<> \n]+?)\.(gif|jpg|jpeg|png|bmp))\[\/img\]/i", '<img class="mainimage" src="\\2" border="0" align="\\1"  max-width: 5px  alt="">', $text);
       $text = preg_replace("/\n/", "&nbrlb;", $text);
       $text = preg_replace("/\[left\](.+?)\[\/left\]/", "<div style='text-align: left;'>$1</div>", $text);
       $text = preg_replace("/\[center\](.+?)\[\/center\]/", "<div style='text-align: center;'>$1</div>", $text);
       $text = preg_replace("/\[right\](.+?)\[\/right\]/", "<div style='text-align: right;'>$1</div>", $text);
       $text = preg_replace("/\[quote name='(.+?)\'](.+?)\[\/quote\]/", "<div class='quotetop'>Quote($1)</div><div class='quotemain'>$2</div>", $text);
       $text = preg_replace("/\[quote\](.+?)\[\/quote\]/", "<div class='quotetop'>Quote</div><div class='quotemain'>$1</div>", $text);
       $text = preg_replace("/\[style=(.+?)\](.+?)\[\/style\]/", "<div style='$1'>$2</div>", $text);
       $text = preg_replace("/\[quote\](.+?)\[\/quote\]/", "<div class='quotetop'>Quote</div><div class='quotemain'>$1</div>", $text);
       $text = preg_replace("/\[code\](.+?)\[\/code\]/", "<div class='codetop'>Code</div><div class='codemain'><code>$1</code></div>", $text);
       $text = preg_replace("/\[codebox\](.+?)\[\/codebox\]/", "<div class='codetop'>Code</div><div class='codemain'><code>$1</code></div>", $text);
       $text = preg_replace("/&nbrlb;/", "\n", $text);
       $text = preg_replace("/\[colour=(.+?)\]/", "<span style='color:$1;'>", $text);
       $text = preg_replace("/\[\/colour\]/", "</span>", $text);
       $text = preg_replace("/\[color=(.+?)\]/", "<span style='color:$1;'>", $text);
       $text = preg_replace("/\[\/color\]/", "</span>", $text);
       $text = preg_replace("/\[br \/]/", "</br>", $text);
       $text = preg_replace("/\[br]/", "<br>", $text);
       $text = preg_replace("/\[hr \/]/", "<hr />", $text);
       $text = preg_replace("/\[hr]/", "<hr />", $text);
       $text = preg_replace("/\[list\]/", "<ul>", $text);
       $text = preg_replace("/\[\/list\]/", "</ul>", $text);
       $text = preg_replace("/\[olist\]/", "<ol>", $text);
       $text = preg_replace("/\[\/olist\]/", "</ol>", $text);
       $text = preg_replace("/\[li\]/", "<li>", $text);
       $text = preg_replace("/\[\/li\]/", "</li>", $text);
       return $text;
   }
}
$bbc = new BBCode;
?>

 

Staff posting an announcement file -

 

function announcements()
{
   global $db, $ir, $c, $h, $userid, $set;
   if ($ir['user_level'] != 2)
   {
       echo 'You cannot access this area.<br />
       > <a href="staff.php">Go Back</a>';
       die($h->endpage());
   }



   $_POST['TITLE'] =
           (isset($_POST['TITLE']))
                   ? $db->escape(
                           strip_tags(
                                   stripslashes($_POST['TITLE'])))
                   : '';


if($_POST['TITLE'])
{
	if(strlen($_POST['TITLE']) < 5)
	{
	error('Sorry, the annoucement title is too short.');
               die($h->endpage());
	}
               $text = $_POST['TEXT'];
	$db->query("INSERT INTO announcements (`announce_NAME`, `announce_TEXT`, `announce_TIME`, `announce_URGENCY`, `announce_TOPIC`, `announce_POSTED`) VALUES ('{$_POST['TITLE']}', '{$text}', unix_timestamp(), '{$_POST['URGENCY']}', '{$_POST['TOPIC']}', '{$_POST['POSTED']}')");


	$db->query("UPDATE users SET `new_announcements` = `new_announcements` + 1");

	confirmation('Announcement added!');
	stafflog_add('Posted A New Annoucement');
	$h->endpage();
	exit;
}
else
{
	echo 'Adding an announcement - <br />
	Please try to make sure the announcement is concise and covers everything you want it to.
	<form action="staff.php?action=announce" method="post">

	Announcement Title:<input type="text" name="TITLE">
	<br /><br />

	Announcement Text:<br />
	<textarea name="TEXT" rows="10" cols="60">[font=Impact][color=orange][size=3][u]TITLE[/u][/size][/font][/color]</textarea>
	<br /><br />

	Announcement Urgency:
	<select name="URGENCY" type="dropdown">
	<option value="No Urgency">No Urgency</option>
	<option value="Low">Low</option>
	<option value="Medium">Medium</option>
	<option value="High">High</option>
	<option value="Urgent">Urgent</option>
	</select>
	<br /><br />

	Announcement Topic:
	<select name="TOPIC" type="dropdown">
	<option value="Updates">Updates</option>
	<option value="General News">General News</option>
	<option value="Fun">Fun</option>
	<option value="Warnings!">Warnings!</option>
	<option value="Design Info">Design Info</option>
	<option value="Edits">Edits</option>
	</select>
	<br /><br />

	<input type="hidden" name="POSTED" value="'.$ir['username'].'">
	<input type="submit" value="Add Announcement!" />
	</form>';
}

}

Try that I have amended your bbcode engine. You where replacing nothing for [br] or [/br] try that and see if that works if it does not I will have a look again when I get home

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...