views:

41

answers:

1

Hi there,

I am working on a small project for learning PHP better. This project has a primary file, which opens another website (e.g. youtube) by using fopen + fread. (or file_get_contents ?)

The site will be saved into a variable and after that a function will parse the file's content and should replace certain items with advanced content, for example:

<div onclick="play(id=12432);">
Play Video
</div>

replace with

<div onclick="play(id=12432);">
Play Video
<div>
<div onclick="add2fav(id=12432);">
Add to favorites
</div>

Any idea how someone can perform this without huge performance leeks and clean code?

It is just about "loading a website", "advance its content", "echo it".

+1  A: 

Simply embed the youtube video, and don't parse the whole page. It could be done very easily. Then put under the video your special buttons. Be aware! Don't trust your users input. If you embed based on someones input, maybe you embed a mlicious site, and it's dangerious. Lear about XSS/CSRF.

erenon