Return to Snippet

Revision: 13411
at April 23, 2009 05:21 by fearghalmurphy


Initial Code
<?php

//*code from http://moodle.org/blocks/HOWTO.html-->

class block_livestats extends block_list {
    // The init() method does not need to change at all

    function init() {
	$this->title = "Live Statistik";
//	$this->title = "Live Stats";
        $this->version = 2006150300;
	}
	
	function preferred_width() {
    // The preferred value is in pixels
    return 120;
}

function get_content() {
    if ($this->content !== NULL) {
        return $this->content;}
    

	$date=time() - 3600;
        //echo $date.'<br>';

	global $CFG;
        
        $datum = date("d.m.Y",time());   
        //echo $datum.'<br>';

        $timestamp = mktime(0,0,0,substr($datum,3,2),substr($datum,0,2),substr($datum,6,4));
        //echo $timestamp.'<br>';

	
	$query='SELECT COUNT( * ) FROM `mdl_log` WHERE `time` > '.$timestamp.' AND `action` = "login"';
	$res = mysql_query($query);
	list($count) = mysql_fetch_row($res);
	
    
    $this->content->items = array();
    $this->content->icons = array();
    $this->content->footer = "<p>".date("jS F Y") ."</p>";

	$Users =  count_records('user','deleted',0,'confirmed',1);
    $Courses = count_records('course','visible',1);
	
	
	$this->content->items[] = 
	
'<br><table  border="0" align="center">
  	<tr>
    	<td width="133"> <div align="left">Gesamtzahl Benutzer: </div></td>
    	<td width="42"><div align="left">' .$Users. '</div></td>
  	</tr>
 	<tr>
    	<td width="133"> <div align="left">Gesamtzahl Kurse: </div></td>
    	<td><div align="left">'.$Courses.'</div></td>
  	</tr>
  	<tr>
    	<td width="133"> <div align="left">Logins heute: </div></td>
    	<td><div align="left">'.$count.'</div></td>
  	</tr>
</table>';


    return $this->content;
}
}

?>

Initial URL

                                

Initial Description
Block - install as normal

Initial Title
Moodle Livestats

Initial Tags
php

Initial Language
PHP