How to make an automatically generated list of websites that use my plugin

Discussion in 'PHP' started by lelkoun, May 8, 2010.

  1. #1
    I develop a plugin designed for WordPress. I want to know who uses my plugin.

    There are install and uninstall hooks in WP. So every instance of my plugin can do a "pingback" to my server when it is activated or deactivated.

    But I do not know how to make it. Any ideas?

    Thank you! :)
     
    lelkoun, May 8, 2010 IP
  2. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Have a script that writes to your mysql server every time it's installed with the domain name of the server. Should be as simple as that really, then just get the list from your mysql table
     
    JAY6390, May 8, 2010 IP
  3. live.co.uk

    live.co.uk Banned

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i can't understand what you are looking for
     
    live.co.uk, May 8, 2010 IP
  4. Grit.

    Grit. Well-Known Member

    Messages:
    1,424
    Likes Received:
    22
    Best Answers:
    1
    Trophy Points:
    110
    #4
    Well how about you stick something in the plugin so that when a visit views the content, it sends a request to your callback URL on your server, so you can tell which sites are actively using your plugin, and then refresh the list using some kind of cron on your server that if the callback isn't recieved within the past 24 hours, it can remove the URL assuming it isn't actively using the plugins anymore.

    If you want me to elaborate, I am happy to go over my idea further, but it goes like this for basics:

    function chckforactive($content){

    //send a message to your server or site

    return $content ;

    }

    then add the action so it parses the content (this way when a user views the content while your plugin is installed, your server will get a message)

    then on your site have a script to recieve the data you're sending. you may wish to extend past 24 hours just to allow for smaller sites to be known. just make sure that they aren't aware you're doing it, or you may just get sites adding and then removing your plugin to get a free backlink
     
    Grit., May 8, 2010 IP
  5. musicmasteria

    musicmasteria Peon

    Messages:
    33
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Doing something like Grit suggested could be very bad for the performance of the server that would receive daily pings from potentially thousands of servers (depending upon how popular your plugin is).

    Stick to the on activate/deactive method.
    Example:
    -------- site -------- | myPluginID | anotherPluginID | ...
    urlencodedurl.com | ---- 1 -----| -------- 0 ------- | ...

    Possible values for myPluginID, anotherPluginID, ... = 0: never activated, 1:activated, 2:decativated

    In your activation function:
    1. url encode the users site url
    2. ping your server's script like this: example.com/activated.php?plugin=myPluginID&site=urlencodedurl.com&status=1

    In your deactivation function:
    1. url encode the users site url
    2. ping your server's script like this: example.com/activated.php?plugin=myPluginID&site=urlencodedurl.com&status=2

    Create a database table for site 'profiles'

    in your activated.php file:
    1. Check for occurrence of site ($_GET['site']) in your database
    2. If site not found add a new row/profile for it
    3. check site's profile for plugin
    3. if no occurrence found, add new plugin to sites profile
    4. Check status ($_GET['status']) and update the plugin's status under the site's profile accordingly (1:activated, 2 deactivated)
    In summary the script will create/update a site's profile in your database that will include which plugins a site is using and what the last known status of that/those plugin(s) is/are.

    Anyway that's how I'd begin to do this.
     
    Last edited: May 10, 2010
    musicmasteria, May 10, 2010 IP
    lelkoun likes this.
  6. lelkoun

    lelkoun Active Member

    Messages:
    288
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    60
    #6
    Thank you! :)
     
    lelkoun, May 10, 2010 IP