PageRenderTime 42ms CodeModel.GetById 9ms RepoModel.GetById 1ms app.codeStats 0ms

/oc-includes/osclass/install.php

https://code.google.com/
PHP | 252 lines | 220 code | 13 blank | 19 comment | 8 complexity | d92ba6786adfd50a28e00951862eafd1 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. /*
  3. * OSCLass รข&#x20AC;&#x201C; software for creating and publishing online classified
  4. * advertising platforms
  5. *
  6. * Copyright (C) 2010 OSCLASS
  7. *
  8. * This program is free software: you can redistribute it and/or
  9. * modify it under the terms of the GNU Affero General Public License
  10. * as published by the Free Software Foundation, either version 3 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. error_reporting(E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_PARSE);
  22. define( 'ABS_PATH', dirname(dirname(dirname(__FILE__))) . '/' );
  23. define( 'LIB_PATH', ABS_PATH . 'oc-includes/' ) ;
  24. define( 'CONTENT_PATH', ABS_PATH . 'oc-content/' ) ;
  25. define( 'TRANSLATIONS_PATH', CONTENT_PATH . 'languages/' ) ;
  26. define( 'OSC_INSTALLING', 1 );
  27. require_once LIB_PATH . 'osclass/Logger/Logger.php' ;
  28. require_once LIB_PATH . 'osclass/Logger/LogDatabase.php' ;
  29. require_once LIB_PATH . 'osclass/Logger/LogOsclass.php' ;
  30. require_once LIB_PATH . 'osclass/classes/database/DBConnectionClass.php';
  31. require_once LIB_PATH . 'osclass/classes/database/DBCommandClass.php';
  32. require_once LIB_PATH . 'osclass/classes/database/DBRecordsetClass.php';
  33. require_once LIB_PATH . 'osclass/classes/database/DAO.php';
  34. require_once LIB_PATH . 'osclass/core/Session.php';
  35. require_once LIB_PATH . 'osclass/core/Params.php';
  36. require_once LIB_PATH . 'osclass/model/Preference.php';
  37. require_once LIB_PATH . 'osclass/helpers/hDatabaseInfo.php';
  38. require_once LIB_PATH . 'osclass/helpers/hDefines.php';
  39. require_once LIB_PATH . 'osclass/helpers/hErrors.php';
  40. require_once LIB_PATH . 'osclass/helpers/hLocale.php';
  41. require_once LIB_PATH . 'osclass/helpers/hPreference.php';
  42. require_once LIB_PATH . 'osclass/helpers/hSearch.php';
  43. require_once LIB_PATH . 'osclass/helpers/hPlugins.php';
  44. require_once LIB_PATH . 'osclass/helpers/hTranslations.php';
  45. require_once LIB_PATH . 'osclass/helpers/hSanitize.php';
  46. require_once LIB_PATH . 'osclass/default-constants.php';
  47. require_once LIB_PATH . 'osclass/install-functions.php';
  48. require_once LIB_PATH . 'osclass/utils.php';
  49. require_once LIB_PATH . 'osclass/core/Translation.php';
  50. require_once LIB_PATH . 'osclass/plugins.php';
  51. require_once LIB_PATH . 'osclass/locales.php';
  52. Session::newInstance()->session_start() ;
  53. $locales = osc_listLocales();
  54. if(Params::getParam('install_locale')!='') {
  55. Session::newInstance()->_set('userLocale', Params::getParam('install_locale')) ;
  56. Session::newInstance()->_set('adminLocale', Params::getParam('install_locale')) ;
  57. }
  58. if(Session::newInstance()->_get('adminLocale')!='' && key_exists(Session::newInstance()->_get('adminLocale'), $locales)) {
  59. $current_locale = Session::newInstance()->_get('adminLocale');
  60. } else if(isset($locales['en_US'])) {
  61. $current_locale = 'en_US';
  62. } else {
  63. $current_locale = key($locales);
  64. }
  65. Session::newInstance()->_set('userLocale', $current_locale);
  66. Session::newInstance()->_set('adminLocale', $current_locale);
  67. $translation = new Translation(true);
  68. $step = Params::getParam('step');
  69. if( !is_numeric($step) ) {
  70. $step = '1';
  71. }
  72. if( is_osclass_installed( ) ) {
  73. $message = __("Looks like you've already installed OSClass. To reinstall please clear your old database tables first.");
  74. osc_die('OSClass &raquo; Error', $message) ;
  75. }
  76. switch( $step ) {
  77. case 1:
  78. $requirements = get_requirements() ;
  79. $error = check_requirements($requirements) ;
  80. break;
  81. case 2:
  82. if( Params::getParam('save_stats') == '1' || isset($_COOKIE['osclass_save_stats'])) {
  83. setcookie('osclass_save_stats', 1, time() + (24*60*60) );
  84. } else {
  85. setcookie('osclass_save_stats', 0, time() + (24*60*60) );
  86. }
  87. if( Params::getParam('ping_engines') == '1' || isset($_COOKIE['osclass_ping_engines']) ) {
  88. setcookie('osclass_ping_engines', 1, time() + (24*60*60) );
  89. } else {
  90. setcookie('osclass_ping_engines', 0, time()+ (24*60*60) );
  91. }
  92. break;
  93. case 3:
  94. if( Params::getParam('dbname') != '' ) {
  95. $error = oc_install();
  96. }
  97. break;
  98. case 4:
  99. if( Params::getParam('result') != '' ) {
  100. $error = Params::getParam('result');
  101. }
  102. $password = Params::getParam('password', false, false);
  103. break;
  104. case 5:
  105. $password = Params::getParam('password', false, false);
  106. break;
  107. default:
  108. break;
  109. }
  110. ?>
  111. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  112. <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xml:lang="en-US">
  113. <head>
  114. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  115. <title><?php _e('OSClass Installation'); ?></title>
  116. <script src="<?php echo get_absolute_url(); ?>oc-includes/osclass/installer/jquery.js" type="text/javascript"></script>
  117. <script src="<?php echo get_absolute_url(); ?>oc-includes/osclass/installer/jquery-ui.js" type="text/javascript"></script>
  118. <script src="<?php echo get_absolute_url(); ?>oc-includes/osclass/installer/vtip/vtip.js" type="text/javascript"></script>
  119. <script src="<?php echo get_absolute_url(); ?>oc-includes/osclass/installer/jquery.jsonp.js" type="text/javascript"></script>
  120. <script src="<?php echo get_absolute_url(); ?>oc-includes/osclass/installer/install.js" type="text/javascript"></script>
  121. <script src="<?php echo get_absolute_url(); ?>oc-admin/themes/modern/js/location.js" type="text/javascript"></script>
  122. <link rel="stylesheet" type="text/css" media="all" href="<?php echo get_absolute_url(); ?>oc-includes/osclass/installer/install.css" />
  123. <link rel="stylesheet" type="text/css" media="all" href="<?php echo get_absolute_url(); ?>oc-includes/osclass/installer/vtip/css/vtip.css" />
  124. </head>
  125. <body>
  126. <div id="wrapper">
  127. <div id="container">
  128. <div id="header" class="installation">
  129. <h1 id="logo">
  130. <img src="<?php echo get_absolute_url(); ?>oc-includes/images/osclass-logo.png" alt="OSClass" title="OSClass" />
  131. </h1>
  132. <?php if(in_array($step, array(2,3,4))) { ?>
  133. <ul id="nav">
  134. <li class="<?php if($step == 2) { ?>actual<?php } elseif($step < 2) { ?>next<?php } else { ?>past<?php }?>">1 - Database</li>
  135. <li class="<?php if($step == 3) { ?>actual<?php } elseif($step < 3) { ?>next<?php } else { ?>past<?php }?>">2 - Target</li>
  136. <li class="<?php if($step == 4) { ?>actual<?php } elseif($step < 4) { ?>next<?php } else { ?>past<?php }?>">3 - Categories</li>
  137. </ul>
  138. <div class="clear"></div>
  139. <?php } ?>
  140. </div>
  141. <div id="content">
  142. <?php if($step == 1) { ?>
  143. <h2 class="target"><?php _e('Welcome');?></h2>
  144. <form action="install.php" method="post">
  145. <div class="form-table">
  146. <?php if( count($locales) > 1 ) { ?>
  147. <div>
  148. <label><?php _e('Choose language') ; ?></label>
  149. <select name="install_locale" id="install_locale" onchange="window.location.href='?install_locale='+document.getElementById(this.id).value">
  150. <?php foreach($locales as $k => $locale) {?>
  151. <option value="<?php echo osc_esc_html($k) ; ?>" <?php if( $k == $current_locale ) { echo 'selected="selected"' ; } ?>><?php echo $locale['name'] ; ?></option>
  152. <?php } ?>
  153. </select>
  154. </div>
  155. <?php } ?>
  156. <?php if($error) { ?>
  157. <p><?php _e('Check the next requirements:');?></p>
  158. <div class="requirements_help">
  159. <p><b><?php _e('Requirements help:'); ?></b></p>
  160. <ul>
  161. <?php foreach($requirements as $k => $v) { ?>
  162. <?php if(!$v['fn'] && $v['solution'] != ''){ ?>
  163. <li><?php echo $v['solution']; ?></li>
  164. <?php } ?>
  165. <?php } ?>
  166. <li><a href="http://forums.osclass.org/"><?php _e('Need more help?');?></a></li>
  167. </ul>
  168. </div>
  169. <?php } else { ?>
  170. <p><?php _e('All right! All the requirements have met:');?></p>
  171. <?php } ?>
  172. <ul>
  173. <?php foreach($requirements as $k => $v) { ?>
  174. <li><?php echo $v['requirement']; ?> <img src="<?php echo get_absolute_url(); ?>oc-includes/images/<?php echo $v['fn'] ? 'tick.png' : 'cross.png'; ?>" alt="" title="" /></li>
  175. <?php } ?>
  176. </ul>
  177. <div class="more-stats">
  178. <input type="checkbox" name="ping_engines" id="ping_engines" checked="checked" value="1" />
  179. <label for="ping_engines">
  180. <?php _e('Allow my site to appear in search engines like Google.');?>
  181. </label>
  182. <br />
  183. <input type="checkbox" name="save_stats" id="save_stats" checked="checked" value="1" />
  184. <input type="hidden" name="step" value="2" />
  185. <label for="save_stats">
  186. <?php _e('Help make OSClass better by automatically sending usage statistics and crash reports to OSClass.');?>
  187. </label>
  188. </div>
  189. </div>
  190. <?php if($error) { ?>
  191. <p class="margin20">
  192. <input type="button" class="button" onclick="document.location = 'install.php?step=1'" value="<?php echo osc_esc_html( __('Try again'));?>" />
  193. </p>
  194. <?php } else { ?>
  195. <p class="margin20">
  196. <input type="submit" class="button" value="<?php echo osc_esc_html( __('Run the install'));?>" />
  197. </p>
  198. <?php } ?>
  199. </form>
  200. <?php } elseif($step == 2) {
  201. display_database_config();
  202. } elseif($step == 3) {
  203. if( !isset($error["error"]) ) {
  204. display_target();
  205. } else {
  206. display_database_error($error, ($step - 1));
  207. }
  208. } elseif($step == 4) {
  209. display_categories($error, $password);
  210. } elseif($step == 5) {
  211. // ping engines
  212. ping_search_engines( $_COOKIE['osclass_ping_engines'] ) ;
  213. setcookie('osclass_save_stats', '', time() - 3600);
  214. setcookie('osclass_ping_engines', '', time() - 3600);
  215. display_finish($password);
  216. }
  217. ?>
  218. </div>
  219. <div id="footer">
  220. <ul>
  221. <li>
  222. <a href="<?php echo get_absolute_url(); ?>readme.php" target="_blank"><?php _e('Readme'); ?></a>
  223. </li>
  224. <li>
  225. <a href="http://admin.osclass.org/feedback.php" target="_blank"><?php _e('Feedback'); ?></a>
  226. </li>
  227. <li>
  228. <a href="http://forums.osclass.org/index.php" target="_blank"><?php _e('Forums');?></a>
  229. </li>
  230. </ul>
  231. </div>
  232. </div>
  233. </div>
  234. </body>
  235. </html>