* 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 graph extension procduces a query of the overall logins 
 *
 * Authors:	Liran Tal <*****@*****.**>
 *
 *********************************************************************************************************
 */
include 'checklogin.php';
$type = $_REQUEST['type'];
if ($type == "daily") {
    daily();
} elseif ($type == "monthly") {
    monthly();
} elseif ($type == "yearly") {
    yearly();
}
function daily()
{
    include 'opendb.php';
    include 'libchart/libchart.php';
    header("Content-type: image/png");
    $chart = new VerticalChart(680, 500);
    $sql = "SELECT count(AcctStartTime), DAY(AcctStartTime) AS Day from " . $configValues['CONFIG_DB_TBL_RADACCT'] . " group by Day;";
    $res = $dbSocket->query($sql);
    while ($row = $res->fetchRow()) {
        $chart->addPoint(new Point("{$row['1']}", "{$row['0']}"));
$type = $_REQUEST['type'];
$username = $_REQUEST['user'];
$size = $_REQUEST['size'];
switch ($size) {
    case "gigabytes":
        $sizeDivision = "1073741824";
        break;
    case "megabytes":
        $sizeDivision = "1048576";
        break;
    default:
        $sizeDivision = "1048576";
        break;
}
if ($type == "daily") {
    daily($username);
} elseif ($type == "monthly") {
    monthly($username);
} elseif ($type == "yearly") {
    yearly($username);
}
function daily($username)
{
    global $sizeDivision;
    global $size;
    include 'opendb.php';
    include 'libchart/libchart.php';
    $username = $dbSocket->escapeSimple($username);
    header("Content-type: image/png");
    $chart = new VerticalChart(680, 500);
    $sql = "SELECT UserName, sum(AcctInputOctets) as Uploads, day(AcctStartTime) AS day FROM " . $configValues['CONFIG_DB_TBL_RADACCT'] . " WHERE username='******' AND acctstoptime>0 AND AcctStartTime>DATE_SUB(curdate(),INTERVAL (DAY(curdate())+30) DAY) AND AcctStartTime< now() GROUP BY day;";
 * of the License, or (at your option) any later version.
 *
 * 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 graph extension procduces a query of the alltime logins made by all users on a daily, monthly and yearly basis.
 *
 * Authors:	Liran Tal <*****@*****.**>
 *
 *********************************************************************************************************
 */
if ($type == "daily") {
    daily($orderBy, $orderType);
} elseif ($type == "monthly") {
    monthly($orderBy, $orderType);
} elseif ($type == "yearly") {
    yearly($orderBy, $orderType);
}
function daily($orderBy, $orderType)
{
    include 'opendb.php';
    $sql = "SELECT count(username) AS numberoflogins, day(AcctStartTime) AS day from " . $configValues['CONFIG_DB_TBL_RADACCT'] . " GROUP BY day ORDER BY {$orderBy} {$orderType};";
    $res = $dbSocket->query($sql);
    $total_logins = 0;
    // initialize variables
    $count = 0;
    $array_logins = array();
    $array_days = array();
 * of the License, or (at your option) any later version.
 *
 * 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 graph extension procduces a query of the alltime downloads made by all users on a daily, monthly and yearly basis.
 *
 * Authors:	Liran Tal <*****@*****.**>
 *
 *********************************************************************************************************
 */
if ($type == "daily") {
    daily($username, $orderBy, $orderType);
} elseif ($type == "monthly") {
    monthly($username, $orderBy, $orderType);
} elseif ($type == "yearly") {
    yearly($username, $orderBy, $orderType);
}
function daily($username, $orderBy, $orderType)
{
    include 'opendb.php';
    $sql = "SELECT sum(AcctOutputOctets) as Downloads, day(AcctStartTime) AS day, UserName from " . $configValues['CONFIG_DB_TBL_RADACCT'] . " where UserName='******' AND acctstoptime>0 AND AcctStartTime>DATE_SUB(curdate(),INTERVAL (DAY(curdate())-1) DAY) AND AcctStartTime< now() group by day ORDER BY {$orderBy} {$orderType};";
    $res = $dbSocket->query($sql);
    $total_downloads = 0;
    // initialize variables
    $count = 0;
    $array_downloads = array();
    $array_days = array();
예제 #5
0
파일: json.php 프로젝트: patmtp35/Teleinfo
function main()
{
    global $db_connect;
    $query = isset($_GET['query']) ? $_GET['query'] : "daily";
    if (isset($query)) {
        mysql_connect($db_connect['serveur'], $db_connect['login'], $db_connect['pass']) or die("Erreur de connexion au serveur MySql");
        mysql_select_db($db_connect['base']) or die("Erreur de connexion a la base de donnees {$base}");
        mysql_query("SET NAMES 'utf8'");
        mysql_query("SET lc_time_names = 'fr_FR'");
        // Pour afficher date en français dans MySql.
        switch ($query) {
            case "instantly":
                $data = instantly();
                break;
            case "daily":
                $data = daily();
                break;
            case "history":
                $data = history();
                break;
            default:
                break;
        }
        mysql_close();
        echo json_encode($data);
    }
}