...

View Full Version : If the user has permission to download the file_name or the file_pack, then go ahead.



oskare100
12-26-2006, 12:11 PM
Hello,
I've a file downloading script that hides the real location from the person who is trying to download the file.

First I run this (don't know if it's right) to get the file_pack and the file_name of the file:

$result2 = mysql_query('select `file_name` , `file_pack` from '$file_tbl' where `file_id` = "'.$_GET['serve'].'"')
or die( mysql_error() );

Then I run this (don't know if it's right) to get the file_pack and file_name from the user permission table:

$result3 = mysql_query('select `file_name` , `file_pack` from '$user_tbl' where `username` = "'$_SESSION['username']'"')
or die( mysql_error() );

If one of the "file_name"s from the uuser permissions table matches the "file_name" from the requested file OR if one of the "file_pack"s from the user permissions table matches the "file_pack" of the current file then go ahead and continue with the script. If not, then die. I hope that you understand what I want to do with this and I really hope that you can help me..


IF YOU NEED IT, here is the database structure:

The user permission table where I will store which users has permission to download which files.
CREATE TABLE `user_perm` (
`perm_id` int(11) NOT NULL auto_increment,
`perm_user` varchar(50) NOT NULL default '',
`file_pack` varchar(30) NOT NULL default '',
`file_name` varchar(100) NOT NULL default '',
`perm_date` varchar(30) NOT NULL default '',
`perm_timestamp` varchar(30) NOT NULL default '',
PRIMARY KEY (`perm_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

The file table where I will store the files:
CREATE TABLE `files` (
`file_id` int(11) NOT NULL auto_increment,
`file_pack` varchar(50) NOT NULL default '',
`file_pack_cat` varchar(50) NOT NULL default '',
`file_cat` varchar(50) NOT NULL default '',
`file_name` varchar(100) NOT NULL default '',
`file_desc` text NOT NULL,
`file_fullname` varchar(100) NOT NULL default '',
`file_downloads` varchar(11) NOT NULL default '',
`file_date` varchar(30) NOT NULL default '',
`file_timestamp` varchar(30) NOT NULL default '',
PRIMARY KEY (`file_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;


Thanks in advance,
Best Regards
Oskar R



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum