Jump to content

can any help and correct this


pklover

Recommended Posts

i have search this php code by net and this not work in my site can any help and correct this

 

<?php

if($_SERVER['DOCUMENT_ROOT']=="/home/user/public_html"){

$flv=array(

'1' => 'video1.flv',

'2' => 'video2.flv',

'3' => 'video3.flv',

'4' => 'video4.flv',

'5' => 'video5.flv'

);

readfile ($flv[$_GET['tv']]);

}else{

header("Location: mysite.com/sorry.flv");

}

?>

Link to comment
https://forums.phpfreaks.com/topic/195535-can-any-help-and-correct-this/
Share on other sites

<?php
if($_SERVER['DOCUMENT_ROOT'] == '/home/user/public_html')
{
$flv=array(
	'1' => 'video1.flv',
	'2' => 'video2.flv',
	'3' => 'video3.flv',
	'4' => 'video4.flv',
	'5' => 'video5.flv'
);
readfile($flv[$_GET['tv']]);
}
else
header('Location: mysite.com/sorry.flv');
?>

 

What isn't working, exactly?

 

I'm assuming you just want to output a FLV, based on a parameter passed via URL.  If that's the case:

 

1) Make sure that you're passing a valid value for "tv" in the URL (1-5.)

2) Is the document root correct?

3) Is "mysite.com/sorry.flv" for our benefit or is that actually in your code?

this code is checking if the server's document root is set to /home/user/public_html. if it is, it creates an array of values $flv.

 

it then tries to output a value (a video file) based on the GET value of 'tv', else it will redirect the user to mysite.com/sorry.flv

 

ways this could fail:

if:

- $_SERVER['DOCUMENT_ROOT'] is not equalling "/home/user/public_html" <- this literally means that string. not your username where it says "user"

- $_GET['tv'] is not set, or is not set to a value from 1 to 5. - probably no error would be thrown in this case - you might not even know its not working besides that a download window wouldn't appear in the browser. a regular user wont know the difference but. they'd just likely say "what the hell?" and close the window.

- the referenced filename might not exist either, and i dont know if there'd be any errors displayed. none of this is verified or checked in the code so afaik it would do nothing about missing files.

Archived

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

×
×
  • Create New...

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.