--- filebrowser.module 2009-05-19 00:09:51.000000000 +0200 +++ filebrowserNew.module 2009-09-23 15:07:55.000000000 +0200 @@ -132,8 +132,17 @@ function _filebrowser_download_callback( header('Content-Disposition: attachment; filename="'.$match['name'].'";'); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".$match['size']); - $content= file_get_contents($match['path']); - print $content; + if ($node->private_downloads==1) { + $content= file_get_contents($match['path']); + print $content; + } + if ($node->private_downloads==2) { + $randomstring = md5(rand().time().rand()); + $obscurity_link = file_directory_temp().'/filebrowser_obscurity_link_'.$randomstring.'/'.basename($match['path']); + mkdir(dirname($obscurity_link)); + symlink($match['path'],$obscurity_link); + header("Location: ".$base_url.'/'.$obscurity_link); + } exit (); } @@ -384,10 +393,15 @@ function filebrowser_form(& $node, & $pa '#weight' => -8 ); $form['folder_description']['private_downloads']= array ( - '#type' => 'checkbox', - '#title' => t("Use private downloads"), - '#description' => t("Use private downloads if your files are outside Drupal root or if you want Drupal to check permissions."), - '#default_value' => isset ($node->private_downloads) ? $node->private_downloads : '', + '#type' => 'select', + '#title' => t("protect your downloads"), + '#description' => t("how to protect your downloads outside drupal."), + '#default_value' => isset ($node->private_downloads) ? $node->private_downloads : '0', + '#options' => array( + '0' => t('none'), + '1' => t('private'), + '2' => t('security through obsurity'), + ), '#weight' => -7 ); @@ -536,8 +550,8 @@ function filebrowser_delete($node) { * hook_validate implementation. */ function filebrowser_validate(& $node) { - if (!$node->private_downloads && $node->file_path[0] == '/') { - form_set_error('file_path', t('If you specify an absolute path, you should choose "private downloads".')); + if ($node->private_downloads==0 && $node->file_path[0] == '/') { + form_set_error('file_path', t('If you specify an absolute path, you should choose "private downloads" or "security through obscurity".')); } // Verify the file system location & check that it's a directory.