Advertisement:

Author Topic: Download System  (Read 650647 times)

Offline @rjen

  • Sr. Member
  • ****
  • Posts: 761
  • Gender: Male
    • FJR-club Nederland
Re: Download System
« Reply #2280 on: July 22, 2021, 02:52:48 AM »
That’s not quite it I am afraid: still getting these now...

https://xxx.XX.nl/index.php?action=downloads;sa=prev&id=3270
8: Trying to access array offset on value of type null
Bestand: /home/deb77453/domains/xxx.xx.nl/public_html/Sources/Downloads2.php
Regel: 4536
Running SMF 2.0 with Tinyportal 2.0.1 at www.fjr-club.nl
Testing SMF 2.1 with Tinyportal 2.1.0 at test2.fjr-club.nl

Offline @rjen

  • Sr. Member
  • ****
  • Posts: 761
  • Gender: Male
    • FJR-club Nederland
Re: Download System
« Reply #2281 on: July 22, 2021, 03:16:05 AM »
I think this is what is needed...

Code: [Select]
function Downloads_PreviousDownload()
{
global $txt, $smcFunc;

$id = (int) $_REQUEST['id'];
if (empty($id))
fatal_error($txt['downloads_error_no_file_selected']);

// Get the category
$dbresult = $smcFunc['db_query']('', "
SELECT
ID_FILE, ID_CAT
FROM {db_prefix}down_file
WHERE ID_FILE = $id  LIMIT 1");
if ($smcFunc['db_affected_rows']() != 0)
{
$row = $smcFunc['db_fetch_assoc']($dbresult);
$ID_CAT = $row['ID_CAT'];
}
else
fatal_error($txt['downloads_error_no_file_selected'],false);

$smcFunc['db_free_result']($dbresult);


// Get previous download
$dbresult = $smcFunc['db_query']('', "
SELECT
ID_FILE
FROM {db_prefix}down_file
WHERE ID_CAT = $ID_CAT AND approved = 1 AND ID_FILE < $id ORDER BY ID_FILE DESC LIMIT 1");
if ($smcFunc['db_affected_rows']() != 0)
{
$row = $smcFunc['db_fetch_assoc']($dbresult);
$ID_FILE = $row['ID_FILE'];
}
else
$ID_FILE = $id;

$smcFunc['db_free_result']($dbresult);

redirectexit('action=downloads;sa=view;down=' . $ID_FILE);
}

function Downloads_NextDownload()
{
global $txt, $smcFunc;

$id = (int) $_REQUEST['id'];
if (empty($id))
fatal_error($txt['downloads_error_no_file_selected']);

// Get the category
$dbresult = $smcFunc['db_query']('', "
SELECT
ID_FILE, ID_CAT
FROM {db_prefix}down_file
WHERE ID_FILE = $id  LIMIT 1");
if ($smcFunc['db_affected_rows']() != 0)
{
$row = $smcFunc['db_fetch_assoc']($dbresult);
$ID_CAT = $row['ID_CAT'];
}
else
fatal_error($txt['downloads_error_no_file_selected'],false);

$smcFunc['db_free_result']($dbresult);

// Get next download
$dbresult = $smcFunc['db_query']('', "
SELECT
ID_FILE
FROM {db_prefix}down_file
WHERE ID_CAT = $ID_CAT AND approved = 1 AND ID_FILE > $id
ORDER BY ID_FILE ASC LIMIT 1");
if ($smcFunc['db_affected_rows']() != 0)
{
$row = $smcFunc['db_fetch_assoc']($dbresult);
$ID_FILE = $row['ID_FILE'];
}
else
$ID_FILE = $id;
$smcFunc['db_free_result']($dbresult);

redirectexit('action=downloads;sa=view;down=' . $ID_FILE);
}
Running SMF 2.0 with Tinyportal 2.0.1 at www.fjr-club.nl
Testing SMF 2.1 with Tinyportal 2.1.0 at test2.fjr-club.nl

Online vbgamer45

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 23,610
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Download System
« Reply #2282 on: July 22, 2021, 08:36:04 AM »
I think i i needed to move the statement up one spot attached
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Offline @rjen

  • Sr. Member
  • ****
  • Posts: 761
  • Gender: Male
    • FJR-club Nederland
Re: Download System
« Reply #2283 on: July 22, 2021, 09:55:59 AM »
Yeah, that’s what I proposed originally. To be honest, the code I posted after that is more elegant: that works flawless, so I would suggest the second code snippet above the first...
Running SMF 2.0 with Tinyportal 2.0.1 at www.fjr-club.nl
Testing SMF 2.1 with Tinyportal 2.1.0 at test2.fjr-club.nl

Offline @rjen

  • Sr. Member
  • ****
  • Posts: 761
  • Gender: Male
    • FJR-club Nederland
Re: Download System
« Reply #2284 on: July 24, 2021, 11:26:37 AM »

Code: [Select]
function Downloads_PreviousDownload()
{
global $txt, $smcFunc;

$id = (int) $_REQUEST['id'];
if (empty($id))
fatal_error($txt['downloads_error_no_file_selected']);

// Get the category
$dbresult = $smcFunc['db_query']('', "
SELECT
ID_FILE, ID_CAT
FROM {db_prefix}down_file
WHERE ID_FILE = $id  LIMIT 1");
if ($smcFunc['db_affected_rows']() != 0)
{
$row = $smcFunc['db_fetch_assoc']($dbresult);
$ID_CAT = $row['ID_CAT'];
}
else
fatal_error($txt['downloads_error_no_file_selected'],false);

$smcFunc['db_free_result']($dbresult);


// Get previous download
$dbresult = $smcFunc['db_query']('', "
SELECT
ID_FILE
FROM {db_prefix}down_file
WHERE ID_CAT = $ID_CAT AND approved = 1 AND ID_FILE < $id ORDER BY ID_FILE DESC LIMIT 1");
if ($smcFunc['db_affected_rows']() != 0)
{
$row = $smcFunc['db_fetch_assoc']($dbresult);
$ID_FILE = $row['ID_FILE'];
}
else
$ID_FILE = $id;

$smcFunc['db_free_result']($dbresult);

redirectexit('action=downloads;sa=view;down=' . $ID_FILE);
}

function Downloads_NextDownload()
{
global $txt, $smcFunc;

$id = (int) $_REQUEST['id'];
if (empty($id))
fatal_error($txt['downloads_error_no_file_selected']);

// Get the category
$dbresult = $smcFunc['db_query']('', "
SELECT
ID_FILE, ID_CAT
FROM {db_prefix}down_file
WHERE ID_FILE = $id  LIMIT 1");
if ($smcFunc['db_affected_rows']() != 0)
{
$row = $smcFunc['db_fetch_assoc']($dbresult);
$ID_CAT = $row['ID_CAT'];
}
else
fatal_error($txt['downloads_error_no_file_selected'],false);

$smcFunc['db_free_result']($dbresult);

// Get next download
$dbresult = $smcFunc['db_query']('', "
SELECT
ID_FILE
FROM {db_prefix}down_file
WHERE ID_CAT = $ID_CAT AND approved = 1 AND ID_FILE > $id
ORDER BY ID_FILE ASC LIMIT 1");
if ($smcFunc['db_affected_rows']() != 0)
{
$row = $smcFunc['db_fetch_assoc']($dbresult);
$ID_FILE = $row['ID_FILE'];
}
else
$ID_FILE = $id;
$smcFunc['db_free_result']($dbresult);

redirectexit('action=downloads;sa=view;down=' . $ID_FILE);
}

Will you include this fix in the mod?
Running SMF 2.0 with Tinyportal 2.0.1 at www.fjr-club.nl
Testing SMF 2.1 with Tinyportal 2.1.0 at test2.fjr-club.nl

Online vbgamer45

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 23,610
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Download System
« Reply #2285 on: July 24, 2021, 11:29:31 AM »
I just included the fix where it moved it up.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Offline @rjen

  • Sr. Member
  • ****
  • Posts: 761
  • Gender: Male
    • FJR-club Nederland
Re: Download System
« Reply #2286 on: July 24, 2021, 11:54:05 AM »
That will do as well.
So it is already in the latest package?
Running SMF 2.0 with Tinyportal 2.0.1 at www.fjr-club.nl
Testing SMF 2.1 with Tinyportal 2.1.0 at test2.fjr-club.nl

Online vbgamer45

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 23,610
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Download System
« Reply #2287 on: July 24, 2021, 12:30:54 PM »
Yes it is.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro