ClioSport.net

Register a free account today to become a member!
Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

  • When you purchase through links on our site, we may earn an affiliate commission. Read more here.

[Coding] Auto Add IMG Src links to a URL.



Typhoon

Gangsta
ClioSport Moderator
  TT
Just like vBulletin does, I want the user to be able to click a box, inset their url to their image, and it then adds "<img src="their url here">"

Best way?
 
If it's for external links only, you only have to echo '<img src="'.$usersurl.'" />'

Most message boards will already have this functionality though.
 

SharkyUK

ClioSport Club Member
I'll be writing it in PHP more than likely, just for a message board.
So... are you actually writing your own message board system / forum in PHP from scratch or using an existing one? I'm not entirely sure what you are trying to achieve here...

I don't think you'll be able to do much in PHP as it's a server-side scripting language. Maybe something along the lines of the Javascript window.prompt() method is what you need?! That allows (assuming Javascript is enabled on the client machine) for user input. Obviously you will then have to process and validate any input the user enters.
 

Typhoon

Gangsta
ClioSport Moderator
  TT
I've written the message board from scratch, but I can't think of an effective way to add image tags automatically.
Saves people having to type out "<img src="Lynkzzzz.gif>" manually.
 

SharkyUK

ClioSport Club Member
I've written the message board from scratch, but I can't think of an effective way to add image tags automatically.
Saves people having to type out "<img src="Lynkzzzz.gif>" manually.

Ah, got it. I would probably do something along the lines of popping up a dialog using Javascript that captures the user's input. Once you've got that input do the necessary validation and parsing so that you build up your "<img...>" string. Once that is done, append / insert that built string to the contents of the text input area used for catching the user's post (by updating the DOM). That should do the trick.
 
  182/RS2/ Turbo/Mk1
If its your own software and users can stay logged in, think a bit about security.
If you let people put their on javascript in for example then it will allow them to steal the cookies from other peoples machines (did a bit of hacking like that back when forums were a new thing and not as well developed as now)
 

Typhoon

Gangsta
ClioSport Moderator
  TT
Ah, got it. I would probably do something along the lines of popping up a dialog using Javascript that captures the user's input. Once you've got that input do the necessary validation and parsing so that you build up your "<img...>" string. Once that is done, append / insert that built string to the contents of the text input area used for catching the user's post (by updating the DOM). That should do the trick.

Yeah, I'll give that a go man, cheers.

If its your own software and users can stay logged in, think a bit about security.
If you let people put their on javascript in for example then it will allow them to steal the cookies from other peoples machines (did a bit of hacking like that back when forums were a new thing and not as well developed as now)

Yeah, jSessionID theft. I've used strip_tag modules at the minute.
 


Top