PageRenderTime 54ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/jappixmini/jappix/php/install.php

https://github.com/chiefdome/friendica-addons
PHP | 289 lines | 206 code | 49 blank | 34 comment | 42 complexity | d864f3f45ea831d63ab59070c3e07d48 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-3.0, GPL-2.0
  1. <?php
  2. /*
  3. Jappix - An open social platform
  4. This is the Jappix Install PHP/HTML code
  5. -------------------------------------------------
  6. License: AGPL
  7. Author: Vanaryon
  8. Last revision: 25/08/11
  9. */
  10. // Someone is trying to hack us?
  11. if(!defined('JAPPIX_BASE'))
  12. exit;
  13. // Define the configuration folder
  14. $conf_folder = JAPPIX_BASE.'/store/conf';
  15. // Initialize the step
  16. $step = 1;
  17. // Initialize some vars
  18. $form_parent = 'install';
  19. $user_name = '';
  20. $user_password = '';
  21. $valid_user = true;
  22. if(isset($_POST['step']) && !empty($_POST['step'])) {
  23. $step = intval($_POST['step']);
  24. switch($step) {
  25. // Administrator account configuration submitted
  26. case 3:
  27. include(JAPPIX_BASE.'/php/post-users.php');
  28. break;
  29. // Main configuration submitted
  30. case 4:
  31. include(JAPPIX_BASE.'/php/post-main.php');
  32. break;
  33. // Hosts configuration submitted
  34. case 5:
  35. include(JAPPIX_BASE.'/php/post-hosts.php');
  36. break;
  37. }
  38. }
  39. // Not frozen on the previous step?
  40. if(!isset($_POST['check']) && (isset($_POST['submit']) || isset($_POST['finish']))) {
  41. // Checks the current step is valid
  42. if(($step >= 2) && !is_dir($conf_folder))
  43. $step = 2;
  44. else if(($step >= 3) && !usersConfName())
  45. $step = 3;
  46. else if(($step >= 4) && !file_exists($conf_folder.'/main.xml'))
  47. $step = 4;
  48. else if(($step >= 5) && !file_exists($conf_folder.'/hosts.xml'))
  49. $step = 5;
  50. else
  51. $step++;
  52. }
  53. // These steps are not available
  54. if(($step > 6) || !is_int($step))
  55. $step = 6;
  56. // Get the current step title
  57. $names = array(
  58. T_("Welcome"),
  59. T_("Storage configuration"),
  60. T_("Administrator account"),
  61. T_("Main configuration"),
  62. T_("Hosts configuration"),
  63. T_("Services installation")
  64. );
  65. // Continue marker
  66. $continue = true;
  67. // Form action
  68. if($step < 6)
  69. $form_action = './?m=install'.keepGet('m', false);
  70. else
  71. $form_action = './'.keepGet('m', true);
  72. ?>
  73. <!DOCTYPE html>
  74. <?php htmlTag($locale); ?>
  75. <head>
  76. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  77. <meta name="robots" content="none" />
  78. <title><?php _e("Jappix installation"); ?> &bull; <?php echo($names[$step - 1]); ?></title>
  79. <link rel="shortcut icon" href="./favicon.ico" />
  80. <?php echoGetFiles($hash, '', 'css', 'install.xml', ''); echo "\n"; ?>
  81. <!--[if lt IE 9]><?php echoGetFiles($hash, '', 'css', '', 'ie.css'); ?><![endif]-->
  82. </head>
  83. <body class="body-images">
  84. <form id="install" method="post" action="<?php echo $form_action; ?>">
  85. <div id="install-top">
  86. <div class="logo install-images"><?php _e("Installation"); ?></div>
  87. <div class="step"><?php echo $step; ?> <span>/ 6</span></div>
  88. <div class="clear"></div>
  89. <input type="hidden" name="step" value="<?php echo($step); ?>" />
  90. </div>
  91. <div id="install-content">
  92. <?php
  93. // First step: welcome
  94. if($step == 1) { ?>
  95. <h3 class="start install-images"><?php _e("Welcome to the Jappix installation!"); ?></h3>
  96. <p><?php _e("This tool will help you fastly install Jappix, the first full-featured XMPP-based social platform, on your server. You don't even need any technical knowledge."); ?></p>
  97. <p><?php _e("Let's have a look at the installation steps:"); ?></p>
  98. <ol>
  99. <li><?php _e("Welcome"); ?></li>
  100. <li><?php _e("Storage configuration"); ?></li>
  101. <li><?php _e("Administrator account"); ?></li>
  102. <li><?php _e("Main configuration"); ?></li>
  103. <li><?php _e("Hosts configuration"); ?></li>
  104. <li><?php _e("Services installation"); ?></li>
  105. </ol>
  106. <p><?php printf(T_("If the current language does not match yours (%1s), you can make Jappix speak %2s it will be saved."), getLanguageName($locale), languageSwitcher($locale)); ?></p>
  107. <p><?php _e("If you want to get some help about the Jappix installation and configuration, you can use our whole documentation, available at:"); ?> <a href="http://codingteam.net/project/jappix/doc" target="_blank">http://codingteam.net/project/jappix/doc</a></p>
  108. <p><?php _e("It's time to build your own social cloud: just go to the next step!"); ?></p>
  109. <?php }
  110. // Second step: storage configuration
  111. else if($step == 2) { ?>
  112. <h3 class="storage install-images"><?php _e("Storage configuration"); ?></h3>
  113. <p><?php _e("Jappix stores persistent data (such as shared files, chat logs, your own music and its configuration) into a single secured storage folder."); ?></p>
  114. <p><?php printf(T_("Jappix must be able to write in this folder to create its sub-directories. If not, you must set the rights to %1s or change the folder owner to %2s (depending of your configuration)."), '<em>777</em>', '<em>www-data</em>'); ?></p>
  115. <?php if(is_writable(JAPPIX_BASE.'/store')) {
  116. // Create the store tree
  117. include(JAPPIX_BASE.'/php/store-tree.php');
  118. ?>
  119. <p class="info bigspace success"><?php _e("The folder is writable, you can continue!"); ?></p>
  120. <?php }
  121. else {
  122. $continue = false;
  123. ?>
  124. <p class="info bigspace fail"><?php printf(T_("The folder is not writable, set the right permissions to the %s directory."), "<em>./store</em>"); ?></p>
  125. <?php } ?>
  126. <?php }
  127. // Third step: administrator account
  128. else if($step == 3) { ?>
  129. <h3 class="account install-images"><?php _e("Administrator account"); ?></h3>
  130. <p><?php _e("Jappix offers you the possibility to manage your configuration, install new plugins or search for updates. That's why you must create an administrator account to access the manager."); ?></p>
  131. <p><?php _e("When Jappix will be installed, just click on the manager link on the home page to access it."); ?></p>
  132. <?php
  133. // Include the user add form
  134. include(JAPPIX_BASE.'/php/form-users.php');
  135. if(!$valid_user) { ?>
  136. <p class="info bigspace fail"><?php _e("Oops, you missed something or the two passwords do not match!"); ?></p>
  137. <?php }
  138. }
  139. // Fourth step: main configuration
  140. else if($step == 4) { ?>
  141. <h3 class="main install-images"><?php _e("Main configuration"); ?></h3>
  142. <p><?php _e("Jappix needs that you specify some values to work. Please correct the following inputs (or keep the default values, which are sufficient for most people)."); ?></p>
  143. <p><?php _e("Note that if you don't specify a value which is compulsory, it will be automatically completed with the default one."); ?></p>
  144. <?php
  145. // Define the main configuration variables
  146. include(JAPPIX_BASE.'/php/vars-main.php');
  147. // Are we using developer mode?
  148. if(preg_match('/~dev/i', $version))
  149. $developer = 'on';
  150. // Include the main configuration form
  151. include(JAPPIX_BASE.'/php/form-main.php');
  152. }
  153. // Fifth step: hosts configuration
  154. else if($step == 5) { ?>
  155. <h3 class="hosts install-images"><?php _e("Hosts configuration"); ?></h3>
  156. <p><?php _e("This page helps you specify the default hosts Jappix will connect to. You can leave it as it is and continue if you want to use the official service hosts."); ?></p>
  157. <p><?php _e("Maybe you don't know what a BOSH server is? In fact, this is a relay between a Jappix client and a XMPP server, which is necessary because of technical limitations."); ?></p>
  158. <p><?php _e("Note that if you don't specify a value which is compulsory, it will be automatically completed with the default one."); ?></p>
  159. <?php
  160. // Define the hosts configuration variables
  161. include(JAPPIX_BASE.'/php/vars-hosts.php');
  162. // Include the hosts configuration form
  163. include(JAPPIX_BASE.'/php/form-hosts.php');
  164. }
  165. // Last step: services installation
  166. else if($step == 6) { ?>
  167. <h3 class="services install-images"><?php _e("Services installation"); ?></h3>
  168. <p><?php _e("You can install some extra softwares on your server, to extend your Jappix features. Some others might be modified, because of security restrictions which are set by default."); ?></p>
  169. <p><?php _e("To perform this, you must be able to access your server's shell and be logged in as root. Remember this is facultative, Jappix will work without these modules, but some of its features will be unavailable."); ?></p>
  170. <?php
  171. // Write the installed marker
  172. writeXML('conf', 'installed', '<installed>true</installed>');
  173. // Checks some services are installed
  174. $services_functions = array('gd_info', 'curl_init');
  175. $services_names = array('GD', 'cURL');
  176. $services_packages = array('php5-gd', 'php5-curl');
  177. for($i = 0; $i < count($services_names); $i++) {
  178. $service_class = 'info smallspace';
  179. // First info?
  180. if($i == 0)
  181. $service_class .= ' first';
  182. // Service installed?
  183. if(function_exists($services_functions[$i])) { ?>
  184. <p class="<?php echo($service_class) ?> success"><?php printf(T_("%s is installed on your system."), $services_names[$i]); ?></p>
  185. <?php }
  186. // Missing service!
  187. else { ?>
  188. <p class="<?php echo($service_class) ?> fail"><?php printf(T_("%1s is not installed on your system, you should install %2s."), $services_names[$i], '<em>'.$services_packages[$i].'</em>'); ?></p>
  189. <?php }
  190. }
  191. // Checks the upload size limit
  192. $upload_max = uploadMaxSize();
  193. $upload_human = formatBytes($upload_max);
  194. if($upload_max >= 7000000) { ?>
  195. <p class="info smallspace last success"><?php printf(T_("PHP maximum upload size is sufficient (%s)."), $upload_human); ?></p>
  196. <?php }
  197. else { ?>
  198. <p class="info smallspace last fail"><?php printf(T_("PHP maximum upload size is not sufficient (%1s), you should define it to %2s in %3s."), $upload_human, '8M', '<em>php.ini</em>'); ?></p>
  199. <?php } ?>
  200. <p><?php _e("After you finished the setup, Jappix will generate the cache files. It might be slow, just wait until the application is displayed and do not press any button."); ?></p>
  201. <p><?php _e("Thanks for using Jappix!"); ?></p>
  202. <?php } ?>
  203. </div>
  204. <div id="install-buttons">
  205. <?php if($continue && ($step < 6)) { ?>
  206. <input type="submit" name="submit" value="<?php _e("Next"); ?> Âť" />
  207. <?php } if($step == 6) { ?>
  208. <input type="submit" name="finish" value="<?php _e("Finish"); ?> Âť" />
  209. <?php } if(!$continue) { ?>
  210. <input type="submit" name="check" value="<?php _e("Check again"); ?>" />
  211. <?php } ?>
  212. <div class="clear"></div>
  213. </div>
  214. </form>
  215. </body>
  216. </html>
  217. <!-- Jappix Install <?php echo $version; ?> - An open social platform -->