Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 05-27-2005, 09:31 AM Download script
Raulică's Avatar
Ultra Talker

Posts: 253
Location: Constanta,Romania
Trades: 0
Hi,

A customer of mine hosts some files on one of our servers. The problem is someone is using the links on my customer website to make possible the download on his webpage so he is using my customers bandwith for free. I have tried to make a download script wich will prevent this. Please note that my customer links to the files on my server from another domain name.

PHP Code:
<?
// valori mysql
$user 'user';
$pass 'pass';
$host 'localhost';
$db 'muzica';

// conectam mysql
mysql_connect($host,$user,$pass);
mysql_select_db($db);

// preluam valori
if(!strlen($_GET['id']))
{
    die(
"Nu a fost specificat nici un fisier<br>Click <a href='javascript: history.back(-1)'>aici</a>");
}
global 
$HTTP_REFERER;
$url parse_url($HTTP_REFERER);
if((
$url['host'] != "www.anotherdomain.com") && ($url['host'] != "anotherdomain.com"))
{
    echo 
"Aceasta muzica apartine site-ului <a href='http://www.anotherdomain.com'>www.anotherdomain.com</a>";
    die(
"<br>Aceasta muzica o puteti gasii numai pe site-ul precizat mai sus,enjoy");
}
$id $_GET['id'];
$path "/usr/local/psa/home/vhosts/domainname.com/httpdocs/muzica/lauRica/";
opendir($path);
$query "select file from muzica where id = '$id'";
$row mysql_fetch_array(mysql_query($query));
if(!
mysql_error())
{
    
$file $row['file'];
    
$path .= $file;
    include 
$path;
}
else
{
    echo 
"Eroare, fisierul NU exista pe serverul nostru";
    
header("Location: $HTTP_REFERER");
}
?>
It didn't work and i can't figure why, do i have to set some special permisions to the files ?
__________________

Please login or register to view this content. Registration is FREE

Professional hosting for all pockets!

Please login or register to view this content. Registration is FREE
Raulică is offline
Reply With Quote
View Public Profile Visit Raulică's homepage!
 
 
Register now for full access!
Old 05-27-2005, 11:09 AM
Uche's Avatar
Extreme Talker

Posts: 174
Location: Nigeria/Lagos
Trades: 0
Sorry pls we all speak English in this Forum , Can you please translate those Scripts to English so we could help you out.
__________________
Life is just lyke a school where everybody goes to learn one or two thing. the more u school, the more u learn more about school..The more we live our lifes.. the more we learn more about life.

Please login or register to view this content. Registration is FREE
Uche is offline
Reply With Quote
View Public Profile Visit Uche's homepage!
 
Old 05-27-2005, 11:18 AM
OmuCuSucu's Avatar
Vi Veri Veniversum Vivus

Posts: 1,168
Name: Dragos-Valentin
Location: Cluj-Napoca, RO
Trades: 0
Quote:
Originally Posted by Uche
Sorry pls we all speak English in this Forum , Can you please translate those Scripts to English so we could help you out.

i don't really believe that would be aproplem Uche, but here you have the transaltion. i did it for Raulica so he may have an answer when he's back:

PHP Code:
<?
// mysql values
$user 'user';
$pass 'pass';
$host 'localhost';
$db 'muzica';

// connection to database
mysql_connect($host,$user,$pass);
mysql_select_db($db);

// getting values
if(!strlen($_GET['id']))
{
    die(
"no file specified<br>Click <a href='javascript: history.back(-1)'>here</a>");
}
global 
$HTTP_REFERER;
$url parse_url($HTTP_REFERER);
if((
$url['host'] != "www.anotherdomain.com") && ($url['host'] != "anotherdomain.com"))
{
    echo 
"this file belongs to the site <a href='http://www.anotherdomain.com'>www.anotherdomain.com</a>";
    die(
"<br>this file you can only find on the above mentioned website.");
}
$id $_GET['id'];
$path "/usr/local/psa/home/vhosts/domainname.com/httpdocs/muzica/lauRica/";
opendir($path);
$query "select file from muzica where id = '$id'";
$row mysql_fetch_array(mysql_query($query));
if(!
mysql_error())
{
    
$file $row['file'];
    
$path .= $file;
    include 
$path;
}
else
{
    echo 
"Error, the file does not exist on our server";
    
header("Location: $HTTP_REFERER");
}
?>
__________________
.
» Please remember to add to my Talkupation if you enjoyed my post. Thank you :)
.
OmuCuSucu is offline
Reply With Quote
View Public Profile
 
Old 05-27-2005, 11:19 AM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Uche Why do you need the error messages in english to work out what the code does ?

Raulică
Explain why it didn't work and any errors that occured. We have more chance of debugging then.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-27-2005, 12:02 PM
Raulică's Avatar
Ultra Talker

Posts: 253
Location: Constanta,Romania
Trades: 0
Sorry, i forgot to translate, anyway thanks OmuCuSucu.
Here are the error messages i get :
Quote:
Warning: opendir(): open_basedir restriction in effect. File(/usr/local/psa/home/vhosts/domainname.com/httpdocs/muzica/lauRica/) is not within the allowed path(s): (/usr/local/psa/home/vhosts/future-host.org/httpdocs:/tmp) in /usr/local/psa/home/vhosts/future-host.org/httpdocs/download.php on line 29

Warning: opendir(/usr/local/psa/home/vhosts/domainname.com/httpdocs/muzica/lauRica/): failed to open dir: Operation not permitted in /usr/local/psa/home/vhosts/future-host.org/httpdocs/download.php on line 29

Warning: main(): open_basedir restriction in effect. File(/usr/local/psa/home/vhosts/domainname.com/httpdocs/muzica/lauRica/gigi.tgz) is not within the allowed path(s): (/usr/local/psa/home/vhosts/future-host.org/httpdocs:/tmp) in /usr/local/psa/home/vhosts/future-host.org/httpdocs/download.php on line 36

Warning: main(/usr/local/psa/home/vhosts/domainname.com/httpdocs/muzica/lauRica/gigi.tgz): failed to open stream: Operation not permitted in /usr/local/psa/home/vhosts/future-host.org/httpdocs/download.php on line 36

Warning: main(): Failed opening '/usr/local/psa/home/vhosts/domainname.com/httpdocs/muzica/lauRica/gigi.tgz' for inclusion (include_path='.:/usr/local/psa/apache/lib/php') in /usr/local/psa/home/vhosts/future-host.org/httpdocs/download.php on line 36
__________________

Please login or register to view this content. Registration is FREE

Professional hosting for all pockets!

Please login or register to view this content. Registration is FREE
Raulică is offline
Reply With Quote
View Public Profile Visit Raulică's homepage!
 
Reply     « Reply to Download script
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21330 seconds with 12 queries