Tracking software usage

Just starting out? Need help? Post your questions and find answers here.
jcoggins
User
User
Posts: 25
Joined: Sat Apr 12, 2008 12:30 am

Tracking software usage

Post by jcoggins »

I am looking for a way to track software usage. For example, the total number of times a particular program is used each day.

Any ideas on how I would go about doing that?

Jason
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Tracking software usage

Post by PB »

http://www.purebasic.fr/english/viewtopic.php?t=8624

No need to start a new thread. Search before posting, please. Thanks.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
jcoggins
User
User
Posts: 25
Joined: Sat Apr 12, 2008 12:30 am

Post by jcoggins »

I read the other post and I am talking about something different. The program is going to be given away free to all who want it but I want to keep track of such things as how many times the application is used each day by all users, how many different users are using it, etc... For example if user 1 used it 3 times and user 2 used it 2 times that would result in a total usage of 5 times by 2 users.

I am thinking that having the application store the information on an internet database might be the best way to go. Now if I can find some tutorials on how to access internet databases.

Edit: If anyone else knows of a better way to do this other then use a database let me know.

Jason
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

jcoggins wrote:I am thinking that having the application store the information on an internet database might be the best way to go.
I agree and it's also very easy to do if you know PHP and SQL. Then all you need is to to make your program contact that webscript each time it is run. Your program will not need to connect to any databases itself then (which would not be very safe either).
I like logic, hence I dislike humans but love computers.
jcoggins
User
User
Posts: 25
Joined: Sat Apr 12, 2008 12:30 am

Post by jcoggins »

Unfortunately I am not very familiar with PHP or MYSQL. Do you know of any good online tutorials that could walk me through it?

Jason
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> I am talking about something different

Sorry. I thought you meant an anti-piracy thing. My bad.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

jcoggins wrote:Unfortunately I am not very familiar with PHP or MYSQL. Do you know of any good online tutorials that could walk me through it?

Jason
google is your friend

www.w3schools.com/PHP/DEfaULT.asP
www.php.net/tut.php

many more :)

cheers
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

jcoggins wrote:Unfortunately I am not very familiar with PHP or MYSQL. Do you know of any good online tutorials that could walk me through it?
This site is really good for learning anything web related:
http://www.w3schools.com/PHP/php_intro.asp
http://www.w3schools.com/sql/sql_intro.asp

And to get you started I made this example for you (not tested, but probably works):

Code: Select all

<?php
//your webserver should have the needed information for you
mysql_connect('localhost','username','password') or die(mysql_error());
mysql_select_db('database_name') or die(mysql_error());

//Uncomment the line below to create your table or use phpMyAdmin
//mysql_query('CREATE TABLE counter (count int)') or die(mysql_error());

if (isset($_GET['countme']) and $_GET['countme'] == 'true') { //myWebsite/thisScript.php?countme=true
  mysql_query('UPDATE counter SET count=count+1') or die(mysql_error());
} else { //or if you're there to check the count
  $result = mysql_query('SELECT count FROM counter') or die(mysql_error());
  if ($row = mysql_fetch_array($result)) {
    echo 'Your program has been started '.$row['count'].' times.';
  }
}
?>
I like logic, hence I dislike humans but love computers.
jcoggins
User
User
Posts: 25
Joined: Sat Apr 12, 2008 12:30 am

Post by jcoggins »

Joakim Christiansen wrote:
jcoggins wrote:I am thinking that having the application store the information on an internet database might be the best way to go.
I agree and it's also very easy to do if you know PHP and SQL. Then all you need is to to make your program contact that webscript each time it is run. Your program will not need to connect to any databases itself then (which would not be very safe either).
How do I get my program to contact the webscript each time it is run? Do I use a WebGadet or do I use some other method?

Jason
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

jcoggins wrote:How do I get my program to contact the webscript each time it is run? Do I use a WebGadet or do I use some other method?
I tried to cut this function down to just contacting the script and then disconnect (no download of the html). It depends on your server, but this might be enough to cause a valid visit so your counter will count it.

Code: Select all

Procedure.s HttpGet(Server$,Path$) ;simple one to make page count a hit
  Protected Request$, ServerID = OpenNetworkConnection(Server$,80)
  
  If ServerID
    Request$ = "GET "+Path$+" HTTP/1.1"+#CRLF$
    Request$ + "Host: "+Server$+#CRLF$+#CRLF$
    SendNetworkData(ServerID,@Request$,Len(Request$))
    CloseNetworkConnection(ServerID)
  Else
    Debug "Error connecting"
  ProcedureReturn Result$
EndProcedure

HttpGet("myWebsever.com","/theCountScript.php?countme=true")
If this doesn't work then just contact me :) There is also a ReceiveHTTPFile() function included in PureBasic you can use, but that one needs to save the page to a file each time (which is kinda silly to use then).
I like logic, hence I dislike humans but love computers.
Post Reply