Beispiel #1
0
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 * 
 */
/**
 * Vertical bars demonstration
 *
 */
include "../libchart.php";
$chart = new PieChart();
$chart->addPoint(new Point("Mozilla Firefox (80)", 80));
$chart->addPoint(new Point("Konqueror (75)", 75));
$chart->addPoint(new Point("Opera (50)", 50));
$chart->addPoint(new Point("Safari (37)", 37));
$chart->addPoint(new Point("Dillo (37)", 37));
$chart->addPoint(new Point("Other (72)", 70));
$chart->setTitle("User agents for www.example.com");
$chart->render("generated/demo3.png");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Libcharts pie chart demonstration</title>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15" />
</head>
<body>
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 *********************************************************************************************************
 * Description:
 *		this extension creates a pie chart of the comparison of hotspots per unique users
 *
 * Authors:	Liran Tal <*****@*****.**>
 *
 *********************************************************************************************************
 */
include 'checklogin.php';
include 'opendb.php';
include 'libchart/libchart.php';
header("Content-type: image/png");
$chart = new PieChart(620, 320);
// getting total downloads of days in a month
$sql = "SELECT " . $configValues['CONFIG_DB_TBL_DALOHOTSPOTS'] . ".name, count(distinct(UserName)), count(radacctid), " . " avg(AcctSessionTime), sum(AcctSessionTime) FROM " . $configValues['CONFIG_DB_TBL_RADACCT'] . " JOIN " . $configValues['CONFIG_DB_TBL_DALOHOTSPOTS'] . " ON (" . $configValues['CONFIG_DB_TBL_RADACCT'] . ".calledstationid LIKE " . $configValues['CONFIG_DB_TBL_DALOHOTSPOTS'] . ".mac) GROUP BY " . $configValues['CONFIG_DB_TBL_DALOHOTSPOTS'] . ".name;";
$res = $dbSocket->query($sql);
while ($row = $res->fetchRow()) {
    $chart->addPoint(new Point("{$row['0']} ({$row['3']} seconds)", "{$row['3']}"));
}
$chart->setTitle("Distribution of Time usage per Hotspot");
$chart->render();
include 'closedb.php';
?>


 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 *********************************************************************************************************
 * Description:
 *		this extension creates a pie chart of the comparison of hotspots per unique users
 *
 * Authors:	Liran Tal <*****@*****.**>
 *
 *********************************************************************************************************
 */
include 'checklogin.php';
include 'opendb.php';
include 'libchart/libchart.php';
header("Content-type: image/png");
$chart = new PieChart(620, 320);
// getting total downloads of days in a month
$sql = "SELECT " . $configValues['CONFIG_DB_TBL_DALOHOTSPOTS'] . ".name, count(distinct(UserName)), count(radacctid), avg(AcctSessionTime), sum(AcctSessionTime) FROM " . $configValues['CONFIG_DB_TBL_RADACCT'] . " JOIN " . $configValues['CONFIG_DB_TBL_DALOHOTSPOTS'] . " ON (" . $configValues['CONFIG_DB_TBL_RADACCT'] . ".calledstationid LIKE " . $configValues['CONFIG_DB_TBL_DALOHOTSPOTS'] . ".mac) GROUP BY " . $configValues['CONFIG_DB_TBL_DALOHOTSPOTS'] . ".name;";
$res = $dbSocket->query($sql);
while ($row = $res->fetchRow()) {
    $chart->addPoint(new Point("{$row['0']} ({$row['2']} users)", "{$row['2']}"));
}
$chart->setTitle("Distribution of Hits (Logins) per Hotspot");
$chart->render();
include 'closedb.php';
?>


Beispiel #4
0
/** Libchart - PHP chart library
 *	
 * Copyright (C) 2005-2006 Jean-Marc Trémeaux (jm.tremeaux at gmail.com)
 * 	
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 * 
 */
/**
 * Direct PNG output demonstration (image not saved to disk)
 *
 */
include "../libchart.php";
header("Content-type: image/png");
$chart = new PieChart(500, 300);
$chart->addPoint(new Point("Bleu d'Auvergne", 50));
$chart->addPoint(new Point("Tomme de Savoie", 75));
$chart->addPoint(new Point("Crottin de Chavignol", 30));
$chart->setTitle("Preferred Cheese");
$chart->render();
 *
 *********************************************************************************************************
 * Description:
 *		this extension creates a pie chart of online users
 *
 * Authors:	Liran Tal <*****@*****.**>
 *
 *********************************************************************************************************
 */
include 'checklogin.php';
include 'opendb.php';
include 'libchart/libchart.php';
header("Content-type: image/png");
$chart = new PieChart(620, 320);
// getting total users
$sql = "SELECT DISTINCT(UserName) FROM " . $configValues['CONFIG_DB_TBL_RADCHECK'];
$res = $dbSocket->query($sql);
$totalUsers = $res->numRows();
$chart->addPoint(new Point("{$totalUsers}  usuarios totales", "{$totalUsers}"));
// get total users online
$sql = "SELECT DISTINCT(UserName) FROM " . $configValues['CONFIG_DB_TBL_RADACCT'] . " WHERE (AcctStopTime is NULL OR AcctStopTime = '0000-00-00 00:00:00')";
$res = $dbSocket->query($sql);
$totalUsersOnline = $res->numRows();
$chart->addPoint(new Point("{$totalUsersOnline} usuarios en linea", "{$totalUsersOnline}"));
$chart->setTitle("Usuarios en linea");
$chart->render();
include 'closedb.php';
?>


Beispiel #6
0
$Plot->setMarker($PointingMarker);
// format value marker labels as percentage values
$Marker->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%0.1f%%'));
$Plot->Radius = 2;
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
$Plot->setFillStyle($FillArray);
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'green'));
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'blue'));
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'yellow'));
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'red'));
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'orange'));
$Plot->explode(5);
$PointingMarker->setLineColor(false);
$Marker->setBorderColor(false);
$Marker->setFillColor(false);
// output the Graph
$Graph->done();
exit;
?>
 

