The problem is that the report page displays nothing except "No download count records are found for the file."
I did changed the file system to public and downloaded some attached files and yet I get nothing but desperate. Is there any solution?

Comments

lesleyfernandes’s picture

Same here, my files are with the correct link eg. name_file(0), and I downloaded and still displaying "No download count records are found for the file."

petermilad’s picture

Well, I find this issue important to me a little bit

pixture’s picture

Priority: Minor » Normal

When you move the mouse cursor over the file download link, what kind of URL do you see?
It's supposed to have pubdlcnt.php?file=xxxxxxxx&nid=zzzzz. Please let me know the URL.

In addition, make sure that you install PDC module to the standard 3rd party module directory where (drupal-root)/sites/all/modules. If not, PDC module may not work.

vrato’s picture

Public download counter doesn't work for me too:-(
When I move the mouse cursor over the file download link, I see this URL.
http://MYSERVER/Drupal/sites/all/modules/pubdlcnt/pubdlcnt.php?file=http...

Clean url and Public download are enabled, but counting is not working. Where could be problem?

I use drupal 6.19.

mikelo’s picture

I have the same problem after upgrading to CCK 6.x-2.9.

pixture’s picture

> @vrato,

The link URL looks good.
When you click the download link, the file is downloaded but the counter is not implemented. Is that correct?
If so, the possible reasons of not counting are:

1) The file extension is not in the list of supported extensions. In case of your example link, .pdf is the file's extension. Be sure that this file extension is in the list of supported extensions.

2) Somehow, the URL of the target download file can not be verified. When the file is about to be downloaded, PDC module checks if the file URL is valid and the file actually exists or not. If it is determined to not to exists, then it skips updating counter. When the web server does not return expected responses (HTTP/1.1 200 OK or HTTP/1/1 302 Found) when the existence of the file is checked, the PDC module determines that the file does not exist and skip updating the counter. If this is the case, you can skip this existence check by making a minor code change (see below).

Before (pubdlcnt.php)

/**
 * Function to check if the specified file URL is valid or not
 */
function is_valid_file_url($url) {
  // replace space characters in the URL with '%20' to support file name
  // with space characters
  $url = preg_replace('/\s/', '%20', $url);

  if (!valid_url($url, true)) {
    return false;
  }

  //  -- skipped -- 

  if (!url_exists($url)) {
    return false;
  }
  return true; // it seems that the file URL is valid
}

After (pubdlcnt.php)

/**
 * Function to check if the specified file URL is valid or not
 */
function is_valid_file_url($url) {
  // replace space characters in the URL with '%20' to support file name
  // with space characters
  $url = preg_replace('/\s/', '%20', $url);

  if (!valid_url($url, true)) {
    return false;
  }

  //  -- skipped -- 

/* -- comment out three lines below
  if (!url_exists($url)) {
    return false;
  }
*/
  return true; // it seems that the file URL is valid
}

Please make this change and see if this fix your issue or not.
Thanks,

aacraig’s picture

I have the same issue (in 7.x-dev).

The problem is that I have my module installed in the (now standard) contrib/ directory, so my file structure is:

/path/to/drupal/sites/all/modules/contrib/pubdlcnt

If I adjust the code in pubdlcnt.php to the following, the report displays correctly:

// we need to change the current directory to the (drupal-root) directory
// in order to include some necessary files.
if (file_exists('../../../../includes/bootstrap.inc')) {
  // If this script is in the (drupal-root)/sites/(site)/modules/pubdlcnt directory
  chdir('../../../../'); // go to drupal root
}
else if (file_exists('../../../../../includes/bootstrap.inc')) {
  // If this script is in the (drupal-root)/sites/(site)/modules/contrib/pubdlcnt directory
  chdir('../../../../../'); // go to drupal root
}
else if (file_exists('../../includes/bootstrap.inc')) {
  // If this script is in the (drupal-root)/modules/pubdlcnt directory
  chdir('../../'); // go to drupal root
}
else {
  // Non standard location: you need to edit the line below so that chdir()
  // command change the directory to the drupal root directory of your server
  // using an absolute path.
  // First, please delete the line below and then edit the next line
  print "Error: Public Download Count module failed to work. The file pubdlcnt.php requires manual editing.\n";
  chdir('/absolute-path-to-drupal-root/'); // <---- edit this line!

  if (!file_exists('./includes/bootstrap.inc')) {
    // We can not locate the bootstrap.inc file, let's give up using the
    // script and just fetch the file
    header('Location: ' . $_GET['file']);
    exit;
  }
}
Bandy’s picture

Version: 6.x-1.0-beta5 » 7.x-1.0

#6

That works in 7.x-1.0

sreynen’s picture

Status: Active » Reviewed & tested by the community

The contrib issue in #7 is addressed in #1294868: Also check if module is in sites/all/modules/contib/pubdlcnt. That doesn't seem to be the main problem in this issue. #8 suggests the main problem is fixed with #6, so marking this RTBC.

phily’s picture

@pixture (#6)
THANK YOU! my aspirin box is empty and you saved me ;-)

manoloka’s picture

Hi there,

In #3 you state;

When you move the mouse cursor over the file download link, what kind of URL do you see?
It's supposed to have pubdlcnt.php?file=xxxxxxxx&nid=zzzzz. Please let me know the URL.

In addition, make sure that you install PDC module to the standard 3rd party module directory where (drupal-root)/sites/all/modules. If not, PDC module may not work.

I couldn't find anything within the README file (or anywhere at all) that explains what the link should be, how are we supposed to guess that? as it seems that without that information the module doesn't do what it's supposed to do

parasolx’s picture

#6 solved my problem also...

nice patch

thermador’s picture

For what it's worth #6 solved my problem for drupal 7 as well.

This problem started when my host upgraded PHP versions from 5.2 to 5.3, so I think that may be the cause... dunno for sure.

EDIT: I now know EXACTLY what caused this problem for me. When I upgraded from 5.2 to 5.3, I also changed my settings with the host to "remove www." from the URL. Unfortunately, I did not remember to update the $baseurl in Drupal's settings.php to match. Once I did this, Public Download Count worked fine again. And, then I broke it again on purpose to test, and fixed it.

tl;dr: mismatched host's site url vs. drupal's $baseurl is at least one of the possible causes of this bug.

bkudrle’s picture

#7 worked for me. Thanks so much!

roryt2000’s picture

Issue summary: View changes

I've tried all of the above suggestions, and this module still just doesn't work for me at all.

The download link just shows the direct file URL (not pubdlcnt.php?file=xxxxxxxx&nid=zzzzz), and none of the downloads are tracked.

DanNY’s picture

Hi, not getting the installation and why link to File Download would show location in the module.

I have File Download module installed. In an Article, have a File Download field for adding a file on Article creation. For the visitor, the file link appears and people can download. Files are saved in the default public file folder sites/default/files/

Am I supposed to change the location of my File Download files to the module sites/all/modules/contrib/pubdlcnt/, then upload my file to that location when creating my Article with downloadable file?

Thanks
Daniel

rituraj.gupta’s picture

You just need to comment line no 137 to 139 in pubdlcnt.php

comment these lines:

if (!url_exists($url)) {
return false;
}

Now counter will work .

punyaruchal’s picture

I have also same problem . downloaded file record didn't count.
Drupal version: 7.34
PDC version: 7.x-1.0

File path URL: http://mysite-address/sites/all/modules/pubdlcnt/pubdlcnt.php?file=http:...

i tried #6 but not working for me.
Please can anyone help me what happen?

greggles’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Status: Reviewed & tested by the community » Needs work

There's not a patch here as far as I can tell, so moving to needs work for the generation of a patch.