php help

argh found a problem

im using this php to send params to an activex control

its a basic chat.ocx

but when i use links like this

index.php?server=gggg

it only printf's the param names and overrides the html from showing/loading..

when i run plain index.php the chat works but has no params.

code

Code:
<html>
 </object>
<OBJECT ID="ChatFrame"
CLASSID="CLSID:982E01D9-0386-441C-B151-83035135A918"
CODEBASE="CHAT.ocx">

foreach ($_GET as $param => $value) {

printf('<PARAM NAME="%s" value="%s">%s',$param,$value,"\n");
 }  
</OBJECT>
</BODY>
</HTML>
<html>

any idea how to make it printf the php part and write the html as well?

http://denby.ukhost-group.co.uk/index3.php?Server=irc.amcool.net

cheers
 
Last edited:
No, he did a bad job. It's insecure as hell.

I shall justify, but in a less rude way as I did before, because rob's comment was just totally unnecessary, in my opinion.

what I did works, which was what the OP asked for. When I started out, I wanted people to explain things like this to me in a simple way because anything more than that can be quite overwhelming. I, maybe incorrectly, assumed that the OP is just starting out with PHP, and didn't want to confuse him with htmlspecialchars and the like, because they weren't related to what he was trying to do.

So, you're right - in the grand scheme of things, it wasn't a good job - but when do you see tutorials for this sort of thing using htmlspecialchars? You don't - for the very same reason that I didn't.

psyreen was correct (I never disputed this), you do need to make-safe the data because a lot of harmful things can be run from $_GET, so please don't use solely what I posted if it's actually going online :) however, I'd do this:

PHP:
foreach ($_GET as $param => $value) {
  printf('<param name="%s" value="%s" />',htmlspecialchars($param),htmlspecialchars($value));
}

if that's still very insecure - for my edification I would appreciate the feedback, but I'd never do anymore than that in a real-world example. obviously, you could create a blocklist - but that would add complexity to the situation that the OP doesn't seem to be after at this stage
 
Back
Top Bottom