<?php 
include "inx/libchart/libchart.php";
$filename = $date_mysql;
$chart = new PieChart(200, 200);
$chart->addPoint(new Point("Mozilla Firefox (80)", 80));
$chart->addPoint(new Point("Konqueror (75)", 75));
$chart->addPoint(new Point("Other (50)", 50));
$chart->render("img/generated/{$filename}.png");
?>
<img src="img/generated/$filename.png">
Beispiel #7
0
if (count($v) / 2 > 8) {
    $chart = new PieChart(450, 300);
} else {
    $chart = new PieChart(400, 250);
}
if (isset($_GET['order'])) {
    $chart->order = true;
} else {
    $chart->order = false;
}
$tot = 0;
for ($i = 1; $i < count($v); $i += 2) {
    $tot += $v[$i + 1];
}
for ($i = 1; $i < count($v); $i += 2) {
    $color = null;
    if ($cor != null) {
        $r = hexdec(substr($cor[($i - 1) / 2], 0, 2));
        $g = hexdec(substr($cor[($i - 1) / 2], 2, 2));
        $b = hexdec(substr($cor[($i - 1) / 2], 4, 2));
        $color = array($r, $g, $b);
    }
    if ($v[$i + 1] > $tot / 100) {
        $chart->addPoint(new Point($v[$i], $v[$i + 1], $color));
    } else {
        $chart->addPoint(new Point($v[$i], $tot / 100, $color));
    }
}
$chart->setTitle($v[0]);
$chart->setLogo($locr . "/images/poweredbyboca.png");
$chart->render();
function JLMS_sreportAccess($option, $is_full)
{
    global $JLMS_DB, $JLMS_CONFIG, $JLMS_SESSION, $my, $Itemid;
    $JLMS_ACL =& JLMSFactory::getACL();
    $view = mosGetParam($_REQUEST, 'view', '');
    if ($view == 'csv' || $view == 'xls') {
        $is_full = 1;
    }
    $start_date = mosGetParam($_REQUEST, 'start_date', "");
    $end_date = mosGetParam($_REQUEST, 'end_date', "");
    $limit = intval(mosGetParam($_GET, 'limit', $JLMS_SESSION->get('list_limit', $JLMS_CONFIG->get('list_limit'))));
    $JLMS_SESSION->set('list_limit', $limit);
    $limitstart = intval(mosGetParam($_GET, 'limitstart', 0));
    $filt_group = intval(mosGetParam($_REQUEST, 'filt_group', 0));
    $lists = array();
    $reporting_header = array();
    $filt_cat = intval(mosGetParam($_REQUEST, 'filt_cat', 0));
    //FLMS multicat
    $levels = array();
    if ($JLMS_CONFIG->get('multicat_use', 0)) {
        $query = "SELECT * FROM #__lms_course_cats_config ORDER BY id";
        $JLMS_DB->setQuery($query);
        $levels = $JLMS_DB->loadObjectList();
        if (count($levels) == 0) {
            for ($i = 0; $i < 5; $i++) {
                if ($i > 0) {
                    $levels[$i]->cat_name = _JLMS_COURSES_COURSES_GROUPS;
                } else {
                    $levels[$i]->cat_name = _JLMS_COURSES_COURSES_GROUPS;
                }
            }
        }
        $level_id = array();
        for ($i = 0; $i < count($levels); $i++) {
            if ($i == 0) {
                $level_id[$i] = intval(mosGetParam($_REQUEST, 'filter_id_' . $i . '', $JLMS_SESSION->get('FLMS_filter_id_' . $i . '', 0)));
                $_REQUEST['filter_id_' . $i] = $level_id[$i];
                $JLMS_SESSION->set('FLMS_filter_id_' . $i . '', $level_id[$i]);
            } else {
                $level_id[$i] = intval(mosGetParam($_REQUEST, 'filter_id_' . $i . '', $JLMS_SESSION->get('FLMS_filter_id_' . $i . '', 0)));
                $_REQUEST['filter_id_' . $i] = $level_id[$i];
                $JLMS_SESSION->set('FLMS_filter_id_' . $i . '', $level_id[$i]);
            }
            if ($i == 0) {
                $parent_id[$i] = 0;
            } else {
                $parent_id[$i] = $level_id[$i - 1];
            }
            if ($i == 0 || $parent_id[$i]) {
                //(Max): extra requests
                $query = "SELECT count(id) FROM `#__lms_course_cats` WHERE parent = '" . $parent_id[$i] . "' ORDER BY c_category";
                $JLMS_DB->setQuery($query);
                $groups = $JLMS_DB->loadResult();
                if ($groups == 0) {
                    $level_id[$i] = 0;
                    $JLMS_SESSION->set('FLMS_filter_id_' . $i . '', $level_id[$i]);
                }
            }
        }
        for ($i = 0; $i < count($levels); $i++) {
            if ($i > 0 && $level_id[$i - 1] == 0) {
                $level_id[$i] = 0;
                $_REQUEST['filter_id_' . $i] = $level_id[$i];
                $JLMS_SESSION->set('FLMS_filter_id_' . $i . '', $level_id[$i]);
                $parent_id[$i] = 0;
            } elseif ($i == 0 && $level_id[$i] == 0) {
                $level_id[$i] = 0;
                $_REQUEST['filter_id_' . $i] = $level_id[$i];
                $JLMS_SESSION->set('FLMS_filter_id_' . $i . '', $level_id[$i]);
                $parent_id[$i] = 0;
            }
        }
        $javascript = 'onclick="javascript:read_filter();" onchange="javascript:write_filter();submitFormView(\'\');"';
        $query1 = "SELECT group_id FROM `#__lms_users_in_global_groups` WHERE user_id = '" . $my->id . "'";
        $JLMS_DB->setQuery($query1);
        $user_group_ids = $JLMS_DB->loadResultArray();
        $categories_reporting = array();
        $name_categories_reporting = array();
        for ($i = 0; $i < count($levels); $i++) {
            if ($i == 0 || $parent_id[$i]) {
                //(Max): extra requests
                if ($parent_id[$i] == 0 && !$JLMS_ACL->CheckPermissions('lms', 'create_course')) {
                    $query = "SELECT * FROM `#__lms_course_cats` WHERE `parent` = '0'";
                    $query .= "\n AND (";
                    if (count($user_group_ids)) {
                        $query .= "( `restricted` = 1 AND ( `groups` LIKE '%|{$user_group_ids['0']}|%'";
                        for ($i1 = 1; $i1 < count($user_group_ids); $i1++) {
                            $query .= "\n OR `groups` like '%|{$user_group_ids[$i1]}|%'";
                        }
                        $query .= "\n ) ) \n OR ";
                    }
                    $query .= "(`restricted` = 0 )) ";
                    $query .= "\n ORDER BY `c_category`";
                } else {
                    $query = "SELECT * FROM `#__lms_course_cats` WHERE parent = '" . $parent_id[$i] . "' ORDER BY c_category";
                }
                $JLMS_DB->setQuery($query);
                $groups = $JLMS_DB->loadObjectList();
                if ($parent_id[$i] && $i > 0 && count($groups)) {
                    $type_level[$i][] = mosHTML::makeOption(0, ' &nbsp; ');
                    foreach ($groups as $group) {
                        $type_level[$i][] = mosHTML::makeOption($group->id, $group->c_category);
                        if ($group->id == $level_id[$i]) {
                            $name_categories_reporting[] = $levels[$i]->cat_name;
                            $categories_reporting[] = $group->c_category;
                        }
                    }
                    $lists['filter_' . $i . ''] = mosHTML::selectList($type_level[$i], 'filter_id_' . $i . '', 'class="inputbox" size="1" style="width: 100%;" ' . $javascript, 'value', 'text', $level_id[$i]);
                    //onchange="document.location.href=\''. $link_multi .'\';"
                } elseif ($i == 0) {
                    $type_level[$i][] = mosHTML::makeOption(0, ' &nbsp; ');
                    foreach ($groups as $group) {
                        $type_level[$i][] = mosHTML::makeOption($group->id, $group->c_category);
                        if ($group->id == $level_id[$i]) {
                            $name_categories_reporting[] = $levels[$i]->cat_name;
                            $categories_reporting[] = $group->c_category;
                        }
                    }
                    $lists['filter_' . $i . ''] = mosHTML::selectList($type_level[$i], 'filter_id_' . $i . '', 'class="inputbox" size="1" style="width: 100%;" ' . $javascript, 'value', 'text', $level_id[$i]);
                    //onchange="document.location.href=\''. $link_multi .'\';"
                }
            }
        }
        $reporting_header['name_categories'] = $name_categories_reporting;
        $reporting_header['categories'] = $categories_reporting;
    }
    //FLMS multicat
    $s_date_db = '';
    $start_date = $start_date == "-" ? "" : $start_date;
    $end_date = $end_date == "-" ? "" : $end_date;
    if ($start_date) {
        $start_date = JLMS_dateToDB($start_date);
        $s_date = explode('-', $start_date);
        $s_date_db = date("Y-m-d H:i:s", mktime(0, 0, 0, $s_date[1], $s_date[2], $s_date[0]));
    }
    $e_date_db = '';
    if ($end_date) {
        $end_date = JLMS_dateToDB($end_date);
        $e_date = explode('-', $end_date);
        $e_date_db = date("Y-m-d H:i:s", mktime(23, 59, 0, $e_date[1], $e_date[2], $e_date[0]));
    }
    $teacher_in_courses = $JLMS_CONFIG->get('teacher_in_courses', array());
    $parent_in_courses = array();
    $parent_in_courses = $JLMS_CONFIG->get('parent_in_courses', array());
    $courses = array_merge($teacher_in_courses, $parent_in_courses);
    //var_dump($courses);
    if (count($courses)) {
        $courses_str = implode(',', $courses);
        $JLMS_DB->setQuery('SELECT id FROM #__lms_courses WHERE id IN(' . $courses_str . ')');
        $courses = $JLMS_DB->loadResultArray();
        $g_items = array();
        $g_items[] = mosHTML::makeOption(0, _JLMS_ATT_FILTER_ALL_GROUPS);
        if ($JLMS_CONFIG->get('use_global_groups', 1)) {
            if (!count($courses)) {
                $courses = array(0);
            }
            $query = "SELECT user_id FROM #__lms_users_in_groups WHERE course_id IN (" . implode(',', $courses) . ")";
            $JLMS_DB->setQuery($query);
            $cid = $JLMS_DB->loadResultArray();
            if (!$cid) {
                $cid = array(-1);
            }
            $query = "SELECT group_id FROM #__lms_users_in_global_groups WHERE user_id IN (" . implode(',', $cid) . ")";
            $JLMS_DB->setQuery($query);
            $gid = $JLMS_DB->loadResultArray();
            if (!$gid) {
                $gid = array(-1);
            }
            $query = "SELECT distinct id AS value, ug_name AS text FROM #__lms_usergroups WHERE id IN (" . implode(',', $gid) . ") AND course_id = 0 ORDER BY text";
            //course id check just in case))
            $JLMS_DB->setQuery($query);
            $groups = $JLMS_DB->loadObjectList();
        } else {
            if (!count($courses)) {
                $courses = array(0);
            }
            $query = "SELECT distinct a.id as value, a.ug_name as text FROM #__lms_usergroups as a, #__lms_users_in_groups as b" . "\n WHERE a.course_id IN (" . implode(',', $courses) . ") AND b.group_id = a.id ORDER BY a.ug_name";
            $JLMS_DB->SetQuery($query);
            $groups = $JLMS_DB->LoadObjectList();
        }
        $g_items = array_merge($g_items, $groups);
        $link = "javascript:document.adminForm.submit();";
        $lists['filter'] = mosHTML::selectList($g_items, 'filt_group', 'class="inputbox" size="1" style="width: 100%;" onchange="' . $link . '"', 'value', 'text', $filt_group);
        $groups_reporting = array();
        foreach ($groups as $grp) {
            if ($filt_group && $grp->value == $filt_group) {
                $groups_reporting[] = $grp->text;
            }
        }
        $name_groups_reporting[] = 'Usergroup';
        $reporting_header['name_groups'] = $name_groups_reporting;
        $reporting_header['groups'] = $groups_reporting;
        //---
        $where = '';
        if ($JLMS_CONFIG->get('multicat_use', 0)) {
            //NEW MUSLTICATS
            //			$tmp_level = array();
            $last_catid = 0;
            $tmp_cats_filter = JLMS_getFilterMulticategories($last_catid);
            $catids = implode(",", $tmp_cats_filter);
            if ($last_catid && count($tmp_cats_filter)) {
                $where .= "\n AND ( cat_id IN (" . $catids . ")";
                if ($JLMS_CONFIG->get('sec_cat_use', 0)) {
                    foreach ($tmp_cats_filter as $tmp_cats_filter_one) {
                        $where .= "\n OR sec_cat LIKE '%|" . $tmp_cats_filter_one . "|%'";
                    }
                }
                $where .= "\n )";
            }
            //NEW MUSLTICATS
        }
        if (!$courses_str) {
            $courses_str = '0';
        }
        $query = "SELECT id FROM #__lms_courses WHERE id IN (" . $courses_str . ")" . $where . " ORDER BY course_name, id";
        $JLMS_DB->setQuery($query);
        $courses2 = $JLMS_DB->loadResultArray();
        $courses = $courses2;
        //---
        if ($JLMS_CONFIG->get('use_global_groups', 1) && $filt_group) {
            $query = "SELECT DISTINCT(a.id)" . "\n FROM #__users as a, #__lms_users_in_global_groups as c" . "\n WHERE a.id = c.user_id " . ($filt_group ? "\n AND c.group_id = '" . $filt_group . "'" : '');
        } else {
            $query = "SELECT DISTINCT(a.id)" . "\n FROM #__users as a, #__lms_users_in_groups as c" . "\n WHERE a.id = c.user_id AND c.course_id IN (" . $courses_str . ")" . ($filt_group ? "\n AND c.group_id = '" . $filt_group . "'" : '');
        }
        $JLMS_DB->SetQuery($query);
        $users2 = $JLMS_DB->LoadResultArray();
        require_once _JOOMLMS_FRONT_HOME . DS . "includes" . DS . "classes" . DS . "lms.pagination.php";
        $pageNav = new JLMSPageNav(count($users2), $limitstart, $limit);
        if ($JLMS_CONFIG->get('use_global_groups', 1) && $filt_group) {
            $query = "SELECT DISTINCT(a.id)" . "\n FROM #__users as a, #__lms_users_in_global_groups as c" . "\n WHERE a.id = c.user_id " . ($filt_group ? "\n AND c.group_id = '" . $filt_group . "'" : '') . "\n ORDER BY a.name " . (!$is_full ? "LIMIT {$pageNav->limitstart}, {$pageNav->limit}" : "");
        } else {
            $query = "SELECT DISTINCT(a.id)" . "\n FROM #__users as a, #__lms_users_in_groups as c" . "\n WHERE a.id = c.user_id AND c.course_id IN (" . $courses_str . ")" . ($filt_group ? "\n AND c.group_id = '" . $filt_group . "'" : '') . "\n ORDER BY a.name " . (!$is_full ? "LIMIT {$pageNav->limitstart}, {$pageNav->limit}" : "");
        }
        $JLMS_DB->SetQuery($query);
        $users = $JLMS_DB->LoadResultArray();
        //var_dump($users);
        if (count($users)) {
            // 21 May 2007
            // prepare tracking images
            // 18 August 2007 - changes (DEN) - added check for GD and FreeType support
            if ($JLMS_CONFIG->get('show_reports_images', 0)) {
                $generate_images = true;
            } else {
                $generate_images = false;
            }
            $msg = '';
            if (!function_exists('imageftbbox') || !function_exists('imagecreatetruecolor')) {
                $generate_images = false;
                $sec = false;
                if (!function_exists('imagecreatetruecolor')) {
                    $msg = 'This function requires GD 2.0.1 or later (2.0.28 or later is recommended).';
                    $sec = true;
                }
                if (!function_exists('imageftbbox')) {
                    $msg .= ($sec ? '<br />' : '') . 'This function is only available if PHP is compiled with freetype support.';
                }
            }
            // end of GD and FreeType support check
            $users_str = implode(',', $users);
            $new_image_ym_stats = new stdClass();
            if ($JLMS_CONFIG->get('temp_folder', '') && $generate_images) {
                // temp folder setup is ready.
                $img_gl_width = $JLMS_CONFIG->get('visual_set_tracking_image_base_width', 400);
                //parameter added 09.06.2007
                $img_gl_height = $JLMS_CONFIG->get('visual_set_tracking_image_base_height', 260);
                //parameter added 09.06.2007
                require_once _JOOMLMS_FRONT_HOME . "/includes/libchart/libchart.php";
                JLMS_cleanLibChartCache();
                // Year/Month statistic
                $chart = new PieChart($img_gl_width * 2, $img_gl_height + 40, false, 'no_title');
                //(700, 70 + count($img_names)*30);
                $query = "SELECT COUNT(*) as hits,c.course_name FROM #__lms_track_hits as h LEFT JOIN #__users as u ON h.user_id=u.id LEFT JOIN #__lms_courses as c ON h.course_id = c.id WHERE h.course_id IN (" . $courses_str . ") AND h.user_id IN  (" . implode(',', $users2) . ") " . ($s_date_db ? "AND h.track_time > '" . $s_date_db . "'" : "") . " " . ($e_date_db ? "AND h.track_time < '" . $e_date_db . "'" : "") . "  group by h.course_id ORDER BY hits desc LIMIT 10";
                $JLMS_DB->SetQuery($query);
                $img_names = $JLMS_DB->LoadObjectLIST();
                //var_dump($img_names);
                for ($i = 0, $n = count($img_names); $i < $n; $i++) {
                    $chart->addPoint(new Point($img_names[$i]->course_name, $img_names[$i]->hits));
                }
                $title = "Top 10 courses";
                //$title = JLMS_TR_temp_fix($title);
                $mas[0] = $title;
                $title = '';
                $chart->setTitle($title);
                $filename = time() . '_' . md5(uniqid(rand(), true)) . ".png";
                $new_image_ym_stats->filename = $filename;
                $new_image_ym_stats->width = $img_gl_width;
                $new_image_ym_stats->height = $img_gl_height;
                $new_image_ym_stats->alt = $title;
                $new_image_ym_stats->title = $mas[0];
                $chart->render($JLMS_CONFIG->get('absolute_path') . "/" . $JLMS_CONFIG->get('temp_folder', '') . "/{$filename}");
            }
            $query = "SELECT COUNT(*) as hits,h.course_id as c_id FROM #__lms_track_hits as h LEFT JOIN #__users as u ON h.user_id=u.id LEFT JOIN #__lms_courses as c ON h.course_id = c.id WHERE h.course_id IN (" . $courses_str . ") AND h.user_id IN  (" . implode(',', $users2) . ") " . ($s_date_db ? "AND h.track_time > '" . $s_date_db . "'" : "") . " " . ($e_date_db ? "AND h.track_time < '" . $e_date_db . "'" : "") . "   group by h.course_id ";
            $JLMS_DB->SetQuery($query);
            $tot_hits = $JLMS_DB->LoadObjectLIST();
            $query = "SELECT COUNT(*) as hits,h.user_id as usr_id,h.course_id as c_id FROM #__lms_track_hits as h LEFT JOIN #__users as u ON h.user_id=u.id LEFT JOIN #__lms_courses as c ON h.course_id = c.id WHERE h.course_id IN (" . $courses_str . ") AND h.user_id IN  (" . $users_str . ") " . ($s_date_db ? "AND h.track_time > '" . $s_date_db . "'" : "") . " " . ($e_date_db ? "AND h.track_time < '" . $e_date_db . "'" : "") . "   group by h.course_id,h.user_id ORDER BY h.course_id,h.user_id";
            $JLMS_DB->SetQuery($query);
            $hits = $JLMS_DB->LoadObjectLIST();
            //var_dump($hits);
            if ($view == 'csv') {
                JLMS_REP_exportCsv($hits, $tot_hits, $users, $courses, $pageNav, $lists, $levels, $filt_cat, $filt_group, $option, 1);
            } else {
                if ($view == 'xls') {
                    JLMS_REP_exportXLS($hits, $tot_hits, $users, $courses, $reporting_header);
                } else {
                    JLMS_reports_html::JLMS_sreportAccess($tot_hits, $new_image_ym_stats, $hits, $users, $courses, $pageNav, $start_date, $end_date, $lists, $levels, $filt_cat, $filt_group, $option, $is_full);
                }
            }
        }
    }
}
 *********************************************************************************************************
 */
