User Tools

Site Tools


a_simple_php_sqlite_download_counter

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
a_simple_php_sqlite_download_counter [2020/06/27 21:21] waxphilosophica_simple_php_sqlite_download_counter [2024/08/31 19:27] (current) – %%h hc9
Line 3: Line 3:
 ===== Summary ===== ===== Summary =====
  
-If you host downloadable content on SDF, you may want to get an idea of how many people have downloaded things and which are the most popular. In this tutorial, I will focus on an example of tracking PDF formatted ebooks. After completing this tutorial, you should be able to modify things to suit your needs, even if your downloads are not ebooks. You will need to have PHP access to do this, so check your membership level before you get started.+If you host downloadable web content on SDF, you may want to get an idea of how many people have downloaded things and which are the most popular. In this tutorial, I will focus on an example of tracking PDF formatted ebooks. After completing this tutorial, you should be able to modify things to suit your needs, even if your downloads are not ebooks. You will need to have PHP access to do this, so check your membership level before you get started.
  
 ===== The Download Script ===== ===== The Download Script =====
Line 75: Line 75:
 <code>$content_dir = basename(__FILE__) . "/download";</code> <code>$content_dir = basename(__FILE__) . "/download";</code>
  
-__FILE__ in PHP means the filesystem path to the PHP script being executed. This is not the URL path, but the filesystem path. So it will not be ''http://login.sdf.org/download''. It will look more like ''/sdf/arpa/tz/l/login/html'' and using the dot concatenation operator will tack ''/download'' to the end of it.+__FILE__ in PHP means the filesystem path to the PHP script being executed. This is not the URL path, but the filesystem path. So it will not be ''%%http://login.sdf.org/download%%''. It will look more like ''/sdf/arpa/tz/l/login/html'' and using the dot concatenation operator will tack ''/download'' to the end of it.
  
 So now you know where to store you content and what to change if it's located somewhere else. So now you know where to store you content and what to change if it's located somewhere else.
Line 230: Line 230:
 Even if you're not a SQL expert, you can prune by simply picking a rowid and delete everything before it. "DELETE FROM tally WHERE rowid<100" will purge everything from 1 to 99. You get the idea. Even if you're not a SQL expert, you can prune by simply picking a rowid and delete everything before it. "DELETE FROM tally WHERE rowid<100" will purge everything from 1 to 99. You get the idea.
  
-====== Go Forth and Conquer ======+===== Go Forth and Conquer =====
  
 Now that you know what people are downloading from your site, you'll have better insight into what's popular and what's not. Now that you know what people are downloading from your site, you'll have better insight into what's popular and what's not.
  
 It's your call, but I like to let people know I'm tracking downloads. Even though I'm not gathering any personal information with it, I like to be transparent about it. I put it in a privacy statement on my site and even offer a link to the PHP query that shows what's been downloaded. It's your call, but I like to let people know I'm tracking downloads. Even though I'm not gathering any personal information with it, I like to be transparent about it. I put it in a privacy statement on my site and even offer a link to the PHP query that shows what's been downloaded.
- 
- 
  
a_simple_php_sqlite_download_counter.1593292919.txt.gz · Last modified: 2020/06/27 21:21 by waxphilosophic