Author Topic: about BB Code  (Read 814 times)

Offline azsxsaz13

  • Hero Member
  • *****
  • Posts: 44
  • Karma: +0/-0
about BB Code
« on: April 01, 2014, 10:09:04 AM »
Hi, Alexa
Hope you’re well.

It would be great if this be added in MaPA Answers

I added BB Code in  "Reply to this Answer", but encountered a problem.
I added it in article.php:
Code: [Select]
<script>edToolbar('secondfield');</script>
over
Code: [Select]
<textarea name="text1" rows="3" cols="50" id="secondfield"></textarea><br /><br />

Here it displayed and I do not know how to fix:
Code: [Select]
Invalid Characters '[' 

I would be happy if you could help me

if I can ask you one more question about BB Code

I want to add the option: URL

I added this line in ed.js:
Code: [Select]
document.write("<a name=\"btnCode\" title=\"URL\" onClick=\"doAddTags('[url]','[/url]','"+obj+"')\"><img src=\"editore/images/superscript.png\" width=\"16\" height=\"16\" border=\"0\">&nbsp;URL</a>");

but I have trouble adding a line in modifier.bbcode2html.php and modifier.bbcode3html.php
I do not know what to do here:

Code: [Select]
$preg = array( 
// Font and text manipulation ( [color] [size] [font] [align] )
'/\[code(?::\w+)?\](.*?)\[\/code(?::\w+)?\]/si' => "<div>Code:<div class=\"prettyprint\">\\1</div></div>",
'/\[b(?::\w+)?\](.*?)\[\/b(?::\w+)?\]/si' => "<b>\\1</b>",
'/\[i(?::\w+)?\](.*?)\[\/i(?::\w+)?\]/si' => "<i>\\1</i>",
'/\[u(?::\w+)?\](.*?)\[\/u(?::\w+)?\]/si' => "<u>\\1</u>",
'/\[quote(?::\w+)?\](.*?)\[\/quote(?::\w+)?\]/si' => "<blockquote>\\1</blockquote>",
'/\[quote=(?:&|"|\')?(.*?)["\']?(?:&|"|\')?\](.*?)\[\/quote(?::\w+)?\]/si' => "<div class=\"ng_quote\">Quote \\1:<div class=\"ng_quote_body\">\\2</div></div>"
);




Offline alexa

  • Administrator
  • Hero Member
  • *****
  • Posts: 493
  • Karma: +7/-1
Re: about BB Code
« Reply #1 on: April 01, 2014, 03:29:08 PM »
Hello,

Please provide code from your review.php file.


URL in BBCode modifer:


Code: [Select]
// [url] 
'/\[url(?::\w+)?\]www\.(.*?)\[\/url(?::\w+)?\]/si' => "<a href=\"http://www.\\1\" target=\"_blank\" class=\"ng_url\">\\1</a>",
'/\[url(?::\w+)?\](.*?)\[\/url(?::\w+)?\]/si' => "<a href=\"\\1\" target=\"_blank\" class=\"ng_url\">\\1</a>",
'/\[url=(.*?)(?::\w+)?\](.*?)\[\/url(?::\w+)?\]/si' => "<a href=\"\\1\" target=\"_blank\" class=\"ng_url\">\\2</a>",

Offline azsxsaz13

  • Hero Member
  • *****
  • Posts: 44
  • Karma: +0/-0
Re: about BB Code
« Reply #2 on: April 02, 2014, 02:46:01 AM »
Hi, Alexa
thanks for the reply

I wanted to do here in this photo, but it seems too complicated for me. I'll be glad for advice

Offline alexa

  • Administrator
  • Hero Member
  • *****
  • Posts: 493
  • Karma: +7/-1
Re: about BB Code
« Reply #3 on: April 02, 2014, 10:22:38 AM »
I will try to find a solution till tomorrow.  :)

Offline azsxsaz13

  • Hero Member
  • *****
  • Posts: 44
  • Karma: +0/-0
Re: about BB Code
« Reply #4 on: April 02, 2014, 03:40:34 PM »
thank you, Alexa  :)

Offline alexa

  • Administrator
  • Hero Member
  • *****
  • Posts: 493
  • Karma: +7/-1
Re: about BB Code
« Reply #5 on: April 03, 2014, 03:11:29 AM »
article.php

replace this code:

Code: [Select]
<a href="profile.php?id={$secsub.comenter}"><strong>{$secsub.commid}</strong></a>
{$secsub.ctexte|stripslashes}

with this code:

Code: [Select]
<a href="profile.php?id={$secsub.comenter}"><strong>{$secsub.commid}</strong></a>
{$secsub.ctexte|intergrate:$sitepath|stripslashes|bbcode2html|nl2br}

and this code:

Code: [Select]
<textarea name="text1" rows="3" cols="50" id="secondfield"></textarea><br /><br />

with this code:

Code: [Select]
<script>edToolbar('secondfield{$firstsub.revid}');</script>
<textarea name="text1" rows="3" cols="50" id="secondfield{$firstsub.revid}"></textarea><br /><br />

