MyBB Community Forums

Full Version: Modifying MusicalMidget's Download System
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
I want to use MusicalMidget's download system on my forums, but there are a number of features that aren't present, namely:

File size limits (if this is part of attachment limits can I separate them?)
Preview images
Inclusion into the search system or a separate system
Sorting by Name, Time posted, views, downloads, etc.
Creating a php feed that can be posted on my homepage to show latest files.

Would all of this be on download.php? Are there any relatively easy ways (for someone fairly inexperienced with PHP/MySQL) to add any of the features? Thanks.
Yeah there are a number of shortfalls with the download mod. I asked for permission to modify and redistribute but no response. Maybe he didn't get my email.

I hope he does some udpating to his plugin. It's one of the more popular ones available but it could use some new features. I would like to see easier control. You can't currently update a download with a new file. You have to delete a download and then make a new one. Also for some reason whenever I am in front-end and use one of the admin links...I get a blank page in admincp. I have to refresh and just use the regular links. Might be and SID issue.
The main things I want to do are to allow sorting, timestamp each submission, and a search function. I'm not sure how to add a sorting feature (not very experienced with php), but a simple ORDER BY and a link creation somewhere should fix it, no?
It depends on your experience. If you're experienced, yes, sorting, and timestamping is easy. I would presume searching shouldn't be hard either, but I've never handled complex searches (simple ones can be done via queries still).
I suppose that's the problem then; I don't have a lot of experience with php.

Managed to get sorting done myself after a good deal of trial and error.
Timestamping is next, though...I want it to save the time and date of when the file is uploaded, add it to the database in the same row as the other information, then display that as one of my sortable columns, and finally create a feed with the last 10 files. Any pointers? Thanks.

By the way, what variable do I use to retain the original filename?

I tried to add preview upload but neither the file nor the database update.

My code changes have been:

templates/download_submit:
<td class="trow1"><strong>Upload Preview:</strong></td>
<td class="trow1"><input type="file" class="textbox" name="preview" size="30" /></td>
</tr>

added in with the other submission options.

<tr>
<td class="trow2">{$download['preview']}</td>
</tr>

in the file info window

	if($_FILES['preview']['size'] > 0)
	{
		$previewfile = downloads_upload_preview($_FILES['preview']);
	}
	
	if($previewfile['error'])
	{
		error($attachedfile['error']);
	}
with the same info for attachment in download.php

and
		'preview' => $db->escape_string($previewfile['filename']),
appended to the end of the array $new_download.

I've duplicated the downloads_upload_attachment function, changed all instances of $attachment to $preview, the folder uploaded to into downloads_preview (the folder is there). Is there anything else I need to change?
If you want to see some example of sorting look at my MYPS history page. That might be a good enough example for you to follow. Normally that's what I do...look for examples of existing code. Self-taught is a blueberry though.
Sorting is fine, I finished it and seems to be working fine after about an hour or 2 copying and modifying code from forumdisplay.php...my problems right now are timestamp (can't figure out how to save the date into a separate column when I submit a download) and an image upload form (as stated above). Thanks.
I'll probably make a plugin once MyBB 1.4 is out. I have my own customized version of this plugin, however, it's somewhat a mess in the back-end (with over 400 downloads, the AdminCP isn't exactly nice...).
I'll remember to take a look at that...since you have modified this yourself, what should I be changing to my current code to add the image preview system?

As it is, the file is uploaded fine but the file name isn't saved into the mysql database. When manually inserting the information into the database, I have the following as my display code:

Inside the template downloads_view_download

{$download['preview']}
Then in download.php...
$download['preview'] = "<a href='uploads/downloads_previews/" . $download['preview'] . "><img src='uploads/preview_thumbs/" . $download['preview'] . "' alt ='' /></a>";
So the original $download['preview'], the filename, is replaced by the above code...I then require a thumb.php to change it into a thumbnail and save the thumbnail with the same name to preview_thumbs with:
	} else {
	require MYBB_ROOT.'thumb.php?src='.$filename2;
	}
When it checks if the file uploaded. Instead, I get the following php error:
Warning: require(/home/tf2so0/public_html/forums/thumb.php?src=tf2s_preview_1_1196817017.jpg) [function.require]: failed to open stream: No such file or directory in /home/tf2so0/public_html/forums/downloads.php on line 651

Fatal error: require() [function.require]: Failed opening required '/home/tf2so0/public_html/forums/thumb.php?src=tf2s_preview_1_1196817017.jpg' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/tf2so0/public_html/forums/downloads.php on line 651
so this means that it's looking for the file in /downloads.php...not sure how to fix that. In addition, my server has full-url includes disabled (shared server) so I can't try that to make sure the rest of it works.

In addition, I already have it saving a unix timestamp into my database...how would I convert this into a date to display when browsing?

Finally, the ACP deletion doesn't seem to delete the actual file...how would I set this up?
Bump.

Well everything seems fine right now, except one problem:
I want the script to delete the corresponding file whenever I delete a file or deny validation; how would I got about doing so? Or instead, I could set up a script that would delete all files in a certain category that aren't referenced in the mysql table.
Pages: 1 2 3