News:

Wondering if this will always be free?  See why free is better.

Main Menu

Problem with Download System

Started by Darwin94, October 11, 2009, 10:07:03 AM

Previous topic - Next topic

Darwin94

Hi,

I'm using SMF 2.0 RC1.2 and installed the Download System. When there's an "&" sign in the Download link, the link, which is output by the download system is with "&"  (for example "http://example.com/Down&load.exe" becomes "http://example.com/Down&load.exe" )and so the download doesn't work. The error should be here:
// Get the download information
  $dbresult = $smcFunc['db_query']('', "
  SELECT
    f.filename, f.fileurl, f.orginalfilename, f.approved, f.credits, f.ID_CAT, f.id_member
  FROM {db_prefix}down_file as f
  WHERE f.ID_FILE = $id");
  $row = $smcFunc['db_fetch_assoc']($dbre​sult);
  $smcFunc['db_free_result'​]($dbresult);

or here:
// Download File or Redirect to the download location
  if ($row['fileurl'] != '')
  {
    $lastdownload = time();
    // Update download count
    $dbresult = $smcFunc['db_query']('', "
    UPDATE {db_prefix}down_file
      SET totaldownloads = totaldownloads + 1, lastdownload  = '$lastdownload'
    WHERE ID_FILE = $id LIMIT 1");

    // Redirect to the download
    header("Location: " . $row['fileurl']);
   
    exit;
  }
  else
  {
    $lastdownload = time();
    // Update download count
    $dbresult = $smcFunc['db_query']('', "
    UPDATE {db_prefix}down_file
      SET totaldownloads = totaldownloads + 1, lastdownload  = '$lastdownload'
    WHERE ID_FILE = $id LIMIT 1");


    $real_filename = $row['orginalfilename'];
    $filename = $modSettings['down_path'] . $row['filename'];

Why is that the case and how do i fix that?

thanks

Darwin :)

Kays

It's how its stored in the database. Plus if the "&" is in the file name it shouldn't be there.

Try adding this before the redirect.



$row['fileurl'] = un_htmlspecialchars($row['fileurl']);


If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Darwin94


Kays

Great. Which download system are you using?

IMO, all file names should be cleaned and stripped of any illegal characters and blank spaces before beng saved.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods


Kays


If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Advertisement: