PageRenderTime 69ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/install.php

https://bitbucket.org/themattreid/kontrollbase
PHP | 189 lines | 145 code | 31 blank | 13 comment | 39 complexity | bb5c201c27bec1fcb6aeeef9ec8399a4 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /**
  3. * Kontrollbase
  4. *
  5. * An open source MySQL monitoring and analytics application
  6. * ID: $Id: install.php 326 2011-04-25 21:04:18Z themattreid $
  7. * @package Kontrollbase
  8. * @author Matt Reid
  9. * @copyright Copyright (c) 2009 Matt Reid, Kontrollbase LLC
  10. * @license http://kontrollsoft.com/kontrollbase/userguide/general-LICENSE.php
  11. * @link http://kontrollbase.com
  12. */
  13. function head_d($nroot,$syspath,$w_logs,$w_includes,$w_config) {
  14. $d_logs = "$syspath/system/logs";
  15. $d_includes = "$syspath/includes";
  16. $d_config = "$syspath/system/application/config";
  17. if($w_logs == 1) { $w_logs = '<img src="includes/images/delete-icon.png" width="11" height="11">'; }
  18. else { $w_logs = '<img src="includes/images/check-red.png" width="16" height="20">'; }
  19. if($w_includes == 1) { $w_includes = '<img src="includes/images/delete-icon.png" width="11" height="11">'; }
  20. else { $w_includes = '<img src="includes/images/check-red.png" width="16" height="20">'; }
  21. if($w_config == 1) { $w_config = '<img src="includes/images/delete-icon.png" width="11" height="11">'; }
  22. else { $w_config = '<img src="includes/images/check-red.png" width="16" height="20">'; }
  23. print<<<HEAD
  24. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  25. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
  26. <head>
  27. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  28. <title>Kontrollbase 2.0.1 - MySQL Monitoring</title>
  29. <link rel="stylesheet" type="text/css" href="$nroot/includes/style.css" />
  30. <link rel="stylesheet" type="text/css" media="all" href="$nroot/userguide/css/userguide-nofluff.css" />
  31. <link rel="stylesheet" type="text/css" href="$nroot/includes/extjs/layout/layout-browser.css">
  32. <link rel="stylesheet" type="text/css" href="$nroot/includes/extjs/resources/css/ext-all.css" />
  33. <link rel="stylesheet" type="text/css" href="$nroot/includes/extjs/resources/css/xtheme-slate.css" />
  34. <script type="text/javascript" src="$nroot/includes/extjs/adapter/ext/ext-base.js"></script>
  35. <script type="text/javascript" src="$nroot/includes/extjs/ext-all-debug.js"></script>
  36. <script type='text/javascript'>
  37. Ext.onReady(function(){ Ext.Msg.alert('Installation Failure.', '<table><tr><td colspan="2">Directory Check:</td></td></tr><tr><td align="left">$d_logs</td><td align="center">$w_logs</td></tr><tr><td align="left">$d_includes</td><td align="center">$w_includes</td></tr><tr><td align="left">$d_config</td><td align="center">$w_config</td></tr><tr><td colspan="2">&nbsp;</td></tr><tr><td colspan="2">Directories must be writeable by the webserver user and group</td></tr><tr><td colspan="2">ie: $> chown -R apache:apache includes</td></tr><tr><td colspan="2">ie: $> chown -R apache:apache system/logs</td></tr><tr><td colspan="2">ie: $> chown -R apache:apache system/application/config</td></tr><tr><td colspan="2">&nbsp;</td></tr><tr><td colspan="2">Run the proper commands, then refresh this screen to continue.</td></tr></table>', function(btn, text){
  38. if (btn == 'ok'){
  39. var redirect = '$nroot/install.php';
  40. window.location = redirect;
  41. }
  42. })});
  43. </script>
  44. </head>
  45. <body>
  46. HEAD;
  47. }
  48. function head_m($nroot,$syspath,$install_sc,$install_sd) {
  49. $sysconfig="system/application/config/config.php";
  50. $sysdatabase="system/application/config/database.php";
  51. if($install_sc == 1) { $install_sc = '<img src="includes/images/delete-icon.png" width="11" height="11">'; }
  52. else { $install_sc = '<img src="includes/images/check-red.png" width="16" height="20">'; }
  53. if($install_sd == 1) { $install_sd = '<img src="includes/images/delete-icon.png" width="11" height="11">'; }
  54. else { $install_sd = '<img src="includes/images/check-red.png" width="16" height="20">'; }
  55. print<<<HEAD
  56. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  57. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
  58. <head>
  59. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  60. <title>Kontrollbase 2.0.1 - MySQL Monitoring</title>
  61. <link rel="stylesheet" type="text/css" href="$nroot/includes/style.css" />
  62. <link rel="stylesheet" type="text/css" media="all" href="$nroot/userguide/css/userguide-nofluff.css" />
  63. <link rel="stylesheet" type="text/css" href="$nroot/includes/extjs/layout/layout-browser.css">
  64. <link rel="stylesheet" type="text/css" href="$nroot/includes/extjs/resources/css/ext-all.css" />
  65. <link rel="stylesheet" type="text/css" href="$nroot/includes/extjs/resources/css/xtheme-slate.css" />
  66. <script type="text/javascript" src="$nroot/includes/extjs/adapter/ext/ext-base.js"></script>
  67. <script type="text/javascript" src="$nroot/includes/extjs/ext-all-debug.js"></script>
  68. <script type='text/javascript'>
  69. Ext.onReady(function(){
  70. Ext.Msg.alert('Installation Failure.', '<table><tr><td colspan="2">Config files check</td></tr><tr><td>$sysconfig</td><td>$install_sc</td></tr><tr><td>$sysdatabase</td><td>$install_sd</td></tr><tr><td colspan="2">Remove the config files to continue.</td></tr></table>', function(btn, text){
  71. if (btn == 'ok'){
  72. var redirect = '$nroot/install.php';
  73. window.location = redirect;
  74. }
  75. })});
  76. </script>
  77. </head>
  78. <body>
  79. HEAD;
  80. }
  81. function head_i($nroot,$syspath,$d_logs,$d_includes,$d_config) {
  82. $len = ((strlen($syspath)) + 1) ;
  83. $d_logs = substr($d_logs,$len);
  84. $d_includes = substr($d_includes,$len);
  85. $d_config = substr($d_config,$len);
  86. print<<<HEAD
  87. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  88. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
  89. <head>
  90. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  91. <title>Kontrollbase 2.0.1 - MySQL Monitoring</title>
  92. <link rel="stylesheet" type="text/css" href="$nroot/includes/style.css" />
  93. <link rel="stylesheet" type="text/css" media="all" href="$nroot/userguide/css/userguide-nofluff.css" />
  94. <link rel="stylesheet" type="text/css" href="$nroot/includes/extjs/layout/layout-browser.css">
  95. <link rel="stylesheet" type="text/css" href="$nroot/includes/extjs/resources/css/ext-all.css" />
  96. <link rel="stylesheet" type="text/css" href="$nroot/includes/extjs/resources/css/xtheme-slate.css" />
  97. <script type="text/javascript" src="$nroot/includes/extjs/adapter/ext/ext-base.js"></script>
  98. <script type="text/javascript" src="$nroot/includes/extjs/ext-all-debug.js"></script>
  99. <script type='text/javascript'>
  100. Ext.onReady(function(){
  101. Ext.Msg.alert('The Kontrollbase Installer', '<table><tr><td align="left">Config File Check</td><td align="center"><img src="includes/images/check-red.png" width="16" height="20"></td></tr><tr><td align="left">Directory $d_logs:</td><td align="center"><img src="includes/images/check-red.png" width="16" height="20"></td></tr><tr><td align="left">Directory $d_includes:</td><td align="center"><img src="includes/images/check-red.png" width="16" height="20"></td></tr><tr><td align="left">Directory $d_config:</td><td align="center"><img src="includes/images/check-red.png" width="16" height="20"></td></tr></table>', function(btn, text){
  102. if (btn == 'ok'){
  103. var redirect = '$nroot/install/overview.php';
  104. window.location = redirect;
  105. }
  106. })});
  107. </script>
  108. </head>
  109. <body>
  110. HEAD;
  111. }
  112. function dir_writeable($file) {
  113. if(is_writable($file)) {
  114. return 0;
  115. }
  116. else {
  117. return 1;
  118. }
  119. }
  120. function check_install() {
  121. $nroot = $_SERVER['PHP_SELF'];
  122. $server = $_SERVER['SERVER_NAME'];
  123. $nroot = rtrim($nroot, "/install.php");
  124. $syspath = $_SERVER['SCRIPT_FILENAME'];
  125. $syspath = rtrim($syspath, ".php");
  126. $syspath = rtrim($syspath, "/install");
  127. $sysconfig="$syspath/system/application/config/config.php";
  128. $sysdatabase="$syspath/system/application/config/database.php";
  129. // $d_cache = "$syspath/system/cache"; // might want to be checking this too...
  130. $d_logs = "$syspath/system/logs";
  131. $d_includes = "$syspath/includes";
  132. $d_config = "$syspath/system/application/config";
  133. //check to see if config files exist
  134. $install_sc = exists($sysconfig);
  135. $install_sd = exists($sysdatabase);
  136. $w_logs = dir_writeable($d_logs);
  137. $w_includes = dir_writeable($d_includes);
  138. $w_config = dir_writeable($d_config);
  139. if(($install_sc == 0) && ($install_sd == 0) && ($w_logs == 0) && ($w_includes == 0) && ($w_config == 0)) {
  140. head_i($nroot,$syspath,$d_logs,$d_includes,$d_config);
  141. }
  142. elseif(($install_sc == 1) || ($install_sd == 1)) {
  143. head_m($nroot,$syspath,$install_sc,$install_sd);
  144. }
  145. else {
  146. head_d($nroot,$syspath,$w_logs,$w_includes,$w_config);
  147. }
  148. }
  149. function exists($file) {
  150. if (file_exists($file)) {
  151. return 1;
  152. }
  153. else {
  154. return 0;
  155. }
  156. }
  157. check_install();
  158. ?>