Visualizzazione dei risultati da 1 a 5 su 5

Discussione: utenti on line

  1. #1

    utenti on line

    ho una community virtuale con utenti iscritti... esiste un metodo per cui riesco a visualizzare la lista degli iscritti online in un determinato momento? tipo:

    utenti online:

    Paperino
    Paperoga
    Pippo
    Qui
    Quo
    Qua
    Pluto



  2. #2
    mi servirebbe anche a me se qualcuno ha dei esempi di codice ...

    Grazie

    Michel
    PHP THE BEST

  3. #3
    speriamo in qualche anima pia

  4. #4
    Utente di HTML.it
    Registrato dal
    Dec 2005
    Messaggi
    434
    beh, l'avete trovata questo script usa i file.
    online.class.php
    codice:
    <?php
    class usersOnline {
    	var $users_file;
    	var $timeout;
    	var $timestamp;
    	var $ip;
    	function usersOnline($file_, $timeout_) {
    		global $_SERVER;
    		$this->timestamp = time();
    		$ip_ = ($_SERVER['REMOTE_ADDR'] != "" && preg_match("/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/", $_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : "non rilevato";
    		$this->ip = $ip_;
    		$this->users_file = $file_;
    		$this->timeout = $timeout_;
    		$this->newUser();
    		$this->deleteUser();
    	}
    	function newUser() {
    		$content = file_get_contents($this->users_file);
    		$lines = file($this->users_file);
    		foreach($lines as $line) {
    			$linea = explode("|", $line);
    			if($linea[0] == $this->ip) {
    				return;
    			}
    		}
    		$ip = $this->ip;
    		$timestamp = $this->timestamp;
    		$content .= "\n$ip|$timestamp";
    		writeFile($this->users_file, trim($content));
    	}
    	function deleteUser() {
    		$file = file($this->users_file);
    		foreach($file as $key => $line) {
    			$linea = explode("|", $line);
    			$aa = $this->timestamp - $this->timeout;
    			if($linea[1] < $aa && $linea[0] != $this->ip) {
    				unset($file[$key]);
    			}
    		}
    		writeFile($this->users_file, trim(str_replace("\n\n", "\n", implode("\n", $file))));
    	}
    	function countVisits() {
    		return count(file($this->users_file));
    	}
    }
    ?>
    per applicare basta fare:
    codice:
    <?php
    require("online.class.php");
    $online = new usersonline("online.txt", 3*60);
    echo "Utenti online: ".$online->countVisits();
    ?>
    Cià

  5. #5
    Ma non è proprio quello ke volevamo, (mi aggiungo alla lista).

    Non apre database per estrarre nick o email. come fare?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.