friendica-addons /jappixmini/jappix/php/install.php

Language PHP Lines 290
MD5 Hash d864f3f45ea831d63ab59070c3e07d48
Repository https://github.com/chiefdome/friendica-addons.git View Raw File
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
<?php

/*

Jappix - An open social platform
This is the Jappix Install PHP/HTML code

-------------------------------------------------

License: AGPL
Author: Vanaryon
Last revision: 25/08/11

*/

// Someone is trying to hack us?
if(!defined('JAPPIX_BASE'))
	exit;

// Define the configuration folder
$conf_folder = JAPPIX_BASE.'/store/conf';

// Initialize the step
$step = 1;

// Initialize some vars
$form_parent = 'install';
$user_name = '';
$user_password = '';
$valid_user = true;

if(isset($_POST['step']) && !empty($_POST['step'])) {
	$step = intval($_POST['step']);
	
	switch($step) {
		// Administrator account configuration submitted
		case 3:
			include(JAPPIX_BASE.'/php/post-users.php');
			break;
		
		// Main configuration submitted
		case 4:
			include(JAPPIX_BASE.'/php/post-main.php');
			break;
		
		// Hosts configuration submitted
		case 5:
			include(JAPPIX_BASE.'/php/post-hosts.php');
			break;
	}
}

// Not frozen on the previous step?
if(!isset($_POST['check']) && (isset($_POST['submit']) || isset($_POST['finish']))) {
	// Checks the current step is valid
	if(($step >= 2) && !is_dir($conf_folder))
		$step = 2;
	else if(($step >= 3) && !usersConfName())
		$step = 3;
	else if(($step >= 4) && !file_exists($conf_folder.'/main.xml'))
		$step = 4;
	else if(($step >= 5) && !file_exists($conf_folder.'/hosts.xml'))
		$step = 5;
	else
		$step++;
}

// These steps are not available
if(($step > 6) || !is_int($step))
	$step = 6;

// Get the current step title
$names = array(
	T_("Welcome"),
	T_("Storage configuration"),
	T_("Administrator account"),
	T_("Main configuration"),
	T_("Hosts configuration"),
	T_("Services installation")
);

// Continue marker
$continue = true;

// Form action
if($step < 6)
	$form_action = './?m=install'.keepGet('m', false);
else
	$form_action = './'.keepGet('m', true);

?>
<!DOCTYPE html>
<?php htmlTag($locale); ?>

<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<meta name="robots" content="none" />
	<title><?php _e("Jappix installation"); ?> &bull; <?php echo($names[$step - 1]); ?></title>
	<link rel="shortcut icon" href="./favicon.ico" />
	<?php echoGetFiles($hash, '', 'css', 'install.xml', ''); echo "\n"; ?>
	<!--[if lt IE 9]><?php echoGetFiles($hash, '', 'css', '', 'ie.css'); ?><![endif]-->
</head>

