Commit 6b3b41a877e3b57516c4ccf54bd8ee6cfda4f90b

Authored by Megan Watson
1 parent 22187144

Broke the user and document info into separate fields

PT: 1591661

Committed by: Megan Watson
Showing 1 changed file with 40 additions and 23 deletions
bin/system_info.php
... ... @@ -43,7 +43,12 @@
43 43 * The following data is collected:
44 44 * Unique installation information: installation GUID, number of users in repository, number of documents in repository,
45 45 * operating system (platform, platform version, flavor if Linux), version and edition.
  46 +
  47 +<installation guid>|<enabled user count>|<disabled user count>|<deleted user count>|
  48 +<live document count>|<deleted document count>|<archived document count>|
  49 +<KT version>|<KT edition>|<User licenses>|<OS info>
46 50 */
  51 +
47 52 chdir(realpath(dirname(__FILE__)));
48 53 require_once('../config/dmsDefaults.php');
49 54  
... ... @@ -56,7 +61,7 @@ function getGuid()
56 61 $guid = KTUtil::getSystemIdentifier();
57 62  
58 63 if(PEAR::isError($guid)){
59   - $guid = '';
  64 + $guid = '-';
60 65 }
61 66 return $guid;
62 67 }
... ... @@ -68,42 +73,43 @@ function getUserCnt()
68 73 $result = DBUtil::getResultArray($query);
69 74  
70 75 if(empty($result) || PEAR::isError($result)){
71   - return '';
  76 + return '-|-|-';
72 77 }
73   - $users = '';
  78 + $enabled = '-';
  79 + $disabled = '-';
  80 + $deleted = '-';
74 81  
75 82 foreach ($result as $row){
76   - $str = '';
77 83 switch($row['disabled']){
78   - case 0: $str = 'Enabled'; break;
79   - case 1: $str = 'Disabled'; break;
80   - case 2: $str = 'Deleted'; break;
  84 + case 0: $enabled = $row['cnt']; break;
  85 + case 1: $disabled = $row['cnt']; break;
  86 + case 2: $deleted = $row['cnt']; break;
81 87 }
82   -
83   - $str .= ': '.$row['cnt'];
84   -
85   - $users .= (!empty($users)) ? '; ' : '';
86   - $users .= $str;
87 88 }
88   - return $users;
  89 + return "{$enabled}|{$disabled}|{$deleted}";
89 90 }
90 91  
91 92 // Get the number of documents in the repository
92 93 function getDocCnt()
93 94 {
94   - $query = 'select count(*) as cnt, s.name from documents d, status_lookup s WHERE s.id = d.status_id group by d.status_id;';
  95 + $query = 'select count(*) as cnt, status_id from documents d WHERE status_id IN (1,3,4) group by d.status_id;';
95 96 $result2 = DBUtil::getResultArray($query);
96 97  
97 98 if(empty($result2) || PEAR::isError($result2)){
98   - return '';
  99 + return '-|-|-';
99 100 }
100   - $docs = '';
  101 + $live = '-';
  102 + $deleted = '-';
  103 + $archived = '-';
101 104  
102 105 foreach ($result2 as $row){
103   - $docs .= (!empty($docs)) ? '; ' : '';
104   - $docs .= $row['name'].': '.$row['cnt'];
  106 + switch($row['status_id']){
  107 + case 1: $live = $row['cnt']; break;
  108 + case 3: $deleted = $row['cnt']; break;
  109 + case 4: $archived = $row['cnt']; break;
  110 + }
105 111 }
106   - return $docs;
  112 + return "{$live}|{$deleted}|{$archived}";
107 113 }
108 114  
109 115 // Get the version of KT
... ... @@ -121,15 +127,21 @@ function getKTVersion()
121 127 // Get the edition of KT
122 128 function getKTEdition()
123 129 {
124   - $edition = 'Community';
  130 + $edition = 'Community|-';
125 131 if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
126 132 $path = KTPluginUtil::getPluginPath('ktdms.wintools');
127 133 require_once($path . 'baobabkeyutil.inc.php');
128 134 $edition = BaobabKeyUtil::getName();
129 135  
  136 + // this could be done with regular expressions...
130 137 // Remove the brackets around the name
131 138 $edition = substr($edition, 1);
132 139 $edition = substr($edition, 0, strlen($edition)-1);
  140 + // Remove the "users"
  141 + $pos = strpos($edition, 'users');
  142 + $edition = ($pos === false) ? $edition.'|-' : substr($edition, 0, $pos-1);
  143 + // Replace the , with |
  144 + $edition = str_replace(', ', '|', $edition);
133 145 }
134 146 return $edition;
135 147 }
... ... @@ -139,22 +151,27 @@ function getKTEdition()
139 151 function getOSInfo()
140 152 {
141 153 $server = php_uname();
  154 + $flavour = '';//'|-';
142 155  
143 156 if(strpos($server, 'Darwin') !== false){
144 157 $os = 'Mac OS X';
145 158 }else if(strpos($server, 'Win') !== false){
146 159 $os = 'Windows';
147   - }else {
  160 + }else if(strpos($server, 'Linux') !== false) {
  161 + // Again regular expressions would be nice...
  162 + // $pos = strpos($server, 'SMP');
  163 + // $flavour = '|'.substr($server, 6, $pos-7);
148 164 $os = 'Linux';
  165 + }else {
  166 + $os = 'Unix';
149 167 }
150 168  
151   - return $os;
  169 + return $os.$flavour;
152 170 }
153 171  
154 172 function sendForm($data)
155 173 {
156 174 $url = 'http://ktnetwork.knowledgetree.com/call_home.php';
157   - //$url = 'http://10.33.20.250/knowledgetree/call_home.php';
158 175 $data = http_build_query($data);
159 176  
160 177 $ch = curl_init($url);
... ...