Browse Source

Revert "Moved .htconfig.php file & extracted Install business logic"

tags/2018.05
Tobias Diekershoff 1 year ago
parent
commit
f63be91bd5
No account linked to committer's email address

+ 7
- 7
INSTALL.txt View File

@@ -77,7 +77,7 @@ password, database name).
77 77
     - Please check the additional notes if running on MySQ 5.7.17 or newer
78 78
 
79 79
 4. If you know in advance that it will be impossible for the web server to
80
-write or create files in your web directory, create an empty file in config/ called
80
+write or create files in your web directory, create an empty file called
81 81
 .htconfig.php and make it writable by the web server.
82 82
 
83 83
 5. Visit your website with a web browser and follow the instructions. Please
@@ -92,8 +92,8 @@ so in the host name setting for the database.
92 92
 
93 93
 6. *If* the automated installation fails for any reason, check the following:
94 94
 
95
-	- "config/.htconfig.php" exists
96
-		If not, edit config/htconfig.php and change system settings. Rename
95
+	- ".htconfig.php" exists
96
+		If not, edit htconfig.php and change system settings. Rename
97 97
 to .htconfig.php
98 98
 	-  Database is populated.
99 99
 		If not, import the contents of "database.sql" with phpmyadmin
@@ -148,7 +148,7 @@ Bad things will happen. Let there be a hardware failure, a corrupted
148 148
 database or whatever you can think of. So once the installation of your
149 149
 Friendica node is done, you should make yoursef a backup plan.
150 150
 
151
-The most important file is the `.htconfig.php` file in the `config/` directory.
151
+The most important file is the `.htconfig.php` file in the base directory.
152 152
 As it stores all your data, you should also have a recent dump of your
153 153
 Friendica database at hand, should you have to recover your node.
154 154
 
@@ -252,14 +252,14 @@ due to permissions issues:
252 252
 	create an empty file with that name and give it world-write permission.
253 253
 For Linux:
254 254
 
255
-% touch config/.htconfig.php
256
-% chmod 777 config/.htconfig.php
255
+% touch .htconfig.php
256
+% chmod 777 .htconfig.php
257 257
 
258 258
 Retry the installation. As soon as the database has been created,
259 259
 
260 260
 ******* this is important *********
261 261
 
262
-% chmod 755 config/.htconfig.php
262
+% chmod 755 .htconfig.php
263 263
 
264 264
 #####################################################################
265 265
 - Some configurations with "suhosin" security are configured without

+ 1
- 1
bin/auth_ejabberd.php View File

@@ -57,7 +57,7 @@ require_once "include/dba.php";
57 57
 $a = new App(dirname(__DIR__));
58 58
 BaseObject::setApp($a);
59 59
 
60
-@include "config/.htconfig.php";
60
+@include ".htconfig.php";
61 61
 dba::connect($db_host, $db_user, $db_pass, $db_data);
62 62
 unset($db_host, $db_user, $db_pass, $db_data);
63 63
 

+ 1
- 1
bin/daemon.php View File

@@ -38,7 +38,7 @@ if (substr($directory, 0, 1) != "/") {
38 38
 }
39 39
 $directory = realpath($directory."/..");
40 40
 
41
-@include($directory."/config/.htconfig.php");
41
+@include($directory."/.htconfig.php");
42 42
 
43 43
 if (!isset($pidfile)) {
44 44
 	die('Please specify a pid file in the variable $pidfile in the .htconfig.php. For example:'."\n".

+ 1
- 1
bin/dev/vagrant_provision.sh View File

@@ -86,7 +86,7 @@ cd /var/www
86 86
 php bin/composer.phar install
87 87
 
88 88
 # initial config file for friendica in vagrant
89
-cp /vagrant/util/htconfig.vagrant.php /vagrant/config/.htconfig.php
89
+cp /vagrant/util/htconfig.vagrant.php /vagrant/.htconfig.php
90 90
 
91 91
 # create the friendica database
92 92
 echo "create database friendica DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci" | $MYSQL -u root -proot

+ 1
- 1
bin/worker.php View File

@@ -29,7 +29,7 @@ require_once "include/dba.php";
29 29
 $a = new App(dirname(__DIR__));
30 30
 BaseObject::setApp($a);
31 31
 
32
-require_once "config/.htconfig.php";
32
+require_once ".htconfig.php";
33 33
 dba::connect($db_host, $db_user, $db_pass, $db_data);
34 34
 unset($db_host, $db_user, $db_pass, $db_data);
35 35
 

+ 2
- 2
doc/Install.md View File

@@ -89,7 +89,7 @@ If you need to specify a port for the connection to the database, you can do so
89 89
 
90 90
 *If* the automated installation fails for any reason, check the following:
91 91
 
92
-* Does ".htconfig.php" in "config/" exist? If not, edit htconfig.php and change the system settings. Rename to .htconfig.php
92
+* Does ".htconfig.php" exist? If not, edit htconfig.php and change the system settings. Rename to .htconfig.php
93 93
 * Is the database is populated? If not, import the contents of "database.sql" with phpmyadmin or mysql command line.
94 94
 
95 95
 At this point visit your website again, and register your personal account.
@@ -125,5 +125,5 @@ Bad things will happen.
125 125
 Let there be a hardware failure, a corrupted database or whatever you can think of.
126 126
 So once the installation of your Friendica node is done, you should make yourself a backup plan.
127 127
 
128
-The most important file is the `.htconfig.php` file in the `config/` directory.
128
+The most important file is the `.htconfig.php` file in the base directory.
129 129
 As it stores all your data, you should also have a recent dump of your Friendica database at hand, should you have to recover your node.

+ 1
- 1
doc/Update.md View File

@@ -7,7 +7,7 @@ Updating Friendica
7 7
 
8 8
 If you installed Friendica in the ``path/to/friendica`` folder:
9 9
 1. Unpack the new Friendica archive in ``path/to/friendica_new``.
10
-2. Copy ``config/.htconfig.php``, ``photo/`` and ``proxy/`` from ``path/to/friendica`` to ``path/to/friendica_new``.
10
+2. Copy ``.htconfig.php``, ``photo/`` and ``proxy/`` from ``path/to/friendica`` to ``path/to/friendica_new``.
11 11
 3. Rename the ``path/to/friendica`` folder to ``path/to/friendica_old``.
12 12
 4. Rename the ``path/to/friendica_new`` folder to ``path/to/friendica``.
13 13
 5. Check your site. Note: it may go into maintenance mode to update the database schema.

+ 1
- 1
doc/Vagrant.md View File

@@ -42,7 +42,7 @@ This will not delete the virtual machine.
42 42
 9. To ultimately delete the virtual machine run
43 43
 
44 44
         $> vagrant destroy
45
-        $> rm /vagrant/config/.htconfig.php
45
+        $> rm /vagrant/.htconfig.php
46 46
 
47 47
 to make sure that you can start from scratch with another "vagrant up".
48 48
 

+ 1
- 1
doc/de/FAQ.md View File

@@ -199,7 +199,7 @@ Admin
199 199
 
200 200
 Ja, das ist möglich.
201 201
 Es ist allerdings nicht möglich, eine Datenbank durch zwei Domains zu nutzen.
202
-Solange Du Deine .htconfig.php allerdings so einrichtest, dass das System nicht versucht, eine Installation durchzuführen, kannst Du die richtige Config-Datei in include/$hostname/config/.htconfig.php hinterlegen.
202
+Solange Du Deine .htconfig.php allerdings so einrichtest, dass das System nicht versucht, eine Installation durchzuführen, kannst Du die richtige Config-Datei in include/$hostname/.htconfig.php hinterlegen.
203 203
 Alle Cache-Aspekte und der Zugriffsschutz können pro Instanz konfiguriert werden.
204 204
 
205 205
 <a name="sources"></a>

+ 2
- 2
doc/de/Install.md View File

@@ -78,7 +78,7 @@ Friendica benötigt die Berechtigungen um neue Felder in dieser Datenbank zu ert
78 78
 
79 79
 5. *Wenn* die automatisierte Installation aus irgendeinem Grund fehlschlägt, dann prüfe das Folgende:
80 80
 
81
-    - "config/.htconfig.php" existiert ... wenn nicht, bearbeite die „config/htconfig.php“ und ändere die Systemeinstellungen. Benenne sie um in „.htconfig.php"
81
+    - ".htconfig.php" existiert ... wenn nicht, bearbeite die „htconfig.php“ und ändere die Systemeinstellungen. Benenne sie um in „.htconfig.php"
82 82
83 83
     - die Datenbank beinhaltet Daten. ... wenn nicht, importiere den Inhalt der Datei "database.sql" mit phpmyadmin oder per mysql-Kommandozeile.
84 84
 
@@ -106,5 +106,5 @@ Es werden schlimme Dinge geschehen.
106 106
 Sei es nun ein Hardwareversage oder eine korrumpierte Datenbank.
107 107
 Deshalb solltest du dir nachdem die Installation deines Friendica Knotens abgeschlossen ist einen Backup Plan erstellen.
108 108
 
109
-Die wichtigste Datei ist die `.htconfig.php` im `config/`-Verzeicnhis deiner Friendica Installation.
109
+Die wichtigste Datei ist die `.htconfig.php` im Stammverzeichnis deiner Friendica Installation.
110 110
 Und da alle Daten in der Datenbank gespeichert werden, solltest du einen nicht all zu alten Dump der Friendica Datenbank zur Hand haben, solltest du deinen Knoten wieder herstellen müssen.

config/htconfig.php → htconfig.php View File


+ 0
- 1
include/dba.php View File

@@ -93,7 +93,6 @@ class dba {
93 93
 
94 94
 		// No suitable SQL driver was found.
95 95
 		if (!self::$connected) {
96
-			self::$driver = null;
97 96
 			self::$db = null;
98 97
 		}
99 98
 		$a->save_timestamp($stamp1, "network");

+ 2
- 2
index.php View File

@@ -37,11 +37,11 @@ $a->backend = false;
37 37
  * installation mode.
38 38
  */
39 39
 
40
-$install = ((file_exists('config/.htconfig.php') && filesize('config/.htconfig.php')) ? false : true);
40
+$install = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? false : true);
41 41
 
42 42
 // Only load config if found, don't surpress errors
43 43
 if (!$install) {
44
-	include "config/.htconfig.php";
44
+	include ".htconfig.php";
45 45
 }
46 46
 
47 47
 /**

+ 297
- 4
mod/install.php View File

@@ -5,9 +5,11 @@
5 5
 
6 6
 use Friendica\App;
7 7
 use Friendica\Core\L10n;
8
-use Friendica\Core\Install;
9 8
 use Friendica\Core\System;
10 9
 use Friendica\Database\DBM;
10
+use Friendica\Database\DBStructure;
11
+use Friendica\Object\Image;
12
+use Friendica\Util\Network;
11 13
 use Friendica\Util\Temporal;
12 14
 
13 15
 $install_wizard_pass = 1;
@@ -70,7 +72,34 @@ function install_post(App $a) {
70 72
 			// connect to db
71 73
 			dba::connect($dbhost, $dbuser, $dbpass, $dbdata, true);
72 74
 
73
-			Install::install($urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $phpath, $timezone, $language, $adminmail, $rino);
75
+			$tpl = get_markup_template('htconfig.tpl');
76
+			$txt = replace_macros($tpl,[
77
+				'$dbhost' => $dbhost,
78
+				'$dbuser' => $dbuser,
79
+				'$dbpass' => $dbpass,
80
+				'$dbdata' => $dbdata,
81
+				'$timezone' => $timezone,
82
+				'$language' => $language,
83
+				'$urlpath' => $urlpath,
84
+				'$phpath' => $phpath,
85
+				'$adminmail' => $adminmail,
86
+				'$rino' => $rino
87
+			]);
88
+
89
+
90
+			$result = file_put_contents('.htconfig.php', $txt);
91
+			if (! $result) {
92
+				$a->data['txt'] = $txt;
93
+			}
94
+
95
+			$errors = load_database();
96
+
97
+
98
+			if ($errors) {
99
+				$a->data['db_failed'] = $errors;
100
+			} else {
101
+				$a->data['db_installed'] = true;
102
+			}
74 103
 
75 104
 			return;
76 105
 		break;
@@ -138,11 +167,37 @@ function install_content(App $a) {
138 167
 	switch ($install_wizard_pass) {
139 168
 		case 1: { // System check
140 169
 
170
+
171
+			$checks = [];
172
+
173
+			check_funcs($checks);
174
+
175
+			check_imagik($checks);
176
+
177
+			check_htconfig($checks);
178
+
179
+			check_smarty3($checks);
180
+
181
+			check_keys($checks);
182
+
141 183
 			if (x($_POST, 'phpath')) {
142 184
 				$phpath = notags(trim($_POST['phpath']));
143 185
 			}
144 186
 
145
-			list($checks, $checkspassed) = Install::check($phpath);
187
+			check_php($phpath, $checks);
188
+
189
+			check_htaccess($checks);
190
+
191
+			/// @TODO Maybe move this out?
192
+			function check_passed($v, $c) {
193
+				if ($c['required']) {
194
+					$v = $v && $c['status'];
195
+				}
196
+				return $v;
197
+			}
198
+			$checkspassed = array_reduce($checks, "check_passed", true);
199
+
200
+
146 201
 
147 202
 			$tpl = get_markup_template('install_checks.tpl');
148 203
 			$o .= replace_macros($tpl, [
@@ -241,9 +296,241 @@ function install_content(App $a) {
241 296
 	}
242 297
 }
243 298
 
299
+/**
300
+ * checks   : array passed to template
301
+ * title    : string
302
+ * status   : boolean
303
+ * required : boolean
304
+ * help		: string optional
305
+ */
306
+function check_add(&$checks, $title, $status, $required, $help) {
307
+	$checks[] = [
308
+		'title' => $title,
309
+		'status' => $status,
310
+		'required' => $required,
311
+		'help'	=> $help,
312
+	];
313
+}
314
+
315
+function check_php(&$phpath, &$checks) {
316
+	$passed = $passed2 = $passed3 = false;
317
+	if (strlen($phpath)) {
318
+		$passed = file_exists($phpath);
319
+	} else {
320
+		$phpath = trim(shell_exec('which php'));
321
+		$passed = strlen($phpath);
322
+	}
323
+	$help = "";
324
+	if (!$passed) {
325
+		$help .= L10n::t('Could not find a command line version of PHP in the web server PATH.'). EOL;
326
+		$help .= L10n::t("If you don't have a command line version of PHP installed on your server, you will not be able to run the background processing. See <a href='https://github.com/friendica/friendica/blob/master/doc/Install.md#set-up-the-worker'>'Setup the worker'</a>") . EOL;
327
+		$help .= EOL . EOL;
328
+		$tpl = get_markup_template('field_input.tpl');
329
+		$help .= replace_macros($tpl, [
330
+			'$field' => ['phpath', L10n::t('PHP executable path'), $phpath, L10n::t('Enter full path to php executable. You can leave this blank to continue the installation.')],
331
+		]);
332
+		$phpath = "";
333
+	}
334
+
335
+	check_add($checks, L10n::t('Command line PHP').($passed?" (<tt>$phpath</tt>)":""), $passed, false, $help);
336
+
337
+	if ($passed) {
338
+		$cmd = "$phpath -v";
339
+		$result = trim(shell_exec($cmd));
340
+		$passed2 = ( strpos($result, "(cli)") !== false);
341
+		list($result) = explode("\n", $result);
342
+		$help = "";
343
+		if (!$passed2) {
344
+			$help .= L10n::t("PHP executable is not the php cli binary \x28could be cgi-fgci version\x29"). EOL;
345
+			$help .= L10n::t('Found PHP version: ')."<tt>$result</tt>";
346
+		}
347
+		check_add($checks, L10n::t('PHP cli binary'), $passed2, true, $help);
348
+	}
349
+
350
+
351
+	if ($passed2) {
352
+		$str = autoname(8);
353
+		$cmd = "$phpath testargs.php $str";
354
+		$result = trim(shell_exec($cmd));
355
+		$passed3 = $result == $str;
356
+		$help = "";
357
+		if (!$passed3) {
358
+			$help .= L10n::t('The command line version of PHP on your system does not have "register_argc_argv" enabled.'). EOL;
359
+			$help .= L10n::t('This is required for message delivery to work.');
360
+		}
361
+		check_add($checks, L10n::t('PHP register_argc_argv'), $passed3, true, $help);
362
+	}
363
+
364
+
365
+}
366
+
367
+function check_keys(&$checks) {
368
+
369
+	$help = '';
370
+
371
+	$res = false;
372
+
373
+	if (function_exists('openssl_pkey_new')) {
374
+		$res = openssl_pkey_new([
375
+			'digest_alg'       => 'sha1',
376
+			'private_key_bits' => 4096,
377
+			'encrypt_key'      => false
378
+		]);
379
+	}
380
+
381
+	// Get private key
382
+
383
+	if (! $res) {
384
+		$help .= L10n::t('Error: the "openssl_pkey_new" function on this system is not able to generate encryption keys'). EOL;
385
+		$help .= L10n::t('If running under Windows, please see "http://www.php.net/manual/en/openssl.installation.php".');
386
+	}
387
+	check_add($checks, L10n::t('Generate encryption keys'), $res, true, $help);
388
+
389
+}
390
+
391
+
392
+function check_funcs(&$checks) {
393
+	$ck_funcs = [];
394
+	check_add($ck_funcs, L10n::t('libCurl PHP module'), true, true, "");
395
+	check_add($ck_funcs, L10n::t('GD graphics PHP module'), true, true, "");
396
+	check_add($ck_funcs, L10n::t('OpenSSL PHP module'), true, true, "");
397
+	check_add($ck_funcs, L10n::t('PDO or MySQLi PHP module'), true, true, "");
398
+	check_add($ck_funcs, L10n::t('mb_string PHP module'), true, true, "");
399
+	check_add($ck_funcs, L10n::t('XML PHP module'), true, true, "");
400
+	check_add($ck_funcs, L10n::t('iconv PHP module'), true, true, "");
401
+	check_add($ck_funcs, L10n::t('POSIX PHP module'), true, true, "");
402
+
403
+	if (function_exists('apache_get_modules')) {
404
+		if (! in_array('mod_rewrite',apache_get_modules())) {
405
+			check_add($ck_funcs, L10n::t('Apache mod_rewrite module'), false, true, L10n::t('Error: Apache webserver mod-rewrite module is required but not installed.'));
406
+		} else {
407
+			check_add($ck_funcs, L10n::t('Apache mod_rewrite module'), true, true, "");
408
+		}
409
+	}
410
+
411
+	if (! function_exists('curl_init')) {
412
+		$ck_funcs[0]['status'] = false;
413
+		$ck_funcs[0]['help'] = L10n::t('Error: libCURL PHP module required but not installed.');
414
+	}
415
+	if (! function_exists('imagecreatefromjpeg')) {
416
+		$ck_funcs[1]['status'] = false;
417
+		$ck_funcs[1]['help'] = L10n::t('Error: GD graphics PHP module with JPEG support required but not installed.');
418
+	}
419
+	if (! function_exists('openssl_public_encrypt')) {
420
+		$ck_funcs[2]['status'] = false;
421
+		$ck_funcs[2]['help'] = L10n::t('Error: openssl PHP module required but not installed.');
422
+	}
423
+	if (! function_exists('mysqli_connect') && !class_exists('pdo')) {
424
+		$ck_funcs[3]['status'] = false;
425
+		$ck_funcs[3]['help'] = L10n::t('Error: PDO or MySQLi PHP module required but not installed.');
426
+	}
427
+	if (!function_exists('mysqli_connect') && class_exists('pdo') && !in_array('mysql', PDO::getAvailableDrivers())) {
428
+		$ck_funcs[3]['status'] = false;
429
+		$ck_funcs[3]['help'] = L10n::t('Error: The MySQL driver for PDO is not installed.');
430
+	}
431
+	if (! function_exists('mb_strlen')) {
432
+		$ck_funcs[4]['status'] = false;
433
+		$ck_funcs[4]['help'] = L10n::t('Error: mb_string PHP module required but not installed.');
434
+	}
435
+	if (! function_exists('iconv_strlen')) {
436
+		$ck_funcs[6]['status'] = false;
437
+		$ck_funcs[6]['help'] = L10n::t('Error: iconv PHP module required but not installed.');
438
+	}
439
+	if (! function_exists('posix_kill')) {
440
+		$ck_funcs[7]['status'] = false;
441
+		$ck_funcs[7]['help'] = L10n::t('Error: POSIX PHP module required but not installed.');
442
+	}
443
+
444
+	$checks = array_merge($checks, $ck_funcs);
445
+
446
+	// check for XML DOM Documents being able to be generated
447
+	try {
448
+		$xml = new DOMDocument();
449
+	} catch (Exception $e) {
450
+		$ck_funcs[5]['status'] = false;
451
+		$ck_funcs[5]['help'] = L10n::t('Error, XML PHP module required but not installed.');
452
+	}
453
+}
454
+
455
+
456
+function check_htconfig(&$checks) {
457
+	$status = true;
458
+	$help = "";
459
+	if ((file_exists('.htconfig.php') && !is_writable('.htconfig.php')) ||
460
+		(!file_exists('.htconfig.php') && !is_writable('.'))) {
461
+
462
+		$status = false;
463
+		$help = L10n::t('The web installer needs to be able to create a file called ".htconfig.php" in the top folder of your web server and it is unable to do so.') .EOL;
464
+		$help .= L10n::t('This is most often a permission setting, as the web server may not be able to write files in your folder - even if you can.').EOL;
465
+		$help .= L10n::t('At the end of this procedure, we will give you a text to save in a file named .htconfig.php in your Friendica top folder.').EOL;
466
+		$help .= L10n::t('You can alternatively skip this procedure and perform a manual installation. Please see the file "INSTALL.txt" for instructions.').EOL;
467
+	}
468
+
469
+	check_add($checks, L10n::t('.htconfig.php is writable'), $status, false, $help);
470
+
471
+}
472
+
473
+function check_smarty3(&$checks) {
474
+	$status = true;
475
+	$help = "";
476
+	if (!is_writable('view/smarty3')) {
477
+
478
+		$status = false;
479
+		$help = L10n::t('Friendica uses the Smarty3 template engine to render its web views. Smarty3 compiles templates to PHP to speed up rendering.') .EOL;
480
+		$help .= L10n::t('In order to store these compiled templates, the web server needs to have write access to the directory view/smarty3/ under the Friendica top level folder.').EOL;
481
+		$help .= L10n::t("Please ensure that the user that your web server runs as \x28e.g. www-data\x29 has write access to this folder.").EOL;
482
+		$help .= L10n::t("Note: as a security measure, you should give the web server write access to view/smarty3/ only--not the template files \x28.tpl\x29 that it contains.").EOL;
483
+	}
484
+
485
+	check_add($checks, L10n::t('view/smarty3 is writable'), $status, true, $help);
486
+
487
+}
488
+
489
+function check_htaccess(&$checks) {
490
+	$status = true;
491
+	$help = "";
492
+	if (function_exists('curl_init')) {
493
+		$test = Network::fetchUrl(System::baseUrl()."/install/testrewrite");
494
+
495
+		if ($test != "ok") {
496
+			$test = Network::fetchUrl(normalise_link(System::baseUrl()."/install/testrewrite"));
497
+		}
498
+
499
+		if ($test != "ok") {
500
+			$status = false;
501
+			$help = L10n::t('Url rewrite in .htaccess is not working. Check your server configuration.');
502
+		}
503
+		check_add($checks, L10n::t('Url rewrite is working'), $status, true, $help);
504
+	} else {
505
+		// cannot check modrewrite if libcurl is not installed
506
+		/// @TODO Maybe issue warning here?
507
+	}
508
+}
509
+
510
+function check_imagik(&$checks) {
511
+	$imagick = false;
512
+	$gif = false;
513
+
514
+	if (class_exists('Imagick')) {
515
+		$imagick = true;
516
+		$supported = Image::supportedTypes();
517
+		if (array_key_exists('image/gif', $supported)) {
518
+			$gif = true;
519
+		}
520
+	}
521
+	if ($imagick == false) {
522
+		check_add($checks, L10n::t('ImageMagick PHP extension is not installed'), $imagick, false, "");
523
+	} else {
524
+		check_add($checks, L10n::t('ImageMagick PHP extension is installed'), $imagick, false, "");
525
+		if ($imagick) {
526
+			check_add($checks, L10n::t('ImageMagick supports GIF'), $gif, false, "");
527
+		}
528
+	}
529
+}
530
+
244 531
 function manual_config(App $a) {
245 532
 	$data = htmlentities($a->data['txt'],ENT_COMPAT, 'UTF-8');
246
-	$o = L10n::t('The database configuration file ".htconfig.php" could not be written. Please use the enclosed text to create a configuration file in your web server "config/".');
533
+	$o = L10n::t('The database configuration file ".htconfig.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.');
247 534
 	$o .= "<textarea rows=\"24\" cols=\"80\" >$data</textarea>";
248 535
 	return $o;
249 536
 }
@@ -257,6 +544,12 @@ function load_database_rem($v, $i) {
257 544
 	}
258 545
 }
259 546
 
547
+function load_database() {
548
+	$errors = DBStructure::update(false, true, true);
549
+
550
+	return $errors;
551
+}
552
+
260 553
 function what_next() {
261 554
 	$baseurl = System::baseUrl();
262 555
 	return

+ 1
- 1
src/Core/Console/Config.php View File

@@ -92,7 +92,7 @@ HELP;
92 92
 			throw new CommandArgsException('Too many arguments');
93 93
 		}
94 94
 
95
-		require_once 'config/.htconfig.php';
95
+		require_once '.htconfig.php';
96 96
 		$result = dba::connect($db_host, $db_user, $db_pass, $db_data);
97 97
 		unset($db_host, $db_user, $db_pass, $db_data);
98 98
 

+ 1
- 1
src/Core/Console/DatabaseStructure.php View File

@@ -56,7 +56,7 @@ HELP;
56 56
 			throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
57 57
 		}
58 58
 
59
-		require_once 'config/.htconfig.php';
59
+		require_once '.htconfig.php';
60 60
 		$result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
61 61
 		unset($db_host, $db_user, $db_pass, $db_data);
62 62
 

+ 1
- 1
src/Core/Console/GlobalCommunityBlock.php View File

@@ -56,7 +56,7 @@ HELP;
56 56
 			throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
57 57
 		}
58 58
 
59
-		require_once 'config/.htconfig.php';
59
+		require_once '.htconfig.php';
60 60
 		$result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
61 61
 		unset($db_host, $db_user, $db_pass, $db_data);
62 62
 

+ 1
- 1
src/Core/Console/GlobalCommunitySilence.php View File

@@ -64,7 +64,7 @@ HELP;
64 64
 			throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
65 65
 		}
66 66
 
67
-		require_once 'config/.htconfig.php';
67
+		require_once '.htconfig.php';
68 68
 		$result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
69 69
 		unset($db_host, $db_user, $db_pass, $db_data);
70 70
 

+ 1
- 1
src/Core/Console/Maintenance.php View File

@@ -64,7 +64,7 @@ HELP;
64 64
 			throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
65 65
 		}
66 66
 
67
-		require_once 'config/.htconfig.php';
67
+		require_once '.htconfig.php';
68 68
 		$result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