<body class="body-images">
	<form id="install" method="post" action="<?php echo $form_action; ?>">
		<div id="install-top">
			<div class="logo install-images"><?php _e("Installation"); ?></div>
			<div class="step"><?php echo $step; ?> <span>/ 6</span></div>
			<div class="clear"></div>
			
			<input type="hidden" name="step" value="<?php echo($step); ?>" />
		</div>
		
		<div id="install-content">
			<?php
			
			// First step: welcome
			if($step == 1) { ?>
				<h3 class="start install-images"><?php _e("Welcome to the Jappix installation!"); ?></h3>
				
				<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>
				<p><?php _e("Let's have a look at the installation steps:"); ?></p>
				
				<ol>
					<li><?php _e("Welcome"); ?></li>
					<li><?php _e("Storage configuration"); ?></li>
					<li><?php _e("Administrator account"); ?></li>
					<li><?php _e("Main configuration"); ?></li>
					<li><?php _e("Hosts configuration"); ?></li>
					<li><?php _e("Services installation"); ?></li>
				</ol>
				
				<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>
				
				<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>
				
				<p><?php _e("It's time to build your own social cloud: just go to the next step!"); ?></p>
			<?php }
			
			// Second step: storage configuration
			else if($step == 2) { ?>
				<h3 class="storage install-images"><?php _e("Storage configuration"); ?></h3>
				
				<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>
				
				<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>
				
				<?php if(is_writable(JAPPIX_BASE.'/store')) {
					// Create the store tree
					include(JAPPIX_BASE.'/php/store-tree.php');
				?>
					<p class="info bigspace success"><?php _e("The folder is writable, you can continue!"); ?></p>
				<?php }
				
				else {
					$continue = false;
				?>
					<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>
				<?php } ?>
			<?php }
			
			// Third step: administrator account
			else if($step == 3) { ?>
				<h3 class="account  install-images"><?php _e("Administrator account"); ?></h3>
				
				<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>
				
				<p><?php _e("When Jappix will be installed, just click on the manager link on the home page to access it."); ?></p>
				
				<?php
				
				// Include the user add form
				include(JAPPIX_BASE.'/php/form-users.php');
				
				if(!$valid_user) { ?>
					<p class="info bigspace fail"><?php _e("Oops, you missed something or the two passwords do not match!"); ?></p>
				<?php }
			}
			
			// Fourth step: main configuration
			else if($step == 4) { ?>
				<h3 class="main install-images"><?php _e("Main configuration"); ?></h3>
				
				<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>
				
				<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>
				
				<?php
				
				// Define the main configuration variables
				include(JAPPIX_BASE.'/php/vars-main.php');
				
				// Are we using developer mode?
				if(preg_match('/~dev/i', $version))
					$developer = 'on';
				
				// Include the main configuration form
				include(JAPPIX_BASE.'/php/form-main.php');
			}
			
			// Fifth step: hosts configuration
			else if($step == 5) { ?>
				<h3 class="hosts install-images"><?php _e("Hosts configuration"); ?></h3>
				
				<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>
				
				<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>
				
				<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>
				
				<?php
				
				// Define the hosts configuration variables
				include(JAPPIX_BASE.'/php/vars-hosts.php');
				
				// Include the hosts configuration form
				include(JAPPIX_BASE.'/php/form-hosts.php');
			}
			
			// Last step: services installation
			else if($step == 6) { ?>
				<h3 class="services install-images"><?php _e("Services installation"); ?></h3>
				
				<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>
				<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>
				
				<?php
				
				// Write the installed marker
				writeXML('conf', 'installed', '<installed>true</installed>');
				
				// Checks some services are installed
				$services_functions = array('gd_info', 'curl_init');
				$services_names = array('GD', 'cURL');
				$services_packages = array('php5-gd', 'php5-curl');
				
				for($i = 0; $i < count($services_names); $i++) {
					$service_class = 'info smallspace';
					
					// First info?
					if($i == 0)
						$service_class .= ' first';
					
					// Service installed?
					if(function_exists($services_functions[$i])) { ?>
						<p class="<?php echo($service_class) ?> success"><?php printf(T_("%s is installed on your system."), $services_names[$i]); ?></p>
					<?php }
					
					// Missing service!
					else { ?>
						<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>
					<?php }
				}
				
				// Checks the upload size limit
				$upload_max = uploadMaxSize();
				$upload_human = formatBytes($upload_max);
				
				if($upload_max >= 7000000) { ?>
					<p class="info smallspace last success"><?php printf(T_("PHP maximum upload size is sufficient (%s)."), $upload_human); ?></p>
				<?php }
				
				else { ?>
					<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>
				<?php } ?>
				
				<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>
				
				<p><?php _e("Thanks for using Jappix!"); ?></p>
			<?php } ?>
		</div>
		
		<div id="install-buttons">
			<?php if($continue && ($step < 6)) { ?>
				<input type="submit" name="submit" value="<?php _e("Next"); ?> Âť" />
			<?php } if($step == 6) { ?>
				<input type="submit" name="finish" value="<?php _e("Finish"); ?> Âť" />
			<?php } if(!$continue) { ?>
				<input type="submit" name="check" value="<?php _e("Check again"); ?>" />
			<?php } ?>
			
			<div class="clear"></div>
		</div>
	</form>
</body>

</html>

<!-- Jappix Install <?php echo $version; ?> - An open social platform -->
Back to Top