Page 2 of 2

Download-Counter

Posted: Mon 9. Aug 2004, 16:03
by Tekl!
Hallo,

ich habe mal ein kleinen Counter-Hack (für 1.1-RC4) gemacht:

- Füge in phpMyAdmin das Feld f_counts zur Tabelle phpwcms_file hinzu, als Typ habe ich bigint verwendet
- Füge folgendes in download.php ab Zeile 66 ein:

Code: Select all

	// begin download-counter (by Tekl)
	$download["f_counts"]++;
	$sql =  "UPDATE ".DB_PREPEND."phpwcms_file SET ".
		"f_counts='".$download["f_counts"]."' ".
		"WHERE f_kid=1 AND f_id=".$fid." AND f_uid=".$uid;
	$result = mysql_query($sql, $db) or die ("error while updating file info");
	// end download-counter
- In /include/inc_tmpl/files.private.editfile.tmpl.php füge folgendes ein:
unterhalb von: $file_longinfo = slweg(trim($_POST["file_longinfo"]));

Code: Select all

	$file_counts	= intval($_POST["file_counts"]);  // Tekl
unterhalb von: "f_keywords='".$file_keys."', ".

Code: Select all

	"f_counts='".$file_counts."', ". // Tekl
unterhalb von: $file_keys = $row["f_keywords"];

Code: Select all

	$file_counts	= $row["f_counts"];  // Tekl
13 Zeilen unterhalb von: //Wenn passende Extension, dann Thumbnail Creation anbieten

Code: Select all

	<td>&nbsp;&nbsp;<input name="file_counts" type="text" id="file_counts" size="8" value="<?php echo $file_counts; ?>"></td>
	<td class="v10"><strong><?php echo "Counts" ?></strong></td>
- In /include/inc_lib/files.private-functions.inc.php
Für einen Tooltip Zeile 128 ändern in:

Code: Select all

echo "<a href=\"fileinfo.php?fid=".$file_row["f_id"]."\" title=\"download-counter: ".$file_row["f_counts"];
Für eine Darstellung direkt in der Liste vor dieser Zeile folgende einfügen:

Code: Select all

if ($file_row["f_counts"]>0) echo "<div style=\"float:right\">(".$file_row["f_counts"].")</div>";
Gruß, Tekl

Posted: Wed 25. Aug 2004, 17:32
by Christian
Hallo Tekl!,

Ich habe den Counter-Hack mal offline versucht, doch es wird kein Ergebnis angezeigt, auch kein Fehler, einfach nichts.

Ich denke mal das ich einen Fehler beim erstellen der Tabelle mache, kannst Du mir erklären wie ich das einbauen muß, bzw. wie der Befehl lautet.

Bei mir schaut die Tabelle so aus:
CREATE TABLE phpwcms_file (
f_id int(11) NOT NULL auto_increment,
f_pid int(11) NOT NULL default '0',
f_uid int(11) NOT NULL default '0',
f_kid int(2) NOT NULL default '0',
f_order int(11) NOT NULL default '0',
f_trash int(1) NOT NULL default '0',
f_aktiv int(1) NOT NULL default '0',
f_public int(1) NOT NULL default '0',
f_tstamp timestamp(14) NOT NULL,
f_name varchar(255) NOT NULL default '',
f_cat varchar(200) NOT NULL default '',
f_created varchar(10) NOT NULL default '',
f_changed longblob NOT NULL,
f_size varchar(15) NOT NULL default '',
f_type varchar(200) NOT NULL default '',
f_ext varchar(50) NOT NULL default '',
f_shortinfo varchar(255) NOT NULL default '',
f_longinfo blob NOT NULL,
f_log longblob NOT NULL,
f_thumb_list varchar(255) NOT NULL default '',
f_thumb_preview varchar(255) NOT NULL default '',
f_keywords varchar(255) NOT NULL default '',
f_counts bigint(20) unsigned default NULL,
PRIMARY KEY (f_id),
FULLTEXT KEY f_name (f_name),
FULLTEXT KEY f_shortinfo (f_shortinfo)
) TYPE=MyISAM COMMENT='WCS Filemanagement';

MfG
Christian

Posted: Thu 26. Aug 2004, 11:13
by schmidti83
Hi Tekl,

ich habe das auch mal ausprobiert und bekomme folgende Fehlermeldung beim Download einer Datei:

Code: Select all

Warning: Cannot modify header information - headers already sent by (output started at /srv/www/htdocs/web15/html/download.php:3) in /srv/www/htdocs/web15/html/download.php on line 83

Warning: Cannot modify header information - headers already sent by (output started at /srv/www/htdocs/web15/html/download.php:3) in /srv/www/htdocs/web15/html/download.php on line 87

Warning: Cannot modify header information - headers already sent by (output started at /srv/www/htdocs/web15/html/download.php:3) in /srv/www/htdocs/web15/html/download.php on line 88

Warning: Cannot modify header information - headers already sent by (output started at /srv/www/htdocs/web15/html/download.php:3) in /srv/www/htdocs/web15/html/download.php on line 89

Warning: Cannot modify header information - headers already sent by (output started at /srv/www/htdocs/web15/html/download.php:3) in /srv/www/htdocs/web15/html/download.php on line 90

Warning: Cannot modify header information - headers already sent by (output started at /srv/www/htdocs/web15/html/download.php:3) in /srv/www/htdocs/web15/html/download.php on line 91
Im Backend kommt keine fehlermedlung bei der Anzeige der Dateiinfos.

Ich hoffe das ein Downloadcenter mit eingebaut wird, von Olli oder als Hack, Backend abet auch Frontend-Seitig.
Bis dahin, hope until the next release...

Posted: Mon 11. Apr 2005, 14:57
by spirelli
Download Counter Mod is available here:
http://www.emediafabrik.de/index.php?de ... oadcounter

Posted: Sat 10. Jun 2006, 23:42
by terry_b
Hello

Sorry for the *bump :)

Is it possible to do the same mod but to count clicks on links?

Thank you and keep up the great work.

T.