Jump to content


[Mantis BugTracker] Add downloads counter to project files


No replies to this topic

#1 visiblesoul

  • Administrators
  • 551 posts
  • Location:Earth
  • Texas

Posted 28 December 2007 - 05:06 PM

This little hack will display the number of times a project file has been downloaded.

IMPORTANT! As always, backup your database and Mantis files before modifying.

RUN QUERY:

Run this database query to add a "downloads" field to the mantis_project_file_table database table.

ALTER TABLE `mantis_project_file_table` ADD `downloads` INT( 10 ) NOT NULL DEFAULT '0';
FIND in file_download.php

	exit();
?>
ADD ABOVE:
	//Download counter
	$t_project_file_table = config_get( 'mantis_project_file_table' );
	$query2 = "UPDATE $t_project_file_table SET downloads = {$row['downloads']}+1 WHERE id='$c_file_id'";
	$result2 = db_query( $query2 );
FIND in proj_doc_page.php:
	$query = "SELECT pft.id, pft.project_id, pft.filename, pft.filesize, pft.title, pft.description, pft.date_added
REPLACE WITH:
	//Download counter
	//$query = "SELECT pft.id, pft.project_id, pft.filename, pft.filesize, pft.title, pft.description, pft.date_added
	$query = "SELECT pft.id, pft.project_id, pft.filename, pft.filesize, pft.title, pft.description, pft.date_added, pft.downloads
FIND:
		$v_title = string_display( $v_title );
ADD BELOW:
		$v_downloads = string_display( $v_downloads ); //Download counter
FIND:
		echo '</a> ' . $t_href . $v_title . '</a> ('.$v_filesize.' bytes)';
ADD BELOW:
		echo ' Downloads: ' . $v_downloads; //Download counter



Please note that I offer free support on this forum in my free time. Depending on how much work I have backlogged it may take me a week or more to answer questions. I am not ignoring you. I answer everyone but please be patient. Thanks.

Disclaimer: All forum posts, including code examples, on this forum are offered for free in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Use code examples at your own risk.

"If at first you don't succeed, keep on suckin' til you do succeed." -Curly Howard




Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users