diff --git a/CHANGELOG.md b/CHANGELOG.md index 22a2b576e0fe7d4e6d1e22892a8eb3775b04159a..590a863adc4555189e2f3f0c1988ac450c13234c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ All notable changes to this project will be documented in this file. [Changed] - Storing entityIds instead of SpName/IdPName. +[Fixed] +- Used only tabs for indentations + ## [v1.2.1] [Fixed] - Fixed the problem with getting utf8 chars from database diff --git a/config-templates/module_statisticsproxy.php b/config-templates/module_statisticsproxy.php index ccf5d3b9f260f11b107ffda6fc39c4477be16db8..01e21b92a7252b65983f20a14cf2efdcf621c3d4 100644 --- a/config-templates/module_statisticsproxy.php +++ b/config-templates/module_statisticsproxy.php @@ -8,82 +8,82 @@ $config = array( - /* - * Fill the serverName - */ - 'serverName' => 'localhost', - - /* - * If you want to use the default port, please comment option 'port' - */ - 'port' => 3306, - - /* - * Fill the user name - */ - 'userName' => 'stats', - - /* - * Fill the password - */ - 'password' => 'stats', - - /* - * Fill the database name - */ - 'databaseName' => 'STATS', - - /* - * Fill the table name for identityProviders - */ - 'identityProvidersTableName' => 'identityProviders', - - /* - * Fill the table name for identityProvidersMap - */ - 'identityProvidersMapTableName' => 'identityProvidersMap', - - /* - * Fill the table name for serviceProviders - */ - 'serviceProvidersTableName' => 'serviceProviders', - - /* - * Fill the table name for serviceProviders - */ - 'serviceProvidersMapTableName' => 'serviceProvidersMap', - - /* - * Fill true, if you want to use encryption, false if not. - */ - 'encryption' => true/false, - - /* - * The path name to the certificate authority file. - * - * If you use encryption, you must fill this option. - */ - 'ssl_ca' => '/example/ca.pem', - - /* - * The path name to the certificate file. - * - * If you use encryption, you must fill this option. - */ - 'ssl_cert_path' => '/example/cert.pem', - - /* - * The path name to the key file. - * - * If you use encryption, you must fill this option. - */ - 'ssl_key_path' => '/example/key.pem', - - /* - * The pathname to a directory that contains trusted SSL CA certificates in PEM format. - * - * If you use encryption, you must fill this option. - */ - 'ssl_ca_path' => '/etc/ssl', + /* + * Fill the serverName + */ + 'serverName' => 'localhost', + + /* + * If you want to use the default port, please comment option 'port' + */ + 'port' => 3306, + + /* + * Fill the user name + */ + 'userName' => 'stats', + + /* + * Fill the password + */ + 'password' => 'stats', + + /* + * Fill the database name + */ + 'databaseName' => 'STATS', + + /* + * Fill the table name for identityProviders + */ + 'identityProvidersTableName' => 'identityProviders', + + /* + * Fill the table name for identityProvidersMap + */ + 'identityProvidersMapTableName' => 'identityProvidersMap', + + /* + * Fill the table name for serviceProviders + */ + 'serviceProvidersTableName' => 'serviceProviders', + + /* + * Fill the table name for serviceProviders + */ + 'serviceProvidersMapTableName' => 'serviceProvidersMap', + + /* + * Fill true, if you want to use encryption, false if not. + */ + 'encryption' => true/false, + + /* + * The path name to the certificate authority file. + * + * If you use encryption, you must fill this option. + */ + 'ssl_ca' => '/example/ca.pem', + + /* + * The path name to the certificate file. + * + * If you use encryption, you must fill this option. + */ + 'ssl_cert_path' => '/example/cert.pem', + + /* + * The path name to the key file. + * + * If you use encryption, you must fill this option. + */ + 'ssl_key_path' => '/example/key.pem', + + /* + * The pathname to a directory that contains trusted SSL CA certificates in PEM format. + * + * If you use encryption, you must fill this option. + */ + 'ssl_ca_path' => '/etc/ssl', ); diff --git a/lib/Auth/Process/DatabaseCommand.php b/lib/Auth/Process/DatabaseCommand.php index 1ac500be511a25c6b53eef793d011c7e60c074d2..be24b1a943b23e6fac9a798d4b7ff7eac1901293 100644 --- a/lib/Auth/Process/DatabaseCommand.php +++ b/lib/Auth/Process/DatabaseCommand.php @@ -7,217 +7,217 @@ include ("DatabaseConnector.php"); class DatabaseCommand { - public static function insertLogin(&$request, &$date) - { - $databaseConnector = new DatabaseConnector(); - $conn = $databaseConnector->getConnection(); - assert($conn != NULL); - $identityProvidersTableName = $databaseConnector->getIdentityProvidersTableName(); - $identityProvidersMapTableName = $databaseConnector->getIdentityProvidersMapTableName(); - $serviceProvidersTableName = $databaseConnector->getServiceProvidersTableName(); - $serviceProvidersMapTableName = $databaseConnector->getServiceProvidersMapTableName(); - $idpEntityID = $request['saml:sp:IdP']; - $idpName = $request['Attributes']['sourceIdPName'][0]; - $spEntityId = $request['Destination']['entityid']; - $spName = $request['Destination']['name']['en']; - $year = $date->format('Y'); - $month = $date->format('m'); - $day = $date->format('d'); + public static function insertLogin(&$request, &$date) + { + $databaseConnector = new DatabaseConnector(); + $conn = $databaseConnector->getConnection(); + assert($conn != NULL); + $identityProvidersTableName = $databaseConnector->getIdentityProvidersTableName(); + $identityProvidersMapTableName = $databaseConnector->getIdentityProvidersMapTableName(); + $serviceProvidersTableName = $databaseConnector->getServiceProvidersTableName(); + $serviceProvidersMapTableName = $databaseConnector->getServiceProvidersMapTableName(); + $idpEntityID = $request['saml:sp:IdP']; + $idpName = $request['Attributes']['sourceIdPName'][0]; + $spEntityId = $request['Destination']['entityid']; + $spName = $request['Destination']['name']['en']; + $year = $date->format('Y'); + $month = $date->format('m'); + $day = $date->format('d'); - if (is_null($idpEntityID) || empty($idpEntityID) || is_null($spEntityId) || empty($spEntityId)) { - SimpleSAML\Logger::error("Some from attribute: 'idpEntityId', 'idpName', 'spEntityId' and 'spName' is null or empty and login log wasn't inserted into the database."); - } else { - $stmt = $conn->prepare("INSERT INTO ".$identityProvidersTableName."(year, month, day, sourceIdp, count) VALUES (?, ?, ?, ?, '1') ON DUPLICATE KEY UPDATE count = count + 1"); - $stmt->bind_param("iiis", $year, $month, $day, $idpEntityID); - if ($stmt->execute() === FALSE) { - SimpleSAML\Logger::error("The login log wasn't inserted into table: " . $identityProvidersTableName . "."); - } + if (is_null($idpEntityID) || empty($idpEntityID) || is_null($spEntityId) || empty($spEntityId)) { + SimpleSAML\Logger::error("Some from attribute: 'idpEntityId', 'idpName', 'spEntityId' and 'spName' is null or empty and login log wasn't inserted into the database."); + } else { + $stmt = $conn->prepare("INSERT INTO ".$identityProvidersTableName."(year, month, day, sourceIdp, count) VALUES (?, ?, ?, ?, '1') ON DUPLICATE KEY UPDATE count = count + 1"); + $stmt->bind_param("iiis", $year, $month, $day, $idpEntityID); + if ($stmt->execute() === FALSE) { + SimpleSAML\Logger::error("The login log wasn't inserted into table: " . $identityProvidersTableName . "."); + } - $stmt = $conn->prepare("INSERT INTO ".$serviceProvidersTableName."(year, month, day, service, count) VALUES (?, ?, ?, ?, '1') ON DUPLICATE KEY UPDATE count = count + 1"); - $stmt->bind_param("iiis", $year, $month, $day, $spEntityId); - if ($stmt->execute() === FALSE) { - SimpleSAML\Logger::error("The login log wasn't inserted into into table: " . $serviceProvidersTableName . "."); - } + $stmt = $conn->prepare("INSERT INTO ".$serviceProvidersTableName."(year, month, day, service, count) VALUES (?, ?, ?, ?, '1') ON DUPLICATE KEY UPDATE count = count + 1"); + $stmt->bind_param("iiis", $year, $month, $day, $spEntityId); + if ($stmt->execute() === FALSE) { + SimpleSAML\Logger::error("The login log wasn't inserted into into table: " . $serviceProvidersTableName . "."); + } - if (is_null($idpName) || empty($idpName)) { - $stmt->prepare("INSERT INTO " . $identityProvidersMapTableName . "(entityId, name) VALUES (?, ?) ON DUPLICATE KEY UPDATE name = ?"); - $stmt->bind_param("sss", $idpEntityID, $idpName, $idpName); - $stmt->execute(); - } + if (is_null($idpName) || empty($idpName)) { + $stmt->prepare("INSERT INTO " . $identityProvidersMapTableName . "(entityId, name) VALUES (?, ?) ON DUPLICATE KEY UPDATE name = ?"); + $stmt->bind_param("sss", $idpEntityID, $idpName, $idpName); + $stmt->execute(); + } - if (is_null($spName) || empty($spName)) { - $stmt->prepare("INSERT INTO " . $serviceProvidersMapTableName . "(identifier, name) VALUES (?, ?) ON DUPLICATE KEY UPDATE name = ?"); - $stmt->bind_param("sss", $spEntityId, $spName, $spName); - $stmt->execute(); - } - } + if (is_null($spName) || empty($spName)) { + $stmt->prepare("INSERT INTO " . $serviceProvidersMapTableName . "(identifier, name) VALUES (?, ?) ON DUPLICATE KEY UPDATE name = ?"); + $stmt->bind_param("sss", $spEntityId, $spName, $spName); + $stmt->execute(); + } + } - SimpleSAML\Logger::error("The login log was successfully stored in database"); + SimpleSAML\Logger::error("The login log was successfully stored in database"); - $conn->close(); - } + $conn->close(); + } - public static function getLoginCountPerDay() - { - $databaseConnector = new DatabaseConnector(); - $conn = $databaseConnector->getConnection(); - assert($conn != NULL); - $table_name = $databaseConnector->getIdentityProvidersTableName(); - $stmt = $conn->prepare("SELECT year, month, day, SUM(count) AS count FROM ".$table_name." GROUP BY year DESC,month DESC,day DESC"); - $stmt->execute(); - $result = $stmt->get_result(); - while($row = $result->fetch_assoc()) { - echo "[new Date(".$row["year"].",". ($row["month"] - 1 ). ", ".$row["day"]."), {v:".$row["count"]."}],"; - } - $conn->close(); - } + public static function getLoginCountPerDay() + { + $databaseConnector = new DatabaseConnector(); + $conn = $databaseConnector->getConnection(); + assert($conn != NULL); + $table_name = $databaseConnector->getIdentityProvidersTableName(); + $stmt = $conn->prepare("SELECT year, month, day, SUM(count) AS count FROM ".$table_name." GROUP BY year DESC,month DESC,day DESC"); + $stmt->execute(); + $result = $stmt->get_result(); + while($row = $result->fetch_assoc()) { + echo "[new Date(".$row["year"].",". ($row["month"] - 1 ). ", ".$row["day"]."), {v:".$row["count"]."}],"; + } + $conn->close(); + } - public static function getLoginCountPerDeyPerService() - { - $databaseConnector = new DatabaseConnector(); - $conn = $databaseConnector->getConnection(); - assert($conn != NULL); - $identityProvidersTableName = $databaseConnector->getIdentityProvidersTableName(); - $identityProvidersMapTableName = $databaseConnector->getIdentityProvidersMapTableName(); - $stmt = $conn->prepare("SELECT year, month, IFNULL(name,sourceIdp) AS idPName, SUM(count) AS count FROM ".$identityProvidersTableName. " LEFT OUTER JOIN " . $identityProvidersMapTableName . " ON sourceIdp = entityId GROUP BY year, month, sourceIdp HAVING sourceIdp != '' ORDER BY year DESC, month DESC, count DESC"); - $stmt->execute(); - $result = $stmt->get_result(); - while($row = $result->fetch_assoc()) { - echo "[new Date(".$row["year"].",".($row["month"] - 1 )."),'".$row["idPName"]."', {v:".$row["count"]."}],"; - } - $conn->close(); - } + public static function getLoginCountPerDeyPerService() + { + $databaseConnector = new DatabaseConnector(); + $conn = $databaseConnector->getConnection(); + assert($conn != NULL); + $identityProvidersTableName = $databaseConnector->getIdentityProvidersTableName(); + $identityProvidersMapTableName = $databaseConnector->getIdentityProvidersMapTableName(); + $stmt = $conn->prepare("SELECT year, month, IFNULL(name,sourceIdp) AS idPName, SUM(count) AS count FROM ".$identityProvidersTableName. " LEFT OUTER JOIN " . $identityProvidersMapTableName . " ON sourceIdp = entityId GROUP BY year, month, sourceIdp HAVING sourceIdp != '' ORDER BY year DESC, month DESC, count DESC"); + $stmt->execute(); + $result = $stmt->get_result(); + while($row = $result->fetch_assoc()) { + echo "[new Date(".$row["year"].",".($row["month"] - 1 )."),'".$row["idPName"]."', {v:".$row["count"]."}],"; + } + $conn->close(); + } - public static function getAccessToServicesPerMonth() - { - $databaseConnector = new DatabaseConnector(); - $conn = $databaseConnector->getConnection(); - assert($conn != NULL); - $serviceProvidersTableName = $databaseConnector->getServiceProvidersTableName(); - $serviceProvidersMapTableName = $databaseConnector->getServiceProvidersMapTableName(); - $stmt = $conn->prepare("SELECT year, month, IFNULL(name,service) AS spName, SUM(count) AS count FROM ".$serviceProvidersTableName." LEFT OUTER JOIN " . $serviceProvidersMapTableName . " ON service = identifier GROUP BY year DESC, month DESC, service HAVING service != '' ORDER BY year DESC, month DESC, count DESC"); - $stmt->execute(); - $result = $stmt->get_result(); - while($row = $result->fetch_assoc()) { - echo "[new Date(".$row["year"].",".($row["month"] - 1 )."),'".$row["spName"]."', {v:".$row["count"]."}],"; } - $conn->close(); - } + public static function getAccessToServicesPerMonth() + { + $databaseConnector = new DatabaseConnector(); + $conn = $databaseConnector->getConnection(); + assert($conn != NULL); + $serviceProvidersTableName = $databaseConnector->getServiceProvidersTableName(); + $serviceProvidersMapTableName = $databaseConnector->getServiceProvidersMapTableName(); + $stmt = $conn->prepare("SELECT year, month, IFNULL(name,service) AS spName, SUM(count) AS count FROM ".$serviceProvidersTableName." LEFT OUTER JOIN " . $serviceProvidersMapTableName . " ON service = identifier GROUP BY year DESC, month DESC, service HAVING service != '' ORDER BY year DESC, month DESC, count DESC"); + $stmt->execute(); + $result = $stmt->get_result(); + while($row = $result->fetch_assoc()) { + echo "[new Date(".$row["year"].",".($row["month"] - 1 )."),'".$row["spName"]."', {v:".$row["count"]."}],"; } + $conn->close(); + } - public static function getCountOfAllLogins() - { - $databaseConnector = new DatabaseConnector(); - $conn = $databaseConnector->getConnection(); - assert($conn != NULL); - $table_name = $databaseConnector->getIdentityProvidersTableName(); - $stmt = $conn->prepare("SELECT SUM(count) AS count FROM " . $table_name); - $stmt->execute(); - $result = $stmt->get_result(); - while ($row = $result->fetch_assoc()) { - $count = $row["count"]; - } - $conn->close(); - if ($count === null) - { - $count = 0; - } - echo $count; - } + public static function getCountOfAllLogins() + { + $databaseConnector = new DatabaseConnector(); + $conn = $databaseConnector->getConnection(); + assert($conn != NULL); + $table_name = $databaseConnector->getIdentityProvidersTableName(); + $stmt = $conn->prepare("SELECT SUM(count) AS count FROM " . $table_name); + $stmt->execute(); + $result = $stmt->get_result(); + while ($row = $result->fetch_assoc()) { + $count = $row["count"]; + } + $conn->close(); + if ($count === null) + { + $count = 0; + } + echo $count; + } - public static function getCountOfAllLoginsForToday() - { - $count = 0; - $dateTime = new DateTime(); - $databaseConnector = new DatabaseConnector(); - $conn = $databaseConnector->getConnection(); - assert($conn != NULL); - $table_name = $databaseConnector->getIdentityProvidersTableName(); - $stmt = $conn->prepare("SELECT SUM(count) AS count FROM " . $table_name." WHERE year = ".$dateTime->format('Y')." AND month=".$dateTime->format('m')." AND day = ".$dateTime->format('d')); - $stmt->execute(); - $result = $stmt->get_result(); - while ($row = $result->fetch_assoc()) { - $count = $row["count"]; - } - $conn->close(); - if ($count === null) - { - $count = 0; - } - echo $count; - } + public static function getCountOfAllLoginsForToday() + { + $count = 0; + $dateTime = new DateTime(); + $databaseConnector = new DatabaseConnector(); + $conn = $databaseConnector->getConnection(); + assert($conn != NULL); + $table_name = $databaseConnector->getIdentityProvidersTableName(); + $stmt = $conn->prepare("SELECT SUM(count) AS count FROM " . $table_name." WHERE year = ".$dateTime->format('Y')." AND month=".$dateTime->format('m')." AND day = ".$dateTime->format('d')); + $stmt->execute(); + $result = $stmt->get_result(); + while ($row = $result->fetch_assoc()) { + $count = $row["count"]; + } + $conn->close(); + if ($count === null) + { + $count = 0; + } + echo $count; + } - public static function getAccessCountPerService() - { - $databaseConnector = new DatabaseConnector(); - $conn = $databaseConnector->getConnection(); - assert($conn != NULL); - $serviceProvidersTableName = $databaseConnector->getServiceProvidersTableName(); - $serviceProvidersMapTableName = $databaseConnector->getServiceProvidersMapTableName(); - $stmt = $conn->prepare("SELECT IFNULL(name,service) AS spName, SUM(count) AS count FROM ".$serviceProvidersTableName." LEFT OUTER JOIN " . $serviceProvidersMapTableName . " ON service = identifier GROUP BY service HAVING service != ''"); - $stmt->execute(); - $result = $stmt->get_result(); - while($row = $result->fetch_assoc()) { - echo "['".$row["spName"]."', ".$row["count"]."],"; - } - $conn->close(); - } + public static function getAccessCountPerService() + { + $databaseConnector = new DatabaseConnector(); + $conn = $databaseConnector->getConnection(); + assert($conn != NULL); + $serviceProvidersTableName = $databaseConnector->getServiceProvidersTableName(); + $serviceProvidersMapTableName = $databaseConnector->getServiceProvidersMapTableName(); + $stmt = $conn->prepare("SELECT IFNULL(name,service) AS spName, SUM(count) AS count FROM ".$serviceProvidersTableName." LEFT OUTER JOIN " . $serviceProvidersMapTableName . " ON service = identifier GROUP BY service HAVING service != ''"); + $stmt->execute(); + $result = $stmt->get_result(); + while($row = $result->fetch_assoc()) { + echo "['".$row["spName"]."', ".$row["count"]."],"; + } + $conn->close(); + } - public static function getLoginCountPerIdp() - { - $databaseConnector = new DatabaseConnector(); - $conn = $databaseConnector->getConnection(); - assert($conn != NULL); - $identityProvidersTableName = $databaseConnector->getIdentityProvidersTableName(); - $identityProvidersMapTableName = $databaseConnector->getIdentityProvidersMapTableName(); - $stmt = $conn->prepare("SELECT IFNULL(name,sourceIdp) AS idPName, SUM(count) AS count FROM ".$identityProvidersTableName. " LEFT OUTER JOIN " . $identityProvidersMapTableName . " ON sourceIdp = entityId GROUP BY sourceIdp HAVING sourceIdp != ''"); - $stmt->execute(); - $result = $stmt->get_result(); - while($row = $result->fetch_assoc()) { - echo "['".$row["idPName"]."', ".$row["count"]."],"; - } - $conn->close(); - } + public static function getLoginCountPerIdp() + { + $databaseConnector = new DatabaseConnector(); + $conn = $databaseConnector->getConnection(); + assert($conn != NULL); + $identityProvidersTableName = $databaseConnector->getIdentityProvidersTableName(); + $identityProvidersMapTableName = $databaseConnector->getIdentityProvidersMapTableName(); + $stmt = $conn->prepare("SELECT IFNULL(name,sourceIdp) AS idPName, SUM(count) AS count FROM ".$identityProvidersTableName. " LEFT OUTER JOIN " . $identityProvidersMapTableName . " ON sourceIdp = entityId GROUP BY sourceIdp HAVING sourceIdp != ''"); + $stmt->execute(); + $result = $stmt->get_result(); + while($row = $result->fetch_assoc()) { + echo "['".$row["idPName"]."', ".$row["count"]."],"; + } + $conn->close(); + } - public static function getCountOfUsedIdp() - { - $databaseConnector = new DatabaseConnector(); - $conn = $databaseConnector->getConnection(); - assert($conn != NULL); - $table_name = $databaseConnector->getIdentityProvidersTableName(); - $stmt = $conn->prepare("SELECT COUNT(*) AS count FROM (SELECT DISTINCT sourceIdp FROM ".$table_name." ) AS idps WHERE sourceIdp != ''"); - $stmt->execute(); - $result = $stmt->get_result(); - while($row = $result->fetch_assoc()) { - $count = $row["count"]; - } - $conn->close(); - if ($count === null) - { - $count = 0; - } - echo $count; - } + public static function getCountOfUsedIdp() + { + $databaseConnector = new DatabaseConnector(); + $conn = $databaseConnector->getConnection(); + assert($conn != NULL); + $table_name = $databaseConnector->getIdentityProvidersTableName(); + $stmt = $conn->prepare("SELECT COUNT(*) AS count FROM (SELECT DISTINCT sourceIdp FROM ".$table_name." ) AS idps WHERE sourceIdp != ''"); + $stmt->execute(); + $result = $stmt->get_result(); + while($row = $result->fetch_assoc()) { + $count = $row["count"]; + } + $conn->close(); + if ($count === null) + { + $count = 0; + } + echo $count; + } - public static function getCountOfAccesedServices() - { - $databaseConnector = new DatabaseConnector(); - $conn = $databaseConnector->getConnection(); - assert($conn != NULL); - $table_name = $databaseConnector->getServiceProvidersTableName(); - $stmt = $conn->prepare("SELECT COUNT(*) AS count FROM (SELECT DISTINCT service FROM ".$table_name." ) AS services WHERE service != ''"); - $stmt->execute(); - $result = $stmt->get_result(); - while($row = $result->fetch_assoc()) { - $count = $row["count"]; - } - $conn->close(); - if ($count === null) - { - $count = 0; - } - echo $count; - } + public static function getCountOfAccesedServices() + { + $databaseConnector = new DatabaseConnector(); + $conn = $databaseConnector->getConnection(); + assert($conn != NULL); + $table_name = $databaseConnector->getServiceProvidersTableName(); + $stmt = $conn->prepare("SELECT COUNT(*) AS count FROM (SELECT DISTINCT service FROM ".$table_name." ) AS services WHERE service != ''"); + $stmt->execute(); + $result = $stmt->get_result(); + while($row = $result->fetch_assoc()) { + $count = $row["count"]; + } + $conn->close(); + if ($count === null) + { + $count = 0; + } + echo $count; + } public static function getAverageLoginCountPerDay() { @@ -225,9 +225,9 @@ class DatabaseCommand $conn = $databaseConnector->getConnection(); assert($conn != NULL); $table_name = $databaseConnector->getServiceProvidersTableName(); - $stmt = $conn->prepare("SELECT AVG(count) as avg_count FROM (SELECT year, month, day, SUM(count) AS count FROM " . $table_name . " GROUP BY year,month,day ) AS average_count;"); - $stmt->execute(); - $result = $stmt->get_result(); + $stmt = $conn->prepare("SELECT AVG(count) as avg_count FROM (SELECT year, month, day, SUM(count) AS count FROM " . $table_name . " GROUP BY year,month,day ) AS average_count;"); + $stmt->execute(); + $result = $stmt->get_result(); while($row = $result->fetch_assoc()) { $avg_count = $row["avg_count"]; } @@ -245,9 +245,9 @@ class DatabaseCommand $conn = $databaseConnector->getConnection(); assert($conn != NULL); $table_name = $databaseConnector->getServiceProvidersTableName(); - $stmt = $conn->prepare("SELECT MAX(count) as max_count FROM (SELECT year, month, day, SUM(count) AS count FROM " . $table_name . " GROUP BY year,month,day ) AS maximal_count;"); - $stmt->execute(); - $result = $stmt->get_result(); + $stmt = $conn->prepare("SELECT MAX(count) as max_count FROM (SELECT year, month, day, SUM(count) AS count FROM " . $table_name . " GROUP BY year,month,day ) AS maximal_count;"); + $stmt->execute(); + $result = $stmt->get_result(); while($row = $result->fetch_assoc()) { $max_count = $row["max_count"]; } diff --git a/lib/Auth/Process/DatabaseConnector.php b/lib/Auth/Process/DatabaseConnector.php index 545037af2e456385de08e5f38d37e2a990cca49a..f73dc9afcca644f2e8ca10aa00ffb72762521890 100644 --- a/lib/Auth/Process/DatabaseConnector.php +++ b/lib/Auth/Process/DatabaseConnector.php @@ -5,97 +5,97 @@ class databaseConnector { - private $serverName; - private $port; - private $username; - private $password; - private $databaseName; - private $identityProvidersTableName; - private $identityProvidersMapTableName; - private $serviceProvidersTableName; - private $serviceProvidersMapTableName; - private $encryption; - private $sslCA; - private $sslCert; - private $sslKey; - private $sslCAPath; + private $serverName; + private $port; + private $username; + private $password; + private $databaseName; + private $identityProvidersTableName; + private $identityProvidersMapTableName; + private $serviceProvidersTableName; + private $serviceProvidersMapTableName; + private $encryption; + private $sslCA; + private $sslCert; + private $sslKey; + private $sslCAPath; - const CONFIG_FILE_NAME = 'module_statisticsproxy.php'; - const SERVER = 'serverName'; - const PORT = 'port'; - const USER = 'userName'; - const PASSWORD = 'password'; - const DATABASE = 'databaseName'; - const IDP_TABLE_NAME = 'identityProvidersTableName'; - const IDP_MAP_TABLE_NAME = 'identityProvidersMapTableName'; - const SP_TABLE_NAME = 'serviceProvidersTableName' ; - const SP_MAP_TABLE_NAME = 'serviceProvidersMapTableName'; - const ENCRYPTION = 'encryption'; - const SSL_CA = 'ssl_ca'; - const SSL_CERT = 'ssl_cert_path'; - const SSL_KEY = 'ssl_key_path'; - const SSL_CA_PATH = 'ssl_ca_path'; + const CONFIG_FILE_NAME = 'module_statisticsproxy.php'; + const SERVER = 'serverName'; + const PORT = 'port'; + const USER = 'userName'; + const PASSWORD = 'password'; + const DATABASE = 'databaseName'; + const IDP_TABLE_NAME = 'identityProvidersTableName'; + const IDP_MAP_TABLE_NAME = 'identityProvidersMapTableName'; + const SP_TABLE_NAME = 'serviceProvidersTableName' ; + const SP_MAP_TABLE_NAME = 'serviceProvidersMapTableName'; + const ENCRYPTION = 'encryption'; + const SSL_CA = 'ssl_ca'; + const SSL_CERT = 'ssl_cert_path'; + const SSL_KEY = 'ssl_key_path'; + const SSL_CA_PATH = 'ssl_ca_path'; - public function __construct () - { - $conf = SimpleSAML_Configuration::getConfig(self::CONFIG_FILE_NAME); - $this->serverName = $conf->getString(self::SERVER); - $this->port = $conf->getInteger(self::PORT, null); - $this->username = $conf->getString(self::USER); - $this->password = $conf->getString(self::PASSWORD); - $this->databaseName = $conf->getString(self::DATABASE); - $this->identityProvidersTableName = $conf->getString(self::IDP_TABLE_NAME); - $this->identityProvidersMapTableName = $conf->getString(self::IDP_MAP_TABLE_NAME); - $this->serviceProvidersTableName = $conf->getString(self::SP_TABLE_NAME); - $this->serviceProvidersMapTableName = $conf->getString(self::SP_MAP_TABLE_NAME); - $this->encryption = $conf->getBoolean(self::ENCRYPTION); - $this->sslCA = $conf->getString(self::SSL_CA); - $this->sslCert = $conf->getString(self::SSL_CERT); - $this->sslKey = $conf->getString(self::SSL_KEY); - $this->sslCAPath = $conf->getString(self::SSL_CA_PATH); - } + public function __construct () + { + $conf = SimpleSAML_Configuration::getConfig(self::CONFIG_FILE_NAME); + $this->serverName = $conf->getString(self::SERVER); + $this->port = $conf->getInteger(self::PORT, null); + $this->username = $conf->getString(self::USER); + $this->password = $conf->getString(self::PASSWORD); + $this->databaseName = $conf->getString(self::DATABASE); + $this->identityProvidersTableName = $conf->getString(self::IDP_TABLE_NAME); + $this->identityProvidersMapTableName = $conf->getString(self::IDP_MAP_TABLE_NAME); + $this->serviceProvidersTableName = $conf->getString(self::SP_TABLE_NAME); + $this->serviceProvidersMapTableName = $conf->getString(self::SP_MAP_TABLE_NAME); + $this->encryption = $conf->getBoolean(self::ENCRYPTION); + $this->sslCA = $conf->getString(self::SSL_CA); + $this->sslCert = $conf->getString(self::SSL_CERT); + $this->sslKey = $conf->getString(self::SSL_KEY); + $this->sslCAPath = $conf->getString(self::SSL_CA_PATH); + } - public function getConnection() - { - $conn = mysqli_init(); - if ($this->encryption ===true){ - SimpleSAML\Logger::debug("Getting connection with encryption."); - mysqli_ssl_set($conn, $this->sslKey,$this->sslCert, $this->sslCA, $this->sslCAPath, null); - if ($this->port === null){ - mysqli_real_connect($conn, $this->serverName, $this->username, $this->password, $this->databaseName); - } else{ - mysqli_real_connect($conn, $this->serverName, $this->username, $this->password, $this->databaseName, $this->port ); - } - } - else{ - if ($this->port === null){ - mysqli_real_connect($conn, $this->serverName, $this->username, $this->password, $this->databaseName); - } else{ - mysqli_real_connect($conn, $this->serverName, $this->username, $this->password, $this->databaseName, $this->port ); - } - } - mysqli_set_charset($conn,"utf8"); - return $conn; - } + public function getConnection() + { + $conn = mysqli_init(); + if ($this->encryption ===true){ + SimpleSAML\Logger::debug("Getting connection with encryption."); + mysqli_ssl_set($conn, $this->sslKey,$this->sslCert, $this->sslCA, $this->sslCAPath, null); + if ($this->port === null){ + mysqli_real_connect($conn, $this->serverName, $this->username, $this->password, $this->databaseName); + } else{ + mysqli_real_connect($conn, $this->serverName, $this->username, $this->password, $this->databaseName, $this->port ); + } + } + else{ + if ($this->port === null){ + mysqli_real_connect($conn, $this->serverName, $this->username, $this->password, $this->databaseName); + } else{ + mysqli_real_connect($conn, $this->serverName, $this->username, $this->password, $this->databaseName, $this->port ); + } + } + mysqli_set_charset($conn,"utf8"); + return $conn; + } - public function getIdentityProvidersTableName() - { - return $this->identityProvidersTableName; + public function getIdentityProvidersTableName() + { + return $this->identityProvidersTableName; - } + } - public function getIdentityProvidersMapTableName() - { - return $this->identityProvidersMapTableName; - } + public function getIdentityProvidersMapTableName() + { + return $this->identityProvidersMapTableName; + } - public function getServiceProvidersTableName() - { - return $this->serviceProvidersTableName; + public function getServiceProvidersTableName() + { + return $this->serviceProvidersTableName; - } + } public function getServiceProvidersMapTableName() { diff --git a/lib/Auth/Process/statistics.php b/lib/Auth/Process/statistics.php index b12404710a0a8067ad5a22a97bd5ab3069f04cdd..eff2063b61ce81349ef4708a16d60d8ddbe2e258 100644 --- a/lib/Auth/Process/statistics.php +++ b/lib/Auth/Process/statistics.php @@ -23,8 +23,8 @@ class sspmod_proxystatistics_Auth_Process_statistics extends SimpleSAML_Auth_Pro public function process(&$request) { - $dateTime = new DateTime(); - DatabaseCommand::insertLogin($request, $dateTime); + $dateTime = new DateTime(); + DatabaseCommand::insertLogin($request, $dateTime); } } \ No newline at end of file diff --git a/templates/graphs-tpl.php b/templates/graphs-tpl.php index ab94fcc628cb259dd6dc372a58db7f3f002507d9..96f9efea8928dd3e81c052db04432ec95e12979e 100644 --- a/templates/graphs-tpl.php +++ b/templates/graphs-tpl.php @@ -9,99 +9,99 @@ include dirname(__DIR__)."/lib/Auth/Process/DatabaseCommand.php"; ?> <h2><?php echo $this->t('{proxystatistics:Proxystatistics:templates/graphs_logins}'); ?></h2> <div> - <script type="text/javascript"> - google.charts.load('current', {'packages':['corechart', 'controls']}); - google.charts.setOnLoadCallback(drawChart); - - function drawChart() { - var data = google.visualization.arrayToDataTable([ - ['Date', 'Count'], - <?php DatabaseCommand::getLoginCountPerDay()?> - ]); - - var dashboard = new google.visualization.Dashboard( - document.getElementById('dashboard_div')); - - var chartRangeFilter=new google.visualization.ControlWrapper({ - 'controlType': 'ChartRangeFilter', - 'containerId': 'control_div', - 'options': { - 'filterColumnLabel': 'Date' - } - }); - - var chart = new google.visualization.ChartWrapper({ - 'chartType' : 'LineChart', - 'containerId' : 'line_div', - 'options':{ - 'title' :'<?php echo $this->t('{proxystatistics:Proxystatistics:templates/logins_day}'); ?>', - 'legend' : 'none' - } - }); - - - dashboard.bind(chartRangeFilter, chart); - dashboard.draw(data); - } - </script> - - <div id="dashboard_div" style="width: 900px; height: 600px"> - <div id="line_div" style="width: 900px; height: 550px"></div> - <div id="control_div" style="width: 900px; height: 50px"></div> - </div> + <script type="text/javascript"> + google.charts.load('current', {'packages':['corechart', 'controls']}); + google.charts.setOnLoadCallback(drawChart); + + function drawChart() { + var data = google.visualization.arrayToDataTable([ + ['Date', 'Count'], + <?php DatabaseCommand::getLoginCountPerDay()?> + ]); + + var dashboard = new google.visualization.Dashboard( + document.getElementById('dashboard_div')); + + var chartRangeFilter=new google.visualization.ControlWrapper({ + 'controlType': 'ChartRangeFilter', + 'containerId': 'control_div', + 'options': { + 'filterColumnLabel': 'Date' + } + }); + + var chart = new google.visualization.ChartWrapper({ + 'chartType' : 'LineChart', + 'containerId' : 'line_div', + 'options':{ + 'title' :'<?php echo $this->t('{proxystatistics:Proxystatistics:templates/logins_day}'); ?>', + 'legend' : 'none' + } + }); + + + dashboard.bind(chartRangeFilter, chart); + dashboard.draw(data); + } + </script> + + <div id="dashboard_div" style="width: 900px; height: 600px"> + <div id="line_div" style="width: 900px; height: 550px"></div> + <div id="control_div" style="width: 900px; height: 50px"></div> + </div> </div> <h2><?php echo $this->t('{proxystatistics:Proxystatistics:templates/graphs_id_providers}'); ?></h2> <div> - <script type="text/javascript"> - google.charts.load('current', {'packages':['corechart']}); - google.charts.setOnLoadCallback(drawChart); + <script type="text/javascript"> + google.charts.load('current', {'packages':['corechart']}); + google.charts.setOnLoadCallback(drawChart); - function drawChart() { + function drawChart() { - var data = google.visualization.arrayToDataTable([ - ['sourceIdp', 'Count'], - <?php DatabaseCommand::getLoginCountPerIdp()?> - ]); + var data = google.visualization.arrayToDataTable([ + ['sourceIdp', 'Count'], + <?php DatabaseCommand::getLoginCountPerIdp()?> + ]); - var options = { - title: '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/logins_identity}'); ?>', - pieSliceText: 'value' - }; + var options = { + title: '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/logins_identity}'); ?>', + pieSliceText: 'value' + }; - var chart = new google.visualization.PieChart(document.getElementById('piechart')); + var chart = new google.visualization.PieChart(document.getElementById('piechart')); - data.sort([{column: 1, desc: true}]); - chart.draw(data, options); - } - </script> - <div id="piechart" style="width: 900px; height: 500px;"></div> + data.sort([{column: 1, desc: true}]); + chart.draw(data, options); + } + </script> + <div id="piechart" style="width: 900px; height: 500px;"></div> </div> <h2><?php echo $this->t('{proxystatistics:Proxystatistics:templates/graphs_service_providers}'); ?></h2> <div> - <script type="text/javascript"> - google.charts.load('current', {'packages':['corechart']}); - google.charts.setOnLoadCallback(drawChart); + <script type="text/javascript"> + google.charts.load('current', {'packages':['corechart']}); + google.charts.setOnLoadCallback(drawChart); - function drawChart() { + function drawChart() { - var data = google.visualization.arrayToDataTable([ - ['service', 'Count'], - <?php DatabaseCommand::getAccessCountPerService()?> - ]); + var data = google.visualization.arrayToDataTable([ + ['service', 'Count'], + <?php DatabaseCommand::getAccessCountPerService()?> + ]); - var options = { - title: '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/logins_service}'); ?>', - pieSliceText: 'value' - }; + var options = { + title: '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/logins_service}'); ?>', + pieSliceText: 'value' + }; - var chart = new google.visualization.PieChart(document.getElementById('piechart2')); + var chart = new google.visualization.PieChart(document.getElementById('piechart2')); - data.sort([{column: 1, desc: true}]); - chart.draw(data, options); - } - </script> - <div id="piechart2" style="width: 900px; height: 500px;"></div> + data.sort([{column: 1, desc: true}]); + chart.draw(data, options); + } + </script> + <div id="piechart2" style="width: 900px; height: 500px;"></div> </div> diff --git a/templates/statistics-tpl.php b/templates/statistics-tpl.php index b5c585e78bb4dd008334c981751f7baff4705e8d..8d6cc1baf6c48217b59f76dee9683bc0f767bb7e 100644 --- a/templates/statistics-tpl.php +++ b/templates/statistics-tpl.php @@ -18,11 +18,11 @@ $(document).ready(function() { $this->includeAtTemplateBase('includes/header.php'); ?> <div id="tabdiv"> - <ul class="tabset_tabs" width="100px"> - <li><a href='summary.php'><?php echo $this->t('{proxystatistics:Proxystatistics:summary}'); ?></a></li> - <li><a href='graphs.php'><?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_graphs}'); ?></a></li> - <li><a href='tables.php'><?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_tables}'); ?></a></li> - </ul> + <ul class="tabset_tabs" width="100px"> + <li><a href='summary.php'><?php echo $this->t('{proxystatistics:Proxystatistics:summary}'); ?></a></li> + <li><a href='graphs.php'><?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_graphs}'); ?></a></li> + <li><a href='tables.php'><?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_tables}'); ?></a></li> + </ul> </div> diff --git a/templates/summary-tpl.php b/templates/summary-tpl.php index a0284ae447b6ef273cbda480cfaab85de62bc184..9368210d7cd4107a09a1a6db10157e03c09821bf 100644 --- a/templates/summary-tpl.php +++ b/templates/summary-tpl.php @@ -9,28 +9,28 @@ include dirname(__DIR__)."/lib/Auth/Process/DatabaseCommand.php"; <h2><?php echo $this->t('{proxystatistics:Proxystatistics:summary}'); ?></h2> <div id="summary" > - <script type="text/javascript"> - google.charts.load('current', {'packages':['table']}); - google.charts.setOnLoadCallback(drawTable); + <script type="text/javascript"> + google.charts.load('current', {'packages':['table']}); + google.charts.setOnLoadCallback(drawTable); - function drawTable() { - var data = new google.visualization.DataTable(); - data.addColumn('string', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/summary_name}'); ?>'); - data.addColumn('number', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/count}'); ?>'); - data.addRows([ - ['<?php echo $this->t('{proxystatistics:Proxystatistics:templates/summary_overall_logins}'); ?>', <?php DatabaseCommand::getCountOfAllLogins()?> ], - ['<?php echo $this->t('{proxystatistics:Proxystatistics:templates/summary_accessed_providers}'); ?>', <?php DatabaseCommand::getCountOfAccesedServices()?>], - ['<?php echo $this->t('{proxystatistics:Proxystatistics:templates/summary_used_identity_providers}'); ?>', <?php DatabaseCommand::getCountOfUsedIdp()?>], - ['<?php echo $this->t('{proxystatistics:Proxystatistics:templates/summary_logins_today}'); ?>', <?php DatabaseCommand::getCountOfAllLoginsForToday()?>], - ['<?php echo $this->t('{proxystatistics:Proxystatistics:templates/summary_average_logins}'); ?>', <?php DatabaseCommand::getAverageLoginCountPerDay()?>], - ['<?php echo $this->t('{proxystatistics:Proxystatistics:templates/summary_max_logins}'); ?>', <?php DatabaseCommand::getMaxLoginCountPerDay()?>] - ]); + function drawTable() { + var data = new google.visualization.DataTable(); + data.addColumn('string', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/summary_name}'); ?>'); + data.addColumn('number', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/count}'); ?>'); + data.addRows([ + ['<?php echo $this->t('{proxystatistics:Proxystatistics:templates/summary_overall_logins}'); ?>', <?php DatabaseCommand::getCountOfAllLogins()?> ], + ['<?php echo $this->t('{proxystatistics:Proxystatistics:templates/summary_accessed_providers}'); ?>', <?php DatabaseCommand::getCountOfAccesedServices()?>], + ['<?php echo $this->t('{proxystatistics:Proxystatistics:templates/summary_used_identity_providers}'); ?>', <?php DatabaseCommand::getCountOfUsedIdp()?>], + ['<?php echo $this->t('{proxystatistics:Proxystatistics:templates/summary_logins_today}'); ?>', <?php DatabaseCommand::getCountOfAllLoginsForToday()?>], + ['<?php echo $this->t('{proxystatistics:Proxystatistics:templates/summary_average_logins}'); ?>', <?php DatabaseCommand::getAverageLoginCountPerDay()?>], + ['<?php echo $this->t('{proxystatistics:Proxystatistics:templates/summary_max_logins}'); ?>', <?php DatabaseCommand::getMaxLoginCountPerDay()?>] + ]); - var table = new google.visualization.Table(document.getElementById('summaryTable')); + var table = new google.visualization.Table(document.getElementById('summaryTable')); - table.draw(data, {showRowNumber: false, width: '80%', height: '300px'}); - } - </script> + table.draw(data, {showRowNumber: false, width: '80%', height: '300px'}); + } + </script> - <div id="summaryTable" ></div> + <div id="summaryTable" ></div> </div> diff --git a/templates/tables-tpl.php b/templates/tables-tpl.php index 529f1c65d268eb73bb080ca2ee833c166a801f77..a79a348df9c134addaadd32252fd4e8025481f9f 100644 --- a/templates/tables-tpl.php +++ b/templates/tables-tpl.php @@ -8,77 +8,77 @@ include dirname(__DIR__)."/lib/Auth/Process/DatabaseCommand.php"; <link rel="stylesheet" media="screen" type="text/css" href="<?php SimpleSAML_Module::getModuleUrl('proxystatistics/statisticsproxy.css')?>" /> <h2><?php echo $this->t('{proxystatistics:Proxystatistics:templates/logins_day}'); ?></h2> <div id="tableOfAllLogin"> - <script type="text/javascript"> - google.charts.load('current', {'packages':['table']}); - google.charts.setOnLoadCallback(drawTable); + <script type="text/javascript"> + google.charts.load('current', {'packages':['table']}); + google.charts.setOnLoadCallback(drawTable); - function drawTable() { - var data = new google.visualization.DataTable(); - data.addColumn('date', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/tables_date}'); ?>'); - data.addColumn('number', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/count}'); ?>'); - data.addRows([<?php DatabaseCommand::getLoginCountPerDay()?>]); + function drawTable() { + var data = new google.visualization.DataTable(); + data.addColumn('date', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/tables_date}'); ?>'); + data.addColumn('number', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/count}'); ?>'); + data.addRows([<?php DatabaseCommand::getLoginCountPerDay()?>]); - var table = new google.visualization.Table(document.getElementById('tableOfAllLogin')); + var table = new google.visualization.Table(document.getElementById('tableOfAllLogin')); - var formatter = new google.visualization.DateFormat({pattern:"d MMMM yyyy"}); - formatter.format(data, 0); // Apply formatter to second column + var formatter = new google.visualization.DateFormat({pattern:"d MMMM yyyy"}); + formatter.format(data, 0); // Apply formatter to second column - table.draw(data, {showRowNumber: false, width: '60%', height: '300px'}); - } - </script> + table.draw(data, {showRowNumber: false, width: '60%', height: '300px'}); + } + </script> - <div id="tableOfAllLogin" ></div> + <div id="tableOfAllLogin" ></div> </div> <h2><?php echo $this->t('{proxystatistics:Proxystatistics:templates/logins_identity}'); ?></h2> <div> - <script type="text/javascript"> - google.charts.load('current', {'packages':['table']}); - google.charts.setOnLoadCallback(drawTable); + <script type="text/javascript"> + google.charts.load('current', {'packages':['table']}); + google.charts.setOnLoadCallback(drawTable); - function drawTable() { - var data = new google.visualization.DataTable(); - data.addColumn('date', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/tables_month}'); ?>'); - data.addColumn('string', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/tables_identity_provider}'); ?>'); - data.addColumn('number', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/count}'); ?>'); - data.addRows([<?php DatabaseCommand::getLoginCountPerDeyPerService()?>]); + function drawTable() { + var data = new google.visualization.DataTable(); + data.addColumn('date', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/tables_month}'); ?>'); + data.addColumn('string', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/tables_identity_provider}'); ?>'); + data.addColumn('number', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/count}'); ?>'); + data.addRows([<?php DatabaseCommand::getLoginCountPerDeyPerService()?>]); - var table = new google.visualization.Table(document.getElementById('tablePerIdP')); + var table = new google.visualization.Table(document.getElementById('tablePerIdP')); - var formatter = new google.visualization.DateFormat({pattern:"MMMM yyyy"}); - formatter.format(data, 0); // Apply formatter to second column + var formatter = new google.visualization.DateFormat({pattern:"MMMM yyyy"}); + formatter.format(data, 0); // Apply formatter to second column - table.draw(data, {showRowNumber: false, width: '100%', height: '300px'}); - } - </script> + table.draw(data, {showRowNumber: false, width: '100%', height: '300px'}); + } + </script> - <div id="tablePerIdP"></div> + <div id="tablePerIdP"></div> </div> <h2><?php echo $this->t('{proxystatistics:Proxystatistics:templates/logins_service}'); ?></h2> <div> - <script type="text/javascript"> - google.charts.load('current', {'packages':['table']}); - google.charts.setOnLoadCallback(drawTable); + <script type="text/javascript"> + google.charts.load('current', {'packages':['table']}); + google.charts.setOnLoadCallback(drawTable); - function drawTable() { - var data = new google.visualization.DataTable(); - data.addColumn('date', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/tables_month}'); ?>'); - data.addColumn('string', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/tables_service_provider}'); ?>'); - data.addColumn('number', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/count}'); ?>'); - data.addRows([<?php DatabaseCommand::getAccessToServicesPerMonth()?>]); + function drawTable() { + var data = new google.visualization.DataTable(); + data.addColumn('date', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/tables_month}'); ?>'); + data.addColumn('string', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/tables_service_provider}'); ?>'); + data.addColumn('number', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/count}'); ?>'); + data.addRows([<?php DatabaseCommand::getAccessToServicesPerMonth()?>]); - var table = new google.visualization.Table(document.getElementById('accessToServices')); + var table = new google.visualization.Table(document.getElementById('accessToServices')); - var formatter = new google.visualization.DateFormat({pattern:"MMMM yyyy"}); - formatter.format(data, 0); // Apply formatter to second column + var formatter = new google.visualization.DateFormat({pattern:"MMMM yyyy"}); + formatter.format(data, 0); // Apply formatter to second column - table.draw(data, {showRowNumber: false, width: '100%', height: '300px'}); - } - </script> + table.draw(data, {showRowNumber: false, width: '100%', height: '300px'}); + } + </script> - <div id="accessToServices"></div> + <div id="accessToServices"></div> </div>