• Welcome to Simple Machines Community Forum. Please login or sign up.
December 08, 2021, 07:59:21 AM

News:

SMF 2.0.18 has been released! Please update. Read more.


Download System

Started by SMFHacks.com Team, October 31, 2007, 06:55:37 PM

Previous topic - Next topic

@rjen

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.1.0 at www.fjr-club.nl
Testing SMF 2.1 with Tinyportal 2.1.0 at test2.fjr-club.nl

@rjen

I think this is what is needed...


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.1.0 at www.fjr-club.nl
Testing SMF 2.1 with Tinyportal 2.1.0 at test2.fjr-club.nl

vbgamer45

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

@rjen

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.1.0 at www.fjr-club.nl
Testing SMF 2.1 with Tinyportal 2.1.0 at test2.fjr-club.nl

@rjen

Quote from: @rjen on July 22, 2021, 03:16:05 AM


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.1.0 at www.fjr-club.nl
Testing SMF 2.1 with Tinyportal 2.1.0 at test2.fjr-club.nl

vbgamer45

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

@rjen

That will do as well.
So it is already in the latest package?
Running SMF 2.0 with Tinyportal 2.1.0 at www.fjr-club.nl
Testing SMF 2.1 with Tinyportal 2.1.0 at test2.fjr-club.nl

vbgamer45

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

Mick.

Hey.... This bit needs a closing tag; in Downloads2.1.template.php line 232 or so.
            // Show return to downloads link and Show add download if they can
            echo '
                    <div class="tborder">
            <div class="roundframe centertext">';
   
if ($g_manage)
echo '<a href="', $scripturl, '?action=downloads;sa=addcat;cat=', $cat, '">', $txt['downloads_text_addsubcat'], '</a>&nbsp;&nbsp;';

if ($g_add)
echo '<a href="', $scripturl, '?action=downloads;sa=add;cat=', $cat, '">', $txt['downloads_text_adddownload'], '</a> ';


echo '
<a href="', $scripturl, '?action=downloads">', $txt['downloads_text_returndownload'], '</a
            </div>


This:
<a href="', $scripturl, '?action=downloads">', $txt['downloads_text_returndownload'], '</a

It broke the layout in my template. I thought something i had done;possibly but I checked the current download and yes, it's missing the closing tag.

vbgamer45

Thanks for the report fixed


3.0.12
!Fixed some unclosed html tags
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

shawnb61

I am about to merge two forums.  Both use this mod, and both have hundreds of downloads.

Is there any way to merge the two sets of downloads?

Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

vbgamer45

September 19, 2021, 11:24:23 PM #2291 Last Edit: September 19, 2021, 11:43:42 PM by vbgamer45
The filenames should be unique enough in 99% of the time so those should be safe to copy from the source to the target forum. This is for the lite version.

I would check the max id_file on the target forum. Lets says it is 200.  For the source I would increment ID_FILE, ID_CAT, id_comment,_id_parent  in the tables by 1000 as well. check the max id's on each
I choose 1000 since you can easily see old/new data.

Backup first.
Then here is a quick example that may work Run on source site. Make sure it works.
UPDATE smf_down_file SET id_file = id_file + 1000, id_cat = id_cat + 1000;
UPDATE smf_comment SET ID_comment = id_comment + 1000, id_file = id_file + 1000;
UPDATE smf_down_cat SET id_cat = id_cat + 1000, id_parent = id_parent + 1000;


Then you should be able to export those inserts for those tables and copy them to the new main site. If on same server INSERT INTO databasemain.smf_down_file SELECT * FROM databasesource.smf_down_file;

Those are the main tables if you copying rating, custom fields I would do something similar.  Ratings, I would increase id_file by 1000 and then insert id_file,id_member_comment,date into the main target database so a new rating id will be created.

Only issue remaining would be memberids if they change from going one forum to another.


Hopefully that helps. I was actually doing some downloads pro coding this weekend have it setup with amazon s3 for 2.0,2.1 and was not that hard, will be doing that to some of my other mods.
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

shawnb61

We have an engine that does exactly that in mergeSMF.php...  Hmmm...
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

vbgamer45

Yeah i was sort of thinking something similar for my  mods. Have a way to autoincrement fields if known they are keys I guess maybe indexed integers too? (but could be false positives) maybe have to hard a code a list not ideal.
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

shawnb61

Which files/folders get copied over?

I have download files in multiple folders, as well as a # of oddly named folders...
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

vbgamer45

I would just copy the entire downloads folder. Backup first but that should be ok
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

shawnb61

Holy smokes that worked!

Just a few tweaks to mergeSMF.php to add the downloads tables, then copied the actual files over.   8)

I just focused on down_cat, down_comment, down_file & down_rating. 
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

vbgamer45

Love that! Glad that worked! Got to keep that in mind for any future requests.
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

landyvlad

I just downloaded the file DownloadSystem3.0.12.zip
Uploaded to package manager and there it shows as Download System 3.0.11a

What gives?
Please do not PM, IM or Email me with questions on astrophysics or theology.  You will get better and faster responses by asking homeless people in the street. Thank you.

To paraphrase Kindred: "There are no technical solutions to social problems."

vbgamer45

Wrong package manager display issue will fix for next update. Does not impact the download system.
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

Advertisement: