1

Our company wants to have a secured downloads area for software. We want to send a link to a customer via email, after they have purchased a license for the software. We don't want to create a site account for every customer; we just want them to click the link to get one-time access to the downloads page. All the modules I have seen for one-time use links either assume that the link is something used for password reset, etc., or the module is not ready for prime-time.

Any ideas?

Thanks!

0

You need write a module to do this job, I wrote a module that do something like this ( count download times )

<?php

/**
* Implements hook_menu();
*/
function bicuk_downloadounter_menu() {

    $items=array();
    $items['download/%']=array(
        'title' => 'increase Download counter ',
        'description' => t('callback url for increse Downloading count'),
        'page callback' => 'downloadcounter_tickup',
        'page arguments' =>array(1),
        'type' => MENU_CALLBACK,
        'access callback' =>true,

    );
    return $items;
}

/* call back function to increase counter
 * @param $fid , file id 
 */
function downloadcounter_tickup($fid){

   if(!is_numeric($fid)) 
              drupal_goto();
   $file=file_load($fid);
   if(!isset($file->fid))
            drupal_goto();
   $acceptable_ext=unserialize(variable_get('bicuk_downloadounter_valid_extensions'));
   $file_path=file_create_url($file->uri);
   $pathinfo=  pathinfo($file_path);
   $extension=$pathinfo['extension'];
 if(!in_array(strtolower($extension), $acceptable_ext))
             drupal_goto();
   $query=  db_select('bicuk_downloadcounter_counter','bdc')->fields('bdc',array('count'));
   $query->condition('fid',$fid, '=');
   $count=$query->execute()->fetchField();
if($count)
{
    $query=  db_update('bicuk_downloadcounter_counter')->fields(array('count'=>$count+1));
    $query->condition('fid',$fid, '=');
    $query->execute(); 
}
else
  {
    $query=  db_insert('bicuk_downloadcounter_counter')->fields(array('name','count','fid'),array($file->filename,1,$fid));
    $query->execute();
  }
   drupal_goto($file_path);
}

/**
 *
 * @param type $fid fid
 * @return type int count
 */

function downloadcounter_get($fid){
   $query=  db_select('bicuk_downloadcounter_counter','bdc')->fields('bdc',array('count'));
   $query->condition('fid',$fid, '=');
   $count=$query->execute()->fetchField();
   return $count;
}

you can get idea from this code to achieve your job,instead of counting download time try to check downlading time by IP and do your limitation

| improve this answer | |
  • Thanks ! Did you have to create new tables/databases to activate this ? – commonpike Oct 7 '15 at 15:15
0

No need to write a new module. One of the modules that I referred to as "not ready for prime-time" is a module called "Deep link". I had said that because there seemed to be some bugs with the use of one-time-only links. After looking at the code for a few days, I was able to fix a couple issues and submitted patches back to the project page. The module now works well enough to suit my purpose, and I would recommend it!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.