X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Finstall.php;h=9043459b8625ac02ca9aeca6257167d687d00e29;hb=ddec422de6707809aceb541e1191073b43aec18a;hp=2a791b98c8188ddcdbee99d99939cebea627ae59;hpb=93c33f0eb39ee582bf3763ac1149e8ab01e2bdb9;p=friendica.git diff --git a/mod/install.php b/mod/install.php index 2a791b98c8..9043459b86 100644 --- a/mod/install.php +++ b/mod/install.php @@ -5,6 +5,7 @@ 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'])); @@ -17,11 +18,21 @@ function install_post(&$a) { $db = new dba($dbhost, $dbuser, $dbpass, $dbdata, $true); if(mysqli_connect_errno()) { - notice( t('Could not connect to database.') . EOL); - return; + $db = new dba($dbhost, $dbuser, $dbpass, '', true); + if(! mysql_connect_errno()) { + $r = q("CREATE DATABASE '%s'", + dbesc($dbdata) + ); + if($r) + $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); + + notice( t('Connected to database.') . EOL); $tpl = load_view_file('view/htconfig.tpl'); $txt = replace_macros($tpl,array( @@ -30,6 +41,7 @@ function install_post(&$a) { '$dbpass' => $dbpass, '$dbdata' => $dbdata, '$timezone' => $timezone, + '$urlpath' => $urlpath, '$phpath' => $phpath )); $result = file_put_contents('.htconfig.php', $txt); @@ -67,8 +79,13 @@ function install_post(&$a) { function install_content(&$a) { + $o = ''; + notice( t('Welcome to Friendika.') . EOL); + + check_funcs(); + $o .= check_htconfig(); if(strlen($o)) return $o; @@ -80,10 +97,14 @@ function install_content(&$a) { $o .= check_php($phpath); + $o .= check_keys(); + + require_once('datetime.php'); $tpl = load_view_file('view/install_db.tpl'); $o .= replace_macros($tpl, array( + '$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'), @@ -100,12 +121,60 @@ function check_php(&$phpath) { $o = ''; $phpath = trim(shell_exec('which php')); if(! strlen($phpath)) { - $o .= t('Could not find a command line version of PHP in the web server PATH.'); - $o .= t('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; + + 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; + + return $o; + +} + + +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((x($_SESSION,'sysmsg')) && strlen($_SESSION['sysmsg'])) + notice( t('Please see the file "INSTALL".') . EOL); +} + + function check_htconfig() { if(((file_exists('.htconfig.php')) && (! is_writable('.htconfig.php'))) @@ -142,6 +211,6 @@ function load_database($db) { $errors ++; } } - } + } return $errors; } \ No newline at end of file