Modifying PHP Code to Automatically Insert Image

  • Thread starter Jameson
  • Start date
  • Tags
    Php
In summary, the person is trying to figure out how to automatically insert an image whenever someone types in some code on a phpBB forum. They found a tutorial on how to do it, but are having trouble following it because it is in a language they are not familiar with and there are no instructions on how to replicate it.
  • #1
Jameson
Gold Member
MHB
4,541
13
I have a phpBB forum and I'm trying to edit some code so that whenever someone types in \(\displaystyle Some code\) it automatically inserts <img src="mysite.com/cgi-bin-mimetex.cgi?Some code">. This will save people the trouble of typing in all of the extra stuff. It seems rather simple but I have no idea how to go about it.

Any ideas?
 
Computer science news on Phys.org
  • #2
I would imagine the cleanest way to do this is find the script that handles the other BB codes, the add the few new tags of your own using similar syntax.

This is going to require you to do some tracing from the post display php, unless someone with experience would kindly pinpoint the file :P

With Invision Boards which I use on my site, there is a file in the /lib/ directory post_parser.php, which contains a

//-----------------------------------------
// Custom BB code
//-----------------------------------------

section. I could imagine phpBB having something similar.
 
Last edited:
  • #3
That's what I was thinking, but I'm not familiar with PHP and the syntax is very meticulous.
 
  • #4
I know the file... and I'm looking at the code right now. I'm just not sure how to recreate it. There are many parts.

Here's some of it:

Code:
function prepare_bbcode_template($bbcode_tpl)
{
	global $lang;

	$bbcode_tpl['olist_open'] = str_replace('{LIST_TYPE}', '\\1', $bbcode_tpl['olist_open']);

	$bbcode_tpl['color_open'] = str_replace('{COLOR}', '\\1', $bbcode_tpl['color_open']);

	$bbcode_tpl['size_open'] = str_replace('{SIZE}', '\\1', $bbcode_tpl['size_open']);

	$bbcode_tpl['quote_open'] = str_replace('{L_QUOTE}', $lang['Quote'], $bbcode_tpl['quote_open']);

I can see where certain parts fit in, but I couldn't write it myself.
 
  • #5
I did some searches and it says that phpBB's code is in bbcode.php. A bit tedious to go through... that's why I didn't choose to do programming as a major >.<

However, while searching I did come across this site, which is probably the best direct help you could probably get.

http://www.phpbbhacks.com/forums/archive/o_t/t_54124/making_your_custom_bbcode.html [Broken]
 
Last edited by a moderator:
  • #6
Hey thanks a bunch! That's a great tutorial. I'll let you know if I get something useful written.
 
  • #7
Hmmm... reading this through, I'm having trouble following it. I need something to the evquivalent of this.

When $text = \(\displaystyle then copy until \)
and insert <img src="mysite.com/cgi-bin/mimetex.cgi?$text">

That's not in any language of course, but the general logic of it. I tried reading that tutorial, and it starts out nicely, but kind of stops describing.
 
  • #8
No one here knows PHP? :(
 
  • #9
Further explain this and I'll give you the instructions
Do you mean when someone types \(\displaystyle text here\) it inserts <img src="mysite.com/cgi-bin/memetex.cgi?text%20here">

If so I'll give the directions ASAP
 
  • #10
Thanks for the help, but I already got the code from someone else. Appreciate it.
 

What is PHP code modification?

PHP code modification involves making changes to the existing PHP code in order to achieve a specific goal, such as automatically inserting an image into a webpage.

Why would I need to modify PHP code to insert an image?

In some cases, the image may need to be inserted dynamically based on user input or other factors. Modifying the PHP code allows for this type of functionality.

What are the potential risks of modifying PHP code?

Modifying PHP code can introduce bugs or security vulnerabilities if not done carefully. It is important to thoroughly test the modified code before deploying it to a live environment.

How can I ensure my modified PHP code is efficient and effective?

It is important to follow best practices and use proper coding techniques when modifying PHP code. Regular testing and debugging can also help ensure the code is efficient and effective.

Are there any tools or resources available to assist with modifying PHP code?

Yes, there are various online resources, tutorials, and forums that can provide guidance and support for modifying PHP code. Additionally, there are code editors and debugging tools that can help with the process.

Similar threads

  • Computing and Technology
Replies
2
Views
8K
Replies
10
Views
2K
  • Programming and Computer Science
Replies
4
Views
6K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
222
  • Computing and Technology
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
Replies
1
Views
526
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • STEM Career Guidance
Replies
4
Views
1K
Back
Top