Skip to content

Instantly share code, notes, and snippets.

@netcarver
Created August 19, 2008 18:45
Show Gist options
  • Save netcarver/6218 to your computer and use it in GitHub Desktop.
Save netcarver/6218 to your computer and use it in GitHub Desktop.
function ign_filter_downloads() //callback routine called by file_download
{
global $id, $file_error, $ign_user, $pretext, $s;
if(empty($id)) {
//no $id means we need to reparse the URL...
extract($pretext);
if($prefs['permlink_mode']=='messy') {
$id = gps('id'); //get $id from GET
} else { //we need to parse the uri
extract(chopurl($_SERVER['REQUEST_URI']));
$id = $u2; //should probably test for failure here...
}
}
//let's check to see if this file has permissions set and get the category
$file = safe_row('permissions, category', 'txp_file', "id='$id'");
$parent = (!empty($file['category'])) ? safe_field('parent','txp_category', "name='{$file['category']}'") : '';
if(!empty($file['permissions'])) // permissions set, carry on
{
if(empty($ign_user) || !ign_checkPrivs($file['permissions'])) //if any check fails, give 'em the boot
$file_error = '403';
} else if($parent == 'clients'){ // let's fire off a quick category comparison for client-specific setups...
if(empty($ign_user) || $file['category'] !== $ign_user)
$file_error = '403';
}
//return to let file_download do its thing...
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment