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

/osCommerce/OM/Core/Site/Setup/Application/Install/pages/step_3.php

http://github.com/osCommerce/oscommerce
PHP | 174 lines | 152 code | 16 blank | 6 comment | 6 complexity | 9c1a7846a59e4f80d0bb9d915f4bc53f MD5 | raw file
  1. <?php
  2. /**
  3. * osCommerce Online Merchant
  4. *
  5. * @copyright Copyright (c) 2011 osCommerce; http://www.oscommerce.com
  6. * @license BSD License; http://www.oscommerce.com/bsdlicense.txt
  7. */
  8. use osCommerce\OM\Core\DirectoryListing;
  9. use osCommerce\OM\Core\HTML;
  10. use osCommerce\OM\Core\OSCOM;
  11. ?>
  12. <div class="mainBlock">
  13. <div class="stepsBox">
  14. <ol>
  15. <li><?php echo OSCOM::getDef('box_steps_step_1'); ?></li>
  16. <li><?php echo OSCOM::getDef('box_steps_step_2'); ?></li>
  17. <li style="font-weight: bold;"><?php echo OSCOM::getDef('box_steps_step_3'); ?></li>
  18. </ol>
  19. </div>
  20. <h1><?php echo OSCOM::getDef('page_title_installation'); ?></h1>
  21. <p><?php echo OSCOM::getDef('text_installation'); ?></p>
  22. </div>
  23. <div class="contentBlock">
  24. <div class="infoPane">
  25. <h3><?php echo OSCOM::getDef('box_info_step_3_title'); ?></h3>
  26. <div class="infoPaneContents">
  27. <p><?php echo OSCOM::getDef('box_info_step_3_text'); ?></p>
  28. </div>
  29. </div>
  30. <div class="contentPane">
  31. <h2><?php echo OSCOM::getDef('page_heading_finished'); ?></h2>
  32. <?php
  33. $http_url = parse_url($_POST['HTTP_WWW_ADDRESS']);
  34. $http_server = $http_url['scheme'] . '://' . $http_url['host'];
  35. $http_dir_ws = $http_url['path'];
  36. if ( isset($http_url['port']) && !empty($http_url['port']) ) {
  37. $http_server .= ':' . $http_url['port'];
  38. }
  39. if ( substr($http_dir_ws, -1) != '/' ) {
  40. $http_dir_ws .= '/';
  41. }
  42. $http_cookie_domain = '';
  43. if ( (substr_count($http_url['host'], '.') > 1) && !filter_var($http_url['host'], FILTER_VALIDATE_IP) ) {
  44. $http_cookie_domain = $http_url['host'];
  45. }
  46. $dir_fs_document_root = OSCOM_PUBLIC_BASE_DIRECTORY;
  47. $DL_Cache = new DirectoryListing(OSCOM::BASE_DIRECTORY . 'Work/Cache');
  48. $DL_Cache->setIncludeDirectories(false);
  49. $DL_Cache->setCheckExtension('cache');
  50. foreach ( $DL_Cache->getFiles() as $files ) {
  51. @unlink($DL_Cache->getDirectory() . '/' . $files['name']);
  52. }
  53. $db_class = str_replace('_', '\\', $_POST['DB_DATABASE_CLASS']);
  54. $file_contents = <<<EOT
  55. [OSCOM]
  56. bootstrap_file = "index.php"
  57. default_site = "Shop"
  58. time_zone = "{$_POST['CFG_TIME_ZONE']}"
  59. dir_fs_public = "{$dir_fs_document_root}public/"
  60. [Admin]
  61. enable_ssl = "false"
  62. http_server = "$http_server"
  63. https_server = "$http_server"
  64. http_cookie_domain = "$http_cookie_domain"
  65. https_cookie_domain = "$http_cookie_domain"
  66. http_cookie_path = "$http_dir_ws"
  67. https_cookie_path = "$http_dir_ws"
  68. dir_ws_http_server = "$http_dir_ws"
  69. dir_ws_https_server = "$http_dir_ws"
  70. db_server = "{$_POST['DB_SERVER']}"
  71. db_server_username = "{$_POST['DB_SERVER_USERNAME']}"
  72. db_server_password = "{$_POST['DB_SERVER_PASSWORD']}"
  73. db_server_port = "{$_POST['DB_SERVER_PORT']}"
  74. db_database = "{$_POST['DB_DATABASE']}"
  75. db_driver = "$db_class"
  76. db_table_prefix = "{$_POST['DB_TABLE_PREFIX']}"
  77. db_server_persistent_connections = "false"
  78. store_sessions = "Database"
  79. [Shop]
  80. enable_ssl = "false"
  81. http_server = "$http_server"
  82. https_server = "$http_server"
  83. http_cookie_domain = "$http_cookie_domain"
  84. https_cookie_domain = "$http_cookie_domain"
  85. http_cookie_path = "$http_dir_ws"
  86. https_cookie_path = "$http_dir_ws"
  87. dir_ws_http_server = "$http_dir_ws"
  88. dir_ws_https_server = "$http_dir_ws"
  89. product_images_http_server = ""
  90. product_images_https_server = ""
  91. product_images_dir_ws_http_server = "{$http_dir_ws}public/products/"
  92. product_images_dir_ws_https_server = "{$http_dir_ws}public/products/"
  93. db_server = "{$_POST['DB_SERVER']}"
  94. db_server_username = "{$_POST['DB_SERVER_USERNAME']}"
  95. db_server_password = "{$_POST['DB_SERVER_PASSWORD']}"
  96. db_server_port = "{$_POST['DB_SERVER_PORT']}"
  97. db_database = "{$_POST['DB_DATABASE']}"
  98. db_driver = "$db_class"
  99. db_table_prefix = "{$_POST['DB_TABLE_PREFIX']}"
  100. db_server_persistent_connections = "false"
  101. store_sessions = "Database"
  102. [Setup]
  103. offline = "true"
  104. EOT;
  105. if ( is_writable(OSCOM::BASE_DIRECTORY . 'Config/settings.ini') ) {
  106. file_put_contents(OSCOM::BASE_DIRECTORY . 'Config/settings.ini', $file_contents);
  107. ?>
  108. <p><?php echo OSCOM::getDef('text_successful_installation'); ?></p>
  109. <?php
  110. } else {
  111. ?>
  112. <form name="install" action="<?php echo OSCOM::getLink(null, null, 'step=3'); ?>" method="post">
  113. <div class="noticeBox">
  114. <p><?php echo sprintf(OSCOM::getDef('error_configuration_file_not_writeable'), OSCOM::BASE_DIRECTORY . 'Config/settings.ini'); ?></p>
  115. <p align="right"><?php echo HTML::button(array('icon' => 'refresh', 'title' => OSCOM::getDef('button_retry'))); ?></p>
  116. <p><?php echo OSCOM::getDef('error_configuration_file_alternate_method'); ?></p>
  117. <?php echo HTML::textareaField('contents', $file_contents, 60, 5, 'readonly="readonly" style="width: 100%; height: 120px;"', false); ?>
  118. </div>
  119. <?php
  120. foreach ( $_POST as $key => $value ) {
  121. if ( ($key != 'x') && ($key != 'y') ) {
  122. if ( is_array($value) ) {
  123. for ( $i=0, $n=count($value); $i<$n; $i++ ) {
  124. echo HTML::hiddenField($key . '[]', $value[$i]);
  125. }
  126. } else {
  127. echo HTML::hiddenField($key, $value);
  128. }
  129. }
  130. }
  131. ?>
  132. </form>
  133. <p><?php echo OSCOM::getDef('text_go_to_shop_after_cfg_file_is_saved'); ?></p>
  134. <?php
  135. }
  136. ?>
  137. <br />
  138. <p align="center"><?php echo HTML::button(array('href' => $http_server . $http_dir_ws . 'index.php?Shop', 'icon' => 'cart', 'title' => OSCOM::getDef('button_shop'))) . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . HTML::button(array('href' => $http_server . $http_dir_ws . 'index.php?Admin', 'icon' => 'gear', 'title' => OSCOM::getDef('button_admin'))); ?></p>
  139. </div>
  140. </div>