User's Online Script?

Discussion in 'Web Programming' started by Covey, Feb 12, 2007.

User's Online Script?
  1. Unread #1 - Feb 12, 2007 at 6:01 AM
  2. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    User's Online Script?

    Ok for my program EliteSwitch im trying to make it have a user's online part, how would i do this?

    When i start the program i need it to add 1 to the user's online, then when i close the program it will have to take 1 away from the user's online.

    How can i do that?
     
  3. Unread #2 - Feb 12, 2007 at 6:47 AM
  4. Michael3455
    Joined:
    Sep 11, 2005
    Posts:
    134
    Referrals:
    0
    Sythe Gold:
    0

    Michael3455 Active Member

    User's Online Script?

    I would think PHP and a Database would be the easiest. I don't think that it would be too hard to do it. I made a members login/members area script for a friend in PHP, from first looking at the language to completion of it, it took me around three hours. But I had some help from a friend...

    So.. For someone who can actually program, it might only take you 20 minutes to find out what you need to know... Or you could just google.. I'm sure you could find a script that would be similar to what you need.
     
  5. Unread #3 - Feb 12, 2007 at 7:36 AM
  6. cp
    Joined:
    Jan 30, 2007
    Posts:
    3,278
    Referrals:
    6
    Sythe Gold:
    0

    cp an cat
    Banned

    User's Online Script?

    What language is the program? I might be able to help you if you're using python for the program, or php.

    The language you're making your program in should have a kill function or a conditional statement on what to do if the program is exited, where you can have it invisibly load the webpage with php and do that. Same goes with opening it. And you could add a while loop to constantly refresh the frame or whatever that holds the data of the people online.

    Assuming you know php, just make a php file that when the get request is ?get=add you add one to the file and read it. If it's ?get=minus then you take one out and read that.

    Assuming that your language can actually do that.
     
  7. Unread #4 - Feb 12, 2007 at 7:53 PM
  8. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    User's Online Script?

    i've got this code from smither at cruels.net
    Code:
    <?php
    If ($_GET['act'] == 'join') {
      // Add one to a file
    } else if ( $_GET['act'] == 'leave') {
      // Remove one
    } else {
      // echo file
    }
    
    ?>
    but i don't know how to use it.

    lets pretend my .php page is called 'online.php'

    when i load my program do it go to www.blah.com/online.php?join

    and when i exit to i go to www.blah.com/online.php?leave

    and to display the number of players online to i go to www.blah.com/online.php

    is that correct?

    also how to i exactly add one to a file and remove one from a file and echo the file (i know echo is a msgbox, well i think)
     
  9. Unread #5 - Feb 12, 2007 at 9:46 PM
  10. cp
    Joined:
    Jan 30, 2007
    Posts:
    3,278
    Referrals:
    6
    Sythe Gold:
    0

    cp an cat
    Banned

    User's Online Script?

    Code:
    <?php
    $fp = fopen('peepz.txt', 'w+');
    $ro = fopen('peepz.txt', 'r');
    $read = fread($ro, filesize("peepz.txt"));
    if(isset($_GET['join'])) {
    $read = $read + 1;
    fwrite($fp, $read);
    }
    else {
    if(isset($_GET['leave'])) {
    $read = $read - 1;
    fwrite($fp, $read);
    }
    }
    
    echo("".$read."");
    ?>
    
    When a user joins, load online.php?join . When the user leaves, load online.php?leave .

    If you want to read (I don't know vb) read the url http://www.whatever.poo/online.php (without ?leave or ?join)

    If you get any errors (there shouldn't be any) tell me, or try fixing it yourself.

    Have fun.
     
  11. Unread #6 - Feb 23, 2007 at 1:41 AM
  12. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    User's Online Script?

    i got an error :(

    Warning: fread(): Length parameter must be greater than 0. in /home/tesstott/public_html/sscovey/eliteswitch/users.php on line 4

    i have the users.php file and an online.txt, they are both CHMOD to 777.

    heres the users.php code:
    Code:
    <?php
    $fp = fopen('online.txt', 'w+');
    $ro = fopen('online.txt', 'r');
    $read = fread($ro, filesize("online.txt"));
    if(isset($_GET['join'])) {
    $read = $read + 1;
    fwrite($fp, $read);
    }
    else {
    if(isset($_GET['leave'])) {
    $read = $read - 1;
    fwrite($fp, $read);
    }
    }
    
    echo("".$read."");
    ?>
    i tried putting 0 and 1 in the online.txt but it made no difference :(

    pelase help
     
  13. Unread #7 - Feb 25, 2007 at 9:09 AM
  14. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    User's Online Script?

    anyone?
     
  15. Unread #8 - Feb 25, 2007 at 3:09 PM
  16. asrkj117
    Referrals:
    0

    asrkj117 Guest

    User's Online Script?

    try this

    <?php
    $fp = fopen('online.txt', 'w+');
    $ro = fopen('online.txt', 'r');
    $read = fread($ro, filesize("online.txt"));
    if(isset($_GET['join'])) {
    $read = $read + 1;
    fwrite($fp, $read);
    }
    else {
    if(isset($_GET['leave'])) {
    fwrite($fp, $read);
    }
    }

    echo("".$read."");
    ?>
     
  17. Unread #9 - Feb 25, 2007 at 8:08 PM
  18. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    User's Online Script?

    still the same error :(
     
  19. Unread #10 - Feb 26, 2007 at 5:44 AM
  20. Jazz00006
    Joined:
    Aug 26, 2005
    Posts:
    807
    Referrals:
    0
    Sythe Gold:
    0

    Jazz00006 Apprentice
    Visual Basic Programmers

    User's Online Script?

    tried mine? (the one MH gave you)
     
  21. Unread #11 - Feb 26, 2007 at 9:30 AM
  22. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    User's Online Script?

    yup, got it brewing now ^_^ thanks again.
     
< [Delphi][Source] FindColor(Tolerance) using ScanLines | [TuT]The Basic Html Code[TuT] >

Users viewing this thread
1 guest


 
 
Adblock breaks this site