include 'checklogin.php';
include 'opendb.php';
include 'libchart/libchart.php';
header("Content-type: image/png");
$chart = new PieChart(620, 320);
// getting total users
$sql = "SELECT DISTINCT(UserName) FROM " . $configValues['CONFIG_DB_TBL_RADCHECK'];
$res = $dbSocket->query($sql);
$totalUsers = $res->numRows();
// get total users online
$sql = "SELECT DISTINCT(UserName) FROM " . $configValues['CONFIG_DB_TBL_RADACCT'] . " WHERE (AcctStopTime is NULL OR AcctStopTime = '0000-00-00 00:00:00')";
$res = $dbSocket->query($sql);
$totalUsersOnline = $res->numRows();
if ($totalUsers != 0) {
    $totalUsersOffline = $totalUsers - $totalUsersOnline;
    if ($totalUsersOnline == 0) {
        $chart->addPoint(new Point("{$totalUsersOffline} ({$totalUsersOffline} users offline)", "{$totalUsersOffline}"));
    } else {
        $chart->addPoint(new Point("{$totalUsersOffline} ({$totalUsersOffline} users offline)", "{$totalUsersOffline}"));
        $chart->addPoint(new Point("{$totalUsersOnline} ({$totalUsersOnline} users online)", "{$totalUsersOnline}"));
    }
}
$chart->setTitle("Online users");
$chart->render();
include 'closedb.php';
?>