69 69
 		unset($db_host, $db_user, $db_pass, $db_data);
70 70
 

+ 1
- 1
src/Core/Console/NewPassword.php View File

@@ -58,7 +58,7 @@ HELP;
58 58
 			throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
59 59
 		}
60 60
 
61
-		require_once 'config/.htconfig.php';
61
+		require_once '.htconfig.php';
62 62
 		$result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
63 63
 		unset($db_host, $db_user, $db_pass, $db_data);
64 64
 

+ 0
- 318
src/Core/Install.php View File

@@ -1,318 +0,0 @@
1
-<?php
2
-/**
3
- * @file src/Core/Install.php
4
- */
5
-namespace Friendica\Core;
6
-
7
-use Friendica\BaseObject;
8
-use Friendica\Database\DBStructure;
9
-use Friendica\Object\Image;
10
-use Friendica\Util\Network;
11
-
12
-use Exception;
13
-use DOMDocument;
14
-
15
-/**
16
- * @brief Contains the class with install relevant stuff *
17
- */
18
-class Install extends BaseObject
19
-{
20
-	public static function check($phpath)
21
-	{
22
-		$checks = [];
23
-
24
-		self::checkFunctions($checks);
25
-
26
-		self::checkImagik($checks);
27
-
28
-		self::checkHtConfig($checks);
29
-
30
-		self::checkSmarty3($checks);
31
-
32
-		self::checkKeys($checks);
33
-
34
-		self::checkPHP($phpath, $checks);
35
-
36
-		self::checkHtAccess($checks);
37
-
38
-		$checkspassed = array_reduce($checks,
39
-			function ($v, $c) {
40
-				if ($c['require']) {
41
-					$v = $v && $c['status'];
42
-				}
43
-				return $v;
44
-			},
45
-			true);
46
-
47
-		return array($checks, $checkspassed);
48
-	}
49
-
50
-	public static function install($urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $phpath, $timezone, $language, $adminmail, $rino = 1)
51
-	{
52
-		$tpl = get_markup_template('htconfig.tpl');
53
-		$txt = replace_macros($tpl,[
54
-			'$dbhost' => $dbhost,
55
-			'$dbuser' => $dbuser,
56
-			'$dbpass' => $dbpass,
57
-			'$dbdata' => $dbdata,
58
-			'$timezone' => $timezone,
59
-			'$language' => $language,
60
-			'$urlpath' => $urlpath,
61
-			'$phpath' => $phpath,
62
-			'$adminmail' => $adminmail,
63
-			'$rino' => $rino
64
-		]);
65
-
66
-
67
-		$result = file_put_contents('config/.htconfig.php', $txt);
68
-		if (! $result) {
69
-			self::getApp()->data['txt'] = $txt;
70
-		}
71
-
72
-		$errors = self::loadDatabase();
73
-
74
-		if ($errors) {
75
-			self::getApp()->data['db_failed'] = $errors;
76
-		} else {
77
-			self::getApp()->data['db_installed'] = true;
78
-		}
79
-	}
80
-
81
-	/**
82
-	 * checks   : array passed to template
83
-	 * title    : string
84
-	 * status   : boolean
85
-	 * required : boolean
86
-	 * help		: string optional
87
-	 */
88
-	private static function addCheck(&$checks, $title, $status, $required, $help) {
89
-		$checks[] = [
90
-			'title' => $title,
91
-			'status' => $status,
92
-			'required' => $required,
93
-			'help'	=> $help,
94
-		];
95
-	}
96
-
97
-	private static function checkPHP(&$phpath, &$checks) {
98
-		$passed = $passed2 = $passed3 = false;
99
-		if (strlen($phpath)) {
100
-			$passed = file_exists($phpath);
101
-		} else {
102
-			$phpath = trim(shell_exec('which php'));
103
-			$passed = strlen($phpath);
104
-		}
105
-		$help = "";
106
-		if (!$passed) {
107
-			$help .= L10n::t('Could not find a command line version of PHP in the web server PATH.'). EOL;
108
-			$help .= L10n::t("If you don't have a command line version of PHP installed on your server, you will not be able to run the background processing. See <a href='https://github.com/friendica/friendica/blob/master/doc/Install.md#set-up-the-worker'>'Setup the worker'</a>") . EOL;
109
-			$help .= EOL . EOL;
110
-			$tpl = get_markup_template('field_input.tpl');
111
-			$help .= replace_macros($tpl, [
112
-				'$field' => ['phpath', L10n::t('PHP executable path'), $phpath, L10n::t('Enter full path to php executable. You can leave this blank to continue the installation.')],
113
-			]);
114
-			$phpath = "";
115
-		}
116
-
117
-		self::addCheck($checks, L10n::t('Command line PHP').($passed?" (<tt>$phpath</tt>)":""), $passed, false, $help);
118
-
119
-		if ($passed) {
120
-			$cmd = "$phpath -v";
121
-			$result = trim(shell_exec($cmd));
122
-			$passed2 = ( strpos($result, "(cli)") !== false);
123
-			list($result) = explode("\n", $result);
124
-			$help = "";
125
-			if (!$passed2) {
126
-				$help .= L10n::t("PHP executable is not the php cli binary \x28could be cgi-fgci version\x29"). EOL;
127
-				$help .= L10n::t('Found PHP version: ')."<tt>$result</tt>";
128
-			}
129
-			self::addCheck($checks, L10n::t('PHP cli binary'), $passed2, true, $help);
130
-		}
131
-
132
-
133
-		if ($passed2) {
134
-			$str = autoname(8);
135
-			$cmd = "$phpath testargs.php $str";
136
-			$result = trim(shell_exec($cmd));
137
-			$passed3 = $result == $str;
138
-			$help = "";
139
-			if (!$passed3) {
140
-				$help .= L10n::t('The command line version of PHP on your system does not have "register_argc_argv" enabled.'). EOL;
141
-				$help .= L10n::t('This is required for message delivery to work.');
142
-			}
143
-			self::addCheck($checks, L10n::t('PHP register_argc_argv'), $passed3, true, $help);
144
-		}
145
-
146
-
147
-	}
148
-
149
-	private static function checkKeys(&$checks) {
150
-
151
-		$help = '';
152
-
153
-		$res = false;
154
-
155
-		if (function_exists('openssl_pkey_new')) {
156
-			$res = openssl_pkey_new([
157
-				'digest_alg'       => 'sha1',
158
-				'private_key_bits' => 4096,
159
-				'encrypt_key'      => false
160
-			]);
161
-		}
162
-
163
-		// Get private key
164
-
165
-		if (! $res) {
166
-			$help .= L10n::t('Error: the "openssl_pkey_new" function on this system is not able to generate encryption keys'). EOL;
167
-			$help .= L10n::t('If running under Windows, please see "http://www.php.net/manual/en/openssl.installation.php".');
168
-		}
169
-		self::addCheck($checks, L10n::t('Generate encryption keys'), $res, true, $help);
170
-
171
-	}
172
-
173
-
174
-	private static function checkFunctions(&$checks) {
175
-		$ck_funcs = [];
176
-		self::addCheck($ck_funcs, L10n::t('libCurl PHP module'), true, true, "");
177
-		self::addCheck($ck_funcs, L10n::t('GD graphics PHP module'), true, true, "");
178
-		self::addCheck($ck_funcs, L10n::t('OpenSSL PHP module'), true, true, "");
179
-		self::addCheck($ck_funcs, L10n::t('PDO or MySQLi PHP module'), true, true, "");
180
-		self::addCheck($ck_funcs, L10n::t('mb_string PHP module'), true, true, "");
181
-		self::addCheck($ck_funcs, L10n::t('XML PHP module'), true, true, "");
182
-		self::addCheck($ck_funcs, L10n::t('iconv PHP module'), true, true, "");
183
-		self::addCheck($ck_funcs, L10n::t('POSIX PHP module'), true, true, "");
184
-
185
-		if (function_exists('apache_get_modules')) {
186
-			if (! in_array('mod_rewrite',apache_get_modules())) {
187
-				self::addCheck($ck_funcs, L10n::t('Apache mod_rewrite module'), false, true, L10n::t('Error: Apache webserver mod-rewrite module is required but not installed.'));
188
-			} else {
189
-				self::addCheck($ck_funcs, L10n::t('Apache mod_rewrite module'), true, true, "");
190
-			}
191
-		}
192
-
193
-		if (! function_exists('curl_init')) {
194
-			$ck_funcs[0]['status'] = false;
195
-			$ck_funcs[0]['help'] = L10n::t('Error: libCURL PHP module required but not installed.');
196
-		}
197
-		if (! function_exists('imagecreatefromjpeg')) {
198
-			$ck_funcs[1]['status'] = false;
199
-			$ck_funcs[1]['help'] = L10n::t('Error: GD graphics PHP module with JPEG support required but not installed.');
200
-		}
201
-		if (! function_exists('openssl_public_encrypt')) {
202
-			$ck_funcs[2]['status'] = false;
203
-			$ck_funcs[2]['help'] = L10n::t('Error: openssl PHP module required but not installed.');
204
-		}
205
-		if (! function_exists('mysqli_connect') && !class_exists('pdo')) {
206
-			$ck_funcs[3]['status'] = false;
207
-			$ck_funcs[3]['help'] = L10n::t('Error: PDO or MySQLi PHP module required but not installed.');
208
-		}
209
-		if (!function_exists('mysqli_connect') && class_exists('pdo') && !in_array('mysql', PDO::getAvailableDrivers())) {
210
-			$ck_funcs[3]['status'] = false;
211
-			$ck_funcs[3]['help'] = L10n::t('Error: The MySQL driver for PDO is not installed.');
212
-		}
213
-		if (! function_exists('mb_strlen')) {
214
-			$ck_funcs[4]['status'] = false;
215
-			$ck_funcs[4]['help'] = L10n::t('Error: mb_string PHP module required but not installed.');
216
-		}
217
-		if (! function_exists('iconv_strlen')) {
218
-			$ck_funcs[6]['status'] = false;
219
-			$ck_funcs[6]['help'] = L10n::t('Error: iconv PHP module required but not installed.');
220
-		}
221
-		if (! function_exists('posix_kill')) {
222
-			$ck_funcs[7]['status'] = false;
223
-			$ck_funcs[7]['help'] = L10n::t('Error: POSIX PHP module required but not installed.');
224
-		}
225
-
226
-		$checks = array_merge($checks, $ck_funcs);
227
-
228
-		// check for XML DOM Documents being able to be generated
229
-		try {
230
-			$xml = new DOMDocument();
231
-		} catch (Exception $e) {
232
-			$ck_funcs[5]['status'] = false;
233
-			$ck_funcs[5]['help'] = L10n::t('Error, XML PHP module required but not installed.');
234
-		}
235
-	}
236
-
237
-
238
-	private static function checkHtConfig(&$checks) {
239
-		$status = true;
240
-		$help = "";
241
-		if ((file_exists('config/.htconfig.php') && !is_writable('.htconfig.php')) ||
242
-			(!file_exists('config/.htconfig.php') && !is_writable('.'))) {
243
-
244
-			$status = false;
245
-			$help = L10n::t('The web installer needs to be able to create a file called ".htconfig.php" in the "config/" folder of your web server and it is unable to do so.') .EOL;
246
-			$help .= L10n::t('This is most often a permission setting, as the web server may not be able to write files in your folder - even if you can.').EOL;
247
-			$help .= L10n::t('At the end of this procedure, we will give you a text to save in a file named .htconfig.php in your Friendica "config/" folder.').EOL;
248
-			$help .= L10n::t('You can alternatively skip this procedure and perform a manual installation. Please see the file "INSTALL.txt" for instructions.').EOL;
249
-		}
250
-
251
-		self::addCheck($checks, L10n::t('config/.htconfig.php is writable'), $status, false, $help);
252
-
253
-	}
254
-
255
-	private static function checkSmarty3(&$checks) {
256
-		$status = true;
257
-		$help = "";
258
-		if (!is_writable('view/smarty3')) {
259
-
260
-			$status = false;
261
-			$help = L10n::t('Friendica uses the Smarty3 template engine to render its web views. Smarty3 compiles templates to PHP to speed up rendering.') .EOL;
262
-			$help .= L10n::t('In order to store these compiled templates, the web server needs to have write access to the directory view/smarty3/ under the Friendica top level folder.').EOL;
263
-			$help .= L10n::t("Please ensure that the user that your web server runs as \x28e.g. www-data\x29 has write access to this folder.").EOL;
264
-			$help .= L10n::t("Note: as a security measure, you should give the web server write access to view/smarty3/ only--not the template files \x28.tpl\x29 that it contains.").EOL;
265
-		}
266
-
267
-		self::addCheck($checks, L10n::t('view/smarty3 is writable'), $status, true, $help);
268
-
269
-	}
270
-
271
-	private static function checkHtAccess(&$checks) {
272
-		$status = true;
273
-		$help = "";
274
-		if (function_exists('curl_init')) {
275
-			$test = Network::fetchUrl(System::baseUrl()."/install/testrewrite");
276
-
277
-			if ($test != "ok") {
278
-				$test = Network::fetchUrl(normalise_link(System::baseUrl()."/install/testrewrite"));
279
-			}
280
-
281
-			if ($test != "ok") {
282
-				$status = false;
283
-				$help = L10n::t('Url rewrite in .htaccess is not working. Check your server configuration.');
284
-			}
285
-			self::addCheck($checks, L10n::t('Url rewrite is working'), $status, true, $help);
286
-		} else {
287
-			// cannot check modrewrite if libcurl is not installed
288
-			/// @TODO Maybe issue warning here?
289
-		}
290
-	}
291
-
292
-	private static function checkImagik(&$checks) {
293
-		$imagick = false;
294
-		$gif = false;
295
-
296
-		if (class_exists('Imagick')) {
297
-			$imagick = true;
298
-			$supported = Image::supportedTypes();
299
-			if (array_key_exists('image/gif', $supported)) {
300
-				$gif = true;
301
-			}
302
-		}
303
-		if ($imagick == false) {
304
-			self::addCheck($checks, L10n::t('ImageMagick PHP extension is not installed'), $imagick, false, "");
305
-		} else {
306
-			self::addCheck($checks, L10n::t('ImageMagick PHP extension is installed'), $imagick, false, "");
307
-			if ($imagick) {
308
-				self::addCheck($checks, L10n::t('ImageMagick supports GIF'), $gif, false, "");
309
-			}
310
-		}
311
-	}
312
-
313
-	private static function loadDatabase() {
314
-		$errors = DBStructure::update(false, true, true);
315
-
316
-		return $errors;
317
-	}
318
-}

+ 1
- 1
util/Doxyfile View File

@@ -2,7 +2,7 @@ INPUT = README.md index.php boot.php testargs.php update.php mod/ object/ includ
2 2
 RECURSIVE = YES
3 3
 PROJECT_NAME = "Friendica"
4 4
 PROJECT_LOGO = images/friendica-64.jpg
5
-EXCLUDE = config/.htconfig.php library/ doc/ .git/ log/ util/zotsh/easywebdav/ addon/ report/ privacy_image_cache/ photo/ proxy/ local/
5
+EXCLUDE = .htconfig.php library/ doc/ .git/ log/ util/zotsh/easywebdav/ addon/ report/ privacy_image_cache/ photo/ proxy/ local/
6 6
 EXCLUDE_PATTERNS = *smarty3* *strings.php*.log *.out *test* 
7 7
 OUTPUT_DIRECTORY = doc
8 8
 GENERATE_HTML = YES

Loading…
Cancel
Save