editore/ed.js


Upload attachment (+ change url icon).

modifier.bbcode2html.php

replace this code:

Code: [Select]
'/\[code(?::\w+)?\](.*?)\[\/code(?::\w+)?\]/si' => "<div>Code:<div class=\"prettyprint\">\\1</div></div>",

with this code:

Code: [Select]
'/\[code(?::\w+)?\](.*?)\[\/code(?::\w+)?\]/si' => "<div>Code:<div class=\"prettyprint\">\\1</div></div>",
// [url]
'/\[url(?::\w+)?\]www\.(.*?)\[\/url(?::\w+)?\]/si' => "<a href=\"http://www.\\1\" target=\"_blank\" class=\"ng_url\">\\1</a>",
'/\[url(?::\w+)?\](.*?)\[\/url(?::\w+)?\]/si' => "<a href=\"\\1\" target=\"_blank\" class=\"ng_url\">\\1</a>",
'/\[url=(.*?)(?::\w+)?\](.*?)\[\/url(?::\w+)?\]/si' => "<a href=\"\\1\" target=\"_blank\" class=\"ng_url\">\\2</a>",

 :)
« Last Edit: April 03, 2014, 03:23:40 AM by alexa »

Offline azsxsaz13

  • Hero Member
  • *****
  • Posts: 44
  • Karma: +0/-0
Re: about BB Code
« Reply #6 on: April 03, 2014, 06:33:27 PM »
Hi, Alexa
there's something we missed, because the message appears again:
Code: [Select]
Invalid Characters. '[' 
I do not know where is the problem   ???
it comes to sending Reply to this Answer

Offline alexa

  • Administrator
  • Hero Member
  • *****
  • Posts: 493
  • Karma: +7/-1
Re: about BB Code
« Reply #7 on: April 03, 2014, 06:40:54 PM »
Try with this review.php


Code: [Select]
<?php session_start();
include ('settings.php');
error_reporting(E_ERROR | E_WARNING | E_PARSE);
require_once 'classes/SessionManager.class.php';
$sess=SessionManager::getInstance();
if(!isset($sess->myvar) || !$sess->myvar) { header('Location: signin.php');die(); }
if(!$_SESSION['myvar']) {echo $lang['100'];die();}
if(get_magic_quotes_gpc()) {
$main = htmlspecialchars(stripslashes($_POST['main']));
$comrev = htmlspecialchars(stripslashes($_POST['comrev']));
        $idrev = htmlspecialchars(stripslashes($_POST['idrev']));
$text = htmlspecialchars(stripslashes($_POST['text']));
$newimg = htmlspecialchars(stripslashes($_POST['newimg']));
$ccuid = htmlspecialchars(stripslashes($_POST['ccuid']));
        $chelper = htmlspecialchars(stripslashes($_POST['chelper']));
$text1 = htmlspecialchars(stripslashes($_POST['text1']));
} else {
$main = htmlspecialchars($_POST['main']);
$comrev = htmlspecialchars($_POST['comrev']);
        $idrev = htmlspecialchars($_POST['idrev']);
$text = htmlspecialchars($_POST['text']);
$newimg = htmlspecialchars($_POST['newimg']);
$ccuid = htmlspecialchars($_POST['ccuid']);
        $chelper = htmlspecialchars($_POST['chelper']);
$text1 = htmlspecialchars($_POST['text1']);
}
?>
<head>
<link rel="stylesheet" type="text/css" href="themes/<?php echo $themes; ?>/styles/style.css" />
</head>
<?php
$subtext = substr($text1,0,8);
if(@$_SESSION["reloadse"] == $subtext) {
echo "<center><div id='error'>$lang[094]</div></center>";
die();
}
if(strlen($text1) < 5) {
echo "<center><div id='error'>$lang[130]&nbsp;<a href='javascript:history.go(-1)'>$lang[004]</a></div></center>";
die();
}
if(strlen($text1) > $maxposting) {
echo "<center><div id='error'>$lang[131]&nbsp;<a href=\"javascript:history.go(-1)\">$lang[004]</a></div></center>";
die();
}
if($comrev == false) {
echo 'Error [72]';
die();
}
if($idrev == false) {
echo 'Error [72]';
die();
}
@$_SESSION["reloadse"] = $subtext;

$time = date("Y-m-d H:i:s");
$helper = preg_replace('/([?,\/,|,",\',:,%,(,),[,\,\],\,])/', "-", $chelper);
$helper = urlencode($helper);
$sql2 = $conn->Prepare('INSERT INTO reviews (comrev,idrev,cmain,comenter,commid,comimage,cdate,chelper,ctexte) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)');
if($conn->Execute($sql2,array($comrev,$idrev,"1",$text,$ccuid,$newimg,$time,$helper,$text1)) === false) {
print '<br /><div id="error">error inserting[1]: '.$conn->ErrorMsg().'</div><br />';
}
$sql3 = $conn->Prepare('UPDATE article SET commno = commno +  ? WHERE univer = ?');
if($conn->Execute($sql3,array("1",$comrev)) === false) {
print '<br /><div id="error">error inserting[1]: '.$conn->ErrorMsg().'</div><br />';
}
$conn->Close();
$asty = $_SERVER['HTTP_REFERER'];
?>
<head>
<script type="text/javascript">
function delayer(){
window.location = "<?php echo $asty ?>"
    }
