X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=mod%2Finstall.php;h=27cc6af840e654d10e6f1758120bd70876af415c;hb=2abcf76ec17a9a7754c399cdde9a4449308a4b02;hp=cb23b31ed5132a94748f4df9240a524b39118d56;hpb=35e29e10e69dfb086e990d852aa6b5006ce31d1b;p=friendica.git
diff --git a/mod/install.php b/mod/install.php
index cb23b31ed5..27cc6af840 100644
--- a/mod/install.php
+++ b/mod/install.php
@@ -5,66 +5,103 @@ function install_post(&$a) {
global $db;
+ $urlpath = $a->get_path();
$dbhost = notags(trim($_POST['dbhost']));
$dbuser = notags(trim($_POST['dbuser']));
$dbpass = notags(trim($_POST['dbpass']));
$dbdata = notags(trim($_POST['dbdata']));
$timezone = notags(trim($_POST['timezone']));
$phpath = notags(trim($_POST['phpath']));
+ $adminmail = notags(trim($_POST['adminmail']));
require_once("dba.php");
-
- $db = new dba($dbhost, $dbuser, $dbpass, $dbdata, $true);
-
- if(! $db->getdb()) {
- notice( t('Could not connect to database.') . EOL);
- return;
+ unset($db);
+ $db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true);
+
+ if(mysqli_connect_errno()) {
+ unset($db);
+ $db = new dba($dbhost, $dbuser, $dbpass, '', true);
+ if(! mysqli_connect_errno()) {
+ $r = q("CREATE DATABASE '%s'",
+ dbesc($dbdata)
+ );
+ if($r) {
+ unset($db);
+ $db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true);
+ }
+ }
+ if(mysqli_connect_errno()) {
+ notice( t('Could not create/connect to database.') . EOL);
+ return;
+ }
}
- else
- notice( t('Connected to database.') . EOL);
- $tpl = file_get_contents('view/htconfig.tpl');
+ info( t('Connected to database.') . EOL);
+
+ $tpl = get_intltext_template('htconfig.tpl');
$txt = replace_macros($tpl,array(
'$dbhost' => $dbhost,
'$dbuser' => $dbuser,
'$dbpass' => $dbpass,
'$dbdata' => $dbdata,
'$timezone' => $timezone,
- '$phpath' => $phpath
+ '$urlpath' => $urlpath,
+ '$phpath' => $phpath,
+ '$adminmail' => $adminmail
));
+
$result = file_put_contents('.htconfig.php', $txt);
if(! $result) {
$a->data = $txt;
}
$errors = load_database($db);
- if(! $errors) {
- // Our sessions normally are stored in the database. But as we have only managed
- // to get it bootstrapped milliseconds ago, we have to apply a bit of trickery so
- // that you'll see the following important notice (which is stored in the session).
-
- session_write_close();
- require_once('session.php');
- session_start();
- $_SESSION['sysmsg'] = '';
-
- notice( t('Database import succeeded.') . EOL
- . t('IMPORTANT: You will need to (manually) setup a scheduled task for the poller.') . EOL
- . t('Please see the file INSTALL.') . EOL );
- goaway($a->get_baseurl());
- }
- else {
- $db = null; // start fresh
- notice( t('Database import failed.') . EOL
- . t('You may need to import the file "database.sql" manually using phpmyadmin or mysql.') . EOL
- . t('Please see the file INSTALL.') . EOL );
- }
+
+ if($errors)
+ $a->data['db_failed'] = true;
+ else
+ $a->data['db_installed'] = true;
+
+ return;
}
function install_content(&$a) {
- notice( t('Welcome to the Mistpark Social Network.') . EOL);
+ global $db;
+ $o = '';
+
+ if(x($a->data,'db_installed')) {
+ $o .= '
' . t('Proceed with Installation') . '
';
+ $o .= '';
+ $o .= t('Your Friendika site database has been installed.') . EOL;
+ $o .= t('IMPORTANT: You will need to [manually] setup a scheduled task for the poller.') . EOL ;
+ $o .= t('Please see the file "INSTALL.txt".') . EOL ;
+ $o .= '
';
+ $o .= '' . t('Proceed to registration') . '' ;
+ $o .= '
';
+ return $o;
+ }
+
+ if(x($a->data,'db_failed')) {
+ $o .= t('Database import failed.') . EOL;
+ $o .= t('You may need to import the file "database.sql" manually using phpmyadmin or mysql.') . EOL;
+ $o .= t('Please see the file "INSTALL.txt".') . EOL ;
+ return $o;
+ }
+
+ if($db && $db->connected) {
+ $r = q("SELECT COUNT(*) as `total` FROM `user`");
+ if($r && count($r) && $r[0]['total']) {
+ notice( t('Permission denied.') . EOL);
+ return '';
+ }
+ }
+
+ info( t('Welcome to Friendika.') . EOL);
+
+
+ check_funcs();
$o .= check_htconfig();
if(strlen($o))
@@ -77,61 +114,120 @@ function install_content(&$a) {
$o .= check_php($phpath);
+ $o .= check_keys();
+
+
require_once('datetime.php');
- $tpl = file_get_contents('view/install_db.tpl');
+ $tpl = get_markup_template('install_db.tpl');
$o .= replace_macros($tpl, array(
+ '$lbl_01' => t('Friendika Social Network'),
+ '$lbl_02' => t('Installation'),
+ '$lbl_03' => t('In order to install Friendika we need to know how to connect to your database.'),
+ '$lbl_04' => t('Please contact your hosting provider or site administrator if you have questions about these settings.'),
+ '$lbl_05' => t('The database you specify below should already exist. If it does not, please create it before continuing.'),
+ '$lbl_06' => t('Database Server Name'),
+ '$lbl_07' => t('Database Login Name'),
+ '$lbl_08' => t('Database Login Password'),
+ '$lbl_09' => t('Database Name'),
+ '$lbl_10' => t('Please select a default timezone for your website'),
+ '$lbl_11' => t('Site administrator email address. Your account email address must match this in order to use the web admin panel.'),
+ '$baseurl' => $a->get_baseurl(),
'$tzselect' => ((x($_POST,'timezone')) ? select_timezone($_POST['timezone']) : select_timezone()),
'$submit' => t('Submit'),
'$dbhost' => ((x($_POST,'dbhost')) ? notags(trim($_POST['dbhost'])) : 'localhost'),
'$dbuser' => notags(trim($_POST['dbuser'])),
'$dbpass' => notags(trim($_POST['dbpass'])),
'$dbdata' => notags(trim($_POST['dbdata'])),
- '$phpath' => $phpath
+ '$phpath' => $phpath,
+ '$adminmail' => notags(trim($_POST['adminmail']))
));
return $o;
}
function check_php(&$phpath) {
+ $o = '';
$phpath = trim(shell_exec('which php'));
if(! strlen($phpath)) {
- $o .= <<< EOT
-Could not find a command line version of PHP in the web server PATH. This is required. Please adjust the configuration file .htconfig.php accordingly.
+ $o .= t('Could not find a command line version of PHP in the web server PATH.') . EOL;
+ $o .= t('This is required. Please adjust the configuration file .htconfig.php accordingly.') . EOL;
+ }
+ if(strlen($phpath)) {
+ $str = autoname(8);
+ $cmd = "$phpath testargs.php $str";
+ $result = trim(shell_exec($cmd));
+ if($result != $str) {
+ $o .= t('The command line version of PHP on your system does not have "register_argc_argv" enabled.') . EOL;
+ $o .= t('This is required for message delivery to work.') . EOL;
+ }
+ }
+ return $o;
+
+}
+
+function check_keys() {
+
+ $o = '';
+
+ $res = false;
-EOT;
+ if(function_exists('openssl_pkey_new'))
+ $res=openssl_pkey_new(array(
+ 'digest_alg' => 'sha1',
+ 'private_key_bits' => 4096,
+ 'encrypt_key' => false ));
+
+ // Get private key
+
+ if(! $res) {
+ $o .= t('Error: the "openssl_pkey_new" function on this system is not able to generate encryption keys') . EOL;
+ $o .= t('If running under Windows, please see "http://www.php.net/manual/en/openssl.installation.php".') . EOL;
}
return $o;
+
}
-function check_htconfig() {
- if(((file_exists('.htconfig.php')) && (! is_writable('.htconfig.php')))
- || (! is_writable('.'))) {
+function check_funcs() {
+ if((function_exists('apache_get_modules')) && (! in_array('mod_rewrite',apache_get_modules())))
+ notice( t('Error: Apache webserver mod-rewrite module is required but not installed.') . EOL);
+ if(! function_exists('curl_init'))
+ notice( t('Error: libCURL PHP module required but not installed.') . EOL);
+ if(! function_exists('imagecreatefromjpeg'))
+ notice( t('Error: GD graphics PHP module with JPEG support required but not installed.') . EOL);
+ if(! function_exists('openssl_public_encrypt'))
+ notice( t('Error: openssl PHP module required but not installed.') . EOL);
+ if(! function_exists('mysqli_connect'))
+ notice( t('Error: mysqli PHP module required but not installed.') . EOL);
+ if(! function_exists('mb_strlen'))
+ notice( t('Error: mb_string PHP module required but not installed.') . EOL);
+
+ if((x($_SESSION,'sysmsg')) && strlen($_SESSION['sysmsg']))
+ notice( t('Please see the file "INSTALL.txt".') . EOL);
+}
-$o .= <<< EOT
-The web installer needs to be able to create a file called ".htconfig.php" in the top folder of
-your web server. It is unable to do so. 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).
+function check_htconfig() {
-Please check with your site documentation or support people to see if this situation can be corrected.
-If not, you may be required to perform a manual installation. Please see the file "INSTALL" for instructions.
+ if(((file_exists('.htconfig.php')) && (! is_writable('.htconfig.php')))
+ || (! is_writable('.'))) {
-EOT;
+ $o = 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.');
+ $o .= 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.');
+ $o .= t('Please check with your site documentation or support people to see if this situation can be corrected.');
+ $o .= t('If not, you may be required to perform a manual installation. Please see the file "INSTALL.txt" for instructions.');
}
-return $o;
+ return $o;
}
function manual_config(&$a) {
-$o .= <<< EOT
-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.
-
-
-EOT;
-return $o;
+ $data = htmlentities($a->data);
+ $o = 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.');
+ $o .= "";
+ return $o;
}
@@ -148,6 +244,6 @@ function load_database($db) {
$errors ++;
}
}
- }
+ }
return $errors;
-}
\ No newline at end of file
+}