function install_content(&$a) { global $install_wizard_pass, $db; $o = ''; $wizard_status = ""; $install_title = t('Friendica Social Communications Server - Setup'); if (x($a->data, 'db_conn_failed')) { $install_wizard_pass = 2; $wizard_status = t('Could not connect to database.'); } if (x($a->data, 'db_create_failed')) { $install_wizard_pass = 2; $wizard_status = t('Could not create table.'); } $db_return_text = ""; if (x($a->data, 'db_installed')) { $txt = '<p style="font-size: 130%;">'; $txt .= t('Your Friendica site database has been installed.') . EOL; $db_return_text .= $txt; } if (x($a->data, 'db_failed')) { $txt = t('You may need to import the file "database.sql" manually using phpmyadmin or mysql.') . EOL; $txt .= t('Please see the file "INSTALL.txt".') . EOL . "<hr>"; $txt .= "<pre>" . $a->data['db_failed'] . "</pre>" . EOL; $db_return_text .= $txt; } if ($db && $db->connected) { $r = q("SELECT COUNT(*) as `total` FROM `user`"); if ($r && count($r) && $r[0]['total']) { $tpl = get_markup_template('install.tpl'); return replace_macros($tpl, array('$title' => $install_title, '$pass' => '', '$status' => t('Permission denied.'), '$text' => '')); } } if (x($a->data, 'txt') && strlen($a->data['txt'])) { $db_return_text .= manual_config($a); } if ($db_return_text != "") { $tpl = get_markup_template('install.tpl'); return replace_macros($tpl, array('$title' => $install_title, '$pass' => "", '$text' => $db_return_text . what_next())); } switch ($install_wizard_pass) { case 1: // System check $checks = array(); check_funcs($checks); check_htconfig($checks); check_smarty3($checks); check_keys($checks); if (x($_POST, 'phpath')) { $phpath = notags(trim($_POST['phpath'])); } check_php($phpath, $checks); check_htaccess($checks); function check_passed($v, $c) { if ($c['required']) { $v = $v && $c['status']; } return $v; } $checkspassed = array_reduce($checks, "check_passed", true); $tpl = get_markup_template('install_checks.tpl'); $o .= replace_macros($tpl, array('$title' => $install_title, '$pass' => t('System check'), '$checks' => $checks, '$passed' => $checkspassed, '$see_install' => t('Please see the file "INSTALL.txt".'), '$next' => t('Next'), '$reload' => t('Check again'), '$phpath' => $phpath, '$baseurl' => $a->get_baseurl())); return $o; break; case 2: // Database config $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 = notags(trim($_POST['phpath'])); $tpl = get_markup_template('install_db.tpl'); $o .= replace_macros($tpl, array('$title' => $install_title, '$pass' => t('Database connection'), '$info_01' => t('In order to install Friendica we need to know how to connect to your database.'), '$info_02' => t('Please contact your hosting provider or site administrator if you have questions about these settings.'), '$info_03' => t('The database you specify below should already exist. If it does not, please create it before continuing.'), '$status' => $wizard_status, '$dbhost' => array('dbhost', t('Database Server Name'), $dbhost, ''), '$dbuser' => array('dbuser', t('Database Login Name'), $dbuser, ''), '$dbpass' => array('dbpass', t('Database Login Password'), $dbpass, ''), '$dbdata' => array('dbdata', t('Database Name'), $dbdata, ''), '$adminmail' => array('adminmail', t('Site administrator email address'), $adminmail, t('Your account email address must match this in order to use the web admin panel.')), '$lbl_10' => t('Please select a default timezone for your website'), '$baseurl' => $a->get_baseurl(), '$phpath' => $phpath, '$submit' => t('Submit'))); return $o; break; case 3: // Site settings require_once 'include/datetime.php'; $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 = notags(trim($_POST['phpath'])); $adminmail = notags(trim($_POST['adminmail'])); $timezone = x($_POST, 'timezone') ? $_POST['timezone'] : 'America/Los_Angeles'; $tpl = get_markup_template('install_settings.tpl'); $o .= replace_macros($tpl, array('$title' => $install_title, '$pass' => t('Site settings'), '$status' => $wizard_status, '$dbhost' => $dbhost, '$dbuser' => $dbuser, '$dbpass' => $dbpass, '$dbdata' => $dbdata, '$phpath' => $phpath, '$adminmail' => array('adminmail', t('Site administrator email address'), $adminmail, t('Your account email address must match this in order to use the web admin panel.')), '$timezone' => field_timezone('timezone', t('Please select a default timezone for your website'), $timezone, ''), '$baseurl' => $a->get_baseurl(), '$submit' => t('Submit'))); return $o; break; } }
/** * @brief Get output for the setup page. * * Depending on the state we are currently in it returns different content. * * @param App &$a * @return string parsed HTML output */ function setup_content(&$a) { global $install_wizard_pass, $db; $o = ''; $wizard_status = ''; $install_title = t('$Projectname Server - Setup'); if (x(App::$data, 'db_conn_failed')) { $install_wizard_pass = 2; $wizard_status = t('Could not connect to database.'); } if (x(App::$data, 'url_fail')) { $install_wizard_pass = 3; $wizard_status = t('Could not connect to specified site URL. Possible SSL certificate or DNS issue.'); if (App::$data['url_error']) { $wizard_status .= ' ' . App::$data['url_error']; } } if (x(App::$data, 'db_create_failed')) { $install_wizard_pass = 2; $wizard_status = t('Could not create table.'); } $db_return_text = ''; if (x(App::$data, 'db_installed')) { $txt = '<p style="font-size: 130%;">'; $txt .= t('Your site database has been installed.') . EOL; $db_return_text .= $txt; } if (x(App::$data, 'db_failed')) { $txt = t('You may need to import the file "install/schema_xxx.sql" manually using a database client.') . EOL; $txt .= t('Please see the file "install/INSTALL.txt".') . EOL . "<hr>"; $txt .= "<pre>" . App::$data['db_failed'] . "</pre>" . EOL; $db_return_text .= $txt; } if ($db && $db->connected) { $r = q("SELECT COUNT(*) as `total` FROM `account`"); if ($r && count($r) && $r[0]['total']) { $tpl = get_markup_template('install.tpl'); return replace_macros($tpl, array('$title' => $install_title, '$pass' => '', '$status' => t('Permission denied.'), '$text' => '')); } } if (x(App::$data, 'txt') && strlen(App::$data['txt'])) { $db_return_text .= manual_config($a); } if ($db_return_text != "") { $tpl = get_markup_template('install.tpl'); return replace_macros($tpl, array('$title' => $install_title, '$pass' => '', '$text' => $db_return_text . what_next())); } switch ($install_wizard_pass) { case 1: // System check $checks = array(); check_funcs($checks); check_htconfig($checks); check_store($checks); check_smarty3($checks); check_keys($checks); if (x($_POST, 'phpath')) { $phpath = notags(trim($_POST['phpath'])); } check_php($phpath, $checks); check_phpconfig($checks); check_htaccess($checks); function check_passed($v, $c) { if ($c['required']) { $v = $v && $c['status']; } return $v; } $checkspassed = array_reduce($checks, "check_passed", true); $tpl = get_markup_template('install_checks.tpl'); $o .= replace_macros($tpl, array('$title' => $install_title, '$pass' => t('System check'), '$checks' => $checks, '$passed' => $checkspassed, '$see_install' => t('Please see the file "install/INSTALL.txt".'), '$next' => t('Next'), '$reload' => t('Check again'), '$phpath' => $phpath, '$baseurl' => z_root())); return $o; break; case 2: // Database config $dbhost = x($_POST, 'dbhost') ? notags(trim($_POST['dbhost'])) : '127.0.0.1'; $dbuser = notags(trim($_POST['dbuser'])); $dbport = intval(notags(trim($_POST['dbport']))); $dbpass = notags(trim($_POST['dbpass'])); $dbdata = notags(trim($_POST['dbdata'])); $dbtype = intval(notags(trim($_POST['dbtype']))); $phpath = notags(trim($_POST['phpath'])); $adminmail = notags(trim($_POST['adminmail'])); $siteurl = notags(trim($_POST['siteurl'])); $tpl = get_markup_template('install_db.tpl'); $o .= replace_macros($tpl, array('$title' => $install_title, '$pass' => t('Database connection'), '$info_01' => t('In order to install $Projectname we need to know how to connect to your database.'), '$info_02' => t('Please contact your hosting provider or site administrator if you have questions about these settings.'), '$info_03' => t('The database you specify below should already exist. If it does not, please create it before continuing.'), '$status' => $wizard_status, '$dbhost' => array('dbhost', t('Database Server Name'), $dbhost, t('Default is 127.0.0.1')), '$dbport' => array('dbport', t('Database Port'), $dbport, t('Communication port number - use 0 for default')), '$dbuser' => array('dbuser', t('Database Login Name'), $dbuser, ''), '$dbpass' => array('dbpass', t('Database Login Password'), $dbpass, ''), '$dbdata' => array('dbdata', t('Database Name'), $dbdata, ''), '$dbtype' => array('dbtype', t('Database Type'), $dbtype, '', array(0 => 'MySQL', 1 => 'PostgreSQL')), '$adminmail' => array('adminmail', t('Site administrator email address'), $adminmail, t('Your account email address must match this in order to use the web admin panel.')), '$siteurl' => array('siteurl', t('Website URL'), z_root(), t('Please use SSL (https) URL if available.')), '$lbl_10' => t('Please select a default timezone for your website'), '$baseurl' => z_root(), '$phpath' => $phpath, '$submit' => t('Submit'))); return $o; break; case 3: // Site settings require_once 'include/datetime.php'; $dbhost = x($_POST, 'dbhost') ? notags(trim($_POST['dbhost'])) : '127.0.0.1'; $dbport = intval(notags(trim($_POST['dbuser']))); $dbuser = notags(trim($_POST['dbuser'])); $dbpass = notags(trim($_POST['dbpass'])); $dbdata = notags(trim($_POST['dbdata'])); $dbtype = intval(notags(trim($_POST['dbtype']))); $phpath = notags(trim($_POST['phpath'])); $adminmail = notags(trim($_POST['adminmail'])); $siteurl = notags(trim($_POST['siteurl'])); $timezone = x($_POST, 'timezone') ? $_POST['timezone'] : 'America/Los_Angeles'; $tpl = get_markup_template('install_settings.tpl'); $o .= replace_macros($tpl, array('$title' => $install_title, '$pass' => t('Site settings'), '$status' => $wizard_status, '$dbhost' => $dbhost, '$dbport' => $dbport, '$dbuser' => $dbuser, '$dbpass' => $dbpass, '$dbdata' => $dbdata, '$phpath' => $phpath, '$dbtype' => $dbtype, '$adminmail' => array('adminmail', t('Site administrator email address'), $adminmail, t('Your account email address must match this in order to use the web admin panel.')), '$siteurl' => array('siteurl', t('Website URL'), z_root(), t('Please use SSL (https) URL if available.')), '$advanced' => array('advanced', t('Enable $Projectname <strong>advanced</strong> features?'), 1, t('Some advanced features, while useful - may be best suited for technically proficient audiences')), '$timezone' => array('timezone', t('Please select a default timezone for your website'), $timezone, '', get_timezones()), '$baseurl' => z_root(), '$submit' => t('Submit'))); return $o; break; } }
header("Connection: close"); readfile($target); } else { if ($action === "getchecks") { $php = version_compare(PHP_VERSION, "5.2.1") >= 0; $archive = class_exists("PharData"); $gd = false; if (function_exists("gd_info")) { $gdinfo = gd_info(); $gd = array_key_exists("JPG Support", $gdinfo) && $gdinfo["JPG Support"] || array_key_exists("JPEG Support", $gdinfo) && $gdinfo["JPEG Support"]; } $cache = is_writable($h5ai->getH5aiAbsPath() . "/cache"); $temp = is_writable(sys_get_temp_dir()); $tar = preg_match("/tar\$/", `which tar`) > 0; $zip = preg_match("/zip\$/", `which zip`) > 0; $convert = preg_match("/convert\$/", `which convert`) > 0; $ffmpeg = preg_match("/ffmpeg\$/", `which ffmpeg`) > 0; $du = preg_match("/du\$/", `which du`) > 0; json_exit(array("php" => $php, "cache" => $cache, "thumbs" => $gd, "temp" => $temp, "archive" => $archive, "tar" => $tar, "zip" => $zip, "convert" => $convert, "ffmpeg" => $ffmpeg, "du" => $du)); } else { if ($action === "getentries") { list($href, $content) = check_keys(array("href", "content")); $content = intval($content, 10); json_exit(array("entries" => $h5ai->getEntries($href, $content))); } else { json_fail(100, "unsupported action"); } } } } }
/** * Do an internal self check * @global array $profile * @global array $sreg * @global array $auth_types */ function self_check() { global $profile, $sreg, $auth_types; if (!isset($profile) || !is_array($profile)) { error_500('No configuration found, you shouldn\'t access this file directly.'); } if (version_compare(phpversion(), '4.2.0', 'lt')) { error_500('The required minimum version of PHP is 4.2.0, you are running ' . phpversion()); } $extension_r = array('session', 'pcre'); foreach ($extension_r as $x) { if (!extension_loaded($x)) { @dl($x); } if (!extension_loaded($x)) { error_500("Required extension '{$x}' is missing."); } } $extension_b = array('suhosin'); foreach ($extension_b as $x) { if (extension_loaded($x) & !$profile["allow_{$x}"]) { error_500("phpMyID is not compatible with '{$x}'"); } } // Check required keys for current auth type if (gettype($profile['auth_type']) == 'array') { foreach ($profile['auth_type'] as $type) { if (!isset($auth_types[$type])) { error_500('Configuration Error: Invalid auth_type.'); } check_keys($type); } } else { if (!isset($auth_types[$profile['auth_type']])) { error_500('Configuration Error: Invalid auth_type.'); } check_keys($profile['auth_type']); } if (!isset($sreg) || !is_array($sreg)) { $sreg = array(); } }
function install_content(&$a) { global $db; $o = ''; if (x($a->data, 'db_installed')) { $o .= '<h2>' . t('Proceed with Installation') . '</h2>'; $o .= '<p style="font-size: 130%;">'; $o .= t('Your Friendica 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 .= '<br />'; $o .= '<a href="' . $a->get_baseurl() . '/register' . '">' . t('Proceed to registration') . '</a>'; $o .= '</p>'; 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 Friendica.') . EOL); check_funcs(); $o .= check_htconfig(); if (strlen($o)) { return $o; } if (strlen($a->data['txt'])) { $o .= manual_config($a); return; } $o .= check_php($phpath); $o .= check_keys(); require_once 'datetime.php'; $tpl = get_markup_template('install_db.tpl'); $o .= replace_macros($tpl, array('$lbl_01' => t('Friendica Social Communications Server'), '$lbl_02' => t('Installation'), '$lbl_03' => t('In order to install Friendica 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, '$adminmail' => notags(trim($_POST['adminmail'])))); return $o; }