From 6b3b41a877e3b57516c4ccf54bd8ee6cfda4f90b Mon Sep 17 00:00:00 2001 From: Megan Watson Date: Thu, 29 Oct 2009 17:07:22 +0200 Subject: [PATCH] Broke the user and document info into separate fields PT: 1591661 --- bin/system_info.php | 63 ++++++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/bin/system_info.php b/bin/system_info.php index 8c3ae59..e9b39d0 100644 --- a/bin/system_info.php +++ b/bin/system_info.php @@ -43,7 +43,12 @@ * The following data is collected: * Unique installation information: installation GUID, number of users in repository, number of documents in repository, * operating system (platform, platform version, flavor if Linux), version and edition. + +|||| +||| +||| */ + chdir(realpath(dirname(__FILE__))); require_once('../config/dmsDefaults.php'); @@ -56,7 +61,7 @@ function getGuid() $guid = KTUtil::getSystemIdentifier(); if(PEAR::isError($guid)){ - $guid = ''; + $guid = '-'; } return $guid; } @@ -68,42 +73,43 @@ function getUserCnt() $result = DBUtil::getResultArray($query); if(empty($result) || PEAR::isError($result)){ - return ''; + return '-|-|-'; } - $users = ''; + $enabled = '-'; + $disabled = '-'; + $deleted = '-'; foreach ($result as $row){ - $str = ''; switch($row['disabled']){ - case 0: $str = 'Enabled'; break; - case 1: $str = 'Disabled'; break; - case 2: $str = 'Deleted'; break; + case 0: $enabled = $row['cnt']; break; + case 1: $disabled = $row['cnt']; break; + case 2: $deleted = $row['cnt']; break; } - - $str .= ': '.$row['cnt']; - - $users .= (!empty($users)) ? '; ' : ''; - $users .= $str; } - return $users; + return "{$enabled}|{$disabled}|{$deleted}"; } // Get the number of documents in the repository function getDocCnt() { - $query = 'select count(*) as cnt, s.name from documents d, status_lookup s WHERE s.id = d.status_id group by d.status_id;'; + $query = 'select count(*) as cnt, status_id from documents d WHERE status_id IN (1,3,4) group by d.status_id;'; $result2 = DBUtil::getResultArray($query); if(empty($result2) || PEAR::isError($result2)){ - return ''; + return '-|-|-'; } - $docs = ''; + $live = '-'; + $deleted = '-'; + $archived = '-'; foreach ($result2 as $row){ - $docs .= (!empty($docs)) ? '; ' : ''; - $docs .= $row['name'].': '.$row['cnt']; + switch($row['status_id']){ + case 1: $live = $row['cnt']; break; + case 3: $deleted = $row['cnt']; break; + case 4: $archived = $row['cnt']; break; + } } - return $docs; + return "{$live}|{$deleted}|{$archived}"; } // Get the version of KT @@ -121,15 +127,21 @@ function getKTVersion() // Get the edition of KT function getKTEdition() { - $edition = 'Community'; + $edition = 'Community|-'; if (KTPluginUtil::pluginIsActive('ktdms.wintools')) { $path = KTPluginUtil::getPluginPath('ktdms.wintools'); require_once($path . 'baobabkeyutil.inc.php'); $edition = BaobabKeyUtil::getName(); + // this could be done with regular expressions... // Remove the brackets around the name $edition = substr($edition, 1); $edition = substr($edition, 0, strlen($edition)-1); + // Remove the "users" + $pos = strpos($edition, 'users'); + $edition = ($pos === false) ? $edition.'|-' : substr($edition, 0, $pos-1); + // Replace the , with | + $edition = str_replace(', ', '|', $edition); } return $edition; } @@ -139,22 +151,27 @@ function getKTEdition() function getOSInfo() { $server = php_uname(); + $flavour = '';//'|-'; if(strpos($server, 'Darwin') !== false){ $os = 'Mac OS X'; }else if(strpos($server, 'Win') !== false){ $os = 'Windows'; - }else { + }else if(strpos($server, 'Linux') !== false) { + // Again regular expressions would be nice... + // $pos = strpos($server, 'SMP'); + // $flavour = '|'.substr($server, 6, $pos-7); $os = 'Linux'; + }else { + $os = 'Unix'; } - return $os; + return $os.$flavour; } function sendForm($data) { $url = 'http://ktnetwork.knowledgetree.com/call_home.php'; - //$url = 'http://10.33.20.250/knowledgetree/call_home.php'; $data = http_build_query($data); $ch = curl_init($url); -- libgit2 0.21.4