Czesc all
No wiec niewiem czy dodalem ten temat w odpowiedni dzial czy nie, mysle ze tu tez dostane odpowiednia odpwoedz.
No wiec chcial bym zeby na stronie pokazywalo sie kto jest zalogowany niewiem nie znam sie na tym caly czas ucze sie php`a jak na razie nie mam takiej wiedzy jaka bym chcial dlatego prosze was o pomoc
Prosze was pomusci mi mecze sie z tym dosc dlogo!!

modules/statistics/inc.Statistics.php
Kod
class statistics
{
  /* new object - configure */
  var $db;  //db class
  var $prefix;  //prefix in tables
  /* class vars */
  var $last24h_expire;  //last24h table
  var $online_expire;  //how old records in online table
  var $ip;
  /* return vars */
  var $visits;
  var $last24h;
  var $online;
  function statistics()
  {

  }
    function init()
  {
    $this->ip = get_ip();
    $this->set_visits() ? $this->set_last24h() : '';
    $this->clean_last24h();
    $this->set_online();  $this->clean_online();    
    $this->count_visits();
    $this->count_last24h();
    $this->count_online();
    $this->news();
    $this->members();
    $this->users();
    $this->news_posts();
    $this->replays_posts();
    $this->replays();
    $this->forum();
    $this->forum_posts();
    $this->clanwars();
    $this->clanwars_games();
    $this->clanwars_players();
  } //end func
  
  function get_visits()
  {
    return $this->visits;
  } //end func
  
  function get_last24h()
  {
    return $this->last24h;
  } //end func
  
  function get_online()
  {
    return $this->online;
  } //end func

     function get_news()
  {
    return $this->news;
  } //end func

    function get_members()
  {
    return $this->members;
  } //end func

    function get_users()
  {
    return $this->users;
  } //end func

  function get_news_posts()
{
   return $this->news_posts;
  } //end func

  function get_replays_posts()
  {
    return $this->replays_posts;
  } //end func
function get_replays()
  {
    return $this->replays;
  } //end func
  function get_forum_posts()
  {
    return $this->forum_posts;
  } //end func

function get_clanwars()
  {
    return $this->clanwars;
  } //end func

function get_clanwars_games()
  {
    return $this->clanwars_games;
  } //end func
function get_clanwars_players()
  {
   return $this->clanwars_players;
  } //end func
  function get_forum()
  {
   return $this->forum;
  } //end func
  function count_visits()
  {
    $this->db->query("select * from `{$this->prefix}visits`");
    $this->db->next_record();
    $this->visits = $this->db->Record['visits'];
  } //end func
    function count_last24h()
  {
    $this->db->query("select COUNT(*) as count from  `{$this->prefix}last24h`");
    $this->db->next_record();
    $this->last24h = $this->db->Record['count'];
  } //end func
    function count_online()
  {
    $this->db->query("select * from `{$this->prefix}online` group by ip");
    $this->online = $this->db->num_rows();
  } //end func
  

  function set_visits()
  {
    $this->db->query("update `{$this->prefix}visits` set visits = IF(MD5(CONCAT(visits,'crc32'))=visits_coded, visits+1, 0),  visits_coded=MD5(CONCAT(visits,'crc32')), lip1=lip2, lip2=lip3, lip3='{$this->ip}' where lip1<>'{$this->ip}' and lip2<>'{$this->ip}' and lip3<>'{$this->ip}'");

    if($this->db->affected_rows() == 1) return true;
    return false;
    
  } //end func
  
  function set_last24h()
  {
    $referer = isset($_SERVER['HTTP_REFERER']) ? addslashes($_SERVER['HTTP_REFERER']) : '';
    if(stristr($referer, $_SERVER['HTTP_HOST']) !== false) $referer = '';
    $this->db->query("insert into `{$this->prefix}last24h` set time=unix_timestamp(), ip='{$this->ip}', referer='$referer'");
  } //end func
  
  function clean_last24h()
  {
    $expire = time() - $this->last24h_expire;
    $this->db->query("delete from `{$this->prefix}last24h` where time<'$expire'");
  } //end func
  
  function set_online()
  {
    $PHPSESSID = addslashes(session_id());
    $this->db->query("select * from `{$this->prefix}online` where PHPSESSID='$PHPSESSID'");

    #-- update time
    if($this->db->num_rows() == 1) {
      $this->db->query("update `{$this->prefix}online` set time=unix_timestamp() where PHPSESSID='$PHPSESSID'");
    }

    #-- insert new
    else {
      $this->db->query("insert into `{$this->prefix}online` set PHPSESSID='$PHPSESSID', time=unix_timestamp(), ip='{$this->ip}'");
    }
  } //end func
  function clean_online()
  {
    $expire = time() - $this->online_expire;
    $this->db->query("delete from `{$this->prefix}online` where time<'$expire'");
  } //end func
  function display_last24h()
  {
    $this->db->query("select * from `{$this->prefix}last24h` order by time desc");
    $last24h = array();
    while($this->db->next_record()) {
      $this->db->Record['host'] = @gethostbyaddr($this->db->Record['ip']);
      $last24h[] = $this->db->Record;
    }
    $this->smarty->assign_by_ref('last24h', $last24h);
    $this->smarty->display($this->dir.'last24h.tpl');
    }//end func
    function news()
    {
     $this->db->query("select * from `{$this->prefix}news`");
     $this->news = $this->db->num_rows();
    } //end func
        function members ()
    {
     $this->db->query("select * from `{$this->prefix}users`");
     $this->members =$this->db->num_rows();
    } //end func
        function users ()
    {
     $this->db->query("select * from `{$this->prefix}members`");
     $this->users =$this->db->num_rows();
    } //end func
        function news_posts ()
    {
     $this->db->query("select * from `{$this->prefix}news_posts`");
     $this->news_posts =$this->db->num_rows();
    } //end func
        function replays_posts ()
    {
     $this->db->query("select * from `{$this->prefix}replays_posts`");
     $this->replays_posts =$this->db->num_rows();
    } //end func
       function replays ()
   {
     $this->db->query("select * from `{$this->prefix}replays`");
     $this->replays =$this->db->num_rows();
    } //end func
        function forum_posts ()
    {
     $this->db->query("select * from `{$this->prefix}forum_posts`");
     $this->forum_posts =$this->db->num_rows();
    } //end func
   function forum ()
    {
     $this->db->query("select * from `{$this->prefix}forum`");
     $this->forum =$this->db->num_rows();
    } //end func
  function clanwars ()
    {
     $this->db->query("select * from `{$this->prefix}clanwars`");
     $this->clanwars =$this->db->num_rows();
    } //end func
    function clanwars_games ()
   {
    $this->db->query("select * from `{$this->prefix}clanwars_games`");
     $this->clanwars_games =$this->db->num_rows();
    } //end func
        function clanwars_players ()
    {
     $this->db->query("select * from `{$this->prefix}clanwars_players`");
     $this->clanwars_players =$this->db->num_rows();
    } //end func
} //end class
?>


modules/statistics/statistics.php

Kod
if(basename(__FILE__) == basename($_SERVER['PHP_SELF'])) exit('You cannot access this file directly !');

require 'modules/statistics/inc.Statistics.php';

global $stats;
global $db;
global $cfg;

$stats =& new statistics;

$stats->db =& $db;
$stats->prefix = $cfg['prefix'];

$stats->last24h_expire = 60 * 60 * 24;
$stats->online_expire = 60 * 30;

$stats->init();

$this->assign('visits', $stats->get_visits());
$this->assign('last24h', $stats->get_last24h());
$this->assign('online', $stats->get_online());
$this->assign('news', $stats->get_news());
$this->assign('members', $stats->get_members());
$this->assign('users', $stats->get_users());
$this->assign('news_posts', $stats->get_news_posts());
$this->assign('replays_posts', $stats->get_replays_posts());
$this->assign('replays', $stats->get_replays());
$this->assign('forum', $stats->get_forum());
$this->assign('forum_posts', $stats->get_forum_posts());
$this->assign('clanwars', $stats->get_clanwars());
$this->assign('clanwars_games', $stats->get_clanwars_games());
$this->assign('clanwars_players', $stats->get_clanwars_players());
?>

modules/statistics/statistics.sql
Kod
create table `mgc_online` (
  PHPSESSID varchar(32) not null default '',
  time varchar(14) not null default '0',
  ip varchar(15) not null default '',
  primary key (PHPSESSID)
);




W tym kodzie wyswietal sie zawartosc tego na www
templates/statistics/statistics.tpl
Kod
{* statistics.tpl *}
{include_php file="modules/statistics/statistics.php"}



<table cellspacing=0 cellpadding=5 width=100%>

<tr><td align=center class=extra><div align="center"><b class=heading><img border="0" src="images/mb/m_b3_over.gif" width="100" height="15"></B></DIV></td></tr>
<tr><td class=extras>


<font color="#FFF8DC">Wizyt:</font> {$visits} <br />
<font color="#FFF8DC">Dzis:</font> {$last24h} <br />
<font color="#FFF8DC">Aktualnie:</font> {$online} <br />
<font color="#604527">==Ladder-CW==</font> <br>
<font color="#FFF8DC">LCW:</font> {$clanwars} <br>
<font color="#FFF8DC">Players:</font> {$clanwars_players} <br>
<font color="#FFF8DC">Games:</font> {$clanwars_games} <br>
<font color="#604527">====Users====</font> <br>
<font color="#FFF8DC">Members:</font> {$users} <br>
<font color="#FFF8DC">Users:</font> {$members} <br>
<font color="#604527">====INFO====</font> <br>
<font color="#FFF8DC">News:</font> {$news} <br>
<font color="#FFF8DC">Post:</font> {$news_posts} <br>
<font color="#FFF8DC">Forum:</font> {$forum} <br>
<font color="#FFF8DC">Posts:</font> {$forum_posts} <br>
<font color="#FFF8DC">Replays:</font> {$replays} <br>
<font color="#FFF8DC">Posts:</font> {$replays_posts} <br>
</td></tr>

</table>

    <br /><br />