X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Finstall.php;h=78e537cfe261a82ec4d0c56fb9ad5d5fe3c0908d;hb=a1a07e7287e9e764912bbd08383cf43503deb9e8;hp=643f9a55ccb2b3c40d64d8fb8d946729770be45d;hpb=a1d593613d737d6f1a694adaddf515187580105c;p=friendica.git diff --git a/mod/install.php b/mod/install.php index 643f9a55cc..78e537cfe2 100644 --- a/mod/install.php +++ b/mod/install.php @@ -12,19 +12,23 @@ function install_post(&$a) { $dbdata = notags(trim($_POST['dbdata'])); $timezone = notags(trim($_POST['timezone'])); $phpath = notags(trim($_POST['phpath'])); + $adminmail = notags(trim($_POST['adminmail'])); require_once("dba.php"); - + unset($db); $db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true); if(mysqli_connect_errno()) { + unset($db); $db = new dba($dbhost, $dbuser, $dbpass, '', true); - if(! mysql_connect_errno()) { + if(! mysqli_connect_errno()) { $r = q("CREATE DATABASE '%s'", dbesc($dbdata) ); - if($r) + 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); @@ -32,9 +36,9 @@ function install_post(&$a) { } } - notice( t('Connected to database.') . EOL); + info( t('Connected to database.') . EOL); - $tpl = load_view_file('view/htconfig.tpl'); + $tpl = get_intltext_template('htconfig.tpl'); $txt = replace_macros($tpl,array( '$dbhost' => $dbhost, '$dbuser' => $dbuser, @@ -42,46 +46,59 @@ function install_post(&$a) { '$dbdata' => $dbdata, '$timezone' => $timezone, '$urlpath' => $urlpath, - '$phpath' => $phpath + '$phpath' => $phpath, + '$adminmail' => $adminmail )); + $result = file_put_contents('.htconfig.php', $txt); if(! $result) { - $a->data = $txt; + $a->data['txt'] = $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_regenerate_id(); - $_SESSION['sysmsg'] = ''; + if($errors) + $a->data['db_failed'] = true; + else + $a->data['db_installed'] = true; - 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.txt".') . EOL ); - goaway($a->get_baseurl() . '/register' ); - } - 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.txt".') . EOL ); - } + return; } function install_content(&$a) { + 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; + } - notice( t('Welcome to Friendika.') . EOL); + 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(); @@ -90,7 +107,7 @@ function install_content(&$a) { if(strlen($o)) return $o; - if(strlen($a->data)) { + if(strlen($a->data['txt'])) { $o .= manual_config($a); return; } @@ -102,8 +119,19 @@ function install_content(&$a) { require_once('datetime.php'); - $tpl = load_view_file('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'), @@ -111,7 +139,8 @@ function install_content(&$a) { '$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; @@ -170,8 +199,11 @@ function check_funcs() { 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('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')) && is_array($_SESSION['sysmsg']) && count($_SESSION['sysmsg'])) notice( t('Please see the file "INSTALL.txt".') . EOL); } @@ -192,7 +224,7 @@ function check_htconfig() { function manual_config(&$a) { - $data = htmlentities($a->data); + $data = htmlentities($a->data['txt']); $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; @@ -214,4 +246,4 @@ function load_database($db) { } } return $errors; -} \ No newline at end of file +}