-
Notifications
You must be signed in to change notification settings - Fork 7
/
license_cache.php
73 lines (53 loc) · 1.97 KB
/
license_cache.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
#
# $Id: license_cache.php 49448 2011-10-15 00:51:45Z proche $
#
######################################################
# license_cache
# my job is to query the license server once at the start of the day
# and populate the database with the max number of licenses available
# per feature
######################################################
if ( ! is_readable('./config.php') ) {
echo("<H2>Error: Configuration file config.php does not exist. Please
notify your system administrator.</H2>");
exit;
} else
include_once('./config.php');
require_once("./common.php");
require_once("./tools.php");
###################################################
# We are using PEAR's DB abstraction library
###################################################
require_once("DB.php");
################################################################
# Connect to the database
# Use persistent connections
################################################################
$db = DB::connect($dsn, true);
if (DB::isError($db)) {
die ($db->getMessage());
}
$today = date("Y-m-d");
foreach ($server as $host) {
$master_array = getDetails($host);
$license_array = $master_array['licenses'];
foreach ($license_array as $feature=>$feature_array) {
$license_total=0;
# add up all the licenses available to each product feature
foreach ($feature_array as $key) {
$license_total += $key['num_licenses'];
}
$sql_format = 'INSERT INTO licenses_available (flmavailable_server,flmavailable_date,flmavailable_product,flmavailable_num_licenses) VALUES ("%s","%s","%s","%s")';
$sql = sprintf($sql_format,$host["hostname"],$today,$feature,$license_total);
if ( isset($debug) && $debug == 1 ) {
print_sql ($sql);
}
$recordset = $db->query($sql);
if (DB::isError($recordset)) {
die ($recordset->getMessage());
}
}
}
$db->disconnect();
?>