PageRenderTime 25ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/install/installer/overview.php

http://section-cms.googlecode.com/
PHP | 247 lines | 172 code | 41 blank | 34 comment | 28 complexity | f158196e0ec9bd495fb73b4f4c6c91ba MD5 | raw file
  1. <?php
  2. /* ====================================================================
  3. *
  4. * PHP Setup Wizard
  5. *
  6. * -= FILE/SETTINGS OVERVIEW =-
  7. *
  8. * This script is intended to give an overview of what has been configured,
  9. * if all files exists, if mask files contain any of the keywords etc. In
  10. * final "deployment" of your product, this file should not be included as
  11. * this is only indented for those who are configuring the Installer
  12. *
  13. * ================================================================= */
  14. /********************************[ DO CONFIGURATION/INSTALLER EXIST ]********************************/
  15. if(!is_file('configuration.php') || !is_readable('configuration.php'))
  16. die('The configuration file <b>configuration.php</b> is either not found or is unreadable');
  17. if(!is_file('installer.php') || !is_readable('installer.php'))
  18. die('The main Installer file <b>installer.php</b> is either not found or is unreadable');
  19. /********************************[ DO CLASSES/HELPERS EXIST ]********************************/
  20. // Asset folder
  21. $assetFolder = 'assets';
  22. // Files that MUST be in Assets folder
  23. $includes = array(
  24. 'class.databases.php',
  25. 'class.htmlmaker.php',
  26. 'class.masks.php',
  27. 'helper.functions.php',
  28. 'helper.sessions.php',
  29. 'helper.adminaccount.php'
  30. );
  31. // The folder "assets" contains classes and helpers
  32. if(!is_dir($assetFolder))
  33. {
  34. echo 'The folder <b>'.$assetFolder.'</b> is not found, it contains core Installer classes and helpers:';
  35. echo '<ul>';
  36. foreach($includes as $include)
  37. echo '<li>'.$include.'</li>';
  38. echo '</ul>';
  39. die();
  40. }
  41. // Check availability of files
  42. foreach($includes as $include)
  43. {
  44. $file = $assetFolder.DIRECTORY_SEPARATOR.$include;
  45. if(!is_file($file) || !is_readable($file))
  46. {
  47. die('The file <b>'.$file.'</b> is either not found or is unreadable');
  48. }
  49. }
  50. /********************************[ ENABLED STEPS ]********************************/
  51. define('INST_RUNSCRIPT', pathinfo(__FILE__, PATHINFO_BASENAME));
  52. define('INST_BASEDIR', str_replace(INST_RUNSCRIPT, '', __FILE__));
  53. define('INST_RUNFOLDER', '');
  54. define('INST_RUNINSTALL', 'installer.php');
  55. include('configuration.php');
  56. include($assetFolder.DIRECTORY_SEPARATOR.'class.htmlmaker.php');
  57. include($assetFolder.DIRECTORY_SEPARATOR.'class.masks.php');
  58. $page = new Inst_HtmlMaker();
  59. $mask = new Inst_Masks();
  60. $page->HideDisabledSteps(false);
  61. $page->HideAutoskipSteps(false);
  62. $page->UseStepWait(false);
  63. // Get the settings for some requested step
  64. $step = (isset($_REQUEST['step'])) ? $_REQUEST['step'] : 'overview';
  65. $sett = false;
  66. if(isset($steps[$step]))
  67. $sett = $steps[$step];
  68. // If the settings are 'false', then the step is not
  69. // configured in the $steps variable - show $config overview!
  70. if($sett === false)
  71. {
  72. $page->MainTitle('Main Configuration', 'settings');
  73. $page->StartTable(2, array('class'=>'dbtests'));
  74. foreach($config as $key=>$value)
  75. {
  76. $show = GetSettingsValue($value);
  77. $page->AddTableData('<b>'.$key.'</b>', array('style'=>'text-align:right; padding-right:12px;'));
  78. $page->AddTableData('<tt>'.$show.'</tt>');
  79. }
  80. $page->EndTable();
  81. $page->Paragraph();
  82. $page->MainTitle('Installer Keywords', 'keywords');
  83. $page->StartTable(2, array('class'=>'dbtests'));
  84. foreach($keywords as $key=>$value)
  85. {
  86. if(is_array($value))
  87. {
  88. $page->AddTableData('<b>'.$key.'</b>', array('style'=>'text-align:right; padding-right:12px;'));
  89. $page->AddTableData('<span style="color:#BEBEBE">'.count($value).' keywords</span>');
  90. foreach($value as $wordkey=>$wordvalue)
  91. {
  92. $show = GetSettingsValue($wordvalue);
  93. $page->AddTableData('');
  94. if(strlen($show) > 0)
  95. $page->AddTableData('<tt>'.$wordkey.' = <b>'.$show.'</b></tt>');
  96. else $page->AddTableData('<tt>'.$wordkey.'</tt>');
  97. }
  98. }
  99. else
  100. {
  101. $show = GetSettingsValue($value);
  102. $page->AddTableData('<b>'.$key.'</b>', array('style'=>'text-align:right; padding-right:12px;'));
  103. $page->AddTableData('<tt>'.$show.'</tt>');
  104. }
  105. }
  106. $page->EndTable();
  107. }
  108. // Do some step checking
  109. else
  110. {
  111. // Show the title of the step and a "for all" icon
  112. if(isset($steps[$step]['title']))
  113. $title = $steps[$step]['title'];
  114. else $title = 'Installer step';
  115. $page->MainTitle($title, 'allsteps');
  116. // Display the keys and values
  117. $page->StartTable(2, array('class'=>'dbtests'));
  118. foreach($sett as $key=>$value)
  119. {
  120. $show = GetSettingsValue($value);
  121. $page->AddTableData('<b>'.$key.'</b>', array('style'=>'text-align:right; padding-right:12px;'));
  122. $page->AddTableData('<tt>'.$show.'</tt>');
  123. }
  124. $page->EndTable();
  125. // Make sure this mask file exists!
  126. if(isset($sett['maskname']))
  127. {
  128. if($mask->DoesMaskExistAndIsReadable($sett['maskname']))
  129. {
  130. $page->SuccessBox('The mask file <b>'.$sett['maskname'].'</b> exists and is readable');
  131. // The mask is checked for few things
  132. $maskContent = $mask->GetMask($sett['maskname'], false);
  133. // Get if ANY keyword is found in the mask
  134. $counts = $mask->GetReplaceKeywordCount($maskContent);
  135. if(is_array($counts) && count($counts) > 0)
  136. {
  137. $str = '';
  138. foreach($counts as $word=>$count)
  139. $str .= "\n".'<br /><tt><b>'.$keywords['open_bracket'].$word.$keywords['close_bracket'].'</b></tt> = <b>'.$count.'</b>';
  140. $page->SuccessBox('The mask file contains the following keywords:'.$str);
  141. }
  142. else
  143. {
  144. $page->InfoBox('This mask file does not contain any keywords to replace.');
  145. }
  146. // Check if there is SEPARATOR KEYWORD in the sql file
  147. $ext = $mask->GetMaskExtension($sett['maskname'], true);
  148. if($ext == 'sql')
  149. {
  150. $counts = $mask->GetSqlSeparatorCount($maskContent);
  151. if($counts > 0)
  152. {
  153. $page->SuccessBox('The SQL mask has <b>'.$counts.'</b> occurences of the <i>SQL Query Separator</i>');
  154. }
  155. else
  156. {
  157. $page->WarningBox('There is no occurence of the <i>SQL Query Separator</i>! If your "Installation SQL Script" contains '.
  158. 'more than one query, <b>the installation will fail!</b> <br />&nbsp;<br />'.
  159. 'PHP does not support multiple queries, unless <tt>mysqli</tt> is used. Because we cannot be certain '.
  160. 'that <tt>mysqli</tt> will be installed, the Installer does not support that extension, but rather '.
  161. 'requires that the <tt>'.$keywords['next_query'].'</tt> separator is placed in between all queries.');
  162. }
  163. }
  164. }
  165. else
  166. $page->WarningBox('The mask file <b>'.$sett['maskname'].'</b> does not exists, make sure filenames are correct!');
  167. }
  168. }
  169. // Create a new array with the configuration overview as first element
  170. // and copy the rest of the $steps array into the new array
  171. $newSteps = array(STEP_SETTOVERVIEW => array('title'=>'Configuration Overview'));
  172. foreach($steps as $key=>$value)
  173. $newSteps[$key] = $value;
  174. // Clear the original steps and update with the modified version
  175. $steps = array();
  176. $steps = $newSteps;
  177. if(!isset($steps[$step]))
  178. $step = STEP_SETTOVERVIEW;
  179. // Show the page with the modified steps array
  180. $page->ShowPage($step, true, true, 'Installation Overview');
  181. //=================================[ Functions used in Overview Script ]=================================//
  182. function GetSettingsValue($value)
  183. {
  184. $show = '';
  185. if(is_array($value))
  186. {
  187. if(count($value) == 0)
  188. $show = '<i style="color:#9A9A9A;">*empty*</i>';
  189. else
  190. {
  191. foreach($value as $item)
  192. $show .= $item.', ';
  193. $show = substr($show, 0, strlen($show)-2);
  194. }
  195. }
  196. else
  197. {
  198. if($value === true)
  199. $show = '<span style="color:#0000FF">true</span>';
  200. else if($value === false)
  201. $show = '<span style="color:#FF0000">false</span>';
  202. else
  203. $show = htmlentities($value);
  204. }
  205. return $show;
  206. }