Characters in url being replaced.
Posted: Mon Apr 07, 2008 11:30 pm
This is probably a simple question, but I am unsure of how to fix it.
I have a page set up to take a url from a form, then send it via GET to the same page, then play the file with a shell_exec(). Here is my code:
My problem is that the url gets all special characters replaced with their equivalents for html; i.e. http:// = http%3A%2F%2F when I need http:// to be sent to the command. I can't figure out how to change it back.
When I echo the variable, it shows fine, html doing what it's supposed to do.
How can I get the correct string sent to the command?
Note: Yeah, this is probably very insecure, but this is a locally-accessible only server, so I'm not too worried.
I have a page set up to take a url from a form, then send it via GET to the same page, then play the file with a shell_exec(). Here is my code:
Code: Select all
<html>
<head>
<title>Play music file</title>
</head>
<body>
<?php
$file = $_GET['file'];
if ($file == null) {
echo('<p>Please enter music file you wish to play. Allowed formats are mp3 & wav.</p><form action="play.php" method="get"><p><input type="text" name="file" /><input type="submit" value="Play" /></form>');
} else {
$command = shell_exec('mpg123 "' . $file . '"');
echo('<p>File ' . $file . ' is now playing.');
}
?>
</body>
</html>When I echo the variable, it shows fine, html doing what it's supposed to do.
How can I get the correct string sent to the command?
Note: Yeah, this is probably very insecure, but this is a locally-accessible only server, so I'm not too worried.