Welcome to Dream.In.Code
Getting Help is Easy!

Join 107,639 Programmers for FREE! Ask your question and get quick answers from experts. There are 981 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



How does this process work?

 
Reply to this topicStart new topic

How does this process work?, user based editing question

jumpman23
post 16 Jun, 2008 - 12:34 AM
Post #1


New D.I.C Head

*
Joined: 13 Jun, 2008
Posts: 7

ok I'm going to try to explain this in the clearest way.. Im in development of a social type based website but with a spin off.. I understand that PHP is going to need to talk to mysql for the fundamentals such as friends, and other information. Now my question is, What is the best way to have a textbox that reflects the html.. In terms of thinking, take myspace for example.. You have an about me box were you can enter general information were the page displays a default layout of that information.. MY question is How is it possible so that it translates all the information from the textbox and embed it into the html with the format. I understand its through CSS layout, But how does it translate.
For example, in the myspace mind frame, if you were to go to one of those myspace modifier websites, Take the code they provide and inject it into the textbox, it completly changes the whole look of that page to a diffrent template with backrounds, etc. Im not trying to mimic myspace, but understand how this is accomplished and done. Thanks for the help on this confusing process.
User is offlineProfile CardPM

Go to the top of the page


BetaWar
post 16 Jun, 2008 - 01:05 AM
Post #2


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,117



Thanked 38 times

Dream Kudos: 725
My Contributions


I haven't personally used myspace (thank god) but I believe what you are talking about is a sort of BB code system. The information (be it code or whatever) that is inserted into the textbox is being parsed (and looked through) either on submission, or when the page is rendered adn then changing its contents by replacing what the program recognizes with what it is told to replace with.

Take this case for example. You have some BB to make text bold this is done with
CODE
[b]Bold Text[/b]
The server (backend) looks at the stuff and says something to the effect of "Oh, hey look there is a [ b] tag. I am supposed to change that out with a <b> tag. Okay I did that any more?" And will go through as much as is fed to it and look for the various things to replace.

The replace is commonly done with preg_replace (a php function) and can look like so:

CODE

$string_given = "[b]Bold Text[/b]";
$output = preg_replace("|\[b\](.*?)\[\/b\]|i", "<b>$1</b>", $string_given);


And would output something looking like so:

Bold Text

I believe that the same system (or at least type of thing) is going on behind the scene at myspace and other social networking sites. They are just replacing some code bits with more things. Like so:

CODE

$skin_array = array("<style>body{whatever} etc.</style>", "More styles", "and more styles", "and so on");
$string_given = "Look a different skin: <[Skin_0]>";
$output = preg_replace("|\[<\[Skin_(.*?)\]\>|i", $skin_array[$1], $string_given);


Which would output:

QUOTE
Look a new skin: <style>body{whatever} etc.</style>


Everything is also kept in a mysql (orother) database to make it easy to find and use again

Hopefully that was able to help you, or at least touched a bit upon what you were asking.

NOTE - I didn't test the code, so it may not work.

This post has been edited by BetaWar: 16 Jun, 2008 - 01:10 AM
User is offlineProfile CardPM

Go to the top of the page

jumpman23
post 16 Jun, 2008 - 09:14 AM
Post #3


New D.I.C Head

*
Joined: 13 Jun, 2008
Posts: 7

yea in a way you can think in terms of BB.. But heres what i dont understand, You have default text boxes like i said to input your information such as about me, interests. But what seems to happen is people are actually getting CSS layouts and pasting the code in those boxes, and it is creating a whole new template from that.
How is this code putting itself in say the <Body> of the html so that it rearranges the while page such as changing the borders color adding pictures abouve a default picture, so on and so forth.
User is offlineProfile CardPM

Go to the top of the page

BetaWar
post 16 Jun, 2008 - 11:55 AM
Post #4


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,117



Thanked 38 times

Dream Kudos: 725
My Contributions


That is likely simply the CSS. If myspace allows for css injections, a user could potentially change the whole look of the site, or make it display nothing. Bascially they inject the CSS into one of the boxes and use myspace's class and id names for html tags. Then when the page is loaded it overwrites the previous css with the injected stuff. Sadly I can't find an example of a forum that still allows for css injections, but that would make sinceif myspace didn't take them out.

Here is an example of what it could look like:

CODE
<style>
b{
  font-size: 120px;
}
</style>

<body>

<div>
Content and people's information <style>b{display: none;}</style> (CSS injection).
<b> NICE BIG BOLD TEXT!!!</b>
</div>


See the first styleis telling it to be huge text. The 'injection' is telling it not to show, so since the second one came later it overwrites the first one and bold text doesn't show.

This same property can be done (I presume) on myspace.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 8/29/08 06:59PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month