</script>
</head>
<body onLoad="setTimeout('delayer()', 800)">
<center><div style='text-align:center;width:468px;margin:0px auto;min-height:98px;max-height:98px;background: #F8F8F8;font-size:12px;color:#555;font-family:tahoma;helvetica,arial;border-top: 1px dashed #EEE;margin-top:32px;padding-top:8px;'><?php echo $lang['166'] ?><br /><br /><img src="themes/<?php echo $themes; ?>/styles/images/ajax-loader.gif" border="0"><br /><br /></div></center>

Offline azsxsaz13

  • Hero Member
  • *****
  • Posts: 44
  • Karma: +0/-0
Re: about BB Code
« Reply #8 on: April 03, 2014, 07:41:59 PM »
I'm with the old version 1.1 and gives an error in line 4, but my file(review.php) remove this line:
Code: [Select]
if(preg_match("/\\[/",$text1)) {
echo "<center><div id='error'>$lang[INVALIDCHAR]&nbsp;'['&nbsp;<a href=\"javascript:history.go(-1)\">$lang[BOOKBACK]</a></div></center>";
Die();
}

and the things fell into place  :)
Тhank you
Alexa, Why not display BB code in Reply to this Answer
shows this:
Code: [Select]
test [b]test[/b] test 

Offline alexa

  • Administrator
  • Hero Member
  • *****
  • Posts: 493
  • Karma: +7/-1
Re: about BB Code
« Reply #9 on: April 03, 2014, 07:57:36 PM »
Make sure you replace this code:


Code: [Select]
{$secsub.ctexte|stripslashes}

with this code:

Code: [Select]
{$secsub.ctexte|intergrate:$sitepath|stripslashes|bbcode2html|nl2br}

Offline azsxsaz13

  • Hero Member
  • *****
  • Posts: 44
  • Karma: +0/-0
Re: about BB Code
« Reply #10 on: April 03, 2014, 08:19:31 PM »
Alexa, replaced, but the problem is not there.

Offline alexa

  • Administrator
  • Hero Member
  • *****
  • Posts: 493
  • Karma: +7/-1
Re: about BB Code
« Reply #11 on: April 03, 2014, 08:27:45 PM »
Try with this code in bb2html

Code: [Select]
function smarty_modifier_bbcode2html($message) { 
$preg = array(
// Font and text manipulation ( [color] [size] [font] [align] )
'/\[code(?::\w+)?\](.*?)\[\/code(?::\w+)?\]/si' => "<div>Code:<div class=\"prettyprint\">\\1</div></div>",
// [url]
'/\[url(?::\w+)?\]www\.(.*?)\[\/url(?::\w+)?\]/si' => "<a href=\"http://www.\\1\" target=\"_blank\" class=\"ng_url\">\\1</a>",
'/\[url(?::\w+)?\](.*?)\[\/url(?::\w+)?\]/si' => "<a href=\"\\1\" target=\"_blank\" class=\"ng_url\">\\1</a>",
'/\[url=(.*?)(?::\w+)?\](.*?)\[\/url(?::\w+)?\]/si' => "<a href=\"\\1\" target=\"_blank\" class=\"ng_url\">\\2</a>",
'/\[b(?::\w+)?\](.*?)\[\/b(?::\w+)?\]/si' => "<b>\\1</b>",
'/\[i(?::\w+)?\](.*?)\[\/i(?::\w+)?\]/si' => "<i>\\1</i>",
'/\[u(?::\w+)?\](.*?)\[\/u(?::\w+)?\]/si' => "<u>\\1</u>",
'/\[quote(?::\w+)?\](.*?)\[\/quote(?::\w+)?\]/si' => "<blockquote>\\1</blockquote>",
'/\[quote=(?:&|"|\')?(.*?)["\']?(?:&|"|\')?\](.*?)\[\/quote(?::\w+)?\]/si' => "<div class=\"ng_quote\">Quote \\1:<div class=\"ng_quote_body\">\\2</div></div>"
);

Offline azsxsaz13

  • Hero Member
  • *****
  • Posts: 44
  • Karma: +0/-0
Re: about BB Code
« Reply #12 on: April 03, 2014, 08:36:25 PM »
Alexa, in a previous post- there turned out to be the problem
everything works PERFECT  :)
I do not know how to thank you for everything

Offline alexa

  • Administrator
  • Hero Member
  • *****
  • Posts: 493
  • Karma: +7/-1
Re: about BB Code
« Reply #13 on: April 03, 2014, 08:44:01 PM »
 :)