TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 08-08-2010, 06:10 PM   #1 (permalink)
The Contributor
 
Tim Dobson's Avatar
 
Join Date: Feb 2010
Posts: 69
Thanks: 16
Tim Dobson is on a distinguished road
Default Embed Youtube code in .htm

Ok so im working on this site... it all works well i have the add youtube script etc...

It uses highslide to view the video on site so the file where the youtube video inbeds i am using is .htm

So i have made a script that allows the website owner to add his videos using a simple layout and it creates a .htm file in the spcified location using the episode number and .htm extension

Anyway i have a text field form where he inserts the Episode name number and the youtube embed code and it all adds but i run in to an issue and now i am clueless

Youtube embed code:
HTML Code:
<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/nvNuc9isOeU&amp;hl=en_GB&amp;fs=1?color1=0x234900&amp;color2=0x4e9e00"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/nvNuc9isOeU&amp;hl=en_GB&amp;fs=1?color1=0x234900&amp;color2=0x4e9e00" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>
so we have the embed code and submit is pushed which takes us to the add script

PHP Code:
$epnumb $_REQUEST["epnum"];
$epembedcode $_REQUEST["epcode"];
//lets right to the new .htm file start off fresh to save confusion
$myFile '../../highslide/eps/ep' $epnumb '.htm';
$fh fopen($myFile'a') or die("can't open file");
$stringData '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Included content</title>
    <style type="text/css">
        p {
            font-family: "Trebuchet MS", Arial, sans-serif;
            font-size: 10pt;
        }
        h3 {
            font-family: "Trebuchet MS", Arial, sans-serif;
            color: #666;
        }
    </style>
</head><body style="margin:0;padding:0">
<p>' 
$epembedcode '</p>
</body>
</html>'

Now this does what its meant to do it creates the new file on server and writes to it, however the youtube embed code comes out like this in the actualy htm file

HTML Code:
<p><object width=\"480\" height=\"385\"><param name=\"movie\" value=\"http://www.youtube.com/v/nvNuc9isOeU&amp;hl=en_GB&amp;fs=1?color1=0x234900&amp;color2=0x4e9e00\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/v/nvNuc9isOeU&amp;hl=en_GB&amp;fs=1?color1=0x234900&amp;color2=0x4e9e00\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"480\" height=\"385\"></embed></object></p>
adding backslashes and bla bla bla and now im lost... why does this do such and thing and how would i fix it?

Thanks
Tim Dobson is offline  
Reply With Quote
Old 08-08-2010, 06:43 PM   #2 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

Seems like the most likely cause is magic_quotes_gpc (thank gosh they finally decided to deprecate and get rid of this k to the rap). Check if you have it running either in your php.ini, via phpinfo(); or get_magic_quotes_runtime() (alternatively check gpc as well). If you do, turn it off, and never ever think about turning it back on (security is our responsibility and relying on the parser to do it for us is bad coding).
__________________
uʍop ǝpısdn sı ɹǝʇndɯoɔ ɹnoʎ sıɥʇ pɐǝɹ uɐɔ noʎ ɟı
delayedinsanity is offline  
Reply With Quote
Old 08-09-2010, 08:41 AM   #3 (permalink)
The Contributor
 
Tim Dobson's Avatar
 
Join Date: Feb 2010
Posts: 69
Thanks: 16
Tim Dobson is on a distinguished road
Default

Well i did look in to this. 500 internal server error from a .htaccess so i looked in the mod_rewrite and as far as i know my server does not have this enabled. Dont have access to the .ini file unfortunatly is there no other alternative? or would i be better off contacting my host?
Tim Dobson is offline  
Reply With Quote
Old 08-09-2010, 03:40 PM   #4 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

Who's your host? A lot of the shared hosts now-a-days offer directory based php.ini, though some of them don't advertise it. Try grabbing a copy for your version of PHP and putting it in your root folder. Run a file with a phpinfo() in it to see if the changes take effect.

Alternatively handle it within your script;

php Code:
$epnumb = stripslashes( $_REQUEST["epnum"] );
$epembedcode = stripslashes( $_REQUEST["epcode"] );

There are also two excellent examples of handling the entire group of superglobals posted in the first two comments at the bottom of http://us.php.net/manual/en/function...quotes-gpc.php of which I won't repost here so the original authors get credit where credit is due. :)
__________________
uʍop ǝpısdn sı ɹǝʇndɯoɔ ɹnoʎ sıɥʇ pɐǝɹ uɐɔ noʎ ɟı
delayedinsanity is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Prettifying Pasted Code on TalkPHP Wildhoney The Lounge 15 01-04-2013 02:46 AM
Tips to Improve Your Coding and Projects Village Idiot Tips & Tricks 45 12-03-2012 07:46 AM
Writing Clean Code Village Idiot Tips & Tricks 10 06-25-2012 12:35 PM
Match code in link with code with one in file and extract line Peuplarchie General 0 10-23-2009 02:38 PM
Game: Let's Develop Something Crazy! Wildhoney The Lounge 25 05-23-2009 09:18 PM


All times are GMT. The time now is 08:09 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design