Jump to content

Archived

This topic is now archived and is closed to further replies.

Ninjakreborn

somethign wrong with script

Recommended Posts

What am I doing wrong here
[code]
$funnyurl = $site . $funnyurl;
if (preg_match("/[.txt]{4}/i", $funnyurl)){
require_once("./includes/view_text.php");
}else if (preg_match("/[.jpg|.gif|.jpeg|.bmp|.tiff]{4}/i",$funnyurl)) {
require_once("./includes/view_picture.php");
}else if (preg_match("/[.mov]{4}/i",$funnyurl)) {
require_once("./includes/view_quicktime.php");
}else if (preg_match("/[.ram|.rm|.ra|.rpm]{4}/i",$funnyurl)) {
require_once("./includes/view_realmedia.php");
}else if (preg_match("/[.asf|.wma|.wmv|.wma|.wm|.asf|.avi|.mpeg|.mpg|.mp2|.mp3|.mid|.midi|.wav]{4}/i",$funnyurl)) {
require_once("./includes/view_windowsmedia.php");
}else if (preg_match("/[.swf|.swc|flv]{4}/i",$funnyurl)) {
require_once("./includes/view_flash.php");
}else {
echo "No file exists at this location";
}
[/code]
http://www.funnyemailforwards.com/display.php
The problem is currently, it shows a media player file it shouldn't were did I misformat my code?
It isn't suppose to show anything unless something matches one of those filetypes, it was working right all the way down to the point where I added in
else if (preg_match("/[.asf|.wma|.wmv|.wma|.wm|.asf|.avi|.mpeg|.mpg|.mp2|.mp3|.mid|.midi|.wav]{4}/i",$funnyurl)) {
require_once("./includes/view_windowsmedia.php");
}
Now it tried to show that one whether it matches or not.

Share this post


Link to post
Share on other sites
Is there a reason you place a space between your else and if's ?
I mostly use
[code]
<?php
if(...) {
  ...
} elseif(...) {
  ...
} else {
  ...
}
?>
[/code]

I also noticed you are missing a dot in your last preg_match =:> [.swf|.swc|<b>.</b>flv]{4}
This will not solve your problem but it's certainly a 'mini' bug in your script.

Share this post


Link to post
Share on other sites
[code]
<?php
$funnyurl = $site . $funnyurl;
if (preg_match("/[.txt]{4}/i", $funnyurl)){
require_once("./includes/view_text.php");
}elseif (preg_match("/[.jpg|.gif|.jpeg|.bmp|.tiff]{4}/i",$funnyurl)) {
require_once("./includes/view_picture.php");
}elseif (preg_match("/[.mov]{4}/i",$funnyurl)) {
require_once("./includes/view_quicktime.php");
}elseif (preg_match("/[.ram|.rm|.ra|.rpm]{4}/i",$funnyurl)) {
require_once("./includes/view_realmedia.php");
}elseif (preg_match("/[.asf|.wma|.wmv|.wma|.wm|.asf|.avi|.mpeg|.mpg|.mp2|.mp3|.mid|.midi|.wav]{4}/i",$funnyurl)) {
require_once("./includes/view_windowsmedia.php");
}elseif (preg_match("/[.swf|.swc|.flv]{4}/i",$funnyurl)) {
require_once("./includes/view_flash.php");
}else {
echo "No file exists at this location";
}
?>
[/code]
I took care of all those, I was getting confused with java script, I mostly use javascript or did.
The next question I had is why isn't it working now, it's still having the same problem
http://www.funnyemailforwards.com/display.php

Share this post


Link to post
Share on other sites
What does $funnyurl contain?

Can you use a combination of the parse_url() and pathinfo() functions to get the file extension and then use a switch statement to include the proper file?

Ken

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.