Page 1 of 1

Tracking software usage

Posted: Sun May 10, 2009 7:27 pm
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

Re: Tracking software usage

Posted: Sun May 10, 2009 9:23 pm
by PB
http://www.purebasic.fr/english/viewtopic.php?t=8624

No need to start a new thread. Search before posting, please. Thanks.

Posted: Sun May 10, 2009 10:16 pm
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

Posted: Sun May 10, 2009 10:22 pm
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).

Posted: Mon May 11, 2009 12:00 am
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

Posted: Mon May 11, 2009 10:52 am
by PB
> I am talking about something different

Sorry. I thought you meant an anti-piracy thing. My bad.

Posted: Mon May 11, 2009 12:46 pm
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

Posted: Mon May 11, 2009 12:53 pm
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.';
  }
}
?>

Posted: Tue May 12, 2009 8:40 pm
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

Posted: Tue May 12, 2009 11:17 pm
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).