GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 05-Aug-2003, 23:43
Caged Caged is offline
New Member
 
Join Date: Aug 2003
Posts: 2
Caged is an unknown quantity at this point

Php bbcode issue


Hi I am attempting to use the php bbcode function listed in the Code Archive forum but I am getting an error when trying to process information from a form.

I just created a basic form with a text area to test the code

Code:
<form action="highlight.php" method="post" enctype="multipart/form-data" name="TutorialSubmmit"> <textarea name="contents" cols="30" rows="6" ></textarea> <input name="submit" type="submit" class="submit" value="Submit"> </form>

And I have the php bbcode stored within the highlight.php file and I am using the function like

[code]
processbb_php($contents);
[/php]

Am I using the function correctly? If not then could you please provide an example as to the correct way to do this.

Thanks in Advance
  #2  
Old 06-Aug-2003, 04:37
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Hello Caged,

Looking at your example above, and from what I can assume from it, it does seem like that function: processbb_php() will not work for you.

It all depends on what is inside $contents; e.g.

PHP Code:

<?php

// is $contents including plain text and / or other bbcodes?
$contents = 'This is a test paragraph.
[php_]
<?php
  phpinfo();
?>
[/php_]
Including some highlighted php code.';

// or is $contents just php code?
$contents = '<?php
  phpinfo();
?>';

?>


Also, it would matter if the string is passed through htmlentities() / htmlspecialchars() before-hand or not...
  #3  
Old 06-Aug-2003, 16:21
Caged Caged is offline
New Member
 
Join Date: Aug 2003
Posts: 2
Caged is an unknown quantity at this point
I thought the highlight_php function handled html as well?

Will the contents need to be passed through htmlentities first and then sent to your bb code function?

$contents will contain normal text as well as php code mixed with html just like your article system on your main site. Basically I'm wanting to do something alot like you got here...provide my editors a means of making php code stand out among there normal instructions.
  #4  
Old 06-Aug-2003, 18:55
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Take a look at the example at the bottom of this thread: http://www.gidforums.com/t-727.html.

Yes, php highlighting will take care of the html as well but I preferred to wrap the block with <pre> tags so I had to remove all &nbsp; and line breaks inserted by the function (in highlighted PHP code).

Usually, I make it a habit to pass any string (potentially supplied by others) through htmlentities() first.

So, I would normally start working on $contents, with this line:
PHP Code:

<?php

$contents = htmlentities( $row['contents'] );

?>


But if you decide to do this too, you have to add (to the top) a line in the custom function parsePHP( $str ).

PHP Code:

<?php
// the function parsePHP()
function parsePHP( $str )
{
  // added line here
  $str = html_entity_decode( $str );

  $mark = marker( 'PHP' );
  $str = highlight_string( $str, 1 );
  // add the marker and highlighted code into our $replacements array
  $GLOBALS['replacements']["$mark"] = $str;
  return $mark;
}
?>

 
 

Recent GIDBlog2nd Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Optimizing your web server with Turck MMCache for PHP JdS Web Hosting Forum 2 07-Jan-2004 07:48
apache2 - php cgi fehler - schleife inna Apache Web Server Forum 8 27-Nov-2003 09:55
[Linux] Installing PHP --with-mcrypt JdS Web Hosting Forum 0 20-Aug-2003 08:40
PHP in HTML jrobbio Web Design Forum 4 24-Jul-2003 06:05
All the big PHP script collections that matter jrobbio MySQL / PHP Forum 5 06-Jun-2003 16:14

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 18:48.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.