]> git.mxchange.org Git - friendica-addons.git/blob - jappixmini/jappix/php/install.php
Merge branch '3.6-release'
[friendica-addons.git] / jappixmini / jappix / php / install.php
1 <?php
2
3 /*
4
5 Jappix - An open social platform
6 This is the Jappix Install PHP/HTML code
7
8 -------------------------------------------------
9
10 License: AGPL
11 Author: Vanaryon
12 Last revision: 25/08/11
13
14 */
15
16 // Someone is trying to hack us?
17 if(!defined('JAPPIX_BASE'))
18         exit;
19
20 // Define the configuration folder
21 $conf_folder = JAPPIX_BASE.'/store/conf';
22
23 // Initialize the step
24 $step = 1;
25
26 // Initialize some vars
27 $form_parent = 'install';
28 $user_name = '';
29 $user_password = '';
30 $valid_user = true;
31
32 if(isset($_POST['step']) && !empty($_POST['step'])) {
33         $step = intval($_POST['step']);
34         
35         switch($step) {
36                 // Administrator account configuration submitted
37                 case 3:
38                         include(JAPPIX_BASE.'/php/post-users.php');
39                         break;
40                 
41                 // Main configuration submitted
42                 case 4:
43                         include(JAPPIX_BASE.'/php/post-main.php');
44                         break;
45                 
46                 // Hosts configuration submitted
47                 case 5:
48                         include(JAPPIX_BASE.'/php/post-hosts.php');
49                         break;
50         }
51 }
52
53 // Not frozen on the previous step?
54 if(!isset($_POST['check']) && (isset($_POST['submit']) || isset($_POST['finish']))) {
55         // Checks the current step is valid
56         if(($step >= 2) && !is_dir($conf_folder))
57                 $step = 2;
58         else if(($step >= 3) && !usersConfName())
59                 $step = 3;
60         else if(($step >= 4) && !file_exists($conf_folder.'/main.xml'))
61                 $step = 4;
62         else if(($step >= 5) && !file_exists($conf_folder.'/hosts.xml'))
63                 $step = 5;
64         else
65                 $step++;
66 }
67
68 // These steps are not available
69 if(($step > 6) || !is_int($step))
70         $step = 6;
71
72 // Get the current step title
73 $names = array(
74         T_("Welcome"),
75         T_("Storage configuration"),
76         T_("Administrator account"),
77         T_("Main configuration"),
78         T_("Hosts configuration"),
79         T_("Services installation")
80 );
81
82 // Continue marker
83 $continue = true;
84
85 // Form action
86 if($step < 6)
87         $form_action = './?m=install'.keepGet('m', false);
88 else
89         $form_action = './'.keepGet('m', true);
90
91 ?>
92 <!DOCTYPE html>
93 <?php htmlTag($locale); ?>
94
95 <head>
96         <meta http-equiv="content-type" content="text/html; charset=utf-8" />
97         <meta name="robots" content="none" />
98         <title><?php _e("Jappix installation"); ?> &bull; <?php echo($names[$step - 1]); ?></title>
99         <link rel="shortcut icon" href="./favicon.ico" />
100         <?php echoGetFiles($hash, '', 'css', 'install.xml', ''); echo "\n"; ?>
101         <!--[if lt IE 9]><?php echoGetFiles($hash, '', 'css', '', 'ie.css'); ?><![endif]-->
102 </head>
103
104 <body class="body-images">
105         <form id="install" method="post" action="<?php echo $form_action; ?>">
106                 <div id="install-top">
107                         <div class="logo install-images"><?php _e("Installation"); ?></div>
108                         <div class="step"><?php echo $step; ?> <span>/ 6</span></div>
109                         <div class="clear"></div>
110                         
111                         <input type="hidden" name="step" value="<?php echo($step); ?>" />
112                 </div>
113                 
114                 <div id="install-content">
115                         <?php
116                         
117                         // First step: welcome
118                         if($step == 1) { ?>
119                                 <h3 class="start install-images"><?php _e("Welcome to the Jappix installation!"); ?></h3>
120                                 
121                                 <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>
122                                 <p><?php _e("Let's have a look at the installation steps:"); ?></p>
123                                 
124                                 <ol>
125                                         <li><?php _e("Welcome"); ?></li>
126                                         <li><?php _e("Storage configuration"); ?></li>
127                                         <li><?php _e("Administrator account"); ?></li>
128                                         <li><?php _e("Main configuration"); ?></li>
129                                         <li><?php _e("Hosts configuration"); ?></li>
130                                         <li><?php _e("Services installation"); ?></li>
131                                 </ol>
132                                 
133                                 <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>
134                                 
135                                 <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>
136                                 
137                                 <p><?php _e("It's time to build your own social cloud: just go to the next step!"); ?></p>
138                         <?php }
139                         
140                         // Second step: storage configuration
141                         else if($step == 2) { ?>
142                                 <h3 class="storage install-images"><?php _e("Storage configuration"); ?></h3>
143                                 
144                                 <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>
145                                 
146                                 <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>
147                                 
148                                 <?php if(is_writable(JAPPIX_BASE.'/store')) {
149                                         // Create the store tree
150                                         include(JAPPIX_BASE.'/php/store-tree.php');
151                                 ?>
152                                         <p class="info bigspace success"><?php _e("The folder is writable, you can continue!"); ?></p>
153                                 <?php }
154                                 
155                                 else {
156                                         $continue = false;
157                                 ?>
158                                         <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>
159                                 <?php } ?>
160                         <?php }
161                         
162                         // Third step: administrator account
163                         else if($step == 3) { ?>
164                                 <h3 class="account  install-images"><?php _e("Administrator account"); ?></h3>
165                                 
166                                 <p><?php _e("Jappix offers you the possibility to manage your configuration, install new addons or search for updates. That's why you must create an administrator account to access the manager."); ?></p>
167                                 
168                                 <p><?php _e("When Jappix will be installed, just click on the manager link on the home page to access it."); ?></p>
169                                 
170                                 <?php
171                                 
172                                 // Include the user add form
173                                 include(JAPPIX_BASE.'/php/form-users.php');
174                                 
175                                 if(!$valid_user) { ?>
176                                         <p class="info bigspace fail"><?php _e("Oops, you missed something or the two passwords do not match!"); ?></p>
177                                 <?php }
178                         }
179                         
180                         // Fourth step: main configuration
181                         else if($step == 4) { ?>
182                                 <h3 class="main install-images"><?php _e("Main configuration"); ?></h3>
183                                 
184                                 <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>
185                                 
186                                 <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>
187                                 
188                                 <?php
189                                 
190                                 // Define the main configuration variables
191                                 include(JAPPIX_BASE.'/php/vars-main.php');
192                                 
193                                 // Are we using developer mode?
194                                 if(preg_match('/~dev/i', $version))
195                                         $developer = 'on';
196                                 
197                                 // Include the main configuration form
198                                 include(JAPPIX_BASE.'/php/form-main.php');
199                         }
200                         
201                         // Fifth step: hosts configuration
202                         else if($step == 5) { ?>
203                                 <h3 class="hosts install-images"><?php _e("Hosts configuration"); ?></h3>
204                                 
205                                 <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>
206                                 
207                                 <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>
208                                 
209                                 <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>
210                                 
211                                 <?php
212                                 
213                                 // Define the hosts configuration variables
214                                 include(JAPPIX_BASE.'/php/vars-hosts.php');
215                                 
216                                 // Include the hosts configuration form
217                                 include(JAPPIX_BASE.'/php/form-hosts.php');
218                         }
219                         
220                         // Last step: services installation
221                         else if($step == 6) { ?>
222                                 <h3 class="services install-images"><?php _e("Services installation"); ?></h3>
223                                 
224                                 <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>
225                                 <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>
226                                 
227                                 <?php
228                                 
229                                 // Write the installed marker
230                                 writeXML('conf', 'installed', '<installed>true</installed>');
231                                 
232                                 // Checks some services are installed
233                                 $services_functions = array('gd_info', 'curl_init');
234                                 $services_names = array('GD', 'cURL');
235                                 $services_packages = array('php5-gd', 'php5-curl');
236                                 
237                                 for($i = 0; $i < count($services_names); $i++) {
238                                         $service_class = 'info smallspace';
239                                         
240                                         // First info?
241                                         if($i == 0)
242                                                 $service_class .= ' first';
243                                         
244                                         // Service installed?
245                                         if(function_exists($services_functions[$i])) { ?>
246                                                 <p class="<?php echo($service_class) ?> success"><?php printf(T_("%s is installed on your system."), $services_names[$i]); ?></p>
247                                         <?php }
248                                         
249                                         // Missing service!
250                                         else { ?>
251                                                 <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>
252                                         <?php }
253                                 }
254                                 
255                                 // Checks the upload size limit
256                                 $upload_max = uploadMaxSize();
257                                 $upload_human = formatBytes($upload_max);
258                                 
259                                 if($upload_max >= 7000000) { ?>
260                                         <p class="info smallspace last success"><?php printf(T_("PHP maximum upload size is sufficient (%s)."), $upload_human); ?></p>
261                                 <?php }
262                                 
263                                 else { ?>
264                                         <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>
265                                 <?php } ?>
266                                 
267                                 <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>
268                                 
269                                 <p><?php _e("Thanks for using Jappix!"); ?></p>
270                         <?php } ?>
271                 </div>
272                 
273                 <div id="install-buttons">
274                         <?php if($continue && ($step < 6)) { ?>
275                                 <input type="submit" name="submit" value="<?php _e("Next"); ?> »" />
276                         <?php } if($step == 6) { ?>
277                                 <input type="submit" name="finish" value="<?php _e("Finish"); ?> »" />
278                         <?php } if(!$continue) { ?>
279                                 <input type="submit" name="check" value="<?php _e("Check again"); ?>" />
280                         <?php } ?>
281                         
282                         <div class="clear"></div>
283                 </div>
284         </form>
285 </body>
286
287 </html>
288
289 <!-- Jappix Install <?php echo $version; ?> - An open social platform -->