PHP Classes

File: app/api/numerOfUsersPerMonth.php

Recommend this page to a friend!
  Classes of Faris AL-Otabi   PHP IP Logger   app/api/numerOfUsersPerMonth.php   Download  
File: app/api/numerOfUsersPerMonth.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP IP Logger
Track user IP addresses that access certain pages
Author: By
Last change:
Date: 1 year ago
Size: 908 bytes
 

Contents

Class file image Download
<?php

header
("Content-Type: application/json");
require_once
'../config/config.php';

$database = new Framework\Database($config);

$utils = new Framework\Utils();

$clients = new Framework\Client($database, $utils);

$arrays = [];
$date = [];
$count = [];

if (
$clients->countClients() > 0) {
    foreach (
$clients->selectInfoFromClients('created_at') as $dd) {
       
array_push($date, $dd->created_at);
    }

    foreach (
$date as $d) {
       
array_push(
           
$arrays,
            [
               
"label" => date("Y/m/d", strtotime($d)),
               
"data" => $clients->countClientsByCond("created_at", $d)
            ]
        );
    }

    foreach (
$arrays as $c) {
        if (!
$utils->findKeyValue($count, "label", $c['label'])) {
           
array_push($count, $c);
        }
    }
} else {
   
array_push($count, ["label" => "Nothing", "data" => 0]);
}

echo
json_encode($count);