diff --git a/bin/system_info.php b/bin/system_info.php
new file mode 100644
index 0000000..8c3ae59
--- /dev/null
+++ b/bin/system_info.php
@@ -0,0 +1,176 @@
+.
+ *
+ * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
+ * California 94120-7775, or email info@knowledgetree.com.
+ *
+ * The interactive user interfaces in modified source and object code versions
+ * of this program must display Appropriate Legal Notices, as required under
+ * Section 5 of the GNU General Public License version 3.
+ *
+ * In accordance with Section 7(b) of the GNU General Public License version 3,
+ * these Appropriate Legal Notices must retain the display of the "Powered by
+ * KnowledgeTree" logo and retain the original copyright notice. If the display of the
+ * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
+ * Contributor( s): ______________________________________
+ */
+
+/*
+* Script to collect system information as part of a call home mechanism, no identifying information is stored.
+*
+* 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');
+
+global $default;
+$default->log->debug('System information collection script starting...');
+
+// Get installation guid
+function getGuid()
+{
+ $guid = KTUtil::getSystemIdentifier();
+
+ if(PEAR::isError($guid)){
+ $guid = '';
+ }
+ return $guid;
+}
+
+// Get the number of users in the repository
+function getUserCnt()
+{
+ $query = 'select count(*) as cnt, disabled from users where id > 0 group by disabled;';
+ $result = DBUtil::getResultArray($query);
+
+ if(empty($result) || PEAR::isError($result)){
+ return '';
+ }
+ $users = '';
+
+ foreach ($result as $row){
+ $str = '';
+ switch($row['disabled']){
+ case 0: $str = 'Enabled'; break;
+ case 1: $str = 'Disabled'; break;
+ case 2: $str = 'Deleted'; break;
+ }
+
+ $str .= ': '.$row['cnt'];
+
+ $users .= (!empty($users)) ? '; ' : '';
+ $users .= $str;
+ }
+ return $users;
+}
+
+// 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;';
+ $result2 = DBUtil::getResultArray($query);
+
+ if(empty($result2) || PEAR::isError($result2)){
+ return '';
+ }
+ $docs = '';
+
+ foreach ($result2 as $row){
+ $docs .= (!empty($docs)) ? '; ' : '';
+ $docs .= $row['name'].': '.$row['cnt'];
+ }
+ return $docs;
+}
+
+// Get the version of KT
+function getKTVersion()
+{
+ $version = KTUtil::getSystemSetting('knowledgeTreeVersion');
+ if(empty($version) || PEAR::isError($version)){
+ $version = file_get_contents(KT_DIR . 'docs/VERSION.txt');
+ }
+ // remove newline that is in the version file
+ $version = str_replace("\n", '', $version);
+ return $version;
+}
+
+// Get the edition of KT
+function getKTEdition()
+{
+ $edition = 'Community';
+ if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
+ $path = KTPluginUtil::getPluginPath('ktdms.wintools');
+ require_once($path . 'baobabkeyutil.inc.php');
+ $edition = BaobabKeyUtil::getName();
+
+ // Remove the brackets around the name
+ $edition = substr($edition, 1);
+ $edition = substr($edition, 0, strlen($edition)-1);
+ }
+ return $edition;
+}
+
+
+// Get OS info - platform, version, linux flavour
+function getOSInfo()
+{
+ $server = php_uname();
+
+ if(strpos($server, 'Darwin') !== false){
+ $os = 'Mac OS X';
+ }else if(strpos($server, 'Win') !== false){
+ $os = 'Windows';
+ }else {
+ $os = 'Linux';
+ }
+
+ return $os;
+}
+
+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);
+ curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
+ curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, false);
+ curl_setopt($ch, CURLOPT_POST, true);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+ curl_exec($ch);
+ curl_close($ch);
+}
+
+$post_str = getGuid() .'|'. getUserCnt() .'|'. getDocCnt() .'|'. getKTVersion() .'|'. getKTEdition() .'|'. getOSInfo();
+$data['system_info'] = $post_str;
+
+sendForm($data);
+
+$default->log->debug('System information collection script finishing.');
+exit(0);
+?>
diff --git a/setup/wizard/config/config.xml b/setup/wizard/config/config.xml
index dfc3e7d..8f7f9e3 100644
--- a/setup/wizard/config/config.xml
+++ b/setup/wizard/config/config.xml
@@ -17,7 +17,7 @@
servicesdatabaseregistration
- install
+ installcomplete
\ No newline at end of file
diff --git a/setup/wizard/installUtil.php b/setup/wizard/installUtil.php
index 3df47c2..55e029d 100644
--- a/setup/wizard/installUtil.php
+++ b/setup/wizard/installUtil.php
@@ -39,8 +39,8 @@
* @package Installer
* @version Version 0.1
*/
-class InstallUtil {
-
+class InstallUtil {
+
private $salt = 'installers';
/**
* Constructs installation object
@@ -50,7 +50,7 @@ class InstallUtil {
*/
public function __construct() {
}
-
+
/**
* Check if system needs to be installed
*
@@ -64,7 +64,7 @@ class InstallUtil {
return true;
}
-
+
return false;
}
@@ -100,13 +100,13 @@ class InstallUtil {
/**
* Redirect
- *
+ *
* This function redirects the client. This is done by issuing
* a "Location" header and exiting if wanted. If you set $rfc2616 to true
* HTTP will output a hypertext note with the location of the redirect.
- *
- * @static
- * @access public
+ *
+ * @static
+ * @access public
* have already been sent.
* @param string $url URL where the redirect should go to.
* @param bool $exit Whether to exit immediately after redirection.
@@ -119,10 +119,10 @@ class InstallUtil {
if (headers_sent()) {
return false;
}
-
+
$url = $this->absoluteURI($url);
header('Location: '. $url);
-
+
if ( $rfc2616 && isset($_SERVER['REQUEST_METHOD']) &&
$_SERVER['REQUEST_METHOD'] != 'HEAD') {
printf('Redirecting to: %s.', $url, $url);
@@ -135,21 +135,21 @@ class InstallUtil {
/**
* Absolute URI
- *
+ *
* This function returns the absolute URI for the partial URL passed.
* The current scheme (HTTP/HTTPS), host server, port, current script
* location are used if necessary to resolve any relative URLs.
- *
+ *
* Offsets potentially created by PATH_INFO are taken care of to resolve
* relative URLs to the current script.
- *
- * You can choose a new protocol while resolving the URI. This is
- * particularly useful when redirecting a web browser using relative URIs
+ *
+ * You can choose a new protocol while resolving the URI. This is
+ * particularly useful when redirecting a web browser using relative URIs
* and to switch from HTTP to HTTPS, or vice-versa, at the same time.
- *
- * @author Philippe Jausions
- * @static
- * @access public
+ *
+ * @author Philippe Jausions
+ * @static
+ * @access public
* @param string $url Absolute or relative URI the redirect should go to.
* @param string $protocol Protocol to use when redirecting URIs.
* @param integer $port A new port number.
@@ -159,7 +159,7 @@ class InstallUtil {
{
// filter CR/LF
$url = str_replace(array("\r", "\n"), ' ', $url);
-
+
// Mess around with already absolute URIs
if (preg_match('!^([a-z0-9]+)://!i', $url)) {
if (empty($protocol) && empty($port)) {
@@ -169,12 +169,12 @@ class InstallUtil {
$url = $protocol .':'. end($array = explode(':', $url, 2));
}
if (!empty($port)) {
- $url = preg_replace('!^(([a-z0-9]+)://[^/:]+)(:[\d]+)?!i',
+ $url = preg_replace('!^(([a-z0-9]+)://[^/:]+)(:[\d]+)?!i',
'\1:'. $port, $url);
}
return $url;
}
-
+
$host = 'localhost';
if (!empty($_SERVER['HTTP_HOST'])) {
list($host) = explode(':', $_SERVER['HTTP_HOST']);
@@ -192,7 +192,7 @@ class InstallUtil {
$port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : 80;
}
}
-
+
if ($protocol == 'http' && $port == 80) {
unset($port);
}
@@ -201,31 +201,31 @@ class InstallUtil {
}
$server = $protocol .'://'. $host . (isset($port) ? ':'. $port : '');
-
+
if (!strlen($url)) {
- $url = isset($_SERVER['REQUEST_URI']) ?
+ $url = isset($_SERVER['REQUEST_URI']) ?
$_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF'];
}
-
+
if ($url{0} == '/') {
return $server . $url;
}
-
+
// Check for PATH_INFO
- if (isset($_SERVER['PATH_INFO']) && strlen($_SERVER['PATH_INFO']) &&
+ if (isset($_SERVER['PATH_INFO']) && strlen($_SERVER['PATH_INFO']) &&
$_SERVER['PHP_SELF'] != $_SERVER['PATH_INFO']) {
$path = dirname(substr($_SERVER['PHP_SELF'], 0, -strlen($_SERVER['PATH_INFO'])));
} else {
$path = dirname($_SERVER['PHP_SELF']);
}
-
+
if (substr($path = strtr($path, '\\', '/'), -1) != '/') {
$path .= '/';
}
-
+
return $server . $path . $url;
}
-
+
/**
* Check whether a given directory / file path exists and is writable
*
@@ -244,7 +244,7 @@ class InstallUtil {
}
}
-
+
/**
* Check whether a given directory / file path exists and is writable
*
@@ -258,7 +258,7 @@ class InstallUtil {
{
if(!$file)
$exist = 'Directory doesn\'t exist';
- else
+ else
$exist = 'File doesn\'t exist';
$write = 'Directory not writable';
$ret = array('class' => 'cross');
@@ -280,12 +280,12 @@ class InstallUtil {
$ret['msg'] = $exist;
return $ret;
}
- mkdir($dir, '0755');
+ mkdir($dir, 0755);
}
if(is_writable($dir)){
$ret['class'] = 'tick';
-
+
return $ret;
}
@@ -293,7 +293,7 @@ class InstallUtil {
$ret['msg'] = $write;
return $ret;
}
-
+
/**
* Change permissions on a directory helper
*
@@ -305,7 +305,7 @@ class InstallUtil {
public function canChangePermissions($folderPath) {
return $this->_chmodRecursive($folderPath, 0755);
}
-
+
/**
* Change permissions on a directory (recursive)
*
@@ -344,7 +344,7 @@ class InstallUtil {
return true;
}
}
-
+
/**
* Check if a file can be written to a folder
*
@@ -358,11 +358,11 @@ class InstallUtil {
if($fr = fwrite($fh, 'test') === false) {
return false;
}
-
+
fclose($fh);
return true;
}
-
+
/**
* Attempt using the php-java bridge
*
@@ -379,7 +379,7 @@ class InstallUtil {
}
return true;
}
-
+
/**
* Check if Zend Bridge is enabled
*
@@ -390,12 +390,12 @@ class InstallUtil {
*/
public function zendBridge() {
$mods = get_loaded_extensions();
- if(in_array('Zend Java Bridge', $mods))
+ if(in_array('Zend Java Bridge', $mods))
return true;
- else
+ else
return false;
}
-
+
/**
* Attempt java detection
*
@@ -412,7 +412,7 @@ class InstallUtil {
return 'java';
}
-
+
/**
* Attempt java detection
*
@@ -429,7 +429,7 @@ class InstallUtil {
return 'java';
}
-
+
/**
* Attempt java detection
*
@@ -451,7 +451,7 @@ class InstallUtil {
}
}
}
-
+
/**
* Check if user entered location of JRE
*
@@ -471,7 +471,7 @@ class InstallUtil {
return false;
}
}
-
+
/**
* Check if user entered location of PHP
*
@@ -491,7 +491,7 @@ class InstallUtil {
return false;
}
}
-
+
public function openOfficeSpecified() {
if(isset($_POST['soffice'])) {
if($_POST['soffice'] != '') {
@@ -503,7 +503,7 @@ class InstallUtil {
return false;
}
}
-
+
/**
* Get session data from post
*
@@ -516,10 +516,10 @@ class InstallUtil {
if(empty($_SESSION[$this->salt][$class])) {
return false;
}
-
+
return $_SESSION[$this->salt][$class];
}
-
+
/**
* Determine the location of JAVA_HOME
*
@@ -539,7 +539,7 @@ class InstallUtil {
return $response;
}
-
+
/**
* Determine the location of PHP
*
@@ -562,10 +562,10 @@ class InstallUtil {
if(file_exists(PHP_DIR."php")) {
return PHP_DIR."php";
}
-
+
return 'php';
}
-
+
function getPhpHelper($cmd) {
$response = $this->pexec($cmd);
if(is_array($response['out'])) {
@@ -579,10 +579,10 @@ class InstallUtil {
}
}
}
-
- return '';
+
+ return '';
}
-
+
function getOpenOffice() {
$cmd = "whereis soffice";
$res = $this->getOpenOfficeHelper($cmd);
@@ -594,10 +594,10 @@ class InstallUtil {
if($res != '') {
return $res;
}
-
+
return 'soffice';
}
-
+
function getOpenOfficeHelper($cmd) {
$response = $this->pexec($cmd);
if(is_array($response['out'])) {
@@ -611,11 +611,11 @@ class InstallUtil {
}
}
}
-
+
return '';
}
-
-
+
+
/**
* Portably execute a command on any of the supported platforms.
*
@@ -656,9 +656,9 @@ class InstallUtil {
return $aRet;
}
-
+
/**
- *
+ *
*
* @author KnowledgeTree Team
* @access public
@@ -681,9 +681,9 @@ class InstallUtil {
}
return $mDefault;
}
-
+
/**
- *
+ *
*
* @author KnowledgeTree Team
* @access public
diff --git a/setup/wizard/steps/install.php b/setup/wizard/steps/install.php
index af4f620..bbe598f 100644
--- a/setup/wizard/steps/install.php
+++ b/setup/wizard/steps/install.php
@@ -1,6 +1,6 @@
temp_variables = array("step_name"=>"install");
}
@@ -52,12 +70,14 @@ class install extends step
return 'landing';
}
if($this->install()) {
+ $this->doRun();
return 'install';
} else if($this->previous()) {
return 'previous';
}
- return 'landing';
+ $this->doRun();
+ return 'landing';
}
public function getStepVars()
@@ -68,5 +88,41 @@ class install extends step
public function getErrors() {
return $this->error;
}
+
+ public function doRun()
+ {
+ if(isset($_POST['Install'])){
+ if(isset($_POST['call_home'])){
+ $value = $_POST['call_home'];
+ }else{
+ $value = 'disable';
+ }
+ $this->temp_variables['call_home'] = $value;
+
+ // Force a set session
+ // TODO: fix this to correctly set the session
+ $_SESSION['installers'] ['install']['call_home'] = $value;
+ }
+ }
+
+ public function installStep()
+ {
+ $conf = $this->getDataFromSession("install");
+ // retrieve database information from session
+ // initialise the db connection
+ $this->_dbhandler = new dbUtil();
+ $dbconf = $this->getDataFromSession("database");
+ $this->_dbhandler->load($dbconf['dhost'], $dbconf['duname'], $dbconf['dpassword'], $dbconf['dname']);
+
+ $complete = 1;
+ if($conf['call_home'] == 'enable'){
+ $complete = 0;
+ }
+ $query = "UPDATE scheduler_tasks SET is_complete = {$complete} WHERE task = 'Call Home'";
+ $this->_dbhandler->query($query);
+
+ // close the database connection
+ $this->_dbhandler->close();
+ }
}
?>
\ No newline at end of file
diff --git a/setup/wizard/templates/install.tpl b/setup/wizard/templates/install.tpl
index d5d22e4..d518c4b 100644
--- a/setup/wizard/templates/install.tpl
+++ b/setup/wizard/templates/install.tpl
@@ -5,9 +5,14 @@
- The wizard will now complete the installation and run a final check on the system.
+ The wizard will now complete the installation and run a final check on the system.
+
+
image('kt_browse.png'); ?>
+
+
+
+ Enable the monitoring system
-
image('dame/kt_browse.png'); ?>
diff --git a/sql/mysql/upgrade/3.7.0/call_home_task.sql b/sql/mysql/upgrade/3.7.0/call_home_task.sql
new file mode 100644
index 0000000..0ba0234
--- /dev/null
+++ b/sql/mysql/upgrade/3.7.0/call_home_task.sql
@@ -0,0 +1,2 @@
+INSERT INTO `scheduler_tasks` (task, script_url, frequency, run_time, status)
+VALUES ('Call Home','bin/system_info.php','daily','2009-10-01','system');
\ No newline at end of file